From 78f0ab36823127b67c1ea24b7245c51ba814b16a Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 27 Nov 2017 22:23:51 -0600 Subject: Last remaining website fixes --- packages/0x.js/test/exchange_wrapper_test.ts | 2 +- packages/0x.js/test/token_wrapper_test.ts | 2 +- packages/website/ts/blockchain.ts | 16 +++++++++------- .../website/ts/subproviders/redundant_rpc_subprovider.ts | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) (limited to 'packages') diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts index f6c823cc4..14559c706 100644 --- a/packages/0x.js/test/exchange_wrapper_test.ts +++ b/packages/0x.js/test/exchange_wrapper_test.ts @@ -680,7 +680,7 @@ describe('ExchangeWrapper', () => { await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelTakerAmountInBaseUnits); })().catch(done); }); - it('Outstanding subscriptions are cancelled when zeroEx.setProviderAsync called', (done: DoneCallback) => { + it('Outstanding subscriptions are cancelled when zeroEx.setProvider called', (done: DoneCallback) => { (async () => { const callbackNeverToBeCalled = (err: Error, logEvent: DecodedLogEvent) => { diff --git a/packages/0x.js/test/token_wrapper_test.ts b/packages/0x.js/test/token_wrapper_test.ts index cc61c2324..c853fe0c2 100644 --- a/packages/0x.js/test/token_wrapper_test.ts +++ b/packages/0x.js/test/token_wrapper_test.ts @@ -398,7 +398,7 @@ describe('TokenWrapper', () => { await zeroEx.token.setAllowanceAsync(tokenAddress, coinbase, addressWithoutFunds, allowanceAmount); })().catch(done); }); - it('Outstanding subscriptions are cancelled when zeroEx.setProviderAsync called', (done: DoneCallback) => { + it('Outstanding subscriptions are cancelled when zeroEx.setProvider called', (done: DoneCallback) => { (async () => { const callbackNeverToBeCalled = (err: Error, logEvent: DecodedLogEvent) => { done(new Error('Expected this subscription to have been cancelled')); diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts index fbe12ee75..38a2ef532 100644 --- a/packages/website/ts/blockchain.ts +++ b/packages/website/ts/blockchain.ts @@ -217,7 +217,7 @@ export class Blockchain { this.web3Wrapper.destroy(); const shouldPollUserAddress = false; this.web3Wrapper = new Web3Wrapper(this.dispatcher, provider, this.networkId, shouldPollUserAddress); - await this.zeroEx.setProviderAsync(provider); + this.zeroEx.setProvider(provider, networkId); await this.postInstantiationOrUpdatingProviderZeroExAsync(); break; } @@ -229,7 +229,7 @@ export class Blockchain { provider = this.cachedProvider; const shouldPollUserAddress = true; this.web3Wrapper = new Web3Wrapper(this.dispatcher, provider, this.networkId, shouldPollUserAddress); - await this.zeroEx.setProviderAsync(provider); + this.zeroEx.setProvider(provider, this.networkId); await this.postInstantiationOrUpdatingProviderZeroExAsync(); delete this.ledgerSubProvider; delete this.cachedProvider; @@ -612,7 +612,7 @@ export class Blockchain { return tokenByAddress; } private async onPageLoadInitFireAndForgetAsync() { - await this.onPageLoadAsync(); // wait for page to load + await Blockchain.onPageLoadAsync(); // wait for page to load // Hack: We need to know the networkId the injectedWeb3 is connected to (if it is defined) in // order to properly instantiate the web3Wrapper. Since we must use the async call, we cannot @@ -630,8 +630,10 @@ export class Blockchain { } } - const provider = await this.getProviderAsync(injectedWeb3, networkId); - this.zeroEx = new ZeroEx(provider); + const provider = await Blockchain.getProviderAsync(injectedWeb3, networkId); + this.zeroEx = new ZeroEx(provider, { + networkId, + }); this.updateProviderName(injectedWeb3); const shouldPollUserAddress = true; this.web3Wrapper = new Web3Wrapper(this.dispatcher, provider, networkId, shouldPollUserAddress); @@ -641,12 +643,12 @@ export class Blockchain { // of the ZeroEx instance. private async postInstantiationOrUpdatingProviderZeroExAsync() { utils.assert(!_.isUndefined(this.zeroEx), 'ZeroEx must be instantiated.'); - this.exchangeAddress = await this.zeroEx.exchange.getContractAddressAsync(); + this.exchangeAddress = await this.zeroEx.exchange.getContractAddress(); } private updateProviderName(injectedWeb3: Web3) { const doesInjectedWeb3Exist = !_.isUndefined(injectedWeb3); const providerName = doesInjectedWeb3Exist ? - this.getNameGivenProvider(injectedWeb3.currentProvider) : + Blockchain.getNameGivenProvider(injectedWeb3.currentProvider) : constants.PUBLIC_PROVIDER_NAME; this.dispatcher.updateInjectedProviderName(providerName); } diff --git a/packages/website/ts/subproviders/redundant_rpc_subprovider.ts b/packages/website/ts/subproviders/redundant_rpc_subprovider.ts index 74675d910..8dffd4437 100644 --- a/packages/website/ts/subproviders/redundant_rpc_subprovider.ts +++ b/packages/website/ts/subproviders/redundant_rpc_subprovider.ts @@ -33,7 +33,7 @@ export class RedundantRPCSubprovider extends Subprovider { end: (err?: Error, data?: any) => void): Promise { const rpcsCopy = this.rpcs.slice(); try { - const data = await this.firstSuccessAsync(rpcsCopy, payload, next); + const data = await RedundantRPCSubprovider.firstSuccessAsync(rpcsCopy, payload, next); end(null, data); } catch (err) { end(err); -- cgit v1.2.3