aboutsummaryrefslogtreecommitdiffstats
path: root/src/web3_wrapper.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-06-02 22:06:26 +0800
committerFabio Berger <me@fabioberger.com>2017-06-02 22:06:26 +0800
commit844f138908a30fa6daa904beafab85823c6d47d7 (patch)
treebe2402e849e6c67acd27ccb323cd39a08ea103d8 /src/web3_wrapper.ts
parentb8ff2468776e1c784ff50e5ada1c633ee0d3aeda (diff)
downloaddexon-0x-contracts-844f138908a30fa6daa904beafab85823c6d47d7.tar.gz
dexon-0x-contracts-844f138908a30fa6daa904beafab85823c6d47d7.tar.zst
dexon-0x-contracts-844f138908a30fa6daa904beafab85823c6d47d7.zip
Add setAllowanceAsync, getAllowanceAsync and transferFrom to tokenWrapper
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 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<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 isSenderAddressAvailable(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)();
@@ -64,6 +68,10 @@ export class Web3Wrapper {
const {timestamp} = await promisify(this.web3.eth.getBlock)(blockHash);
return timestamp;
}
+ 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;