aboutsummaryrefslogtreecommitdiffstats
path: root/src/web3_wrapper.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/web3_wrapper.ts')
-rw-r--r--src/web3_wrapper.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts
index 49bd8b67d..9892abcb8 100644
--- a/src/web3_wrapper.ts
+++ b/src/web3_wrapper.ts
@@ -29,11 +29,15 @@ export class Web3Wrapper {
return senderAddressIfExists as string;
}
public async getFirstAddressIfExistsAsync(): Promise<string|undefined> {
- const addresses = await promisify(this.web3.eth.getAccounts)();
+ const addresses = await this.getAvailableSenderAddressesAsync();
if (_.isEmpty(addresses)) {
return undefined;
}
- return (addresses as string[])[0];
+ return addresses[0];
+ }
+ public async isSenderAddressAvailableAsync(senderAddress: string): Promise<boolean> {
+ const addresses = await this.getAvailableSenderAddressesAsync();
+ return _.includes(addresses, senderAddress);
}
public async getNodeVersionAsync(): Promise<string> {
const nodeVersion = await promisify(this.web3.version.getNode)();
@@ -77,6 +81,10 @@ export class Web3Wrapper {
const firstAccount = await this.getFirstAddressIfExistsAsync();
return firstAccount;
}
+ private async getAvailableSenderAddressesAsync(): Promise<string[]> {
+ const addresses: string[] = await promisify(this.web3.eth.getAccounts)();
+ return addresses;
+ }
private async getNetworkAsync(): Promise<number> {
const networkId = await promisify(this.web3.version.getNetwork)();
return networkId;