diff options
author | Fabio Berger <me@fabioberger.com> | 2018-04-06 14:46:27 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-04-06 14:46:27 +0800 |
commit | 22fa5a57a588c3c5c2a72ec5ef539797c2847688 (patch) | |
tree | 4ecfb7ff51b4f41213c571c13dcb55b650671b0f /packages/website | |
parent | e30c76b7430d8518319eb7d90c7d70ef7c7f6c8d (diff) | |
download | dexon-0x-contracts-22fa5a57a588c3c5c2a72ec5ef539797c2847688.tar dexon-0x-contracts-22fa5a57a588c3c5c2a72ec5ef539797c2847688.tar.gz dexon-0x-contracts-22fa5a57a588c3c5c2a72ec5ef539797c2847688.tar.bz2 dexon-0x-contracts-22fa5a57a588c3c5c2a72ec5ef539797c2847688.tar.lz dexon-0x-contracts-22fa5a57a588c3c5c2a72ec5ef539797c2847688.tar.xz dexon-0x-contracts-22fa5a57a588c3c5c2a72ec5ef539797c2847688.tar.zst dexon-0x-contracts-22fa5a57a588c3c5c2a72ec5ef539797c2847688.zip |
Refactor RedundantRpcSubprovider into RedundantSubprovider
Diffstat (limited to 'packages/website')
-rw-r--r-- | packages/website/ts/blockchain.ts | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts index fd34ab82d..7d79542a3 100644 --- a/packages/website/ts/blockchain.ts +++ b/packages/website/ts/blockchain.ts @@ -21,7 +21,8 @@ import { ledgerEthereumBrowserClientFactoryAsync, LedgerSubprovider, LedgerWalletSubprovider, - RedundantRPCSubprovider, + RedundantSubprovider, + Subprovider, } from '@0xproject/subproviders'; import { Provider } from '@0xproject/types'; import { BigNumber, intervalUtils, logUtils, promisify } from '@0xproject/utils'; @@ -54,6 +55,7 @@ import { utils } from 'ts/utils/utils'; import Web3 = require('web3'); import ProviderEngine = require('web3-provider-engine'); import FilterSubprovider = require('web3-provider-engine/subproviders/filters'); +import RpcSubprovider = require('web3-provider-engine/subproviders/rpc'); import * as MintableArtifacts from '../contracts/Mintable.json'; @@ -98,7 +100,12 @@ export class Blockchain { provider = new ProviderEngine(); provider.addProvider(new InjectedWeb3Subprovider(injectedWeb3.currentProvider)); provider.addProvider(new FilterSubprovider()); - provider.addProvider(new RedundantRPCSubprovider(publicNodeUrlsIfExistsForNetworkId)); + const rpcSubproviders = _.map(publicNodeUrlsIfExistsForNetworkId, publicNodeUrl => { + return new RpcSubprovider({ + rpcUrl: publicNodeUrl, + }); + }); + provider.addProvider(new RedundantSubprovider(rpcSubproviders as Subprovider[])); provider.start(); } else if (doesInjectedWeb3Exist) { // Since no public node for this network, all requests go to injectedWeb3 instance @@ -110,7 +117,12 @@ export class Blockchain { provider = new ProviderEngine(); provider.addProvider(new FilterSubprovider()); const networkId = configs.IS_MAINNET_ENABLED ? constants.NETWORK_ID_MAINNET : constants.NETWORK_ID_KOVAN; - provider.addProvider(new RedundantRPCSubprovider(configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkId])); + const rpcSubproviders = _.map(configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkId], publicNodeUrl => { + return new RpcSubprovider({ + rpcUrl: publicNodeUrl, + }); + }); + provider.addProvider(new RedundantSubprovider(rpcSubproviders as Subprovider[])); provider.start(); } @@ -201,7 +213,12 @@ export class Blockchain { this._ledgerSubprovider = new LedgerSubprovider(ledgerWalletConfigs); provider.addProvider(this._ledgerSubprovider); provider.addProvider(new FilterSubprovider()); - provider.addProvider(new RedundantRPCSubprovider(configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkId])); + const rpcSubproviders = _.map(configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkId], publicNodeUrl => { + return new RpcSubprovider({ + rpcUrl: publicNodeUrl, + }); + }); + provider.addProvider(new RedundantSubprovider(rpcSubproviders as Subprovider[])); provider.start(); this.networkId = networkId; this._dispatcher.updateNetworkId(this.networkId); |