aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/blockchain.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-07-17 18:06:35 +0800
committerFabio Berger <me@fabioberger.com>2018-07-17 18:06:35 +0800
commit03a6a088c5f1a086c1f3f02a0a70edaea3603860 (patch)
treebbe67afd2ad3d902444da65964c7401c9d38d63d /packages/website/ts/blockchain.ts
parent1e787a764615bd3df839f2cb117b711be297b9d5 (diff)
parenta9038f2afc974cecf567a9aef50267d29a995e02 (diff)
downloaddexon-sol-tools-03a6a088c5f1a086c1f3f02a0a70edaea3603860.tar
dexon-sol-tools-03a6a088c5f1a086c1f3f02a0a70edaea3603860.tar.gz
dexon-sol-tools-03a6a088c5f1a086c1f3f02a0a70edaea3603860.tar.bz2
dexon-sol-tools-03a6a088c5f1a086c1f3f02a0a70edaea3603860.tar.lz
dexon-sol-tools-03a6a088c5f1a086c1f3f02a0a70edaea3603860.tar.xz
dexon-sol-tools-03a6a088c5f1a086c1f3f02a0a70edaea3603860.tar.zst
dexon-sol-tools-03a6a088c5f1a086c1f3f02a0a70edaea3603860.zip
Merge branch 'v2-prototype' into fix-order-watcher
* v2-prototype: (39 commits) Add chris to website Fix ocean link Move update onboarding step tracking to onboarding flow code Bump npm-run-all from 4.1.2 to 4.1.3 Move format to helper function Fix linter Add assertion to make sure caller to fetchAsync isn't trying to set timeout in a context-specific way Fix linter issues Remove unused import Switch conditional Update yarn.lock and artifact Fix abi-gen tests to not rely on sleep, since it causes intermittent failures Add missing assertion Move type defs to typescript-typingsd Fix linter Make createFinalPayload protected Replace process.browser with detect-node library Export Web3ProviderEngine and RPCSubprovider from 0x.js Export Web3ProviderEngine from subproviders package Update deps ...
Diffstat (limited to 'packages/website/ts/blockchain.ts')
-rw-r--r--packages/website/ts/blockchain.ts38
1 files changed, 15 insertions, 23 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index 0e6698318..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];
}
@@ -571,7 +564,7 @@ export class Blockchain {
configs.DEFAULT_TRACKED_TOKEN_SYMBOLS,
)}) not found in tokenRegistry: ${JSON.stringify(tokenRegistryTokens)}`,
);
- await errorReporter.reportAsync(err);
+ errorReporter.report(err);
return;
}
if (_.isEmpty(trackedTokensByAddress)) {
@@ -682,8 +675,7 @@ export class Blockchain {
// Note: it's not entirely clear from the documentation which
// errors will be thrown by `watch`. For now, let's log the error
// to rollbar and stop watching when one occurs
- // tslint:disable-next-line:no-floating-promises
- errorReporter.reportAsync(err); // fire and forget
+ errorReporter.report(err); // fire and forget
return;
} else {
const decodedLog = decodedLogEvent.log;
@@ -795,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();
@@ -915,7 +907,7 @@ export class Blockchain {
if (_.includes(errMsg, 'not been deployed to detected network')) {
throw new Error(BlockchainCallErrs.ContractDoesNotExist);
} else {
- await errorReporter.reportAsync(err);
+ errorReporter.report(err);
throw new Error(BlockchainCallErrs.UnhandledError);
}
}