From 844f138908a30fa6daa904beafab85823c6d47d7 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 2 Jun 2017 16:06:26 +0200 Subject: Add setAllowanceAsync, getAllowanceAsync and transferFrom to tokenWrapper --- src/web3_wrapper.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/web3_wrapper.ts') diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts index e65f29b56..93203ff38 100644 --- a/src/web3_wrapper.ts +++ b/src/web3_wrapper.ts @@ -24,11 +24,15 @@ export class Web3Wrapper { return firstAccount; } public async getFirstAddressIfExistsAsync(): Promise { - 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 isSenderAddressAvailable(senderAddress: string): Promise { + const addresses = await this.getAvailableSenderAddressesAsync(); + return _.includes(addresses, senderAddress); } public async getNodeVersionAsync(): Promise { const nodeVersion = await promisify(this.web3.version.getNode)(); @@ -64,6 +68,10 @@ export class Web3Wrapper { const {timestamp} = await promisify(this.web3.eth.getBlock)(blockHash); return timestamp; } + private async getAvailableSenderAddressesAsync(): Promise { + const addresses: string[] = await promisify(this.web3.eth.getAccounts)(); + return addresses; + } private async getNetworkAsync(): Promise { const networkId = await promisify(this.web3.version.getNetwork)(); return networkId; -- cgit v1.2.3