diff options
author | Leonid <logvinov.leon@gmail.com> | 2017-06-06 21:14:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-06 21:14:53 +0800 |
commit | 692a0fd965f7c0cfc0eef79112d2abffdf9e90db (patch) | |
tree | a3a97eb6522bc887966da6575e4b2ac73560fdcf /src/web3_wrapper.ts | |
parent | 2eb99f46f53984c1a54315f87059ef18b9d06349 (diff) | |
parent | f54b513935dbba0dd1922566ed2fd4b4acbf6459 (diff) | |
download | dexon-sol-tools-692a0fd965f7c0cfc0eef79112d2abffdf9e90db.tar dexon-sol-tools-692a0fd965f7c0cfc0eef79112d2abffdf9e90db.tar.gz dexon-sol-tools-692a0fd965f7c0cfc0eef79112d2abffdf9e90db.tar.bz2 dexon-sol-tools-692a0fd965f7c0cfc0eef79112d2abffdf9e90db.tar.lz dexon-sol-tools-692a0fd965f7c0cfc0eef79112d2abffdf9e90db.tar.xz dexon-sol-tools-692a0fd965f7c0cfc0eef79112d2abffdf9e90db.tar.zst dexon-sol-tools-692a0fd965f7c0cfc0eef79112d2abffdf9e90db.zip |
Merge pull request #39 from 0xProject/senderAccount
Make methods accept senderAccount
Diffstat (limited to 'src/web3_wrapper.ts')
-rw-r--r-- | src/web3_wrapper.ts | 30 |
1 files changed, 2 insertions, 28 deletions
diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts index 9892abcb8..05a8dc063 100644 --- a/src/web3_wrapper.ts +++ b/src/web3_wrapper.ts @@ -17,26 +17,8 @@ export class Web3Wrapper { public isAddress(address: string): boolean { return this.web3.isAddress(address); } - public getDefaultAccount(): string { - return this.web3.eth.defaultAccount; - } - 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.getAvailableAddressesAsync(); return _.includes(addresses, senderAddress); } public async getNodeVersionAsync(): Promise<string> { @@ -73,15 +55,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 getAvailableAddressesAsync(): Promise<string[]> { const addresses: string[] = await promisify(this.web3.eth.getAccounts)(); return addresses; } |