aboutsummaryrefslogtreecommitdiffstats
path: root/src/web3_wrapper.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-05-30 04:14:18 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-05-30 04:14:18 +0800
commit7dddf2010e16167260f7ffbb7c7d2fd83609d8a0 (patch)
tree9e5ceec9bba32b24a8e4542076ddbba844787760 /src/web3_wrapper.ts
parent34de5986421cca90d37b30a1b64678a8a5149b57 (diff)
downloaddexon-sol-tools-7dddf2010e16167260f7ffbb7c7d2fd83609d8a0.tar
dexon-sol-tools-7dddf2010e16167260f7ffbb7c7d2fd83609d8a0.tar.gz
dexon-sol-tools-7dddf2010e16167260f7ffbb7c7d2fd83609d8a0.tar.bz2
dexon-sol-tools-7dddf2010e16167260f7ffbb7c7d2fd83609d8a0.tar.lz
dexon-sol-tools-7dddf2010e16167260f7ffbb7c7d2fd83609d8a0.tar.xz
dexon-sol-tools-7dddf2010e16167260f7ffbb7c7d2fd83609d8a0.tar.zst
dexon-sol-tools-7dddf2010e16167260f7ffbb7c7d2fd83609d8a0.zip
Add getExchangeInstanceOrThrowAsync && getSenderAddressOrThrowAsync
Diffstat (limited to 'src/web3_wrapper.ts')
-rw-r--r--src/web3_wrapper.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts
index 3b460e4da..72daabe6f 100644
--- a/src/web3_wrapper.ts
+++ b/src/web3_wrapper.ts
@@ -2,6 +2,8 @@ import * as _ from 'lodash';
import * as Web3 from 'web3';
import * as BigNumber from 'bignumber.js';
import promisify = require('es6-promisify');
+import {ZeroExError} from "./types";
+import {assert} from "./utils/assert";
export class Web3Wrapper {
private web3: Web3;
@@ -20,6 +22,11 @@ export class Web3Wrapper {
const firstAccount = await this.getFirstAddressIfExistsAsync();
return firstAccount;
}
+ public async getSenderAddressOrThrowAsync(): Promise<string> {
+ const senderAddressIfExists = await this.getSenderAddressIfExistsAsync();
+ assert.assert(!_.isUndefined(senderAddressIfExists), ZeroExError.USER_HAS_NO_ASSOCIATED_ADDRESSES);
+ return senderAddressIfExists as string;
+ }
public async getFirstAddressIfExistsAsync(): Promise<string|undefined> {
const addresses = await promisify(this.web3.eth.getAccounts)();
if (_.isEmpty(addresses)) {