rm plasma folder from examples
DELETE
examples/plasma/deposit_status_from_txhash.js
-const { getMaticPlasmaClient } = require('../utils')
-
-const txHash = '0x8cff1ef2b198273fe7f9fb41918cd7e3e8d04c58650614af39b3086e1de1a7e6'
-
-const execute = async () => {
- const { matic } = await getMaticPlasmaClient()
- await matic.depositStatusFromTxHash(txHash).then(res => {
- console.log(res) // eslint-disable-line
- })
-}
-
-execute().then(_ => {
- process.exit(0)
-})

DELETE
examples/plasma/erc20/approve.js
-const { getMaticPlasmaClient, plasma, from } = require('../../utils')
-
-const amount = '1000000000000000' // amount in wei
-const erc20TokenOnParent = plasma.parent.erc20
-async function execute() {
- const { matic } = await getMaticPlasmaClient()
- const result = await matic.approveERC20TokensForDeposit(erc20TokenOnParent, amount, { from })
- console.log(result)
-}
-
-async function executeRaw() {
- // eslint-disable-line
- const { matic } = await getMaticPlasmaClient()
- const { from } = getAccount()
- const txParams = await matic.approveERC20TokensForDeposit(erc20TokenOnParent, amount, { from, encodeAbi: true })
- let serializedTx = utils.buildRawTransaction(txParams, user1.privateKey)
- return matic.web3Client.parentWeb3.eth.sendSignedTransaction(serializedTx)
-}
-
-execute().then(_ => {
- process.exit(0)
-})

DELETE
examples/plasma/erc20/balance.js
-const { getMaticPlasmaClient, from, plasma } = require('../../utils')
-
-const execute = async () => {
- const { matic } = await getMaticPlasmaClient()
- const balance = await matic.balanceOfERC20(from, plasma.child.erc20, {})
- console.log('balance', balance)
-}
-
-execute().then(_ => {
- process.exit(0)
-})

DELETE
examples/plasma/erc20/deposit.js
-const { getMaticPlasmaClient, plasma, from } = require('../../utils')
-
-const amount = '1000000000000000' // amount in wei
-const token = plasma.parent.erc20
-async function execute() {
- const { matic } = await getMaticPlasmaClient()
- // get approved first
- await matic.approveERC20TokensForDeposit(token, amount, { from, gasPrice: '10000000000' })
- // then deposit
- return matic.depositERC20ForUser(token, from, amount, { from, gasPrice: '10000000000' })
-}
-
-async function executeRaw() {
- // eslint-disable-line
- const { matic } = await getMaticPlasmaClient()
- const { from } = getAccount()
-
- // get approved first
- let txParams = await matic.approveERC20TokensForDeposit(token, amount, { from, encodeAbi: true })
- let serializedTx = utils.buildRawTransaction(txParams, user1.privateKey)
- await matic.web3Client.parentWeb3.eth.sendSignedTransaction(serializedTx)
-
- txParams = await matic.depositERC20ForUser(token, from, amount, { from, encodeAbi: true })
- serializedTx = utils.buildRawTransaction(txParams, user1.privateKey)
- return matic.web3Client.parentWeb3.eth.sendSignedTransaction(serializedTx)
-}
-
-execute()
- .then(console.log)
- .then(_ => {
- process.exit(0)
- })

DELETE
examples/plasma/erc20/get_allowance.js
-const { plasma } = require('../../config');
-const { getPlasmaClient, from } = require('../../utils');
-
-const execute = async () => {
- const client = await getPlasmaClient();
- const erc720Token = client.erc20(plasma.parent.erc20, true);
-
- const result = await erc720Token.getAllowance(from);
-
- console.log("result", result);
-
-}
-execute().then(() => {
-}).catch(err => {
- console.error("err", err);
-}).finally(_ => {
- process.exit(0);
-})
\ No newline at end of file

DELETE
examples/plasma/erc20/start_withdraw.js
-const { getMaticPlasmaClient, from, plasma } = require('../../utils')
-
-const amount = '1000000000000000' // amount in wei
-const token = plasma.child.erc20
-async function execute() {
- const { matic } = await getMaticPlasmaClient()
-
- await matic
- .startWithdraw(token, amount, {
- from,
- })
- .then(res => {
- console.log(res) // eslint-disable-line
- })
-}
-
-execute().then(_ => {
- process.exit(0)
-})

DELETE
examples/plasma/erc20/transfer.js
-const { getMaticPlasmaClient, from, plasma, to } = require('../../utils')
-
-const amount = '1000000000000000' // amount in wei
-const token = plasma.child.erc20
-const recipient = to
-async function execute() {
- const { matic } = await getMaticPlasmaClient()
-
- await matic
- .transferERC20Tokens(token, recipient, amount, {
- from,
- // parent: true, // For token transfer on Main network (false for Matic Network)
- })
- .then(result => {
- console.log('hash', result) // eslint-disable-line
- })
-}
-
-execute().then(_ => {
- process.exit(0)
-})

