-
Notifications
You must be signed in to change notification settings - Fork 41
/
connectors.ts
68 lines (60 loc) · 1.71 KB
/
connectors.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
import {UAuthConnector} from '@uauth/web3-react'
import {initializeConnector, Web3ReactHooks} from '@web3-react/core'
import { CoinbaseWallet } from '@web3-react/coinbase-wallet'
import {MetaMask} from '@web3-react/metamask'
import {Connector, Web3ReactStore} from '@web3-react/types';
import {WalletConnect} from '@web3-react/walletconnect'
const mainnetUrl = `https://mainnet.infura.io/v3/${process.env.REACT_APP_INFURA_ID!}`;
//
// MetaMask connector
//
const metaMask = initializeConnector<Connector>((actions) => new MetaMask({ actions }));
//
// WalletConnect connector
//
const rbcObj = {
1: mainnetUrl
};
const walletConnect = initializeConnector<Connector>(
(actions) =>
new WalletConnect({
actions,
options: {
rpc: rbcObj,
qrcode: true,
},
})
)
//
// Coinbase connector
//
export const coinbase = initializeConnector<CoinbaseWallet>(
(actions) =>
new CoinbaseWallet({
actions,
options: {
url: mainnetUrl,
appName: 'uauth',
},
})
)
const uauth = initializeConnector<Connector>(
(actions) => new UAuthConnector({
actions,
options: {
clientID: process.env.REACT_APP_CLIENT_ID!,
redirectUri: process.env.REACT_APP_REDIRECT_URI!,
// Scope must include openid and wallet
scope: 'openid wallet',
// Injected/metamask and walletconnect connectors are required
connectors: {injected: metaMask[0], walletconnect: walletConnect[0]}
},
})
)
const connectors: Record<string, [Connector, Web3ReactHooks] | [Connector, Web3ReactHooks, Web3ReactStore]> = {
"Login with Unstoppable": uauth,
"MetaMask": metaMask,
"WalletConnect": walletConnect,
"Coinbase": coinbase,
}
export default connectors