aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2017-06-01 01:25:03 +0800
committerGitHub <noreply@github.com>2017-06-01 01:25:03 +0800
commit1c765cd55f227d99941f5944ff60022884890fe1 (patch)
tree246ed68ffad1036b5545e35f3123de3ec98801a4 /src/contract_wrappers
parent11b6b36ccaac04f39b425345daa61396a62ab0fc (diff)
parent4d43f4d6108575b889aca8e8c969574c121ce0c9 (diff)
downloaddexon-sol-tools-1c765cd55f227d99941f5944ff60022884890fe1.tar
dexon-sol-tools-1c765cd55f227d99941f5944ff60022884890fe1.tar.gz
dexon-sol-tools-1c765cd55f227d99941f5944ff60022884890fe1.tar.bz2
dexon-sol-tools-1c765cd55f227d99941f5944ff60022884890fe1.tar.lz
dexon-sol-tools-1c765cd55f227d99941f5944ff60022884890fe1.tar.xz
dexon-sol-tools-1c765cd55f227d99941f5944ff60022884890fe1.tar.zst
dexon-sol-tools-1c765cd55f227d99941f5944ff60022884890fe1.zip
Merge pull request #28 from 0xProject/erc20transfer
Add transfer function and tests for it
Diffstat (limited to 'src/contract_wrappers')
-rw-r--r--src/contract_wrappers/token_wrapper.ts17
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)) {