diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-07-17 19:26:49 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-07-17 19:26:49 +0800 |
commit | 28a9a8c3809a63510d2cddf7f9eeaf74635b08ad (patch) | |
tree | b9d76d042f80b1a1b7d59270f508c9c0610010e2 | |
parent | 6c2796b433257806efd294318e5f46c8a020184c (diff) | |
download | dexon-sol-tools-28a9a8c3809a63510d2cddf7f9eeaf74635b08ad.tar dexon-sol-tools-28a9a8c3809a63510d2cddf7f9eeaf74635b08ad.tar.gz dexon-sol-tools-28a9a8c3809a63510d2cddf7f9eeaf74635b08ad.tar.bz2 dexon-sol-tools-28a9a8c3809a63510d2cddf7f9eeaf74635b08ad.tar.lz dexon-sol-tools-28a9a8c3809a63510d2cddf7f9eeaf74635b08ad.tar.xz dexon-sol-tools-28a9a8c3809a63510d2cddf7f9eeaf74635b08ad.tar.zst dexon-sol-tools-28a9a8c3809a63510d2cddf7f9eeaf74635b08ad.zip |
Await transactions in fillScenarios
-rw-r--r-- | packages/fill-scenarios/src/constants.ts | 1 | ||||
-rw-r--r-- | packages/fill-scenarios/src/fill_scenarios.ts | 13 |
2 files changed, 9 insertions, 5 deletions
diff --git a/packages/fill-scenarios/src/constants.ts b/packages/fill-scenarios/src/constants.ts index ec2fe744a..5661b059f 100644 --- a/packages/fill-scenarios/src/constants.ts +++ b/packages/fill-scenarios/src/constants.ts @@ -1,3 +1,4 @@ export const constants = { + AWAIT_TRANSACTION_MINED_MS: 0, NULL_ADDRESS: '0x0000000000000000000000000000000000000000', }; diff --git a/packages/fill-scenarios/src/fill_scenarios.ts b/packages/fill-scenarios/src/fill_scenarios.ts index 9f5218274..84c5fbc27 100644 --- a/packages/fill-scenarios/src/fill_scenarios.ts +++ b/packages/fill-scenarios/src/fill_scenarios.ts @@ -130,12 +130,13 @@ export class FillScenarios { 'exchangeAddress', ]) as OrderWithoutExchangeAddress; - await exchangeInstance.fillOrder.sendTransactionAsync( + const txHash = await exchangeInstance.fillOrder.sendTransactionAsync( orderWithoutExchangeAddress, partialFillAmount, signedOrder.signature, { from: takerAddress }, ); + await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); return signedOrder; } private async _createAsymmetricFillableSignedOrderWithFeesAsync( @@ -224,7 +225,7 @@ export class FillScenarios { const txHash = await erc721Token.setApprovalForAll.sendTransactionAsync(this._erc721ProxyAddress, isApproved, { from: address, }); - await this._web3Wrapper.awaitTransactionSuccessAsync(txHash); + await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); } private async _increaseERC721BalanceAsync( tokenAddress: string, @@ -238,7 +239,7 @@ export class FillScenarios { this._web3Wrapper.getContractDefaults(), ); const txHash = await erc721Token.mint.sendTransactionAsync(address, tokenId, { from: this._coinbase }); - await this._web3Wrapper.awaitTransactionSuccessAsync(txHash); + await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); } private async _increaseERC20BalanceAndAllowanceAsync( tokenAddress: string, @@ -260,9 +261,10 @@ export class FillScenarios { this._web3Wrapper.getProvider(), this._web3Wrapper.getContractDefaults(), ); - await erc20Token.transfer.sendTransactionAsync(address, amount, { + const txHash = await erc20Token.transfer.sendTransactionAsync(address, amount, { from: this._coinbase, }); + await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); } private async _increaseERC20AllowanceAsync( tokenAddress: string, @@ -278,8 +280,9 @@ export class FillScenarios { const oldMakerAllowance = await erc20Token.allowance.callAsync(address, this._erc20ProxyAddress); const newMakerAllowance = oldMakerAllowance.plus(amount); - await erc20Token.approve.sendTransactionAsync(this._erc20ProxyAddress, newMakerAllowance, { + const txHash = await erc20Token.approve.sendTransactionAsync(this._erc20ProxyAddress, newMakerAllowance, { from: address, }); + await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); } } |