aboutsummaryrefslogtreecommitdiffstats
path: root/src/web3_wrapper.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-05 22:22:56 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-05 22:22:56 +0800
commitbac6833436960d2a7eb50d89e94fed226a16008b (patch)
tree69556bb591ecd1fc5ebcd3e2da8c688d5cbaccd0 /src/web3_wrapper.ts
parenteb5c9ae70886cb1a14ae154f363f052a76b24479 (diff)
downloaddexon-sol-tools-bac6833436960d2a7eb50d89e94fed226a16008b.tar
dexon-sol-tools-bac6833436960d2a7eb50d89e94fed226a16008b.tar.gz
dexon-sol-tools-bac6833436960d2a7eb50d89e94fed226a16008b.tar.bz2
dexon-sol-tools-bac6833436960d2a7eb50d89e94fed226a16008b.tar.lz
dexon-sol-tools-bac6833436960d2a7eb50d89e94fed226a16008b.tar.xz
dexon-sol-tools-bac6833436960d2a7eb50d89e94fed226a16008b.tar.zst
dexon-sol-tools-bac6833436960d2a7eb50d89e94fed226a16008b.zip
Make methods accept senderAccount
Diffstat (limited to 'src/web3_wrapper.ts')
-rw-r--r--src/web3_wrapper.ts24
1 files changed, 2 insertions, 22 deletions
diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts
index 9892abcb8..2508c5116 100644
--- a/src/web3_wrapper.ts
+++ b/src/web3_wrapper.ts
@@ -23,20 +23,8 @@ export class Web3Wrapper {
public setDefaultAccount(address: string): void {
this.web3.eth.defaultAccount = address;
}
- 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 this.getAvailableSenderAddressesAsync();
- if (_.isEmpty(addresses)) {
- return undefined;
- }
- return addresses[0];
- }
public async isSenderAddressAvailableAsync(senderAddress: string): Promise<boolean> {
- const addresses = await this.getAvailableSenderAddressesAsync();
+ const addresses = await this.getAvailableAccountsAsync();
return _.includes(addresses, senderAddress);
}
public async getNodeVersionAsync(): Promise<string> {
@@ -73,15 +61,7 @@ export class Web3Wrapper {
const {timestamp} = await promisify(this.web3.eth.getBlock)(blockHash);
return timestamp;
}
- public 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 getAvailableSenderAddressesAsync(): Promise<string[]> {
+ public async getAvailableAccountsAsync(): Promise<string[]> {
const addresses: string[] = await promisify(this.web3.eth.getAccounts)();
return addresses;
}