fix issue with depositMany in erc721
MODIFY
src/pos/erc721.ts
src/pos/erc721.ts
@@ -178,10 +178,10 @@ export class ERC721 extends POSToken {
depositMany(tokenIds: TYPE_AMOUNT[], userAddress: string, option?: ITransactionOption) {
this.checkForRoot("depositMany");
- const tokensInUint256 = this.validateMany_(tokenIds);
+ const tokensInHex = this.validateMany_(tokenIds);
const amountInABI = this.client.parent.encodeParameters(
- tokensInUint256,
+ [tokensInHex],
['uint256[]'],
);
return this.rootChainManager.deposit(
@@ -208,12 +208,12 @@ export class ERC721 extends POSToken {
withdrawStartMany(tokenIds: TYPE_AMOUNT[], option?: ITransactionOption) {
this.checkForChild("withdrawStartMany");
+ const tokensInHex = this.validateMany_(tokenIds);
- const tokensInUint256 = this.validateMany_(tokenIds);
return this.getContract().then(contract => {
const method = contract.method(
"withdrawBatch",
- tokensInUint256
+ tokensInHex
);
return this.processWrite(method, option);
});

MODIFY
test/debug.js
test/debug.js
@@ -40,7 +40,7 @@ const execute = async () => {
- return console.log(await client.isDeposited('0xc67599f5c967f2040786d5924ec55d37bf943c009bdd23f3b50e5ae66efde258'));
+ // return console.log(await client.isDeposited('0xc67599f5c967f2040786d5924ec55d37bf943c009bdd23f3b50e5ae66efde258'));
// const balance = await mumbaiERC20Token.getBalance(
@@ -48,15 +48,17 @@ const execute = async () => {
// );
// return console.log("balance", balance);
- // const tokens = await mumbaiERC721Token.getAllTokens(
+ // const tokens = await goerliERC721Token.getAllTokens(
// from
// );
// return console.log("tokens", tokens);
- const tx = await client.depositEther('10000', from, {
- // returnTransaction: true
+ // const tx = await goerliERC721Token.approveAll();
+
+ const tx = await goerliERC721Token.depositMany(['70362948865848051982628883253610138761681237831617060123833093242173388773544'], from, {
+ returnTransaction: true
});
- // console.log('tx', tx);
+ return console.log('tx', tx);
// // setProofApi("https://apis.matic.network")
// // const tx = await goerliERC20Token.withdrawExit('0xd6f7f4c6052611761946519076de28fbd091693af974e7d4abc1b17fd7926fd7');
console.log("txHash", await tx.getTransactionHash());

MODIFY
test/specs/erc721.spec.ts
test/specs/erc721.spec.ts
import { erc721, from, posClient, posClientForTo, to, } from "./client";
import { expect } from 'chai'
+import { ABIManager, setProofApi } from '@maticnetwork/maticjs'
describe('ERC721', () => {
@@ -7,8 +8,12 @@ describe('ERC721', () => {
let erc721Child = posClient.erc721(erc721.child);
let erc721Parent = posClient.erc721(erc721.parent, true);
+ const abiManager = new ABIManager("testnet", "mumbai");
before(() => {
- return posClient.init();
+ return Promise.all([
+ posClient.init(),
+ abiManager.init()
+ ]);
});
it('getTokensCounts child', async () => {
@@ -68,6 +73,24 @@ describe('ERC721', () => {
expect(result['to'].toLowerCase()).equal(erc721.parent.toLowerCase());
})
+ it('deposit return tx', async () => {
+ const allTokens = await erc721Parent.getAllTokens(from);
+ const tx = await erc721Parent.deposit(allTokens[0], from, {
+ returnTransaction: true
+ });
+ const rootChainManager = await abiManager.getConfig("Main.POSContracts.RootChainManagerProxy")
+ expect(tx['to'].toLowerCase()).equal(rootChainManager.toLowerCase());
+ })
+
+ it('depositMany return tx', async () => {
+ const allTokens = await erc721Parent.getAllTokens(from);
+ const tx = await erc721Parent.depositMany(allTokens, from, {
+ returnTransaction: true
+ });
+ const rootChainManager = await abiManager.getConfig("Main.POSContracts.RootChainManagerProxy")
+ expect(tx['to'].toLowerCase()).equal(rootChainManager.toLowerCase());
+ })
+
it('withdrawStart return tx', async () => {
const allTokens = await erc721Child.getAllTokens(from);
const result = await erc721Child.withdrawStart(allTokens[0], {
@@ -78,9 +101,9 @@ describe('ERC721', () => {
it('transfer write', async () => {
const allTokensFrom = await erc721Child.getAllTokens(from);
- console.log('allTokensFrom', allTokensFrom);
+ // console.log('allTokensFrom', allTokensFrom);
const allTokensTo = await erc721Child.getAllTokens(to);
- console.log('allTokensTo', allTokensTo);
+ // console.log('allTokensTo', allTokensTo);
const targetToken = allTokensFrom[0];
let result = await erc721Child.transfer(targetToken, from, to);
@@ -101,10 +124,10 @@ describe('ERC721', () => {
const newAllTokensFrom = await erc721Child.getAllTokens(from);
- console.log('newAllTokensFrom', newAllTokensFrom);
+ // console.log('newAllTokensFrom', newAllTokensFrom);
expect(newAllTokensFrom.length).equal(allTokensFrom.length - 1);
const newAllTokensTo = await erc721Child.getAllTokens(to);
- console.log('newAllTokensTo', newAllTokensTo);
+ // console.log('newAllTokensTo', newAllTokensTo);
expect(newAllTokensTo.length).equal(allTokensTo.length + 1);
await posClientForTo.init();

fix issue with depositMany in erc721