add erc20 withdraw example
MODIFY
examples/pos/erc20/approve.js
examples/pos/erc20/approve.js
-const { pos, from, getMaticPOSClient } = require('../../utils')
-
-const amount = '1000000000000000' // amount in wei
-const erc20TokenOnParent = pos.parent.erc20
-async function execute() {
- const maticPOSClient = getMaticPOSClient()
- const result = await maticPOSClient.approveERC20ForDeposit(erc20TokenOnParent, amount, { from })
- console.log(result)
-}
+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 result = await erc20Token.approve(10);
-execute().then(_ => {
- process.exit(0)
+ 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

DELETE
examples/pos/erc20/burn.js
-const { getMaticPOSClient, pos, from } = require('../../utils')
-
-const amount = '1000000000000000' // amount in wei
-const token = pos.child.erc20
-
-const execute = async () => {
- try {
- const tx = await getMaticPOSClient().burnERC20(token, amount, {
- from: from,
- gasPrice: 900000000000,
- gas: 300000,
- })
- console.log(tx) // eslint-disable-line
- } catch (e) {
- console.error(e) // eslint-disable-line
- }
-}
-
-execute().then(() => process.exit(0))

MODIFY
examples/pos/erc20/deposit.js
examples/pos/erc20/deposit.js
-const { getMaticPOSClient, from, pos } = require('../../utils')
-
-const amount = '1000000000000000' // amount in wei
-const token = pos.parent.erc20
+const { pos } = require('../../config');
+const { getPOSClient, from } = require('../../utils');
const execute = async () => {
- try {
- const tx = await getMaticPOSClient().depositERC20ForUser(token, from, amount)
- console.log(tx.transactionHash) // eslint-disable-line
- } catch (e) {
- console.error(e) // eslint-disable-line
- }
-}
+ const client = await getPOSClient();
+ const erc20Token = client.erc20(pos.parent.erc20, true);
-execute().then(() => process.exit(0))
+ const result = await erc20Token.deposit(10, from);
+
+ 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

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

ADD
examples/pos/erc20/withdraw_exit.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 result = await erc20Token.withdrawExit('0x086e38e832bc967c79c34afaa9fece5cbf1fa4e593f649c28c06174005d44d6b');
+
+ 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/erc20/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.erc20);
+
+ 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

add erc20 withdraw example