DELETE
examples/plasma/erc20/withdraw.js
-const { getMaticPlasmaClient, from } = require('../../utils')
-
-var transactionHash = '0xbbaf7712bc426b665650992215f9c15ac9bda72bbb4e7d453ba9ed3875e0ebf5' // Insert txHash generated from initiate-withdraw.js
-
-async function execute() {
- const { matic } = await getMaticPlasmaClient()
-
- await matic
- .withdraw(transactionHash, {
- from,
- })
- .then(result => {
- console.log(result)
- })
-}
-
-execute().then(_ => {
- process.exit(0)
-})

DELETE
examples/plasma/erc721/balance.js
-const { getMaticPlasmaClient, from, plasma } = require('../../utils')
-
-const execute = async () => {
- const { matic } = await getMaticPlasmaClient()
- const balance = await matic.balanceOfERC721(from, plasma.child.erc721, {})
- console.log('balance', balance)
-}
-
-execute().then(_ => {
- process.exit(0)
-})

DELETE
examples/plasma/erc721/deposit.js
-const { getMaticPlasmaClient, plasma, from } = require('../../utils')
-
-const token = plasma.parent.erc721
-const tokenId721 = '2'
-async function execute() {
- const { matic } = await getMaticPlasmaClient()
- // get approved first
- await matic.safeDepositERC721Tokens(token, tokenId721, { from, gasPrice: '10000000000' })
-}
-
-execute()
- .then(console.log)
- .then(_ => {
- process.exit(0)
- })

DELETE
examples/plasma/erc721/start_withdraw.js
-const { getMaticPlasmaClient, plasma, from } = require('../../utils')
-
-const token = plasma.child.erc721
-const tokenId721 = 1963
-async function execute() {
- const { matic } = await getMaticPlasmaClient()
- // get approved first
- await matic.startWithdrawForNFT(token, tokenId721, { from })
-}
-
-execute()
- .then(console.log)
- .catch(console.log)
- .finally(_ => {
- process.exit(0)
- })

DELETE
examples/plasma/erc721/token_of_owner.js
-const { getMaticPlasmaClient, plasma, from } = require('../../utils')
-
-const token = plasma.parent.erc721
-async function execute() {
- const { matic } = await getMaticPlasmaClient()
- // get approved first
- await matic.tokenOfOwnerByIndexERC721(from, token, 2, { from, gasPrice: '10000000000' })
-}
-
-execute()
- .then(console.log)
- .then(_ => {
- process.exit(0)
- })

DELETE
examples/plasma/erc721/transfer.js
-const { getMaticPlasmaClient, from, plasma, to } = require('../../utils')
-
-const tokenId = '2' // amount in wei
-const token = plasma.child.erc721
-const recipient = to
-async function execute() {
- const { matic } = await getMaticPlasmaClient()
-
- await matic
- .transferERC721Tokens(token, recipient, tokenId, {
- from,
- // parent: true, // For token transfer on Main network (false for Matic Network)
- })
- .then(result => {
- console.log('hash', result) // eslint-disable-line
- })
- .catch(console.log)
-}
-
-execute().then(_ => {
- process.exit(0)
-})

DELETE
examples/plasma/erc721/withdraw.js
-const { getMaticPlasmaClient, from } = require('../../utils')
-
-var transactionHash = '0xbbaf7712bc426b665650992215f9c15ac9bda72bbb4e7d453ba9ed3875e0ebf5' // Insert txHash generated from initiate-withdraw.js
-
-async function execute() {
- const { matic } = await getMaticPlasmaClient()
-
- await matic
- .withdrawNFT(transactionHash, {
- from,
- })
- .then(result => {
- console.log(result)
- })
-}
-
-execute().then(_ => {
- process.exit(0)
-})

DELETE
examples/plasma/process_exit.js
-const { plasma } = require('../config')
-const { getMaticPlasmaClient, from } = require('../utils')
-
-const rootTokenAddress = plasma.parent.erc20
-
-const execute = async () => {
- const { matic } = await getMaticPlasmaClient()
- await matic
- .processExits(rootTokenAddress, {
- from,
- })
- .then(res => {
- console.log(res) // eslint-disable-line
- })
-}
-
-execute().then(_ => {
- process.exit(0)
-})

MODIFY
src/utils/web3_side_chain_client.ts
src/utils/web3_side_chain_client.ts
@@ -14,21 +14,20 @@ export class Web3SideChainClient<T_CONFIG> {
logger = new Logger();
- constructor(config: T_CONFIG) {
+ constructor(config: IBaseClientConfig) {
config = config || {} as any;
- const baseConfig: IBaseClientConfig = config as any;
- baseConfig.parent.defaultConfig = baseConfig.parent.defaultConfig || {} as any;
- baseConfig.child.defaultConfig = baseConfig.child.defaultConfig || {} as any;
- this.config = baseConfig as any;
+ config.parent.defaultConfig = config.parent.defaultConfig || {} as any;
+ config.child.defaultConfig = config.child.defaultConfig || {} as any;
+ this.config = config as any;
if (!Web3Client) {
throw new Error("Web3Client is not set");
}
- this.parent = new (Web3Client as any)(baseConfig.parent.provider, this.logger);
- this.child = new (Web3Client as any)(baseConfig.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);
- this.logger.enableLog(baseConfig.log);
+ this.logger.enableLog(config.log);
}
init() {

rm plasma folder from examples