fix: process write default option
MODIFY
src/model/base_token.ts
src/model/base_token.ts
@@ -16,7 +16,7 @@ interface ITransactionConfigParam {
export class BaseToken {
- contract: BaseContract;
+ protected contract: BaseContract;
constructor(
protected contractParam: IContractInitParam,
@@ -25,7 +25,8 @@ export class BaseToken {
this.contract = this.getContract(contractParam);
}
- protected processWrite(method: BaseContractMethod, option: ITransactionOption): Promise<ContractWriteResult> {
+ protected processWrite(method: BaseContractMethod, option: ITransactionOption = {}): Promise<ContractWriteResult> {
+
return this.createTransactionConfig(
{
txConfig: option,

MODIFY
src/model/web3_side_chain_client.ts
src/model/web3_side_chain_client.ts
@@ -56,8 +56,12 @@ export class Web3SideChainClient {
return this.metaNetwork.abi(name, type);
}
- get mainContracts() {
+ get mainPlasmaContracts() {
return this.metaNetwork.Main.Contracts;
}
+
+ get mainPOSContracts() {
+ return this.metaNetwork.Main.POSContracts;
+ }
}

MODIFY
src/plasma/index.ts
src/plasma/index.ts
@@ -25,7 +25,7 @@ export class PlasmaClient {
this.client_ = new Web3SideChainClient(config);
- const mainContracts = this.client_.mainContracts;
+ const mainContracts = this.client_.mainPlasmaContracts;
config = Object.assign(
{

MODIFY
src/pos/index.ts
src/pos/index.ts
@@ -17,12 +17,11 @@ export class POSClient {
this.client_ = new Web3SideChainClient(config);
- const mainContracts = this.client_.mainContracts;
-
+ const mainContracts = this.client_.mainPOSContracts;
config = Object.assign(
{
- rootChainManager: mainContracts.POSContracts.RootChainManagerProxy
+ rootChainManager: mainContracts.RootChainManagerProxy
} as IPOSClientConfig,
config
);

MODIFY
src/pos/pos_token.ts
src/pos/pos_token.ts
@@ -5,7 +5,7 @@ import { ExitManager } from "./exit_manager";
export class POSToken extends BaseToken {
- predicateAddress: string;
+ private predicateAddress: string;
constructor(
contractParam: IContractInitParam,

MODIFY
src/tsconfig.json
src/tsconfig.json
"removeComments": false,
"sourceMap": true,
"inlineSources": true,
- // "out": "output/jsstore.js",
"target": "es5",
"preserveConstEnums": true,
"declaration": true,

MODIFY
test/debug.js
test/debug.js
-const { use, Web3Plugin, PlasmaClient } = require("@maticnetwork/maticjs");
+const { use, Web3Plugin, PlasmaClient, POSClient } = require("@maticnetwork/maticjs");
const HDWalletProvider = require("@truffle/hdwallet-provider");
-const { user1, plasma, rpc } = require("./config");
+const { user1, plasma, rpc, pos } = require("./config");
use(Web3Plugin);
const from = user1.address;
const execute = async () => {
const privateKey = user1.privateKey;
- const erc20TokenMumbaiAddress = plasma.child.erc20;
- const goerliTokenERC20 = plasma.parent.erc20;
- const matic = new PlasmaClient({
+ // const erc20TokenMumbaiAddress = plasma.child.erc20;
+ // const goerliTokenERC20 = plasma.parent.erc20;
+
+ const erc20POSTokenMumbai = pos.child.erc20;
+ const erc20POSTokenGoerli = pos.parent.erc20;
+
+ const maticPlasma = new PlasmaClient({
network: 'testnet',
version: 'mumbai',
parent: {
@@ -26,26 +30,53 @@ const execute = async () => {
}
});
+ const maticPOS = new POSClient({
+ network: 'testnet',
+ version: 'mumbai',
+ parent: {
+ provider: new HDWalletProvider(privateKey, rpc.parent),
+ defaultConfig: {
+ from
+ }
+ },
+ child: {
+ provider: new HDWalletProvider(privateKey, rpc.child),
+ defaultConfig: {
+ from
+ }
+ }
+ });
+
+ // const childErc20 = maticPOS.erc20(erc20POSTokenMumbai);
+
+ // const balance = await childErc20.getBalance(from);
+ // console.log('balance', balance);
+
+ const parentErc20 = maticPOS.erc20(erc20POSTokenGoerli, true);
+
+ // const balance = await parentErc20.getBalance(from);
+ // console.log('balance', balance);
+
+ const approveResult = await parentErc20.approve('1000000000000000');
+ console.log('txHash', await approveResult.getTransactionHash());
+ console.log('receipt', await approveResult.getReceipt());
+
+
+
// const childErc20 = matic.erc20(erc20TokenMumbaiAddress);
// const balance = await childErc20.getBalance(from);
// console.log('balance', balance);
- const rootTokenErc20 = matic.erc20(goerliTokenERC20, true);
- const approveResult = await rootTokenErc20.approve('1000000000000000');
- const txHash = await approveResult.getTransactionHash();
- console.log("txHash", txHash);
- const txReceipt = await approveResult.getReceipt();
- console.log("txReceipt", txReceipt);
- // const promise = rootTokenErc20.approve(
- // '1000000000000000'
- // )
- // promise.on("txHash", (txHash) => {
- // console.log("transaction hash args", txHash);
- // });
- // console.log("promise result", promise);
- // const result = await promise;
- // console.log("approve result", result);
+ // const rootTokenErc20 = maticPlasma.erc20(goerliTokenERC20, true);
+ // const approveResult = await rootTokenErc20.approve('1000000000000000');
+ // const txHash = await approveResult.getTransactionHash();
+ // console.log("txHash", txHash);
+ // const txReceipt = await approveResult.getReceipt();
+ // console.log("txReceipt", txReceipt);
+
+
+
}
execute().then(_ => {

fix: process write default option