implement transfer
MODIFY
src/plasma/ether.ts
src/plasma/ether.ts
@@ -51,21 +51,11 @@ export class Ether extends BaseToken {
}).then(ethAddress => {
const erc20 = new ERC20(
ethAddress,
- false,
+ isParent,
this.client,
this.contracts_
);
- return erc20['getContract']();
- }).then(contract => {
- const method = contract.method(
- "transfer",
- to,
- Converter.toHex(amount)
- );
- return this.processWrite(
- method, option
- );
+ return erc20.transfer(to, amount);
});
}
-
}
\ No newline at end of file

MODIFY
src/utils/base_token.ts
src/utils/base_token.ts
import { Web3SideChainClient } from "./web3_side_chain_client";
import { ITransactionConfig, ITransactionOption, IContractInitParam } from "../interfaces";
import { BaseContractMethod, BaseContract, BaseWeb3Client } from "../abstracts";
-import { merge } from "../utils";
+import { Converter, merge } from "../utils";
import { EXTRA_GAS_FOR_PROXY_CALL } from "../constant";
import { ContractWriteResult } from "../helpers";
import { promiseResolve } from "./promise_resolve";
import { ERROR_TYPE } from "../enums";
+import { TYPE_AMOUNT } from "../types";
export interface ITransactionConfigParam {
txConfig: ITransactionConfig;
@@ -192,4 +193,17 @@ export class BaseToken {
}
}
+ transfer(to: string, amount: TYPE_AMOUNT, option?: ITransactionOption) {
+ return this.getContract().then(contract => {
+ const method = contract.method(
+ "transfer",
+ to,
+ Converter.toHex(amount)
+ );
+ return this.processWrite(
+ method, option
+ );
+ });
+ }
+
}
\ No newline at end of file

implement transfer