diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-05-31 13:28:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-31 13:28:37 +0800 |
commit | ae47da3801634a17eb25e658272f60528cc06ead (patch) | |
tree | 803e4cbaf892092ad9c62e4d4539fc6fcf85c085 /packages/contracts/src/utils | |
parent | 5b31d0aa3635ea524fb42d73cd6c713887dfef6a (diff) | |
parent | a6d669453f9af7993bdd132862fa5d2da18a62f7 (diff) | |
download | dexon-sol-tools-ae47da3801634a17eb25e658272f60528cc06ead.tar dexon-sol-tools-ae47da3801634a17eb25e658272f60528cc06ead.tar.gz dexon-sol-tools-ae47da3801634a17eb25e658272f60528cc06ead.tar.bz2 dexon-sol-tools-ae47da3801634a17eb25e658272f60528cc06ead.tar.lz dexon-sol-tools-ae47da3801634a17eb25e658272f60528cc06ead.tar.xz dexon-sol-tools-ae47da3801634a17eb25e658272f60528cc06ead.tar.zst dexon-sol-tools-ae47da3801634a17eb25e658272f60528cc06ead.zip |
Merge pull request #640 from 0xProject/await-transaction-success
Add awaitTransactionSuccess where needed
Diffstat (limited to 'packages/contracts/src/utils')
-rw-r--r-- | packages/contracts/src/utils/token_registry_wrapper.ts | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/packages/contracts/src/utils/token_registry_wrapper.ts b/packages/contracts/src/utils/token_registry_wrapper.ts index 86daeca62..6e3abb26b 100644 --- a/packages/contracts/src/utils/token_registry_wrapper.ts +++ b/packages/contracts/src/utils/token_registry_wrapper.ts @@ -1,16 +1,21 @@ -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'; + 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<string> { - const tx = this._tokenReg.addToken.sendTransactionAsync( + const txHash = await this._tokenReg.addToken.sendTransactionAsync( token.address as string, token.name, token.symbol, @@ -19,7 +24,8 @@ export class TokenRegWrapper { token.swarmHash, { from }, ); - return tx; + await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); + return txHash; } public async getTokenMetaDataAsync(tokenAddress: string): Promise<Token> { const data = await this._tokenReg.getTokenMetaData.callAsync(tokenAddress); |