release v - 3.0.0-beta.1
MODIFY
package-lock.json
package-lock.json
{
"name": "@maticnetwork/maticjs",
- "version": "3.0.0-beta.0",
+ "version": "3.0.0-beta.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

MODIFY
package.json
package.json
{
"name": "@maticnetwork/maticjs",
- "version": "3.0.0-beta.0",
+ "version": "3.0.0-beta.1",
"description": "Javascript developer library for interacting with Matic Network",
"main": "dist/npm.export.js",
"types": "dist/ts/index.d.ts",

MODIFY
src/abstracts/base_web3_client.ts
src/abstracts/base_web3_client.ts
@@ -25,7 +25,7 @@ export abstract class BaseWeb3Client {
abstract getBlock(blockHashOrBlockNumber): Promise<IBlock>;
abstract getBlockWithTransaction(blockHashOrBlockNumber): Promise<IBlockWithTransaction>;
- getRootHash(startBlock: number, endBlock: number) {
+ getRootHash?(startBlock: number, endBlock: number) {
return this.sendRPCRequest({
jsonrpc: '2.0',
method: 'eth_getRootHash',

MODIFY
src/constant.ts
src/constant.ts
-import { MaticWeb3Client } from "./web3js";
import { Logger } from "./utils";
import BN from "bn.js";
+import { BaseWeb3Client } from "./abstracts";
-export let Web3Client = MaticWeb3Client;
+export let Web3Client: typeof BaseWeb3Client;
export const setWeb3Client = (web3Client) => {
Web3Client = web3Client;

MODIFY
src/utils/web3_side_chain_client.ts
src/utils/web3_side_chain_client.ts
@@ -21,8 +21,8 @@ export class Web3SideChainClient {
throw new Error("Web3Client is not set");
}
- this.parent = new Web3Client(config.parent.provider, this.logger);
- this.child = new Web3Client(config.child.provider, this.logger);
+ this.parent = new (Web3Client as any)(config.parent.provider, this.logger);
+ this.child = new (Web3Client as any)(config.child.provider, this.logger);
}

DELETE
src/web3js/eth_contract.ts
-import { BaseContract } from "../abstracts";
-import Contract from "web3/eth/contract";
-import { EthMethod } from "./eth_method";
-
-export class Web3Contract extends BaseContract {
- contract: Contract;
-
- constructor(address: string, contract: Contract, logger) {
- super(address, logger);
- this.contract = contract;
- }
-
- method(methodName: string, ...args) {
- this.logger.log("args method", arguments);
- return new EthMethod(
- this.logger, this.contract.methods[methodName](...args)
- );
- }
-}
\ No newline at end of file

DELETE
src/web3js/eth_method.ts
-import { BaseContractMethod } from "../abstracts";
-import { ITransactionConfig } from "../interfaces";
-import { TransactionObject, Tx } from "web3/eth/types";
-import { doNothing } from "../helpers";
-import { Logger } from "../utils";
-
-export class EthMethod extends BaseContractMethod {
-
- constructor(logger: Logger, private method: TransactionObject<any>) {
- super(logger);
- }
-
- private toConfig_(config: ITransactionConfig = {}) {
- return {
- chainId: config.chainId,
- data: config.data,
- from: config.from,
- gas: config.gasLimit,
- gasPrice: config.gasPrice,
- nonce: config.nonce,
- to: config.to,
- value: config.value
- } as Tx;
- }
-
- read<T>(tx: ITransactionConfig): Promise<T> {
- this.logger.log("sending tx with config", tx);
- return this.method.call(
- this.toConfig_(tx)
- );
- }
-
- write(tx: ITransactionConfig) {
- const result = {
- onTransactionHash: (doNothing as any),
- onReceipt: doNothing,
- onReceiptError: doNothing,
- onTxError: doNothing
- };
- setTimeout(() => {
- this.logger.log("sending tx with config", tx);
- this.method.send(
- this.toConfig_(tx)
- ).once("transactionHash", result.onTransactionHash).
- once("receipt", result.onReceipt).
- on("error", result.onTxError).
- on("error", result.onReceiptError);
- }, 0);
- return result;
- }
-
- estimateGas(tx: ITransactionConfig): Promise<number> {
- return this.method.estimateGas(tx as any);
- }
-
- encodeABI() {
- return this.method.encodeABI();
- }
-
-}
\ No newline at end of file

DELETE
src/web3js/index.ts
-export * from "./eth_contract";
-export * from "./web3_client";
\ No newline at end of file

DELETE
src/web3js/web3_client.ts
-import { Web3Contract } from "./eth_contract";
-import Web3 from "web3";
-import { ITransactionConfig, ITransactionData, ITransactionReceipt, IBlockWithTransaction, IJsonRpcRequestPayload, IJsonRpcResponse } from "../interfaces";
-import { Transaction } from "web3/eth/types";
-import { AbstractProvider } from "web3-core";
-import { BaseWeb3Client } from "../abstracts";
-import { Logger } from "../utils";
-import { doNothing } from "../helpers";
-
-export class MaticWeb3Client extends BaseWeb3Client {
- private web3_: Web3;
-
- constructor(provider: any, logger: Logger) {
- super(logger);
- this.web3_ = new Web3(provider);
- }
-
- read(config: ITransactionConfig) {
- return this.web3_.eth.call(config);
- }
-
- write(config: ITransactionConfig) {
- const result = {
- onTransactionHash: (doNothing as any),
- onReceipt: doNothing,
- onReceiptError: doNothing,
- onTxError: doNothing
- };
- setTimeout(() => {
- this.logger.log("sending tx with config", config);
- this.web3_.eth.sendTransaction(
- {
- chainId: config.chainId,
- data: config.data,
- from: config.from,
- gas: config.gasLimit,
- gasPrice: config.gasPrice,
- nonce: config.nonce,
- to: config.to,
- value: config.value
- }
- ).once("transactionHash", result.onTransactionHash).
- once("receipt", result.onReceipt).
- on("error", result.onTxError).
- on("error", result.onReceiptError);
- }, 0);
- return result;
- }
-
- getContract(address: string, abi: any) {
- const cont = new this.web3_.eth.Contract(abi, address);
- return new Web3Contract(address, cont as any, this.logger);
- }
-
- getGasPrice() {
- return this.web3_.eth.getGasPrice();
- }
-
- estimateGas(config: ITransactionConfig) {
- return this.web3_.eth.estimateGas(
- config
- );
- }
-
- getTransactionCount(address: string, blockNumber: any) {
- return this.web3_.eth.getTransactionCount(address, blockNumber);
- }
-
- getChainId() {
- return this.web3_.eth.net.getId();
- }
-
- getTransaction(transactionHash: string) {
- return this.web3_.eth.getTransaction(transactionHash).then(data => {
- return this.toTransaction(data);
- });
- }
-
- private toTransaction(data: Transaction) {
- const tx: ITransactionData = data as any;
- tx.transactionHash = data.hash;
- return tx;
- }
-
- getTransactionReceipt(transactionHash: string): Promise<ITransactionReceipt> {
- return this.web3_.eth.getTransactionReceipt(transactionHash).then(data => {
- return {
- blockHash: data.blockHash,
- blockNumber: data.blockNumber,
- contractAddress: data.contractAddress,
- cumulativeGasUsed: data.cumulativeGasUsed,
- from: data.from,
- gasUsed: data.gasUsed,
- status: data.status,
- to: data.to,
- transactionHash: data.transactionHash,
- transactionIndex: data.transactionIndex,
- events: data.events,
- logs: data.logs,
- logsBloom: data.logsBloom,
- root: (data as any).root,
- type: (data as any).type
- } as ITransactionReceipt;
- });
- }
-
- getBlock(blockHashOrBlockNumber) {
- return (this.web3_.eth.getBlock(blockHashOrBlockNumber) as any);
- }
-
- getBlockWithTransaction(blockHashOrBlockNumber) {
- return this.web3_.eth.getBlock(blockHashOrBlockNumber, true).then(result => {
- const blockData: IBlockWithTransaction = result as any;
- blockData.transactions = result.transactions.map(tx => {
- return this.toTransaction(tx);
- });
- return blockData;
- });
- }
-
- sendRPCRequest(request: IJsonRpcRequestPayload) {
- return new Promise<IJsonRpcResponse>((res, rej) => {
- (this.web3_.currentProvider as AbstractProvider).send(request, (error, result) => {
- if (error) return rej(error);
- res(result);
- });
- });
- }
-
- encodeParameters(params: any[], types: any[]) {
- return this.web3_.eth.abi.encodeParameters(types, params);
- }
-
- etheriumSha3(...value) {
- return Web3.utils.soliditySha3(...value);
- }
-}
\ No newline at end of file

MODIFY
test/debug.js
test/debug.js
@@ -7,10 +7,10 @@ const from = user1.address;
const execute = async () => {
const privateKey = user1.privateKey;
- const mumbaiERC720 = plasma.child.erc20;
- const goerliERC720 = plasma.parent.erc20;
+ const mumbaiERC720 = pos.child.erc721;
+ const goerliERC720 = plasma.parent.erc721;
- const client = new PlasmaClient({
+ const client = new POSClient({
network: 'testnet',
version: 'mumbai',
parent: {
@@ -31,8 +31,8 @@ const execute = async () => {
await client.init();
console.log("init called");
- const mumbaiERC720Token = client.erc20(mumbaiERC720);
- const goerliERC720Token = client.erc20(goerliERC720, true);
+ const mumbaiERC720Token = client.erc721(mumbaiERC720);
+ const goerliERC720Token = client.erc721(goerliERC720, true);
// const balance = await mumbaiERC720Token.getBalance(from);
@@ -44,7 +44,10 @@ const execute = async () => {
// console.log("txReceipt", await tx.getReceipt());
//txhash to plasma exit - 0x63aa095e0d6ee8698399b871daa202eb5522933e2d94c5929cf0fb86b6b0c628
- const tx = await goerliERC720Token.withdrawExit()
+ const tokenId = '60399350241383852757821046101235634991156913804166740995010931519407953501076'
+
+ const tx = await mumbaiERC720Token.withdrawStart(32);
+ // console.log("tx", tx);
// const tx = await mumbaiERC720Token.withdrawStart(
// 10,
// {

release v - 3.0.0-beta.1