diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/contract_wrappers/token_wrapper.ts | 17 | ||||
-rw-r--r-- | src/types.ts | 1 |
2 files changed, 17 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)) { diff --git a/src/types.ts b/src/types.ts index 3619c800f..5b514bdc4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -38,6 +38,7 @@ export interface TokenContract { allowance: { call: (ownerAddress: string, allowedAddress: string) => Promise<BigNumber.BigNumber>; }; + transfer: (to: string, amountInBaseUnits: BigNumber.BigNumber, txOpts: TxOpts) => Promise<boolean>; approve: (proxyAddress: string, amountInBaseUnits: BigNumber.BigNumber, txOpts: TxOpts) => void; } |