implement depositEther and remove ether
MODIFY
src/interfaces/plasma_client_config.ts
src/interfaces/plasma_client_config.ts
@@ -6,4 +6,5 @@ export interface IPlasmaClientConfig extends IBaseClientConfig {
withdrawManager?: string;
registry?: string;
rootChain?: string;
+ erc20Predicate?: string;
}
\ No newline at end of file

MODIFY
src/plasma/erc20.ts
src/plasma/erc20.ts
@@ -92,6 +92,16 @@ export class ERC20 extends PlasmaToken {
});
}
+ depositEther(amount: TYPE_AMOUNT, option: ITransactionOption = {}) {
+ return this.contracts_.depositManager.getContract().then(contract => {
+ option.value = Converter.toHex(amount);
+ const method = contract.method(
+ "depositEther",
+ );
+ return this.processWrite(method, option);
+ });
+ }
+
withdrawStart(amount: TYPE_AMOUNT, option?: ITransactionOption) {
this.checkForChild_("withdrawStart");
@@ -141,4 +151,5 @@ export class ERC20 extends PlasmaToken {
}
+
}
\ No newline at end of file

DELETE
src/plasma/ether.ts
-import { TYPE_AMOUNT } from "../types";
-import { IPlasmaContracts, ITransactionOption } from "../interfaces";
-import { Web3SideChainClient, Converter, BaseToken } from "../utils";
-import { ERC20 } from "./erc20";
-
-export class Ether extends BaseToken {
-
-
- constructor(
- isParent: boolean,
- client: Web3SideChainClient,
- private contracts_: IPlasmaContracts
- ) {
-
- super({
- isParent: isParent,
- address: null as any,
- name: null as any,
- bridgeType: null
- }, client);
- }
-
- deposit(amount: TYPE_AMOUNT, option: ITransactionOption = {}) {
- return this.contracts_.depositManager.getContract().then(contract => {
- option.value = Converter.toHex(amount);
- const method = contract.method(
- "depositEther",
- );
- return this.processWrite(method, option);
- });
- }
-
- transfer(amount: TYPE_AMOUNT, to: string, option: ITransactionOption = {}) {
- const isParent = this.contractParam.isParent;
- if (isParent) {
- option.to = to;
- option.value = Converter.toHex(amount);
- return this.sendTransaction(option);
- }
- return this.contracts_.registry.getContract().then(contract => {
- return contract.method("getWethTokenAddress").read<string>();
- }).then(ethAddress => {
- const erc20 = new ERC20(
- ethAddress,
- isParent,
- this.client,
- this.contracts_
- );
- return erc20.transfer(to, amount);
- });
- }
-}
\ No newline at end of file

MODIFY
src/plasma/index.ts
src/plasma/index.ts
@@ -4,7 +4,6 @@ import { BridgeClient, Web3SideChainClient } from "../utils";
import { IPlasmaClientConfig, IPlasmaContracts, ITransactionOption } from "../interfaces";
import { DepositManager } from "./deposit_manager";
import { RegistryContract } from "./registry";
-import { Ether } from "./ether";
import { ExitManager, RootChain } from "../pos";
import { WithdrawManager } from "./withdraw_manager";
import { MATIC_TOKEN_ADDRESS_ON_POLYGON } from "../constant";
@@ -19,35 +18,6 @@ export class PlasmaClient extends BridgeClient {
registry: RegistryContract;
rootChain: RootChain;
- private getContracts__() {
- return {
- depositManager: this.depositManager,
- exitManager: this.exitManager,
- registry: this.registry,
- withdrawManager: this.withdrawManager
- } as IPlasmaContracts;
- }
-
- erc20(tokenAddress: string, isParent?: boolean) {
- tokenAddress = tokenAddress == null && !isParent ?
- MATIC_TOKEN_ADDRESS_ON_POLYGON : tokenAddress;
-
- return new ERC20(
- tokenAddress,
- isParent,
- this.client_,
- this.getContracts__()
- );
- }
-
- erc721(tokenAddress: string, isParent?: boolean) {
- return new ERC721(
- tokenAddress,
- isParent,
- this.client_,
- this.getContracts__()
- );
- }
constructor(config: IPlasmaClientConfig) {
super();
@@ -100,8 +70,34 @@ export class PlasmaClient extends BridgeClient {
});
}
- ether(isParent?) {
- return new Ether(isParent, this.client_, this.getContracts__());
+ private getContracts__() {
+ return {
+ depositManager: this.depositManager,
+ exitManager: this.exitManager,
+ registry: this.registry,
+ withdrawManager: this.withdrawManager
+ } as IPlasmaContracts;
+ }
+
+ erc20(tokenAddress: string, isParent?: boolean) {
+ tokenAddress = tokenAddress == null && !isParent ?
+ MATIC_TOKEN_ADDRESS_ON_POLYGON : tokenAddress;
+
+ return new ERC20(
+ tokenAddress,
+ isParent,
+ this.client_,
+ this.getContracts__()
+ );
+ }
+
+ erc721(tokenAddress: string, isParent?: boolean) {
+ return new ERC721(
+ tokenAddress,
+ isParent,
+ this.client_,
+ this.getContracts__()
+ );
}
withdrawExit(tokens: string | string[], option?: ITransactionOption) {

implement depositEther and remove ether