aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-06-29 21:02:10 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-06-29 22:52:54 +0800
commit294d3bbdc1db983701472eafed25dc84a455c0f7 (patch)
treec9eb57e1f263f10c5089e512f65201298219a957
parent6db614251e4d1ec7248fd87354bfde8e65d50374 (diff)
downloaddexon-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
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts34
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts24
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts29
3 files changed, 55 insertions, 32 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;
}
diff --git a/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts
index 53190d007..6a7191098 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts
@@ -22,6 +22,8 @@ import { ContractWrapper } from './contract_wrapper';
import { ERC721ProxyWrapper } from './erc721_proxy_wrapper';
import { ERC721TokenContract, ERC721TokenEventArgs, ERC721TokenEvents } from './generated/erc721_token';
+const removeUndefinedProperties = _.pickBy;
+
/**
* This class includes all the functionality related to interacting with ERC721 token contracts.
* All ERC721 method calls are supported, along with some convenience methods for getting/setting allowances
@@ -234,11 +236,11 @@ export class ERC721TokenWrapper extends ContractWrapper {
const txHash = await tokenContract.setApprovalForAll.sendTransactionAsync(
normalizedOperatorAddress,
isApproved,
- {
+ removeUndefinedProperties({
gas: txOpts.gasLimit,
gasPrice: txOpts.gasPrice,
from: normalizedOwnerAddress,
- },
+ }),
);
return txHash;
}
@@ -293,11 +295,15 @@ export class ERC721TokenWrapper extends ContractWrapper {
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
const tokenOwnerAddress = await tokenContract.ownerOf.callAsync(tokenId);
await assert.isSenderAddressAsync('tokenOwnerAddress', tokenOwnerAddress, this._web3Wrapper);
- const txHash = await tokenContract.approve.sendTransactionAsync(normalizedApprovedAddress, tokenId, {
- gas: txOpts.gasLimit,
- gasPrice: txOpts.gasPrice,
- from: tokenOwnerAddress,
- });
+ const txHash = await tokenContract.approve.sendTransactionAsync(
+ normalizedApprovedAddress,
+ tokenId,
+ removeUndefinedProperties({
+ gas: txOpts.gasLimit,
+ gasPrice: txOpts.gasPrice,
+ from: tokenOwnerAddress,
+ }),
+ );
return txHash;
}
/**
@@ -363,11 +369,11 @@ export class ERC721TokenWrapper extends ContractWrapper {
ownerAddress,
normalizedReceiverAddress,
tokenId,
- {
+ removeUndefinedProperties({
gas: txOpts.gasLimit,
gasPrice: txOpts.gasPrice,
from: normalizedSenderAddress,
- },
+ }),
);
return txHash;
}
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;
}
/**