-
Notifications
You must be signed in to change notification settings - Fork 29
/
walletConnection.ts
79 lines (71 loc) · 2.33 KB
/
walletConnection.ts
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
75
76
77
78
79
import { connectorsForWallets, Wallet } from '@rainbow-me/rainbowkit'
import {
injectedWallet,
rainbowWallet,
walletConnectWallet,
argentWallet,
coinbaseWallet,
ledgerWallet,
metaMaskWallet,
tahoWallet,
trustWallet,
zerionWallet
} from '@rainbow-me/rainbowkit/wallets'
import { Connector, Chain } from 'wagmi'
import { parseQueryParam } from '../parseQueryParam'
const HIGHLIGHTED_WALLET_KEY = 'wallet'
const WALLETS = Object.freeze({
metamask: metaMaskWallet,
walletconnect: walletConnectWallet,
rainbow: rainbowWallet,
injected: injectedWallet,
argent: argentWallet,
coinbase: coinbaseWallet,
ledger: ledgerWallet,
taho: tahoWallet,
trust: trustWallet,
zerion: zerionWallet
})
export const getWalletConnectors = (chains: Chain[]): (() => Connector[]) => {
const projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID
const appName = 'PoolTogether'
const walletGroups: {
groupName: string
wallets: Wallet[]
}[] = []
const defaultWallets = ['metamask', 'walletconnect', 'rainbow', 'injected', 'coinbase']
const moreWallets = ['argent', 'ledger', 'taho', 'trust', 'zerion']
const highlightedWallet = parseQueryParam(HIGHLIGHTED_WALLET_KEY, {
validValues: Object.keys(WALLETS)
})
// Don't highlight solely the injected wallet since it might be something sketchy.
if (!!highlightedWallet && highlightedWallet !== 'injected') {
walletGroups.push({
groupName: 'Recommended',
wallets: [WALLETS[highlightedWallet]({ appName, chains, projectId })]
})
walletGroups.push({
groupName: 'Default',
wallets: defaultWallets
.filter((wallet) => highlightedWallet !== wallet)
.map((wallet) => WALLETS[wallet]({ appName, chains, projectId }))
})
walletGroups.push({
groupName: 'More',
wallets: moreWallets
.filter((wallet) => highlightedWallet !== wallet)
.map((wallet) => WALLETS[wallet]({ appName, chains, projectId }))
})
} else {
walletGroups.push({
groupName: 'Recommended',
wallets: defaultWallets.map((wallet) => WALLETS[wallet]({ appName, chains, projectId }))
})
walletGroups.push({
groupName: 'More',
wallets: moreWallets.map((wallet) => WALLETS[wallet]({ appName, chains, projectId }))
})
}
const connectors = connectorsForWallets(walletGroups)
return connectors
}