aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/assert.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-11-10 06:18:30 +0800
committerFabio Berger <me@fabioberger.com>2017-11-10 06:18:30 +0800
commit02cc3f911624d31d581d4637d17ad2fa6fd95bc6 (patch)
tree33925b79c035292e3956adf760cb31fad77896e8 /src/utils/assert.ts
parent62861d1e1315a14e955b30a45db05e7907b0d22d (diff)
downloaddexon-sol-tools-02cc3f911624d31d581d4637d17ad2fa6fd95bc6.tar
dexon-sol-tools-02cc3f911624d31d581d4637d17ad2fa6fd95bc6.tar.gz
dexon-sol-tools-02cc3f911624d31d581d4637d17ad2fa6fd95bc6.tar.bz2
dexon-sol-tools-02cc3f911624d31d581d4637d17ad2fa6fd95bc6.tar.lz
dexon-sol-tools-02cc3f911624d31d581d4637d17ad2fa6fd95bc6.tar.xz
dexon-sol-tools-02cc3f911624d31d581d4637d17ad2fa6fd95bc6.tar.zst
dexon-sol-tools-02cc3f911624d31d581d4637d17ad2fa6fd95bc6.zip
Create assert.isValidSignature method and use it in `addOrder`
Diffstat (limited to 'src/utils/assert.ts')
-rw-r--r--src/utils/assert.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/utils/assert.ts b/src/utils/assert.ts
index 667b41b7b..e5c9439f3 100644
--- a/src/utils/assert.ts
+++ b/src/utils/assert.ts
@@ -1,8 +1,10 @@
import * as _ from 'lodash';
-import BigNumber from 'bignumber.js';
import * as Web3 from 'web3';
-import {Web3Wrapper} from '../web3_wrapper';
+import BigNumber from 'bignumber.js';
import {SchemaValidator, Schema} from '0x-json-schemas';
+import {Web3Wrapper} from '../web3_wrapper';
+import {signatureUtils} from '../utils/signature_utils';
+import {ECSignature} from '../types';
const HEX_REGEX = /^0x[0-9A-F]*$/i;
@@ -18,6 +20,10 @@ export const assert = {
!hasDecimals, `${variableName} should be in baseUnits (no decimals), found value: ${value.toNumber()}`,
);
},
+ isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) {
+ const isValidSignature = signatureUtils.isValidSignature(orderHash, ecSignature, signerAddress);
+ this.assert(isValidSignature, `Expected order with hash '${orderHash}' to have a valid signature`);
+ },
isUndefined(value: any, variableName?: string): void {
this.assert(_.isUndefined(value), this.typeAssertionMessage(variableName, 'undefined', value));
},