aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2017-06-06 21:14:53 +0800
committerGitHub <noreply@github.com>2017-06-06 21:14:53 +0800
commit692a0fd965f7c0cfc0eef79112d2abffdf9e90db (patch)
treea3a97eb6522bc887966da6575e4b2ac73560fdcf /src/utils
parent2eb99f46f53984c1a54315f87059ef18b9d06349 (diff)
parentf54b513935dbba0dd1922566ed2fd4b4acbf6459 (diff)
downloaddexon-sol-tools-692a0fd965f7c0cfc0eef79112d2abffdf9e90db.tar
dexon-sol-tools-692a0fd965f7c0cfc0eef79112d2abffdf9e90db.tar.gz
dexon-sol-tools-692a0fd965f7c0cfc0eef79112d2abffdf9e90db.tar.bz2
dexon-sol-tools-692a0fd965f7c0cfc0eef79112d2abffdf9e90db.tar.lz
dexon-sol-tools-692a0fd965f7c0cfc0eef79112d2abffdf9e90db.tar.xz
dexon-sol-tools-692a0fd965f7c0cfc0eef79112d2abffdf9e90db.tar.zst
dexon-sol-tools-692a0fd965f7c0cfc0eef79112d2abffdf9e90db.zip
Merge pull request #39 from 0xProject/senderAccount
Make methods accept senderAccount
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/assert.ts18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/utils/assert.ts b/src/utils/assert.ts
index 5a31e1b16..f4d653ffb 100644
--- a/src/utils/assert.ts
+++ b/src/utils/assert.ts
@@ -26,10 +26,20 @@ 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');
+ async isSenderAddressAsync(variableName: string, senderAddressHex: string,
+ web3Wrapper: Web3Wrapper): Promise<void> {
+ assert.isETHAddressHex(variableName, senderAddressHex);
+ await assert.isSenderAddressAvailableAsync(web3Wrapper, variableName, senderAddressHex);
+ },
+ async isSenderAddressAvailableAsync(web3Wrapper: Web3Wrapper, variableName: string,
+ senderAddressHex: string): Promise<void> {
+ const isSenderAddressAvailable = await web3Wrapper.isSenderAddressAvailableAsync(senderAddressHex);
+ assert.assert(isSenderAddressAvailable, `Specified ${variableName} ${senderAddressHex} isn't available \
+ through the supplied web3 instance`);
+ },
+ async isUserAddressAvailableAsync(web3Wrapper: Web3Wrapper): Promise<void> {
+ const availableAddresses = await web3Wrapper.getAvailableAddressesAsync();
+ this.assert(!_.isEmpty(availableAddresses), 'No addresses were available on the provided web3 instance');
},
isNumber(variableName: string, value: number): void {
this.assert(_.isFinite(value), this.typeAssertionMessage(variableName, 'number', value));