diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-06-29 21:02:10 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-06-29 22:52:54 +0800 |
commit | 294d3bbdc1db983701472eafed25dc84a455c0f7 (patch) | |
tree | c9eb57e1f263f10c5089e512f65201298219a957 /packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts | |
parent | 6db614251e4d1ec7248fd87354bfde8e65d50374 (diff) | |
download | dexon-sol-tools-294d3bbdc1db983701472eafed25dc84a455c0f7.tar dexon-sol-tools-294d3bbdc1db983701472eafed25dc84a455c0f7.tar.gz dexon-sol-tools-294d3bbdc1db983701472eafed25dc84a455c0f7.tar.bz2 dexon-sol-tools-294d3bbdc1db983701472eafed25dc84a455c0f7.tar.lz dexon-sol-tools-294d3bbdc1db983701472eafed25dc84a455c0f7.tar.xz dexon-sol-tools-294d3bbdc1db983701472eafed25dc84a455c0f7.tar.zst dexon-sol-tools-294d3bbdc1db983701472eafed25dc84a455c0f7.zip |
Use removeUndefinedProperties for txOpts
Diffstat (limited to 'packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts')
-rw-r--r-- | packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts index 49adba1f9..a6e5d8765 100644 --- a/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts @@ -22,6 +22,8 @@ import { ContractWrapper } from './contract_wrapper'; import { ERC20ProxyWrapper } from './erc20_proxy_wrapper'; import { ERC20TokenContract, ERC20TokenEventArgs, ERC20TokenEvents } from './generated/erc20_token'; +const removeUndefinedProperties = _.pickBy; + /** * This class includes all the functionality related to interacting with ERC20 token contracts. * All ERC20 method calls are supported, along with some convenience methods for getting/setting allowances @@ -95,11 +97,15 @@ export class ERC20TokenWrapper extends ContractWrapper { assert.isValidBaseUnitAmount('amountInBaseUnits', amountInBaseUnits); const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress); - const txHash = await tokenContract.approve.sendTransactionAsync(normalizedSpenderAddress, amountInBaseUnits, { - from: normalizedOwnerAddress, - gas: txOpts.gasLimit, - gasPrice: txOpts.gasPrice, - }); + const txHash = await tokenContract.approve.sendTransactionAsync( + normalizedSpenderAddress, + amountInBaseUnits, + removeUndefinedProperties({ + from: normalizedOwnerAddress, + gas: txOpts.gasLimit, + gasPrice: txOpts.gasPrice, + }), + ); return txHash; } /** @@ -265,11 +271,15 @@ export class ERC20TokenWrapper extends ContractWrapper { throw new Error(ContractWrappersError.InsufficientBalanceForTransfer); } - const txHash = await tokenContract.transfer.sendTransactionAsync(normalizedToAddress, amountInBaseUnits, { - from: normalizedFromAddress, - gas: txOpts.gasLimit, - gasPrice: txOpts.gasPrice, - }); + const txHash = await tokenContract.transfer.sendTransactionAsync( + normalizedToAddress, + amountInBaseUnits, + removeUndefinedProperties({ + from: normalizedFromAddress, + gas: txOpts.gasLimit, + gasPrice: txOpts.gasPrice, + }), + ); return txHash; } /** @@ -327,11 +337,11 @@ export class ERC20TokenWrapper extends ContractWrapper { normalizedFromAddress, normalizedToAddress, amountInBaseUnits, - { + removeUndefinedProperties({ from: normalizedSenderAddress, gas: txOpts.gasLimit, gasPrice: txOpts.gasPrice, - }, + }), ); return txHash; } |