diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-24 01:14:21 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-28 07:35:55 +0800 |
commit | 7a21c6854bec32f9a36e8ca3de14a815e9c9fa7d (patch) | |
tree | d86868444bc75f746ebd5d22acdaf853a795629e /packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts | |
parent | 54ef916b93ba0939dcb8824149c9a9fb74df4f2e (diff) | |
download | dexon-sol-tools-7a21c6854bec32f9a36e8ca3de14a815e9c9fa7d.tar dexon-sol-tools-7a21c6854bec32f9a36e8ca3de14a815e9c9fa7d.tar.gz dexon-sol-tools-7a21c6854bec32f9a36e8ca3de14a815e9c9fa7d.tar.bz2 dexon-sol-tools-7a21c6854bec32f9a36e8ca3de14a815e9c9fa7d.tar.lz dexon-sol-tools-7a21c6854bec32f9a36e8ca3de14a815e9c9fa7d.tar.xz dexon-sol-tools-7a21c6854bec32f9a36e8ca3de14a815e9c9fa7d.tar.zst dexon-sol-tools-7a21c6854bec32f9a36e8ca3de14a815e9c9fa7d.zip |
Add option config for gasPrice and gasLimit for every transaction sending method
Diffstat (limited to 'packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts')
-rw-r--r-- | packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts index 7a3f2bc52..65f1cda24 100644 --- a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts @@ -2,7 +2,7 @@ import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import {artifacts} from '../artifacts'; -import {EtherTokenContract, ZeroExError} from '../types'; +import {EtherTokenContract, TransactionOpts, ZeroExError} from '../types'; import {assert} from '../utils/assert'; import {Web3Wrapper} from '../web3_wrapper'; @@ -27,10 +27,11 @@ export class EtherTokenWrapper extends ContractWrapper { * to the depositor address. These wrapped ETH tokens can be used in 0x trades and are redeemable for 1-to-1 * for ETH. * @param amountInWei Amount of ETH in Wei the caller wishes to deposit. - * @param depositor The hex encoded user Ethereum address that would like to make the deposit. + * @param depositor The hex encoded user Ethereum address that would like to make the deposit. + * @param txOpts Transaction parameters. * @return Transaction hash. */ - public async depositAsync(amountInWei: BigNumber, depositor: string): Promise<string> { + public async depositAsync(amountInWei: BigNumber, depositor: string, txOpts: TransactionOpts): Promise<string> { assert.isValidBaseUnitAmount('amountInWei', amountInWei); await assert.isSenderAddressAsync('depositor', depositor, this._web3Wrapper); @@ -41,6 +42,8 @@ export class EtherTokenWrapper extends ContractWrapper { const txHash = await wethContract.deposit.sendTransactionAsync({ from: depositor, value: amountInWei, + gas: txOpts.gasLimit, + gasPrice: txOpts.gasPrice, }); return txHash; } @@ -49,9 +52,10 @@ export class EtherTokenWrapper extends ContractWrapper { * equivalent number of wrapped ETH tokens. * @param amountInWei Amount of ETH in Wei the caller wishes to withdraw. * @param withdrawer The hex encoded user Ethereum address that would like to make the withdrawl. + * @param txOpts Transaction parameters. * @return Transaction hash. */ - public async withdrawAsync(amountInWei: BigNumber, withdrawer: string): Promise<string> { + public async withdrawAsync(amountInWei: BigNumber, withdrawer: string, txOpts: TransactionOpts): Promise<string> { assert.isValidBaseUnitAmount('amountInWei', amountInWei); await assert.isSenderAddressAsync('withdrawer', withdrawer, this._web3Wrapper); @@ -62,6 +66,8 @@ export class EtherTokenWrapper extends ContractWrapper { const wethContract = await this._getEtherTokenContractAsync(); const txHash = await wethContract.withdraw.sendTransactionAsync(amountInWei, { from: withdrawer, + gas: txOpts.gasLimit, + gasPrice: txOpts.gasPrice, }); return txHash; } |