-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathLedgerCard.tsx
More file actions
44 lines (35 loc) · 1.1 KB
/
LedgerCard.tsx
File metadata and controls
44 lines (35 loc) · 1.1 KB
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
import { useEffect, useState } from 'react'
import { MAINNET_CHAINS } from '../../chains'
import { hooks, ledger } from '../../connectors/ledger'
import { Card } from '../Card'
const CHAIN_IDS = Object.keys(MAINNET_CHAINS).map(Number)
const { useChainId, useAccounts, useIsActivating, useIsActive, useProvider, useENSNames } = hooks
export default function LedgerCard() {
const chainId = useChainId()
const accounts = useAccounts()
const isActivating = useIsActivating()
const isActive = useIsActive()
const provider = useProvider()
const ENSNames = useENSNames(provider)
const [error, setError] = useState(undefined)
// attempt to connect eagerly on mount
useEffect(() => {
ledger.connectEagerly().catch((error) => {
console.debug('Failed to connect eagerly to Ledger', error)
})
}, [])
return (
<Card
connector={ledger}
activeChainId={chainId}
chainIds={CHAIN_IDS}
isActivating={isActivating}
isActive={isActive}
error={error}
setError={setError}
accounts={accounts}
provider={provider}
ENSNames={ENSNames}
/>
)
}