diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-05-31 17:16:57 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-05-31 17:16:57 +0800 |
commit | 9409e0aba1d1fa62a60c25149ae1b7115de9e2c9 (patch) | |
tree | 14ecfaf55a330774c81c1eb21d31b2839797d8c0 /src/contract_wrappers | |
parent | 5e6818d3eff89347e704edde4bfee72066caedb1 (diff) | |
download | dexon-sol-tools-9409e0aba1d1fa62a60c25149ae1b7115de9e2c9.tar dexon-sol-tools-9409e0aba1d1fa62a60c25149ae1b7115de9e2c9.tar.gz dexon-sol-tools-9409e0aba1d1fa62a60c25149ae1b7115de9e2c9.tar.bz2 dexon-sol-tools-9409e0aba1d1fa62a60c25149ae1b7115de9e2c9.tar.lz dexon-sol-tools-9409e0aba1d1fa62a60c25149ae1b7115de9e2c9.tar.xz dexon-sol-tools-9409e0aba1d1fa62a60c25149ae1b7115de9e2c9.tar.zst dexon-sol-tools-9409e0aba1d1fa62a60c25149ae1b7115de9e2c9.zip |
Add transfer function and tests for it
Diffstat (limited to 'src/contract_wrappers')
-rw-r--r-- | src/contract_wrappers/token_wrapper.ts | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index 59dfc0667..e93b6b7c2 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -54,7 +54,7 @@ export class TokenWrapper extends ContractWrapper { * of an owner address. */ public async setProxyAllowanceAsync(tokenAddress: string, ownerAddress: string, - amountInBaseUnits: BigNumber.BigNumber) { + amountInBaseUnits: BigNumber.BigNumber): Promise<void> { assert.isETHAddressHex('ownerAddress', ownerAddress); assert.isETHAddressHex('tokenAddress', tokenAddress); assert.isBigNumber('amountInBaseUnits', amountInBaseUnits); @@ -71,6 +71,21 @@ export class TokenWrapper extends ContractWrapper { gas, }); } + /** + * Transfers `amountInBaseUnits` ERC20 tokens from `fromAddress` to `toAddress`. + */ + public async transferAsync(tokenAddress: string, fromAddress: string, toAddress: string, + amountInBaseUnits: BigNumber.BigNumber): Promise<void> { + assert.isETHAddressHex('tokenAddress', tokenAddress); + assert.isETHAddressHex('fromAddress', fromAddress); + assert.isETHAddressHex('toAddress', toAddress); + assert.isBigNumber('amountInBaseUnits', amountInBaseUnits); + + const tokenContract = await this.getTokenContractAsync(tokenAddress); + await tokenContract.transfer(toAddress, amountInBaseUnits, { + from: fromAddress, + }); + } private async getTokenContractAsync(tokenAddress: string): Promise<TokenContract> { let tokenContract = this.tokenContractsByAddress[tokenAddress]; if (!_.isUndefined(tokenContract)) { |