aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/contract_wrappers/token_wrapper.ts17
-rw-r--r--src/types.ts1
2 files changed, 17 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)) {
diff --git a/src/types.ts b/src/types.ts
index bf0a1d8b4..418cf9802 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -42,6 +42,7 @@ export interface TokenContract {
allowance: {
call: (ownerAddress: string, allowedAddress: string) => Promise<BigNumber.BigNumber>;
};
+ transfer: (to: string, amountInBaseUnits: BigNumber.BigNumber, opts: any) => Promise<boolean>;
approve: (proxyAddress: string, amountInBaseUnits: BigNumber.BigNumber, opts: any) => void;
}