aboutsummaryrefslogtreecommitdiffstats
path: root/src/0x.js.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-06-03 02:39:02 +0800
committerFabio Berger <me@fabioberger.com>2017-06-03 02:39:02 +0800
commit36e937f8de348cfdb35ff8f72504aed1dfab07b2 (patch)
treee8e0ba5b603f07bddf6cd01329e001b06b5987dd /src/0x.js.ts
parentc6ceb44682a19c9f53505803547fcb2012691b5b (diff)
parent5925f81fe185a90efaa82dd90bd8d65d74326f11 (diff)
downloaddexon-sol-tools-36e937f8de348cfdb35ff8f72504aed1dfab07b2.tar
dexon-sol-tools-36e937f8de348cfdb35ff8f72504aed1dfab07b2.tar.gz
dexon-sol-tools-36e937f8de348cfdb35ff8f72504aed1dfab07b2.tar.bz2
dexon-sol-tools-36e937f8de348cfdb35ff8f72504aed1dfab07b2.tar.lz
dexon-sol-tools-36e937f8de348cfdb35ff8f72504aed1dfab07b2.tar.xz
dexon-sol-tools-36e937f8de348cfdb35ff8f72504aed1dfab07b2.tar.zst
dexon-sol-tools-36e937f8de348cfdb35ff8f72504aed1dfab07b2.zip
Merge branch 'master' into remainingTokenMethods
# Conflicts: # src/contract_wrappers/token_wrapper.ts
Diffstat (limited to 'src/0x.js.ts')
-rw-r--r--src/0x.js.ts19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/0x.js.ts b/src/0x.js.ts
index 7cf313666..40290467a 100644
--- a/src/0x.js.ts
+++ b/src/0x.js.ts
@@ -17,7 +17,7 @@ import {TokenRegistryWrapper} from './contract_wrappers/token_registry_wrapper';
import {ecSignatureSchema} from './schemas/ec_signature_schema';
import {TokenWrapper} from './contract_wrappers/token_wrapper';
import {SolidityTypes, ECSignature, ZeroExError} from './types';
-import {Order} from './types';
+import {Order, SignedOrder} from './types';
import {orderSchema} from './schemas/order_schemas';
import * as ExchangeArtifacts from './artifacts/Exchange.json';
@@ -69,11 +69,16 @@ export class ZeroEx {
const salt = randomNumber.times(factor).round();
return salt;
}
- /** Checks if order hash is valid */
- public static isValidOrderHash(orderHash: string): boolean {
- assert.isString('orderHash', orderHash);
- const isValid = /^0x[0-9A-F]{64}$/i.test(orderHash);
- return isValid;
+ /**
+ * Checks if the supplied hex encoded order hash is valid.
+ * Note: Valid means it has the expected format, not that an order with the orderHash exists.
+ */
+ public static isValidOrderHash(orderHashHex: string): boolean {
+ // Since this method can be called to check if any arbitrary string conforms to an orderHash's
+ // format, we only assert that we were indeed passed a string.
+ assert.isString('orderHashHex', orderHashHex);
+ const isValidOrderHash = utils.isValidOrderHash(orderHashHex);
+ return isValidOrderHash;
}
/**
* A unit amount is defined as the amount of a token above the specified decimal places (integer part).
@@ -132,7 +137,7 @@ export class ZeroEx {
/**
* Computes the orderHash for a given order and returns it as a hex encoded string.
*/
- public async getOrderHashHexAsync(order: Order): Promise<string> {
+ public async getOrderHashHexAsync(order: Order|SignedOrder): Promise<string> {
const exchangeContractAddr = await this.getExchangeAddressAsync();
assert.doesConformToSchema('order',
SchemaValidator.convertToJSONSchemaCompatibleObject(order as object),