aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
diff options
context:
space:
mode:
authorJacob Evans <jacob@dekz.net>2018-02-07 07:06:56 +0800
committerJacob Evans <jacob@dekz.net>2018-02-23 10:43:00 +0800
commit31f9a848f90fa53d5d3817fe6cfb668a44919ef6 (patch)
tree93dd05b05580dda81709c4a465b4d8ade1b4129d /packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
parent097fc477a2e06b8004d98e77dc17d98ab26ab3f1 (diff)
downloaddexon-sol-tools-31f9a848f90fa53d5d3817fe6cfb668a44919ef6.tar
dexon-sol-tools-31f9a848f90fa53d5d3817fe6cfb668a44919ef6.tar.gz
dexon-sol-tools-31f9a848f90fa53d5d3817fe6cfb668a44919ef6.tar.bz2
dexon-sol-tools-31f9a848f90fa53d5d3817fe6cfb668a44919ef6.tar.lz
dexon-sol-tools-31f9a848f90fa53d5d3817fe6cfb668a44919ef6.tar.xz
dexon-sol-tools-31f9a848f90fa53d5d3817fe6cfb668a44919ef6.tar.zst
dexon-sol-tools-31f9a848f90fa53d5d3817fe6cfb668a44919ef6.zip
Lowercase public addresses
Normalize the public api addresses to lowercase to prevent an avoidable error
Diffstat (limited to 'packages/0x.js/src/contract_wrappers/exchange_wrapper.ts')
-rw-r--r--packages/0x.js/src/contract_wrappers/exchange_wrapper.ts52
1 files changed, 33 insertions, 19 deletions
diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
index c82b7ecf5..71f0618f0 100644
--- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
@@ -179,7 +179,9 @@ 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)
@@ -192,7 +194,7 @@ export class ExchangeWrapper extends ContractWrapper {
exchangeTradeEmulator,
signedOrder,
fillTakerTokenAmount,
- takerAddress,
+ normalizedTakerAddress,
zrxTokenAddress,
);
}
@@ -208,7 +210,7 @@ export class ExchangeWrapper extends ContractWrapper {
signedOrder.ecSignature.r,
signedOrder.ecSignature.s,
{
- from: takerAddress,
+ from: normalizedTakerAddress,
gas: orderTransactionOpts.gasLimit,
gasPrice: orderTransactionOpts.gasPrice,
},
@@ -253,7 +255,9 @@ 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
@@ -267,7 +271,7 @@ export class ExchangeWrapper extends ContractWrapper {
exchangeTradeEmulator,
signedOrder,
fillTakerTokenAmount.minus(filledTakerTokenAmount),
- takerAddress,
+ normalizedTakerAddress,
zrxTokenAddress,
);
filledTakerTokenAmount = filledTakerTokenAmount.plus(singleFilledTakerTokenAmount);
@@ -301,7 +305,7 @@ export class ExchangeWrapper extends ContractWrapper {
rArray,
sArray,
{
- from: takerAddress,
+ from: normalizedTakerAddress,
gas: orderTransactionOpts.gasLimit,
gasPrice: orderTransactionOpts.gasPrice,
},
@@ -344,7 +348,9 @@ 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;
@@ -356,7 +362,7 @@ export class ExchangeWrapper extends ContractWrapper {
exchangeTradeEmulator,
orderFillRequest.signedOrder,
orderFillRequest.takerTokenFillAmount,
- takerAddress,
+ normalizedTakerAddress,
zrxTokenAddress,
);
}
@@ -389,7 +395,7 @@ export class ExchangeWrapper extends ContractWrapper {
rArray,
sArray,
{
- from: takerAddress,
+ from: normalizedTakerAddress,
gas: orderTransactionOpts.gasLimit,
gasPrice: orderTransactionOpts.gasPrice,
},
@@ -416,7 +422,9 @@ 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();
@@ -430,7 +438,7 @@ export class ExchangeWrapper extends ContractWrapper {
exchangeTradeEmulator,
signedOrder,
fillTakerTokenAmount,
- takerAddress,
+ normalizedTakerAddress,
zrxTokenAddress,
);
}
@@ -444,7 +452,7 @@ export class ExchangeWrapper extends ContractWrapper {
signedOrder.ecSignature.r,
signedOrder.ecSignature.s,
{
- from: takerAddress,
+ from: normalizedTakerAddress,
gas: orderTransactionOpts.gasLimit,
gasPrice: orderTransactionOpts.gasPrice,
},
@@ -475,7 +483,9 @@ 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);
}
@@ -492,7 +502,7 @@ export class ExchangeWrapper extends ContractWrapper {
exchangeTradeEmulator,
orderFillRequest.signedOrder,
orderFillRequest.takerTokenFillAmount,
- takerAddress,
+ normalizedTakerAddress,
zrxTokenAddress,
);
}
@@ -520,7 +530,7 @@ export class ExchangeWrapper extends ContractWrapper {
rParams,
sParams,
{
- from: takerAddress,
+ from: normalizedTakerAddress,
gas: orderTransactionOpts.gasLimit,
gasPrice: orderTransactionOpts.gasPrice,
},
@@ -756,14 +766,16 @@ 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(
exchangeTradeEmulator,
signedOrder,
fillTakerTokenAmount,
- takerAddress,
+ normalizedTakerAddress,
zrxTokenAddress,
);
}
@@ -802,14 +814,16 @@ 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(
exchangeTradeEmulator,
signedOrder,
fillTakerTokenAmount,
- takerAddress,
+ normalizedTakerAddress,
zrxTokenAddress,
);
}