diff options
author | Fabio Berger <me@fabioberger.com> | 2017-11-09 23:09:20 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-11-09 23:09:20 +0800 |
commit | c96c681758a9bb62b4444ce21747c3781e9dc742 (patch) | |
tree | 545cf0c2adea7777d7e2c9bff6015e7b33cc0843 /src/contract_wrappers/token_wrapper.ts | |
parent | 6007609f7132d5f919c8e9de04ae6c652ce38980 (diff) | |
download | dexon-sol-tools-c96c681758a9bb62b4444ce21747c3781e9dc742.tar dexon-sol-tools-c96c681758a9bb62b4444ce21747c3781e9dc742.tar.gz dexon-sol-tools-c96c681758a9bb62b4444ce21747c3781e9dc742.tar.bz2 dexon-sol-tools-c96c681758a9bb62b4444ce21747c3781e9dc742.tar.lz dexon-sol-tools-c96c681758a9bb62b4444ce21747c3781e9dc742.tar.xz dexon-sol-tools-c96c681758a9bb62b4444ce21747c3781e9dc742.tar.zst dexon-sol-tools-c96c681758a9bb62b4444ce21747c3781e9dc742.zip |
Add assert.isValidBaseUnitAmount that checks for decimals in amounts that should be in baseUnits. This can sometimes alert developers whenever they accidentally pass in unitAmounts.
Diffstat (limited to 'src/contract_wrappers/token_wrapper.ts')
-rw-r--r-- | src/contract_wrappers/token_wrapper.ts | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index 5d6d61cef..c479aa30f 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -73,6 +73,7 @@ export class TokenWrapper extends ContractWrapper { assert.isETHAddressHex('spenderAddress', spenderAddress); assert.isETHAddressHex('tokenAddress', tokenAddress); assert.isBigNumber('amountInBaseUnits', amountInBaseUnits); + assert.isValidBaseUnitAmount('amountInBaseUnits', amountInBaseUnits); const tokenContract = await this._getTokenContractAsync(tokenAddress); // Hack: for some reason default estimated gas amount causes `base fee exceeds gas limit` exception @@ -153,6 +154,7 @@ export class TokenWrapper extends ContractWrapper { assert.isETHAddressHex('ownerAddress', ownerAddress); assert.isETHAddressHex('tokenAddress', tokenAddress); assert.isBigNumber('amountInBaseUnits', amountInBaseUnits); + assert.isValidBaseUnitAmount('amountInBaseUnits', amountInBaseUnits); const proxyAddress = await this._getTokenTransferProxyAddressAsync(); const txHash = await this.setAllowanceAsync(tokenAddress, ownerAddress, proxyAddress, amountInBaseUnits); @@ -188,6 +190,7 @@ export class TokenWrapper extends ContractWrapper { await assert.isSenderAddressAsync('fromAddress', fromAddress, this._web3Wrapper); assert.isETHAddressHex('toAddress', toAddress); assert.isBigNumber('amountInBaseUnits', amountInBaseUnits); + assert.isValidBaseUnitAmount('amountInBaseUnits', amountInBaseUnits); const tokenContract = await this._getTokenContractAsync(tokenAddress); @@ -222,6 +225,7 @@ export class TokenWrapper extends ContractWrapper { assert.isETHAddressHex('toAddress', toAddress); await assert.isSenderAddressAsync('senderAddress', senderAddress, this._web3Wrapper); assert.isBigNumber('amountInBaseUnits', amountInBaseUnits); + assert.isValidBaseUnitAmount('amountInBaseUnits', amountInBaseUnits); const tokenContract = await this._getTokenContractAsync(tokenAddress); |