add test for erc721
MODIFY
examples/config.js
examples/config.js
@@ -3,6 +3,7 @@ module.exports = {
plasma: {
parent: {
erc20: '0x3f152B63Ec5CA5831061B2DccFb29a874C317502',
+ erc721: '0x4f765cd1d33b2e9ae6dcba1f5852de93b285eb78',
},
child: {
erc721: '0x0f3Fb1354337965BAd0775a75c692D167fbb39F9',

RENAME
examples/plasma/erc20_approve.js
examples/plasma/erc20/approve.js
-const { getMaticPlasmaClient, getAccount, plasma, from } = require('../utils')
+const { getMaticPlasmaClient, plasma, from } = require('../../utils')
const amount = '1000000000000000' // amount in wei
const erc20TokenOnParent = plasma.parent.erc20

RENAME
examples/plasma/erc20_balance.js
examples/plasma/erc20/balance.js
-const { getMaticPlasmaClient, from, plasma } = require('../utils')
+const { getMaticPlasmaClient, from, plasma } = require('../../utils')
const execute = async () => {
const { matic } = await getMaticPlasmaClient()

RENAME
examples/plasma/erc20_deposit.js
examples/plasma/erc20/deposit.js
-const { getMaticPlasmaClient, plasma, from } = require('../utils')
+const { getMaticPlasmaClient, plasma, from } = require('../../utils')
const amount = '1000000000000000' // amount in wei
const token = plasma.parent.erc20

RENAME
examples/plasma/erc20_start_withdraw.js
examples/plasma/erc20/start_withdraw.js
-const { getMaticPlasmaClient, from, plasma, to } = require('../utils')
+const { getMaticPlasmaClient, from, plasma } = require('../../utils')
const amount = '1000000000000000' // amount in wei
const token = plasma.child.erc20

RENAME
examples/plasma/erc20_transfer.js
examples/plasma/erc20/transfer.js
-const { getMaticPlasmaClient, from, plasma, to } = require('../utils')
+const { getMaticPlasmaClient, from, plasma, to } = require('../../utils')
const amount = '1000000000000000' // amount in wei
const token = plasma.child.erc20

RENAME
examples/plasma/erc20_withdraw.js
examples/plasma/erc20/withdraw.js
-const { getMaticPlasmaClient, from } = require('../utils')
+const { getMaticPlasmaClient, from } = require('../../utils')
var transactionHash = '0xbbaf7712bc426b665650992215f9c15ac9bda72bbb4e7d453ba9ed3875e0ebf5' // Insert txHash generated from initiate-withdraw.js

ADD
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)
+})

ADD
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)
+ })

ADD
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)
+ })

ADD
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)
+ })

ADD
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)
+})

ADD
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)
+})

add test for erc721