aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/assert.ts6
-rw-r--r--src/utils/utils.ts3
2 files changed, 9 insertions, 0 deletions
diff --git a/src/utils/assert.ts b/src/utils/assert.ts
index 406f2b149..5a31e1b16 100644
--- a/src/utils/assert.ts
+++ b/src/utils/assert.ts
@@ -1,6 +1,7 @@
import * as _ from 'lodash';
import * as BigNumber from 'bignumber.js';
import * as Web3 from 'web3';
+import {Web3Wrapper} from '../web3_wrapper';
import {SchemaValidator} from './schema_validator';
import {utils} from './utils';
@@ -25,6 +26,11 @@ export const assert = {
const web3 = new Web3();
this.assert(web3.isAddress(value), this.typeAssertionMessage(variableName, 'ETHAddressHex', value));
},
+ async isSenderAddressAvailableAsync(web3Wrapper: Web3Wrapper, senderAddress: string) {
+ const isSenderAddressAvailable = await web3Wrapper.isSenderAddressAvailableAsync(senderAddress);
+ assert.assert(isSenderAddressAvailable, 'Specified senderAddress isn\'t available through the \
+ supplied web3 instance');
+ },
isNumber(variableName: string, value: number): void {
this.assert(_.isFinite(value), this.typeAssertionMessage(variableName, 'number', value));
},
diff --git a/src/utils/utils.ts b/src/utils/utils.ts
index e6840a624..114b46f6c 100644
--- a/src/utils/utils.ts
+++ b/src/utils/utils.ts
@@ -22,4 +22,7 @@ export const utils = {
const isValid = /^0x[0-9A-F]{64}$/i.test(orderHashHex);
return isValid;
},
+ spawnSwitchErr(name: string, value: any) {
+ return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
+ },
};