aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-06-01 02:11:11 +0800
committerFabio Berger <me@fabioberger.com>2017-06-01 02:11:11 +0800
commitecf92a4ad786a324d4c8ce9dba926f377766a144 (patch)
treea399fcdd146b880e3f42f24f30d61264c6d26325 /src
parent52c3330487c9cb1e3fc78cda752717b684deca38 (diff)
parent1c765cd55f227d99941f5944ff60022884890fe1 (diff)
downloaddexon-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')
-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 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 25338a531..aaf703d31 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -47,6 +47,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;
}