aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
diff options
context:
space:
mode:
authorJacob Evans <jacob@dekz.net>2018-02-24 02:36:16 +0800
committerJacob Evans <jacob@dekz.net>2018-02-27 01:39:46 +0800
commiteabe96fd194f21b1c670381506b115589a37eff5 (patch)
tree3998559ffc4f2dea03871068f73a25d90ffc66f8 /packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
parentf689d335c0c4042e7ecf3e4636db3434d0dcd7a8 (diff)
downloaddexon-0x-contracts-eabe96fd194f21b1c670381506b115589a37eff5.tar
dexon-0x-contracts-eabe96fd194f21b1c670381506b115589a37eff5.tar.gz
dexon-0x-contracts-eabe96fd194f21b1c670381506b115589a37eff5.tar.bz2
dexon-0x-contracts-eabe96fd194f21b1c670381506b115589a37eff5.tar.lz
dexon-0x-contracts-eabe96fd194f21b1c670381506b115589a37eff5.tar.xz
dexon-0x-contracts-eabe96fd194f21b1c670381506b115589a37eff5.tar.zst
dexon-0x-contracts-eabe96fd194f21b1c670381506b115589a37eff5.zip
Check isETHAddressHex before lowercase
Flip the check so assertion happens before lowercase
Diffstat (limited to 'packages/0x.js/src/contract_wrappers/exchange_wrapper.ts')
-rw-r--r--packages/0x.js/src/contract_wrappers/exchange_wrapper.ts28
1 files changed, 10 insertions, 18 deletions
diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
index 7db13a1ba..e366c46cd 100644
--- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
@@ -179,9 +179,8 @@ export class ExchangeWrapper extends ContractWrapper {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance);
+ await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const normalizedTakerAddress = takerAddress.toLowerCase();
- assert.isETHAddressHex('takerAddress', normalizedTakerAddress);
- await assert.isSenderAddressAsync('takerAddress', normalizedTakerAddress, this._web3Wrapper);
const exchangeInstance = await this._getExchangeContractAsync();
const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
@@ -255,9 +254,8 @@ export class ExchangeWrapper extends ContractWrapper {
);
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance);
+ await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const normalizedTakerAddress = takerAddress.toLowerCase();
- assert.isETHAddressHex('takerAddress', normalizedTakerAddress);
- await assert.isSenderAddressAsync('takerAddress', normalizedTakerAddress, this._web3Wrapper);
const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
? SHOULD_VALIDATE_BY_DEFAULT
@@ -348,9 +346,8 @@ export class ExchangeWrapper extends ContractWrapper {
ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress,
);
assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance);
+ await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const normalizedTakerAddress = takerAddress.toLowerCase();
- assert.isETHAddressHex('takerAddress', normalizedTakerAddress);
- await assert.isSenderAddressAsync('takerAddress', normalizedTakerAddress, this._web3Wrapper);
const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
? SHOULD_VALIDATE_BY_DEFAULT
: orderTransactionOpts.shouldValidate;
@@ -422,9 +419,8 @@ export class ExchangeWrapper extends ContractWrapper {
): Promise<string> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
+ await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const normalizedTakerAddress = takerAddress.toLowerCase();
- assert.isETHAddressHex('takerAddress', normalizedTakerAddress);
- await assert.isSenderAddressAsync('takerAddress', normalizedTakerAddress, this._web3Wrapper);
const exchangeInstance = await this._getExchangeContractAsync();
@@ -483,9 +479,8 @@ export class ExchangeWrapper extends ContractWrapper {
exchangeContractAddresses,
ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress,
);
+ await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const normalizedTakerAddress = takerAddress.toLowerCase();
- assert.isETHAddressHex('takerAddress', normalizedTakerAddress);
- await assert.isSenderAddressAsync('takerAddress', normalizedTakerAddress, this._web3Wrapper);
if (_.isEmpty(orderFillRequests)) {
throw new Error(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem);
}
@@ -555,7 +550,6 @@ export class ExchangeWrapper extends ContractWrapper {
assert.isValidBaseUnitAmount('takerTokenCancelAmount', cancelTakerTokenAmount);
await assert.isSenderAddressAsync('order.maker', order.maker, this._web3Wrapper);
const normalizedMakerAddress = order.maker.toLowerCase();
- assert.isETHAddressHex('order.maker', normalizedMakerAddress);
const exchangeInstance = await this._getExchangeContractAsync();
@@ -614,9 +608,8 @@ export class ExchangeWrapper extends ContractWrapper {
const makers = _.map(orderCancellationRequests, cancellationRequest => cancellationRequest.order.maker);
assert.hasAtMostOneUniqueValue(makers, ExchangeContractErrs.MultipleMakersInSingleCancelBatchDisallowed);
const maker = makers[0];
+ await assert.isSenderAddressAsync('maker', maker, this._web3Wrapper);
const normalizedMakerAddress = maker.toLowerCase();
- assert.isETHAddressHex('maker', normalizedMakerAddress);
- await assert.isSenderAddressAsync('maker', normalizedMakerAddress, this._web3Wrapper);
const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
? SHOULD_VALIDATE_BY_DEFAULT
@@ -771,9 +764,8 @@ export class ExchangeWrapper extends ContractWrapper {
): Promise<void> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
+ await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const normalizedTakerAddress = takerAddress.toLowerCase();
- assert.isETHAddressHex('takerAddress', normalizedTakerAddress);
- await assert.isSenderAddressAsync('takerAddress', normalizedTakerAddress, this._web3Wrapper);
const zrxTokenAddress = this.getZRXTokenAddress();
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
await this._orderValidationUtils.validateFillOrderThrowIfInvalidAsync(
@@ -819,9 +811,8 @@ export class ExchangeWrapper extends ContractWrapper {
): Promise<void> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
+ await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const normalizedTakerAddress = takerAddress.toLowerCase();
- assert.isETHAddressHex('takerAddress', normalizedTakerAddress);
- await assert.isSenderAddressAsync('takerAddress', normalizedTakerAddress, this._web3Wrapper);
const zrxTokenAddress = this.getZRXTokenAddress();
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
await this._orderValidationUtils.validateFillOrKillOrderThrowIfInvalidAsync(
@@ -892,11 +883,12 @@ export class ExchangeWrapper extends ContractWrapper {
assert.isHexString('dataHex', dataHex);
assert.doesConformToSchema('ecSignature', ecSignature, schemas.ecSignatureSchema);
assert.isETHAddressHex('signerAddressHex', signerAddressHex);
+ const normalizedSignerAddress = signerAddressHex.toLowerCase();
const exchangeInstance = await this._getExchangeContractAsync();
const isValidSignature = await exchangeInstance.isValidSignature.callAsync(
- signerAddressHex,
+ normalizedSignerAddress,
dataHex,
ecSignature.v,
ecSignature.r,