-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathCard.tsx
74 lines (71 loc) · 2.28 KB
/
Card.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import type { CoinbaseWallet } from '@web3-react/coinbase-wallet'
import type { Web3ReactHooks } from '@web3-react/core'
import type { GnosisSafe } from '@web3-react/gnosis-safe'
import type { MetaMask } from '@web3-react/metamask'
import type { Network } from '@web3-react/network'
import type { WalletConnect } from '@web3-react/walletconnect'
import type { WalletConnect as WalletConnectV2 } from '@web3-react/walletconnect-v2'
import type { OKXWallet } from '../../packages/okx/dist/index'
import { getName } from '../utils'
import { Accounts } from './Accounts'
import { Chain } from './Chain'
import { ConnectWithSelect } from './ConnectWithSelect'
import { Status } from './Status'
interface Props {
connector: MetaMask | WalletConnect | WalletConnectV2 | CoinbaseWallet | Network | GnosisSafe | OKXWallet
activeChainId: ReturnType<Web3ReactHooks['useChainId']>
chainIds?: ReturnType<Web3ReactHooks['useChainId']>[]
isActivating: ReturnType<Web3ReactHooks['useIsActivating']>
isActive: ReturnType<Web3ReactHooks['useIsActive']>
error: Error | undefined
setError: (error: Error | undefined) => void
ENSNames: ReturnType<Web3ReactHooks['useENSNames']>
provider?: ReturnType<Web3ReactHooks['useProvider']>
accounts?: string[]
}
export function Card({
connector,
activeChainId,
chainIds,
isActivating,
isActive,
error,
setError,
ENSNames,
accounts,
provider,
}: Props) {
return (
<div
style={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
width: '20rem',
padding: '1rem',
margin: '1rem',
overflow: 'auto',
border: '1px solid',
borderRadius: '1rem',
}}
>
<b>{getName(connector)}</b>
<div style={{ marginBottom: '1rem' }}>
<Status isActivating={isActivating} isActive={isActive} error={error} />
</div>
<Chain chainId={activeChainId} />
<div style={{ marginBottom: '1rem' }}>
<Accounts accounts={accounts} provider={provider} ENSNames={ENSNames} />
</div>
<ConnectWithSelect
connector={connector}
activeChainId={activeChainId}
chainIds={chainIds}
isActivating={isActivating}
isActive={isActive}
error={error}
setError={setError}
/>
</div>
)
}