test balance with ethers
MODIFY
src/ethers/ethjs_method.ts
src/ethers/ethjs_method.ts
@@ -20,7 +20,12 @@ export class ContractMethod extends BaseContractMethod {
}
read(config: ITransactionConfig) {
- return this.getMethod_(config);
+ return this.getMethod_(config).then(result => {
+ if (result._isBigNumber) {
+ result = result.toString();
+ }
+ return result;
+ });
}
private getMethod_(config: ITransactionConfig) {

MODIFY
src/web3js/eth_method.ts
src/web3js/eth_method.ts
@@ -2,7 +2,6 @@ import { BaseContractMethod } from "../abstracts";
import { ITransactionConfig } from "../interfaces";
import { TransactionObject } from "web3/eth/types";
import { doNothing } from "../helpers";
-import { LOGGER } from "../constant";
import { Logger } from "../utils";
export class EthMethod extends BaseContractMethod {
@@ -12,7 +11,7 @@ export class EthMethod extends BaseContractMethod {
}
read<T>(tx: ITransactionConfig): Promise<T> {
- LOGGER.log("sending tx with config", tx);
+ this.logger.log("sending tx with config", tx);
return this.method.call(tx as any);
}

MODIFY
test/debug.js
test/debug.js
-const { use, Web3Plugin, PlasmaClient, POSClient, ProofUtil } = require("@maticnetwork/maticjs");
+const { use, EthersPlugin, PlasmaClient, POSClient, ProofUtil } = require("@maticnetwork/maticjs");
// return console.log("BaseToken", ProofUtil, use);
const HDWalletProvider = require("@truffle/hdwallet-provider");
const { user1, plasma, rpc, pos } = require("./config");
+const { providers, Wallet } = require("ethers");
-// use(Web3Plugin);
+use(EthersPlugin);
const from = user1.address;
const execute = async () => {
const privateKey = user1.privateKey;
- const mumbaiERC721 = pos.child.erc20;
+ const mumbaiERC720 = pos.child.erc20;
const goerliERC721 = pos.parent.erc20;
+ // const matic = 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 parentPrivder = new providers.JsonRpcProvider(rpc.parent);
+ const childProvider = new providers.JsonRpcProvider(rpc.child);
+
+
const matic = new POSClient({
network: 'testnet',
version: 'mumbai',
parent: {
- provider: new HDWalletProvider(privateKey, rpc.parent),
+ provider: new Wallet(privateKey, parentPrivder),
defaultConfig: {
from
}
},
child: {
- provider: new HDWalletProvider(privateKey, rpc.child),
+ provider: new Wallet(privateKey, childProvider),
defaultConfig: {
from
}
}
});
- const tx = await matic.erc20(mumbaiERC721).withdrawStart(
+ const mumbaiERC720Token = matic.erc20(mumbaiERC720);
+ // return console.log("balance", await mumbaiERC720Token.getBalance(from));
+
+
+ const tx = await mumbaiERC720Token.withdrawStart(
10,
{
nonce: 1974,

test balance with ethers