aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src/utils/assert.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-05-12 01:11:27 +0800
committerGitHub <noreply@github.com>2018-05-12 01:11:27 +0800
commit6aed4fb1ae27dabed027c855f2cbdc0bfb4f3b6b (patch)
tree8d374bf8f4f70a40d75c8bf4b35fe9a169250909 /packages/contract-wrappers/src/utils/assert.ts
parentf42f608f3f97a5244f09f17ae5ee184c0f775de3 (diff)
parentad8e12eeaebd40fdafac7cbef96121d4454909df (diff)
downloaddexon-0x-contracts-6aed4fb1ae27dabed027c855f2cbdc0bfb4f3b6b.tar
dexon-0x-contracts-6aed4fb1ae27dabed027c855f2cbdc0bfb4f3b6b.tar.gz
dexon-0x-contracts-6aed4fb1ae27dabed027c855f2cbdc0bfb4f3b6b.tar.bz2
dexon-0x-contracts-6aed4fb1ae27dabed027c855f2cbdc0bfb4f3b6b.tar.lz
dexon-0x-contracts-6aed4fb1ae27dabed027c855f2cbdc0bfb4f3b6b.tar.xz
dexon-0x-contracts-6aed4fb1ae27dabed027c855f2cbdc0bfb4f3b6b.tar.zst
dexon-0x-contracts-6aed4fb1ae27dabed027c855f2cbdc0bfb4f3b6b.zip
Merge pull request #579 from 0xProject/breakUp0xjs
Split 0x.js into: contract-wrappers & order-watcher
Diffstat (limited to 'packages/contract-wrappers/src/utils/assert.ts')
-rw-r--r--packages/contract-wrappers/src/utils/assert.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/contract-wrappers/src/utils/assert.ts b/packages/contract-wrappers/src/utils/assert.ts
new file mode 100644
index 000000000..2588a4d09
--- /dev/null
+++ b/packages/contract-wrappers/src/utils/assert.ts
@@ -0,0 +1,31 @@
+import { assert as sharedAssert } from '@0xproject/assert';
+// We need those two unused imports because they're actually used by sharedAssert which gets injected here
+// tslint:disable-next-line:no-unused-variable
+import { Schema } from '@0xproject/json-schemas';
+// tslint:disable-next-line:no-unused-variable
+import { ECSignature } from '@0xproject/types';
+import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import * as _ from 'lodash';
+
+import { isValidSignature } from '@0xproject/order-utils';
+
+export const assert = {
+ ...sharedAssert,
+ isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) {
+ const isValid = isValidSignature(orderHash, ecSignature, signerAddress);
+ this.assert(isValid, `Expected order with hash '${orderHash}' to have a valid signature`);
+ },
+ async isSenderAddressAsync(
+ variableName: string,
+ senderAddressHex: string,
+ web3Wrapper: Web3Wrapper,
+ ): Promise<void> {
+ sharedAssert.isETHAddressHex(variableName, senderAddressHex);
+ const isSenderAddressAvailable = await web3Wrapper.isSenderAddressAvailableAsync(senderAddressHex);
+ sharedAssert.assert(
+ isSenderAddressAvailable,
+ `Specified ${variableName} ${senderAddressHex} isn't available through the supplied web3 provider`,
+ );
+ },
+};