aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-11-10 05:30:32 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-11-10 05:30:40 +0800
commit6aa91d89e0fd02601f7e4df86e8499edc00316ce (patch)
tree18ce9ec7e9ab6e2c732c301572379ce24f252936 /src
parentecc54b07c70c9f191a0eb0dece8137f088250a41 (diff)
downloaddexon-0x-contracts-6aa91d89e0fd02601f7e4df86e8499edc00316ce.tar.gz
dexon-0x-contracts-6aa91d89e0fd02601f7e4df86e8499edc00316ce.tar.zst
dexon-0x-contracts-6aa91d89e0fd02601f7e4df86e8499edc00316ce.zip
Remove redundant assertions
Diffstat (limited to 'src')
-rw-r--r--src/contract_wrappers/ether_token_wrapper.ts2
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts10
-rw-r--r--src/contract_wrappers/token_wrapper.ts4
-rw-r--r--src/utils/assert.ts1
4 files changed, 1 insertions, 16 deletions
diff --git a/src/contract_wrappers/ether_token_wrapper.ts b/src/contract_wrappers/ether_token_wrapper.ts
index 6db07228e..3cd2f0224 100644
--- a/src/contract_wrappers/ether_token_wrapper.ts
+++ b/src/contract_wrappers/ether_token_wrapper.ts
@@ -29,7 +29,6 @@ export class EtherTokenWrapper extends ContractWrapper {
* @return Transaction hash.
*/
public async depositAsync(amountInWei: BigNumber, depositor: string): Promise<string> {
- assert.isBigNumber('amountInWei', amountInWei);
assert.isValidBaseUnitAmount('amountInWei', amountInWei);
await assert.isSenderAddressAsync('depositor', depositor, this._web3Wrapper);
@@ -51,7 +50,6 @@ export class EtherTokenWrapper extends ContractWrapper {
* @return Transaction hash.
*/
public async withdrawAsync(amountInWei: BigNumber, withdrawer: string): Promise<string> {
- assert.isBigNumber('amountInWei', amountInWei);
assert.isValidBaseUnitAmount('amountInWei', amountInWei);
await assert.isSenderAddressAsync('withdrawer', withdrawer, this._web3Wrapper);
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index ddb1d6bd4..f68e80b5d 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -166,7 +166,6 @@ export class ExchangeWrapper extends ContractWrapper {
takerAddress: string,
orderTransactionOpts?: OrderTransactionOpts): Promise<string> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
- assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount);
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
@@ -240,7 +239,6 @@ export class ExchangeWrapper extends ContractWrapper {
const exchangeContractAddresses = _.map(signedOrders, signedOrder => signedOrder.exchangeContractAddress);
assert.hasAtMostOneUniqueValue(exchangeContractAddresses,
ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress);
- assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount);
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
@@ -410,7 +408,6 @@ export class ExchangeWrapper extends ContractWrapper {
takerAddress: string,
orderTransactionOpts?: OrderTransactionOpts): Promise<string> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
- assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount);
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
@@ -546,7 +543,6 @@ export class ExchangeWrapper extends ContractWrapper {
cancelTakerTokenAmount: BigNumber,
orderTransactionOpts?: OrderTransactionOpts): Promise<string> {
assert.doesConformToSchema('order', order, schemas.orderSchema);
- assert.isBigNumber('takerTokenCancelAmount', cancelTakerTokenAmount);
assert.isValidBaseUnitAmount('takerTokenCancelAmount', cancelTakerTokenAmount);
await assert.isSenderAddressAsync('order.maker', order.maker, this._web3Wrapper);
@@ -742,7 +738,6 @@ export class ExchangeWrapper extends ContractWrapper {
fillTakerTokenAmount: BigNumber,
takerAddress: string): Promise<void> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
- assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount);
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const zrxTokenAddress = await this.getZRXTokenAddressAsync();
@@ -759,7 +754,6 @@ export class ExchangeWrapper extends ContractWrapper {
public async validateCancelOrderThrowIfInvalidAsync(
order: Order, cancelTakerTokenAmount: BigNumber): Promise<void> {
assert.doesConformToSchema('order', order, schemas.orderSchema);
- assert.isBigNumber('cancelTakerTokenAmount', cancelTakerTokenAmount);
assert.isValidBaseUnitAmount('cancelTakerTokenAmount', cancelTakerTokenAmount);
const orderHash = utils.getOrderHashHex(order);
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
@@ -778,7 +772,6 @@ export class ExchangeWrapper extends ContractWrapper {
fillTakerTokenAmount: BigNumber,
takerAddress: string): Promise<void> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
- assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount);
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const zrxTokenAddress = await this.getZRXTokenAddressAsync();
@@ -798,11 +791,8 @@ export class ExchangeWrapper extends ContractWrapper {
public async isRoundingErrorAsync(fillTakerTokenAmount: BigNumber,
takerTokenAmount: BigNumber,
makerTokenAmount: BigNumber): Promise<boolean> {
- assert.isBigNumber('fillTakerTokenAmount', fillTakerTokenAmount);
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
- assert.isBigNumber('takerTokenAmount', takerTokenAmount);
assert.isValidBaseUnitAmount('takerTokenAmount', takerTokenAmount);
- assert.isBigNumber('makerTokenAmount', makerTokenAmount);
assert.isValidBaseUnitAmount('makerTokenAmount', makerTokenAmount);
const exchangeInstance = await this._getExchangeContractAsync();
const isRoundingError = await exchangeInstance.isRoundingError.callAsync(
diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts
index c479aa30f..dd87ebc9f 100644
--- a/src/contract_wrappers/token_wrapper.ts
+++ b/src/contract_wrappers/token_wrapper.ts
@@ -72,7 +72,6 @@ export class TokenWrapper extends ContractWrapper {
await assert.isSenderAddressAsync('ownerAddress', ownerAddress, this._web3Wrapper);
assert.isETHAddressHex('spenderAddress', spenderAddress);
assert.isETHAddressHex('tokenAddress', tokenAddress);
- assert.isBigNumber('amountInBaseUnits', amountInBaseUnits);
assert.isValidBaseUnitAmount('amountInBaseUnits', amountInBaseUnits);
const tokenContract = await this._getTokenContractAsync(tokenAddress);
@@ -153,7 +152,6 @@ export class TokenWrapper extends ContractWrapper {
amountInBaseUnits: BigNumber): Promise<string> {
assert.isETHAddressHex('ownerAddress', ownerAddress);
assert.isETHAddressHex('tokenAddress', tokenAddress);
- assert.isBigNumber('amountInBaseUnits', amountInBaseUnits);
assert.isValidBaseUnitAmount('amountInBaseUnits', amountInBaseUnits);
const proxyAddress = await this._getTokenTransferProxyAddressAsync();
@@ -189,7 +187,6 @@ export class TokenWrapper extends ContractWrapper {
assert.isETHAddressHex('tokenAddress', tokenAddress);
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);
@@ -224,7 +221,6 @@ export class TokenWrapper extends ContractWrapper {
assert.isETHAddressHex('fromAddress', fromAddress);
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);
diff --git a/src/utils/assert.ts b/src/utils/assert.ts
index 48aed6ad3..667b41b7b 100644
--- a/src/utils/assert.ts
+++ b/src/utils/assert.ts
@@ -12,6 +12,7 @@ export const assert = {
this.assert(isBigNumber, this.typeAssertionMessage(variableName, 'BigNumber', value));
},
isValidBaseUnitAmount(variableName: string, value: BigNumber) {
+ assert.isBigNumber(variableName, value);
const hasDecimals = value.decimalPlaces() !== 0;
this.assert(
!hasDecimals, `${variableName} should be in baseUnits (no decimals), found value: ${value.toNumber()}`,