update example with latest version of maticjs - 3.0.0.beta.9
MODIFY
examples/config.js
examples/config.js
@@ -5,20 +5,6 @@ const env = dotenv.config({
});
module.exports = {
- plasma: {
- parent: {
- erc20: '0x3f152B63Ec5CA5831061B2DccFb29a874C317502',
- erc721: '0x4f765cd1d33b2e9ae6dcba1f5852de93b285eb78',
- },
- child: {
- erc721: '0x0f3Fb1354337965BAd0775a75c692D167fbb39F9',
- erc20: '0x2d7882beDcbfDDce29Ba99965dd3cdF7fcB10A1e',
- },
- registryAddress: '0x56B082d0a590A7ce5d170402D6f7f88B58F71988',
- rootChainAddress: '0x82a72315E16cE224f28E1F1fB97856d3bF83f010', // The address for the main Plasma contract in Ropsten testnet
- withdrawManagerAddress: '0x3cf9aD3395028a42EAfc949e2EC4588396b8A7D4', // An address for the WithdrawManager contract on Ropsten testnet
- depositManagerAddress: '0x3Bc6701cA1C32BBaC8D1ffA2294EE3444Ad93989', // An address for a DepositManager contract in Ropsten testnet
- },
parent: {
rpc: process.env.ROOT_RPC,
},

MODIFY
examples/package-lock.json
examples/package-lock.json
}
},
"@maticnetwork/maticjs": {
- "version": "3.0.0-beta.6",
- "resolved": "https://registry.npmjs.org/@maticnetwork/maticjs/-/maticjs-3.0.0-beta.6.tgz",
- "integrity": "sha512-roSomBPkf8Q5JrmBX+N1HJdKHiSxA3QpHgIVT5KqxpBftmiEGllFMVHmIlG8SKMLRpSkDxxvPI6JDuoXvPn2nQ==",
+ "version": "3.0.0-beta.9",
+ "resolved": "https://registry.npmjs.org/@maticnetwork/maticjs/-/maticjs-3.0.0-beta.9.tgz",
+ "integrity": "sha512-csVxIRD+g/K4X82gdacPmYm7TEGiyJdvrznxis1saEin0xN5ZfxdbWCNKLNIVJVXapGtWihnW/6hvecaz8Yvog==",
"requires": {
"bn.js": "5.0.0",
"eth-sig-util": "^2.5.3",
"integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA=="
},
"node-fetch": {
- "version": "2.6.5",
- "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.5.tgz",
- "integrity": "sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ==",
+ "version": "2.6.6",
+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.6.tgz",
+ "integrity": "sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==",
"requires": {
"whatwg-url": "^5.0.0"
}

MODIFY
examples/package.json
examples/package.json
"author": "",
"license": "ISC",
"dependencies": {
- "@maticnetwork/maticjs": "^3.0.0-beta.6",
+ "@maticnetwork/maticjs": "^3.0.0-beta.9",
"@maticnetwork/maticjs-web3": "^0.2.0",
"dotenv": "^10.0.0"
}

DELETE
examples/pos/ether/burn.js
-const { getMaticPOSClient, pos, from } = require('../../utils')
-
-const amount = '100000000000000000'
-const execute = async () => {
- try {
- const tx = await getMaticPOSClient().burnERC20(pos.child.weth, amount)
- console.log(tx.transactionHash) // eslint-disable-line
- } catch (e) {
- console.error(e) // eslint-disable-line
- }
-}
-
-execute().then(() => process.exit(0))

MODIFY
examples/pos/ether/deposit.js
examples/pos/ether/deposit.js
-const { getMaticPOSClient, from } = require('../../utils')
-
-const amount = '100000000000000000'
+const { getPOSClient, from } = require('../../utils');
const execute = async () => {
- try {
- const tx = await getMaticPOSClient().depositEtherForUser(from, amount, {
- from,
- })
- console.log(tx.transactionHash) // eslint-disable-line
- } catch (e) {
- console.error(e) // eslint-disable-line
- }
-}
+ const client = await getPOSClient();
+ const result = await client.depositEther(100, from);
+
+ const txHash = await result.getTransactionHash();
+ console.log("txHash", txHash);
+ const receipt = await result.getReceipt();
+ console.log("receipt", receipt);
-execute().then(() => process.exit(0))
+};
+
+execute().then(() => {
+}).catch(err => {
+ console.error("err", err);
+}).finally(_ => {
+ process.exit(0);
+})
\ No newline at end of file

DELETE
examples/pos/ether/exit.js
-const { getMaticPOSClient, pos, from } = require('../../utils')
-
-const burnHash = '0xbadbf10a33ba5ae48cfa1660e011eb15bf927773610ace9466c71d14749d4132'
-
-const execute = async () => {
- try {
- const tx = await getMaticPOSClient().exitERC20(burnHash)
- console.log(tx.transactionHash) // eslint-disable-line
- } catch (e) {
- console.error(e) // eslint-disable-line
- }
-}
-
-execute().then(() => process.exit(0))

ADD
examples/pos/ether/withdraw_exit.js
+const { getPOSClient, pos } = require('../../utils');
+
+const burnHash = '0xbadbf10a33ba5ae48cfa1660e011eb15bf927773610ace9466c71d14749d4132'
+
+
+const execute = async () => {
+ const client = await getPOSClient();
+ const erc20Token = client.erc20(pos.parent.erc20, true);
+
+ const result = await erc20Token.withdrawExit(burnHash);
+
+ const txHash = await result.getTransactionHash();
+ console.log("txHash", txHash);
+ const receipt = await result.getReceipt();
+ console.log("receipt", receipt);
+
+}
+execute().then(() => {
+}).catch(err => {
+ console.error("err", err);
+}).finally(_ => {
+ process.exit(0);
+})
\ No newline at end of file

ADD
examples/pos/ether/withdraw_start.js
+const { pos } = require('../../config');
+const { getPOSClient, from } = require('../../utils');
+
+const execute = async () => {
+ const client = await getPOSClient();
+ const erc20Token = client.erc20(pos.child.weth);
+
+ const result = await erc20Token.withdrawStart(10);
+
+ const txHash = await result.getTransactionHash();
+ console.log("txHash", txHash);
+ const receipt = await result.getReceipt();
+ console.log("receipt", receipt);
+
+}
+execute().then(() => {
+}).catch(err => {
+ console.error("err", err);
+}).finally(_ => {
+ process.exit(0);
+})
\ No newline at end of file

RENAME
examples/pos/deposit_ether.js
examples/pos/is_deposited.js
+const { pos } = require('../config');
const { getPOSClient, from } = require('../utils');
const execute = async () => {
const client = await getPOSClient();
- const result = await client.depositEther(100);
- const txHash = await result.getTransactionHash();
- console.log("txHash", txHash);
- const receipt = await result.getReceipt();
- console.log("receipt", receipt);
+ const isDeposited = await client.isDeposited('0xc67599f5c967f2040786d5924ec55d37bf943c009bdd23f3b50e5ae66efde258');
+ console.log("isDeposited", isDeposited);
}
execute().then(() => {
}).catch(err => {

update example with latest version of maticjs - 3.0.0.beta.9