(network: string, mnemonic?: string)
| 7 | const BRIDGE = 'https://safe-walletconnect.gnosis.io/'; |
| 8 | |
| 9 | export async function getWeb3(network: string, mnemonic?: string): Promise<Web3> { |
| 10 | if (mnemonic) { |
| 11 | return new Web3( |
| 12 | new HDWalletProvider({ |
| 13 | chainId: networkIds[network], |
| 14 | mnemonic: { |
| 15 | phrase: mnemonic, |
| 16 | }, |
| 17 | providerOrUrl: new HttpProvider(await getConstant('rpcNode', network)), |
| 18 | }) |
| 19 | ); |
| 20 | } else { |
| 21 | let provider = new WalletConnectProvider({ |
| 22 | clientMeta: { |
| 23 | description: '', |
| 24 | url: 'http://localhost:3000', |
| 25 | icons: [], |
| 26 | name: 'Cardstack', |
| 27 | }, |
| 28 | rpc: { |
| 29 | [networkIds[network]]: getConstantByNetwork('rpcNode', network), |
| 30 | }, |
| 31 | bridge: BRIDGE, |
| 32 | }); |
| 33 | await provider.enable(); |
| 34 | return new Web3((provider as unknown) as AbstractProvider); |
| 35 | } |
| 36 | } |
no test coverage detected