aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/blockchain.ts
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-07-14 02:15:50 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-07-14 02:15:50 +0800
commitb70f5d1a1efcb3b07673aa3b4bc7bc2318f55462 (patch)
treed011565b1c95d4682381f8f573afadf98911e396 /packages/website/ts/blockchain.ts
parentc5fcdd06579b67b5b129749474acd9a4d1d4db65 (diff)
parent26363931ed8ba35a55073d00c4fe128c7e616acc (diff)
downloaddexon-sol-tools-b70f5d1a1efcb3b07673aa3b4bc7bc2318f55462.tar
dexon-sol-tools-b70f5d1a1efcb3b07673aa3b4bc7bc2318f55462.tar.gz
dexon-sol-tools-b70f5d1a1efcb3b07673aa3b4bc7bc2318f55462.tar.bz2
dexon-sol-tools-b70f5d1a1efcb3b07673aa3b4bc7bc2318f55462.tar.lz
dexon-sol-tools-b70f5d1a1efcb3b07673aa3b4bc7bc2318f55462.tar.xz
dexon-sol-tools-b70f5d1a1efcb3b07673aa3b4bc7bc2318f55462.tar.zst
dexon-sol-tools-b70f5d1a1efcb3b07673aa3b4bc7bc2318f55462.zip
Merge branch 'v2-prototype' of https://github.com/0xProject/0x-monorepo into bug/website/txhash-error
Diffstat (limited to 'packages/website/ts/blockchain.ts')
-rw-r--r--packages/website/ts/blockchain.ts31
1 files changed, 12 insertions, 19 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index 1003cbd06..e8168d975 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -15,8 +15,9 @@ import {
ledgerEthereumBrowserClientFactoryAsync,
LedgerSubprovider,
RedundantSubprovider,
+ RPCSubprovider,
SignerSubprovider,
- Subprovider,
+ Web3ProviderEngine,
} from '@0xproject/subproviders';
import {
BlockParam,
@@ -60,9 +61,7 @@ import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants';
import { errorReporter } from 'ts/utils/error_reporter';
import { utils } from 'ts/utils/utils';
-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';
@@ -148,7 +147,7 @@ export class Blockchain {
if (!isU2FSupported) {
throw new Error('Cannot update providerType to LEDGER without U2F support');
}
- const provider = new ProviderEngine();
+ const provider = new Web3ProviderEngine();
const ledgerWalletConfigs = {
networkId: networkIdIfExists,
ledgerEthereumClientFactoryAsync: ledgerEthereumBrowserClientFactoryAsync,
@@ -157,25 +156,21 @@ export class Blockchain {
provider.addProvider(ledgerSubprovider);
provider.addProvider(new FilterSubprovider());
const rpcSubproviders = _.map(configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkIdIfExists], publicNodeUrl => {
- return new RpcSubprovider({
- rpcUrl: publicNodeUrl,
- });
+ return new RPCSubprovider(publicNodeUrl);
});
- provider.addProvider(new RedundantSubprovider(rpcSubproviders as Subprovider[]));
+ provider.addProvider(new RedundantSubprovider(rpcSubproviders));
provider.start();
return [provider, ledgerSubprovider];
} else if (doesInjectedWeb3Exist && isPublicNodeAvailableForNetworkId) {
// We catch all requests involving a users account and send it to the injectedWeb3
// instance. All other requests go to the public hosted node.
- const provider = new ProviderEngine();
+ const provider = new Web3ProviderEngine();
provider.addProvider(new SignerSubprovider(injectedWeb3.currentProvider));
provider.addProvider(new FilterSubprovider());
const rpcSubproviders = _.map(publicNodeUrlsIfExistsForNetworkId, publicNodeUrl => {
- return new RpcSubprovider({
- rpcUrl: publicNodeUrl,
- });
+ return new RPCSubprovider(publicNodeUrl);
});
- provider.addProvider(new RedundantSubprovider(rpcSubproviders as Subprovider[]));
+ provider.addProvider(new RedundantSubprovider(rpcSubproviders));
provider.start();
return [provider, undefined];
} else if (doesInjectedWeb3Exist) {
@@ -185,15 +180,13 @@ export class Blockchain {
// If no injectedWeb3 instance, all requests fallback to our public hosted mainnet/testnet node
// We do this so that users can still browse the 0x Portal DApp even if they do not have web3
// injected into their browser.
- const provider = new ProviderEngine();
+ const provider = new Web3ProviderEngine();
provider.addProvider(new FilterSubprovider());
const networkId = constants.NETWORK_ID_MAINNET;
const rpcSubproviders = _.map(configs.PUBLIC_NODE_URLS_BY_NETWORK_ID[networkId], publicNodeUrl => {
- return new RpcSubprovider({
- rpcUrl: publicNodeUrl,
- });
+ return new RPCSubprovider(publicNodeUrl);
});
- provider.addProvider(new RedundantSubprovider(rpcSubproviders as Subprovider[]));
+ provider.addProvider(new RedundantSubprovider(rpcSubproviders));
provider.start();
return [provider, undefined];
}
@@ -794,7 +787,7 @@ export class Blockchain {
return tokenByAddress;
}
private async _onPageLoadInitFireAndForgetAsync(): Promise<void> {
- await utils.onPageLoadAsync(); // wait for page to load
+ await utils.onPageLoadPromise; // wait for page to load
const networkIdIfExists = await Blockchain._getInjectedWeb3ProviderNetworkIdIfExistsAsync();
this.networkId = !_.isUndefined(networkIdIfExists) ? networkIdIfExists : constants.NETWORK_ID_MAINNET;
const injectedWeb3IfExists = Blockchain._getInjectedWeb3();