diff options
author | Fabio Berger <me@fabioberger.com> | 2018-02-28 01:58:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-28 01:58:09 +0800 |
commit | fce10548d2d992317e36af48638a5ee799e94e7c (patch) | |
tree | 51b9a6a2f0dbaee50a9758a7983fe201d5898354 /packages/0x.js/src/0x.ts | |
parent | 709fa9e02ec21cee9fc145b4a578742c8dd190aa (diff) | |
parent | 6961169f89c4cd8480aca9c720cd8299aec9bbc0 (diff) | |
download | dexon-sol-tools-fce10548d2d992317e36af48638a5ee799e94e7c.tar dexon-sol-tools-fce10548d2d992317e36af48638a5ee799e94e7c.tar.gz dexon-sol-tools-fce10548d2d992317e36af48638a5ee799e94e7c.tar.bz2 dexon-sol-tools-fce10548d2d992317e36af48638a5ee799e94e7c.tar.lz dexon-sol-tools-fce10548d2d992317e36af48638a5ee799e94e7c.tar.xz dexon-sol-tools-fce10548d2d992317e36af48638a5ee799e94e7c.tar.zst dexon-sol-tools-fce10548d2d992317e36af48638a5ee799e94e7c.zip |
Merge pull request #373 from 0xProject/feature/0x.js/lowercase-addresses
Lowercase addresses in the Public API
Diffstat (limited to 'packages/0x.js/src/0x.ts')
-rw-r--r-- | packages/0x.js/src/0x.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts index c578478d8..22a5fee10 100644 --- a/packages/0x.js/src/0x.ts +++ b/packages/0x.js/src/0x.ts @@ -76,8 +76,9 @@ export class ZeroEx { assert.isHexString('data', data); assert.doesConformToSchema('signature', signature, schemas.ecSignatureSchema); assert.isETHAddressHex('signerAddress', signerAddress); + const normalizedSignerAddress = signerAddress.toLowerCase(); - const isValidSignature = signatureUtils.isValidSignature(data, signature, signerAddress); + const isValidSignature = signatureUtils.isValidSignature(data, signature, normalizedSignerAddress); return isValidSignature; } /** @@ -250,6 +251,7 @@ export class ZeroEx { ): Promise<ECSignature> { assert.isHexString('orderHash', orderHash); await assert.isSenderAddressAsync('signerAddress', signerAddress, this._web3Wrapper); + const normalizedSignerAddress = signerAddress.toLowerCase(); let msgHashHex = orderHash; if (shouldAddPersonalMessagePrefix) { @@ -258,7 +260,7 @@ export class ZeroEx { msgHashHex = ethUtil.bufferToHex(msgHashBuff); } - const signature = await this._web3Wrapper.signTransactionAsync(signerAddress, msgHashHex); + const signature = await this._web3Wrapper.signTransactionAsync(normalizedSignerAddress, msgHashHex); // HACK: There is no consensus on whether the signatureHex string should be formatted as // v + r + s OR r + s + v, and different clients (even different versions of the same client) @@ -267,7 +269,7 @@ export class ZeroEx { const validVParamValues = [27, 28]; const ecSignatureVRS = signatureUtils.parseSignatureHexAsVRS(signature); if (_.includes(validVParamValues, ecSignatureVRS.v)) { - const isValidVRSSignature = ZeroEx.isValidSignature(orderHash, ecSignatureVRS, signerAddress); + const isValidVRSSignature = ZeroEx.isValidSignature(orderHash, ecSignatureVRS, normalizedSignerAddress); if (isValidVRSSignature) { return ecSignatureVRS; } @@ -275,7 +277,7 @@ export class ZeroEx { const ecSignatureRSV = signatureUtils.parseSignatureHexAsRSV(signature); if (_.includes(validVParamValues, ecSignatureRSV.v)) { - const isValidRSVSignature = ZeroEx.isValidSignature(orderHash, ecSignatureRSV, signerAddress); + const isValidRSVSignature = ZeroEx.isValidSignature(orderHash, ecSignatureRSV, normalizedSignerAddress); if (isValidRSVSignature) { return ecSignatureRSV; } |