generated from web3/web3.js-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: configure prettier and eslint for react app
- Loading branch information
Showing
31 changed files
with
331 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
{ | ||
"trailingComma": "all" | ||
"semi": true, | ||
"trailingComma": "all", | ||
"singleQuote": true, | ||
"printWidth": 90, | ||
"tabWidth": 2, | ||
"endOfLine": "auto", | ||
"bracketSpacing": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
extends: '@chainsafe/eslint-config/frontend-react', | ||
rules: { | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useContext } from 'react'; | ||
|
||
import { AccountContext, type IAccountContext } from '../web3/AccountContext'; | ||
|
||
import { AccountDetail } from './AccountDetail'; | ||
|
||
export function Accounts() { | ||
const accountContext: IAccountContext = useContext(AccountContext); | ||
|
||
return ( | ||
<> | ||
<h2>Accounts</h2> | ||
<div> | ||
{accountContext.selectedAccount === undefined ? ( | ||
<button onClick={accountContext.requestAccounts}>Connect Accounts</button> | ||
) : ( | ||
<> | ||
<h3>Selected Account</h3> | ||
<AccountDetail address={accountContext.selectedAccount} /> | ||
{accountContext.accounts.length > 1 ? ( | ||
<> | ||
<h3>Other Accounts</h3> | ||
{accountContext.accounts.slice(1).map((account: string) => ( | ||
<AccountDetail address={account} key={account} /> | ||
))} | ||
</> | ||
) : null} | ||
</> | ||
)} | ||
</div> | ||
</> | ||
); | ||
} |
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
packages/example-react-app/src/components/ProviderButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { useContext } from 'react'; | ||
import type { EIP6963ProviderDetail } from 'web3'; | ||
|
||
import type { IWeb3Context } from '../web3/Web3Context'; | ||
import { Web3Context } from '../web3/Web3Context'; | ||
|
||
import './ProviderButton.css'; | ||
|
||
export function ProviderButton({ provider }: { provider: EIP6963ProviderDetail }) { | ||
const web3Context: IWeb3Context = useContext(Web3Context); | ||
|
||
return ( | ||
<button onClick={() => web3Context.setCurrentProvider(provider)}> | ||
<img src={provider.info.icon} alt={provider.info.name} width="35" /> | ||
<span> {provider.info.name}</span> | ||
</button> | ||
); | ||
} |
Oops, something went wrong.