From 294d3bbdc1db983701472eafed25dc84a455c0f7 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 29 Jun 2018 16:02:10 +0300 Subject: Use removeUndefinedProperties for txOpts --- .../src/contract_wrappers/ether_token_wrapper.ts | 29 ++++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts') diff --git a/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts index 15ed0b63c..f8e4a683c 100644 --- a/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts @@ -12,6 +12,8 @@ import { ContractWrapper } from './contract_wrapper'; import { ERC20TokenWrapper } from './erc20_token_wrapper'; import { WETH9Contract, WETH9EventArgs, WETH9Events } from './generated/weth9'; +const removeUndefinedProperties = _.pickBy; + /** * This class includes all the functionality related to interacting with a wrapped Ether ERC20 token contract. * The caller can convert ETH into the equivalent number of wrapped ETH ERC20 tokens and back. @@ -52,12 +54,14 @@ export class EtherTokenWrapper extends ContractWrapper { assert.assert(ethBalanceInWei.gte(amountInWei), ContractWrappersError.InsufficientEthBalanceForDeposit); const wethContract = await this._getEtherTokenContractAsync(normalizedEtherTokenAddress); - const txHash = await wethContract.deposit.sendTransactionAsync({ - from: normalizedDepositorAddress, - value: amountInWei, - gas: txOpts.gasLimit, - gasPrice: txOpts.gasPrice, - }); + const txHash = await wethContract.deposit.sendTransactionAsync( + removeUndefinedProperties({ + from: normalizedDepositorAddress, + value: amountInWei, + gas: txOpts.gasLimit, + gasPrice: txOpts.gasPrice, + }), + ); return txHash; } /** @@ -91,11 +95,14 @@ export class EtherTokenWrapper extends ContractWrapper { ); const wethContract = await this._getEtherTokenContractAsync(normalizedEtherTokenAddress); - const txHash = await wethContract.withdraw.sendTransactionAsync(amountInWei, { - from: normalizedWithdrawerAddress, - gas: txOpts.gasLimit, - gasPrice: txOpts.gasPrice, - }); + const txHash = await wethContract.withdraw.sendTransactionAsync( + amountInWei, + removeUndefinedProperties({ + from: normalizedWithdrawerAddress, + gas: txOpts.gasLimit, + gasPrice: txOpts.gasPrice, + }), + ); return txHash; } /** -- cgit