1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

Use provided Web3 provider on Web3 browsers. #225

This commit is contained in:
Pedro Gutiérrez 2019-05-15 13:56:21 +02:00 committed by Pedro Gutiérrez
parent 5910552f20
commit 46ff37c2eb

View File

@ -9,8 +9,11 @@ export default class Web3Provider {
*/
public static getWeb3(config: Partial<Config> = {}): Web3 {
if (!this.instances.has(config.nodeUri)) {
const web3Provider = config.web3Provider || new Web3.providers.HttpProvider(config.nodeUri)
this.instances.set(config.nodeUri, new Web3(Web3.givenProvider || web3Provider))
this.instances.set(config.nodeUri, new Web3(
config.web3Provider
|| Web3.givenProvider
|| new Web3.providers.HttpProvider(config.nodeUri),
))
}
return this.instances.get(config.nodeUri)