From 064608a8ef5c332e09fefaadd3b4c1155d4853c9 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Wed, 30 May 2018 11:10:30 -0700 Subject: Add awaitTransactionSuccess where needed --- packages/contracts/src/utils/token_registry_wrapper.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'packages/contracts/src/utils/token_registry_wrapper.ts') diff --git a/packages/contracts/src/utils/token_registry_wrapper.ts b/packages/contracts/src/utils/token_registry_wrapper.ts index 86daeca62..99f17050a 100644 --- a/packages/contracts/src/utils/token_registry_wrapper.ts +++ b/packages/contracts/src/utils/token_registry_wrapper.ts @@ -4,13 +4,16 @@ import { TokenRegistryContract } from '../contract_wrappers/generated/token_regi import { Token } from './types'; +import { constants } from './constants'; +import { web3Wrapper } from './web3_wrapper'; + export class TokenRegWrapper { private _tokenReg: TokenRegistryContract; constructor(tokenRegContract: TokenRegistryContract) { this._tokenReg = tokenRegContract; } public async addTokenAsync(token: Token, from: string): Promise { - const tx = this._tokenReg.addToken.sendTransactionAsync( + const txHash = await this._tokenReg.addToken.sendTransactionAsync( token.address as string, token.name, token.symbol, @@ -19,7 +22,8 @@ export class TokenRegWrapper { token.swarmHash, { from }, ); - return tx; + await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); + return txHash; } public async getTokenMetaDataAsync(tokenAddress: string): Promise { const data = await this._tokenReg.getTokenMetaData.callAsync(tokenAddress); -- cgit v1.2.3 From a6d669453f9af7993bdd132862fa5d2da18a62f7 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Wed, 30 May 2018 17:54:12 -0700 Subject: Pass in a provider and instantiate a new web3Wrapper in token_registry_wrapper --- packages/contracts/src/utils/token_registry_wrapper.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'packages/contracts/src/utils/token_registry_wrapper.ts') diff --git a/packages/contracts/src/utils/token_registry_wrapper.ts b/packages/contracts/src/utils/token_registry_wrapper.ts index 99f17050a..6e3abb26b 100644 --- a/packages/contracts/src/utils/token_registry_wrapper.ts +++ b/packages/contracts/src/utils/token_registry_wrapper.ts @@ -1,16 +1,18 @@ -import * as Web3 from 'web3'; +import { Provider } from '@0xproject/types'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { TokenRegistryContract } from '../contract_wrappers/generated/token_registry'; import { Token } from './types'; import { constants } from './constants'; -import { web3Wrapper } from './web3_wrapper'; export class TokenRegWrapper { private _tokenReg: TokenRegistryContract; - constructor(tokenRegContract: TokenRegistryContract) { + private _web3Wrapper: Web3Wrapper; + constructor(tokenRegContract: TokenRegistryContract, provider: Provider) { this._tokenReg = tokenRegContract; + this._web3Wrapper = new Web3Wrapper(provider); } public async addTokenAsync(token: Token, from: string): Promise { const txHash = await this._tokenReg.addToken.sendTransactionAsync( @@ -22,7 +24,7 @@ export class TokenRegWrapper { token.swarmHash, { from }, ); - await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); + await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); return txHash; } public async getTokenMetaDataAsync(tokenAddress: string): Promise { -- cgit v1.2.3