fix: erc20 examples and added extra APIs
ADD
examples/.env.example
+FROM=0x
+PRIVATE_KEY=0x
+USER2_ADDRESS=0x
+ROOT_RPC=
+MATIC_RPC=
\ No newline at end of file

MODIFY
examples/config.js
examples/config.js
@@ -14,13 +14,13 @@ module.exports = {
pos: {
parent: {
erc20: '0x655f2166b0709cd575202630952d71e2bb0d61af',
- erc721: '0x5a08d01e07714146747950CE07BB0f741445D1b8',
+ erc721: '0x16F7EF3774c59264C46E5063b1111bCFd6e7A72f',
erc1155: '0x2e3Ef7931F2d0e4a7da3dea950FF3F19269d9063',
- chainManagerAddress: '0x86B4EC021875d0123ED209A333B29D67F9AC6540', // Address of RootChainManager for POS Portal
+ chainManagerAddress: '0xBbD7cBFA79faee899Eaf900F13C9065bF03B1A74', // Address of RootChainManager for POS Portal
},
child: {
- erc721: '0xEC8CB8bBb069470bC358ffB0e3710c64830da383',
- erc20: '0x2d7882beDcbfDDce29Ba99965dd3cdF7fcB10A1e',
+ erc721: '0xbD88C3A7c0e242156a46Fbdf87141Aa6D0c0c649',
+ erc20: '0xfe4F5145f6e09952a5ba9e956ED0C25e3Fa4c7F1',
weth: '0x714550C2C1Ea08688607D86ed8EeF4f5E4F22323',
erc1155: '0xA07e45A987F19E25176c877d98388878622623FA',
},

RENAME
examples/pos/ether/withdraw_start.js
examples/pos/erc20/approve_max.js
@@ -3,9 +3,9 @@ const { getPOSClient, from } = require('../../utils');
const execute = async () => {
const client = await getPOSClient();
- const erc20Token = client.erc20(pos.child.weth);
+ const erc20Token = client.erc20(pos.parent.erc20, true);
- const result = await erc20Token.withdrawStart(10);
+ const result = await erc20Token.approveMax();
const txHash = await result.getTransactionHash();
console.log("txHash", txHash);

MODIFY
examples/pos/erc20/balance.js
examples/pos/erc20/balance.js
@@ -3,9 +3,9 @@ const { getPOSClient, from } = require('../../utils');
const execute = async () => {
const client = await getPOSClient();
- const erc720Token = client.erc20(pos.child.erc20);
+ const erc20Token = client.erc20(pos.child.erc20);
- const result = await erc720Token.getBalance(from);
+ const result = await erc20Token.getBalance(from);
console.log("result", result);

RENAME
examples/pos/ether/deposit.js
examples/pos/erc20/deposit_ether.js
MODIFY
examples/pos/erc20/get_allowance.js
examples/pos/erc20/get_allowance.js
@@ -3,9 +3,9 @@ const { getPOSClient, from } = require('../../utils');
const execute = async () => {
const client = await getPOSClient();
- const erc720Token = client.erc20(pos.parent.erc20, true);
+ const erc20Token = client.erc20(pos.parent.erc20, true);
- const result = await erc720Token.getAllowance(from);
+ const result = await erc20Token.getAllowance(from);
console.log("result", result);

ADD
examples/pos/erc20/is_withdraw_exited.js
+const { pos } = require('../../config');
+const { getPOSClient, from } = require('../../utils');
+
+const execute = async () => {
+ const client = await getPOSClient();
+ const erc20Token = client.erc20(pos.parent.erc20, true);
+ const isExited = await erc20Token.isWithdrawExited('0xb005d8db45f33836c422ee18286fa8ebe49b4ec7b9930e673d85ecd081cc3b8e');
+
+ console.log("result", isExited);
+}
+execute().then(() => {
+}).catch(err => {
+ console.error("err", err);
+}).finally(_ => {
+ process.exit(0);
+})
\ No newline at end of file

MODIFY
examples/pos/erc20/transfer.js
examples/pos/erc20/transfer.js
@@ -3,11 +3,10 @@ const { getPOSClient, to } = require('../../utils');
const execute = async () => {
const client = await getPOSClient();
- const erc720Token = client.erc20(pos.parent.erc20);
+ const erc20Token = client.erc20(pos.parent.erc20, true);
- const result = await erc720Token.transfer(to, 10, {
- gasPrice: '4000000000',
- nonce: 11795,
+ const result = await erc20Token.transfer(100, to, {
+ gasPrice: '30000000000',
});
const txHash = await result.getTransactionHash();

MODIFY
examples/pos/erc20/withdraw_exit.js
examples/pos/erc20/withdraw_exit.js
@@ -5,7 +5,7 @@ const execute = async () => {
const client = await getPOSClient();
const erc20Token = client.erc20(pos.parent.erc20, true);
- const result = await erc20Token.withdrawExit('0x086e38e832bc967c79c34afaa9fece5cbf1fa4e593f649c28c06174005d44d6b');
+ const result = await erc20Token.withdrawExit('0xb005d8db45f33836c422ee18286fa8ebe49b4ec7b9930e673d85ecd081cc3b8e');
const txHash = await result.getTransactionHash();
console.log("txHash", txHash);

DELETE
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

MODIFY
examples/pos/is_check_pointed.js
examples/pos/is_check_pointed.js
@@ -4,7 +4,7 @@ const { getPOSClient, from } = require('../utils');
const execute = async () => {
const client = await getPOSClient();
- const result = await client.isCheckPointed('0xf63a77f1b6435e5d89c8958d80b658350f74409188a8efa17d51044d3a32e1d0');
+ const result = await client.isCheckPointed('0xb005d8db45f33836c422ee18286fa8ebe49b4ec7b9930e673d85ecd081cc3b8e');
console.log("result", result);
}

MODIFY
examples/pos/is_deposited.js
examples/pos/is_deposited.js
@@ -4,7 +4,7 @@ const { getPOSClient, from } = require('../utils');
const execute = async () => {
const client = await getPOSClient();
- const isDeposited = await client.isDeposited('0xc67599f5c967f2040786d5924ec55d37bf943c009bdd23f3b50e5ae66efde258');
+ const isDeposited = await client.isDeposited('0x967ab5578a09d278db8b400354e874a0e5d38374db7b9edc42a3640fffdb3c7c');
console.log("isDeposited", isDeposited);
}

fix: erc20 examples and added extra APIs