diff options
author | Fabio Berger <me@fabioberger.com> | 2017-06-01 02:11:11 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-06-01 02:11:11 +0800 |
commit | ecf92a4ad786a324d4c8ce9dba926f377766a144 (patch) | |
tree | a399fcdd146b880e3f42f24f30d61264c6d26325 /src/contract_wrappers | |
parent | 52c3330487c9cb1e3fc78cda752717b684deca38 (diff) | |
parent | 1c765cd55f227d99941f5944ff60022884890fe1 (diff) | |
download | dexon-sol-tools-ecf92a4ad786a324d4c8ce9dba926f377766a144.tar dexon-sol-tools-ecf92a4ad786a324d4c8ce9dba926f377766a144.tar.gz dexon-sol-tools-ecf92a4ad786a324d4c8ce9dba926f377766a144.tar.bz2 dexon-sol-tools-ecf92a4ad786a324d4c8ce9dba926f377766a144.tar.lz dexon-sol-tools-ecf92a4ad786a324d4c8ce9dba926f377766a144.tar.xz dexon-sol-tools-ecf92a4ad786a324d4c8ce9dba926f377766a144.tar.zst dexon-sol-tools-ecf92a4ad786a324d4c8ce9dba926f377766a144.zip |
Merge branch 'master' into unavailableFilledCancelled
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 35e008905..cedbfbdae 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -52,7 +52,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); @@ -69,6 +69,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)) { |