aboutsummaryrefslogtreecommitdiffstats
path: root/src/web3_wrapper.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-06-01 22:07:43 +0800
committerFabio Berger <me@fabioberger.com>2017-06-01 22:07:43 +0800
commita1041348d5695ee3b84433e9874176e85543a4e0 (patch)
tree4743e84bcc19ebf2df0919a9ba1a0d9dffb75046 /src/web3_wrapper.ts
parent88a70afa70f84efc866ff53121d05a6d8d77bff8 (diff)
downloaddexon-sol-tools-a1041348d5695ee3b84433e9874176e85543a4e0.tar.gz
dexon-sol-tools-a1041348d5695ee3b84433e9874176e85543a4e0.tar.zst
dexon-sol-tools-a1041348d5695ee3b84433e9874176e85543a4e0.zip
Get getSenderAddressOrThrowAsync everywhere where we throw if the senderAddress doesn't exist
Diffstat (limited to 'src/web3_wrapper.ts')
-rw-r--r--src/web3_wrapper.ts16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts
index 70e77dbe3..c1263222a 100644
--- a/src/web3_wrapper.ts
+++ b/src/web3_wrapper.ts
@@ -20,14 +20,6 @@ export class Web3Wrapper {
public setDefaultAccount(address: string): void {
this.web3.eth.defaultAccount = address;
}
- public async getSenderAddressIfExistsAsync(): Promise<string|undefined> {
- const defaultAccount = this.web3.eth.defaultAccount;
- if (!_.isUndefined(defaultAccount)) {
- return defaultAccount;
- }
- 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);
@@ -74,6 +66,14 @@ export class Web3Wrapper {
const {timestamp} = await promisify(this.web3.eth.getBlock)(blockHash);
return timestamp;
}
+ private async getSenderAddressIfExistsAsync(): Promise<string|undefined> {
+ const defaultAccount = this.web3.eth.defaultAccount;
+ if (!_.isUndefined(defaultAccount)) {
+ return defaultAccount;
+ }
+ const firstAccount = await this.getFirstAddressIfExistsAsync();
+ return firstAccount;
+ }
private async getNetworkAsync(): Promise<number> {
const networkId = await promisify(this.web3.version.getNetwork)();
return networkId;