aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-05-25 19:42:53 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-05-25 19:42:53 +0800
commiteee06e0cc97333891a84aff22196849105846eb4 (patch)
tree751a4e528301544e3a8b4059badecb78ad2bff76 /src
parent74a80c28d348da6e4050e43e713113c4c0df87df (diff)
downloaddexon-sol-tools-eee06e0cc97333891a84aff22196849105846eb4.tar
dexon-sol-tools-eee06e0cc97333891a84aff22196849105846eb4.tar.gz
dexon-sol-tools-eee06e0cc97333891a84aff22196849105846eb4.tar.bz2
dexon-sol-tools-eee06e0cc97333891a84aff22196849105846eb4.tar.lz
dexon-sol-tools-eee06e0cc97333891a84aff22196849105846eb4.tar.xz
dexon-sol-tools-eee06e0cc97333891a84aff22196849105846eb4.tar.zst
dexon-sol-tools-eee06e0cc97333891a84aff22196849105846eb4.zip
Address feedback
Diffstat (limited to 'src')
-rw-r--r--src/ts/0x.js.ts13
-rw-r--r--src/ts/utils/assert.ts2
2 files changed, 8 insertions, 7 deletions
diff --git a/src/ts/0x.js.ts b/src/ts/0x.js.ts
index a3a83670d..bd0ce80e2 100644
--- a/src/ts/0x.js.ts
+++ b/src/ts/0x.js.ts
@@ -1,5 +1,6 @@
import * as BigNumber from 'bignumber.js';
import * as ethUtil from 'ethereumjs-util';
+import * as _ from 'lodash';
import {assert} from './utils/assert';
import {ECSignatureSchema} from './schemas/ec_signature_schema';
@@ -13,17 +14,16 @@ export interface ECSignature {
}
const MAX_DIGITS_IN_UNSIGNED_256_INT = 78;
-const ORDER_HASH_LENGTH = 66;
export class ZeroEx {
/**
* Verifies that the elliptic curve signature `signature` was generated
* by signing `data` with the private key corresponding to the `signer` address.
*/
- public static isValidSignature(dataHex: string, signature: ECSignature, signerAddress: string): boolean {
+ public static isValidSignature(dataHex: string, signature: ECSignature, signerETHAddressHex: string): boolean {
assert.isHexString('dataHex', dataHex);
assert.doesConformToSchema('signature', signature, ECSignatureSchema);
- assert.isETHAddressHex('signerAddress', signerAddress);
+ assert.isETHAddressHex('signerAddress', signerETHAddressHex);
const dataBuff = ethUtil.toBuffer(dataHex);
const msgHashBuff = ethUtil.hashPersonalMessage(dataBuff);
@@ -33,7 +33,7 @@ export class ZeroEx {
ethUtil.toBuffer(signature.r),
ethUtil.toBuffer(signature.s));
const retrievedAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey));
- return retrievedAddress === signerAddress;
+ return retrievedAddress === signerETHAddressHex;
} catch (err) {
return false;
}
@@ -53,7 +53,8 @@ export class ZeroEx {
}
/** Checks if order hash is valid */
public static isValidOrderHash(orderHash: string): boolean {
- assert.isHexString('orderHash', orderHash);
- return orderHash.length === ORDER_HASH_LENGTH;
+ assert.isString('orderHash', orderHash);
+ const isValid = /^0x[0-9A-F]{66}$/i.test(orderHash);
+ return isValid;
}
}
diff --git a/src/ts/utils/assert.ts b/src/ts/utils/assert.ts
index 509590ee6..2f52c6a3b 100644
--- a/src/ts/utils/assert.ts
+++ b/src/ts/utils/assert.ts
@@ -3,7 +3,7 @@ import * as BigNumber from 'bignumber.js';
import Web3 = require('web3');
import {SchemaValidator} from './schema_validator';
-const HEX_REGEX = /^0x([0-9A-F]{2})*$/i;
+const HEX_REGEX = /^0x[0-9A-F]*$/i;
export const assert = {
isBigNumber(variableName: string, value: BigNumber.BigNumber) {