From 9a0e9a0bde1a94820eaf1a53770d0c7835e8c0c2 Mon Sep 17 00:00:00 2001 From: Vadim Yavorsky Date: Wed, 13 Nov 2024 19:22:57 +0000 Subject: [PATCH] Refactor contract interaction to use instance directly instead of getAddress --- .../test/MessageProxyForSchainTester.sol | 4 +- test/CommunityLocker.ts | 18 +- test/CommunityPool.ts | 22 +- test/DepositBoxERC1155.ts | 94 +- test/DepositBoxERC20.ts | 216 ++--- test/DepositBoxERC721.ts | 80 +- test/DepositBoxERC721WithMetadata.ts | 80 +- test/DepositBoxEth.ts | 42 +- test/Linker.ts | 82 +- test/MessageProxy.ts | 232 ++--- test/TokenManagerERC1155.ts | 834 +++++++++--------- test/TokenManagerERC20.ts | 558 ++++++------ test/TokenManagerERC721.ts | 490 +++++----- test/TokenManagerERC721WithMetadata.ts | 500 +++++------ test/TokenManagerEth.ts | 69 +- test/TokenManagerLinker.ts | 74 +- .../ERC721MintingFromSchainToMainnet.ts | 70 +- test/utils/deploy/mainnet/communityPool.ts | 12 +- .../utils/deploy/mainnet/depositBoxERC1155.ts | 4 +- test/utils/deploy/mainnet/depositBoxERC20.ts | 4 +- test/utils/deploy/mainnet/depositBoxERC721.ts | 4 +- .../mainnet/depositBoxERC721WithMetadata.ts | 4 +- test/utils/deploy/mainnet/depositBoxEth.ts | 4 +- test/utils/deploy/mainnet/linker.ts | 4 +- .../deploy/mainnet/messageProxyForMainnet.ts | 4 +- test/utils/deploy/schain/communityLocker.ts | 11 +- .../deploy/schain/tokenManagerERC1155.ts | 6 +- test/utils/deploy/schain/tokenManagerERC20.ts | 6 +- .../utils/deploy/schain/tokenManagerERC721.ts | 6 +- .../schain/tokenManagerERC721WithMetadata.ts | 6 +- test/utils/deploy/schain/tokenManagerEth.ts | 6 +- .../utils/deploy/schain/tokenManagerLinker.ts | 8 +- test/utils/deploy/test/communityPoolTester.ts | 6 +- test/utils/deploy/test/fallbackEthTester.ts | 2 +- .../test/messageProxyForMainnetTester.ts | 4 +- .../test/messageProxyForSchainTester.ts | 4 +- .../skale-manager-utils/contractManager.ts | 18 +- test/utils/skale-manager-utils/keyStorage.ts | 2 +- .../skale-manager-utils/schainsInternal.ts | 2 +- test/utils/skale-manager-utils/wallets.ts | 4 +- 40 files changed, 1813 insertions(+), 1783 deletions(-) diff --git a/contracts/test/MessageProxyForSchainTester.sol b/contracts/test/MessageProxyForSchainTester.sol index a40c88093..6838d25f8 100644 --- a/contracts/test/MessageProxyForSchainTester.sol +++ b/contracts/test/MessageProxyForSchainTester.sol @@ -43,7 +43,7 @@ interface IMessageProxyForSchainTester { } -contract MessageProxyForSchainTester is MessageProxyForSchain, IMessageProxyForSchainTester { +contract MessageProxyForSchainTester is MessageProxyForSchain, IMessageProxyForSchainTester { IEtherbaseUpgradeable public etherbase = ETHERBASE; @@ -82,4 +82,4 @@ contract MessageProxyForSchainTester is MessageProxyForSchain, IMessageProxyForS function _getEtherbase() internal view override returns (IEtherbaseUpgradeable) { return etherbase; } -} \ No newline at end of file +} diff --git a/test/CommunityLocker.ts b/test/CommunityLocker.ts index 5cd895398..088b67b0c 100644 --- a/test/CommunityLocker.ts +++ b/test/CommunityLocker.ts @@ -65,11 +65,11 @@ describe("CommunityLocker", () => { beforeEach(async () => { messages = await deployMessages(); - fakeCommunityPool = await messages.getAddress(); + fakeCommunityPool = user.address; const messageProxyForSchainWithoutSignatureFactory = await ethers.getContractFactory("MessageProxyForSchainWithoutSignature"); messageProxyForSchain = await messageProxyForSchainWithoutSignatureFactory.deploy("MyChain") as MessageProxyForSchainWithoutSignature; tokenManagerLinker = await deployTokenManagerLinker(messageProxyForSchain, deployer.address); - communityLocker = await deployCommunityLocker(schainName, await messageProxyForSchain.getAddress(), tokenManagerLinker, fakeCommunityPool); + communityLocker = await deployCommunityLocker(schainName, messageProxyForSchain, tokenManagerLinker, fakeCommunityPool); }) it("should activate user", async () => { @@ -79,19 +79,19 @@ describe("CommunityLocker", () => { await communityLocker.postMessage(mainnetHash, fakeCommunityPool, data) .should.be.eventually.rejectedWith("Sender is not a message proxy"); - await messageProxyForSchain.postMessage(await communityLocker.getAddress(), mainnetHash, deployer.address, data) + await messageProxyForSchain.postMessage(communityLocker, mainnetHash, deployer.address, data) .should.be.eventually.rejectedWith("Sender must be CommunityPool"); - await messageProxyForSchain.postMessage(await communityLocker.getAddress(), schainHash, fakeCommunityPool, data) + await messageProxyForSchain.postMessage(communityLocker, schainHash, fakeCommunityPool, data) .should.be.eventually.rejectedWith("Source chain name must be Mainnet"); - await messageProxyForSchain.postMessage(await communityLocker.getAddress(), mainnetHash, fakeCommunityPool, fakeData) + await messageProxyForSchain.postMessage(communityLocker, mainnetHash, fakeCommunityPool, fakeData) .should.be.eventually.rejectedWith("The message should contain a status of user"); expect(await communityLocker.activeUsers(deployer.address)).to.be.equal(false); - await messageProxyForSchain.postMessage(await communityLocker.getAddress(), mainnetHash, fakeCommunityPool, data); - await messageProxyForSchain.postMessage(await communityLocker.getAddress(), mainnetHash, fakeCommunityPool, data) + await messageProxyForSchain.postMessage(communityLocker, mainnetHash, fakeCommunityPool, data); + await messageProxyForSchain.postMessage(communityLocker, mainnetHash, fakeCommunityPool, data) .should.be.eventually.rejectedWith("Active user statuses must be different"); expect(await communityLocker.activeUsers(deployer.address)).to.be.equal(true); }); @@ -99,9 +99,9 @@ describe("CommunityLocker", () => { it("should activate and then lock user", async () => { const activateData = await messages.encodeActivateUserMessage(user.address); const lockData = await messages.encodeLockUserMessage(user.address); - await messageProxyForSchain.postMessage(await communityLocker.getAddress(), mainnetHash, fakeCommunityPool, activateData); + await messageProxyForSchain.postMessage(communityLocker, mainnetHash, fakeCommunityPool, activateData); expect(await communityLocker.activeUsers(user.address)).to.be.equal(true); - await messageProxyForSchain.postMessage(await communityLocker.getAddress(), mainnetHash, fakeCommunityPool, lockData); + await messageProxyForSchain.postMessage(communityLocker, mainnetHash, fakeCommunityPool, lockData); expect(await communityLocker.activeUsers(user.address)).to.be.equal(false); }); diff --git a/test/CommunityPool.ts b/test/CommunityPool.ts index 3b462ce6a..b7d07b5f7 100644 --- a/test/CommunityPool.ts +++ b/test/CommunityPool.ts @@ -129,11 +129,11 @@ describe("CommunityPool", () => { it("should not allow to withdraw from user wallet if CommunityPool is not registered for all chains", async () => { const extraContractRegistrarRole = await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(); await messageProxy.grantRole(extraContractRegistrarRole, deployer.address); - await messageProxy.registerExtraContractForAll(await communityPool.getAddress()); + await messageProxy.registerExtraContractForAll(communityPool); const tx = await messageProxy.addConnectedChain(schainName); const wei = BigInt(minTransactionGas) * tx.gasPrice; await communityPool.connect(user).rechargeUserWallet(schainName, user.address, { value: wei.toString() }); - await messageProxy.removeExtraContractForAll(await communityPool.getAddress()); + await messageProxy.removeExtraContractForAll(communityPool); await communityPool.connect(user).withdrawFunds(schainName, wei.toString()) .should.be.eventually.rejectedWith("Sender contract is not registered"); }); @@ -141,14 +141,14 @@ describe("CommunityPool", () => { describe("when chain connected and contract registered", async () => { let gasPrice: BigNumberish; beforeEach(async () => { - await messageProxy.registerExtraContract(schainName, await communityPool.getAddress()); + await messageProxy.registerExtraContract(schainName, communityPool); gasPrice = ((await messageProxy.addConnectedChain(schainName)).gasPrice) as BigNumberish; }); it("should not allow to withdraw from user wallet if CommunityPool is not registered", async () => { const amount = BigInt(minTransactionGas) * BigInt(gasPrice); await communityPool.connect(user).rechargeUserWallet(schainName, user.address, { value: amount.toString() }); - await messageProxy.removeExtraContract(schainName, await communityPool.getAddress()); + await messageProxy.removeExtraContract(schainName, communityPool); await communityPool.connect(user).withdrawFunds(schainName, amount.toString()) .should.be.eventually.rejectedWith("Sender contract is not registered"); }); @@ -232,7 +232,7 @@ describe("CommunityPool", () => { await communityPool.addSchainContract(schainName2, mockContractOnSchain); for (const schain of [schainName, schainName2]) { - await messageProxy.registerExtraContract(schain, await communityPool.getAddress()); + await messageProxy.registerExtraContract(schain, communityPool); await messageProxy.addConnectedChain(schain); } @@ -248,12 +248,12 @@ describe("CommunityPool", () => { await expect(res1) .to.emit(messageProxy, "OutgoingMessage") - .withArgs(schainHash, 0, await communityPool.getAddress(), mockContractOnSchain, activateUserData); + .withArgs(schainHash, 0, communityPool, mockContractOnSchain, activateUserData); await expect(res2) .to.emit(messageProxy, "OutgoingMessage") - .withArgs(schainHash2, 0, await communityPool.getAddress(), mockContractOnSchain, activateUserData); + .withArgs(schainHash2, 0, communityPool, mockContractOnSchain, activateUserData); const res3 = await communityPool.connect(user).rechargeUserWallet( schainName, @@ -321,7 +321,7 @@ describe("CommunityPool", () => { it("should be rejected with Node address must be set", async () => { const tx = await messageProxyTester.addConnectedChain(schainNameRGBU); - await messageProxyTester.registerExtraContract(schainNameRGBU, await communityPoolTester.getAddress()); + await messageProxyTester.registerExtraContract(schainNameRGBU, communityPoolTester); const gasPrice = tx.gasPrice as BigNumberish; const wei = BigInt(minTransactionGas) * BigInt(gasPrice) * 2n; await communityPoolTester.connect(user).rechargeUserWallet(schainNameRGBU, user.address, { value: wei.toString() }); @@ -332,7 +332,7 @@ describe("CommunityPool", () => { it("should refund node", async () => { const balanceBefore = await getBalance(node.address); const tx = await messageProxyTester.addConnectedChain(schainNameRGBU); - await messageProxyTester.registerExtraContract(schainNameRGBU, await communityPoolTester.getAddress()); + await messageProxyTester.registerExtraContract(schainNameRGBU, communityPoolTester); const gasPrice = tx.gasPrice as BigNumberish; const wei = BigInt(minTransactionGas) * BigInt(gasPrice) * 2n; await communityPoolTester.connect(user).rechargeUserWallet(schainNameRGBU, user.address, { value: wei.toString() }); @@ -344,7 +344,7 @@ describe("CommunityPool", () => { it("should lock user", async () => { const tx = await messageProxyTester.addConnectedChain(schainNameRGBU); - await messageProxyTester.registerExtraContract(schainNameRGBU, await communityPoolTester.getAddress()); + await messageProxyTester.registerExtraContract(schainNameRGBU, communityPoolTester); const gasPrice = tx.gasPrice as BigNumberish; const wei = BigInt(minTransactionGas) * BigInt(gasPrice); expect(await communityPoolTester.activeUsers(user.address, schainHashRGBU)).to.be.false; @@ -356,7 +356,7 @@ describe("CommunityPool", () => { it("should lock user with extra low balance", async () => { const tx = await messageProxyTester.addConnectedChain(schainNameRGBU); - await messageProxyTester.registerExtraContract(schainNameRGBU, await communityPoolTester.getAddress()); + await messageProxyTester.registerExtraContract(schainNameRGBU, communityPoolTester); const gasPrice = tx.gasPrice as BigNumberish; const wei = BigInt(minTransactionGas) * BigInt(gasPrice); const gasPriceDuringGasSpikes = BigInt(gasPrice) * 2n; diff --git a/test/DepositBoxERC1155.ts b/test/DepositBoxERC1155.ts index 5c61c2575..34257c362 100644 --- a/test/DepositBoxERC1155.ts +++ b/test/DepositBoxERC1155.ts @@ -106,7 +106,7 @@ describe("DepositBoxERC1155", () => { depositBoxERC1155 = await deployDepositBoxERC1155(contractManager, linker, messageProxy); communityPool = await deployCommunityPool(contractManager, linker, messageProxy); messages = await deployMessages(); - await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), await linker.getAddress()); + await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); const nodeCreationParams = { @@ -121,9 +121,9 @@ describe("DepositBoxERC1155", () => { await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); - await messageProxy.registerExtraContractForAll(await depositBoxERC1155.getAddress()); - await messageProxy.registerExtraContract(schainName, await communityPool.getAddress()); - await messageProxy.registerExtraContract(schainName, await linker.getAddress()); + await messageProxy.registerExtraContractForAll(depositBoxERC1155); + await messageProxy.registerExtraContract(schainName, communityPool); + await messageProxy.registerExtraContract(schainName, linker); }); describe("tests with `ERC1155`", async () => { @@ -152,13 +152,13 @@ describe("DepositBoxERC1155", () => { const fakeERC1155Contract = deployer.address; await depositBoxERC1155.connect(user).addERC1155TokenByOwner(schainName, fakeERC1155Contract) .should.be.eventually.rejectedWith("Given address is not a contract"); - await depositBoxERC1155.connect(deployer).addERC1155TokenByOwner(schainName, await erc1155.getAddress()) + await depositBoxERC1155.connect(deployer).addERC1155TokenByOwner(schainName, erc1155) .should.be.eventually.rejectedWith("Sender is not an Schain owner"); - await depositBoxERC1155.connect(user).addERC1155TokenByOwner(schainName, await erc1155.getAddress()); - await depositBoxERC1155.connect(user).addERC1155TokenByOwner(schainName, await erc1155.getAddress()).should.be.eventually.rejectedWith("ERC1155 Token was already added"); - expect(await depositBoxERC1155.getSchainToERC1155(schainName, await erc1155.getAddress())).to.be.equal(true); - expect((await depositBoxERC1155.getSchainToAllERC1155(schainName, 0, 1))[0]).to.be.equal(await erc1155.getAddress()); + await depositBoxERC1155.connect(user).addERC1155TokenByOwner(schainName, erc1155); + await depositBoxERC1155.connect(user).addERC1155TokenByOwner(schainName, erc1155).should.be.eventually.rejectedWith("ERC1155 Token was already added"); + expect(await depositBoxERC1155.getSchainToERC1155(schainName, erc1155)).to.be.equal(true); + expect((await depositBoxERC1155.getSchainToAllERC1155(schainName, 0, 1))[0]).to.be.equal(erc1155); expect((await depositBoxERC1155.getSchainToAllERC1155(schainName, 0, 1)).length).to.be.equal(1); expect((await depositBoxERC1155.getSchainToAllERC1155Length(schainName)).toString()).to.be.equal("1"); await depositBoxERC1155.getSchainToAllERC1155(schainName, 1, 0).should.be.eventually.rejectedWith("Range is incorrect"); @@ -169,7 +169,7 @@ describe("DepositBoxERC1155", () => { it("should rejected with `DepositBox was not approved for ERC1155 token`", async () => { // preparation const error = "DepositBox was not approved for ERC1155 token"; - const contractHere = await erc1155.getAddress(); + const contractHere = erc1155; const id = 5; const amount = 7; // the wei should be MORE than (55000 * 1000000000) @@ -188,7 +188,7 @@ describe("DepositBoxERC1155", () => { it("should invoke `depositERC1155` without mistakes", async () => { // preparation - const contractHere = await erc1155.getAddress(); + const contractHere = erc1155; const id = 5; const amount = 7; const id2 = 10; @@ -200,7 +200,7 @@ describe("DepositBoxERC1155", () => { .connect(deployer) .connectSchain(schainName, [deployer.address, deployer.address, deployer.address]); // transfer tokenId from `deployer` to `depositBoxERC1155` - await erc1155.connect(deployer).setApprovalForAll(await depositBoxERC1155.getAddress(), true); + await erc1155.connect(deployer).setApprovalForAll(depositBoxERC1155, true); // execution await depositBoxERC1155 .connect(deployer) @@ -214,13 +214,13 @@ describe("DepositBoxERC1155", () => { .depositERC1155(schainName, contractHere, id2, amount2)).wait(); // console.log("Gas for depositERC1155:", res.receipt.gasUsed); // expectation - expect(await erc1155.balanceOf(await depositBoxERC1155.getAddress(), id)).to.equal(amount); - expect(await erc1155.balanceOf(await depositBoxERC1155.getAddress(), id2)).to.equal(amount2); + expect(await erc1155.balanceOf(depositBoxERC1155, id)).to.equal(amount); + expect(await erc1155.balanceOf(depositBoxERC1155, id2)).to.equal(amount2); }); it("should invoke `depositERC1155Direct` without mistakes", async () => { // preparation - const contractHere = await erc1155.getAddress(); + const contractHere = erc1155; const to = user.address; const id = 5; const amount = 7; @@ -233,7 +233,7 @@ describe("DepositBoxERC1155", () => { .connect(deployer) .connectSchain(schainName, [deployer.address, deployer.address, deployer.address]); // transfer tokenId from `deployer` to `depositBoxERC1155` - await erc1155.connect(deployer).setApprovalForAll(await depositBoxERC1155.getAddress(), true); + await erc1155.connect(deployer).setApprovalForAll(depositBoxERC1155, true); // execution await depositBoxERC1155 .connect(deployer) @@ -245,22 +245,22 @@ describe("DepositBoxERC1155", () => { .connect(deployer) .depositERC1155Direct(schainName, contractHere, id, amount, to) .should.emit(messageProxy, "OutgoingMessage") - .withArgs(schainHash, 0, await depositBoxERC1155.getAddress(), deployer.address, data1); + .withArgs(schainHash, 0, depositBoxERC1155, deployer.address, data1); await depositBoxERC1155 .connect(deployer) .depositERC1155Direct(schainName, contractHere, id2, amount2, to) .should.emit(messageProxy, "OutgoingMessage") - .withArgs(schainHash, 1, await depositBoxERC1155.getAddress(), deployer.address, data2); + .withArgs(schainHash, 1, depositBoxERC1155, deployer.address, data2); // console.log("Gas for depositERC1155:", res.receipt.gasUsed); // expectation - expect(await erc1155.balanceOf(await depositBoxERC1155.getAddress(), id)).to.equal(amount); - expect(await erc1155.balanceOf(await depositBoxERC1155.getAddress(), id2)).to.equal(amount2); + expect(await erc1155.balanceOf(depositBoxERC1155, id)).to.equal(amount); + expect(await erc1155.balanceOf(depositBoxERC1155, id2)).to.equal(amount2); }); it("should rejected with `DepositBox was not approved for ERC1155 token Batch`", async () => { // preparation const error = "DepositBox was not approved for ERC1155 token Batch"; - const contractHere = await erc1155.getAddress(); + const contractHere = erc1155; const ids = [1, 2, 3]; const amounts = [3, 2, 1]; // the wei should be MORE than (55000 * 1000000000) @@ -279,7 +279,7 @@ describe("DepositBoxERC1155", () => { it("should invoke `depositERC1155Batch` without mistakes", async () => { // preparation - const contractHere = await erc1155.getAddress(); + const contractHere = erc1155; const ids = [1, 2, 3]; const amounts = [3, 2, 1]; const ids2 = [5, 4, 99]; @@ -291,7 +291,7 @@ describe("DepositBoxERC1155", () => { .connect(deployer) .connectSchain(schainName, [deployer.address, deployer.address, deployer.address]); // transfer tokenId from `deployer` to `depositBoxERC1155` - await erc1155.connect(deployer).setApprovalForAll(await depositBoxERC1155.getAddress(), true); + await erc1155.connect(deployer).setApprovalForAll(depositBoxERC1155, true); // execution await depositBoxERC1155 .connect(deployer) @@ -305,8 +305,8 @@ describe("DepositBoxERC1155", () => { .depositERC1155Batch(schainName, contractHere, ids2, amounts2)).wait(); // console.log("Gas for depositERC1155:", res.receipt.gasUsed); // expectation - const balanceIds = await erc1155.balanceOfBatch([await depositBoxERC1155.getAddress(), await depositBoxERC1155.getAddress(), await depositBoxERC1155.getAddress()], ids); - const balanceIds2 = await erc1155.balanceOfBatch([await depositBoxERC1155.getAddress(), await depositBoxERC1155.getAddress(), await depositBoxERC1155.getAddress()], ids2); + const balanceIds = await erc1155.balanceOfBatch([depositBoxERC1155, depositBoxERC1155, depositBoxERC1155], ids); + const balanceIds2 = await erc1155.balanceOfBatch([depositBoxERC1155, depositBoxERC1155, depositBoxERC1155], ids2); const balanceIdsNumber: number[] = []; const balanceIds2Number: number[] = []; balanceIds.forEach(element => { @@ -321,7 +321,7 @@ describe("DepositBoxERC1155", () => { it("should invoke `depositERC1155BatchDirect` without mistakes", async () => { // preparation - const contractHere = await erc1155.getAddress(); + const contractHere = erc1155; const to = user.address; const ids = [1, 2, 3]; const amounts = [3, 2, 1]; @@ -334,7 +334,7 @@ describe("DepositBoxERC1155", () => { .connect(deployer) .connectSchain(schainName, [deployer.address, deployer.address, deployer.address]); // transfer tokenId from `deployer` to `depositBoxERC1155` - await erc1155.connect(deployer).setApprovalForAll(await depositBoxERC1155.getAddress(), true); + await erc1155.connect(deployer).setApprovalForAll(depositBoxERC1155, true); // execution await depositBoxERC1155 .connect(deployer) @@ -346,16 +346,16 @@ describe("DepositBoxERC1155", () => { .connect(deployer) .depositERC1155BatchDirect(schainName, contractHere, ids, amounts, to) .should.emit(messageProxy, "OutgoingMessage") - .withArgs(schainHash, 0, await depositBoxERC1155.getAddress(), deployer.address, data1); + .withArgs(schainHash, 0, depositBoxERC1155, deployer.address, data1); await depositBoxERC1155 .connect(deployer) .depositERC1155BatchDirect(schainName, contractHere, ids2, amounts2, to) .should.emit(messageProxy, "OutgoingMessage") - .withArgs(schainHash, 1, await depositBoxERC1155.getAddress(), deployer.address, data2); + .withArgs(schainHash, 1, depositBoxERC1155, deployer.address, data2); // console.log("Gas for depositERC1155:", res.receipt.gasUsed); // expectation - const balanceIds = await erc1155.balanceOfBatch([await depositBoxERC1155.getAddress(), await depositBoxERC1155.getAddress(), await depositBoxERC1155.getAddress()], ids); - const balanceIds2 = await erc1155.balanceOfBatch([await depositBoxERC1155.getAddress(), await depositBoxERC1155.getAddress(), await depositBoxERC1155.getAddress()], ids2); + const balanceIds = await erc1155.balanceOfBatch([depositBoxERC1155, depositBoxERC1155, depositBoxERC1155], ids); + const balanceIds2 = await erc1155.balanceOfBatch([depositBoxERC1155, depositBoxERC1155, depositBoxERC1155], ids2); const balanceIdsNumber: number[] = []; const balanceIds2Number: number[] = []; balanceIds.forEach(element => { @@ -374,16 +374,16 @@ describe("DepositBoxERC1155", () => { .connect(deployer) .connectSchain(schainName, [deployer.address, deployer.address, deployer.address]); await erc1155.connect(deployer).mint(deployer.address, 4, 100, "0x"); - await erc1155.connect(deployer).setApprovalForAll(await depositBoxERC1155.getAddress(), true); + await erc1155.connect(deployer).setApprovalForAll(depositBoxERC1155, true); await depositBoxERC1155.connect(user).disableWhitelist(schainName); await depositBoxERC1155 .connect(deployer) - .depositERC1155(schainName, await erc1155.getAddress(), 4, 50); - await depositBoxERC1155.connect(user).getFunds(schainName, await erc1155.getAddress(), user.address, [4], [50]).should.be.eventually.rejectedWith("Schain is not killed"); + .depositERC1155(schainName, erc1155, 4, 50); + await depositBoxERC1155.connect(user).getFunds(schainName, erc1155, user.address, [4], [50]).should.be.eventually.rejectedWith("Schain is not killed"); await linker.connect(deployer).kill(schainName); await linker.connect(user).kill(schainName); - await depositBoxERC1155.connect(user).getFunds(schainName, await erc1155.getAddress(), user.address, [4], [60]).should.be.eventually.rejectedWith("Incorrect amount"); - await depositBoxERC1155.connect(user).getFunds(schainName, await erc1155.getAddress(), user.address, [4], [50]); + await depositBoxERC1155.connect(user).getFunds(schainName, erc1155, user.address, [4], [60]).should.be.eventually.rejectedWith("Incorrect amount"); + await depositBoxERC1155.connect(user).getFunds(schainName, erc1155, user.address, [4], [50]); expect(await erc1155.balanceOf(user.address, 4)).to.equal("50"); }); @@ -391,14 +391,14 @@ describe("DepositBoxERC1155", () => { const fakeERC1155Contract = deployer.address; await depositBoxERC1155.connect(user).addERC1155TokenByOwner(schainName, fakeERC1155Contract) .should.be.eventually.rejectedWith("Given address is not a contract"); - await depositBoxERC1155.connect(user).addERC1155TokenByOwner(schainName, await erc1155.getAddress()); - expect(await depositBoxERC1155.getSchainToERC1155(schainName, await erc1155.getAddress())).to.be.equal(true); + await depositBoxERC1155.connect(user).addERC1155TokenByOwner(schainName, erc1155); + expect(await depositBoxERC1155.getSchainToERC1155(schainName, erc1155)).to.be.equal(true); }); it("should not allow to add token by schain owner if schain killed", async () => { await linker.connect(deployer).kill(schainName); await linker.connect(user).kill(schainName); - await depositBoxERC1155.connect(user).addERC1155TokenByOwner(schainName, await erc1155.getAddress()) + await depositBoxERC1155.connect(user).addERC1155TokenByOwner(schainName, erc1155) .should.be.eventually.rejectedWith("Schain is killed"); }); }); @@ -412,7 +412,7 @@ describe("DepositBoxERC1155", () => { it("should transfer ERC1155 token", async () => { // preparation - const contractHere = await erc1155.getAddress(); + const contractHere = erc1155; const id = 5; const amount = 7; const to = user.address; @@ -429,7 +429,7 @@ describe("DepositBoxERC1155", () => { const message = { data: await messages.encodeTransferErc1155Message(contractHere, to, id, amount), - destinationContract: await depositBoxERC1155.getAddress(), + destinationContract: depositBoxERC1155, sender: senderFromSchain }; @@ -445,9 +445,9 @@ describe("DepositBoxERC1155", () => { // mint some ERC1155 of for `deployer` address await erc1155.connect(deployer).mint(deployer.address, id, amount, "0x"); - await erc1155.connect(deployer).setApprovalForAll(await depositBoxERC1155.getAddress(), true); + await erc1155.connect(deployer).setApprovalForAll(depositBoxERC1155, true); // transfer tokenId from `deployer` to `depositBoxERC1155` - // await erc1155.connect(deployer).transferFrom(deployer.address, await depositBoxERC1155.getAddress(), tokenId); + // await erc1155.connect(deployer).transferFrom(deployer.address, depositBoxERC1155, tokenId); // get data from `receiveERC1155` await depositBoxERC1155.connect(user2).disableWhitelist(schainName); await depositBoxERC1155 @@ -467,7 +467,7 @@ describe("DepositBoxERC1155", () => { it("should transfer ERC1155 token Batch", async () => { // preparation - const contractHere = await erc1155.getAddress(); + const contractHere = erc1155; const ids = [5, 6, 7]; const amounts = [100, 100, 100]; const to = user.address; @@ -484,7 +484,7 @@ describe("DepositBoxERC1155", () => { const message = { data: await messages.encodeTransferErc1155BatchMessage(contractHere, to, ids, amounts), - destinationContract: await depositBoxERC1155.getAddress(), + destinationContract: depositBoxERC1155, sender: senderFromSchain }; @@ -500,9 +500,9 @@ describe("DepositBoxERC1155", () => { // mint some ERC1155 of for `deployer` address await erc1155.connect(deployer).mintBatch(deployer.address, ids, amounts, "0x"); - await erc1155.connect(deployer).setApprovalForAll(await depositBoxERC1155.getAddress(), true); + await erc1155.connect(deployer).setApprovalForAll(depositBoxERC1155, true); // transfer tokenId from `deployer` to `depositBoxERC1155` - // await erc1155.connect(deployer).transferFrom(deployer.address, await depositBoxERC1155.getAddress(), tokenId); + // await erc1155.connect(deployer).transferFrom(deployer.address, depositBoxERC1155, tokenId); // get data from `receiveERC1155` await depositBoxERC1155.connect(user2).disableWhitelist(schainName); await depositBoxERC1155 diff --git a/test/DepositBoxERC20.ts b/test/DepositBoxERC20.ts index 1b3ece311..df7d8cb8a 100644 --- a/test/DepositBoxERC20.ts +++ b/test/DepositBoxERC20.ts @@ -103,7 +103,7 @@ describe("DepositBoxERC20", () => { linker = await deployLinker(contractManager, messageProxy); depositBoxERC20 = await deployDepositBoxERC20(contractManager, linker, messageProxy); communityPool = await deployCommunityPool(contractManager, linker, messageProxy); - await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), await linker.getAddress()); + await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, schainOwner.address, 1, 1); const nodeCreationParams = { @@ -118,9 +118,9 @@ describe("DepositBoxERC20", () => { await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); - await messageProxy.registerExtraContractForAll(await depositBoxERC20.getAddress()); - await messageProxy.registerExtraContract(schainName, await communityPool.getAddress()); - await messageProxy.registerExtraContract(schainName, await linker.getAddress()); + await messageProxy.registerExtraContractForAll(depositBoxERC20); + await messageProxy.registerExtraContract(schainName, communityPool); + await messageProxy.registerExtraContract(schainName, linker); messages = await deployMessages(); }); @@ -141,12 +141,12 @@ describe("DepositBoxERC20", () => { const error = "Whitelist is enabled"; await depositBoxERC20.connect(schainOwner).enableWhitelist(schainName); await erc20.connect(deployer).mint(user.address, "1000000000"); - await erc20.connect(deployer).approve(await depositBoxERC20.getAddress(), "1000000"); + await erc20.connect(deployer).approve(depositBoxERC20, "1000000"); // set `DepositBox` contract to avoid the `Not allowed` error in LockAndDataForMainnet.sol // execution/expectation await depositBoxERC20 .connect(deployer) - .depositERC20(schainName, await erc20.getAddress(), 100) + .depositERC20(schainName, erc20, 100) .should.be.eventually.rejectedWith(error); }); @@ -158,7 +158,7 @@ describe("DepositBoxERC20", () => { // execution/expectation await depositBoxERC20 .connect(deployer) - .depositERC20(schainName, await erc20.getAddress(), 100) + .depositERC20(schainName, erc20, 100) .should.be.eventually.rejectedWith(error); }); @@ -167,18 +167,18 @@ describe("DepositBoxERC20", () => { // mint some quantity of ERC20 tokens for `deployer` address const amount = 10; await erc20.connect(deployer).mint(deployer.address, amount); - await erc20.connect(deployer).approve(await depositBoxERC20.getAddress(), amount); + await erc20.connect(deployer).approve(depositBoxERC20, amount); // execution await depositBoxERC20 .connect(deployer) - .depositERC20(schainName, await erc20.getAddress(), 1).should.be.eventually.rejectedWith("Whitelist is enabled"); + .depositERC20(schainName, erc20, 1).should.be.eventually.rejectedWith("Whitelist is enabled"); await depositBoxERC20.connect(schainOwner).disableWhitelist(schainName); await depositBoxERC20 .connect(deployer) - .depositERC20(schainName, await erc20.getAddress(), 1); + .depositERC20(schainName, erc20, 1); await depositBoxERC20 .connect(deployer) - .depositERC20(schainName, await erc20.getAddress(), 1); + .depositERC20(schainName, erc20, 1); }); it("should invoke `depositERC20Direct` without mistakes", async () => { @@ -186,25 +186,25 @@ describe("DepositBoxERC20", () => { // mint some quantity of ERC20 tokens for `deployer` address const amount = 10; await erc20.connect(deployer).mint(deployer.address, amount); - await erc20.connect(deployer).approve(await depositBoxERC20.getAddress(), amount); + await erc20.connect(deployer).approve(depositBoxERC20, amount); // execution await depositBoxERC20 .connect(deployer) - .depositERC20Direct(schainName, await erc20.getAddress(), 1, user.address).should.be.eventually.rejectedWith("Whitelist is enabled"); + .depositERC20Direct(schainName, erc20, 1, user.address).should.be.eventually.rejectedWith("Whitelist is enabled"); await depositBoxERC20.connect(schainOwner).disableWhitelist(schainName); - const data1 = await messages.encodeTransferErc20AndTokenInfoMessage(await erc20.getAddress(), user.address, 1, amount, { name: "D2-token", symbol: "D2", decimals: 18 }); - const data2 = await messages.encodeTransferErc20AndTotalSupplyMessage(await erc20.getAddress(), user.address, 1, amount); + const data1 = await messages.encodeTransferErc20AndTokenInfoMessage(erc20, user.address, 1, amount, { name: "D2-token", symbol: "D2", decimals: 18 }); + const data2 = await messages.encodeTransferErc20AndTotalSupplyMessage(erc20, user.address, 1, amount); await depositBoxERC20 .connect(deployer) - .depositERC20Direct(schainName, await erc20.getAddress(), 1, user.address) + .depositERC20Direct(schainName, erc20, 1, user.address) .should.emit(messageProxy, "OutgoingMessage") - .withArgs(schainHash, 0, await depositBoxERC20.getAddress(), deployer.address, data1); + .withArgs(schainHash, 0, depositBoxERC20, deployer.address, data1); await depositBoxERC20 .connect(deployer) - .depositERC20Direct(schainName, await erc20.getAddress(), 1, user.address) + .depositERC20Direct(schainName, erc20, 1, user.address) .should.emit(messageProxy, "OutgoingMessage") - .withArgs(schainHash, 1, await depositBoxERC20.getAddress(), deployer.address, data2); + .withArgs(schainHash, 1, depositBoxERC20, deployer.address, data2); }); it("should rejected with `Amount is incorrect`", async () => { @@ -212,28 +212,28 @@ describe("DepositBoxERC20", () => { // mint some quantity of ERC20 tokens for `deployer` address const amount = 10; await erc20.connect(deployer).mint(deployer.address, amount); - await erc20.connect(deployer).approve(await depositBoxERC20.getAddress(), amount + 1); + await erc20.connect(deployer).approve(depositBoxERC20, amount + 1); await depositBoxERC20.connect(schainOwner).disableWhitelist(schainName); await depositBoxERC20 .connect(deployer) - .depositERC20(schainName, await erc20.getAddress(), amount + 1) + .depositERC20(schainName, erc20, amount + 1) .should.be.eventually.rejectedWith("Amount is incorrect"); }); }); it("should get funds after kill", async () => { await erc20.connect(deployer).mint(deployer.address, "1000000000"); - await erc20.connect(deployer).approve(await depositBoxERC20.getAddress(), "1000000"); + await erc20.connect(deployer).approve(depositBoxERC20, "1000000"); await depositBoxERC20.connect(schainOwner).disableWhitelist(schainName); await depositBoxERC20 .connect(deployer) - .depositERC20(schainName, await erc20.getAddress(), 1); - await depositBoxERC20.connect(schainOwner).getFunds(schainName, await erc20.getAddress(), schainOwner.address, 1).should.be.eventually.rejectedWith("Schain is not killed"); + .depositERC20(schainName, erc20, 1); + await depositBoxERC20.connect(schainOwner).getFunds(schainName, erc20, schainOwner.address, 1).should.be.eventually.rejectedWith("Schain is not killed"); await linker.connect(deployer).kill(schainName); await linker.connect(schainOwner).kill(schainName); - await depositBoxERC20.connect(schainOwner).getFunds(schainName, await erc20.getAddress(), schainOwner.address, 2).should.be.eventually.rejectedWith("Incorrect amount"); - await depositBoxERC20.connect(schainOwner).getFunds(schainName, await erc20.getAddress(), schainOwner.address, 1); + await depositBoxERC20.connect(schainOwner).getFunds(schainName, erc20, schainOwner.address, 2).should.be.eventually.rejectedWith("Incorrect amount"); + await depositBoxERC20.connect(schainOwner).getFunds(schainName, erc20, schainOwner.address, 1); expect(await erc20.balanceOf(schainOwner.address)).to.equal("1"); }); @@ -241,10 +241,10 @@ describe("DepositBoxERC20", () => { const fakeERC20Contract = deployer.address; await depositBoxERC20.connect(schainOwner).addERC20TokenByOwner(schainName, fakeERC20Contract) .should.be.eventually.rejectedWith("Given address is not a contract"); - await depositBoxERC20.connect(schainOwner).addERC20TokenByOwner(schainName, await erc20.getAddress()); - await depositBoxERC20.connect(schainOwner).addERC20TokenByOwner(schainName, await erc20.getAddress()).should.be.eventually.rejectedWith("ERC20 Token was already added"); - expect(await depositBoxERC20.getSchainToERC20(schainName, await erc20.getAddress())).to.be.equal(true); - expect((await depositBoxERC20.getSchainToAllERC20(schainName, 0, 1))[0]).to.be.equal(await erc20.getAddress()); + await depositBoxERC20.connect(schainOwner).addERC20TokenByOwner(schainName, erc20); + await depositBoxERC20.connect(schainOwner).addERC20TokenByOwner(schainName, erc20).should.be.eventually.rejectedWith("ERC20 Token was already added"); + expect(await depositBoxERC20.getSchainToERC20(schainName, erc20)).to.be.equal(true); + expect((await depositBoxERC20.getSchainToAllERC20(schainName, 0, 1))[0]).to.be.equal(erc20); expect((await depositBoxERC20.getSchainToAllERC20(schainName, 0, 1)).length).to.be.equal(1); expect((await depositBoxERC20.getSchainToAllERC20Length(schainName)).toString()).to.be.equal("1"); await depositBoxERC20.getSchainToAllERC20(schainName, 1, 0).should.be.eventually.rejectedWith("Range is incorrect"); @@ -254,7 +254,7 @@ describe("DepositBoxERC20", () => { it("should not allow to add token by schain owner if schain killed", async () => { await linker.connect(deployer).kill(schainName); await linker.connect(schainOwner).kill(schainName); - await depositBoxERC20.connect(schainOwner).addERC20TokenByOwner(schainName, await erc20.getAddress()) + await depositBoxERC20.connect(schainOwner).addERC20TokenByOwner(schainName, erc20) .should.be.eventually.rejectedWith("Schain is killed"); }); @@ -269,25 +269,25 @@ describe("DepositBoxERC20", () => { await erc20TWFR.connect(deployer).mint(deployer.address, amount); await erc20IT.connect(deployer).mint(deployer.address, amount); await erc20.connect(deployer).mint(deployer.address, amount); - await erc20TWR.connect(deployer).approve(await depositBoxERC20.getAddress(), amount); - await erc20TWFR.connect(deployer).approve(await depositBoxERC20.getAddress(), amount); - await erc20IT.connect(deployer).approve(await depositBoxERC20.getAddress(), amount); - await erc20.connect(deployer).approve(await depositBoxERC20.getAddress(), amount); + await erc20TWR.connect(deployer).approve(depositBoxERC20, amount); + await erc20TWFR.connect(deployer).approve(depositBoxERC20, amount); + await erc20IT.connect(deployer).approve(depositBoxERC20, amount); + await erc20.connect(deployer).approve(depositBoxERC20, amount); // execution await depositBoxERC20.connect(schainOwner).disableWhitelist(schainName); await depositBoxERC20 .connect(deployer) - .depositERC20(schainName, await erc20.getAddress(), 1); + .depositERC20(schainName, erc20, 1); await depositBoxERC20 .connect(deployer) - .depositERC20(schainName, await erc20TWR.getAddress(), 1); + .depositERC20(schainName, erc20TWR, 1); await depositBoxERC20 .connect(deployer) - .depositERC20(schainName, await erc20IT.getAddress(), 1) + .depositERC20(schainName, erc20IT, 1) .should.be.eventually.rejectedWith("SafeERC20: low-level call failed"); await depositBoxERC20 .connect(deployer) - .depositERC20(schainName, await erc20TWFR.getAddress(), 1) + .depositERC20(schainName, erc20TWFR, 1) .should.be.eventually.rejectedWith("SafeERC20: ERC20 operation did not succeed"); }); }); @@ -303,8 +303,8 @@ describe("DepositBoxERC20", () => { it("should transfer ERC20 token", async () => { // preparation - const ercOnSchain = await erc20.getAddress(); - const fakeErc20OnSchain = await erc20Clone.getAddress(); + const ercOnSchain = erc20; + const fakeErc20OnSchain = erc20Clone; const amount = 10; const to = user.address; const senderFromSchain = deployer.address; @@ -319,25 +319,25 @@ describe("DepositBoxERC20", () => { const message = { data: await messages.encodeTransferErc20Message(ercOnSchain, to, amount), - destinationContract: await depositBoxERC20.getAddress(), + destinationContract: depositBoxERC20, sender: senderFromSchain }; const messageWithWrongTokenAddress = { data: await messages.encodeTransferErc20Message(user2.address, to, amount), - destinationContract: await depositBoxERC20.getAddress(), + destinationContract: depositBoxERC20, sender: senderFromSchain }; const messageWithNotMintedToken = { data: await messages.encodeTransferErc20Message(fakeErc20OnSchain, to, amount), - destinationContract: await depositBoxERC20.getAddress(), + destinationContract: depositBoxERC20, sender: senderFromSchain }; await initializeSchain(contractManager, schainName, schainOwner.address, 1, 1); await setCommonPublicKey(contractManager, schainName); - await depositBoxERC20.connect(user).depositERC20(schainName, await erc20.getAddress(), amount) + await depositBoxERC20.connect(user).depositERC20(schainName, erc20, amount) .should.be.eventually.rejectedWith("Unconnected chain"); await linker @@ -351,11 +351,11 @@ describe("DepositBoxERC20", () => { await depositBoxERC20.connect(schainOwner).disableWhitelist(schainName); await erc20.connect(deployer).mint(user.address, amount * 2); - await depositBoxERC20.connect(user).depositERC20(schainName, await erc20.getAddress(), amount) + await depositBoxERC20.connect(user).depositERC20(schainName, erc20, amount) .should.be.eventually.rejectedWith("DepositBox was not approved for ERC20 token"); - await erc20.connect(user).approve(await depositBoxERC20.getAddress(), amount * 2); + await erc20.connect(user).approve(depositBoxERC20, amount * 2); - await depositBoxERC20.connect(user).depositERC20(schainName, await erc20.getAddress(), amount); + await depositBoxERC20.connect(user).depositERC20(schainName, erc20, amount); const tx = await messageProxy .connect(nodeAddress) @@ -383,9 +383,9 @@ describe("DepositBoxERC20", () => { balance.should.be.least(balanceBefore); balance.should.be.closeTo(balanceBefore, 10); - await depositBoxERC20.connect(user).depositERC20(schainName, await erc20.getAddress(), amount); + await depositBoxERC20.connect(user).depositERC20(schainName, erc20, amount); await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 3, [message], sign); - const transferredAmount = await depositBoxERC20.transferredAmount(schainHash, await erc20.getAddress()); + const transferredAmount = await depositBoxERC20.transferredAmount(schainHash, erc20); expect(transferredAmount).to.be.equal(0n); (await erc20.balanceOf(user.address)).toString().should.be.equal((amount * 2).toString()); @@ -408,20 +408,20 @@ describe("DepositBoxERC20", () => { }; const message = { - data: await messages.encodeTransferErc20Message(await erc20.getAddress(), to, amount), - destinationContract: await depositBoxERC20.getAddress(), + data: await messages.encodeTransferErc20Message(erc20, to, amount), + destinationContract: depositBoxERC20, sender: senderFromSchain }; const messageTWR = { - data: await messages.encodeTransferErc20Message(await erc20TWR.getAddress(), to, amount), - destinationContract: await depositBoxERC20.getAddress(), + data: await messages.encodeTransferErc20Message(erc20TWR, to, amount), + destinationContract: depositBoxERC20, sender: senderFromSchain }; await initializeSchain(contractManager, schainName, schainOwner.address, 1, 1); await setCommonPublicKey(contractManager, schainName); - await depositBoxERC20.connect(user).depositERC20(schainName, await erc20.getAddress(), amount) + await depositBoxERC20.connect(user).depositERC20(schainName, erc20, amount) .should.be.eventually.rejectedWith("Unconnected chain"); await linker @@ -436,11 +436,11 @@ describe("DepositBoxERC20", () => { await erc20.connect(deployer).mint(user.address, amount * 2); await erc20TWR.connect(deployer).mint(user.address, amount * 2); - await erc20.connect(user).approve(await depositBoxERC20.getAddress(), amount * 2); - await erc20TWR.connect(user).approve(await depositBoxERC20.getAddress(), amount * 2); + await erc20.connect(user).approve(depositBoxERC20, amount * 2); + await erc20TWR.connect(user).approve(depositBoxERC20, amount * 2); - await depositBoxERC20.connect(user).depositERC20(schainName, await erc20.getAddress(), amount); - await depositBoxERC20.connect(user).depositERC20(schainName, await erc20TWR.getAddress(), amount); + await depositBoxERC20.connect(user).depositERC20(schainName, erc20, amount); + await depositBoxERC20.connect(user).depositERC20(schainName, erc20TWR, amount); const balanceBefore = await ethers.provider.getBalance(deployer.address); await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message, messageTWR], sign); @@ -448,12 +448,12 @@ describe("DepositBoxERC20", () => { balance.should.be.least(balanceBefore); balance.should.be.closeTo(balanceBefore, 10); - await depositBoxERC20.connect(user).depositERC20(schainName, await erc20.getAddress(), amount); - await depositBoxERC20.connect(user).depositERC20(schainName, await erc20TWR.getAddress(), amount); + await depositBoxERC20.connect(user).depositERC20(schainName, erc20, amount); + await depositBoxERC20.connect(user).depositERC20(schainName, erc20TWR, amount); await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 2, [message, messageTWR], sign); - const transferredAmount = await depositBoxERC20.transferredAmount(schainHash, await erc20.getAddress()); + const transferredAmount = await depositBoxERC20.transferredAmount(schainHash, erc20); expect(transferredAmount).to.be.equal(0); - const transferredAmountTWR = await depositBoxERC20.transferredAmount(schainHash, await erc20TWR.getAddress()); + const transferredAmountTWR = await depositBoxERC20.transferredAmount(schainHash, erc20TWR); expect(transferredAmountTWR).to.be.equal(0); (await erc20.balanceOf(user.address)).toString().should.be.equal((amount * 2).toString()); @@ -495,17 +495,17 @@ describe("DepositBoxERC20", () => { await token.mint(user.address, depositedAmount); await token2.mint(user.address, depositedAmount); - await token.connect(user).approve(await depositBoxERC20.getAddress(), depositedAmount); - await depositBoxERC20.connect(user).depositERC20(schainName, await token.getAddress(), depositedAmount); + await token.connect(user).approve(depositBoxERC20, depositedAmount); + await depositBoxERC20.connect(user).depositERC20(schainName, token, depositedAmount); - await token2.connect(user).approve(await depositBoxERC20.getAddress(), depositedAmount); - await depositBoxERC20.connect(user).depositERC20(schainName, await token2.getAddress(), depositedAmount); + await token2.connect(user).approve(depositBoxERC20, depositedAmount); + await depositBoxERC20.connect(user).depositERC20(schainName, token2, depositedAmount); await expect( - depositBoxERC20.connect(schainOwner).setBigTransferValue(schainName, await token.getAddress(), bigAmount) + depositBoxERC20.connect(schainOwner).setBigTransferValue(schainName, token, bigAmount) ).to.emit(depositBoxERC20, "BigTransferThresholdIsChanged") - .withArgs(schainHash, await token.getAddress(), 0, bigAmount); - await depositBoxERC20.connect(schainOwner).setBigTransferValue(schainName, await token2.getAddress(), bigAmount); + .withArgs(schainHash, token, 0, bigAmount); + await depositBoxERC20.connect(schainOwner).setBigTransferValue(schainName, token2, bigAmount); await expect( depositBoxERC20.connect(schainOwner).setBigTransferDelay(schainName, timeDelay) ).to.emit(depositBoxERC20, "BigTransferDelayIsChanged") @@ -522,15 +522,15 @@ describe("DepositBoxERC20", () => { const balanceBefore = await token.balanceOf(user.address); const message = { - data: await messages.encodeTransferErc20Message(await token.getAddress(), user.address, bigAmount), - destinationContract: await depositBoxERC20.getAddress(), + data: await messages.encodeTransferErc20Message(token, user.address, bigAmount), + destinationContract: depositBoxERC20, sender: deployer.address }; await expect( messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], randomSignature) ).to.emit(depositBoxERC20, "TransferDelayed") - .withArgs(0, user.address, await token.getAddress(), bigAmount); + .withArgs(0, user.address, token, bigAmount); (await token.balanceOf(user.address)).should.be.equal(balanceBefore); @@ -548,26 +548,26 @@ describe("DepositBoxERC20", () => { it("should allow to perform arbitrage", async () => { const smallTransferOfToken1 = { - data: await messages.encodeTransferErc20Message(await token.getAddress(), user.address, amount), - destinationContract: await depositBoxERC20.getAddress(), + data: await messages.encodeTransferErc20Message(token, user.address, amount), + destinationContract: depositBoxERC20, sender: deployer.address }; const bigTransferOfToken1 = { - data: await messages.encodeTransferErc20Message(await token.getAddress(), user.address, bigAmount), - destinationContract: await depositBoxERC20.getAddress(), + data: await messages.encodeTransferErc20Message(token, user.address, bigAmount), + destinationContract: depositBoxERC20, sender: deployer.address }; const smallTransferOfToken2 = { - data: await messages.encodeTransferErc20Message(await token2.getAddress(), user.address, amount), - destinationContract: await depositBoxERC20.getAddress(), + data: await messages.encodeTransferErc20Message(token2, user.address, amount), + destinationContract: depositBoxERC20, sender: deployer.address }; const bigTransferOfToken2 = { - data: await messages.encodeTransferErc20Message(await token2.getAddress(), user.address, bigAmount), - destinationContract: await depositBoxERC20.getAddress(), + data: await messages.encodeTransferErc20Message(token2, user.address, bigAmount), + destinationContract: depositBoxERC20, sender: deployer.address }; @@ -591,13 +591,13 @@ describe("DepositBoxERC20", () => { randomSignature ); - (await depositBoxERC20.getDelayedAmount(user.address, await token.getAddress())) + (await depositBoxERC20.getDelayedAmount(user.address, token)) .should.be.equal(4 * bigAmount); - (await depositBoxERC20.getDelayedAmount(user.address, await token2.getAddress())) + (await depositBoxERC20.getDelayedAmount(user.address, token2)) .should.be.equal(bigAmount); - (await depositBoxERC20.getNextUnlockTimestamp(user.address, await token.getAddress())) + (await depositBoxERC20.getNextUnlockTimestamp(user.address, token)) .should.be.equal((await currentTime()) + timeDelay); - (await depositBoxERC20.getNextUnlockTimestamp(user.address, await token2.getAddress())) + (await depositBoxERC20.getNextUnlockTimestamp(user.address, token2)) .should.be.equal((await currentTime()) + timeDelay); // 2 small transfers of token 1 and 2 small transfers of token 2 must be processed without delay @@ -654,8 +654,8 @@ describe("DepositBoxERC20", () => { it("should not stuck after big amount of competed transfers", async () => { const bigTransfer = { - data: await messages.encodeTransferErc20Message(await token.getAddress(), user.address, bigAmount), - destinationContract: await depositBoxERC20.getAddress(), + data: await messages.encodeTransferErc20Message(token, user.address, bigAmount), + destinationContract: depositBoxERC20, sender: deployer.address }; @@ -706,19 +706,19 @@ describe("DepositBoxERC20", () => { it("should not stuck if a token reverts transfer", async () => { const bigTransfer = { - data: await messages.encodeTransferErc20Message(await token.getAddress(), user.address, bigAmount), - destinationContract: await depositBoxERC20.getAddress(), + data: await messages.encodeTransferErc20Message(token, user.address, bigAmount), + destinationContract: depositBoxERC20, sender: deployer.address }; const badToken = await (await ethers.getContractFactory("RevertableERC20")).deploy("Test", "TST"); await badToken.mint(user.address, bigAmount); - await badToken.connect(user).approve(await depositBoxERC20.getAddress(), bigAmount); - await depositBoxERC20.connect(user).depositERC20(schainName, await badToken.getAddress(), bigAmount); + await badToken.connect(user).approve(depositBoxERC20, bigAmount); + await depositBoxERC20.connect(user).depositERC20(schainName, badToken, bigAmount); const badTokenBigTransfer = { - data: await messages.encodeTransferErc20Message(await badToken.getAddress(), user.address, bigAmount), - destinationContract: await depositBoxERC20.getAddress(), + data: await messages.encodeTransferErc20Message(badToken, user.address, bigAmount), + destinationContract: depositBoxERC20, sender: deployer.address }; @@ -755,8 +755,8 @@ describe("DepositBoxERC20", () => { it("should disable delay for trusted receivers", async () => { const bigTransfer = { - data: await messages.encodeTransferErc20Message(await token.getAddress(), user.address, bigAmount), - destinationContract: await depositBoxERC20.getAddress(), + data: await messages.encodeTransferErc20Message(token, user.address, bigAmount), + destinationContract: depositBoxERC20, sender: deployer.address }; @@ -791,14 +791,14 @@ describe("DepositBoxERC20", () => { ); (await token.balanceOf(user.address)).should.be.equal(bigAmount); - (await depositBoxERC20.getDelayedAmount(user.address, await token.getAddress())) + (await depositBoxERC20.getDelayedAmount(user.address, token)) .should.be.equal(bigAmount); }) it("should reduce delay", async () => { const bigTransfer = { - data: await messages.encodeTransferErc20Message(await token.getAddress(), user.address, bigAmount), - destinationContract: await depositBoxERC20.getAddress(), + data: await messages.encodeTransferErc20Message(token, user.address, bigAmount), + destinationContract: depositBoxERC20, sender: deployer.address }; @@ -809,7 +809,7 @@ describe("DepositBoxERC20", () => { randomSignature ); - (await depositBoxERC20.getNextUnlockTimestamp(user.address, await token.getAddress())) + (await depositBoxERC20.getNextUnlockTimestamp(user.address, token)) .should.be.equal(await currentTime() + timeDelay); @@ -823,16 +823,16 @@ describe("DepositBoxERC20", () => { randomSignature ); - (await depositBoxERC20.getNextUnlockTimestamp(user.address, await token.getAddress())) + (await depositBoxERC20.getNextUnlockTimestamp(user.address, token)) .should.be.equal(await currentTime() + lowerDelay); - (await depositBoxERC20.getDelayedAmount(user.address, await token.getAddress())) + (await depositBoxERC20.getDelayedAmount(user.address, token)) .should.be.equal(2 * bigAmount); }); it("should process correctly in non linear order", async () => { const bigTransfer = { - data: await messages.encodeTransferErc20Message(await token.getAddress(), user.address, bigAmount), - destinationContract: await depositBoxERC20.getAddress(), + data: await messages.encodeTransferErc20Message(token, user.address, bigAmount), + destinationContract: depositBoxERC20, sender: deployer.address }; @@ -850,14 +850,14 @@ describe("DepositBoxERC20", () => { await depositBoxERC20.escalate(0); - (await depositBoxERC20.getNextUnlockTimestamp(user.address, await token.getAddress())) + (await depositBoxERC20.getNextUnlockTimestamp(user.address, token)) .should.be.equal(lockedUntil); await skipTime(timeDelay); await depositBoxERC20.retrieveFor(user.address); - (await depositBoxERC20.getDelayedAmount(user.address, await token.getAddress())) + (await depositBoxERC20.getDelayedAmount(user.address, token)) .should.be.equal(bigAmount); await messageProxy.connect(nodeAddress).postIncomingMessages( @@ -870,15 +870,15 @@ describe("DepositBoxERC20", () => { ); lockedUntil = await currentTime() + timeDelay; - (await depositBoxERC20.getNextUnlockTimestamp(user.address, await token.getAddress())) + (await depositBoxERC20.getNextUnlockTimestamp(user.address, token)) .should.be.equal(lockedUntil); - (await depositBoxERC20.getDelayedAmount(user.address, await token.getAddress())) + (await depositBoxERC20.getDelayedAmount(user.address, token)) .should.be.equal(2 * bigAmount); await skipTime(timeDelay); await depositBoxERC20.retrieveFor(user.address); - (await depositBoxERC20.getDelayedAmount(user.address, await token.getAddress())) + (await depositBoxERC20.getDelayedAmount(user.address, token)) .should.be.equal(bigAmount); (await token.balanceOf(user.address)) .should.be.equal(2 * bigAmount); diff --git a/test/DepositBoxERC721.ts b/test/DepositBoxERC721.ts index 03a3c734e..998634fd0 100644 --- a/test/DepositBoxERC721.ts +++ b/test/DepositBoxERC721.ts @@ -105,7 +105,7 @@ describe("DepositBoxERC721", () => { depositBoxERC721 = await deployDepositBoxERC721(contractManager, linker, messageProxy); communityPool = await deployCommunityPool(contractManager, linker, messageProxy); messages = await deployMessages(); - await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), await linker.getAddress()); + await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); const nodeCreationParams = { @@ -120,9 +120,9 @@ describe("DepositBoxERC721", () => { await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); - await messageProxy.registerExtraContractForAll(await depositBoxERC721.getAddress()); - await messageProxy.registerExtraContract(schainName, await communityPool.getAddress()); - await messageProxy.registerExtraContract(schainName, await linker.getAddress()); + await messageProxy.registerExtraContractForAll(depositBoxERC721); + await messageProxy.registerExtraContract(schainName, communityPool); + await messageProxy.registerExtraContract(schainName, linker); }); describe("tests with `ERC721`", async () => { @@ -147,14 +147,14 @@ describe("DepositBoxERC721", () => { // preparation const amount = 10; - await depositBoxERC721.connect(user).depositERC721(schainName, await erc721.getAddress(), amount) + await depositBoxERC721.connect(user).depositERC721(schainName, erc721, amount) .should.be.eventually.rejectedWith("Unconnected chain"); }); it("should rejected with `DepositBox was not approved for ERC721 token`", async () => { // preparation const error = "DepositBox was not approved for ERC721 token"; - const contractHere = await erc721OnChain.getAddress(); + const contractHere = erc721OnChain; const tokenId = 10; // the wei should be MORE than (55000 * 1000000000) // GAS_AMOUNT_POST_MESSAGE * AVERAGE_TX_PRICE constants in DepositBox.sol @@ -172,7 +172,7 @@ describe("DepositBoxERC721", () => { it("should invoke `depositERC721` without mistakes", async () => { // preparation - const contractHere = await erc721OnChain.getAddress(); + const contractHere = erc721OnChain; const tokenId = 10; const tokenId2 = 11; // the wei should be MORE than (55000 * 1000000000) @@ -182,8 +182,8 @@ describe("DepositBoxERC721", () => { .connect(deployer) .connectSchain(schainName, [deployer.address, deployer.address, deployer.address]); // transfer tokenId from `deployer` to `depositBoxERC721` - await erc721OnChain.connect(deployer).approve(await depositBoxERC721.getAddress(), tokenId); - await erc721OnChain.connect(deployer).approve(await depositBoxERC721.getAddress(), tokenId2); + await erc721OnChain.connect(deployer).approve(depositBoxERC721, tokenId); + await erc721OnChain.connect(deployer).approve(depositBoxERC721, tokenId2); // execution await depositBoxERC721 .connect(deployer) @@ -197,13 +197,13 @@ describe("DepositBoxERC721", () => { .depositERC721(schainName, contractHere, tokenId2)).wait(); // console.log("Gas for depositERC721:", res.receipt.gasUsed); // expectation - expect(await erc721OnChain.ownerOf(tokenId)).to.equal(await depositBoxERC721.getAddress()); - expect(await erc721OnChain.ownerOf(tokenId2)).to.equal(await depositBoxERC721.getAddress()); + expect(await erc721OnChain.ownerOf(tokenId)).to.equal(depositBoxERC721); + expect(await erc721OnChain.ownerOf(tokenId2)).to.equal(depositBoxERC721); }); it("should invoke `depositERC721Direct` without mistakes", async () => { // preparation - const contractHere = await erc721OnChain.getAddress(); + const contractHere = erc721OnChain; const to = user.address; const tokenId = 10; const tokenId2 = 11; @@ -214,8 +214,8 @@ describe("DepositBoxERC721", () => { .connect(deployer) .connectSchain(schainName, [deployer.address, deployer.address, deployer.address]); // transfer tokenId from `deployer` to `depositBoxERC721` - await erc721OnChain.connect(deployer).approve(await depositBoxERC721.getAddress(), tokenId); - await erc721OnChain.connect(deployer).approve(await depositBoxERC721.getAddress(), tokenId2); + await erc721OnChain.connect(deployer).approve(depositBoxERC721, tokenId); + await erc721OnChain.connect(deployer).approve(depositBoxERC721, tokenId2); // execution await depositBoxERC721 .connect(deployer) @@ -227,16 +227,16 @@ describe("DepositBoxERC721", () => { .connect(deployer) .depositERC721Direct(schainName, contractHere, tokenId, to) .should.emit(messageProxy, "OutgoingMessage") - .withArgs(schainHash, 0, await depositBoxERC721.getAddress(), deployer.address, data1); + .withArgs(schainHash, 0, depositBoxERC721, deployer.address, data1); await depositBoxERC721 .connect(deployer) .depositERC721Direct(schainName, contractHere, tokenId2, to) .should.emit(messageProxy, "OutgoingMessage") - .withArgs(schainHash, 1, await depositBoxERC721.getAddress(), deployer.address, data2); + .withArgs(schainHash, 1, depositBoxERC721, deployer.address, data2); // console.log("Gas for depositERC721:", res.receipt.gasUsed); // expectation - expect(await erc721OnChain.ownerOf(tokenId)).to.equal(await depositBoxERC721.getAddress()); - expect(await erc721OnChain.ownerOf(tokenId2)).to.equal(await depositBoxERC721.getAddress()); + expect(await erc721OnChain.ownerOf(tokenId)).to.equal(depositBoxERC721); + expect(await erc721OnChain.ownerOf(tokenId2)).to.equal(depositBoxERC721); }); }); @@ -247,16 +247,16 @@ describe("DepositBoxERC721", () => { await linker .connect(deployer) .connectSchain(schainName, [deployer.address, deployer.address, deployer.address]); - await erc721OnChain.connect(deployer).approve(await depositBoxERC721.getAddress(), tokenId); + await erc721OnChain.connect(deployer).approve(depositBoxERC721, tokenId); await depositBoxERC721.connect(user).disableWhitelist(schainName); await depositBoxERC721 .connect(deployer) - .depositERC721(schainName, await erc721OnChain.getAddress(), tokenId); - await depositBoxERC721.connect(user).getFunds(schainName, await erc721OnChain.getAddress(), user.address, tokenId).should.be.eventually.rejectedWith("Schain is not killed"); + .depositERC721(schainName, erc721OnChain, tokenId); + await depositBoxERC721.connect(user).getFunds(schainName, erc721OnChain, user.address, tokenId).should.be.eventually.rejectedWith("Schain is not killed"); await linker.connect(deployer).kill(schainName); await linker.connect(user).kill(schainName); - await depositBoxERC721.connect(user).getFunds(schainName, await erc721OnChain.getAddress(), user.address, tokenId2).should.be.eventually.rejectedWith("Incorrect tokenId"); - await depositBoxERC721.connect(user).getFunds(schainName, await erc721OnChain.getAddress(), user.address, tokenId); + await depositBoxERC721.connect(user).getFunds(schainName, erc721OnChain, user.address, tokenId2).should.be.eventually.rejectedWith("Incorrect tokenId"); + await depositBoxERC721.connect(user).getFunds(schainName, erc721OnChain, user.address, tokenId); expect(await erc721OnChain.ownerOf(tokenId)).to.equal(user.address); }); @@ -264,13 +264,13 @@ describe("DepositBoxERC721", () => { const fakeERC721Contract = deployer.address; await depositBoxERC721.connect(user).addERC721TokenByOwner(schainName, fakeERC721Contract) .should.be.eventually.rejectedWith("Given address is not a contract"); - await depositBoxERC721.connect(deployer).addERC721TokenByOwner(schainName, await erc721.getAddress()) + await depositBoxERC721.connect(deployer).addERC721TokenByOwner(schainName, erc721) .should.be.eventually.rejectedWith("Sender is not an Schain owner"); - await depositBoxERC721.connect(user).addERC721TokenByOwner(schainName, await erc721.getAddress()); - await depositBoxERC721.connect(user).addERC721TokenByOwner(schainName, await erc721.getAddress()).should.be.eventually.rejectedWith("ERC721 Token was already added"); - expect(await depositBoxERC721.getSchainToERC721(schainName, await erc721.getAddress())).to.be.equal(true); - expect((await depositBoxERC721.getSchainToAllERC721(schainName, 0, 1))[0]).to.be.equal(await erc721.getAddress()); + await depositBoxERC721.connect(user).addERC721TokenByOwner(schainName, erc721); + await depositBoxERC721.connect(user).addERC721TokenByOwner(schainName, erc721).should.be.eventually.rejectedWith("ERC721 Token was already added"); + expect(await depositBoxERC721.getSchainToERC721(schainName, erc721)).to.be.equal(true); + expect((await depositBoxERC721.getSchainToAllERC721(schainName, 0, 1))[0]).to.be.equal(erc721); expect((await depositBoxERC721.getSchainToAllERC721(schainName, 0, 1)).length).to.be.equal(1); expect((await depositBoxERC721.getSchainToAllERC721Length(schainName)).toString()).to.be.equal("1"); await depositBoxERC721.getSchainToAllERC721(schainName, 1, 0).should.be.eventually.rejectedWith("Range is incorrect"); @@ -317,13 +317,13 @@ describe("DepositBoxERC721", () => { const senderFromSchain = deployer.address; const message = { - data: await messages.encodeTransferErc721Message(await erc721.getAddress(), to, tokenId), - destinationContract: await depositBoxERC721.getAddress(), + data: await messages.encodeTransferErc721Message(erc721, to, tokenId), + destinationContract: depositBoxERC721, sender: senderFromSchain }; await erc721.connect(deployer).mint(deployer.address, tokenId); - await erc721.connect(deployer).transferFrom(deployer.address, await depositBoxERC721.getAddress(), tokenId); + await erc721.connect(deployer).transferFrom(deployer.address, depositBoxERC721, tokenId); const balanceBefore = await getBalance(deployer.address); await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); @@ -342,12 +342,12 @@ describe("DepositBoxERC721", () => { const messageWithWrongTokenAddress = { data: await messages.encodeTransferErc721Message(user2.address, to, tokenId), - destinationContract: await depositBoxERC721.getAddress(), + destinationContract: depositBoxERC721, sender: senderFromSchain }; await erc721.connect(deployer).mint(deployer.address, tokenId); - await erc721.connect(deployer).transferFrom(deployer.address, await depositBoxERC721.getAddress(), tokenId); + await erc721.connect(deployer).transferFrom(deployer.address, depositBoxERC721, tokenId); const tx = await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign); await expect(tx) @@ -361,8 +361,8 @@ describe("DepositBoxERC721", () => { const senderFromSchain = deployer.address; const messageWithWrongTokenAddress = { - data: await messages.encodeTransferErc721Message(await erc721.getAddress(), to, tokenId), - destinationContract: await depositBoxERC721.getAddress(), + data: await messages.encodeTransferErc721Message(erc721, to, tokenId), + destinationContract: depositBoxERC721, sender: senderFromSchain }; @@ -382,23 +382,23 @@ describe("DepositBoxERC721", () => { const senderFromSchain = deployer.address; const message = { - data: await messages.encodeTransferErc721Message(await erc721.getAddress(), to, tokenId), - destinationContract: await depositBoxERC721.getAddress(), + data: await messages.encodeTransferErc721Message(erc721, to, tokenId), + destinationContract: depositBoxERC721, sender: senderFromSchain }; await erc721.mint(deployer.address, tokenId); - await erc721.approve(await depositBoxERC721.getAddress(), tokenId); + await erc721.approve(depositBoxERC721, tokenId); await depositBoxERC721 - .depositERC721(schainName, await erc721.getAddress(), tokenId); + .depositERC721(schainName, erc721, tokenId); const balanceBefore = await getBalance(deployer.address); await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); - expect(await depositBoxERC721.transferredAmount(await erc721.getAddress(), tokenId)).to.be.equal(zeroHash); + expect(await depositBoxERC721.transferredAmount(erc721, tokenId)).to.be.equal(zeroHash); (await erc721.ownerOf(tokenId)).should.be.equal(user.address); }); diff --git a/test/DepositBoxERC721WithMetadata.ts b/test/DepositBoxERC721WithMetadata.ts index f6c372556..300827e21 100644 --- a/test/DepositBoxERC721WithMetadata.ts +++ b/test/DepositBoxERC721WithMetadata.ts @@ -105,7 +105,7 @@ describe("DepositBoxERC721WithMetadata", () => { depositBoxERC721WithMetadata = await deployDepositBoxERC721WithMetadata(contractManager, linker, messageProxy); communityPool = await deployCommunityPool(contractManager, linker, messageProxy); messages = await deployMessages(); - await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), await linker.getAddress()); + await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); const nodeCreationParams = { @@ -120,9 +120,9 @@ describe("DepositBoxERC721WithMetadata", () => { await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); - await messageProxy.registerExtraContractForAll(await depositBoxERC721WithMetadata.getAddress()); - await messageProxy.registerExtraContract(schainName, await communityPool.getAddress()); - await messageProxy.registerExtraContract(schainName, await linker.getAddress()); + await messageProxy.registerExtraContractForAll(depositBoxERC721WithMetadata); + await messageProxy.registerExtraContract(schainName, communityPool); + await messageProxy.registerExtraContract(schainName, linker); }); describe("tests with `ERC721`", async () => { @@ -151,14 +151,14 @@ describe("DepositBoxERC721WithMetadata", () => { // preparation const amount = 10; - await depositBoxERC721WithMetadata.connect(user).depositERC721(schainName, await erc721.getAddress(), amount) + await depositBoxERC721WithMetadata.connect(user).depositERC721(schainName, erc721, amount) .should.be.eventually.rejectedWith("Unconnected chain"); }); it("should rejected with `DepositBox was not approved for ERC721 token`", async () => { // preparation const error = "DepositBox was not approved for ERC721 token"; - const contractHere = await erc721OnChain.getAddress(); + const contractHere = erc721OnChain; const tokenId = 10; // the wei should be MORE than (55000 * 1000000000) // GAS_AMOUNT_POST_MESSAGE * AVERAGE_TX_PRICE constants in DepositBox.sol @@ -176,7 +176,7 @@ describe("DepositBoxERC721WithMetadata", () => { it("should invoke `depositERC721` without mistakes", async () => { // preparation - const contractHere = await erc721OnChain.getAddress(); + const contractHere = erc721OnChain; const tokenId = 10; const tokenId2 = 11; // the wei should be MORE than (55000 * 1000000000) @@ -186,8 +186,8 @@ describe("DepositBoxERC721WithMetadata", () => { .connect(deployer) .connectSchain(schainName, [deployer.address, deployer.address, deployer.address]); // transfer tokenId from `deployer` to `depositBoxERC721WithMetadata` - await erc721OnChain.connect(deployer).approve(await depositBoxERC721WithMetadata.getAddress(), tokenId); - await erc721OnChain.connect(deployer).approve(await depositBoxERC721WithMetadata.getAddress(), tokenId2); + await erc721OnChain.connect(deployer).approve(depositBoxERC721WithMetadata, tokenId); + await erc721OnChain.connect(deployer).approve(depositBoxERC721WithMetadata, tokenId2); // execution await depositBoxERC721WithMetadata .connect(deployer) @@ -201,13 +201,13 @@ describe("DepositBoxERC721WithMetadata", () => { .depositERC721(schainName, contractHere, tokenId2)).wait(); // console.log("Gas for depositERC721:", res.receipt.gasUsed); // expectation - expect(await erc721OnChain.ownerOf(tokenId)).to.equal(await depositBoxERC721WithMetadata.getAddress()); - expect(await erc721OnChain.ownerOf(tokenId2)).to.equal(await depositBoxERC721WithMetadata.getAddress()); + expect(await erc721OnChain.ownerOf(tokenId)).to.equal(depositBoxERC721WithMetadata); + expect(await erc721OnChain.ownerOf(tokenId2)).to.equal(depositBoxERC721WithMetadata); }); it("should invoke `depositERC721Direct` without mistakes", async () => { // preparation - const contractHere = await erc721OnChain.getAddress(); + const contractHere = erc721OnChain; const to = user.address; const tokenId = 10; const tokenId2 = 11; @@ -218,8 +218,8 @@ describe("DepositBoxERC721WithMetadata", () => { .connect(deployer) .connectSchain(schainName, [deployer.address, deployer.address, deployer.address]); // transfer tokenId from `deployer` to `depositBoxERC721` - await erc721OnChain.connect(deployer).approve(await depositBoxERC721WithMetadata.getAddress(), tokenId); - await erc721OnChain.connect(deployer).approve(await depositBoxERC721WithMetadata.getAddress(), tokenId2); + await erc721OnChain.connect(deployer).approve(depositBoxERC721WithMetadata, tokenId); + await erc721OnChain.connect(deployer).approve(depositBoxERC721WithMetadata, tokenId2); // execution await depositBoxERC721WithMetadata .connect(deployer) @@ -231,16 +231,16 @@ describe("DepositBoxERC721WithMetadata", () => { .connect(deployer) .depositERC721Direct(schainName, contractHere, tokenId, to) .should.emit(messageProxy, "OutgoingMessage") - .withArgs(schainHash, 0, await depositBoxERC721WithMetadata.getAddress(), deployer.address, data1); + .withArgs(schainHash, 0, depositBoxERC721WithMetadata, deployer.address, data1); await depositBoxERC721WithMetadata .connect(deployer) .depositERC721Direct(schainName, contractHere, tokenId2, to) .should.emit(messageProxy, "OutgoingMessage") - .withArgs(schainHash, 1, await depositBoxERC721WithMetadata.getAddress(), deployer.address, data2); + .withArgs(schainHash, 1, depositBoxERC721WithMetadata, deployer.address, data2); // console.log("Gas for depositERC721:", res.receipt.gasUsed); // expectation - expect(await erc721OnChain.ownerOf(tokenId)).to.equal(await depositBoxERC721WithMetadata.getAddress()); - expect(await erc721OnChain.ownerOf(tokenId2)).to.equal(await depositBoxERC721WithMetadata.getAddress()); + expect(await erc721OnChain.ownerOf(tokenId)).to.equal(depositBoxERC721WithMetadata); + expect(await erc721OnChain.ownerOf(tokenId2)).to.equal(depositBoxERC721WithMetadata); }); }); @@ -251,16 +251,16 @@ describe("DepositBoxERC721WithMetadata", () => { await linker .connect(deployer) .connectSchain(schainName, [deployer.address, deployer.address, deployer.address]); - await erc721OnChain.connect(deployer).approve(await depositBoxERC721WithMetadata.getAddress(), tokenId); + await erc721OnChain.connect(deployer).approve(depositBoxERC721WithMetadata, tokenId); await depositBoxERC721WithMetadata.connect(user).disableWhitelist(schainName); await depositBoxERC721WithMetadata .connect(deployer) - .depositERC721(schainName, await erc721OnChain.getAddress(), tokenId); - await depositBoxERC721WithMetadata.connect(user).getFunds(schainName, await erc721OnChain.getAddress(), user.address, tokenId).should.be.eventually.rejectedWith("Schain is not killed"); + .depositERC721(schainName, erc721OnChain, tokenId); + await depositBoxERC721WithMetadata.connect(user).getFunds(schainName, erc721OnChain, user.address, tokenId).should.be.eventually.rejectedWith("Schain is not killed"); await linker.connect(deployer).kill(schainName); await linker.connect(user).kill(schainName); - await depositBoxERC721WithMetadata.connect(user).getFunds(schainName, await erc721OnChain.getAddress(), user.address, tokenId2).should.be.eventually.rejectedWith("Incorrect tokenId"); - await depositBoxERC721WithMetadata.connect(user).getFunds(schainName, await erc721OnChain.getAddress(), user.address, tokenId); + await depositBoxERC721WithMetadata.connect(user).getFunds(schainName, erc721OnChain, user.address, tokenId2).should.be.eventually.rejectedWith("Incorrect tokenId"); + await depositBoxERC721WithMetadata.connect(user).getFunds(schainName, erc721OnChain, user.address, tokenId); expect(await erc721OnChain.ownerOf(tokenId)).to.equal(user.address); }); @@ -268,13 +268,13 @@ describe("DepositBoxERC721WithMetadata", () => { const fakeERC721Contract = deployer.address; await depositBoxERC721WithMetadata.connect(user).addERC721TokenByOwner(schainName, fakeERC721Contract) .should.be.eventually.rejectedWith("Given address is not a contract"); - await depositBoxERC721WithMetadata.connect(deployer).addERC721TokenByOwner(schainName, await erc721.getAddress()) + await depositBoxERC721WithMetadata.connect(deployer).addERC721TokenByOwner(schainName, erc721) .should.be.eventually.rejectedWith("Sender is not an Schain owner"); - await depositBoxERC721WithMetadata.connect(user).addERC721TokenByOwner(schainName, await erc721.getAddress()); - await depositBoxERC721WithMetadata.connect(user).addERC721TokenByOwner(schainName, await erc721.getAddress()).should.be.eventually.rejectedWith("ERC721 Token was already added"); - expect(await depositBoxERC721WithMetadata.getSchainToERC721(schainName, await erc721.getAddress())).to.be.equal(true); - expect((await depositBoxERC721WithMetadata.getSchainToAllERC721(schainName, 0, 1))[0]).to.be.equal(await erc721.getAddress()); + await depositBoxERC721WithMetadata.connect(user).addERC721TokenByOwner(schainName, erc721); + await depositBoxERC721WithMetadata.connect(user).addERC721TokenByOwner(schainName, erc721).should.be.eventually.rejectedWith("ERC721 Token was already added"); + expect(await depositBoxERC721WithMetadata.getSchainToERC721(schainName, erc721)).to.be.equal(true); + expect((await depositBoxERC721WithMetadata.getSchainToAllERC721(schainName, 0, 1))[0]).to.be.equal(erc721); expect((await depositBoxERC721WithMetadata.getSchainToAllERC721(schainName, 0, 1)).length).to.be.equal(1); expect((await depositBoxERC721WithMetadata.getSchainToAllERC721Length(schainName)).toString()).to.be.equal("1"); await depositBoxERC721WithMetadata.getSchainToAllERC721(schainName, 1, 0).should.be.eventually.rejectedWith("Range is incorrect"); @@ -322,14 +322,14 @@ describe("DepositBoxERC721WithMetadata", () => { const senderFromSchain = deployer.address; const message = { - data: await messages.encodeTransferErc721MessageWithMetadata(await erc721.getAddress(), to, tokenId, tokenURI), - destinationContract: await depositBoxERC721WithMetadata.getAddress(), + data: await messages.encodeTransferErc721MessageWithMetadata(erc721, to, tokenId, tokenURI), + destinationContract: depositBoxERC721WithMetadata, sender: senderFromSchain }; await erc721.connect(deployer).mint(deployer.address, tokenId); await erc721.connect(deployer).setTokenURI(tokenId, tokenURI); - await erc721.connect(deployer).transferFrom(deployer.address, await depositBoxERC721WithMetadata.getAddress(), tokenId); + await erc721.connect(deployer).transferFrom(deployer.address, depositBoxERC721WithMetadata, tokenId); const balanceBefore = await getBalance(deployer.address); await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); @@ -350,13 +350,13 @@ describe("DepositBoxERC721WithMetadata", () => { const messageWithWrongTokenAddress = { data: await messages.encodeTransferErc721MessageWithMetadata(user2.address, to, tokenId, tokenURI), - destinationContract: await depositBoxERC721WithMetadata.getAddress(), + destinationContract: depositBoxERC721WithMetadata, sender: senderFromSchain }; await erc721.connect(deployer).mint(deployer.address, tokenId); await erc721.connect(deployer).setTokenURI(tokenId, tokenURI); - await erc721.connect(deployer).transferFrom(deployer.address, await depositBoxERC721WithMetadata.getAddress(), tokenId); + await erc721.connect(deployer).transferFrom(deployer.address, depositBoxERC721WithMetadata, tokenId); const tx = await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign); await expect(tx) @@ -371,8 +371,8 @@ describe("DepositBoxERC721WithMetadata", () => { const senderFromSchain = deployer.address; const messageWithWrongTokenAddress = { - data: await messages.encodeTransferErc721MessageWithMetadata(await erc721.getAddress(), to, tokenId, tokenURI), - destinationContract: await depositBoxERC721WithMetadata.getAddress(), + data: await messages.encodeTransferErc721MessageWithMetadata(erc721, to, tokenId, tokenURI), + destinationContract: depositBoxERC721WithMetadata, sender: senderFromSchain }; @@ -394,24 +394,24 @@ describe("DepositBoxERC721WithMetadata", () => { const senderFromSchain = deployer.address; const message = { - data: await messages.encodeTransferErc721MessageWithMetadata(await erc721.getAddress(), to, tokenId, tokenURI), - destinationContract: await depositBoxERC721WithMetadata.getAddress(), + data: await messages.encodeTransferErc721MessageWithMetadata(erc721, to, tokenId, tokenURI), + destinationContract: depositBoxERC721WithMetadata, sender: senderFromSchain }; await erc721.mint(deployer.address, tokenId); await erc721.connect(deployer).setTokenURI(tokenId, tokenURI); - await erc721.approve(await depositBoxERC721WithMetadata.getAddress(), tokenId); + await erc721.approve(depositBoxERC721WithMetadata, tokenId); await depositBoxERC721WithMetadata - .depositERC721(schainName, await erc721.getAddress(), tokenId); + .depositERC721(schainName, erc721, tokenId); const balanceBefore = await getBalance(deployer.address); await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); - expect(await depositBoxERC721WithMetadata.transferredAmount(await erc721.getAddress(), tokenId)).to.be.equal(zeroHash); + expect(await depositBoxERC721WithMetadata.transferredAmount(erc721, tokenId)).to.be.equal(zeroHash); (await erc721.ownerOf(tokenId)).should.be.equal(user.address); (await erc721.tokenURI(tokenId)).should.be.equal(tokenURI); diff --git a/test/DepositBoxEth.ts b/test/DepositBoxEth.ts index 4da4ab5cc..7c2e10909 100644 --- a/test/DepositBoxEth.ts +++ b/test/DepositBoxEth.ts @@ -126,7 +126,7 @@ describe("DepositBoxEth", () => { depositBoxEth = await deployDepositBoxEth(contractManager, linker, messageProxy); communityPool = await deployCommunityPool(contractManager, linker, messageProxy); messages = await deployMessages(); - await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), await linker.getAddress()); + await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); const nodeCreationParams = { @@ -141,9 +141,9 @@ describe("DepositBoxEth", () => { await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); - await messageProxy.registerExtraContractForAll(await depositBoxEth.getAddress()); - await messageProxy.registerExtraContract(schainName, await communityPool.getAddress()); - await messageProxy.registerExtraContract(schainName, await linker.getAddress()); + await messageProxy.registerExtraContractForAll(depositBoxEth); + await messageProxy.registerExtraContract(schainName, communityPool); + await messageProxy.registerExtraContract(schainName, linker); }); describe("tests for `deposit` function", async () => { @@ -184,7 +184,7 @@ describe("DepositBoxEth", () => { .connect(deployer) .deposit(schainName, { value: wei }); - const lockAndDataBalance = await ethers.provider.getBalance(await depositBoxEth.getAddress()); + const lockAndDataBalance = await ethers.provider.getBalance(depositBoxEth); // expectation expect(lockAndDataBalance).to.equal(wei); }); @@ -206,9 +206,9 @@ describe("DepositBoxEth", () => { .connect(deployer) .depositDirect(schainName, user.address, { value: wei }) .should.emit(messageProxy, "OutgoingMessage") - .withArgs(schainHash, 0, await depositBoxEth.getAddress(), deployer.address, data); + .withArgs(schainHash, 0, depositBoxEth, deployer.address, data); - const lockAndDataBalance = await ethers.provider.getBalance(await depositBoxEth.getAddress()); + const lockAndDataBalance = await ethers.provider.getBalance(depositBoxEth); // expectation expect(lockAndDataBalance).to.equal(wei); }); @@ -217,7 +217,7 @@ describe("DepositBoxEth", () => { // preparation const error = "Use deposit function"; // execution/expectation - await deployer.sendTransaction({to: await depositBoxEth.getAddress(), value: ethers.parseEther("1") }) + await deployer.sendTransaction({to: depositBoxEth, value: ethers.parseEther("1") }) .should.be.eventually.rejectedWith(error); }); @@ -276,7 +276,7 @@ describe("DepositBoxEth", () => { const message = { data: bytesData, - destinationContract: await depositBoxEth.getAddress(), + destinationContract: depositBoxEth, sender: senderFromSchain }; // redeploy depositBoxEth with `developer` address instead `messageProxyForMainnet.address` @@ -314,7 +314,7 @@ describe("DepositBoxEth", () => { const message = { data: bytesData, - destinationContract: await depositBoxEth.getAddress(), + destinationContract: depositBoxEth, sender: senderFromSchain }; // redeploy depositBoxEth with `developer` address instead `messageProxyForMainnet.address` @@ -360,7 +360,7 @@ describe("DepositBoxEth", () => { const message = { data: bytesData, - destinationContract: await depositBoxEth.getAddress(), + destinationContract: depositBoxEth, sender: senderFromSchain }; // redeploy depositBoxEth with `developer` address instead `messageProxyForMainnet.address` @@ -397,7 +397,7 @@ describe("DepositBoxEth", () => { const message = { data: bytesData, - destinationContract: await depositBoxEth.getAddress(), + destinationContract: depositBoxEth, sender: senderFromSchain, }; // redeploy depositBoxEth with `developer` address instead `messageProxyForMainnet.address` @@ -431,7 +431,7 @@ describe("DepositBoxEth", () => { const message = { data: bytesData, - destinationContract: await depositBoxEth.getAddress(), + destinationContract: depositBoxEth, sender: senderFromSchain, }; @@ -480,7 +480,7 @@ describe("DepositBoxEth", () => { const message = { data: bytesData, - destinationContract: await depositBoxEth.getAddress(), + destinationContract: depositBoxEth, sender: senderFromSchain, }; @@ -543,7 +543,7 @@ describe("DepositBoxEth", () => { const wei = "30000000000000000"; const fallbackEthTester = await deployFallbackEthTester(depositBoxEth, communityPool, schainName); - const bytesData = await messages.encodeTransferEthMessage(await fallbackEthTester.getAddress(), wei); + const bytesData = await messages.encodeTransferEthMessage(fallbackEthTester, wei); await setCommonPublicKey(contractManager, schainName); @@ -556,7 +556,7 @@ describe("DepositBoxEth", () => { const message = { data: bytesData, - destinationContract: await depositBoxEth.getAddress(), + destinationContract: depositBoxEth, sender: senderFromSchain, }; @@ -582,12 +582,12 @@ describe("DepositBoxEth", () => { await reimbursed(await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)); - expect(await depositBoxEth.approveTransfers(await fallbackEthTester.getAddress())).to.equal(wei); + expect(await depositBoxEth.approveTransfers(fallbackEthTester)).to.equal(wei); await depositBoxEth.connect(user2).getMyEth() .should.be.eventually.rejectedWith("User has insufficient ETH"); - expect(await depositBoxEth.approveTransfers(await fallbackEthTester.getAddress())).to.equal(wei); + expect(await depositBoxEth.approveTransfers(fallbackEthTester)).to.equal(wei); expect(await depositBoxEth.activeEthTransfers(schainHash)).to.be.equal(false); await depositBoxEth.connect(user2).enableActiveEthTransfers(schainName).should.be.rejectedWith("Sender is not an Schain owner"); @@ -597,7 +597,7 @@ describe("DepositBoxEth", () => { await depositBoxEth.connect(deployer).enableActiveEthTransfers(schainName).should.be.eventually.rejectedWith("Active eth transfers enabled"); expect(await depositBoxEth.activeEthTransfers(schainHash)).to.be.equal(true); - await ethers.provider.getBalance(await fallbackEthTester.getAddress()); + await ethers.provider.getBalance(fallbackEthTester); const tx = await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 1, [message], sign); @@ -606,9 +606,9 @@ describe("DepositBoxEth", () => { .withArgs(1n, stringToHex("Address: unable to send value, recipient may have reverted")); - expect(await depositBoxEth.approveTransfers(await fallbackEthTester.getAddress())).to.equal(wei); + expect(await depositBoxEth.approveTransfers(fallbackEthTester)).to.equal(wei); await fallbackEthTester.connect(user).getMyEth(); - expect(await depositBoxEth.approveTransfers(await fallbackEthTester.getAddress())).to.equal("0"); + expect(await depositBoxEth.approveTransfers(fallbackEthTester)).to.equal("0"); await fallbackEthTester.connect(user).getMyEth() .should.be.eventually.rejectedWith("User has insufficient ETH"); }); diff --git a/test/Linker.ts b/test/Linker.ts index 8a6372d9d..a34b5d514 100644 --- a/test/Linker.ts +++ b/test/Linker.ts @@ -78,16 +78,16 @@ describe("Linker", () => { depositBoxEth = await deployDepositBoxEth(contractManager, linker, messageProxy); depositBoxERC20 = await deployDepositBoxERC20(contractManager, linker, messageProxy); depositBoxERC721 = await deployDepositBoxERC721(contractManager, linker, messageProxy); - await linker.removeMainnetContract(await depositBoxEth.getAddress()); - await linker.removeMainnetContract(await depositBoxERC20.getAddress()); - await linker.removeMainnetContract(await depositBoxERC721.getAddress()); - await linker.removeMainnetContract(await linker.getAddress()); + await linker.removeMainnetContract(depositBoxEth); + await linker.removeMainnetContract(depositBoxERC20); + await linker.removeMainnetContract(depositBoxERC721); + await linker.removeMainnetContract(linker); await linker.grantRole(await linker.LINKER_ROLE(), deployer.address); - await linker.grantRole(await linker.LINKER_ROLE(), await linker.getAddress()); - await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), await linker.getAddress()); + await linker.grantRole(await linker.LINKER_ROLE(), linker); + await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, deployer.address, 1, 1); - await messageProxy.registerExtraContractForAll(await linker.getAddress()); + await messageProxy.registerExtraContractForAll(linker); }); it("should connect schain", async () => { @@ -107,11 +107,11 @@ describe("Linker", () => { const nullAddress = "0x0000000000000000000000000000000000000000"; const tokenManagerAddress = user.address; - expect(await linker.hasMainnetContract(await depositBoxEth.getAddress())).to.equal(false); + expect(await linker.hasMainnetContract(depositBoxEth)).to.equal(false); - await linker.connect(deployer).registerMainnetContract(await depositBoxEth.getAddress()); + await linker.connect(deployer).registerMainnetContract(depositBoxEth); - expect(await linker.hasMainnetContract(await depositBoxEth.getAddress())).to.equal(true); + expect(await linker.hasMainnetContract(depositBoxEth)).to.equal(true); await linker.connect(deployer).connectSchain(schainName, []) .should.be.eventually.rejectedWith("Incorrect number of addresses"); @@ -134,20 +134,20 @@ describe("Linker", () => { const nullAddress = "0x0000000000000000000000000000000000000000"; const tokenManagerAddress = user.address; - expect(await linker.hasMainnetContract(await depositBoxEth.getAddress())).to.equal(false); - expect(await linker.hasMainnetContract(await depositBoxERC20.getAddress())).to.equal(false); - expect(await linker.hasMainnetContract(await depositBoxERC721.getAddress())).to.equal(false); - expect(await linker.hasMainnetContract(await linker.getAddress())).to.equal(false); + expect(await linker.hasMainnetContract(depositBoxEth)).to.equal(false); + expect(await linker.hasMainnetContract(depositBoxERC20)).to.equal(false); + expect(await linker.hasMainnetContract(depositBoxERC721)).to.equal(false); + expect(await linker.hasMainnetContract(linker)).to.equal(false); - await linker.connect(deployer).registerMainnetContract(await depositBoxEth.getAddress()); - await linker.connect(deployer).registerMainnetContract(await depositBoxERC20.getAddress()); - await linker.connect(deployer).registerMainnetContract(await depositBoxERC721.getAddress()); - await linker.connect(deployer).registerMainnetContract(await linker.getAddress()); + await linker.connect(deployer).registerMainnetContract(depositBoxEth); + await linker.connect(deployer).registerMainnetContract(depositBoxERC20); + await linker.connect(deployer).registerMainnetContract(depositBoxERC721); + await linker.connect(deployer).registerMainnetContract(linker); - expect(await linker.hasMainnetContract(await depositBoxEth.getAddress())).to.equal(true); - expect(await linker.hasMainnetContract(await depositBoxERC20.getAddress())).to.equal(true); - expect(await linker.hasMainnetContract(await depositBoxERC721.getAddress())).to.equal(true); - expect(await linker.hasMainnetContract(await linker.getAddress())).to.equal(true); + expect(await linker.hasMainnetContract(depositBoxEth)).to.equal(true); + expect(await linker.hasMainnetContract(depositBoxERC20)).to.equal(true); + expect(await linker.hasMainnetContract(depositBoxERC721)).to.equal(true); + expect(await linker.hasMainnetContract(linker)).to.equal(true); await linker.connect(deployer).connectSchain(schainName, []) .should.be.eventually.rejectedWith("Incorrect number of addresses"); @@ -174,10 +174,10 @@ describe("Linker", () => { it("should invoke `disconnectSchain` without mistakes", async () => { const tokenManagerAddress = user.address; - await linker.connect(deployer).registerMainnetContract(await depositBoxEth.getAddress()); - await linker.connect(deployer).registerMainnetContract(await depositBoxERC20.getAddress()); - await linker.connect(deployer).registerMainnetContract(await depositBoxERC721.getAddress()); - await linker.connect(deployer).registerMainnetContract(await linker.getAddress()); + await linker.connect(deployer).registerMainnetContract(depositBoxEth); + await linker.connect(deployer).registerMainnetContract(depositBoxERC20); + await linker.connect(deployer).registerMainnetContract(depositBoxERC721); + await linker.connect(deployer).registerMainnetContract(linker); await linker.connect(deployer).connectSchain(schainName, [tokenManagerAddress, tokenManagerAddress, tokenManagerAddress, tokenManagerAddress]); @@ -193,17 +193,17 @@ describe("Linker", () => { const nullAddress = "0x0000000000000000000000000000000000000000"; const tokenManagerAddress = user.address; - expect(await linker.hasMainnetContract(await depositBoxEth.getAddress())).to.equal(false); - expect(await linker.hasMainnetContract(await depositBoxERC20.getAddress())).to.equal(false); - expect(await linker.hasMainnetContract(await depositBoxERC721.getAddress())).to.equal(false); + expect(await linker.hasMainnetContract(depositBoxEth)).to.equal(false); + expect(await linker.hasMainnetContract(depositBoxERC20)).to.equal(false); + expect(await linker.hasMainnetContract(depositBoxERC721)).to.equal(false); - await linker.connect(deployer).registerMainnetContract(await depositBoxEth.getAddress()); - await linker.connect(deployer).registerMainnetContract(await depositBoxERC20.getAddress()); - await linker.connect(deployer).registerMainnetContract(await depositBoxERC721.getAddress()); + await linker.connect(deployer).registerMainnetContract(depositBoxEth); + await linker.connect(deployer).registerMainnetContract(depositBoxERC20); + await linker.connect(deployer).registerMainnetContract(depositBoxERC721); - expect(await linker.hasMainnetContract(await depositBoxEth.getAddress())).to.equal(true); - expect(await linker.hasMainnetContract(await depositBoxERC20.getAddress())).to.equal(true); - expect(await linker.hasMainnetContract(await depositBoxERC721.getAddress())).to.equal(true); + expect(await linker.hasMainnetContract(depositBoxEth)).to.equal(true); + expect(await linker.hasMainnetContract(depositBoxERC20)).to.equal(true); + expect(await linker.hasMainnetContract(depositBoxERC721)).to.equal(true); expect(await linker.hasMainnetContract(nullAddress)).to.equal(false); expect(await linker.hasMainnetContract(tokenManagerAddress)).to.equal(false); @@ -227,13 +227,13 @@ describe("Linker", () => { expect(await linker.hasMainnetContract(nullAddress)).to.equal(false); - await linker.connect(deployer).removeMainnetContract(await depositBoxEth.getAddress()); - await linker.connect(deployer).removeMainnetContract(await depositBoxERC20.getAddress()); - await linker.connect(deployer).removeMainnetContract(await depositBoxERC721.getAddress()); + await linker.connect(deployer).removeMainnetContract(depositBoxEth); + await linker.connect(deployer).removeMainnetContract(depositBoxERC20); + await linker.connect(deployer).removeMainnetContract(depositBoxERC721); - expect(await linker.hasMainnetContract(await depositBoxEth.getAddress())).to.equal(false); - expect(await linker.hasMainnetContract(await depositBoxERC20.getAddress())).to.equal(false); - expect(await linker.hasMainnetContract(await depositBoxERC721.getAddress())).to.equal(false); + expect(await linker.hasMainnetContract(depositBoxEth)).to.equal(false); + expect(await linker.hasMainnetContract(depositBoxERC20)).to.equal(false); + expect(await linker.hasMainnetContract(depositBoxERC721)).to.equal(false); }); it("should kill schain by schain owner first", async () => { diff --git a/test/MessageProxy.ts b/test/MessageProxy.ts index b5953743c..f5295aa39 100644 --- a/test/MessageProxy.ts +++ b/test/MessageProxy.ts @@ -121,7 +121,7 @@ describe("MessageProxy", () => { communityPool = await deployCommunityPool(contractManager, imaLinker, messageProxyForMainnet); await messageProxyForMainnet.grantRole(await messageProxyForMainnet.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await messageProxyForMainnet.grantRole(await messageProxyForMainnet.CHAIN_CONNECTOR_ROLE(), deployer.address); - const registerTx = await messageProxyForMainnet.registerExtraContract(schainName, await caller.getAddress()); + const registerTx = await messageProxyForMainnet.registerExtraContract(schainName, caller); if (registerTx.gasPrice) { gasPrice = registerTx.gasPrice; } @@ -214,16 +214,16 @@ describe("MessageProxy", () => { }); it("should post outgoing message twice", async () => { - const contractAddress = await messageProxyForMainnet.getAddress(); + const contractAddress = messageProxyForMainnet; const amount = 4; const bytesData = await messages.encodeTransferEthMessage(user.address, amount); await caller - .postOutgoingMessageTester(await messageProxyForMainnet.getAddress(), schainHash, contractAddress, bytesData) + .postOutgoingMessageTester(messageProxyForMainnet, schainHash, contractAddress, bytesData) .should.be.rejectedWith("Destination chain is not initialized"); await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); - const message1 = caller.postOutgoingMessageTester(await messageProxyForMainnet.getAddress(), schainHash, contractAddress, bytesData); + const message1 = caller.postOutgoingMessageTester(messageProxyForMainnet, schainHash, contractAddress, bytesData); await expect(message1) .to.emit(messageProxyForMainnet, 'PreviousMessageReference') @@ -233,7 +233,7 @@ describe("MessageProxy", () => { outgoingMessagesCounter.should.be.equal(1); const lastOutgoingMessageBlockId = await messageProxyForMainnet.getLastOutgoingMessageBlockId(schainName); - const message2 = caller.postOutgoingMessageTester(await messageProxyForMainnet.getAddress(), schainHash, contractAddress, bytesData); + const message2 = caller.postOutgoingMessageTester(messageProxyForMainnet, schainHash, contractAddress, bytesData); await expect(message2) .to.emit(messageProxyForMainnet, 'PreviousMessageReference') .withArgs(1, lastOutgoingMessageBlockId); @@ -243,13 +243,13 @@ describe("MessageProxy", () => { }); it("should pause with a role and unpause", async () => { - const contractAddress = await messageProxyForMainnet.getAddress(); + const contractAddress = messageProxyForMainnet; const amount = 4; const bytesData = await messages.encodeTransferEthMessage(user.address, amount); const schainOwner = user; await caller - .postOutgoingMessageTester(await messageProxyForMainnet.getAddress(), schainHash, contractAddress, bytesData) + .postOutgoingMessageTester(messageProxyForMainnet, schainHash, contractAddress, bytesData) .should.be.rejectedWith("Destination chain is not initialized"); const schainsInternal = (await ethers.getContractFactory("SchainsInternal")).attach(await contractManager.getContract("SchainsInternal")) as SchainsInternal; @@ -259,7 +259,7 @@ describe("MessageProxy", () => { await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); await caller - .postOutgoingMessageTester(await messageProxyForMainnet.getAddress(), schainHash, contractAddress, bytesData); + .postOutgoingMessageTester(messageProxyForMainnet, schainHash, contractAddress, bytesData); let outgoingMessagesCounter = await messageProxyForMainnet.getOutgoingMessagesCounter(schainName); outgoingMessagesCounter.should.be.equal(1); @@ -287,7 +287,7 @@ describe("MessageProxy", () => { pausedInfo.should.be.equal(true); await caller - .postOutgoingMessageTester(await messageProxyForMainnet.getAddress(), schainHash, contractAddress, bytesData) + .postOutgoingMessageTester(messageProxyForMainnet, schainHash, contractAddress, bytesData) .should.be.rejectedWith("IMA is paused"); await messageProxyForMainnet.connect(client).resume(schainName).should.be.rejectedWith("Incorrect sender"); @@ -303,7 +303,7 @@ describe("MessageProxy", () => { pausedInfo.should.be.equal(false); await caller - .postOutgoingMessageTester(await messageProxyForMainnet.getAddress(), schainHash, contractAddress, bytesData); + .postOutgoingMessageTester(messageProxyForMainnet, schainHash, contractAddress, bytesData); outgoingMessagesCounter = await messageProxyForMainnet.getOutgoingMessagesCounter(schainName); outgoingMessagesCounter.should.be.equal(2); @@ -315,14 +315,14 @@ describe("MessageProxy", () => { pausedInfo.should.be.equal(true); await caller - .postOutgoingMessageTester(await messageProxyForMainnet.getAddress(), schainHash, contractAddress, bytesData) + .postOutgoingMessageTester(messageProxyForMainnet, schainHash, contractAddress, bytesData) .should.be.rejectedWith("IMA is paused"); await messageProxyForMainnet.connect(deployer).resume(schainName); await messageProxyForMainnet.connect(schainOwner).resume(schainName).should.be.rejectedWith("Already unpaused"); await caller - .postOutgoingMessageTester(await messageProxyForMainnet.getAddress(), schainHash, contractAddress, bytesData); + .postOutgoingMessageTester(messageProxyForMainnet, schainHash, contractAddress, bytesData); outgoingMessagesCounter = await messageProxyForMainnet.getOutgoingMessagesCounter(schainName); outgoingMessagesCounter.should.be.equal(3); @@ -370,20 +370,20 @@ describe("MessageProxy", () => { await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); - await messageProxyForMainnet.registerExtraContract(schainName, await communityPool.getAddress()); + await messageProxyForMainnet.registerExtraContract(schainName, communityPool); await depositBox.addSchainContract(schainName, deployer.address); await communityPool.addSchainContract(schainName, deployer.address); const minTransactionGas = await communityPool.minTransactionGas(); const amountWei = minTransactionGas * BigInt(gasPrice); const message1 = { - destinationContract: await depositBox.getAddress(), + destinationContract: depositBox, sender: deployer.address, data: await messages.encodeTransferEthMessage(client.address, 0), }; const message2 = { - destinationContract: await depositBox.getAddress(), + destinationContract: depositBox, sender: deployer.address, data: await messages.encodeTransferEthMessage(customer.address, 7), }; @@ -458,15 +458,15 @@ describe("MessageProxy", () => { await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); - await messageProxyForMainnet.registerExtraContract(schainName, await communityPool.getAddress()); + await messageProxyForMainnet.registerExtraContract(schainName, communityPool); await depositBox.addSchainContract(schainName, deployer.address); const minTransactionGas = await communityPool.minTransactionGas(); const amountWei = minTransactionGas * BigInt(gasPrice) * 2n; - await messageProxyForMainnet.registerExtraContract(schainName, await depositBox.getAddress()); + await messageProxyForMainnet.registerExtraContract(schainName, depositBox); const message1 = { - destinationContract: await depositBox.getAddress(), + destinationContract: depositBox, sender: deployer.address, data: await messages.encodeTransferEthMessage(client.address, 1), }; @@ -480,7 +480,7 @@ describe("MessageProxy", () => { }; await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); - await communityPool.connect(deployer).addSchainContract(schainName, await communityPool.getAddress()); + await communityPool.connect(deployer).addSchainContract(schainName, communityPool); await communityPool.connect(client).rechargeUserWallet(schainName, client.address, {value: amountWei.toString()}); @@ -510,7 +510,7 @@ describe("MessageProxy", () => { newBalance.should.be.lt(balance); newUserBalance.should.be.deep.equal(userBalance); - await messageProxyForMainnet.addReimbursedContract(schainName, await depositBox.getAddress()); + await messageProxyForMainnet.addReimbursedContract(schainName, depositBox); balance = newBalance; userBalance = newUserBalance; @@ -547,7 +547,7 @@ describe("MessageProxy", () => { await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); await setCommonPublicKey(contractManager, schainName); - await messageProxyForMainnet.registerExtraContract(schainName, await communityPool.getAddress()); + await messageProxyForMainnet.registerExtraContract(schainName, communityPool); await depositBox.addSchainContract(schainName, deployer.address); await communityPool.addSchainContract(schainName, deployer.address); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); @@ -555,13 +555,13 @@ describe("MessageProxy", () => { const amountWei = minTransactionGas * BigInt(gasPrice); const message1 = { - destinationContract: await depositBox.getAddress(), + destinationContract: depositBox, sender: deployer.address, data: await messages.encodeTransferEthMessage(client.address, 0), }; const message2 = { - destinationContract: await depositBox.getAddress(), + destinationContract: depositBox, sender: deployer.address, data: await messages.encodeTransferEthMessage(customer.address, 7), }; @@ -665,20 +665,20 @@ describe("MessageProxy", () => { await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); - await messageProxyForMainnet.registerExtraContract(schainName, await communityPool.getAddress()); + await messageProxyForMainnet.registerExtraContract(schainName, communityPool); await depositBox.addSchainContract(schainName, deployer.address); await communityPool.addSchainContract(schainName, deployer.address); const minTransactionGas = await communityPool.minTransactionGas(); const amountWei = minTransactionGas * BigInt(gasPrice); const message1 = { - destinationContract: await depositBox.getAddress(), + destinationContract: depositBox, sender: deployer.address, data: await messages.encodeTransferEthMessage(client.address, 0), }; const message2 = { - destinationContract: await depositBox.getAddress(), + destinationContract: depositBox, sender: deployer.address, data: await messages.encodeTransferEthMessage(customer.address, 7), }; @@ -747,7 +747,7 @@ describe("MessageProxy", () => { }); it("should get outgoing messages counter", async () => { - const contractAddress = await depositBox.getAddress(); + const contractAddress = depositBox; const amount = 5; const addressTo = client.address; const bytesData = await messages.encodeTransferEthMessage(addressTo, amount); @@ -761,7 +761,7 @@ describe("MessageProxy", () => { outgoingMessagesCounter0.should.be.equal(0); await caller - .postOutgoingMessageTester(await messageProxyForMainnet.getAddress(), schainHash, contractAddress, bytesData); + .postOutgoingMessageTester(messageProxyForMainnet, schainHash, contractAddress, bytesData); const outgoingMessagesCounter = await messageProxyForMainnet.getOutgoingMessagesCounter(schainName); outgoingMessagesCounter.should.be.equal(1); @@ -786,14 +786,14 @@ describe("MessageProxy", () => { const message1 = { amount: 3, data: "0x11", - destinationContract: await depositBox.getAddress(), + destinationContract: depositBox, sender: deployer.address, to: client.address }; const message2 = { amount: 7, data: "0x22", - destinationContract: await depositBox.getAddress(), + destinationContract: depositBox, sender: user.address, to: customer.address }; @@ -853,14 +853,14 @@ describe("MessageProxy", () => { const message1 = { amount: 3, data: "0x11", - destinationContract: await depositBox.getAddress(), + destinationContract: depositBox, sender: deployer.address, to: client.address }; const message2 = { amount: 7, data: "0x22", - destinationContract: await depositBox.getAddress(), + destinationContract: depositBox, sender: user.address, to: customer.address }; @@ -891,9 +891,9 @@ describe("MessageProxy", () => { const outgoingMessagesCounter0 = await messageProxyForMainnet.getOutgoingMessagesCounter(schainName); outgoingMessagesCounter0.should.be.equal(0); - await caller.postOutgoingMessageTester(await messageProxyForMainnet.getAddress(), + await caller.postOutgoingMessageTester(messageProxyForMainnet, schainHash, - await depositBox.getAddress(), + depositBox, bytesData, ); @@ -925,7 +925,7 @@ describe("MessageProxy", () => { const message1 = { amount: 0, data: "0x11", - destinationContract: await receiverMock.getAddress(), + destinationContract: receiverMock, sender: deployer.address, to: client.address }; @@ -938,7 +938,7 @@ describe("MessageProxy", () => { hashB: HashB, }; - await messageProxyForMainnet.registerExtraContract(schainName, await receiverMock.getAddress()); + await messageProxyForMainnet.registerExtraContract(schainName, receiverMock); let a = await receiverMock.a(); expect(a).be.equal(0); @@ -977,13 +977,13 @@ describe("MessageProxy", () => { const testCallReceiverContract = await ethers.getContractFactory("TestCallReceiverContract"); const receiverMock = await testCallReceiverContract.deploy(); - await messageProxyForMainnet.registerExtraContract(schainName, await receiverMock.getAddress()); + await messageProxyForMainnet.registerExtraContract(schainName, receiverMock); const startingCounter = 0; const message1 = { amount: 0, data: ethers.AbiCoder.defaultAbiCoder().encode(["uint"], [1]), - destinationContract: await receiverMock.getAddress(), + destinationContract: receiverMock, sender: deployer.address, to: client.address }; @@ -1033,14 +1033,14 @@ describe("MessageProxy", () => { const testCallReceiverContract = await ethers.getContractFactory("TestCallReceiverContract"); const receiverMock = await testCallReceiverContract.deploy(); - await messageProxyForMainnet.registerExtraContract(schainName, await receiverMock.getAddress()); + await messageProxyForMainnet.registerExtraContract(schainName, receiverMock); const startingCounter = 0; const message1 = { amount: 0, data: ethers.AbiCoder.defaultAbiCoder().encode(["uint"], [2]), - destinationContract: await receiverMock.getAddress(), + destinationContract: receiverMock, sender: deployer.address, to: client.address }; @@ -1083,184 +1083,184 @@ describe("MessageProxy", () => { describe("register and remove extra contracts", async () => { it("should register extra contract", async () => { const fakeContractOnSchain = deployer.address; - await messageProxyForMainnet.connect(user).registerExtraContract(schainName, await depositBox.getAddress()) + await messageProxyForMainnet.connect(user).registerExtraContract(schainName, depositBox) .should.be.eventually.rejectedWith("Not enough permissions to register extra contract"); await messageProxyForMainnet.registerExtraContract(schainName, fakeContractOnSchain) .should.be.eventually.rejectedWith("Given address is not a contract"); expect((await messageProxyForMainnet.getContractRegisteredLength(schainHash)).toString()).to.be.equal("1"); - expect(await messageProxyForMainnet.isContractRegistered(schainHash, await depositBox.getAddress())).to.be.equal(false); - await messageProxyForMainnet.registerExtraContract(schainName, await depositBox.getAddress()); - expect(await messageProxyForMainnet.isContractRegistered(schainHash, await depositBox.getAddress())).to.be.equal(true); + expect(await messageProxyForMainnet.isContractRegistered(schainHash, depositBox)).to.be.equal(false); + await messageProxyForMainnet.registerExtraContract(schainName, depositBox); + expect(await messageProxyForMainnet.isContractRegistered(schainHash, depositBox)).to.be.equal(true); expect((await messageProxyForMainnet.getContractRegisteredLength(schainHash)).toString()).to.be.equal("2"); expect((await messageProxyForMainnet.getContractRegisteredRange(schainHash, 0, 1)).length).to.be.equal(1); - expect((await messageProxyForMainnet.getContractRegisteredRange(schainHash, 0, 2))[1]).to.be.equal(await depositBox.getAddress()); + expect((await messageProxyForMainnet.getContractRegisteredRange(schainHash, 0, 2))[1]).to.be.equal(depositBox); await messageProxyForMainnet.getContractRegisteredRange(schainHash, 0, 11).should.be.eventually.rejectedWith("Range is incorrect"); await messageProxyForMainnet.getContractRegisteredRange(schainHash, 1, 0).should.be.eventually.rejectedWith("Range is incorrect"); - await messageProxyForMainnet.registerExtraContract(schainName, await depositBox.getAddress()) + await messageProxyForMainnet.registerExtraContract(schainName, depositBox) .should.be.eventually.rejectedWith("Extra contract is already registered"); }); it("should register extra contract for all", async () => { const fakeContractOnSchain = deployer.address; - await messageProxyForMainnet.connect(user).registerExtraContractForAll(await depositBox.getAddress()) + await messageProxyForMainnet.connect(user).registerExtraContractForAll(depositBox) .should.be.eventually.rejectedWith("EXTRA_CONTRACT_REGISTRAR_ROLE is required"); await messageProxyForMainnet.registerExtraContractForAll(fakeContractOnSchain) .should.be.eventually.rejectedWith("Given address is not a contract"); expect((await messageProxyForMainnet.getContractRegisteredLength(zeroBytes32)).toString()).to.be.equal("0"); - expect(await messageProxyForMainnet.isContractRegistered(zeroBytes32, await depositBox.getAddress())).to.be.equal(false); - await messageProxyForMainnet.registerExtraContractForAll(await depositBox.getAddress()); - expect(await messageProxyForMainnet.isContractRegistered(zeroBytes32, await depositBox.getAddress())).to.be.equal(true); + expect(await messageProxyForMainnet.isContractRegistered(zeroBytes32, depositBox)).to.be.equal(false); + await messageProxyForMainnet.registerExtraContractForAll(depositBox); + expect(await messageProxyForMainnet.isContractRegistered(zeroBytes32, depositBox)).to.be.equal(true); expect((await messageProxyForMainnet.getContractRegisteredLength(zeroBytes32)).toString()).to.be.equal("1"); expect((await messageProxyForMainnet.getContractRegisteredRange(zeroBytes32, 0, 1)).length).to.be.equal(1); - expect((await messageProxyForMainnet.getContractRegisteredRange(zeroBytes32, 0, 1))[0]).to.be.equal(await depositBox.getAddress()); + expect((await messageProxyForMainnet.getContractRegisteredRange(zeroBytes32, 0, 1))[0]).to.be.equal(depositBox); await messageProxyForMainnet.getContractRegisteredRange(zeroBytes32, 0, 11).should.be.eventually.rejectedWith("Range is incorrect"); await messageProxyForMainnet.getContractRegisteredRange(zeroBytes32, 1, 0).should.be.eventually.rejectedWith("Range is incorrect"); - await messageProxyForMainnet.registerExtraContract(schainName, await depositBox.getAddress()) + await messageProxyForMainnet.registerExtraContract(schainName, depositBox) .should.be.eventually.rejectedWith("Extra contract is already registered for all chains"); - await messageProxyForMainnet.registerExtraContractForAll(await depositBox.getAddress()) + await messageProxyForMainnet.registerExtraContractForAll(depositBox) .should.be.eventually.rejectedWith("Extra contract is already registered"); }); it("should register reimbursed contract", async () => { const fakeContractOnSchain = deployer.address; - await messageProxyForMainnet.connect(user).addReimbursedContract(schainName, await depositBox.getAddress()) + await messageProxyForMainnet.connect(user).addReimbursedContract(schainName, depositBox) .should.be.eventually.rejectedWith("Not enough permissions to add reimbursed contract"); await messageProxyForMainnet.addReimbursedContract(schainName, fakeContractOnSchain) .should.be.eventually.rejectedWith("Given address is not a contract"); - await messageProxyForMainnet.addReimbursedContract(schainName, await depositBox.getAddress()) + await messageProxyForMainnet.addReimbursedContract(schainName, depositBox) .should.be.eventually.rejectedWith("Contract is not registered"); expect((await messageProxyForMainnet.getReimbursedContractsLength(schainHash)).toString()).to.be.equal("0"); - expect(await messageProxyForMainnet.isReimbursedContract(schainHash, await depositBox.getAddress())).to.be.equal(false); - await messageProxyForMainnet.registerExtraContract(schainName, await depositBox.getAddress()); - await messageProxyForMainnet.addReimbursedContract(schainName, await depositBox.getAddress()); - expect(await messageProxyForMainnet.isReimbursedContract(schainHash, await depositBox.getAddress())).to.be.equal(true); + expect(await messageProxyForMainnet.isReimbursedContract(schainHash, depositBox)).to.be.equal(false); + await messageProxyForMainnet.registerExtraContract(schainName, depositBox); + await messageProxyForMainnet.addReimbursedContract(schainName, depositBox); + expect(await messageProxyForMainnet.isReimbursedContract(schainHash, depositBox)).to.be.equal(true); expect((await messageProxyForMainnet.getReimbursedContractsLength(schainHash)).toString()).to.be.equal("1"); expect((await messageProxyForMainnet.getReimbursedContractsRange(schainHash, 0, 1)).length).to.be.equal(1); - expect((await messageProxyForMainnet.getReimbursedContractsRange(schainHash, 0, 1))[0]).to.be.equal(await depositBox.getAddress()); + expect((await messageProxyForMainnet.getReimbursedContractsRange(schainHash, 0, 1))[0]).to.be.equal(depositBox); await messageProxyForMainnet.getReimbursedContractsRange(schainHash, 0, 11).should.be.eventually.rejectedWith("Range is incorrect"); await messageProxyForMainnet.getReimbursedContractsRange(schainHash, 1, 0).should.be.eventually.rejectedWith("Range is incorrect"); - await messageProxyForMainnet.addReimbursedContract(schainName, await depositBox.getAddress()) + await messageProxyForMainnet.addReimbursedContract(schainName, depositBox) .should.be.eventually.rejectedWith("Reimbursed contract is already added"); }); it("should remove extra contract", async () => { const fakeContractOnSchain = deployer.address; - await messageProxyForMainnet.connect(user).removeExtraContract(schainName, await depositBox.getAddress()) + await messageProxyForMainnet.connect(user).removeExtraContract(schainName, depositBox) .should.be.eventually.rejectedWith("Not enough permissions to register extra contract"); await messageProxyForMainnet.removeExtraContract(schainName, fakeContractOnSchain) .should.be.eventually.rejectedWith("Extra contract is not registered"); expect((await messageProxyForMainnet.getContractRegisteredLength(schainHash)).toString()).to.be.equal("1"); await expect( - messageProxyForMainnet.registerExtraContract(schainName, await depositBox.getAddress()) + messageProxyForMainnet.registerExtraContract(schainName, depositBox) ).to.emit( messageProxyForMainnet, "ExtraContractRegistered" - ).withArgs(schainHash, await depositBox.getAddress()); + ).withArgs(schainHash, depositBox); expect((await messageProxyForMainnet.getContractRegisteredLength(schainHash)).toString()).to.be.equal("2"); await expect( - messageProxyForMainnet.removeExtraContract(schainName, await depositBox.getAddress()) + messageProxyForMainnet.removeExtraContract(schainName, depositBox) ).to.emit( messageProxyForMainnet, "ExtraContractRemoved" - ).withArgs(schainHash, await depositBox.getAddress()); + ).withArgs(schainHash, depositBox); expect((await messageProxyForMainnet.getContractRegisteredLength(schainHash)).toString()).to.be.equal("1"); - await messageProxyForMainnet.removeExtraContract(schainName, await depositBox.getAddress()) + await messageProxyForMainnet.removeExtraContract(schainName, depositBox) .should.be.eventually.rejectedWith("Extra contract is not registered"); - expect(await messageProxyForMainnet.isContractRegistered(schainHash, await depositBox.getAddress())).to.be.equal(false); + expect(await messageProxyForMainnet.isContractRegistered(schainHash, depositBox)).to.be.equal(false); }); it("should remove extra contract for all", async () => { const fakeContractOnSchain = deployer.address; - await messageProxyForMainnet.connect(user).removeExtraContractForAll(await depositBox.getAddress()) + await messageProxyForMainnet.connect(user).removeExtraContractForAll(depositBox) .should.be.eventually.rejectedWith("EXTRA_CONTRACT_REGISTRAR_ROLE is required"); await messageProxyForMainnet.removeExtraContractForAll(fakeContractOnSchain) .should.be.eventually.rejectedWith("Extra contract is not registered"); expect((await messageProxyForMainnet.getContractRegisteredLength(zeroBytes32)).toString()).to.be.equal("0"); await expect( - messageProxyForMainnet.registerExtraContractForAll(await depositBox.getAddress()) + messageProxyForMainnet.registerExtraContractForAll(depositBox) ).to.emit( messageProxyForMainnet, "ExtraContractRegistered" - ).withArgs(zeroBytes32, await depositBox.getAddress()); + ).withArgs(zeroBytes32, depositBox); expect((await messageProxyForMainnet.getContractRegisteredLength(zeroBytes32)).toString()).to.be.equal("1"); await expect( - messageProxyForMainnet.removeExtraContractForAll(await depositBox.getAddress()) + messageProxyForMainnet.removeExtraContractForAll(depositBox) ).to.emit( messageProxyForMainnet, "ExtraContractRemoved" - ).withArgs(zeroBytes32, await depositBox.getAddress()); + ).withArgs(zeroBytes32, depositBox); expect((await messageProxyForMainnet.getContractRegisteredLength(zeroBytes32)).toString()).to.be.equal("0"); - await messageProxyForMainnet.removeExtraContractForAll(await depositBox.getAddress()) + await messageProxyForMainnet.removeExtraContractForAll(depositBox) .should.be.eventually.rejectedWith("Extra contract is not registered"); }); it("should remove reimbursed contract", async () => { const fakeContractOnSchain = deployer.address; - await messageProxyForMainnet.connect(user).removeReimbursedContract(schainName, await depositBox.getAddress()) + await messageProxyForMainnet.connect(user).removeReimbursedContract(schainName, depositBox) .should.be.eventually.rejectedWith("Not enough permissions to remove reimbursed contract"); await messageProxyForMainnet.removeReimbursedContract(schainName, fakeContractOnSchain) .should.be.eventually.rejectedWith("Reimbursed contract is not added"); expect((await messageProxyForMainnet.getReimbursedContractsLength(schainHash)).toString()).to.be.equal("0"); - await messageProxyForMainnet.registerExtraContract(schainName, await depositBox.getAddress()); + await messageProxyForMainnet.registerExtraContract(schainName, depositBox); await expect( - messageProxyForMainnet.addReimbursedContract(schainName, await depositBox.getAddress()) + messageProxyForMainnet.addReimbursedContract(schainName, depositBox) ).to.emit( messageProxyForMainnet, "ReimbursedContractAdded" - ).withArgs(schainHash, await depositBox.getAddress()); + ).withArgs(schainHash, depositBox); expect((await messageProxyForMainnet.getReimbursedContractsLength(schainHash)).toString()).to.be.equal("1"); await expect( - messageProxyForMainnet.removeReimbursedContract(schainName, await depositBox.getAddress()) + messageProxyForMainnet.removeReimbursedContract(schainName, depositBox) ).to.emit( messageProxyForMainnet, "ReimbursedContractRemoved" - ).withArgs(schainHash, await depositBox.getAddress()); + ).withArgs(schainHash, depositBox); expect((await messageProxyForMainnet.getReimbursedContractsLength(schainHash)).toString()).to.be.equal("0"); - await messageProxyForMainnet.removeReimbursedContract(schainName, await depositBox.getAddress()) + await messageProxyForMainnet.removeReimbursedContract(schainName, depositBox) .should.be.eventually.rejectedWith("Reimbursed contract is not added"); - expect(await messageProxyForMainnet.isReimbursedContract(schainHash, await depositBox.getAddress())).to.be.equal(false); + expect(await messageProxyForMainnet.isReimbursedContract(schainHash, depositBox)).to.be.equal(false); }); it("should remove reimbursed contract when remove extra contract", async () => { const fakeContractOnSchain = deployer.address; - await messageProxyForMainnet.connect(user).removeReimbursedContract(schainName, await depositBox.getAddress()) + await messageProxyForMainnet.connect(user).removeReimbursedContract(schainName, depositBox) .should.be.eventually.rejectedWith("Not enough permissions to remove reimbursed contract"); await messageProxyForMainnet.removeReimbursedContract(schainName, fakeContractOnSchain) .should.be.eventually.rejectedWith("Reimbursed contract is not added"); expect((await messageProxyForMainnet.getReimbursedContractsLength(schainHash)).toString()).to.be.equal("0"); - await messageProxyForMainnet.registerExtraContract(schainName, await depositBox.getAddress()); + await messageProxyForMainnet.registerExtraContract(schainName, depositBox); await expect( - messageProxyForMainnet.addReimbursedContract(schainName, await depositBox.getAddress()) + messageProxyForMainnet.addReimbursedContract(schainName, depositBox) ).to.emit( messageProxyForMainnet, "ReimbursedContractAdded" - ).withArgs(schainHash, await depositBox.getAddress()); + ).withArgs(schainHash, depositBox); expect((await messageProxyForMainnet.getReimbursedContractsLength(schainHash)).toString()).to.be.equal("1"); await expect( - messageProxyForMainnet.removeExtraContract(schainName, await depositBox.getAddress()) + messageProxyForMainnet.removeExtraContract(schainName, depositBox) ).to.emit( messageProxyForMainnet, "ReimbursedContractRemoved" - ).withArgs(schainHash, await depositBox.getAddress()); + ).withArgs(schainHash, depositBox); expect((await messageProxyForMainnet.getReimbursedContractsLength(schainHash)).toString()).to.be.equal("0"); - await messageProxyForMainnet.removeReimbursedContract(schainName, await depositBox.getAddress()) + await messageProxyForMainnet.removeReimbursedContract(schainName, depositBox) .should.be.eventually.rejectedWith("Reimbursed contract is not added"); - expect(await messageProxyForMainnet.isReimbursedContract(schainHash, await depositBox.getAddress())).to.be.equal(false); + expect(await messageProxyForMainnet.isReimbursedContract(schainHash, depositBox)).to.be.equal(false); }); }); @@ -1270,14 +1270,14 @@ describe("MessageProxy", () => { beforeEach(async () => { keyStorage = await deployKeyStorageMock(); - messageProxyForSchain = await deployMessageProxyForSchainTester(await keyStorage.getAddress(), "Base schain"); + messageProxyForSchain = await deployMessageProxyForSchainTester(keyStorage, "Base schain"); messages = await deployMessages(); caller = await deployMessageProxyCaller(); const chainConnectorRole = await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(); await messageProxyForSchain.connect(deployer).grantRole(chainConnectorRole, deployer.address); const extraContractRegistrarRole = await messageProxyForSchain.EXTRA_CONTRACT_REGISTRAR_ROLE(); await messageProxyForSchain.connect(deployer).grantRole(extraContractRegistrarRole, deployer.address); - await messageProxyForSchain.registerExtraContract(schainName, await caller.getAddress()); + await messageProxyForSchain.registerExtraContract(schainName, caller); }); it("should set constants", async () => { @@ -1337,17 +1337,17 @@ describe("MessageProxy", () => { }); it("should post outgoing message", async () => { - const contractAddress = await messageProxyForSchain.getAddress(); + const contractAddress = messageProxyForSchain; const amount = 4; const addressTo = user.address; const bytesData = await messages.encodeTransferEthMessage(addressTo, amount); await caller - .postOutgoingMessageTesterOnSchain(await messageProxyForSchain.getAddress(), schainHash, contractAddress, bytesData) + .postOutgoingMessageTesterOnSchain(messageProxyForSchain, schainHash, contractAddress, bytesData) .should.be.rejectedWith("Destination chain is not initialized"); await messageProxyForSchain.connect(deployer).addConnectedChain(schainName); await caller - .postOutgoingMessageTesterOnSchain(await messageProxyForSchain.getAddress(), schainHash, contractAddress, bytesData); + .postOutgoingMessageTesterOnSchain(messageProxyForSchain, schainHash, contractAddress, bytesData); const outgoingMessagesCounter = await messageProxyForSchain.getOutgoingMessagesCounter(schainName); outgoingMessagesCounter.should.be.equal(1); }); @@ -1492,7 +1492,7 @@ describe("MessageProxy", () => { outgoingMessagesCounter0.should.be.equal(0); await caller - .postOutgoingMessageTesterOnSchain(await messageProxyForSchain.getAddress(), schainHash, messages.getAddress(), bytesData); + .postOutgoingMessageTesterOnSchain(messageProxyForSchain, schainHash, messages.getAddress(), bytesData); const outgoingMessagesCounter = await messageProxyForSchain.getOutgoingMessagesCounter(schainName); outgoingMessagesCounter.should.be.equal(1); @@ -1528,7 +1528,7 @@ describe("MessageProxy", () => { await messageProxyForSchainWithoutSignature.connect(deployer).grantRole(chainConnectorRole, deployer.address); const extraContractRegistrarRole = await messageProxyForSchainWithoutSignature.EXTRA_CONTRACT_REGISTRAR_ROLE(); await messageProxyForSchainWithoutSignature.connect(deployer).grantRole(extraContractRegistrarRole, deployer.address); - await messageProxyForSchainWithoutSignature.registerExtraContract(schainName, await caller.getAddress()); + await messageProxyForSchainWithoutSignature.registerExtraContract(schainName, caller); const receiverMockFactory = await ethers.getContractFactory("ReceiverGasLimitSchainMock"); receiverMock = await receiverMockFactory.deploy() as ReceiverGasLimitSchainMock; @@ -1539,14 +1539,14 @@ describe("MessageProxy", () => { const message1 = { amount: 0, data: "0x11", - destinationContract: await receiverMock.getAddress(), + destinationContract: receiverMock, sender: deployer.address, to: client.address }; const outgoingMessages = [message1]; - await messageProxyForSchainWithoutSignature.registerExtraContract("Mainnet", await receiverMock.getAddress()); + await messageProxyForSchainWithoutSignature.registerExtraContract("Mainnet", receiverMock); let a = await receiverMock.a(); expect(a).be.equal(0); @@ -1571,7 +1571,7 @@ describe("MessageProxy", () => { const message1 = { amount: 0, data: "0x11", - destinationContract: await receiverMock.getAddress(), + destinationContract: receiverMock, sender: deployer.address, to: client.address }; @@ -1579,15 +1579,15 @@ describe("MessageProxy", () => { const etherbase = await (await ethers.getContractFactory("EtherbaseMock")).deploy() as EtherbaseMock; await etherbase.initialize(deployer.address); - await etherbase.grantRole(await etherbase.ETHER_MANAGER_ROLE(), await messageProxyForSchainWithoutSignature.getAddress()); + await etherbase.grantRole(await etherbase.ETHER_MANAGER_ROLE(), messageProxyForSchainWithoutSignature); - await messageProxyForSchainWithoutSignature.registerExtraContract("Mainnet", await receiverMock.getAddress()); - await messageProxyForSchainWithoutSignature.setEtherbase(await etherbase.getAddress()); + await messageProxyForSchainWithoutSignature.registerExtraContract("Mainnet", receiverMock); + await messageProxyForSchainWithoutSignature.setEtherbase(etherbase); const smallBalance = ethers.parseEther("0.02"); // left small amount of eth on agent balance to emulate PoW. - let agentBalance = await ethers.provider.getBalance(await agent.getAddress()); - await agent.sendTransaction({to: await etherbase.getAddress(), value: agentBalance - smallBalance}); + let agentBalance = await ethers.provider.getBalance(agent); + await agent.sendTransaction({to: etherbase, value: agentBalance - smallBalance}); await messageProxyForSchainWithoutSignature .connect(agent) @@ -1598,7 +1598,7 @@ describe("MessageProxy", () => { randomSignature ); - agentBalance = await ethers.provider.getBalance(await agent.getAddress()); + agentBalance = await ethers.provider.getBalance(agent); agentBalance.should.be.closeTo( await messageProxyForSchainWithoutSignature.MINIMUM_BALANCE(), ethers.parseEther("0.001") @@ -1612,7 +1612,7 @@ describe("MessageProxy", () => { const message1 = { amount: 0, data: "0x11", - destinationContract: await receiverMock.getAddress(), + destinationContract: receiverMock, sender: deployer.address, to: client.address }; @@ -1620,17 +1620,17 @@ describe("MessageProxy", () => { const etherbase = await (await ethers.getContractFactory("EtherbaseMock")).deploy() as EtherbaseMock; await etherbase.initialize(deployer.address); - await etherbase.grantRole(await etherbase.ETHER_MANAGER_ROLE(), await messageProxyForSchainWithoutSignature.getAddress()); + await etherbase.grantRole(await etherbase.ETHER_MANAGER_ROLE(), messageProxyForSchainWithoutSignature); - await messageProxyForSchainWithoutSignature.registerExtraContract("Mainnet", await receiverMock.getAddress()); - await messageProxyForSchainWithoutSignature.setEtherbase(await etherbase.getAddress()); + await messageProxyForSchainWithoutSignature.registerExtraContract("Mainnet", receiverMock); + await messageProxyForSchainWithoutSignature.setEtherbase(etherbase); const etherbaseBalance = ethers.parseEther("0.5"); const smallBalance = ethers.parseEther("0.02"); - let agentBalance = await ethers.provider.getBalance(await agent.getAddress()); + let agentBalance = await ethers.provider.getBalance(agent); const rest = agentBalance - smallBalance - etherbaseBalance; // left small amount of eth on agent balance to emulate PoW. - await agent.sendTransaction({to: await etherbase.getAddress(), value: etherbaseBalance}); + await agent.sendTransaction({to: etherbase, value: etherbaseBalance}); await agent.sendTransaction({to: deployer.address, value: rest}); await messageProxyForSchainWithoutSignature @@ -1642,10 +1642,10 @@ describe("MessageProxy", () => { randomSignature ); - (await ethers.provider.getBalance(await etherbase.getAddress())) + (await ethers.provider.getBalance(etherbase)) .should.be.equal(0); - agentBalance = await ethers.provider.getBalance(await agent.getAddress()); + agentBalance = await ethers.provider.getBalance(agent); agentBalance.should.be.gt(etherbaseBalance); await deployer.sendTransaction({to: agent.address, value: rest}); @@ -1671,7 +1671,7 @@ describe("MessageProxy", () => { expect(await messageProxyForSchain.isContractRegistered(schainHash, messages.getAddress())).to.be.equal(true); expect((await messageProxyForSchain.getContractRegisteredLength(schainHash)).toString()).to.be.equal("2"); expect((await messageProxyForSchain.getContractRegisteredRange(schainHash, 0, 1)).length).to.be.equal(1); - expect((await messageProxyForSchain.getContractRegisteredRange(schainHash, 0, 2))[1]).to.be.equal(await messages.getAddress()); + expect((await messageProxyForSchain.getContractRegisteredRange(schainHash, 0, 2))[1]).to.be.equal(messages); await messageProxyForSchain.getContractRegisteredRange(schainHash, 0, 11).should.be.eventually.rejectedWith("Range is incorrect"); await messageProxyForSchain.getContractRegisteredRange(schainHash, 1, 0).should.be.eventually.rejectedWith("Range is incorrect"); @@ -1693,7 +1693,7 @@ describe("MessageProxy", () => { expect(await messageProxyForSchain.isContractRegistered(zeroBytes32, messages.getAddress())).to.be.equal(true); expect((await messageProxyForSchain.getContractRegisteredLength(zeroBytes32)).toString()).to.be.equal("1"); expect((await messageProxyForSchain.getContractRegisteredRange(zeroBytes32, 0, 1)).length).to.be.equal(1); - expect((await messageProxyForSchain.getContractRegisteredRange(zeroBytes32, 0, 1))[0]).to.be.equal(await messages.getAddress()); + expect((await messageProxyForSchain.getContractRegisteredRange(zeroBytes32, 0, 1))[0]).to.be.equal(messages); await messageProxyForSchain.getContractRegisteredRange(zeroBytes32, 0, 11).should.be.eventually.rejectedWith("Range is incorrect"); await messageProxyForSchain.getContractRegisteredRange(zeroBytes32, 1, 0).should.be.eventually.rejectedWith("Range is incorrect"); diff --git a/test/TokenManagerERC1155.ts b/test/TokenManagerERC1155.ts index ff6ecf0b0..fbade719c 100644 --- a/test/TokenManagerERC1155.ts +++ b/test/TokenManagerERC1155.ts @@ -85,23 +85,23 @@ describe("TokenManagerERC1155", () => { beforeEach(async () => { const keyStorage = await deployKeyStorageMock(); - messageProxyForSchain = await deployMessageProxyForSchainTester(await keyStorage.getAddress(), schainName); + messageProxyForSchain = await deployMessageProxyForSchainTester(keyStorage, schainName); tokenManagerLinker = await deployTokenManagerLinker(messageProxyForSchain, deployer.address); messages = await deployMessages(); - fakeDepositBox = await messages.getAddress(); - fakeCommunityPool = await messages.getAddress(); + fakeDepositBox = user.address; + fakeCommunityPool = user.address; - communityLocker = await deployCommunityLocker(schainName, await messageProxyForSchain.getAddress(), tokenManagerLinker, fakeCommunityPool); + communityLocker = await deployCommunityLocker(schainName, messageProxyForSchain, tokenManagerLinker, fakeCommunityPool); tokenManagerERC1155 = await deployTokenManagerERC1155( schainName, - await messageProxyForSchain.getAddress(), + messageProxyForSchain, tokenManagerLinker, communityLocker, fakeDepositBox ); - await tokenManagerLinker.registerTokenManager(await tokenManagerERC1155.getAddress()); + await tokenManagerLinker.registerTokenManager(tokenManagerERC1155); await tokenManagerERC1155.grantRole(await tokenManagerERC1155.TOKEN_REGISTRAR_ROLE(), schainOwner.address); await tokenManagerERC1155.grantRole(await tokenManagerERC1155.AUTOMATIC_DEPLOY_ROLE(), schainOwner.address); @@ -113,16 +113,16 @@ describe("TokenManagerERC1155", () => { to = user.address; const data = await messages.encodeActivateUserMessage(user.address); - await messageProxyForSchain.postMessage(await communityLocker.getAddress(), mainnetId, fakeCommunityPool, data); + await messageProxyForSchain.postMessage(communityLocker, mainnetId, fakeCommunityPool, data); const extraContractRegistrarRole = await messageProxyForSchain.EXTRA_CONTRACT_REGISTRAR_ROLE(); await messageProxyForSchain.connect(deployer).grantRole(extraContractRegistrarRole, deployer.address); - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerERC1155.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC1155); }); it("should change depositBox address", async () => { const newDepositBox = user.address; - expect(await tokenManagerERC1155.depositBox()).to.equal(await messages.getAddress()); + expect(await tokenManagerERC1155.depositBox()).to.equal(fakeDepositBox); await tokenManagerERC1155.connect(user).changeDepositBoxAddress(newDepositBox) .should.be.eventually.rejectedWith("DEFAULT_ADMIN_ROLE is required"); await tokenManagerERC1155.changeDepositBoxAddress(newDepositBox); @@ -131,19 +131,19 @@ describe("TokenManagerERC1155", () => { it("should successfully call exitToMainERC1155", async () => { // should be "No token clone on schain" if chains were different - await tokenManagerERC1155.connect(user).exitToMainERC1155(await token.getAddress(), id, amount) + await tokenManagerERC1155.connect(user).exitToMainERC1155(token, id, amount) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); - await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()); - await tokenManagerERC1155.connect(user).exitToMainERC1155(await token.getAddress(), id, amount) + await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, token, tokenClone); + await tokenManagerERC1155.connect(user).exitToMainERC1155(token, id, amount) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); await tokenClone.connect(deployer).mint(user.address, id, amount, "0x"); - await tokenManagerERC1155.connect(user).exitToMainERC1155(await token.getAddress(), id, amount) + await tokenManagerERC1155.connect(user).exitToMainERC1155(token, id, amount) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); - await tokenClone.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); - await tokenManagerERC1155.connect(user).exitToMainERC1155(await token.getAddress(), id, amount); + await tokenClone.connect(user).setApprovalForAll(tokenManagerERC1155, true); + await tokenManagerERC1155.connect(user).exitToMainERC1155(token, id, amount); const outgoingMessagesCounterMainnet = await messageProxyForSchain.getOutgoingMessagesCounter("Mainnet"); outgoingMessagesCounterMainnet.should.be.equal(1); @@ -151,37 +151,37 @@ describe("TokenManagerERC1155", () => { it("should successfully call exitToMainERC1155Batch", async () => { // should be "No token clone on schain" if chains were different - await tokenManagerERC1155.connect(user).exitToMainERC1155Batch(await token.getAddress(), ids, amounts) + await tokenManagerERC1155.connect(user).exitToMainERC1155Batch(token, ids, amounts) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); - await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()); - await tokenManagerERC1155.connect(user).exitToMainERC1155Batch(await token.getAddress(), ids, amounts) + await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, token, tokenClone); + await tokenManagerERC1155.connect(user).exitToMainERC1155Batch(token, ids, amounts) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); await tokenClone.connect(deployer).mintBatch(user.address, ids, amounts, "0x"); - await tokenManagerERC1155.connect(user).exitToMainERC1155Batch(await token.getAddress(), ids, amounts) + await tokenManagerERC1155.connect(user).exitToMainERC1155Batch(token, ids, amounts) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); - await tokenClone.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); - await tokenManagerERC1155.connect(user).exitToMainERC1155Batch(await token.getAddress(), ids, amounts); + await tokenClone.connect(user).setApprovalForAll(tokenManagerERC1155, true); + await tokenManagerERC1155.connect(user).exitToMainERC1155Batch(token, ids, amounts); const outgoingMessagesCounterMainnet = await messageProxyForSchain.getOutgoingMessagesCounter("Mainnet"); outgoingMessagesCounterMainnet.should.be.equal(1); }); it("should successfully call addERC1155TokenByOwner", async () => { - await tokenManagerERC1155.connect(user).addERC1155TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()) + await tokenManagerERC1155.connect(user).addERC1155TokenByOwner(mainnetName, token, tokenClone) .should.be.eventually.rejectedWith("TOKEN_REGISTRAR_ROLE is required"); - await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, await token.getAddress(), deployer.address) + await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, token, deployer.address) .should.be.eventually.rejectedWith("Given address is not a contract"); - await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()); + await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, token, tokenClone); - await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, await token2.getAddress(), await tokenClone.getAddress()) + await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, token2, tokenClone) .should.be.eventually.rejectedWith("Clone was already added"); - await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, await token.getAddress(), await tokenClone2.getAddress()) + await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, token, tokenClone2) .should.be.eventually.rejectedWith("Could not relink clone"); }); @@ -201,13 +201,13 @@ describe("TokenManagerERC1155", () => { erc1155OnTargetChain = await deployERC1155OnChain("NewToke1n"); const keyStorage2 = await deployKeyStorageMock(); - messageProxyForSchain2 = await deployMessageProxyForSchainTester(await keyStorage2.getAddress(), newSchainName); + messageProxyForSchain2 = await deployMessageProxyForSchainTester(keyStorage2, newSchainName); tokenManagerLinker2 = await deployTokenManagerLinker(messageProxyForSchain2, deployer.address); - communityLocker2 = await deployCommunityLocker(newSchainName, await messageProxyForSchain2.getAddress(), tokenManagerLinker2, fakeCommunityPool); - tokenManagerERC11552 = await deployTokenManagerERC1155(newSchainName, await messageProxyForSchain2.getAddress(), tokenManagerLinker2, communityLocker2, fakeDepositBox); - await erc1155OnTargetChain.connect(deployer).grantRole(await erc1155OnTargetChain.MINTER_ROLE(), await tokenManagerERC11552.getAddress()); - await tokenManagerLinker2.registerTokenManager(await tokenManagerERC11552.getAddress()); - await messageProxyForSchain2.registerExtraContractForAll(await tokenManagerERC11552.getAddress()); + communityLocker2 = await deployCommunityLocker(newSchainName, messageProxyForSchain2, tokenManagerLinker2, fakeCommunityPool); + tokenManagerERC11552 = await deployTokenManagerERC1155(newSchainName, messageProxyForSchain2, tokenManagerLinker2, communityLocker2, fakeDepositBox); + await erc1155OnTargetChain.connect(deployer).grantRole(await erc1155OnTargetChain.MINTER_ROLE(), tokenManagerERC11552); + await tokenManagerLinker2.registerTokenManager(tokenManagerERC11552); + await messageProxyForSchain2.registerExtraContractForAll(tokenManagerERC11552); }); it("should invoke `transferToSchainERC1155` without mistakes", async () => { @@ -216,24 +216,24 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mint(user.address, id, amount, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155("Mainnet", await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155("Mainnet", erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount); // expectation: const outgoingMessagesCounter = await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName); @@ -246,30 +246,30 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mint(user.address, id, 5, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, 1) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, 1) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155("Mainnet", await erc1155OnOriginChain.getAddress(), id, 1) + .transferToSchainERC1155("Mainnet", erc1155OnOriginChain, id, 1) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, 1); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, 1); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(1); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, 1); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, 1); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(2); @@ -279,7 +279,7 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, 1) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, 1) .should.be.eventually.rejectedWith("Exceeded message rate limit"); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(2); @@ -288,7 +288,7 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, 1) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, 1) .should.be.eventually.rejectedWith("Exceeded message rate limit"); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(2); @@ -297,7 +297,7 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, 1); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, 1); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(3); @@ -305,7 +305,7 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, 1); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, 1); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(4); @@ -313,7 +313,7 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, 1) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, 1) .should.be.eventually.rejectedWith("Exceeded message rate limit"); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(4); @@ -322,7 +322,7 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, 1); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, 1); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(5); }); @@ -333,27 +333,27 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mint(user.address, id, amount, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155("Mainnet", await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155("Mainnet", erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount); const data = await messages.encodeTransferErc1155AndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount, @@ -369,18 +369,18 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); await messageProxyForSchain2 - .postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data) + .postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data) .should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC11552.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); - const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, await erc1155OnOriginChain.getAddress()); + const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, erc1155OnOriginChain); const targetErc1155OnChain = (await ethers.getContractFactory("ERC1155OnChain")).attach(addressERC1155OnSchain) as ERC1155OnChain; expect((await targetErc1155OnChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); @@ -392,27 +392,27 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mint(user.address, id, amount, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155("Mainnet", await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155("Mainnet", erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount); let data = await messages.encodeTransferErc1155AndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount, @@ -428,18 +428,18 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); await messageProxyForSchain2 - .postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data) + .postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data) .should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC11552.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); - const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, await erc1155OnOriginChain.getAddress()); + const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, erc1155OnOriginChain); const targetErc1155OnChain = (await ethers.getContractFactory("ERC1155OnChain")).attach(addressERC1155OnSchain) as ERC1155OnChain; expect((await targetErc1155OnChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); @@ -449,16 +449,16 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount2); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount2); data = await messages.encodeTransferErc1155Message( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); const amountSum = 81; @@ -472,27 +472,27 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mint(user.address, id, amount, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155("Mainnet", await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155("Mainnet", erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount); let data = await messages.encodeTransferErc1155AndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount, @@ -510,19 +510,19 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC11552 .connect(schainOwner) - .addERC1155TokenByOwner(schainName, await erc1155OnOriginChain.getAddress(), await erc1155OnTargetChain.getAddress()) + .addERC1155TokenByOwner(schainName, erc1155OnOriginChain, erc1155OnTargetChain) .should.be.eventually.rejectedWith("TOKEN_REGISTRAR_ROLE is required"); await tokenManagerERC11552.connect(deployer).grantRole(await tokenManagerERC11552.TOKEN_REGISTRAR_ROLE(), schainOwner.address); await tokenManagerERC11552 .connect(schainOwner) - .addERC1155TokenByOwner(schainName, await erc1155OnOriginChain.getAddress(), await erc1155OnTargetChain.getAddress()) + .addERC1155TokenByOwner(schainName, erc1155OnOriginChain, erc1155OnTargetChain) .should.be.eventually.rejectedWith("Chain is not connected"); await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, await erc1155OnOriginChain.getAddress(), await erc1155OnTargetChain.getAddress()); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, erc1155OnOriginChain, erc1155OnTargetChain); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); expect((await erc1155OnTargetChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); @@ -532,16 +532,16 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount2); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount2); data = await messages.encodeTransferErc1155Message( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); const amountSum = 81; @@ -555,27 +555,27 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mint(user.address, id, amount, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155("Mainnet", await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155("Mainnet", erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount); let data = await messages.encodeTransferErc1155AndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount, @@ -591,48 +591,48 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC11552.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); - const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, await erc1155OnOriginChain.getAddress()); + const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, erc1155OnOriginChain); const targetErc1155OnChain = await (await ethers.getContractFactory("ERC1155OnChain")).attach(addressERC1155OnSchain) as ERC1155OnChain; expect((await targetErc1155OnChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155("Mainnet", await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155("Mainnet", erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(schainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(schainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); - await targetErc1155OnChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await targetErc1155OnChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(schainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(schainName, erc1155OnOriginChain, id, amount); data = await messages.encodeTransferErc1155Message( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); expect((await erc1155OnOriginChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); @@ -644,27 +644,27 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mint(user.address, id, amount, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155("Mainnet", await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155("Mainnet", erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount); let data = await messages.encodeTransferErc1155AndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount, @@ -680,45 +680,45 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); await tokenManagerERC11552.connect(deployer).grantRole(await tokenManagerERC11552.TOKEN_REGISTRAR_ROLE(), schainOwner.address); await tokenManagerERC11552 .connect(schainOwner) - .addERC1155TokenByOwner(schainName, await erc1155OnOriginChain.getAddress(), await erc1155OnTargetChain.getAddress()); + .addERC1155TokenByOwner(schainName, erc1155OnOriginChain, erc1155OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155("Mainnet", await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155("Mainnet", erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(schainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(schainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); - await erc1155OnTargetChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await erc1155OnTargetChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(schainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(schainName, erc1155OnOriginChain, id, amount); data = await messages.encodeTransferErc1155Message( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); expect((await erc1155OnOriginChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); }); @@ -730,27 +730,27 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mint(user.address, id, amount, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155("Mainnet", await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155("Mainnet", erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount); let data = await messages.encodeTransferErc1155AndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount, @@ -766,66 +766,66 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); await messageProxyForSchain2 - .postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data) + .postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data) .should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC11552.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); - const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, await erc1155OnOriginChain.getAddress()); + const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, erc1155OnOriginChain); const targetErc1155OnChain = await (await ethers.getContractFactory("ERC1155OnChain")).attach(addressERC1155OnSchain) as ERC1155OnChain; expect((await targetErc1155OnChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155("Mainnet", await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155("Mainnet", erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(schainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(schainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); - await targetErc1155OnChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await targetErc1155OnChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(schainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(schainName, erc1155OnOriginChain, id, amount); data = await messages.encodeTransferErc1155Message( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); expect((await erc1155OnOriginChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount); data = await messages.encodeTransferErc1155Message( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount ); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); expect((await targetErc1155OnChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); @@ -835,49 +835,49 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount2); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount2); data = await messages.encodeTransferErc1155Message( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); const amountSum = 81; expect((await targetErc1155OnChain.balanceOf(user.address, id)).toString()).to.be.equal(amountSum.toString()); - await targetErc1155OnChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await targetErc1155OnChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(schainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(schainName, erc1155OnOriginChain, id, amount); data = await messages.encodeTransferErc1155Message( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); expect((await erc1155OnOriginChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(schainName, await erc1155OnOriginChain.getAddress(), id, amount2); + .transferToSchainERC1155(schainName, erc1155OnOriginChain, id, amount2); data = await messages.encodeTransferErc1155Message( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount2 ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); expect((await erc1155OnOriginChain.balanceOf(user.address, id)).toString()).to.be.equal(amountSum.toString()); @@ -889,27 +889,27 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mint(user.address, id, amount, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155("Mainnet", await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155("Mainnet", erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount); let data = await messages.encodeTransferErc1155AndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount, @@ -925,59 +925,59 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); await tokenManagerERC11552.connect(deployer).grantRole(await tokenManagerERC11552.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, await erc1155OnOriginChain.getAddress(), await erc1155OnTargetChain.getAddress()); + await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, erc1155OnOriginChain, erc1155OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155("Mainnet", await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155("Mainnet", erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(schainName, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(schainName, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); - await erc1155OnTargetChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await erc1155OnTargetChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(schainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(schainName, erc1155OnOriginChain, id, amount); data = await messages.encodeTransferErc1155Message( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); expect((await erc1155OnOriginChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount); data = await messages.encodeTransferErc1155Message( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount ); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); expect((await erc1155OnTargetChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); @@ -987,49 +987,49 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount2); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount2); data = await messages.encodeTransferErc1155Message( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); const amountSum = 81; expect((await erc1155OnTargetChain.balanceOf(user.address, id)).toString()).to.be.equal(amountSum.toString()); - await erc1155OnTargetChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await erc1155OnTargetChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(schainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(schainName, erc1155OnOriginChain, id, amount); data = await messages.encodeTransferErc1155Message( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); expect((await erc1155OnOriginChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(schainName, await erc1155OnOriginChain.getAddress(), id, amount2); + .transferToSchainERC1155(schainName, erc1155OnOriginChain, id, amount2); data = await messages.encodeTransferErc1155Message( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount2 ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); expect((await erc1155OnOriginChain.balanceOf(user.address, id)).toString()).to.be.equal(amountSum.toString()); @@ -1041,17 +1041,17 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mint(user.address, id, amount, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount); const data = await messages.encodeTransferErc1155AndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount, @@ -1067,12 +1067,12 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); await tokenManagerERC11552.connect(deployer).grantRole(await tokenManagerERC11552.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, await erc1155OnOriginChain.getAddress(), await erc1155OnTargetChain.getAddress()); + await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, erc1155OnOriginChain, erc1155OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); expect((await erc1155OnTargetChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); @@ -1081,30 +1081,30 @@ describe("TokenManagerERC1155", () => { const erc1155OnTargetZChain = await deployERC1155OnChain("NewTokenZ"); const keyStorageZ = await deployKeyStorageMock(); - const messageProxyForSchainZ = await deployMessageProxyForSchainTester(await keyStorageZ.getAddress(), newSchainNameZ); + const messageProxyForSchainZ = await deployMessageProxyForSchainTester(keyStorageZ, newSchainNameZ); const tokenManagerLinkerZ = await deployTokenManagerLinker(messageProxyForSchainZ, deployer.address); - const communityLockerZ = await deployCommunityLocker(newSchainName, await messageProxyForSchainZ.getAddress(), tokenManagerLinkerZ, fakeCommunityPool); + const communityLockerZ = await deployCommunityLocker(newSchainName, messageProxyForSchainZ, tokenManagerLinkerZ, fakeCommunityPool); const tokenManagerERC1155Z = await deployTokenManagerERC1155( - newSchainNameZ, await messageProxyForSchainZ.getAddress(), tokenManagerLinkerZ, communityLockerZ, fakeDepositBox + newSchainNameZ, messageProxyForSchainZ, tokenManagerLinkerZ, communityLockerZ, fakeDepositBox ); - await erc1155OnTargetZChain.connect(deployer).grantRole(await erc1155OnTargetZChain.MINTER_ROLE(), await tokenManagerERC1155Z.getAddress()); - await tokenManagerLinkerZ.registerTokenManager(await tokenManagerERC1155Z.getAddress()); + await erc1155OnTargetZChain.connect(deployer).grantRole(await erc1155OnTargetZChain.MINTER_ROLE(), tokenManagerERC1155Z); + await tokenManagerLinkerZ.registerTokenManager(tokenManagerERC1155Z); await messageProxyForSchain2.connect(deployer).grantRole(await messageProxyForSchain2.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain2.connect(deployer).addConnectedChain(newSchainNameZ); - await tokenManagerERC11552.addTokenManager(newSchainNameZ, await tokenManagerERC1155Z.getAddress()); + await tokenManagerERC11552.addTokenManager(newSchainNameZ, tokenManagerERC1155Z); - await erc1155OnTargetChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await erc1155OnTargetChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(newSchainNameZ, await erc1155OnOriginChain.getAddress(), id, amount) + .transferToSchainERC1155(newSchainNameZ, erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(newSchainNameZ, await erc1155OnTargetChain.getAddress(), id, amount) + .transferToSchainERC1155(newSchainNameZ, erc1155OnTargetChain, id, amount) .should.be.eventually.rejectedWith("Incorrect main chain token"); }); @@ -1114,17 +1114,17 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mint(user.address, id, amount, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155(newSchainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(newSchainName, erc1155OnOriginChain, id, amount); let data = await messages.encodeTransferErc1155AndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount, @@ -1140,54 +1140,54 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); await tokenManagerERC11552.connect(deployer).grantRole(await tokenManagerERC11552.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, await erc1155OnOriginChain.getAddress(), await erc1155OnTargetChain.getAddress()); + await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, erc1155OnOriginChain, erc1155OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); expect((await erc1155OnTargetChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); data = await messages.encodeActivateUserMessage(user.address); - await messageProxyForSchain2.postMessage(await communityLocker2.getAddress(), mainnetId, fakeCommunityPool, data); + await messageProxyForSchain2.postMessage(communityLocker2, mainnetId, fakeCommunityPool, data); - await erc1155OnTargetChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await erc1155OnTargetChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .exitToMainERC1155(await erc1155OnOriginChain.getAddress(), id, amount) + .exitToMainERC1155(erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); await tokenManagerERC11552 .connect(user) - .exitToMainERC1155(await erc1155OnTargetChain.getAddress(), id, amount) + .exitToMainERC1155(erc1155OnTargetChain, id, amount) .should.be.eventually.rejectedWith("Incorrect main chain token"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155(schainName, await erc1155OnOriginChain.getAddress(), id, amount); + .transferToSchainERC1155(schainName, erc1155OnOriginChain, id, amount); data = await messages.encodeTransferErc1155Message( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, id, amount ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); expect((await erc1155OnOriginChain.balanceOf(user.address, id)).toString()).to.be.equal(amount.toString()); await tokenManagerERC1155 .connect(user) - .exitToMainERC1155(await erc1155OnOriginChain.getAddress(), id, amount) + .exitToMainERC1155(erc1155OnOriginChain, id, amount) .should.be.eventually.rejectedWith("Main chain token could not be transfered to Mainnet"); await tokenManagerERC1155 .connect(user) - .exitToMainERC1155(await erc1155OnTargetChain.getAddress(), id, amount) + .exitToMainERC1155(erc1155OnTargetChain, id, amount) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); }); @@ -1210,13 +1210,13 @@ describe("TokenManagerERC1155", () => { erc1155OnTargetChain = await deployERC1155OnChain("NewToke1n"); const keyStorage2 = await deployKeyStorageMock(); - messageProxyForSchain2 = await deployMessageProxyForSchainTester(await keyStorage2.getAddress(), newSchainName); + messageProxyForSchain2 = await deployMessageProxyForSchainTester(keyStorage2, newSchainName); tokenManagerLinker2 = await deployTokenManagerLinker(messageProxyForSchain2, deployer.address); - communityLocker2 = await deployCommunityLocker(newSchainName, await messageProxyForSchain2.getAddress(), tokenManagerLinker2, fakeCommunityPool); - tokenManagerERC11552 = await deployTokenManagerERC1155(newSchainName, await messageProxyForSchain2.getAddress(), tokenManagerLinker2, communityLocker2, fakeDepositBox); - await erc1155OnTargetChain.connect(deployer).grantRole(await erc1155OnTargetChain.MINTER_ROLE(), await tokenManagerERC11552.getAddress()); - await tokenManagerLinker2.registerTokenManager(await tokenManagerERC11552.getAddress()); - await messageProxyForSchain2.registerExtraContractForAll(await tokenManagerERC11552.getAddress()); + communityLocker2 = await deployCommunityLocker(newSchainName, messageProxyForSchain2, tokenManagerLinker2, fakeCommunityPool); + tokenManagerERC11552 = await deployTokenManagerERC1155(newSchainName, messageProxyForSchain2, tokenManagerLinker2, communityLocker2, fakeDepositBox); + await erc1155OnTargetChain.connect(deployer).grantRole(await erc1155OnTargetChain.MINTER_ROLE(), tokenManagerERC11552); + await tokenManagerLinker2.registerTokenManager(tokenManagerERC11552); + await messageProxyForSchain2.registerExtraContractForAll(tokenManagerERC11552); }); it("should invoke `transferToSchainERC1155` without mistakes", async () => { @@ -1225,24 +1225,24 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mintBatch(user.address, ids, amounts, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch("Mainnet", await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch("Mainnet", erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts); // expectation: const outgoingMessagesCounter = await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName); @@ -1255,30 +1255,30 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mintBatch(user.address, ids, [5, 5, 5, 5], "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, [1, 1, 1, 1]) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, [1, 1, 1, 1]) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch("Mainnet", await erc1155OnOriginChain.getAddress(), ids, [1, 1, 1, 1]) + .transferToSchainERC1155Batch("Mainnet", erc1155OnOriginChain, ids, [1, 1, 1, 1]) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, [1, 1, 1, 1]); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, [1, 1, 1, 1]); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(1); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, [1, 1, 1, 1]); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, [1, 1, 1, 1]); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(2); @@ -1288,7 +1288,7 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, [1, 1, 1, 1]) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, [1, 1, 1, 1]) .should.be.eventually.rejectedWith("Exceeded message rate limit"); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(2); @@ -1297,7 +1297,7 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, [1, 1, 1, 1]) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, [1, 1, 1, 1]) .should.be.eventually.rejectedWith("Exceeded message rate limit"); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(2); @@ -1306,7 +1306,7 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, [1, 1, 1, 1]); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, [1, 1, 1, 1]); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(3); @@ -1314,7 +1314,7 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, [1, 1, 1, 1]); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, [1, 1, 1, 1]); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(4); @@ -1322,7 +1322,7 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, [1, 1, 1, 1]) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, [1, 1, 1, 1]) .should.be.eventually.rejectedWith("Exceeded message rate limit"); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(4); @@ -1331,7 +1331,7 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, [1, 1, 1, 1]); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, [1, 1, 1, 1]); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(5); }); @@ -1342,27 +1342,27 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mintBatch(user.address, ids, amounts, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch("Mainnet", await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch("Mainnet", erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts); const data = await messages.encodeTransferErc1155BatchAndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts, @@ -1378,16 +1378,16 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC11552.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); - const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, await erc1155OnOriginChain.getAddress()); + const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, erc1155OnOriginChain); const targetErc1155OnChain = await (await ethers.getContractFactory("ERC1155OnChain")).attach(addressERC1155OnSchain) as ERC1155OnChain; const balanceIds = await targetErc1155OnChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); @@ -1405,27 +1405,27 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mintBatch(user.address, ids, amounts, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch("Mainnet", await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch("Mainnet", erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts); let data = await messages.encodeTransferErc1155BatchAndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts, @@ -1441,16 +1441,16 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC11552.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); - const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, await erc1155OnOriginChain.getAddress()); + const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, erc1155OnOriginChain); const targetErc1155OnChain = await (await ethers.getContractFactory("ERC1155OnChain")).attach(addressERC1155OnSchain) as ERC1155OnChain; let balanceIds = await targetErc1155OnChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); @@ -1466,16 +1466,16 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts2); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts2); data = await messages.encodeTransferErc1155BatchMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); const amountsSum = [81, 81, 81, 81]; @@ -1494,27 +1494,27 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mintBatch(user.address, ids, amounts, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch("Mainnet", await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch("Mainnet", erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts); let data = await messages.encodeTransferErc1155BatchAndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts, @@ -1530,15 +1530,15 @@ describe("TokenManagerERC1155", () => { // receive: // registration: - await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, await erc1155OnOriginChain.getAddress(), await erc1155OnTargetChain.getAddress()).should.be.eventually.rejectedWith("TOKEN_REGISTRAR_ROLE is required"); + await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, erc1155OnOriginChain, erc1155OnTargetChain).should.be.eventually.rejectedWith("TOKEN_REGISTRAR_ROLE is required"); await tokenManagerERC11552.connect(deployer).grantRole(await tokenManagerERC11552.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, await erc1155OnOriginChain.getAddress(), await erc1155OnTargetChain.getAddress()).should.be.eventually.rejectedWith("Chain is not connected"); + await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, erc1155OnOriginChain, erc1155OnTargetChain).should.be.eventually.rejectedWith("Chain is not connected"); await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, await erc1155OnOriginChain.getAddress(), await erc1155OnTargetChain.getAddress()); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, erc1155OnOriginChain, erc1155OnTargetChain); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); let balanceIds = await erc1155OnTargetChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); let balanceIdsNumber: number[] = []; @@ -1553,16 +1553,16 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts2); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts2); data = await messages.encodeTransferErc1155BatchMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); const amountsSum = [81, 81, 81, 81]; @@ -1581,27 +1581,27 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mintBatch(user.address, ids, amounts, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch("Mainnet", await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch("Mainnet", erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts); let data = await messages.encodeTransferErc1155BatchAndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts, @@ -1617,18 +1617,18 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); await messageProxyForSchain2 - .postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data) + .postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data) .should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC11552.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); - const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, await erc1155OnOriginChain.getAddress()); + const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, erc1155OnOriginChain); const targetErc1155OnChain = await (await ethers.getContractFactory("ERC1155OnChain")).attach(addressERC1155OnSchain) as ERC1155OnChain; let balanceIds = await targetErc1155OnChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); @@ -1640,33 +1640,33 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch("Mainnet", await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch("Mainnet", erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(schainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(schainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); - await targetErc1155OnChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await targetErc1155OnChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(schainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(schainName, erc1155OnOriginChain, ids, amounts); data = await messages.encodeTransferErc1155BatchMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); balanceIds = await erc1155OnOriginChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); balanceIdsNumber = []; @@ -1683,27 +1683,27 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mintBatch(user.address, ids, amounts, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch("Mainnet", await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch("Mainnet", erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts); let data = await messages.encodeTransferErc1155BatchAndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts, @@ -1719,43 +1719,43 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); await tokenManagerERC11552.connect(deployer).grantRole(await tokenManagerERC11552.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, await erc1155OnOriginChain.getAddress(), await erc1155OnTargetChain.getAddress()); + await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, erc1155OnOriginChain, erc1155OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch("Mainnet", await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch("Mainnet", erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(schainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(schainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); - await erc1155OnTargetChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await erc1155OnTargetChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(schainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(schainName, erc1155OnOriginChain, ids, amounts); data = await messages.encodeTransferErc1155BatchMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); const balanceIds = await erc1155OnOriginChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); const balanceIdsNumber: number[] = []; @@ -1773,27 +1773,27 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mintBatch(user.address, ids, amounts, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch("Mainnet", await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch("Mainnet", erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts); let data = await messages.encodeTransferErc1155BatchAndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts, @@ -1809,18 +1809,18 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); await messageProxyForSchain2 - .postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data) + .postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data) .should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC11552.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); - const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, await erc1155OnOriginChain.getAddress()); + const addressERC1155OnSchain = await tokenManagerERC11552.clonesErc1155(schainId, erc1155OnOriginChain); const targetErc1155OnChain = await (await ethers.getContractFactory("ERC1155OnChain")).attach(addressERC1155OnSchain) as ERC1155OnChain; let balanceIds = await targetErc1155OnChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); @@ -1832,33 +1832,33 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch("Mainnet", await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch("Mainnet", erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(schainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(schainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); - await targetErc1155OnChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await targetErc1155OnChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(schainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(schainName, erc1155OnOriginChain, ids, amounts); data = await messages.encodeTransferErc1155BatchMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); balanceIds = await erc1155OnOriginChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); balanceIdsNumber = []; @@ -1867,20 +1867,20 @@ describe("TokenManagerERC1155", () => { }); expect(balanceIdsNumber).to.deep.equal(amounts); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts); data = await messages.encodeTransferErc1155BatchMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts ); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); balanceIds = await targetErc1155OnChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); balanceIdsNumber = []; @@ -1895,16 +1895,16 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts2); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts2); data = await messages.encodeTransferErc1155BatchMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); const amountsSum = [81, 81, 81, 81]; @@ -1915,20 +1915,20 @@ describe("TokenManagerERC1155", () => { }); expect(balanceIdsNumber).to.deep.equal(amountsSum); - await targetErc1155OnChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await targetErc1155OnChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(schainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(schainName, erc1155OnOriginChain, ids, amounts); data = await messages.encodeTransferErc1155BatchMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); balanceIds = await erc1155OnOriginChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); balanceIdsNumber = []; @@ -1939,16 +1939,16 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(schainName, await erc1155OnOriginChain.getAddress(), ids, amounts2); + .transferToSchainERC1155Batch(schainName, erc1155OnOriginChain, ids, amounts2); data = await messages.encodeTransferErc1155BatchMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts2 ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); balanceIds = await erc1155OnOriginChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); balanceIdsNumber = []; @@ -1965,27 +1965,27 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mintBatch(user.address, ids, amounts, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch("Mainnet", await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch("Mainnet", erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts); let data = await messages.encodeTransferErc1155BatchAndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts, @@ -2001,43 +2001,43 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); await tokenManagerERC11552.connect(deployer).grantRole(await tokenManagerERC11552.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, await erc1155OnOriginChain.getAddress(), await erc1155OnTargetChain.getAddress()); + await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, erc1155OnOriginChain, erc1155OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch("Mainnet", await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch("Mainnet", erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(schainName, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(schainName, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); - await erc1155OnTargetChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await erc1155OnTargetChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(schainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(schainName, erc1155OnOriginChain, ids, amounts); data = await messages.encodeTransferErc1155BatchMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); let balanceIds = await erc1155OnOriginChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); let balanceIdsNumber: number[] = []; @@ -2046,20 +2046,20 @@ describe("TokenManagerERC1155", () => { }); expect(balanceIdsNumber).to.deep.equal(amounts); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts); data = await messages.encodeTransferErc1155BatchMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts ); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); balanceIds = await erc1155OnTargetChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); balanceIdsNumber = []; @@ -2074,16 +2074,16 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts2); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts2); data = await messages.encodeTransferErc1155BatchMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); const amountsSum = [81, 81, 81, 81]; @@ -2094,20 +2094,20 @@ describe("TokenManagerERC1155", () => { }); expect(balanceIdsNumber).to.deep.equal(amountsSum); - await erc1155OnTargetChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await erc1155OnTargetChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(schainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(schainName, erc1155OnOriginChain, ids, amounts); data = await messages.encodeTransferErc1155BatchMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); balanceIds = await erc1155OnOriginChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); balanceIdsNumber = []; @@ -2118,16 +2118,16 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(schainName, await erc1155OnOriginChain.getAddress(), ids, amounts2); + .transferToSchainERC1155Batch(schainName, erc1155OnOriginChain, ids, amounts2); data = await messages.encodeTransferErc1155BatchMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts2 ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); balanceIds = await erc1155OnOriginChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); balanceIdsNumber = []; @@ -2144,17 +2144,17 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mintBatch(user.address, ids, amounts, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts); const data = await messages.encodeTransferErc1155BatchAndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts, @@ -2170,12 +2170,12 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); await tokenManagerERC11552.connect(deployer).grantRole(await tokenManagerERC11552.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, await erc1155OnOriginChain.getAddress(), await erc1155OnTargetChain.getAddress()); + await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, erc1155OnOriginChain, erc1155OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); const balanceIds = await erc1155OnTargetChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); const balanceIdsNumber: number[] = []; @@ -2189,28 +2189,28 @@ describe("TokenManagerERC1155", () => { const erc1155OnTargetZChain = await deployERC1155OnChain("NewTokenZ"); const keyStorageZ = await deployKeyStorageMock(); - const messageProxyForSchainZ = await deployMessageProxyForSchainTester(await keyStorageZ.getAddress(), newSchainNameZ); + const messageProxyForSchainZ = await deployMessageProxyForSchainTester(keyStorageZ, newSchainNameZ); const tokenManagerLinkerZ = await deployTokenManagerLinker(messageProxyForSchainZ, deployer.address); - const communityLockerZ = await deployCommunityLocker(newSchainName, await messageProxyForSchainZ.getAddress(), tokenManagerLinkerZ, fakeCommunityPool); - const tokenManagerERC1155Z = await deployTokenManagerERC1155(newSchainNameZ, await messageProxyForSchainZ.getAddress(), tokenManagerLinkerZ, communityLockerZ, fakeDepositBox); - await erc1155OnTargetZChain.connect(deployer).grantRole(await erc1155OnTargetZChain.MINTER_ROLE(), await tokenManagerERC1155Z.getAddress()); - await tokenManagerLinkerZ.registerTokenManager(await tokenManagerERC1155Z.getAddress()); + const communityLockerZ = await deployCommunityLocker(newSchainName, messageProxyForSchainZ, tokenManagerLinkerZ, fakeCommunityPool); + const tokenManagerERC1155Z = await deployTokenManagerERC1155(newSchainNameZ, messageProxyForSchainZ, tokenManagerLinkerZ, communityLockerZ, fakeDepositBox); + await erc1155OnTargetZChain.connect(deployer).grantRole(await erc1155OnTargetZChain.MINTER_ROLE(), tokenManagerERC1155Z); + await tokenManagerLinkerZ.registerTokenManager(tokenManagerERC1155Z); await messageProxyForSchain2.connect(deployer).grantRole(await messageProxyForSchain2.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain2.connect(deployer).addConnectedChain(newSchainNameZ); - await tokenManagerERC11552.addTokenManager(newSchainNameZ, await tokenManagerERC1155Z.getAddress()); + await tokenManagerERC11552.addTokenManager(newSchainNameZ, tokenManagerERC1155Z); - await erc1155OnTargetChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await erc1155OnTargetChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(newSchainNameZ, await erc1155OnOriginChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(newSchainNameZ, erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(newSchainNameZ, await erc1155OnTargetChain.getAddress(), ids, amounts) + .transferToSchainERC1155Batch(newSchainNameZ, erc1155OnTargetChain, ids, amounts) .should.be.eventually.rejectedWith("Incorrect main chain token"); }); @@ -2220,17 +2220,17 @@ describe("TokenManagerERC1155", () => { await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc1155OnOriginChain.connect(deployer).mintBatch(user.address, ids, amounts, "0x"); - await erc1155OnOriginChain.connect(user).setApprovalForAll(await tokenManagerERC1155.getAddress(), true); + await erc1155OnOriginChain.connect(user).setApprovalForAll(tokenManagerERC1155, true); - await tokenManagerERC1155.addTokenManager(newSchainName, await tokenManagerERC11552.getAddress()); + await tokenManagerERC1155.addTokenManager(newSchainName, tokenManagerERC11552); // execution: await tokenManagerERC1155 .connect(user) - .transferToSchainERC1155Batch(newSchainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(newSchainName, erc1155OnOriginChain, ids, amounts); let data = await messages.encodeTransferErc1155BatchAndTokenInfoMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts, @@ -2246,12 +2246,12 @@ describe("TokenManagerERC1155", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC11552.addTokenManager(schainName, await tokenManagerERC1155.getAddress()); + await tokenManagerERC11552.addTokenManager(schainName, tokenManagerERC1155); await tokenManagerERC11552.connect(deployer).grantRole(await tokenManagerERC11552.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, await erc1155OnOriginChain.getAddress(), await erc1155OnTargetChain.getAddress()); + await tokenManagerERC11552.connect(schainOwner).addERC1155TokenByOwner(schainName, erc1155OnOriginChain, erc1155OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC11552.getAddress(), schainId, await tokenManagerERC1155.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC11552, schainId, tokenManagerERC1155, data); let balanceIds = await erc1155OnTargetChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); let balanceIdsNumber: number[] = []; @@ -2262,32 +2262,32 @@ describe("TokenManagerERC1155", () => { data = await messages.encodeActivateUserMessage(user.address); - await messageProxyForSchain2.postMessage(await communityLocker2.getAddress(), mainnetId, fakeCommunityPool, data); + await messageProxyForSchain2.postMessage(communityLocker2, mainnetId, fakeCommunityPool, data); - await erc1155OnTargetChain.connect(user).setApprovalForAll(await tokenManagerERC11552.getAddress(), true); + await erc1155OnTargetChain.connect(user).setApprovalForAll(tokenManagerERC11552, true); await tokenManagerERC11552 .connect(user) - .exitToMainERC1155Batch(await erc1155OnOriginChain.getAddress(), ids, amounts) + .exitToMainERC1155Batch(erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); await tokenManagerERC11552 .connect(user) - .exitToMainERC1155Batch(await erc1155OnTargetChain.getAddress(), ids, amounts) + .exitToMainERC1155Batch(erc1155OnTargetChain, ids, amounts) .should.be.eventually.rejectedWith("Incorrect main chain token"); await tokenManagerERC11552 .connect(user) - .transferToSchainERC1155Batch(schainName, await erc1155OnOriginChain.getAddress(), ids, amounts); + .transferToSchainERC1155Batch(schainName, erc1155OnOriginChain, ids, amounts); data = await messages.encodeTransferErc1155BatchMessage( - await erc1155OnOriginChain.getAddress(), + erc1155OnOriginChain, user.address, ids, amounts ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), newSchainId, await tokenManagerERC11552.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC1155, newSchainId, tokenManagerERC11552, data); balanceIds = await erc1155OnOriginChain.balanceOfBatch([user.address, user.address, user.address, user.address], ids); balanceIdsNumber = []; @@ -2298,12 +2298,12 @@ describe("TokenManagerERC1155", () => { await tokenManagerERC1155 .connect(user) - .exitToMainERC1155Batch(await erc1155OnOriginChain.getAddress(), ids, amounts) + .exitToMainERC1155Batch(erc1155OnOriginChain, ids, amounts) .should.be.eventually.rejectedWith("Main chain token could not be transfered to Mainnet"); await tokenManagerERC1155 .connect(user) - .exitToMainERC1155Batch(await erc1155OnTargetChain.getAddress(), ids, amounts) + .exitToMainERC1155Batch(erc1155OnTargetChain, ids, amounts) .should.be.eventually.rejectedWith("Not allowed ERC1155 Token"); }); @@ -2315,7 +2315,7 @@ describe("TokenManagerERC1155", () => { it("should transfer ERC1155 token through `postMessage` function with token info", async () => { // preparation const data = await messages.encodeTransferErc1155AndTokenInfoMessage( - await token.getAddress(), + token, to, id, amount, @@ -2324,30 +2324,30 @@ describe("TokenManagerERC1155", () => { } ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), mainnetId, fakeDepositBox, data) + await messageProxyForSchain.postMessage(tokenManagerERC1155, mainnetId, fakeDepositBox, data) .should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC1155.connect(schainOwner).enableAutomaticDeploy(); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), mainnetId, fakeDepositBox, data); - const addressERC1155OnSchain = await tokenManagerERC1155.clonesErc1155(mainnetId, await token.getAddress()); + await messageProxyForSchain.postMessage(tokenManagerERC1155, mainnetId, fakeDepositBox, data); + const addressERC1155OnSchain = await tokenManagerERC1155.clonesErc1155(mainnetId, token); const erc1155OnChain = (await ethers.getContractFactory("ERC1155OnChain")).attach(addressERC1155OnSchain) as ERC1155OnChain; expect(await erc1155OnChain.balanceOf(to, id)).to.be.equal(amount); }); it("should transfer ERC1155 token on schain", async () => { // preparation - await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()); - await tokenClone.connect(deployer).grantRole(await tokenClone.MINTER_ROLE(), await tokenManagerERC1155.getAddress()); + await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, token, tokenClone); + await tokenClone.connect(deployer).grantRole(await tokenClone.MINTER_ROLE(), tokenManagerERC1155); const data = await messages.encodeTransferErc1155Message( - await token.getAddress(), + token, to, id, amount ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), mainnetId, fakeDepositBox, data); - const addressERC1155OnSchain = await tokenManagerERC1155.clonesErc1155(mainnetId, await token.getAddress()); + await messageProxyForSchain.postMessage(tokenManagerERC1155, mainnetId, fakeDepositBox, data); + const addressERC1155OnSchain = await tokenManagerERC1155.clonesErc1155(mainnetId, token); const erc1155OnChain = (await ethers.getContractFactory("ERC1155OnChain")).attach(addressERC1155OnSchain) as ERC1155OnChain; expect(await erc1155OnChain.balanceOf(to, id)).to.be.equal(amount); }); @@ -2355,7 +2355,7 @@ describe("TokenManagerERC1155", () => { it("should transfer ERC1155 token batch through `postMessage` function with token info", async () => { // preparation const data = await messages.encodeTransferErc1155BatchAndTokenInfoMessage( - await token.getAddress(), + token, to, ids, amounts, @@ -2364,12 +2364,12 @@ describe("TokenManagerERC1155", () => { } ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), mainnetId, fakeDepositBox, data) + await messageProxyForSchain.postMessage(tokenManagerERC1155, mainnetId, fakeDepositBox, data) .should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC1155.connect(schainOwner).enableAutomaticDeploy(); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), mainnetId, fakeDepositBox, data); - const addressERC1155OnSchain = await tokenManagerERC1155.clonesErc1155(mainnetId, await token.getAddress()); + await messageProxyForSchain.postMessage(tokenManagerERC1155, mainnetId, fakeDepositBox, data); + const addressERC1155OnSchain = await tokenManagerERC1155.clonesErc1155(mainnetId, token); const erc1155OnChain = (await ethers.getContractFactory("ERC1155OnChain")).attach(addressERC1155OnSchain) as ERC1155OnChain; const balanceIds = await erc1155OnChain.balanceOfBatch([to, to, to, to], ids); @@ -2382,18 +2382,18 @@ describe("TokenManagerERC1155", () => { it("should transfer ERC1155 token batch on schain", async () => { // preparation - await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()); - await tokenClone.connect(deployer).grantRole(await tokenClone.MINTER_ROLE(), await tokenManagerERC1155.getAddress()); + await tokenManagerERC1155.connect(schainOwner).addERC1155TokenByOwner(mainnetName, token, tokenClone); + await tokenClone.connect(deployer).grantRole(await tokenClone.MINTER_ROLE(), tokenManagerERC1155); const data = await messages.encodeTransferErc1155BatchMessage( - await token.getAddress(), + token, to, ids, amounts ); - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), mainnetId, fakeDepositBox, data); - const addressERC1155OnSchain = await tokenManagerERC1155.clonesErc1155(mainnetId, await token.getAddress()); + await messageProxyForSchain.postMessage(tokenManagerERC1155, mainnetId, fakeDepositBox, data); + const addressERC1155OnSchain = await tokenManagerERC1155.clonesErc1155(mainnetId, token); const erc1155OnChain = (await ethers.getContractFactory("ERC1155OnChain")).attach(addressERC1155OnSchain) as ERC1155OnChain; const balanceIds = await erc1155OnChain.balanceOfBatch([to, to, to, to], ids); const balanceIdsNumber: number[] = []; @@ -2408,7 +2408,7 @@ describe("TokenManagerERC1155", () => { "000000000000000000000000a51c1fc2f0d1a1b8494ed1fe312d7c3a78ed91c0"+ "00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8"+ "0000000000000000000000000000000000000000000000000000000000000001"; - await messageProxyForSchain.postMessage(await tokenManagerERC1155.getAddress(), mainnetId, fakeDepositBox, data) + await messageProxyForSchain.postMessage(tokenManagerERC1155, mainnetId, fakeDepositBox, data) .should.be.eventually.rejectedWith("MessageType is unknown"); }); diff --git a/test/TokenManagerERC20.ts b/test/TokenManagerERC20.ts index 92d906c84..b5984d501 100644 --- a/test/TokenManagerERC20.ts +++ b/test/TokenManagerERC20.ts @@ -82,21 +82,21 @@ describe("TokenManagerERC20", () => { erc20OnChain = await deployERC20OnChain("ERC20OnChain", "ERC20"); erc20OnMainnet = await deployERC20OnChain("SKALE", "SKL"); messages = await deployMessages(); - fakeDepositBox = await messages.getAddress(); - fakeCommunityPool = await messages.getAddress(); + fakeDepositBox = user.address; + fakeCommunityPool = user.address; const keyStorage = await deployKeyStorageMock(); - messageProxyForSchain = await deployMessageProxyForSchainTester(await keyStorage.getAddress(), schainName); + messageProxyForSchain = await deployMessageProxyForSchainTester(keyStorage, schainName); tokenManagerLinker = await deployTokenManagerLinker(messageProxyForSchain, deployer.address); - communityLocker = await deployCommunityLocker(schainName, await messageProxyForSchain.getAddress(), tokenManagerLinker, fakeCommunityPool); - tokenManagerErc20 = await deployTokenManagerERC20(schainName, await messageProxyForSchain.getAddress(), tokenManagerLinker, communityLocker, fakeDepositBox); - await erc20OnChain.connect(deployer).grantRole(await erc20OnChain.MINTER_ROLE(), await tokenManagerErc20.getAddress()); - await tokenManagerLinker.registerTokenManager(await tokenManagerErc20.getAddress()); + communityLocker = await deployCommunityLocker(schainName, messageProxyForSchain, tokenManagerLinker, fakeCommunityPool); + tokenManagerErc20 = await deployTokenManagerERC20(schainName, messageProxyForSchain, tokenManagerLinker, communityLocker, fakeDepositBox); + await erc20OnChain.connect(deployer).grantRole(await erc20OnChain.MINTER_ROLE(), tokenManagerErc20); + await tokenManagerLinker.registerTokenManager(tokenManagerErc20); await tokenManagerErc20.connect(deployer).grantRole(await tokenManagerErc20.TOKEN_REGISTRAR_ROLE(), schainOwner.address); await tokenManagerErc20.connect(deployer).grantRole(await tokenManagerErc20.AUTOMATIC_DEPLOY_ROLE(), schainOwner.address); const data = await messages.encodeActivateUserMessage(user.address); - await messageProxyForSchain.postMessage(await communityLocker.getAddress(), mainnetId, fakeCommunityPool, data); + await messageProxyForSchain.postMessage(communityLocker, mainnetId, fakeCommunityPool, data); const extraContractRegistrarRole = await messageProxyForSchain.EXTRA_CONTRACT_REGISTRAR_ROLE(); await messageProxyForSchain.connect(deployer).grantRole(extraContractRegistrarRole, deployer.address); @@ -128,14 +128,14 @@ describe("TokenManagerERC20", () => { const symbol = "D2"; const totalSupply = 1e9; - const data = await messages.encodeTransferErc20AndTokenInfoMessage(await erc20OnMainnet.getAddress(), to, amount, totalSupply, { name, symbol, decimals: 18 }); - const data2 = await messages.encodeTransferErc20AndTokenInfoMessage(await erc20OnMainnet.getAddress(), to, amount, totalSupply, { name, symbol, decimals: 18 }); + const data = await messages.encodeTransferErc20AndTokenInfoMessage(erc20OnMainnet, to, amount, totalSupply, { name, symbol, decimals: 18 }); + const data2 = await messages.encodeTransferErc20AndTokenInfoMessage(erc20OnMainnet, to, amount, totalSupply, { name, symbol, decimals: 18 }); await tokenManagerErc20.connect(schainOwner).enableAutomaticDeploy(); - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerErc20.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerErc20); // execution - const receipt = await (await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), mainnetId, fakeDepositBox, data)).wait(); + const receipt = await (await messageProxyForSchain.postMessage(tokenManagerErc20, mainnetId, fakeDepositBox, data)).wait(); // TODO: use waffle @@ -147,7 +147,7 @@ describe("TokenManagerERC20", () => { let balance = await newERC20Contract.balanceOf(to); parseInt(balance.toString(), 10).should.be.equal(amount); // expectation - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), mainnetId, fakeDepositBox, data2); + await messageProxyForSchain.postMessage(tokenManagerErc20, mainnetId, fakeDepositBox, data2); balance = await newERC20Contract.balanceOf(to); parseInt(balance.toString(), 10).should.be.equal(amount * 2); } @@ -158,19 +158,19 @@ describe("TokenManagerERC20", () => { const error = "Insufficient funds"; const amount = 10; // execution/expectation - await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, await erc20OnMainnet.getAddress(), await erc20OnChain.getAddress()); + await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, erc20OnMainnet, erc20OnChain); - await erc20OnChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .exitToMainERC20(await erc20OnMainnet.getAddress(), amount) + .exitToMainERC20(erc20OnMainnet, amount) .should.be.eventually.rejectedWith(error); }); it("should add token by owner", async () => { // preparation - const addressERC20 = await erc20OnChain.getAddress(); - const addressERC201 = await erc20OnMainnet.getAddress(); + const addressERC20 = erc20OnChain; + const addressERC201 = erc20OnMainnet; const automaticDeploy = await tokenManagerErc20.automaticDeploy(); await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, addressERC201, addressERC20); // automaticDeploy == true - enabled automaticDeploy = false - disabled @@ -191,40 +191,36 @@ describe("TokenManagerERC20", () => { await tokenManagerErc20.connect(schainOwner).disableAutomaticDeploy(); } - await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, await eRC20OnMainnet2.getAddress(), await eRC20OnChain2.getAddress()); + await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, eRC20OnMainnet2, eRC20OnChain2); - await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, await eRC20OnMainnet2.getAddress(), deployer.address) + await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, eRC20OnMainnet2, deployer.address) .should.be.eventually.rejectedWith("Given address is not a contract"); await eRC20OnChain2.mint(user.address, 1); await eRC20OnChain3.mint(user.address, 1); - await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, await eRC20OnMainnet3.getAddress(), addressERC20) + await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, eRC20OnMainnet3, addressERC20) .should.be.eventually.rejectedWith("Clone was already added"); - await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, await eRC20OnMainnet3.getAddress(), await eRC20OnChain3.getAddress()) + await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, eRC20OnMainnet3, eRC20OnChain3) .should.be.eventually.rejectedWith("Total supply of a new token is not zero"); }); describe("when token added by owner", async () => { const mainnetChainHash = ethers.id(mainnetName); - let erc20OnSchainTokenAddress: string; - let erc20OnOriginChainTokenAddress: string; beforeEach(async () => { - erc20OnSchainTokenAddress = await erc20OnChain.getAddress(); - erc20OnOriginChainTokenAddress = await erc20OnMainnet.getAddress(); - await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, erc20OnOriginChainTokenAddress, erc20OnSchainTokenAddress); + await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, erc20OnMainnet, erc20OnChain); }) it("should successfully relink if new token was not minted", async () => { const erc20OnSchainPostToken = await deployERC20OnChain("SchainPostToken", "SPT"); - await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, erc20OnOriginChainTokenAddress, await erc20OnSchainPostToken.getAddress()); + await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, erc20OnMainnet, erc20OnSchainPostToken); - await tokenManagerErc20.clonesErc20(mainnetChainHash, erc20OnOriginChainTokenAddress).should.be.eventually.equal(await erc20OnSchainPostToken.getAddress()); - await tokenManagerErc20.addedClones(await erc20OnSchainPostToken.getAddress()).should.be.eventually.equal(true); + await tokenManagerErc20.clonesErc20(mainnetChainHash, erc20OnMainnet).should.be.eventually.equal(erc20OnSchainPostToken); + await tokenManagerErc20.addedClones(erc20OnSchainPostToken).should.be.eventually.equal(true); }); it("should successfully relink if previous token on target chain was minted and then fully burned before relinking to new", async () => { @@ -232,17 +228,17 @@ describe("TokenManagerERC20", () => { await erc20OnChain.connect(user).burn(1); const erc20OnSchainPostToken = await deployERC20OnChain("SchainPostToken", "SPT"); - await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, erc20OnOriginChainTokenAddress, await erc20OnSchainPostToken.getAddress()); + await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, erc20OnMainnet, erc20OnSchainPostToken); - await tokenManagerErc20.clonesErc20(mainnetChainHash, erc20OnOriginChainTokenAddress).should.be.eventually.equal(await erc20OnSchainPostToken.getAddress()); - await tokenManagerErc20.addedClones(await erc20OnSchainPostToken.getAddress()).should.be.eventually.equal(true); + await tokenManagerErc20.clonesErc20(mainnetChainHash, erc20OnMainnet).should.be.eventually.equal(erc20OnSchainPostToken); + await tokenManagerErc20.addedClones(erc20OnSchainPostToken).should.be.eventually.equal(true); }); it("should reject new relinking if previous token was already minted", async () => { await erc20OnChain.mint(user.address, 1); const erc20OnSchainPostToken = await deployERC20OnChain("SchainPostToken", "SPT"); - await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, erc20OnOriginChainTokenAddress, await erc20OnSchainPostToken.getAddress()) + await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, erc20OnMainnet, erc20OnSchainPostToken) .should.be.eventually.rejectedWith("Total supply of a previous token is not zero") }); @@ -251,32 +247,32 @@ describe("TokenManagerERC20", () => { it("should reject with `Transfer is not approved by token holder` when invoke `exitToMainERC20`", async () => { const error = "Transfer is not approved by token holder"; const amount = 20; - await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, await erc20OnMainnet.getAddress(), await erc20OnChain.getAddress()); + await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, erc20OnMainnet, erc20OnChain); // invoke `grantRole` before `sendERC20` to avoid `MinterRole: caller does not have the Minter role` exception const minterRole = await erc20OnChain.MINTER_ROLE(); await erc20OnChain.mint(user.address, amount * 2); - await erc20OnChain.connect(deployer).grantRole(minterRole, await tokenManagerErc20.getAddress()); + await erc20OnChain.connect(deployer).grantRole(minterRole, tokenManagerErc20); // - await erc20OnChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount / 2); + await erc20OnChain.connect(user).approve(tokenManagerErc20, amount / 2); // execution/expectation - await tokenManagerErc20.connect(user).exitToMainERC20(await erc20OnMainnet.getAddress(), amount) + await tokenManagerErc20.connect(user).exitToMainERC20(erc20OnMainnet, amount) .should.be.eventually.rejectedWith(error); }); it("should invoke `exitToMainERC20` without mistakes", async () => { const amountMint = "10000000000000000"; const amountReduceCost = "8000000000000000"; - await messageProxyForSchain.registerExtraContract("Mainnet", await tokenManagerErc20.getAddress()); - await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, await erc20OnMainnet.getAddress(), await erc20OnChain.getAddress()); + await messageProxyForSchain.registerExtraContract("Mainnet", tokenManagerErc20); + await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, erc20OnMainnet, erc20OnChain); await erc20OnChain.connect(deployer).mint(user.address, amountMint); - await erc20OnChain.connect(user).approve(await tokenManagerErc20.getAddress(), amountMint); + await erc20OnChain.connect(user).approve(tokenManagerErc20, amountMint); // execution: await tokenManagerErc20 .connect(user) - .exitToMainERC20(await erc20OnMainnet.getAddress(), amountReduceCost); + .exitToMainERC20(erc20OnMainnet, amountReduceCost); // // expectation: const outgoingMessagesCounterMainnet = await messageProxyForSchain.getOutgoingMessagesCounter("Mainnet"); @@ -299,41 +295,41 @@ describe("TokenManagerERC20", () => { erc20OnTargetChain = await deployERC20OnChain("NewToke1n", "NTN1"); const keyStorage2 = await deployKeyStorageMock(); - messageProxyForSchain2 = await deployMessageProxyForSchainTester(await keyStorage2.getAddress(), newSchainName); + messageProxyForSchain2 = await deployMessageProxyForSchainTester(keyStorage2, newSchainName); tokenManagerLinker2 = await deployTokenManagerLinker(messageProxyForSchain2, deployer.address); - communityLocker2 = await deployCommunityLocker(newSchainName, await messageProxyForSchain2.getAddress(), tokenManagerLinker2, fakeCommunityPool); - tokenManagerErc202 = await deployTokenManagerERC20(newSchainName, await messageProxyForSchain2.getAddress(), tokenManagerLinker2, communityLocker2, fakeDepositBox); - await erc20OnTargetChain.connect(deployer).grantRole(await erc20OnTargetChain.MINTER_ROLE(), await tokenManagerErc202.getAddress()); - await tokenManagerLinker2.registerTokenManager(await tokenManagerErc202.getAddress()); + communityLocker2 = await deployCommunityLocker(newSchainName, messageProxyForSchain2, tokenManagerLinker2, fakeCommunityPool); + tokenManagerErc202 = await deployTokenManagerERC20(newSchainName, messageProxyForSchain2, tokenManagerLinker2, communityLocker2, fakeDepositBox); + await erc20OnTargetChain.connect(deployer).grantRole(await erc20OnTargetChain.MINTER_ROLE(), tokenManagerErc202); + await tokenManagerLinker2.registerTokenManager(tokenManagerErc202); }); it("should invoke `transferToSchainERC20` without mistakes", async () => { const amount = "20000000000000000"; - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerErc20.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerErc20); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc20OnOriginChain.connect(deployer).mint(user.address, amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerErc20 .connect(user) - .transferToSchainERC20("Mainnet", await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20("Mainnet", erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerErc20.addTokenManager(newSchainName, await tokenManagerErc202.getAddress()); + await tokenManagerErc20.addTokenManager(newSchainName, tokenManagerErc202); // execution: await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); // expectation: const outgoingMessagesCounter = await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName); @@ -342,39 +338,39 @@ describe("TokenManagerERC20", () => { it("should reject `transferToSchainERC20` when executing earlier than allowed", async () => { const amount = "20000000000000000"; - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerErc20.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerErc20); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc20OnOriginChain.connect(deployer).mint(user.address, amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerErc20 .connect(user) - .transferToSchainERC20("Mainnet", await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20("Mainnet", erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerErc20.addTokenManager(newSchainName, await tokenManagerErc202.getAddress()); + await tokenManagerErc20.addTokenManager(newSchainName, tokenManagerErc202); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(1); await erc20OnOriginChain.connect(deployer).mint(user.address, amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(2); @@ -383,11 +379,11 @@ describe("TokenManagerERC20", () => { await communityLocker.setTimeLimitPerMessage(newSchainName, 100); await erc20OnOriginChain.connect(deployer).mint(user.address, amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Exceeded message rate limit"); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(2); @@ -396,7 +392,7 @@ describe("TokenManagerERC20", () => { await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Exceeded message rate limit"); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(2); @@ -405,29 +401,29 @@ describe("TokenManagerERC20", () => { await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(3); await communityLocker.setTimeLimitPerMessage(newSchainName, 0); await erc20OnOriginChain.connect(deployer).mint(user.address, amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(4); await communityLocker.setTimeLimitPerMessage(newSchainName, 100); await erc20OnOriginChain.connect(deployer).mint(user.address, amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Exceeded message rate limit"); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(4); @@ -436,41 +432,41 @@ describe("TokenManagerERC20", () => { await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(5); }); it("should invoke `transferToSchainERC20` and receive tokens without mistakes", async () => { const amount = "20000000000000000"; - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerErc20.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerErc20); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc20OnOriginChain.connect(deployer).mint(user.address, amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerErc20 .connect(user) - .transferToSchainERC20("Mainnet", await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20("Mainnet", erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerErc20.addTokenManager(newSchainName, await tokenManagerErc202.getAddress()); + await tokenManagerErc20.addTokenManager(newSchainName, tokenManagerErc202); // execution: await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); const data = await messages.encodeTransferErc20AndTokenInfoMessage( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount, (await erc20OnOriginChain.totalSupply()).toString(), @@ -488,19 +484,19 @@ describe("TokenManagerERC20", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerErc202.addTokenManager(schainName, await tokenManagerErc20.getAddress()); + await tokenManagerErc202.addTokenManager(schainName, tokenManagerErc20); await messageProxyForSchain2 - .postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data) + .postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data) .should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerErc202.enableAutomaticDeploy(); - await messageProxyForSchain2.registerExtraContractForAll(await tokenManagerErc202.getAddress()); + await messageProxyForSchain2.registerExtraContractForAll(tokenManagerErc202); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data); - const addressERC20OnSchain = await tokenManagerErc202.clonesErc20(schainId, await erc20OnOriginChain.getAddress()); + const addressERC20OnSchain = await tokenManagerErc202.clonesErc20(schainId, erc20OnOriginChain); const targetErc20OnChain = (await ethers.getContractFactory("ERC20OnChain")).attach(addressERC20OnSchain) as ERC20OnChain; expect((await targetErc20OnChain.balanceOf(user.address)).toString()).to.be.equal(amount); @@ -508,35 +504,35 @@ describe("TokenManagerERC20", () => { it("should invoke `transferToSchainERC20` and receive tokens without mistakes back and forward twice", async () => { const amount = "20000000000000000"; - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerErc20.getAddress()); - await messageProxyForSchain2.registerExtraContractForAll(await tokenManagerErc202.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerErc20); + await messageProxyForSchain2.registerExtraContractForAll(tokenManagerErc202); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc20OnOriginChain.connect(deployer).mint(user.address, amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerErc20 .connect(user) - .transferToSchainERC20("Mainnet", await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20("Mainnet", erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerErc20.addTokenManager(newSchainName, await tokenManagerErc202.getAddress()); + await tokenManagerErc20.addTokenManager(newSchainName, tokenManagerErc202); // execution: await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); let data = await messages.encodeTransferErc20AndTokenInfoMessage( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount, (await erc20OnOriginChain.totalSupply()).toString(), @@ -554,38 +550,38 @@ describe("TokenManagerERC20", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerErc202.addTokenManager(schainName, await tokenManagerErc20.getAddress()); + await tokenManagerErc202.addTokenManager(schainName, tokenManagerErc20); await messageProxyForSchain2 - .postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data) + .postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data) .should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerErc202.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data); - const addressERC20OnSchain = await tokenManagerErc202.clonesErc20(schainId, await erc20OnOriginChain.getAddress()); + const addressERC20OnSchain = await tokenManagerErc202.clonesErc20(schainId, erc20OnOriginChain); const targetErc20OnChain = (await ethers.getContractFactory("ERC20OnChain")).attach(addressERC20OnSchain) as ERC20OnChain; expect((await targetErc20OnChain.balanceOf(user.address)).toString()).to.be.equal(amount); const amount2 = "50000000000000000"; await erc20OnOriginChain.connect(deployer).mint(user.address, amount2); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount2); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount2); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount2); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount2); data = await messages.encodeTransferErc20AndTotalSupplyMessage( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount2, (await erc20OnOriginChain.totalSupply()).toString() ); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data); const amountSum = "70000000000000000"; @@ -595,35 +591,35 @@ describe("TokenManagerERC20", () => { it("should invoke `transferToSchainERC20` and receive tokens without mistakes double with attached token", async () => { const amount = "20000000000000000"; - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerErc20.getAddress()); - await messageProxyForSchain2.registerExtraContractForAll(await tokenManagerErc202.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerErc20); + await messageProxyForSchain2.registerExtraContractForAll(tokenManagerErc202); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc20OnOriginChain.connect(deployer).mint(user.address, amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerErc20 .connect(user) - .transferToSchainERC20("Mainnet", await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20("Mainnet", erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerErc20.addTokenManager(newSchainName, await tokenManagerErc202.getAddress()); + await tokenManagerErc20.addTokenManager(newSchainName, tokenManagerErc202); // execution: await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); let data = await messages.encodeTransferErc20AndTokenInfoMessage( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount, (await erc20OnOriginChain.totalSupply()).toString(), @@ -643,41 +639,41 @@ describe("TokenManagerERC20", () => { await tokenManagerErc202 .connect(schainOwner) - .addERC20TokenByOwner(schainName, await erc20OnOriginChain.getAddress(), await erc20OnTargetChain.getAddress()) + .addERC20TokenByOwner(schainName, erc20OnOriginChain, erc20OnTargetChain) .should.be.eventually.rejectedWith("TOKEN_REGISTRAR_ROLE is required"); await tokenManagerErc202.connect(deployer).grantRole(await tokenManagerErc202.TOKEN_REGISTRAR_ROLE(), schainOwner.address); await tokenManagerErc202 .connect(schainOwner) - .addERC20TokenByOwner(schainName, await erc20OnOriginChain.getAddress(), await erc20OnTargetChain.getAddress()) + .addERC20TokenByOwner(schainName, erc20OnOriginChain, erc20OnTargetChain) .should.be.eventually.rejectedWith("Chain is not connected"); await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); await tokenManagerErc202 .connect(schainOwner) - .addERC20TokenByOwner(schainName, await erc20OnOriginChain.getAddress(), await erc20OnTargetChain.getAddress()); - await tokenManagerErc202.addTokenManager(schainName, await tokenManagerErc20.getAddress()); + .addERC20TokenByOwner(schainName, erc20OnOriginChain, erc20OnTargetChain); + await tokenManagerErc202.addTokenManager(schainName, tokenManagerErc20); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data); expect((await erc20OnTargetChain.balanceOf(user.address)).toString()).to.be.equal(amount); const amount2 = "50000000000000000"; await erc20OnOriginChain.connect(deployer).mint(user.address, amount2); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount2); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount2); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount2); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount2); data = await messages.encodeTransferErc20AndTotalSupplyMessage( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount2, (await erc20OnOriginChain.totalSupply()).toString() ); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data); const amountSum = "70000000000000000"; @@ -687,35 +683,35 @@ describe("TokenManagerERC20", () => { it("should invoke `transferToSchainERC20` and transfer back without mistakes", async () => { const amount = "20000000000000000"; - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerErc20.getAddress()); - await messageProxyForSchain2.registerExtraContractForAll(await tokenManagerErc202.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerErc20); + await messageProxyForSchain2.registerExtraContractForAll(tokenManagerErc202); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc20OnOriginChain.connect(deployer).mint(user.address, amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerErc20 .connect(user) - .transferToSchainERC20("Mainnet", await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20("Mainnet", erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerErc20.addTokenManager(newSchainName, await tokenManagerErc202.getAddress()); + await tokenManagerErc20.addTokenManager(newSchainName, tokenManagerErc202); // execution: await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); let data = await messages.encodeTransferErc20AndTokenInfoMessage( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount, (await erc20OnOriginChain.totalSupply()).toString(), @@ -733,84 +729,84 @@ describe("TokenManagerERC20", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerErc202.addTokenManager(schainName, await tokenManagerErc20.getAddress()); + await tokenManagerErc202.addTokenManager(schainName, tokenManagerErc20); await messageProxyForSchain2 - .postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data) + .postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data) .should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerErc202.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data); - const addressERC20OnSchain = await tokenManagerErc202.clonesErc20(schainId, await erc20OnOriginChain.getAddress()); + const addressERC20OnSchain = await tokenManagerErc202.clonesErc20(schainId, erc20OnOriginChain); const targetErc20OnChain = (await ethers.getContractFactory("ERC20OnChain")).attach(addressERC20OnSchain) as ERC20OnChain; expect((await targetErc20OnChain.balanceOf(user.address)).toString()).to.be.equal(amount); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerErc202 .connect(user) - .transferToSchainERC20("Mainnet", await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20("Mainnet", erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(schainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(schainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Transfer is not approved by token holder"); - await targetErc20OnChain.connect(user).approve(await tokenManagerErc202.getAddress(), amount); + await targetErc20OnChain.connect(user).approve(tokenManagerErc202, amount); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(schainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(schainName, erc20OnOriginChain, amount); data = await messages.encodeTransferErc20Message( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount ); - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), newSchainId, await tokenManagerErc202.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerErc20, newSchainId, tokenManagerErc202, data); expect((await erc20OnOriginChain.balanceOf(user.address)).toString()).to.be.equal(amount); }); it("should invoke `transferToSchainERC20` and transfer back without mistakes with attached tokens", async () => { const amount = "20000000000000000"; - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerErc20.getAddress()); - await messageProxyForSchain2.registerExtraContractForAll(await tokenManagerErc202.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerErc20); + await messageProxyForSchain2.registerExtraContractForAll(tokenManagerErc202); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc20OnOriginChain.connect(deployer).mint(user.address, amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerErc20 .connect(user) - .transferToSchainERC20("Mainnet", await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20("Mainnet", erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerErc20.addTokenManager(newSchainName, await tokenManagerErc202.getAddress()); + await tokenManagerErc20.addTokenManager(newSchainName, tokenManagerErc202); // execution: await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); let data = await messages.encodeTransferErc20AndTokenInfoMessage( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount, (await erc20OnOriginChain.totalSupply()).toString(), @@ -828,42 +824,42 @@ describe("TokenManagerERC20", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerErc202.addTokenManager(schainName, await tokenManagerErc20.getAddress()); + await tokenManagerErc202.addTokenManager(schainName, tokenManagerErc20); await tokenManagerErc202.connect(deployer).grantRole(await tokenManagerErc202.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerErc202.connect(schainOwner).addERC20TokenByOwner(schainName, await erc20OnOriginChain.getAddress(), await erc20OnTargetChain.getAddress()); + await tokenManagerErc202.connect(schainOwner).addERC20TokenByOwner(schainName, erc20OnOriginChain, erc20OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerErc202 .connect(user) - .transferToSchainERC20("Mainnet", await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20("Mainnet", erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(schainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(schainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Transfer is not approved by token holder"); - await erc20OnTargetChain.connect(user).approve(await tokenManagerErc202.getAddress(), amount); + await erc20OnTargetChain.connect(user).approve(tokenManagerErc202, amount); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(schainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(schainName, erc20OnOriginChain, amount); data = await messages.encodeTransferErc20Message( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount ); - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), newSchainId, await tokenManagerErc202.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerErc20, newSchainId, tokenManagerErc202, data); expect((await erc20OnOriginChain.balanceOf(user.address)).toString()).to.be.equal(amount); }); @@ -871,35 +867,35 @@ describe("TokenManagerERC20", () => { it("should invoke `transferToSchainERC20` and transfer back without mistakes double", async () => { const amount = "20000000000000000"; - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerErc20.getAddress()); - await messageProxyForSchain2.registerExtraContractForAll(await tokenManagerErc202.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerErc20); + await messageProxyForSchain2.registerExtraContractForAll(tokenManagerErc202); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc20OnOriginChain.connect(deployer).mint(user.address, amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerErc20 .connect(user) - .transferToSchainERC20("Mainnet", await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20("Mainnet", erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerErc20.addTokenManager(newSchainName, await tokenManagerErc202.getAddress()); + await tokenManagerErc20.addTokenManager(newSchainName, tokenManagerErc202); // execution: await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); let data = await messages.encodeTransferErc20AndTokenInfoMessage( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount, (await erc20OnOriginChain.totalSupply()).toString(), @@ -917,116 +913,116 @@ describe("TokenManagerERC20", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerErc202.addTokenManager(schainName, await tokenManagerErc20.getAddress()); + await tokenManagerErc202.addTokenManager(schainName, tokenManagerErc20); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerErc202.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data); - const addressERC20OnSchain = await tokenManagerErc202.clonesErc20(schainId, await erc20OnOriginChain.getAddress()); + const addressERC20OnSchain = await tokenManagerErc202.clonesErc20(schainId, erc20OnOriginChain); const targetErc20OnChain = (await ethers.getContractFactory("ERC20OnChain")).attach(addressERC20OnSchain) as ERC20OnChain; expect((await targetErc20OnChain.balanceOf(user.address)).toString()).to.be.equal(amount); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerErc202 .connect(user) - .transferToSchainERC20("Mainnet", await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20("Mainnet", erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(schainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(schainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Transfer is not approved by token holder"); - await targetErc20OnChain.connect(user).approve(await tokenManagerErc202.getAddress(), amount); + await targetErc20OnChain.connect(user).approve(tokenManagerErc202, amount); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(schainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(schainName, erc20OnOriginChain, amount); data = await messages.encodeTransferErc20Message( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount ); - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), newSchainId, await tokenManagerErc202.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerErc20, newSchainId, tokenManagerErc202, data); expect((await erc20OnOriginChain.balanceOf(user.address)).toString()).to.be.equal(amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); data = await messages.encodeTransferErc20AndTotalSupplyMessage( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount, (await erc20OnOriginChain.totalSupply()).toString() ); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data); expect((await targetErc20OnChain.balanceOf(user.address)).toString()).to.be.equal(amount); const amount2 = "50000000000000000"; await erc20OnOriginChain.connect(deployer).mint(user.address, amount2); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount2); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount2); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount2); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount2); data = await messages.encodeTransferErc20AndTotalSupplyMessage( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount2, (await erc20OnOriginChain.totalSupply()).toString() ); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data); const amountSum = "70000000000000000"; expect((await targetErc20OnChain.balanceOf(user.address)).toString()).to.be.equal(amountSum); - await targetErc20OnChain.connect(user).approve(await tokenManagerErc202.getAddress(), amount); + await targetErc20OnChain.connect(user).approve(tokenManagerErc202, amount); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(schainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(schainName, erc20OnOriginChain, amount); data = await messages.encodeTransferErc20Message( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount ); - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), newSchainId, await tokenManagerErc202.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerErc20, newSchainId, tokenManagerErc202, data); expect((await erc20OnOriginChain.balanceOf(user.address)).toString()).to.be.equal(amount); - await targetErc20OnChain.connect(user).approve(await tokenManagerErc202.getAddress(), amount2); + await targetErc20OnChain.connect(user).approve(tokenManagerErc202, amount2); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(schainName, await erc20OnOriginChain.getAddress(), amount2); + .transferToSchainERC20(schainName, erc20OnOriginChain, amount2); data = await messages.encodeTransferErc20Message( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount2 ); - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), newSchainId, await tokenManagerErc202.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerErc20, newSchainId, tokenManagerErc202, data); expect((await erc20OnOriginChain.balanceOf(user.address)).toString()).to.be.equal(amountSum); @@ -1034,35 +1030,35 @@ describe("TokenManagerERC20", () => { it("should invoke `transferToSchainERC20` and transfer back without mistakes double with attached tokens", async () => { const amount = "20000000000000000"; - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerErc20.getAddress()); - await messageProxyForSchain2.registerExtraContractForAll(await tokenManagerErc202.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerErc20); + await messageProxyForSchain2.registerExtraContractForAll(tokenManagerErc202); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc20OnOriginChain.connect(deployer).mint(user.address, amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerErc20 .connect(user) - .transferToSchainERC20("Mainnet", await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20("Mainnet", erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerErc20.addTokenManager(newSchainName, await tokenManagerErc202.getAddress()); + await tokenManagerErc20.addTokenManager(newSchainName, tokenManagerErc202); // execution: await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); let data = await messages.encodeTransferErc20AndTokenInfoMessage( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount, (await erc20OnOriginChain.totalSupply()).toString(), @@ -1080,111 +1076,111 @@ describe("TokenManagerERC20", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerErc202.addTokenManager(schainName, await tokenManagerErc20.getAddress()); + await tokenManagerErc202.addTokenManager(schainName, tokenManagerErc20); await tokenManagerErc202.connect(deployer).grantRole(await tokenManagerErc202.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerErc202.connect(schainOwner).addERC20TokenByOwner(schainName, await erc20OnOriginChain.getAddress(), await erc20OnTargetChain.getAddress()); + await tokenManagerErc202.connect(schainOwner).addERC20TokenByOwner(schainName, erc20OnOriginChain, erc20OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerErc202 .connect(user) - .transferToSchainERC20("Mainnet", await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20("Mainnet", erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(schainName, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(schainName, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Transfer is not approved by token holder"); - await erc20OnTargetChain.connect(user).approve(await tokenManagerErc202.getAddress(), amount); + await erc20OnTargetChain.connect(user).approve(tokenManagerErc202, amount); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(schainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(schainName, erc20OnOriginChain, amount); data = await messages.encodeTransferErc20Message( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount ); - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), newSchainId, await tokenManagerErc202.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerErc20, newSchainId, tokenManagerErc202, data); expect((await erc20OnOriginChain.balanceOf(user.address)).toString()).to.be.equal(amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); data = await messages.encodeTransferErc20AndTotalSupplyMessage( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount, (await erc20OnOriginChain.totalSupply()).toString() ); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data); expect((await erc20OnTargetChain.balanceOf(user.address)).toString()).to.be.equal(amount); const amount2 = "50000000000000000"; await erc20OnOriginChain.connect(deployer).mint(user.address, amount2); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount2); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount2); await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount2); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount2); data = await messages.encodeTransferErc20AndTotalSupplyMessage( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount2, (await erc20OnOriginChain.totalSupply()).toString() ); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data); const amountSum = "70000000000000000"; expect((await erc20OnTargetChain.balanceOf(user.address)).toString()).to.be.equal(amountSum); - await erc20OnTargetChain.connect(user).approve(await tokenManagerErc202.getAddress(), amount); + await erc20OnTargetChain.connect(user).approve(tokenManagerErc202, amount); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(schainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(schainName, erc20OnOriginChain, amount); data = await messages.encodeTransferErc20Message( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount ); - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), newSchainId, await tokenManagerErc202.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerErc20, newSchainId, tokenManagerErc202, data); expect((await erc20OnOriginChain.balanceOf(user.address)).toString()).to.be.equal(amount); - await erc20OnTargetChain.connect(user).approve(await tokenManagerErc202.getAddress(), amount2); + await erc20OnTargetChain.connect(user).approve(tokenManagerErc202, amount2); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(schainName, await erc20OnOriginChain.getAddress(), amount2); + .transferToSchainERC20(schainName, erc20OnOriginChain, amount2); data = await messages.encodeTransferErc20Message( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount2 ); - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), newSchainId, await tokenManagerErc202.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerErc20, newSchainId, tokenManagerErc202, data); expect((await erc20OnOriginChain.balanceOf(user.address)).toString()).to.be.equal(amountSum); @@ -1192,24 +1188,24 @@ describe("TokenManagerERC20", () => { it("should not be able to transfer X->Y->Z", async () => { const amount = "20000000000000000"; - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerErc20.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerErc20); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc20OnOriginChain.connect(deployer).mint(user.address, amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); - await tokenManagerErc20.addTokenManager(newSchainName, await tokenManagerErc202.getAddress()); + await tokenManagerErc20.addTokenManager(newSchainName, tokenManagerErc202); // execution: await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); const data = await messages.encodeTransferErc20AndTokenInfoMessage( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount, (await erc20OnOriginChain.totalSupply()).toString(), @@ -1227,13 +1223,13 @@ describe("TokenManagerERC20", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerErc202.addTokenManager(schainName, await tokenManagerErc20.getAddress()); + await tokenManagerErc202.addTokenManager(schainName, tokenManagerErc20); await tokenManagerErc202.connect(deployer).grantRole(await tokenManagerErc202.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerErc202.connect(schainOwner).addERC20TokenByOwner(schainName, await erc20OnOriginChain.getAddress(), await erc20OnTargetChain.getAddress()); - await messageProxyForSchain2.registerExtraContractForAll(await tokenManagerErc202.getAddress()); + await tokenManagerErc202.connect(schainOwner).addERC20TokenByOwner(schainName, erc20OnOriginChain, erc20OnTargetChain); + await messageProxyForSchain2.registerExtraContractForAll(tokenManagerErc202); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data); expect((await erc20OnTargetChain.balanceOf(user.address)).toString()).to.be.equal(amount); @@ -1242,52 +1238,52 @@ describe("TokenManagerERC20", () => { const erc20OnTargetZChain = await deployERC20OnChain("NewTokenZ", "NTNZ"); const keyStorageZ = await deployKeyStorageMock(); - const messageProxyForSchainZ = await deployMessageProxyForSchainTester(await keyStorageZ.getAddress(), newSchainNameZ); + const messageProxyForSchainZ = await deployMessageProxyForSchainTester(keyStorageZ, newSchainNameZ); const tokenManagerLinkerZ = await deployTokenManagerLinker(messageProxyForSchainZ, deployer.address); - const communityLockerZ = await deployCommunityLocker(newSchainName, await messageProxyForSchainZ.getAddress(), tokenManagerLinkerZ, fakeCommunityPool); - const tokenManagerErc20Z = await deployTokenManagerERC20(newSchainNameZ, await messageProxyForSchainZ.getAddress(), tokenManagerLinkerZ, communityLockerZ, fakeDepositBox); + const communityLockerZ = await deployCommunityLocker(newSchainName, messageProxyForSchainZ, tokenManagerLinkerZ, fakeCommunityPool); + const tokenManagerErc20Z = await deployTokenManagerERC20(newSchainNameZ, messageProxyForSchainZ, tokenManagerLinkerZ, communityLockerZ, fakeDepositBox); await erc20OnTargetZChain.connect(deployer).grantRole(await erc20OnTargetZChain.MINTER_ROLE(), await tokenManagerErc20Z.getAddress()); await tokenManagerLinkerZ.registerTokenManager(await tokenManagerErc20Z.getAddress()); await messageProxyForSchain2.connect(deployer).grantRole(await messageProxyForSchain2.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain2.connect(deployer).addConnectedChain(newSchainNameZ); - await tokenManagerErc202.addTokenManager(newSchainNameZ, await tokenManagerErc20Z.getAddress()); + await tokenManagerErc202.addTokenManager(newSchainNameZ, tokenManagerErc20Z); - await erc20OnTargetChain.connect(user).approve(await tokenManagerErc202.getAddress(), amount); + await erc20OnTargetChain.connect(user).approve(tokenManagerErc202, amount); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(newSchainNameZ, await erc20OnOriginChain.getAddress(), amount) + .transferToSchainERC20(newSchainNameZ, erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Insufficient funds"); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(newSchainNameZ, await erc20OnTargetChain.getAddress(), amount) + .transferToSchainERC20(newSchainNameZ, erc20OnTargetChain, amount) .should.be.eventually.rejectedWith("Incorrect main chain token"); }); it("should not be able to transfer main chain token or clone to mainnet", async () => { const amount = "20000000000000000"; - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerErc20.getAddress()); - await messageProxyForSchain2.registerExtraContractForAll(await tokenManagerErc202.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerErc20); + await messageProxyForSchain2.registerExtraContractForAll(tokenManagerErc202); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc20OnOriginChain.connect(deployer).mint(user.address, amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); - await tokenManagerErc20.addTokenManager(newSchainName, await tokenManagerErc202.getAddress()); + await tokenManagerErc20.addTokenManager(newSchainName, tokenManagerErc202); // execution: await tokenManagerErc20 .connect(user) - .transferToSchainERC20(newSchainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(newSchainName, erc20OnOriginChain, amount); let data = await messages.encodeTransferErc20AndTokenInfoMessage( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount, (await erc20OnOriginChain.totalSupply()).toString(), @@ -1305,55 +1301,55 @@ describe("TokenManagerERC20", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerErc202.addTokenManager(schainName, await tokenManagerErc20.getAddress()); + await tokenManagerErc202.addTokenManager(schainName, tokenManagerErc20); await tokenManagerErc202.connect(deployer).grantRole(await tokenManagerErc202.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerErc202.connect(schainOwner).addERC20TokenByOwner(schainName, await erc20OnOriginChain.getAddress(), await erc20OnTargetChain.getAddress()); + await tokenManagerErc202.connect(schainOwner).addERC20TokenByOwner(schainName, erc20OnOriginChain, erc20OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerErc202.getAddress(), schainId, await tokenManagerErc20.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerErc202, schainId, tokenManagerErc20, data); expect((await erc20OnTargetChain.balanceOf(user.address)).toString()).to.be.equal(amount); data = await messages.encodeActivateUserMessage(user.address); - await messageProxyForSchain2.postMessage(await communityLocker2.getAddress(), mainnetId, fakeCommunityPool, data); + await messageProxyForSchain2.postMessage(communityLocker2, mainnetId, fakeCommunityPool, data); - await erc20OnTargetChain.connect(user).approve(await tokenManagerErc202.getAddress(), amount); + await erc20OnTargetChain.connect(user).approve(tokenManagerErc202, amount); await tokenManagerErc202 .connect(user) - .exitToMainERC20(await erc20OnOriginChain.getAddress(), amount) + .exitToMainERC20(erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Insufficient funds"); await tokenManagerErc202 .connect(user) - .exitToMainERC20(await erc20OnTargetChain.getAddress(), amount) + .exitToMainERC20(erc20OnTargetChain, amount) .should.be.eventually.rejectedWith("Incorrect main chain token"); await tokenManagerErc202 .connect(user) - .transferToSchainERC20(schainName, await erc20OnOriginChain.getAddress(), amount); + .transferToSchainERC20(schainName, erc20OnOriginChain, amount); data = await messages.encodeTransferErc20Message( - await erc20OnOriginChain.getAddress(), + erc20OnOriginChain, user.address, amount ); - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), newSchainId, await tokenManagerErc202.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerErc20, newSchainId, tokenManagerErc202, data); expect((await erc20OnOriginChain.balanceOf(user.address)).toString()).to.be.equal(amount); - await erc20OnOriginChain.connect(user).approve(await tokenManagerErc20.getAddress(), amount); + await erc20OnOriginChain.connect(user).approve(tokenManagerErc20, amount); await tokenManagerErc20 .connect(user) - .exitToMainERC20(await erc20OnOriginChain.getAddress(), amount) + .exitToMainERC20(erc20OnOriginChain, amount) .should.be.eventually.rejectedWith("Main chain token could not be transfered to Mainnet"); await tokenManagerErc20 .connect(user) - .exitToMainERC20(await erc20OnTargetChain.getAddress(), amount) + .exitToMainERC20(erc20OnTargetChain, amount) .should.be.eventually.rejectedWith("Insufficient funds"); }); @@ -1362,7 +1358,7 @@ describe("TokenManagerERC20", () => { describe("tests for `postMessage` function", async () => { beforeEach(async () => { - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerErc20.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerErc20); }); it("should transfer ERC20 token with token info", async () => { @@ -1373,11 +1369,11 @@ describe("TokenManagerERC20", () => { const fromSchainName = "fromSchainName"; const fromSchainHash = ethers.id(fromSchainName); await tokenManagerErc20.addTokenManager(fromSchainName, remoteTokenManagerAddress); - // await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, await erc20OnMainnet.getAddress(), await erc20OnChain.getAddress()); + // await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, erc20OnMainnet, erc20OnChain); await erc20OnMainnet.mint(deployer.address, amount); const data = await messages.encodeTransferErc20AndTokenInfoMessage( - await erc20OnMainnet.getAddress(), + erc20OnMainnet, to, amount, await erc20OnMainnet.totalSupply(), @@ -1390,9 +1386,9 @@ describe("TokenManagerERC20", () => { await tokenManagerErc20.connect(schainOwner).enableAutomaticDeploy(); // execution - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), fromSchainHash, remoteTokenManagerAddress, data); + await messageProxyForSchain.postMessage(tokenManagerErc20, fromSchainHash, remoteTokenManagerAddress, data); // expectation - const addressERC20OnSchain = await tokenManagerErc20.clonesErc20(fromSchainHash, await erc20OnMainnet.getAddress()); + const addressERC20OnSchain = await tokenManagerErc20.clonesErc20(fromSchainHash, erc20OnMainnet); const targetErc20OnChain = (await ethers.getContractFactory("ERC20OnChain")).attach(addressERC20OnSchain) as ERC20OnChain; expect(parseInt((await targetErc20OnChain.balanceOf(to)).toString(), 10)) .to.be.equal(amount); @@ -1405,13 +1401,13 @@ describe("TokenManagerERC20", () => { const fromSchainHash = ethers.id(fromSchainName); await messageProxyForSchain.connect(deployer).addConnectedChain(fromSchainName); await tokenManagerErc20.addTokenManager(fromSchainName, remoteTokenManagerAddress); - await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(fromSchainName, await erc20OnMainnet.getAddress(), await erc20OnChain.getAddress()); + await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(fromSchainName, erc20OnMainnet, erc20OnChain); const amount = 10; const to = user.address; await erc20OnMainnet.mint(deployer.address, amount); const data = await messages.encodeTransferErc20AndTotalSupplyMessage( - await erc20OnMainnet.getAddress(), + erc20OnMainnet, to, amount, await erc20OnMainnet.totalSupply() @@ -1419,9 +1415,9 @@ describe("TokenManagerERC20", () => { await tokenManagerErc20.connect(schainOwner).enableAutomaticDeploy(); // execution - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), fromSchainHash, remoteTokenManagerAddress, data); + await messageProxyForSchain.postMessage(tokenManagerErc20, fromSchainHash, remoteTokenManagerAddress, data); // expectation - const addressERC20OnSchain = await tokenManagerErc20.clonesErc20(fromSchainHash, await erc20OnMainnet.getAddress()); + const addressERC20OnSchain = await tokenManagerErc20.clonesErc20(fromSchainHash, erc20OnMainnet); const targetErc20OnChain = (await ethers.getContractFactory("ERC20OnChain")).attach(addressERC20OnSchain) as ERC20OnChain; expect(parseInt((await targetErc20OnChain.balanceOf(to)).toString(), 10)) .to.be.equal(amount); @@ -1438,7 +1434,7 @@ describe("TokenManagerERC20", () => { const to = user.address; await erc20OnMainnet.mint(deployer.address, amount); const data = await messages.encodeTransferErc20AndTokenInfoMessage( - await erc20OnMainnet.getAddress(), + erc20OnMainnet, to, amount, await erc20OnMainnet.totalSupply(), @@ -1449,16 +1445,16 @@ describe("TokenManagerERC20", () => { } ); - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), fromSchainHash, remoteTokenManagerAddress, data) + await messageProxyForSchain.postMessage(tokenManagerErc20, fromSchainHash, remoteTokenManagerAddress, data) .should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerErc20.connect(schainOwner).enableAutomaticDeploy(); // execution - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), fromSchainHash, remoteTokenManagerAddress, data); + await messageProxyForSchain.postMessage(tokenManagerErc20, fromSchainHash, remoteTokenManagerAddress, data); // expectation - const addressERC20OnSchain = await tokenManagerErc20.clonesErc20(fromSchainHash, await erc20OnMainnet.getAddress()); + const addressERC20OnSchain = await tokenManagerErc20.clonesErc20(fromSchainHash, erc20OnMainnet); const targetErc20OnChain = (await ethers.getContractFactory("ERC20OnChain")).attach(addressERC20OnSchain) as ERC20OnChain; expect(parseInt((await targetErc20OnChain.balanceOf(to)).toString(), 10)) .to.be.equal(amount); @@ -1469,7 +1465,7 @@ describe("TokenManagerERC20", () => { "000000000000000000000000a51c1fc2f0d1a1b8494ed1fe312d7c3a78ed91c0"+ "00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8"+ "0000000000000000000000000000000000000000000000000000000000000001"; - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), mainnetId, fakeDepositBox, data) + await messageProxyForSchain.postMessage(tokenManagerErc20, mainnetId, fakeDepositBox, data) .should.be.eventually.rejectedWith("MessageType is unknown"); }); @@ -1482,11 +1478,11 @@ describe("TokenManagerERC20", () => { const fromSchainName = "fromSchainName"; const fromSchainHash = ethers.id(fromSchainName); await tokenManagerErc20.addTokenManager(fromSchainName, remoteTokenManagerAddress); - await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, await erc20OnMainnet.getAddress(), await erc20OnChain.getAddress()); + await tokenManagerErc20.connect(schainOwner).addERC20TokenByOwner(mainnetName, erc20OnMainnet, erc20OnChain); await erc20OnMainnet.mint(deployer.address, amount); let data = await messages.encodeTransferErc20AndTokenInfoMessage( - await erc20OnMainnet.getAddress(), + erc20OnMainnet, to, amount, await erc20OnMainnet.totalSupply(), @@ -1497,18 +1493,18 @@ describe("TokenManagerERC20", () => { } ); await tokenManagerErc20.connect(schainOwner).enableAutomaticDeploy(); - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), fromSchainHash, remoteTokenManagerAddress, data); + await messageProxyForSchain.postMessage(tokenManagerErc20, fromSchainHash, remoteTokenManagerAddress, data); // execution const UINT256_MAX = BigInt(2 ^ 256 - 1); data = await messages.encodeTransferErc20AndTotalSupplyMessage( - await erc20OnMainnet.getAddress(), + erc20OnMainnet, to, UINT256_MAX, 0); - await messageProxyForSchain.postMessage(await tokenManagerErc20.getAddress(), mainnetId, fakeDepositBox, data) + await messageProxyForSchain.postMessage(tokenManagerErc20, mainnetId, fakeDepositBox, data) .should.be.eventually.rejectedWith("Total supply exceeded"); }); @@ -1521,15 +1517,15 @@ describe("TokenManagerERC20", () => { await tokenManagerErc20.addTokenManager(sourceSchainName, remoteTokenManager.address); const etherbase = await (await ethers.getContractFactory("EtherbaseMock")).deploy() as EtherbaseMock; await etherbase.initialize(deployer.address); - await etherbase.grantRole(await etherbase.ETHER_MANAGER_ROLE(), await messageProxyForSchain.getAddress()); - await messageProxyForSchain.setEtherbase(await etherbase.getAddress()); - await deployer.sendTransaction({to: await etherbase.getAddress(), value: ethers.parseEther("3")}); + await etherbase.grantRole(await etherbase.ETHER_MANAGER_ROLE(), messageProxyForSchain); + await messageProxyForSchain.setEtherbase(etherbase); + await deployer.sendTransaction({to: etherbase, value: ethers.parseEther("3")}); let receiverBalance = await ethers.provider.getBalance(receiver.address); (receiverBalance).should.be.equal(0); const data = await messages.encodeTransferErc20AndTokenInfoMessage( - await erc20OnMainnet.getAddress(), + erc20OnMainnet, receiver.address, amount, 2 * amount, @@ -1541,7 +1537,7 @@ describe("TokenManagerERC20", () => { ); await tokenManagerErc20.connect(schainOwner).enableAutomaticDeploy(); await messageProxyForSchain.postMessage( - await tokenManagerErc20.getAddress(), + tokenManagerErc20, sourceSchainHash, remoteTokenManager.address, data); @@ -1553,7 +1549,7 @@ describe("TokenManagerERC20", () => { .withArgs(0, ethers.parseEther("2")); await messageProxyForSchain.postMessage( - await tokenManagerErc20.getAddress(), + tokenManagerErc20, sourceSchainHash, remoteTokenManager.address, data); diff --git a/test/TokenManagerERC721.ts b/test/TokenManagerERC721.ts index d09352c0d..f408f4d80 100644 --- a/test/TokenManagerERC721.ts +++ b/test/TokenManagerERC721.ts @@ -81,25 +81,25 @@ describe("TokenManagerERC721", () => { beforeEach(async () => { const keyStorage = await deployKeyStorageMock(); - messageProxyForSchain = await deployMessageProxyForSchainTester(await keyStorage.getAddress(), schainName); + messageProxyForSchain = await deployMessageProxyForSchainTester(keyStorage, schainName); tokenManagerLinker = await deployTokenManagerLinker(messageProxyForSchain, deployer.address); messages = await deployMessages(); - fakeDepositBox = await messages.getAddress(); - fakeCommunityPool = await messages.getAddress(); + fakeDepositBox = user.address; + fakeCommunityPool = user.address; - communityLocker = await deployCommunityLocker(schainName, await messageProxyForSchain.getAddress(), tokenManagerLinker, fakeCommunityPool); + communityLocker = await deployCommunityLocker(schainName, messageProxyForSchain, tokenManagerLinker, fakeCommunityPool); tokenManagerERC721 = await deployTokenManagerERC721( schainName, - await messageProxyForSchain.getAddress(), + messageProxyForSchain, tokenManagerLinker, communityLocker, fakeDepositBox ); await tokenManagerERC721.connect(deployer).grantRole(await tokenManagerERC721.TOKEN_REGISTRAR_ROLE(), schainOwner.address); await tokenManagerERC721.connect(deployer).grantRole(await tokenManagerERC721.AUTOMATIC_DEPLOY_ROLE(), schainOwner.address); - await tokenManagerLinker.registerTokenManager(await tokenManagerERC721.getAddress()); + await tokenManagerLinker.registerTokenManager(tokenManagerERC721); tokenClone = await deployERC721OnChain("ELVIS", "ELV"); token = await deployERC721OnChain("SKALE", "SKL"); @@ -109,7 +109,7 @@ describe("TokenManagerERC721", () => { to = user.address; const data = await messages.encodeActivateUserMessage(user.address); - await messageProxyForSchain.postMessage(await communityLocker.getAddress(), mainnetId, fakeCommunityPool, data); + await messageProxyForSchain.postMessage(communityLocker, mainnetId, fakeCommunityPool, data); const extraContractRegistrarRole = await messageProxyForSchain.EXTRA_CONTRACT_REGISTRAR_ROLE(); await messageProxyForSchain.connect(deployer).grantRole(extraContractRegistrarRole, deployer.address); @@ -120,7 +120,7 @@ describe("TokenManagerERC721", () => { it("should change depositBox address", async () => { const newDepositBox = user.address; - expect(await tokenManagerERC721.depositBox()).to.equal(await messages.getAddress()); + expect(await tokenManagerERC721.depositBox()).to.equal(fakeDepositBox); await tokenManagerERC721.connect(user).changeDepositBoxAddress(newDepositBox) .should.be.eventually.rejectedWith("DEFAULT_ADMIN_ROLE is required"); await tokenManagerERC721.connect(deployer).changeDepositBoxAddress(newDepositBox); @@ -129,29 +129,29 @@ describe("TokenManagerERC721", () => { it("should successfully call exitToMainERC721", async () => { // should be "No token clone on schain" if chains were different - await tokenManagerERC721.connect(user).exitToMainERC721(await token.getAddress(), tokenId) + await tokenManagerERC721.connect(user).exitToMainERC721(token, tokenId) .should.be.eventually.rejectedWith("ERC721: invalid token ID"); - await tokenManagerERC721.connect(schainOwner).addERC721TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()); - await tokenManagerERC721.connect(user).exitToMainERC721(await token.getAddress(), tokenId) + await tokenManagerERC721.connect(schainOwner).addERC721TokenByOwner(mainnetName, token, tokenClone); + await tokenManagerERC721.connect(user).exitToMainERC721(token, tokenId) .should.be.eventually.rejectedWith("ERC721: invalid token ID"); await tokenClone.connect(deployer).mint(user.address, tokenId); - await tokenManagerERC721.connect(user).exitToMainERC721(await token.getAddress(), tokenId) + await tokenManagerERC721.connect(user).exitToMainERC721(token, tokenId) .should.be.eventually.rejectedWith("Not allowed ERC721 Token"); - await tokenClone.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); - await tokenManagerERC721.connect(user).exitToMainERC721(await token.getAddress(), tokenId) + await tokenClone.connect(user).approve(tokenManagerERC721, tokenId); + await tokenManagerERC721.connect(user).exitToMainERC721(token, tokenId) .should.be.eventually.rejectedWith("Sender contract is not registered"); - await messageProxyForSchain.registerExtraContract("Mainnet", await tokenManagerERC721.getAddress()); - await tokenManagerERC721.connect(user).exitToMainERC721(await token.getAddress(), tokenId); + await messageProxyForSchain.registerExtraContract("Mainnet", tokenManagerERC721); + await tokenManagerERC721.connect(user).exitToMainERC721(token, tokenId); - await messageProxyForSchain.removeExtraContract("Mainnet", await tokenManagerERC721.getAddress()); + await messageProxyForSchain.removeExtraContract("Mainnet", tokenManagerERC721); await tokenClone.connect(deployer).mint(user.address, tokenId); - await tokenClone.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); + await tokenClone.connect(user).approve(tokenManagerERC721, tokenId); - await tokenManagerERC721.connect(user).exitToMainERC721(await token.getAddress(), tokenId) + await tokenManagerERC721.connect(user).exitToMainERC721(token, tokenId) .should.be.eventually.rejectedWith("Sender contract is not registered"); const outgoingMessagesCounterMainnet = await messageProxyForSchain.getOutgoingMessagesCounter("Mainnet"); @@ -159,18 +159,18 @@ describe("TokenManagerERC721", () => { }); it("should be rejected when call exitToMainERC721 if remove contract for all chains", async () => { - await tokenManagerERC721.connect(schainOwner).addERC721TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()); + await tokenManagerERC721.connect(schainOwner).addERC721TokenByOwner(mainnetName, token, tokenClone); await tokenClone.connect(deployer).mint(user.address, tokenId); - await tokenClone.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerERC721.getAddress()); + await tokenClone.connect(user).approve(tokenManagerERC721, tokenId); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC721); - await tokenManagerERC721.connect(user).exitToMainERC721(await token.getAddress(), tokenId); + await tokenManagerERC721.connect(user).exitToMainERC721(token, tokenId); - await messageProxyForSchain.removeExtraContractForAll(await tokenManagerERC721.getAddress()); + await messageProxyForSchain.removeExtraContractForAll(tokenManagerERC721); await tokenClone.connect(deployer).mint(user.address, tokenId); - await tokenClone.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); + await tokenClone.connect(user).approve(tokenManagerERC721, tokenId); - await tokenManagerERC721.connect(user).exitToMainERC721(await token.getAddress(), tokenId) + await tokenManagerERC721.connect(user).exitToMainERC721(token, tokenId) .should.be.eventually.rejectedWith("Sender contract is not registered"); const outgoingMessagesCounterMainnet = await messageProxyForSchain.getOutgoingMessagesCounter("Mainnet"); @@ -178,18 +178,18 @@ describe("TokenManagerERC721", () => { }); it("should successfully call addERC721TokenByOwner", async () => { - await tokenManagerERC721.connect(user).addERC721TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()) + await tokenManagerERC721.connect(user).addERC721TokenByOwner(mainnetName, token, tokenClone) .should.be.eventually.rejectedWith("TOKEN_REGISTRAR_ROLE is required"); - await tokenManagerERC721.connect(schainOwner).addERC721TokenByOwner(mainnetName, await token.getAddress(), deployer.address) + await tokenManagerERC721.connect(schainOwner).addERC721TokenByOwner(mainnetName, token, deployer.address) .should.be.eventually.rejectedWith("Given address is not a contract"); - await tokenManagerERC721.connect(schainOwner).addERC721TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()); + await tokenManagerERC721.connect(schainOwner).addERC721TokenByOwner(mainnetName, token, tokenClone); - await tokenManagerERC721.connect(schainOwner).addERC721TokenByOwner(mainnetName, await token2.getAddress(), await tokenClone.getAddress()) + await tokenManagerERC721.connect(schainOwner).addERC721TokenByOwner(mainnetName, token2, tokenClone) .should.be.eventually.rejectedWith("Clone was already added"); - await tokenManagerERC721.connect(schainOwner).addERC721TokenByOwner(mainnetName, await token.getAddress(), await tokenClone2.getAddress()) + await tokenManagerERC721.connect(schainOwner).addERC721TokenByOwner(mainnetName, token, tokenClone2) .should.be.eventually.rejectedWith("Could not relink clone"); }); @@ -209,41 +209,41 @@ describe("TokenManagerERC721", () => { erc721OnTargetChain = await deployERC721OnChain("NewToke1n", "NTN1"); const keyStorage2 = await deployKeyStorageMock(); - messageProxyForSchain2 = await deployMessageProxyForSchainTester(await keyStorage2.getAddress(), newSchainName); + messageProxyForSchain2 = await deployMessageProxyForSchainTester(keyStorage2, newSchainName); tokenManagerLinker2 = await deployTokenManagerLinker(messageProxyForSchain2, deployer.address); - communityLocker2 = await deployCommunityLocker(newSchainName, await messageProxyForSchain2.getAddress(), tokenManagerLinker2, fakeCommunityPool); - tokenManagerERC7212 = await deployTokenManagerERC721(newSchainName, await messageProxyForSchain2.getAddress(), tokenManagerLinker2, communityLocker2, fakeDepositBox); + communityLocker2 = await deployCommunityLocker(newSchainName, messageProxyForSchain2, tokenManagerLinker2, fakeCommunityPool); + tokenManagerERC7212 = await deployTokenManagerERC721(newSchainName, messageProxyForSchain2, tokenManagerLinker2, communityLocker2, fakeDepositBox); await erc721OnTargetChain.connect(deployer).grantRole(await erc721OnTargetChain.MINTER_ROLE(), await tokenManagerERC7212.getAddress()); await tokenManagerLinker2.registerTokenManager(await tokenManagerERC7212.getAddress()); await messageProxyForSchain2.registerExtraContractForAll(await tokenManagerERC7212.getAddress()); }); it("should invoke `transferToSchainERC721` without mistakes", async () => { - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerERC721.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerERC721); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721.addTokenManager(newSchainName, await tokenManagerERC7212.getAddress()); + await tokenManagerERC721.addTokenManager(newSchainName, tokenManagerERC7212); // execution: await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); // expectation: const outgoingMessagesCounter = await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName); @@ -251,39 +251,39 @@ describe("TokenManagerERC721", () => { }); it("should reject `transferToSchainERC721` when executing earlier then allowed", async () => { - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerERC721.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerERC721); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc721OnOriginChain.connect(deployer).mint(user.address, 1); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), 1); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, 1); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 1) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 1) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), 1) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, 1) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721.addTokenManager(newSchainName, await tokenManagerERC7212.getAddress()); + await tokenManagerERC721.addTokenManager(newSchainName, tokenManagerERC7212); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 1); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 1); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(1); await erc721OnOriginChain.connect(deployer).mint(user.address, 2); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), 2); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, 2); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 2); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 2); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(2); @@ -292,11 +292,11 @@ describe("TokenManagerERC721", () => { await communityLocker.setTimeLimitPerMessage(newSchainName, 100); await erc721OnOriginChain.connect(deployer).mint(user.address, 3); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), 3); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, 3); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 3) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 3) .should.be.eventually.rejectedWith("Exceeded message rate limit"); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(2); @@ -305,7 +305,7 @@ describe("TokenManagerERC721", () => { await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 3) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 3) .should.be.eventually.rejectedWith("Exceeded message rate limit"); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(2); @@ -314,29 +314,29 @@ describe("TokenManagerERC721", () => { await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 3); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 3); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(3); await communityLocker.setTimeLimitPerMessage(newSchainName, 0); await erc721OnOriginChain.connect(deployer).mint(user.address, 4); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), 4); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, 4); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 4); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 4); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(4); await communityLocker.setTimeLimitPerMessage(newSchainName, 100); await erc721OnOriginChain.connect(deployer).mint(user.address, 5); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), 5); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, 5); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 5) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 5) .should.be.eventually.rejectedWith("Exceeded message rate limit"); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(4); @@ -345,40 +345,40 @@ describe("TokenManagerERC721", () => { await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 5); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 5); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(5); }); it("should invoke `transferToSchainERC721` and receive tokens without mistakes", async () => { - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerERC721.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerERC721); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721.addTokenManager(newSchainName, await tokenManagerERC7212.getAddress()); + await tokenManagerERC721.addTokenManager(newSchainName, tokenManagerERC7212); // execution: await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); const data = await messages.encodeTransferErc721AndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, { @@ -394,52 +394,52 @@ describe("TokenManagerERC721", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC7212.addTokenManager(schainName, await tokenManagerERC721.getAddress()); + await tokenManagerERC7212.addTokenManager(schainName, tokenManagerERC721); await messageProxyForSchain2 - .postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data) + .postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data) .should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC7212.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data); - const addressERC721OnSchain = await tokenManagerERC7212.clonesErc721(schainId, await erc721OnOriginChain.getAddress()); + const addressERC721OnSchain = await tokenManagerERC7212.clonesErc721(schainId, erc721OnOriginChain); const targetErc721OnChain = await (await ethers.getContractFactory("ERC721OnChain")).attach(addressERC721OnSchain) as ERC721OnChain; expect((await targetErc721OnChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); }); it("should invoke `transferToSchainERC721` and receive tokens without mistakes double", async () => { - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerERC721.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerERC721); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721.addTokenManager(newSchainName, await tokenManagerERC7212.getAddress()); + await tokenManagerERC721.addTokenManager(newSchainName, tokenManagerERC7212); // execution: await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); let data = await messages.encodeTransferErc721AndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, { @@ -455,35 +455,35 @@ describe("TokenManagerERC721", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC7212.addTokenManager(schainName, await tokenManagerERC721.getAddress()); + await tokenManagerERC7212.addTokenManager(schainName, tokenManagerERC721); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC7212.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data); - const addressERC721OnSchain = await tokenManagerERC7212.clonesErc721(schainId, await erc721OnOriginChain.getAddress()); + const addressERC721OnSchain = await tokenManagerERC7212.clonesErc721(schainId, erc721OnOriginChain); const targetErc721OnChain = await (await ethers.getContractFactory("ERC721OnChain")).attach(addressERC721OnSchain) as ERC721OnChain; expect((await targetErc721OnChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); const tokenId2 = 2; await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId2); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId2); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId2); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId2); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId2); data = await messages.encodeTransferErc721Message( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data); expect((await targetErc721OnChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await targetErc721OnChain.ownerOf(tokenId2)).toString()).to.be.equal(user.address); @@ -491,34 +491,34 @@ describe("TokenManagerERC721", () => { }); it("should invoke `transferToSchainERC721` and receive tokens without mistakes double with attached token", async () => { - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerERC721.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerERC721); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721.addTokenManager(newSchainName, await tokenManagerERC7212.getAddress()); + await tokenManagerERC721.addTokenManager(newSchainName, tokenManagerERC7212); // execution: await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); let data = await messages.encodeTransferErc721AndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, { @@ -536,38 +536,38 @@ describe("TokenManagerERC721", () => { await tokenManagerERC7212 .connect(schainOwner) - .addERC721TokenByOwner(schainName, await erc721OnOriginChain.getAddress(), await erc721OnTargetChain.getAddress()) + .addERC721TokenByOwner(schainName, erc721OnOriginChain, erc721OnTargetChain) .should.be.eventually.rejectedWith("TOKEN_REGISTRAR_ROLE is required"); await tokenManagerERC7212.connect(deployer).grantRole(await tokenManagerERC7212.TOKEN_REGISTRAR_ROLE(), schainOwner.address); await tokenManagerERC7212 .connect(schainOwner) - .addERC721TokenByOwner(schainName, await erc721OnOriginChain.getAddress(), await erc721OnTargetChain.getAddress()) + .addERC721TokenByOwner(schainName, erc721OnOriginChain, erc721OnTargetChain) .should.be.eventually.rejectedWith("Chain is not connected"); await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC7212.connect(schainOwner).addERC721TokenByOwner(schainName, await erc721OnOriginChain.getAddress(), await erc721OnTargetChain.getAddress()); - await tokenManagerERC7212.addTokenManager(schainName, await tokenManagerERC721.getAddress()); + await tokenManagerERC7212.connect(schainOwner).addERC721TokenByOwner(schainName, erc721OnOriginChain, erc721OnTargetChain); + await tokenManagerERC7212.addTokenManager(schainName, tokenManagerERC721); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data); expect((await erc721OnTargetChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); const tokenId2 = 2; await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId2); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId2); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId2); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId2); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId2); data = await messages.encodeTransferErc721Message( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data); expect((await erc721OnTargetChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnTargetChain.ownerOf(tokenId2)).toString()).to.be.equal(user.address); @@ -575,34 +575,34 @@ describe("TokenManagerERC721", () => { }); it("should invoke `transferToSchainERC721` and transfer back without mistakes", async () => { - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerERC721.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC721); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721.addTokenManager(newSchainName, await tokenManagerERC7212.getAddress()); + await tokenManagerERC721.addTokenManager(newSchainName, tokenManagerERC7212); // execution: await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); let data = await messages.encodeTransferErc721AndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, { @@ -618,80 +618,80 @@ describe("TokenManagerERC721", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC7212.addTokenManager(schainName, await tokenManagerERC721.getAddress()); + await tokenManagerERC7212.addTokenManager(schainName, tokenManagerERC721); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC7212.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data); - const addressERC721OnSchain = await tokenManagerERC7212.clonesErc721(schainId, await erc721OnOriginChain.getAddress()); + const addressERC721OnSchain = await tokenManagerERC7212.clonesErc721(schainId, erc721OnOriginChain); const targetErc721OnChain = await (await ethers.getContractFactory("ERC721OnChain")).attach(addressERC721OnSchain) as ERC721OnChain; expect((await targetErc721OnChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Not allowed ERC721 Token"); - await targetErc721OnChain.connect(user).approve(await tokenManagerERC7212.getAddress(), tokenId); + await targetErc721OnChain.connect(user).approve(tokenManagerERC7212, tokenId); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721Message( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId ); - await messageProxyForSchain.postMessage(await tokenManagerERC721.getAddress(), newSchainId, await tokenManagerERC7212.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721, newSchainId, tokenManagerERC7212, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); }); it("should invoke `transferToSchainERC721` and transfer back without mistakes with attached tokens", async () => { - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerERC721.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC721); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721.addTokenManager(newSchainName, await tokenManagerERC7212.getAddress()); + await tokenManagerERC721.addTokenManager(newSchainName, tokenManagerERC7212); // execution: await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); let data = await messages.encodeTransferErc721AndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, { @@ -707,76 +707,76 @@ describe("TokenManagerERC721", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC7212.addTokenManager(schainName, await tokenManagerERC721.getAddress()); + await tokenManagerERC7212.addTokenManager(schainName, tokenManagerERC721); await tokenManagerERC7212.connect(deployer).grantRole(await tokenManagerERC7212.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC7212.connect(schainOwner).addERC721TokenByOwner(schainName, await erc721OnOriginChain.getAddress(), await erc721OnTargetChain.getAddress()); + await tokenManagerERC7212.connect(schainOwner).addERC721TokenByOwner(schainName, erc721OnOriginChain, erc721OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Not allowed ERC721 Token"); - await erc721OnTargetChain.connect(user).approve(await tokenManagerERC7212.getAddress(), tokenId); + await erc721OnTargetChain.connect(user).approve(tokenManagerERC7212, tokenId); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721Message( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId ); - await messageProxyForSchain.postMessage(await tokenManagerERC721.getAddress(), newSchainId, await tokenManagerERC7212.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721, newSchainId, tokenManagerERC7212, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); }); it("should invoke `transferToSchainERC721` and transfer back without mistakes double", async () => { - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerERC721.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC721); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721.addTokenManager(newSchainName, await tokenManagerERC7212.getAddress()); + await tokenManagerERC721.addTokenManager(newSchainName, tokenManagerERC7212); // execution: await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); let data = await messages.encodeTransferErc721AndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, { @@ -792,113 +792,113 @@ describe("TokenManagerERC721", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC7212.addTokenManager(schainName, await tokenManagerERC721.getAddress()); + await tokenManagerERC7212.addTokenManager(schainName, tokenManagerERC721); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC7212.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data); - const addressERC721OnSchain = await tokenManagerERC7212.clonesErc721(schainId, await erc721OnOriginChain.getAddress()); + const addressERC721OnSchain = await tokenManagerERC7212.clonesErc721(schainId, erc721OnOriginChain); const targetErc721OnChain = (await ethers.getContractFactory("ERC721OnChain")).attach(addressERC721OnSchain) as ERC721OnChain; expect((await targetErc721OnChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Not allowed ERC721 Token"); - await targetErc721OnChain.connect(user).approve(await tokenManagerERC7212.getAddress(), tokenId); + await targetErc721OnChain.connect(user).approve(tokenManagerERC7212, tokenId); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721Message( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId ); - await messageProxyForSchain.postMessage(await tokenManagerERC721.getAddress(), newSchainId, await tokenManagerERC7212.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721, newSchainId, tokenManagerERC7212, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721Message( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId ); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data); expect((await targetErc721OnChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); const tokenId2 = 2; await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId2); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId2); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId2); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId2); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId2); data = await messages.encodeTransferErc721Message( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data); expect((await targetErc721OnChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await targetErc721OnChain.ownerOf(tokenId2)).toString()).to.be.equal(user.address); - await targetErc721OnChain.connect(user).approve(await tokenManagerERC7212.getAddress(), tokenId); + await targetErc721OnChain.connect(user).approve(tokenManagerERC7212, tokenId); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721Message( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId ); - await messageProxyForSchain.postMessage(await tokenManagerERC721.getAddress(), newSchainId, await tokenManagerERC7212.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721, newSchainId, tokenManagerERC7212, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); - await targetErc721OnChain.connect(user).approve(await tokenManagerERC7212.getAddress(), tokenId2); + await targetErc721OnChain.connect(user).approve(tokenManagerERC7212, tokenId2); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId2); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId2); data = await messages.encodeTransferErc721Message( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId2 ); - await messageProxyForSchain.postMessage(await tokenManagerERC721.getAddress(), newSchainId, await tokenManagerERC7212.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721, newSchainId, tokenManagerERC7212, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnOriginChain.ownerOf(tokenId2)).toString()).to.be.equal(user.address); @@ -906,34 +906,34 @@ describe("TokenManagerERC721", () => { }); it("should invoke `transferToSchainERC721` and transfer back without mistakes double with attached tokens", async () => { - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerERC721.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC721); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721.addTokenManager(newSchainName, await tokenManagerERC7212.getAddress()); + await tokenManagerERC721.addTokenManager(newSchainName, tokenManagerERC7212); // execution: await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); let data = await messages.encodeTransferErc721AndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, { @@ -949,132 +949,132 @@ describe("TokenManagerERC721", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC7212.addTokenManager(schainName, await tokenManagerERC721.getAddress()); + await tokenManagerERC7212.addTokenManager(schainName, tokenManagerERC721); await tokenManagerERC7212.connect(deployer).grantRole(await tokenManagerERC7212.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC7212.connect(schainOwner).addERC721TokenByOwner(schainName, await erc721OnOriginChain.getAddress(), await erc721OnTargetChain.getAddress()); + await tokenManagerERC7212.connect(schainOwner).addERC721TokenByOwner(schainName, erc721OnOriginChain, erc721OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Not allowed ERC721 Token"); - await erc721OnTargetChain.connect(user).approve(await tokenManagerERC7212.getAddress(), tokenId); + await erc721OnTargetChain.connect(user).approve(tokenManagerERC7212, tokenId); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721Message( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId ); - await messageProxyForSchain.postMessage(await tokenManagerERC721.getAddress(), newSchainId, await tokenManagerERC7212.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721, newSchainId, tokenManagerERC7212, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721Message( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId ); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data); expect((await erc721OnTargetChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); const tokenId2 = 2; await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId2); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId2); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId2); await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId2); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId2); data = await messages.encodeTransferErc721Message( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data); expect((await erc721OnTargetChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnTargetChain.ownerOf(tokenId2)).toString()).to.be.equal(user.address); - await erc721OnTargetChain.connect(user).approve(await tokenManagerERC7212.getAddress(), tokenId); + await erc721OnTargetChain.connect(user).approve(tokenManagerERC7212, tokenId); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721Message( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId ); - await messageProxyForSchain.postMessage(await tokenManagerERC721.getAddress(), newSchainId, await tokenManagerERC7212.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721, newSchainId, tokenManagerERC7212, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); - await erc721OnTargetChain.connect(user).approve(await tokenManagerERC7212.getAddress(), tokenId2); + await erc721OnTargetChain.connect(user).approve(tokenManagerERC7212, tokenId2); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId2); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId2); data = await messages.encodeTransferErc721Message( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId2 ); - await messageProxyForSchain.postMessage(await tokenManagerERC721.getAddress(), newSchainId, await tokenManagerERC7212.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721, newSchainId, tokenManagerERC7212, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnOriginChain.ownerOf(tokenId2)).toString()).to.be.equal(user.address); }); it("should not be able to transfer X->Y->Z", async () => { - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerERC721.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerERC721); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId); - await tokenManagerERC721.addTokenManager(newSchainName, await tokenManagerERC7212.getAddress()); + await tokenManagerERC721.addTokenManager(newSchainName, tokenManagerERC7212); // execution: await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); const data = await messages.encodeTransferErc721AndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, { @@ -1090,12 +1090,12 @@ describe("TokenManagerERC721", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC7212.addTokenManager(schainName, await tokenManagerERC721.getAddress()); + await tokenManagerERC7212.addTokenManager(schainName, tokenManagerERC721); await tokenManagerERC7212.connect(deployer).grantRole(await tokenManagerERC7212.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC7212.connect(schainOwner).addERC721TokenByOwner(schainName, await erc721OnOriginChain.getAddress(), await erc721OnTargetChain.getAddress()); + await tokenManagerERC7212.connect(schainOwner).addERC721TokenByOwner(schainName, erc721OnOriginChain, erc721OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data); expect((await erc721OnTargetChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); @@ -1104,50 +1104,50 @@ describe("TokenManagerERC721", () => { const erc721OnTargetZChain = await deployERC721OnChain("NewTokenZ", "NTNZ"); const keyStorageZ = await deployKeyStorageMock(); - const messageProxyForSchainZ = await deployMessageProxyForSchainTester(await keyStorageZ.getAddress(), newSchainNameZ); + const messageProxyForSchainZ = await deployMessageProxyForSchainTester(keyStorageZ, newSchainNameZ); const tokenManagerLinkerZ = await deployTokenManagerLinker(messageProxyForSchainZ, deployer.address); - const communityLockerZ = await deployCommunityLocker(newSchainName, await messageProxyForSchainZ.getAddress(), tokenManagerLinkerZ, fakeCommunityPool); - const tokenManagerERC721Z = await deployTokenManagerERC721(newSchainNameZ, await messageProxyForSchainZ.getAddress(), tokenManagerLinkerZ, communityLockerZ, fakeDepositBox); + const communityLockerZ = await deployCommunityLocker(newSchainName, messageProxyForSchainZ, tokenManagerLinkerZ, fakeCommunityPool); + const tokenManagerERC721Z = await deployTokenManagerERC721(newSchainNameZ, messageProxyForSchainZ, tokenManagerLinkerZ, communityLockerZ, fakeDepositBox); await erc721OnTargetZChain.connect(deployer).grantRole(await erc721OnTargetZChain.MINTER_ROLE(), await tokenManagerERC721Z.getAddress()); await tokenManagerLinkerZ.registerTokenManager(await tokenManagerERC721Z.getAddress()); await messageProxyForSchain2.connect(deployer).grantRole(await messageProxyForSchain2.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain2.connect(deployer).addConnectedChain(newSchainNameZ); - await tokenManagerERC7212.addTokenManager(newSchainNameZ, await tokenManagerERC721Z.getAddress()); + await tokenManagerERC7212.addTokenManager(newSchainNameZ, tokenManagerERC721Z); - await erc721OnTargetChain.connect(user).approve(await tokenManagerERC7212.getAddress(), tokenId); + await erc721OnTargetChain.connect(user).approve(tokenManagerERC7212, tokenId); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(newSchainNameZ, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainNameZ, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Not allowed ERC721 Token"); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(newSchainNameZ, await erc721OnTargetChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainNameZ, erc721OnTargetChain, tokenId) .should.be.eventually.rejectedWith("Incorrect main chain token"); }); it("should not be able to transfer main chain token or clone to mainnet", async () => { - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerERC721.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC721); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId); - await tokenManagerERC721.addTokenManager(newSchainName, await tokenManagerERC7212.getAddress()); + await tokenManagerERC721.addTokenManager(newSchainName, tokenManagerERC7212); // execution: await tokenManagerERC721 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); let data = await messages.encodeTransferErc721AndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, { @@ -1163,54 +1163,54 @@ describe("TokenManagerERC721", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC7212.addTokenManager(schainName, await tokenManagerERC721.getAddress()); + await tokenManagerERC7212.addTokenManager(schainName, tokenManagerERC721); await tokenManagerERC7212.connect(deployer).grantRole(await tokenManagerERC7212.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC7212.connect(schainOwner).addERC721TokenByOwner(schainName, await erc721OnOriginChain.getAddress(), await erc721OnTargetChain.getAddress()); + await tokenManagerERC7212.connect(schainOwner).addERC721TokenByOwner(schainName, erc721OnOriginChain, erc721OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC7212.getAddress(), schainId, await tokenManagerERC721.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC7212, schainId, tokenManagerERC721, data); expect((await erc721OnTargetChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); data = await messages.encodeActivateUserMessage(user.address); - await messageProxyForSchain2.postMessage(await communityLocker2.getAddress(), mainnetId, fakeCommunityPool, data); + await messageProxyForSchain2.postMessage(communityLocker2, mainnetId, fakeCommunityPool, data); - await erc721OnTargetChain.connect(user).approve(await tokenManagerERC7212.getAddress(), tokenId); + await erc721OnTargetChain.connect(user).approve(tokenManagerERC7212, tokenId); await tokenManagerERC7212 .connect(user) - .exitToMainERC721(await erc721OnOriginChain.getAddress(), tokenId) + .exitToMainERC721(erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Not allowed ERC721 Token"); await tokenManagerERC7212 .connect(user) - .exitToMainERC721(await erc721OnTargetChain.getAddress(), tokenId) + .exitToMainERC721(erc721OnTargetChain, tokenId) .should.be.eventually.rejectedWith("Incorrect main chain token"); await tokenManagerERC7212 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721Message( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId ); - await messageProxyForSchain.postMessage(await tokenManagerERC721.getAddress(), newSchainId, await tokenManagerERC7212.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721, newSchainId, tokenManagerERC7212, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721, tokenId); await tokenManagerERC721 .connect(user) - .exitToMainERC721(await erc721OnOriginChain.getAddress(), tokenId) + .exitToMainERC721(erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Main chain token could not be transfered to Mainnet"); await tokenManagerERC721 .connect(user) - .exitToMainERC721(await erc721OnTargetChain.getAddress(), tokenId) + .exitToMainERC721(erc721OnTargetChain, tokenId) .should.be.eventually.rejectedWith("ERC721: invalid token ID"); }); @@ -1219,13 +1219,13 @@ describe("TokenManagerERC721", () => { describe("tests for `postMessage` function", async () => { beforeEach(async () => { - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerERC721.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC721); }); it("should transfer ERC721 token token with token info", async () => { // preparation const data = await messages.encodeTransferErc721AndTokenInfoMessage( - await token.getAddress(), + token, to, tokenId, { @@ -1234,29 +1234,29 @@ describe("TokenManagerERC721", () => { } ); - await messageProxyForSchain.postMessage(await tokenManagerERC721.getAddress(), mainnetId, fakeDepositBox, data) + await messageProxyForSchain.postMessage(tokenManagerERC721, mainnetId, fakeDepositBox, data) .should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC721.connect(schainOwner).enableAutomaticDeploy(); - await messageProxyForSchain.postMessage(await tokenManagerERC721.getAddress(), mainnetId, fakeDepositBox, data); - const addressERC721OnSchain = await tokenManagerERC721.clonesErc721(mainnetId, await token.getAddress()); + await messageProxyForSchain.postMessage(tokenManagerERC721, mainnetId, fakeDepositBox, data); + const addressERC721OnSchain = await tokenManagerERC721.clonesErc721(mainnetId, token); const erc721OnChain = (await ethers.getContractFactory("ERC721OnChain")).attach(addressERC721OnSchain) as ERC721OnChain; expect((await erc721OnChain.ownerOf(tokenId))).to.be.equal(to); }); it("should transfer ERC721 token on schain", async () => { // preparation - await tokenManagerERC721.connect(schainOwner).addERC721TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()); - await tokenClone.connect(deployer).grantRole(await tokenClone.MINTER_ROLE(), await tokenManagerERC721.getAddress()); + await tokenManagerERC721.connect(schainOwner).addERC721TokenByOwner(mainnetName, token, tokenClone); + await tokenClone.connect(deployer).grantRole(await tokenClone.MINTER_ROLE(), tokenManagerERC721); const data = await messages.encodeTransferErc721Message( - await token.getAddress(), + token, to, tokenId ); - await messageProxyForSchain.postMessage(await tokenManagerERC721.getAddress(), mainnetId, fakeDepositBox, data); - const addressERC721OnSchain = await tokenManagerERC721.clonesErc721(mainnetId, await token.getAddress()); + await messageProxyForSchain.postMessage(tokenManagerERC721, mainnetId, fakeDepositBox, data); + const addressERC721OnSchain = await tokenManagerERC721.clonesErc721(mainnetId, token); const erc721OnChain = (await ethers.getContractFactory("ERC721OnChain")).attach(addressERC721OnSchain) as ERC721OnChain; expect((await erc721OnChain.ownerOf(tokenId))).to.be.equal(to); }); @@ -1266,7 +1266,7 @@ describe("TokenManagerERC721", () => { "000000000000000000000000a51c1fc2f0d1a1b8494ed1fe312d7c3a78ed91c0"+ "00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8"+ "0000000000000000000000000000000000000000000000000000000000000001"; - await messageProxyForSchain.postMessage(await tokenManagerERC721.getAddress(), mainnetId, fakeDepositBox, data) + await messageProxyForSchain.postMessage(tokenManagerERC721, mainnetId, fakeDepositBox, data) .should.be.eventually.rejectedWith("MessageType is unknown"); }); diff --git a/test/TokenManagerERC721WithMetadata.ts b/test/TokenManagerERC721WithMetadata.ts index 08610aad1..a886f8e73 100644 --- a/test/TokenManagerERC721WithMetadata.ts +++ b/test/TokenManagerERC721WithMetadata.ts @@ -83,25 +83,25 @@ describe("TokenManagerERC721WithMetadata", () => { beforeEach(async () => { const keyStorage = await deployKeyStorageMock(); - messageProxyForSchain = await deployMessageProxyForSchainTester(await keyStorage.getAddress(), schainName); + messageProxyForSchain = await deployMessageProxyForSchainTester(keyStorage, schainName); tokenManagerLinker = await deployTokenManagerLinker(messageProxyForSchain, deployer.address); messages = await deployMessages(); - fakeDepositBox = await messages.getAddress(); - fakeCommunityPool = await messages.getAddress(); + fakeDepositBox = user.address; + fakeCommunityPool = user.address; - communityLocker = await deployCommunityLocker(schainName, await messageProxyForSchain.getAddress(), tokenManagerLinker, fakeCommunityPool); + communityLocker = await deployCommunityLocker(schainName, messageProxyForSchain, tokenManagerLinker, fakeCommunityPool); tokenManagerERC721WithMetadata = await deployTokenManagerERC721WithMetadata( schainName, - await messageProxyForSchain.getAddress(), + messageProxyForSchain, tokenManagerLinker, communityLocker, fakeDepositBox ); await tokenManagerERC721WithMetadata.connect(deployer).grantRole(await tokenManagerERC721WithMetadata.TOKEN_REGISTRAR_ROLE(), schainOwner.address); await tokenManagerERC721WithMetadata.connect(deployer).grantRole(await tokenManagerERC721WithMetadata.AUTOMATIC_DEPLOY_ROLE(), schainOwner.address); - await tokenManagerLinker.registerTokenManager(await tokenManagerERC721WithMetadata.getAddress()); + await tokenManagerLinker.registerTokenManager(tokenManagerERC721WithMetadata); tokenClone = await deployERC721OnChain("ELVIS", "ELV"); token = await deployERC721OnChain("SKALE", "SKL"); @@ -111,7 +111,7 @@ describe("TokenManagerERC721WithMetadata", () => { to = user.address; const data = await messages.encodeActivateUserMessage(user.address); - await messageProxyForSchain.postMessage(await communityLocker.getAddress(), mainnetId, fakeCommunityPool, data); + await messageProxyForSchain.postMessage(communityLocker, mainnetId, fakeCommunityPool, data); const extraContractRegistrarRole = await messageProxyForSchain.EXTRA_CONTRACT_REGISTRAR_ROLE(); await messageProxyForSchain.connect(deployer).grantRole(extraContractRegistrarRole, deployer.address); @@ -122,7 +122,7 @@ describe("TokenManagerERC721WithMetadata", () => { it("should change depositBox address", async () => { const newDepositBox = user.address; - expect(await tokenManagerERC721WithMetadata.depositBox()).to.equal(await messages.getAddress()); + expect(await tokenManagerERC721WithMetadata.depositBox()).to.equal(fakeDepositBox); await tokenManagerERC721WithMetadata.connect(user).changeDepositBoxAddress(newDepositBox) .should.be.eventually.rejectedWith("DEFAULT_ADMIN_ROLE is required"); await tokenManagerERC721WithMetadata.connect(deployer).changeDepositBoxAddress(newDepositBox); @@ -131,31 +131,31 @@ describe("TokenManagerERC721WithMetadata", () => { it("should successfully call exitToMainERC721", async () => { // should be "No token clone on schain" if chains were different - await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(await token.getAddress(), tokenId) + await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(token, tokenId) .should.be.eventually.rejectedWith("ERC721: invalid token ID"); - await tokenManagerERC721WithMetadata.connect(schainOwner).addERC721TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()); - await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(await token.getAddress(), tokenId) + await tokenManagerERC721WithMetadata.connect(schainOwner).addERC721TokenByOwner(mainnetName, token, tokenClone); + await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(token, tokenId) .should.be.eventually.rejectedWith("ERC721: invalid token ID"); await tokenClone.connect(deployer).mint(user.address, tokenId); await tokenClone.connect(user).setTokenURI(tokenId, tokenURI); - await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(await token.getAddress(), tokenId) + await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(token, tokenId) .should.be.eventually.rejectedWith("Not allowed ERC721 Token"); - await tokenClone.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); - await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(await token.getAddress(), tokenId) + await tokenClone.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); + await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(token, tokenId) .should.be.eventually.rejectedWith("Sender contract is not registered"); - await messageProxyForSchain.registerExtraContract("Mainnet", await tokenManagerERC721WithMetadata.getAddress()); - await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(await token.getAddress(), tokenId); + await messageProxyForSchain.registerExtraContract("Mainnet", tokenManagerERC721WithMetadata); + await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(token, tokenId); - await messageProxyForSchain.removeExtraContract("Mainnet", await tokenManagerERC721WithMetadata.getAddress()); + await messageProxyForSchain.removeExtraContract("Mainnet", tokenManagerERC721WithMetadata); await tokenClone.connect(deployer).mint(user.address, tokenId); await tokenClone.connect(user).setTokenURI(tokenId, tokenURI); - await tokenClone.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); + await tokenClone.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); - await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(await token.getAddress(), tokenId) + await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(token, tokenId) .should.be.eventually.rejectedWith("Sender contract is not registered"); const outgoingMessagesCounterMainnet = await messageProxyForSchain.getOutgoingMessagesCounter("Mainnet"); @@ -163,20 +163,20 @@ describe("TokenManagerERC721WithMetadata", () => { }); it("should be rejected when call exitToMainERC721 if remove contract for all chains", async () => { - await tokenManagerERC721WithMetadata.connect(schainOwner).addERC721TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()); + await tokenManagerERC721WithMetadata.connect(schainOwner).addERC721TokenByOwner(mainnetName, token, tokenClone); await tokenClone.connect(deployer).mint(user.address, tokenId); await tokenClone.connect(user).setTokenURI(tokenId, tokenURI); - await tokenClone.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerERC721WithMetadata.getAddress()); + await tokenClone.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC721WithMetadata); - await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(await token.getAddress(), tokenId); + await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(token, tokenId); - await messageProxyForSchain.removeExtraContractForAll(await tokenManagerERC721WithMetadata.getAddress()); + await messageProxyForSchain.removeExtraContractForAll(tokenManagerERC721WithMetadata); await tokenClone.connect(deployer).mint(user.address, tokenId); await tokenClone.connect(user).setTokenURI(tokenId, tokenURI); - await tokenClone.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); + await tokenClone.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); - await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(await token.getAddress(), tokenId) + await tokenManagerERC721WithMetadata.connect(user).exitToMainERC721(token, tokenId) .should.be.eventually.rejectedWith("Sender contract is not registered"); const outgoingMessagesCounterMainnet = await messageProxyForSchain.getOutgoingMessagesCounter("Mainnet"); @@ -184,18 +184,18 @@ describe("TokenManagerERC721WithMetadata", () => { }); it("should successfully call addERC721TokenByOwner", async () => { - await tokenManagerERC721WithMetadata.connect(user).addERC721TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()) + await tokenManagerERC721WithMetadata.connect(user).addERC721TokenByOwner(mainnetName, token, tokenClone) .should.be.eventually.rejectedWith("TOKEN_REGISTRAR_ROLE is required"); - await tokenManagerERC721WithMetadata.connect(schainOwner).addERC721TokenByOwner(mainnetName, await token.getAddress(), deployer.address) + await tokenManagerERC721WithMetadata.connect(schainOwner).addERC721TokenByOwner(mainnetName, token, deployer.address) .should.be.eventually.rejectedWith("Given address is not a contract"); - await tokenManagerERC721WithMetadata.connect(schainOwner).addERC721TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()); + await tokenManagerERC721WithMetadata.connect(schainOwner).addERC721TokenByOwner(mainnetName, token, tokenClone); - await tokenManagerERC721WithMetadata.connect(schainOwner).addERC721TokenByOwner(mainnetName, await token2.getAddress(), await tokenClone.getAddress()) + await tokenManagerERC721WithMetadata.connect(schainOwner).addERC721TokenByOwner(mainnetName, token2, tokenClone) .should.be.eventually.rejectedWith("Clone was already added"); - await tokenManagerERC721WithMetadata.connect(schainOwner).addERC721TokenByOwner(mainnetName, await token.getAddress(), await tokenClone2.getAddress()) + await tokenManagerERC721WithMetadata.connect(schainOwner).addERC721TokenByOwner(mainnetName, token, tokenClone2) .should.be.eventually.rejectedWith("Could not relink clone"); }); @@ -215,23 +215,23 @@ describe("TokenManagerERC721WithMetadata", () => { erc721OnTargetChain = await deployERC721OnChain("NewToke1n", "NTN1"); const keyStorage2 = await deployKeyStorageMock(); - messageProxyForSchain2 = await deployMessageProxyForSchainTester(await keyStorage2.getAddress(), newSchainName); + messageProxyForSchain2 = await deployMessageProxyForSchainTester(keyStorage2, newSchainName); tokenManagerLinker2 = await deployTokenManagerLinker(messageProxyForSchain2, deployer.address); - communityLocker2 = await deployCommunityLocker(newSchainName, await messageProxyForSchain2.getAddress(), tokenManagerLinker2, fakeCommunityPool); + communityLocker2 = await deployCommunityLocker(newSchainName, messageProxyForSchain2, tokenManagerLinker2, fakeCommunityPool); tokenManagerERC721WithMetadata2 = await deployTokenManagerERC721WithMetadata( newSchainName, - await messageProxyForSchain2.getAddress(), + messageProxyForSchain2, tokenManagerLinker2, communityLocker2, fakeDepositBox ); - await erc721OnTargetChain.connect(deployer).grantRole(await erc721OnTargetChain.MINTER_ROLE(), await tokenManagerERC721WithMetadata2.getAddress()); - await tokenManagerLinker2.registerTokenManager(await tokenManagerERC721WithMetadata2.getAddress()); - await messageProxyForSchain2.registerExtraContractForAll(await tokenManagerERC721WithMetadata2.getAddress()); + await erc721OnTargetChain.connect(deployer).grantRole(await erc721OnTargetChain.MINTER_ROLE(), tokenManagerERC721WithMetadata2); + await tokenManagerLinker2.registerTokenManager(tokenManagerERC721WithMetadata2); + await messageProxyForSchain2.registerExtraContractForAll(tokenManagerERC721WithMetadata2); }); it("should invoke `transferToSchainERC721` without mistakes", async () => { - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerERC721WithMetadata.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerERC721WithMetadata); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); @@ -239,24 +239,24 @@ describe("TokenManagerERC721WithMetadata", () => { await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); await erc721OnOriginChain.connect(user).setTokenURI(tokenId, tokenURI); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, await tokenManagerERC721WithMetadata2.getAddress()); + await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, tokenManagerERC721WithMetadata2); // execution: await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); // expectation: const outgoingMessagesCounter = await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName); @@ -264,39 +264,39 @@ describe("TokenManagerERC721WithMetadata", () => { }); it("should reject `transferToSchainERC721` when executing earlier then allowed", async () => { - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerERC721WithMetadata.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerERC721WithMetadata); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain.connect(deployer).addConnectedChain(newSchainName); await erc721OnOriginChain.connect(deployer).mint(user.address, 1); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), 1); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, 1); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 1) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 1) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), 1) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, 1) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, await tokenManagerERC721WithMetadata2.getAddress()); + await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, tokenManagerERC721WithMetadata2); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 1); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 1); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(1); await erc721OnOriginChain.connect(deployer).mint(user.address, 2); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), 2); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, 2); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 2); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 2); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(2); @@ -305,11 +305,11 @@ describe("TokenManagerERC721WithMetadata", () => { await communityLocker.setTimeLimitPerMessage(newSchainName, 100); await erc721OnOriginChain.connect(deployer).mint(user.address, 3); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), 3); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, 3); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 3) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 3) .should.be.eventually.rejectedWith("Exceeded message rate limit"); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(2); @@ -318,7 +318,7 @@ describe("TokenManagerERC721WithMetadata", () => { await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 3) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 3) .should.be.eventually.rejectedWith("Exceeded message rate limit"); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(2); @@ -327,29 +327,29 @@ describe("TokenManagerERC721WithMetadata", () => { await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 3); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 3); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(3); await communityLocker.setTimeLimitPerMessage(newSchainName, 0); await erc721OnOriginChain.connect(deployer).mint(user.address, 4); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), 4); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, 4); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 4); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 4); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(4); await communityLocker.setTimeLimitPerMessage(newSchainName, 100); await erc721OnOriginChain.connect(deployer).mint(user.address, 5); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), 5); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, 5); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 5) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 5) .should.be.eventually.rejectedWith("Exceeded message rate limit"); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(4); @@ -358,13 +358,13 @@ describe("TokenManagerERC721WithMetadata", () => { await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), 5); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, 5); (await messageProxyForSchain.getOutgoingMessagesCounter(newSchainName)).should.be.equal(5); }); it("should invoke `transferToSchainERC721` and receive tokens without mistakes", async () => { - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerERC721WithMetadata.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerERC721WithMetadata); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); @@ -372,27 +372,27 @@ describe("TokenManagerERC721WithMetadata", () => { await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); await erc721OnOriginChain.connect(user).setTokenURI(tokenId, tokenURI); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, await tokenManagerERC721WithMetadata2.getAddress()); + await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, tokenManagerERC721WithMetadata2); // execution: await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); const data = await messages.encodeTransferErc721WithMetadataAndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI, @@ -409,16 +409,16 @@ describe("TokenManagerERC721WithMetadata", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC721WithMetadata2.addTokenManager(schainName, await tokenManagerERC721WithMetadata.getAddress()); + await tokenManagerERC721WithMetadata2.addTokenManager(schainName, tokenManagerERC721WithMetadata); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC721WithMetadata2.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data); - const addressERC721OnSchain = await tokenManagerERC721WithMetadata2.clonesErc721(schainId, await erc721OnOriginChain.getAddress()); + const addressERC721OnSchain = await tokenManagerERC721WithMetadata2.clonesErc721(schainId, erc721OnOriginChain); const targetErc721OnChain = await (await ethers.getContractFactory("ERC721OnChain")).attach(addressERC721OnSchain) as ERC721OnChain; expect((await targetErc721OnChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await targetErc721OnChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); @@ -426,7 +426,7 @@ describe("TokenManagerERC721WithMetadata", () => { }); it("should invoke `transferToSchainERC721` and receive tokens without mistakes double", async () => { - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerERC721WithMetadata.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerERC721WithMetadata); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); @@ -434,27 +434,27 @@ describe("TokenManagerERC721WithMetadata", () => { await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); await erc721OnOriginChain.connect(user).setTokenURI(tokenId, tokenURI); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, await tokenManagerERC721WithMetadata2.getAddress()); + await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, tokenManagerERC721WithMetadata2); // execution: await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); let data = await messages.encodeTransferErc721WithMetadataAndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI, @@ -471,16 +471,16 @@ describe("TokenManagerERC721WithMetadata", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC721WithMetadata2.addTokenManager(schainName, await tokenManagerERC721WithMetadata.getAddress()); + await tokenManagerERC721WithMetadata2.addTokenManager(schainName, tokenManagerERC721WithMetadata); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC721WithMetadata2.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data); - const addressERC721OnSchain = await tokenManagerERC721WithMetadata2.clonesErc721(schainId, await erc721OnOriginChain.getAddress()); + const addressERC721OnSchain = await tokenManagerERC721WithMetadata2.clonesErc721(schainId, erc721OnOriginChain); const targetErc721OnChain = (await ethers.getContractFactory("ERC721OnChain")).attach(addressERC721OnSchain) as ERC721OnChain; expect((await targetErc721OnChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await targetErc721OnChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); @@ -490,20 +490,20 @@ describe("TokenManagerERC721WithMetadata", () => { await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId2); await erc721OnOriginChain.connect(user).setTokenURI(tokenId2, tokenURI2); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId2); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId2); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId2); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId2); data = await messages.encodeTransferErc721MessageWithMetadata( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId2, tokenURI2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data); expect((await targetErc721OnChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await targetErc721OnChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); @@ -513,7 +513,7 @@ describe("TokenManagerERC721WithMetadata", () => { }); it("should invoke `transferToSchainERC721` and receive tokens without mistakes double with attached token", async () => { - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerERC721WithMetadata.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerERC721WithMetadata); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); @@ -521,27 +521,27 @@ describe("TokenManagerERC721WithMetadata", () => { await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); await erc721OnOriginChain.connect(user).setTokenURI(tokenId, tokenURI); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, await tokenManagerERC721WithMetadata2.getAddress()); + await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, tokenManagerERC721WithMetadata2); // execution: await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); let data = await messages.encodeTransferErc721WithMetadataAndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI, @@ -560,21 +560,21 @@ describe("TokenManagerERC721WithMetadata", () => { await tokenManagerERC721WithMetadata2 .connect(schainOwner) - .addERC721TokenByOwner(schainName, await erc721OnOriginChain.getAddress(), await erc721OnTargetChain.getAddress()) + .addERC721TokenByOwner(schainName, erc721OnOriginChain, erc721OnTargetChain) .should.be.eventually.rejectedWith("TOKEN_REGISTRAR_ROLE is required"); await tokenManagerERC721WithMetadata2.connect(deployer).grantRole(await tokenManagerERC721WithMetadata2.TOKEN_REGISTRAR_ROLE(), schainOwner.address); await tokenManagerERC721WithMetadata2 .connect(schainOwner) - .addERC721TokenByOwner(schainName, await erc721OnOriginChain.getAddress(), await erc721OnTargetChain.getAddress()) + .addERC721TokenByOwner(schainName, erc721OnOriginChain, erc721OnTargetChain) .should.be.eventually.rejectedWith("Chain is not connected"); await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); await tokenManagerERC721WithMetadata2 .connect(schainOwner) - .addERC721TokenByOwner(schainName, await erc721OnOriginChain.getAddress(), await erc721OnTargetChain.getAddress()); - await tokenManagerERC721WithMetadata2.addTokenManager(schainName, await tokenManagerERC721WithMetadata.getAddress()); + .addERC721TokenByOwner(schainName, erc721OnOriginChain, erc721OnTargetChain); + await tokenManagerERC721WithMetadata2.addTokenManager(schainName, tokenManagerERC721WithMetadata); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data); expect((await erc721OnTargetChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnTargetChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); @@ -584,20 +584,20 @@ describe("TokenManagerERC721WithMetadata", () => { await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId2); await erc721OnOriginChain.connect(user).setTokenURI(tokenId2, tokenURI2); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId2); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId2); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId2); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId2); data = await messages.encodeTransferErc721MessageWithMetadata( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId2, tokenURI2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data); expect((await erc721OnTargetChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnTargetChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); @@ -607,7 +607,7 @@ describe("TokenManagerERC721WithMetadata", () => { }); it("should invoke `transferToSchainERC721` and transfer back without mistakes", async () => { - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerERC721WithMetadata.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC721WithMetadata); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); @@ -615,27 +615,27 @@ describe("TokenManagerERC721WithMetadata", () => { await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); await erc721OnOriginChain.connect(user).setTokenURI(tokenId, tokenURI); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, await tokenManagerERC721WithMetadata2.getAddress()); + await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, tokenManagerERC721WithMetadata2); // execution: await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); let data = await messages.encodeTransferErc721WithMetadataAndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI, @@ -652,56 +652,56 @@ describe("TokenManagerERC721WithMetadata", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC721WithMetadata2.addTokenManager(schainName, await tokenManagerERC721WithMetadata.getAddress()); + await tokenManagerERC721WithMetadata2.addTokenManager(schainName, tokenManagerERC721WithMetadata); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC721WithMetadata2.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data); - const addressERC721OnSchain = await tokenManagerERC721WithMetadata2.clonesErc721(schainId, await erc721OnOriginChain.getAddress()); + const addressERC721OnSchain = await tokenManagerERC721WithMetadata2.clonesErc721(schainId, erc721OnOriginChain); const targetErc721OnChain = (await ethers.getContractFactory("ERC721OnChain")).attach(addressERC721OnSchain) as ERC721OnChain; expect((await targetErc721OnChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await targetErc721OnChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Not allowed ERC721 Token"); - await targetErc721OnChain.connect(user).approve(await tokenManagerERC721WithMetadata2.getAddress(), tokenId); + await targetErc721OnChain.connect(user).approve(tokenManagerERC721WithMetadata2, tokenId); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721MessageWithMetadata( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI ); - await messageProxyForSchain.postMessage(await tokenManagerERC721WithMetadata.getAddress(), newSchainId, await tokenManagerERC721WithMetadata2.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721WithMetadata, newSchainId, tokenManagerERC721WithMetadata2, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnOriginChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); }); it("should invoke `transferToSchainERC721` and transfer back without mistakes with attached tokens", async () => { - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerERC721WithMetadata.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC721WithMetadata); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); @@ -709,27 +709,27 @@ describe("TokenManagerERC721WithMetadata", () => { await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); await erc721OnOriginChain.connect(user).setTokenURI(tokenId, tokenURI); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, await tokenManagerERC721WithMetadata2.getAddress()); + await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, tokenManagerERC721WithMetadata2); // execution: await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); let data = await messages.encodeTransferErc721WithMetadataAndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI, @@ -746,43 +746,43 @@ describe("TokenManagerERC721WithMetadata", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC721WithMetadata2.addTokenManager(schainName, await tokenManagerERC721WithMetadata.getAddress()); + await tokenManagerERC721WithMetadata2.addTokenManager(schainName, tokenManagerERC721WithMetadata); await tokenManagerERC721WithMetadata2.connect(deployer).grantRole(await tokenManagerERC721WithMetadata2.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC721WithMetadata2.connect(schainOwner).addERC721TokenByOwner(schainName, await erc721OnOriginChain.getAddress(), await erc721OnTargetChain.getAddress()); + await tokenManagerERC721WithMetadata2.connect(schainOwner).addERC721TokenByOwner(schainName, erc721OnOriginChain, erc721OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Not allowed ERC721 Token"); - await erc721OnTargetChain.connect(user).approve(await tokenManagerERC721WithMetadata2.getAddress(), tokenId); + await erc721OnTargetChain.connect(user).approve(tokenManagerERC721WithMetadata2, tokenId); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721MessageWithMetadata( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI ); - await messageProxyForSchain.postMessage(await tokenManagerERC721WithMetadata.getAddress(), newSchainId, await tokenManagerERC721WithMetadata2.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721WithMetadata, newSchainId, tokenManagerERC721WithMetadata2, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnOriginChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); @@ -790,7 +790,7 @@ describe("TokenManagerERC721WithMetadata", () => { it("should invoke `transferToSchainERC721` and transfer back without mistakes double", async () => { - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerERC721WithMetadata.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC721WithMetadata); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); @@ -798,27 +798,27 @@ describe("TokenManagerERC721WithMetadata", () => { await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); await erc721OnOriginChain.connect(user).setTokenURI(tokenId, tokenURI); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, await tokenManagerERC721WithMetadata2.getAddress()); + await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, tokenManagerERC721WithMetadata2); // execution: await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); let data = await messages.encodeTransferErc721WithMetadataAndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI, @@ -835,66 +835,66 @@ describe("TokenManagerERC721WithMetadata", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC721WithMetadata2.addTokenManager(schainName, await tokenManagerERC721WithMetadata.getAddress()); + await tokenManagerERC721WithMetadata2.addTokenManager(schainName, tokenManagerERC721WithMetadata); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data).should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC721WithMetadata2.enableAutomaticDeploy(); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data); - const addressERC721OnSchain = await tokenManagerERC721WithMetadata2.clonesErc721(schainId, await erc721OnOriginChain.getAddress()); + const addressERC721OnSchain = await tokenManagerERC721WithMetadata2.clonesErc721(schainId, erc721OnOriginChain); const targetErc721OnChain = (await ethers.getContractFactory("ERC721OnChain")).attach(addressERC721OnSchain) as ERC721OnChain; expect((await targetErc721OnChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await targetErc721OnChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Not allowed ERC721 Token"); - await targetErc721OnChain.connect(user).approve(await tokenManagerERC721WithMetadata2.getAddress(), tokenId); + await targetErc721OnChain.connect(user).approve(tokenManagerERC721WithMetadata2, tokenId); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721MessageWithMetadata( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI ); - await messageProxyForSchain.postMessage(await tokenManagerERC721WithMetadata.getAddress(), newSchainId, await tokenManagerERC721WithMetadata2.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721WithMetadata, newSchainId, tokenManagerERC721WithMetadata2, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnOriginChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721MessageWithMetadata( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI ); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data); expect((await targetErc721OnChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await targetErc721OnChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); @@ -904,57 +904,57 @@ describe("TokenManagerERC721WithMetadata", () => { await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId2); await erc721OnOriginChain.connect(user).setTokenURI(tokenId2, tokenURI2); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId2); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId2); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId2); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId2); data = await messages.encodeTransferErc721MessageWithMetadata( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId2, tokenURI2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data); expect((await targetErc721OnChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await targetErc721OnChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); expect((await targetErc721OnChain.ownerOf(tokenId2)).toString()).to.be.equal(user.address); expect((await targetErc721OnChain.tokenURI(tokenId2)).toString()).to.be.equal(tokenURI2); - await targetErc721OnChain.connect(user).approve(await tokenManagerERC721WithMetadata2.getAddress(), tokenId); + await targetErc721OnChain.connect(user).approve(tokenManagerERC721WithMetadata2, tokenId); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721MessageWithMetadata( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI ); - await messageProxyForSchain.postMessage(await tokenManagerERC721WithMetadata.getAddress(), newSchainId, await tokenManagerERC721WithMetadata2.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721WithMetadata, newSchainId, tokenManagerERC721WithMetadata2, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnOriginChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); - await targetErc721OnChain.connect(user).approve(await tokenManagerERC721WithMetadata2.getAddress(), tokenId2); + await targetErc721OnChain.connect(user).approve(tokenManagerERC721WithMetadata2, tokenId2); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId2); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId2); data = await messages.encodeTransferErc721MessageWithMetadata( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId2, tokenURI2 ); - await messageProxyForSchain.postMessage(await tokenManagerERC721WithMetadata.getAddress(), newSchainId, await tokenManagerERC721WithMetadata2.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721WithMetadata, newSchainId, tokenManagerERC721WithMetadata2, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnOriginChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); @@ -964,7 +964,7 @@ describe("TokenManagerERC721WithMetadata", () => { }); it("should invoke `transferToSchainERC721` and transfer back without mistakes double with attached tokens", async () => { - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerERC721WithMetadata.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC721WithMetadata); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); @@ -972,27 +972,27 @@ describe("TokenManagerERC721WithMetadata", () => { await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); await erc721OnOriginChain.connect(user).setTokenURI(tokenId, tokenURI); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); - await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, await tokenManagerERC721WithMetadata2.getAddress()); + await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, tokenManagerERC721WithMetadata2); // execution: await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); let data = await messages.encodeTransferErc721WithMetadataAndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI, @@ -1009,60 +1009,60 @@ describe("TokenManagerERC721WithMetadata", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC721WithMetadata2.addTokenManager(schainName, await tokenManagerERC721WithMetadata.getAddress()); + await tokenManagerERC721WithMetadata2.addTokenManager(schainName, tokenManagerERC721WithMetadata); await tokenManagerERC721WithMetadata2.connect(deployer).grantRole(await tokenManagerERC721WithMetadata2.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC721WithMetadata2.connect(schainOwner).addERC721TokenByOwner(schainName, await erc721OnOriginChain.getAddress(), await erc721OnTargetChain.getAddress()); + await tokenManagerERC721WithMetadata2.connect(schainOwner).addERC721TokenByOwner(schainName, erc721OnOriginChain, erc721OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Incorrect Token Manager address"); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721("Mainnet", await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721("Mainnet", erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("This function is not for transferring to Mainnet"); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Not allowed ERC721 Token"); - await erc721OnTargetChain.connect(user).approve(await tokenManagerERC721WithMetadata2.getAddress(), tokenId); + await erc721OnTargetChain.connect(user).approve(tokenManagerERC721WithMetadata2, tokenId); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721MessageWithMetadata( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI ); - await messageProxyForSchain.postMessage(await tokenManagerERC721WithMetadata.getAddress(), newSchainId, await tokenManagerERC721WithMetadata2.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721WithMetadata, newSchainId, tokenManagerERC721WithMetadata2, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnOriginChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721MessageWithMetadata( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI ); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data); expect((await erc721OnTargetChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnTargetChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); @@ -1072,57 +1072,57 @@ describe("TokenManagerERC721WithMetadata", () => { await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId2); await erc721OnOriginChain.connect(user).setTokenURI(tokenId2, tokenURI2); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId2); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId2); await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId2); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId2); data = await messages.encodeTransferErc721MessageWithMetadata( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId2, tokenURI2 ); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data); expect((await erc721OnTargetChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnTargetChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); expect((await erc721OnTargetChain.ownerOf(tokenId2)).toString()).to.be.equal(user.address); expect((await erc721OnTargetChain.tokenURI(tokenId2)).toString()).to.be.equal(tokenURI2); - await erc721OnTargetChain.connect(user).approve(await tokenManagerERC721WithMetadata2.getAddress(), tokenId); + await erc721OnTargetChain.connect(user).approve(tokenManagerERC721WithMetadata2, tokenId); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721MessageWithMetadata( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI ); - await messageProxyForSchain.postMessage(await tokenManagerERC721WithMetadata.getAddress(), newSchainId, await tokenManagerERC721WithMetadata2.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721WithMetadata, newSchainId, tokenManagerERC721WithMetadata2, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnOriginChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); - await erc721OnTargetChain.connect(user).approve(await tokenManagerERC721WithMetadata2.getAddress(), tokenId2); + await erc721OnTargetChain.connect(user).approve(tokenManagerERC721WithMetadata2, tokenId2); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId2); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId2); data = await messages.encodeTransferErc721MessageWithMetadata( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId2, tokenURI2 ); - await messageProxyForSchain.postMessage(await tokenManagerERC721WithMetadata.getAddress(), newSchainId, await tokenManagerERC721WithMetadata2.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721WithMetadata, newSchainId, tokenManagerERC721WithMetadata2, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnOriginChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); @@ -1131,7 +1131,7 @@ describe("TokenManagerERC721WithMetadata", () => { }); it("should not be able to transfer X->Y->Z", async () => { - await messageProxyForSchain.registerExtraContract(newSchainName, await tokenManagerERC721WithMetadata.getAddress()); + await messageProxyForSchain.registerExtraContract(newSchainName, tokenManagerERC721WithMetadata); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); @@ -1139,17 +1139,17 @@ describe("TokenManagerERC721WithMetadata", () => { await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); await erc721OnOriginChain.connect(user).setTokenURI(tokenId, tokenURI); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); - await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, await tokenManagerERC721WithMetadata2.getAddress()); + await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, tokenManagerERC721WithMetadata2); // execution: await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); const data = await messages.encodeTransferErc721WithMetadataAndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI, @@ -1166,12 +1166,12 @@ describe("TokenManagerERC721WithMetadata", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC721WithMetadata2.addTokenManager(schainName, await tokenManagerERC721WithMetadata.getAddress()); + await tokenManagerERC721WithMetadata2.addTokenManager(schainName, tokenManagerERC721WithMetadata); await tokenManagerERC721WithMetadata2.connect(deployer).grantRole(await tokenManagerERC721WithMetadata2.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC721WithMetadata2.connect(schainOwner).addERC721TokenByOwner(schainName, await erc721OnOriginChain.getAddress(), await erc721OnTargetChain.getAddress()); + await tokenManagerERC721WithMetadata2.connect(schainOwner).addERC721TokenByOwner(schainName, erc721OnOriginChain, erc721OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data); expect((await erc721OnTargetChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnTargetChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); @@ -1181,35 +1181,35 @@ describe("TokenManagerERC721WithMetadata", () => { const erc721OnTargetZChain = await deployERC721OnChain("NewTokenZ", "NTNZ"); const keyStorageZ = await deployKeyStorageMock(); - const messageProxyForSchainZ = await deployMessageProxyForSchainTester(await keyStorageZ.getAddress(), newSchainNameZ); + const messageProxyForSchainZ = await deployMessageProxyForSchainTester(keyStorageZ, newSchainNameZ); const tokenManagerLinkerZ = await deployTokenManagerLinker(messageProxyForSchainZ, deployer.address); - const communityLockerZ = await deployCommunityLocker(newSchainName, await messageProxyForSchainZ.getAddress(), tokenManagerLinkerZ, fakeCommunityPool); + const communityLockerZ = await deployCommunityLocker(newSchainName, messageProxyForSchainZ, tokenManagerLinkerZ, fakeCommunityPool); const tokenManagerERC721WithMetadataZ = await deployTokenManagerERC721WithMetadata( - newSchainNameZ, await messageProxyForSchainZ.getAddress(), tokenManagerLinkerZ, communityLockerZ, fakeDepositBox + newSchainNameZ, messageProxyForSchainZ, tokenManagerLinkerZ, communityLockerZ, fakeDepositBox ); - await erc721OnTargetZChain.connect(deployer).grantRole(await erc721OnTargetZChain.MINTER_ROLE(), await tokenManagerERC721WithMetadataZ.getAddress()); - await tokenManagerLinkerZ.registerTokenManager(await tokenManagerERC721WithMetadataZ.getAddress()); + await erc721OnTargetZChain.connect(deployer).grantRole(await erc721OnTargetZChain.MINTER_ROLE(), tokenManagerERC721WithMetadataZ); + await tokenManagerLinkerZ.registerTokenManager(tokenManagerERC721WithMetadataZ); await messageProxyForSchain2.connect(deployer).grantRole(await messageProxyForSchain2.CHAIN_CONNECTOR_ROLE(), deployer.address); await messageProxyForSchain2.connect(deployer).addConnectedChain(newSchainNameZ); - await tokenManagerERC721WithMetadata2.addTokenManager(newSchainNameZ, await tokenManagerERC721WithMetadataZ.getAddress()); + await tokenManagerERC721WithMetadata2.addTokenManager(newSchainNameZ, tokenManagerERC721WithMetadataZ); - await erc721OnTargetChain.connect(user).approve(await tokenManagerERC721WithMetadata2.getAddress(), tokenId); + await erc721OnTargetChain.connect(user).approve(tokenManagerERC721WithMetadata2, tokenId); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(newSchainNameZ, await erc721OnOriginChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainNameZ, erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Not allowed ERC721 Token"); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(newSchainNameZ, await erc721OnTargetChain.getAddress(), tokenId) + .transferToSchainERC721(newSchainNameZ, erc721OnTargetChain, tokenId) .should.be.eventually.rejectedWith("Incorrect main chain token"); }); it("should not be able to transfer main chain token or clone to mainnet", async () => { - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerERC721WithMetadata.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC721WithMetadata); // add connected chain: await messageProxyForSchain.connect(deployer).grantRole(await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(), deployer.address); @@ -1217,17 +1217,17 @@ describe("TokenManagerERC721WithMetadata", () => { await erc721OnOriginChain.connect(deployer).mint(user.address, tokenId); await erc721OnOriginChain.connect(user).setTokenURI(tokenId, tokenURI); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); - await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, await tokenManagerERC721WithMetadata2.getAddress()); + await tokenManagerERC721WithMetadata.addTokenManager(newSchainName, tokenManagerERC721WithMetadata2); // execution: await tokenManagerERC721WithMetadata .connect(user) - .transferToSchainERC721(newSchainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(newSchainName, erc721OnOriginChain, tokenId); let data = await messages.encodeTransferErc721WithMetadataAndTokenInfoMessage( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI, @@ -1244,57 +1244,57 @@ describe("TokenManagerERC721WithMetadata", () => { // receive: // registration: await messageProxyForSchain2.connect(deployer).addConnectedChain(schainName); - await tokenManagerERC721WithMetadata2.addTokenManager(schainName, await tokenManagerERC721WithMetadata.getAddress()); + await tokenManagerERC721WithMetadata2.addTokenManager(schainName, tokenManagerERC721WithMetadata); await tokenManagerERC721WithMetadata2.connect(deployer).grantRole(await tokenManagerERC721WithMetadata2.TOKEN_REGISTRAR_ROLE(), schainOwner.address); - await tokenManagerERC721WithMetadata2.connect(schainOwner).addERC721TokenByOwner(schainName, await erc721OnOriginChain.getAddress(), await erc721OnTargetChain.getAddress()); + await tokenManagerERC721WithMetadata2.connect(schainOwner).addERC721TokenByOwner(schainName, erc721OnOriginChain, erc721OnTargetChain); - await messageProxyForSchain2.postMessage(await tokenManagerERC721WithMetadata2.getAddress(), schainId, await tokenManagerERC721WithMetadata.getAddress(), data); + await messageProxyForSchain2.postMessage(tokenManagerERC721WithMetadata2, schainId, tokenManagerERC721WithMetadata, data); expect((await erc721OnTargetChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnTargetChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); data = await messages.encodeActivateUserMessage(user.address); - await messageProxyForSchain2.postMessage(await communityLocker2.getAddress(), mainnetId, fakeCommunityPool, data); + await messageProxyForSchain2.postMessage(communityLocker2, mainnetId, fakeCommunityPool, data); - await erc721OnTargetChain.connect(user).approve(await tokenManagerERC721WithMetadata2.getAddress(), tokenId); + await erc721OnTargetChain.connect(user).approve(tokenManagerERC721WithMetadata2, tokenId); await tokenManagerERC721WithMetadata2 .connect(user) - .exitToMainERC721(await erc721OnOriginChain.getAddress(), tokenId) + .exitToMainERC721(erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Not allowed ERC721 Token"); await tokenManagerERC721WithMetadata2 .connect(user) - .exitToMainERC721(await erc721OnTargetChain.getAddress(), tokenId) + .exitToMainERC721(erc721OnTargetChain, tokenId) .should.be.eventually.rejectedWith("Incorrect main chain token"); await tokenManagerERC721WithMetadata2 .connect(user) - .transferToSchainERC721(schainName, await erc721OnOriginChain.getAddress(), tokenId); + .transferToSchainERC721(schainName, erc721OnOriginChain, tokenId); data = await messages.encodeTransferErc721MessageWithMetadata( - await erc721OnOriginChain.getAddress(), + erc721OnOriginChain, user.address, tokenId, tokenURI ); - await messageProxyForSchain.postMessage(await tokenManagerERC721WithMetadata.getAddress(), newSchainId, await tokenManagerERC721WithMetadata2.getAddress(), data); + await messageProxyForSchain.postMessage(tokenManagerERC721WithMetadata, newSchainId, tokenManagerERC721WithMetadata2, data); expect((await erc721OnOriginChain.ownerOf(tokenId)).toString()).to.be.equal(user.address); expect((await erc721OnOriginChain.tokenURI(tokenId)).toString()).to.be.equal(tokenURI); - await erc721OnOriginChain.connect(user).approve(await tokenManagerERC721WithMetadata.getAddress(), tokenId); + await erc721OnOriginChain.connect(user).approve(tokenManagerERC721WithMetadata, tokenId); await tokenManagerERC721WithMetadata .connect(user) - .exitToMainERC721(await erc721OnOriginChain.getAddress(), tokenId) + .exitToMainERC721(erc721OnOriginChain, tokenId) .should.be.eventually.rejectedWith("Main chain token could not be transfered to Mainnet"); await tokenManagerERC721WithMetadata .connect(user) - .exitToMainERC721(await erc721OnTargetChain.getAddress(), tokenId) + .exitToMainERC721(erc721OnTargetChain, tokenId) .should.be.eventually.rejectedWith("ERC721: invalid token ID"); }); @@ -1303,13 +1303,13 @@ describe("TokenManagerERC721WithMetadata", () => { describe("tests for `postMessage` function", async () => { beforeEach(async () => { - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerERC721WithMetadata.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC721WithMetadata); }); it("should transfer ERC721 token token with token info", async () => { // preparation const data = await messages.encodeTransferErc721WithMetadataAndTokenInfoMessage( - await token.getAddress(), + token, to, tokenId, tokenURI, @@ -1319,12 +1319,12 @@ describe("TokenManagerERC721WithMetadata", () => { } ); - await messageProxyForSchain.postMessage(await tokenManagerERC721WithMetadata.getAddress(), mainnetId, fakeDepositBox, data) + await messageProxyForSchain.postMessage(tokenManagerERC721WithMetadata, mainnetId, fakeDepositBox, data) .should.be.eventually.rejectedWith("Automatic deploy is disabled"); await tokenManagerERC721WithMetadata.connect(schainOwner).enableAutomaticDeploy(); - await messageProxyForSchain.postMessage(await tokenManagerERC721WithMetadata.getAddress(), mainnetId, fakeDepositBox, data); - const addressERC721OnSchain = await tokenManagerERC721WithMetadata.clonesErc721(mainnetId, await token.getAddress()); + await messageProxyForSchain.postMessage(tokenManagerERC721WithMetadata, mainnetId, fakeDepositBox, data); + const addressERC721OnSchain = await tokenManagerERC721WithMetadata.clonesErc721(mainnetId, token); const erc721OnChain = await (await ethers.getContractFactory("ERC721OnChain")).attach(addressERC721OnSchain) as ERC721OnChain; expect((await erc721OnChain.ownerOf(tokenId))).to.be.equal(to); expect((await erc721OnChain.tokenURI(tokenId))).to.be.equal(tokenURI); @@ -1332,18 +1332,18 @@ describe("TokenManagerERC721WithMetadata", () => { it("should transfer ERC721 token on schain", async () => { // preparation - await tokenManagerERC721WithMetadata.connect(schainOwner).addERC721TokenByOwner(mainnetName, await token.getAddress(), await tokenClone.getAddress()); - await tokenClone.connect(deployer).grantRole(await tokenClone.MINTER_ROLE(), await tokenManagerERC721WithMetadata.getAddress()); + await tokenManagerERC721WithMetadata.connect(schainOwner).addERC721TokenByOwner(mainnetName, token, tokenClone); + await tokenClone.connect(deployer).grantRole(await tokenClone.MINTER_ROLE(), tokenManagerERC721WithMetadata); const data = await messages.encodeTransferErc721MessageWithMetadata( - await token.getAddress(), + token, to, tokenId, tokenURI ); - await messageProxyForSchain.postMessage(await tokenManagerERC721WithMetadata.getAddress(), mainnetId, fakeDepositBox, data); - const addressERC721OnSchain = await tokenManagerERC721WithMetadata.clonesErc721(mainnetId, await token.getAddress()); + await messageProxyForSchain.postMessage(tokenManagerERC721WithMetadata, mainnetId, fakeDepositBox, data); + const addressERC721OnSchain = await tokenManagerERC721WithMetadata.clonesErc721(mainnetId, token); const erc721OnChain = (await ethers.getContractFactory("ERC721OnChain")).attach(addressERC721OnSchain) as ERC721OnChain; expect((await erc721OnChain.ownerOf(tokenId))).to.be.equal(to); expect((await erc721OnChain.tokenURI(tokenId))).to.be.equal(tokenURI); @@ -1354,7 +1354,7 @@ describe("TokenManagerERC721WithMetadata", () => { "000000000000000000000000a51c1fc2f0d1a1b8494ed1fe312d7c3a78ed91c0"+ "00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8"+ "0000000000000000000000000000000000000000000000000000000000000001"; - await messageProxyForSchain.postMessage(await tokenManagerERC721WithMetadata.getAddress(), mainnetId, fakeDepositBox, data) + await messageProxyForSchain.postMessage(tokenManagerERC721WithMetadata, mainnetId, fakeDepositBox, data) .should.be.eventually.rejectedWith("MessageType is unknown"); }); diff --git a/test/TokenManagerEth.ts b/test/TokenManagerEth.ts index a24b43980..9b5b85e5d 100644 --- a/test/TokenManagerEth.ts +++ b/test/TokenManagerEth.ts @@ -74,14 +74,19 @@ describe("TokenManagerEth", () => { beforeEach(async () => { const keyStorage = await deployKeyStorageMock(); - messageProxyForSchain = await deployMessageProxyForSchainTester(await keyStorage.getAddress(), schainName); + messageProxyForSchain = await deployMessageProxyForSchainTester(keyStorage, schainName); tokenManagerLinker = await deployTokenManagerLinker(messageProxyForSchain, deployer.address); - fakeDepositBox = await tokenManagerLinker.getAddress(); - fakeCommunityPool = await tokenManagerLinker.getAddress(); - communityLocker = await deployCommunityLocker(schainName, await messageProxyForSchain.getAddress(), tokenManagerLinker, fakeCommunityPool); + fakeDepositBox = user.address; + fakeCommunityPool = user.address; + communityLocker = await deployCommunityLocker( + schainName, + messageProxyForSchain, + tokenManagerLinker, + fakeCommunityPool + ); tokenManagerEth = await deployTokenManagerEth( schainName, - await messageProxyForSchain.getAddress(), + messageProxyForSchain, tokenManagerLinker, communityLocker, fakeDepositBox, @@ -90,19 +95,19 @@ describe("TokenManagerEth", () => { ethERC20 = await deployEthErc20( tokenManagerEth ); - await tokenManagerLinker.registerTokenManager(await tokenManagerEth.getAddress()); - await tokenManagerEth.connect(deployer).setEthErc20Address(await ethERC20.getAddress()); + await tokenManagerLinker.registerTokenManager(tokenManagerEth); + await tokenManagerEth.connect(deployer).setEthErc20Address(ethERC20); messages = await deployMessages(); const data = await messages.encodeActivateUserMessage(user.address); - await messageProxyForSchain.postMessage(await communityLocker.getAddress(), mainnetHash, fakeCommunityPool, data); + await messageProxyForSchain.postMessage(communityLocker, mainnetHash, fakeCommunityPool, data); const extraContractRegistrarRole = await messageProxyForSchain.EXTRA_CONTRACT_REGISTRAR_ROLE(); await messageProxyForSchain.connect(deployer).grantRole(extraContractRegistrarRole, deployer.address); }); it("should set EthErc20 address", async () => { - const newEthErc20Address = await tokenManagerLinker.getAddress(); + const newEthErc20Address = tokenManagerLinker; // only owner can set EthErc20 address: await tokenManagerEth.connect(user).setEthErc20Address(newEthErc20Address).should.be.rejected; await tokenManagerEth.connect(deployer).setEthErc20Address(newEthErc20Address); @@ -197,23 +202,23 @@ describe("TokenManagerEth", () => { const amount = 60; const amountAfter = 54; const amountTo = 6; - await messageProxyForSchain.registerExtraContract("Mainnet", await tokenManagerEth.getAddress()); + await messageProxyForSchain.registerExtraContract("Mainnet", tokenManagerEth); await ethERC20.grantRole(await ethERC20.MINTER_ROLE(), deployer.address); await ethERC20.mint(user.address, amount); - // send Eth to a client on Mainnet: + // // send Eth to a client on Mainnet: await tokenManagerEth.connect(user).exitToMain(amountTo); expect(await ethERC20.balanceOf(user.address)).to.be.equal(amountAfter.toString()); let data1 = await messages.encodeLockUserMessage(user.address); - await messageProxyForSchain.postMessage(await communityLocker.getAddress(), mainnetHash, fakeCommunityPool, data1); + await messageProxyForSchain.postMessage(communityLocker, mainnetHash, fakeCommunityPool, data1); await tokenManagerEth.connect(user).exitToMain(amountTo) .should.be.eventually.rejectedWith("Recipient must be active"); data1 = await messages.encodeActivateUserMessage(user.address); - await messageProxyForSchain.postMessage(await communityLocker.getAddress(), mainnetHash, fakeCommunityPool, data1); + await messageProxyForSchain.postMessage(communityLocker, mainnetHash, fakeCommunityPool, data1); await tokenManagerEth.connect(user).exitToMain(amountTo) .should.be.eventually.rejectedWith("Exceeded message rate limit"); @@ -242,14 +247,21 @@ describe("TokenManagerEth", () => { const amount = 10; const bytesData = await messages.encodeTransferEthMessage(user.address, amount); const sender = deployer.address; - // redeploy tokenManagerEth with `developer` address instead `await messageProxyForSchain.getAddress()` + // redeploy tokenManagerEth with `developer` address instead `messageProxyForSchain` // to avoid `Not a sender` error - tokenManagerEth = await deployTokenManagerEth(schainName, deployer.address, tokenManagerLinker, communityLocker, fakeDepositBox, await ethERC20.getAddress()); + tokenManagerEth = await deployTokenManagerEth( + schainName, + messageProxyForSchain, + tokenManagerLinker, + communityLocker, + fakeDepositBox, + await ethERC20.getAddress() + ); // await tokenManagerEth.setContract("MessageProxy", deployer, {from: deployer}); // execution - await tokenManagerEth + await messageProxyForSchain .connect(deployer) - .postMessage(schainHash, sender, bytesData) + .postMessage(tokenManagerEth, schainHash, sender, bytesData) .should.be.eventually.rejectedWith(error); }); @@ -257,9 +269,16 @@ describe("TokenManagerEth", () => { // for `Invalid data` message bytesData should be `0x` const bytesData = "0x"; const sender = deployer.address; - // redeploy tokenManagerEth with `developer` address instead `await messageProxyForSchain.getAddress()` + // redeploy tokenManagerEth with `developer` address instead `messageProxyForSchain` // to avoid `Not a sender` error - tokenManagerEth = await deployTokenManagerEth(schainName, deployer.address, tokenManagerLinker, communityLocker, fakeDepositBox, await ethERC20.getAddress()); + tokenManagerEth = await deployTokenManagerEth( + schainName, + messageProxyForSchain, + tokenManagerLinker, + communityLocker, + fakeDepositBox, + await ethERC20.getAddress() + ); // add schain to avoid the `Receiver chain is incorrect` error await tokenManagerEth .connect(deployer) @@ -273,7 +292,7 @@ describe("TokenManagerEth", () => { it("should transfer eth", async () => { // preparation - await messageProxyForSchain.registerExtraContractForAll(await tokenManagerEth.getAddress()); + await messageProxyForSchain.registerExtraContractForAll(tokenManagerEth); const fromSchainName = "fromSchainName"; const fromSchainId = ethers.id(fromSchainName); const amount = "10"; @@ -286,25 +305,25 @@ describe("TokenManagerEth", () => { await tokenManagerEth .connect(deployer) .addTokenManager(fromSchainName, deployer.address); - await ethERC20.connect(deployer).grantRole(await ethERC20.MINTER_ROLE(), await tokenManagerEth.getAddress()); - await ethERC20.connect(deployer).grantRole(await ethERC20.BURNER_ROLE(), await tokenManagerEth.getAddress()); + await ethERC20.connect(deployer).grantRole(await ethERC20.MINTER_ROLE(), tokenManagerEth); + await ethERC20.connect(deployer).grantRole(await ethERC20.BURNER_ROLE(), tokenManagerEth); // execution await messageProxyForSchain.postMessage( - await tokenManagerEth.getAddress(), + tokenManagerEth, fromSchainId, sender, bytesData ).should.be.eventually.rejectedWith("Receiver chain is incorrect"); await messageProxyForSchain.postMessage( - await tokenManagerEth.getAddress(), + tokenManagerEth, mainnetHash, sender, bytesData ).should.be.eventually.rejectedWith("Receiver chain is incorrect"); await messageProxyForSchain.postMessage( - await tokenManagerEth.getAddress(), + tokenManagerEth, mainnetHash, fakeDepositBox, bytesData diff --git a/test/TokenManagerLinker.ts b/test/TokenManagerLinker.ts index da46535f1..c6951dff7 100644 --- a/test/TokenManagerLinker.ts +++ b/test/TokenManagerLinker.ts @@ -73,15 +73,15 @@ describe("TokenManagerLinker", () => { beforeEach(async () => { newSchainName = "newSchainName"; const keyStorage = await deployKeyStorageMock(); - messageProxy = await deployMessageProxyForSchainTester(await keyStorage.getAddress(), schainName); + messageProxy = await deployMessageProxyForSchainTester(keyStorage, schainName); const fakeLinker = deployer.address; linker = await deployTokenManagerLinker(messageProxy, fakeLinker); - fakeDepositBox = await linker.getAddress(); - fakeCommunityPool = await linker.getAddress(); - communityLocker = await deployCommunityLocker(schainName, await messageProxy.getAddress(), linker, fakeCommunityPool); - tokenManagerEth = await deployTokenManagerEth(schainName, await messageProxy.getAddress(), linker, communityLocker, fakeDepositBox, "0x0000000000000000000000000000000000000000"); - tokenManagerERC20 = await deployTokenManagerERC20(schainName, await messageProxy.getAddress(), linker, communityLocker, fakeDepositBox); - tokenManagerERC721 = await deployTokenManagerERC721(schainName, await messageProxy.getAddress(), linker, communityLocker, fakeDepositBox); + fakeDepositBox = deployer.address; + fakeCommunityPool = deployer.address; + communityLocker = await deployCommunityLocker(schainName, messageProxy, linker, fakeCommunityPool); + tokenManagerEth = await deployTokenManagerEth(schainName, messageProxy, linker, communityLocker, fakeDepositBox, "0x0000000000000000000000000000000000000000"); + tokenManagerERC20 = await deployTokenManagerERC20(schainName, messageProxy, linker, communityLocker, fakeDepositBox); + tokenManagerERC721 = await deployTokenManagerERC721(schainName, messageProxy, linker, communityLocker, fakeDepositBox); const chainConnectorRole = await messageProxy.CHAIN_CONNECTOR_ROLE(); await messageProxy.connect(deployer).grantRole(chainConnectorRole, await linker.getAddress()); const extraContractRegistrarRole = await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(); @@ -97,11 +97,11 @@ describe("TokenManagerLinker", () => { }); it("should connect schain with 1 tokenManager", async () => { - expect(await linker.hasTokenManager(await tokenManagerEth.getAddress())).to.equal(false); + expect(await linker.hasTokenManager(tokenManagerEth)).to.equal(false); - await linker.connect(deployer).registerTokenManager(await tokenManagerEth.getAddress()); + await linker.connect(deployer).registerTokenManager(tokenManagerEth); - expect(await linker.hasTokenManager(await tokenManagerEth.getAddress())).to.equal(true); + expect(await linker.hasTokenManager(tokenManagerEth)).to.equal(true); expect(await linker.hasSchain(newSchainName)).to.equal(false); @@ -111,17 +111,17 @@ describe("TokenManagerLinker", () => { }); it("should connect schain with 3 tokenManager", async () => { - expect(await linker.hasTokenManager(await tokenManagerEth.getAddress())).to.equal(false); - expect(await linker.hasTokenManager(await tokenManagerERC20.getAddress())).to.equal(false); - expect(await linker.hasTokenManager(await tokenManagerERC721.getAddress())).to.equal(false); + expect(await linker.hasTokenManager(tokenManagerEth)).to.equal(false); + expect(await linker.hasTokenManager(tokenManagerERC20)).to.equal(false); + expect(await linker.hasTokenManager(tokenManagerERC721)).to.equal(false); - await linker.connect(deployer).registerTokenManager(await tokenManagerEth.getAddress()); - await linker.connect(deployer).registerTokenManager(await tokenManagerERC20.getAddress()); - await linker.connect(deployer).registerTokenManager(await tokenManagerERC721.getAddress()); + await linker.connect(deployer).registerTokenManager(tokenManagerEth); + await linker.connect(deployer).registerTokenManager(tokenManagerERC20); + await linker.connect(deployer).registerTokenManager(tokenManagerERC721); - expect(await linker.hasTokenManager(await tokenManagerEth.getAddress())).to.equal(true); - expect(await linker.hasTokenManager(await tokenManagerERC20.getAddress())).to.equal(true); - expect(await linker.hasTokenManager(await tokenManagerERC721.getAddress())).to.equal(true); + expect(await linker.hasTokenManager(tokenManagerEth)).to.equal(true); + expect(await linker.hasTokenManager(tokenManagerERC20)).to.equal(true); + expect(await linker.hasTokenManager(tokenManagerERC721)).to.equal(true); expect(await linker.hasSchain(newSchainName)).to.equal(false); @@ -131,9 +131,9 @@ describe("TokenManagerLinker", () => { }); it("should invoke `disconnectSchain` without mistakes", async () => { - await linker.connect(deployer).registerTokenManager(await tokenManagerEth.getAddress()); - await linker.connect(deployer).registerTokenManager(await tokenManagerERC20.getAddress()); - await linker.connect(deployer).registerTokenManager(await tokenManagerERC721.getAddress()); + await linker.connect(deployer).registerTokenManager(tokenManagerEth); + await linker.connect(deployer).registerTokenManager(tokenManagerERC20); + await linker.connect(deployer).registerTokenManager(tokenManagerERC721); await linker.connect(deployer).connectSchain(newSchainName); @@ -149,17 +149,17 @@ describe("TokenManagerLinker", () => { const nullAddress = "0x0000000000000000000000000000000000000000"; const tokenManagerAddress = user.address; - expect(await linker.hasTokenManager(await tokenManagerEth.getAddress())).to.equal(false); - expect(await linker.hasTokenManager(await tokenManagerERC20.getAddress())).to.equal(false); - expect(await linker.hasTokenManager(await tokenManagerERC721.getAddress())).to.equal(false); + expect(await linker.hasTokenManager(tokenManagerEth)).to.equal(false); + expect(await linker.hasTokenManager(tokenManagerERC20)).to.equal(false); + expect(await linker.hasTokenManager(tokenManagerERC721)).to.equal(false); - await linker.connect(deployer).registerTokenManager(await tokenManagerEth.getAddress()); - await linker.connect(deployer).registerTokenManager(await tokenManagerERC20.getAddress()); - await linker.connect(deployer).registerTokenManager(await tokenManagerERC721.getAddress()); + await linker.connect(deployer).registerTokenManager(tokenManagerEth); + await linker.connect(deployer).registerTokenManager(tokenManagerERC20); + await linker.connect(deployer).registerTokenManager(tokenManagerERC721); - expect(await linker.hasTokenManager(await tokenManagerEth.getAddress())).to.equal(true); - expect(await linker.hasTokenManager(await tokenManagerERC20.getAddress())).to.equal(true); - expect(await linker.hasTokenManager(await tokenManagerERC721.getAddress())).to.equal(true); + expect(await linker.hasTokenManager(tokenManagerEth)).to.equal(true); + expect(await linker.hasTokenManager(tokenManagerERC20)).to.equal(true); + expect(await linker.hasTokenManager(tokenManagerERC721)).to.equal(true); expect(await linker.hasTokenManager(nullAddress)).to.equal(false); expect(await linker.hasTokenManager(tokenManagerAddress)).to.equal(false); @@ -183,13 +183,13 @@ describe("TokenManagerLinker", () => { expect(await linker.hasTokenManager(nullAddress)).to.equal(false); - await linker.connect(deployer).removeTokenManager(await tokenManagerEth.getAddress()); - await linker.connect(deployer).removeTokenManager(await tokenManagerERC20.getAddress()); - await linker.connect(deployer).removeTokenManager(await tokenManagerERC721.getAddress()); + await linker.connect(deployer).removeTokenManager(tokenManagerEth); + await linker.connect(deployer).removeTokenManager(tokenManagerERC20); + await linker.connect(deployer).removeTokenManager(tokenManagerERC721); - expect(await linker.hasTokenManager(await tokenManagerEth.getAddress())).to.equal(false); - expect(await linker.hasTokenManager(await tokenManagerERC20.getAddress())).to.equal(false); - expect(await linker.hasTokenManager(await tokenManagerERC721.getAddress())).to.equal(false); + expect(await linker.hasTokenManager(tokenManagerEth)).to.equal(false); + expect(await linker.hasTokenManager(tokenManagerERC20)).to.equal(false); + expect(await linker.hasTokenManager(tokenManagerERC721)).to.equal(false); }); }); diff --git a/test/extensions/ERC721MintingFromSchainToMainnet.ts b/test/extensions/ERC721MintingFromSchainToMainnet.ts index 314eb3928..d7199479b 100644 --- a/test/extensions/ERC721MintingFromSchainToMainnet.ts +++ b/test/extensions/ERC721MintingFromSchainToMainnet.ts @@ -123,17 +123,17 @@ describe("ERC721MintingFromSchainToMainnet", () => { schainsInternal = await (await ethers.getContractFactory("SchainsInternal")).deploy() as SchainsInternal; skaleVerifier = await (await ethers.getContractFactory("SkaleVerifierMock")).deploy() as SkaleVerifierMock; wallets = await (await ethers.getContractFactory("Wallets")).deploy() as Wallets; - await contractManager.connect(deployer).setContractsAddress("KeyStorage", await keyStorage.getAddress()); - await contractManager.connect(deployer).setContractsAddress("Nodes", await nodes.getAddress()); - await contractManager.connect(deployer).setContractsAddress("Schains", await schains.getAddress()); - await contractManager.connect(deployer).setContractsAddress("SchainsInternal", await schainsInternal.getAddress()); - await contractManager.connect(deployer).setContractsAddress("SkaleVerifier", await skaleVerifier.getAddress()); - await contractManager.connect(deployer).setContractsAddress("Wallets", await wallets.getAddress()); + await contractManager.connect(deployer).setContractsAddress("KeyStorage", keyStorage); + await contractManager.connect(deployer).setContractsAddress("Nodes", nodes); + await contractManager.connect(deployer).setContractsAddress("Schains", schains); + await contractManager.connect(deployer).setContractsAddress("SchainsInternal", schainsInternal); + await contractManager.connect(deployer).setContractsAddress("SkaleVerifier", skaleVerifier); + await contractManager.connect(deployer).setContractsAddress("Wallets", wallets); // add ContractManager to contracts - await schains.connect(deployer).addContractManager(await contractManager.getAddress()); - await schainsInternal.connect(deployer).addContractManager(await contractManager.getAddress()); - await wallets.connect(deployer).addContractManager(await contractManager.getAddress()); + await schains.connect(deployer).addContractManager(contractManager); + await schainsInternal.connect(deployer).addContractManager(contractManager); + await wallets.connect(deployer).addContractManager(contractManager); // setup 16 nodes const nodeCreationParams = { @@ -191,36 +191,36 @@ describe("ERC721MintingFromSchainToMainnet", () => { const extraContractRegistrarRole = await messageProxyForMainnet.EXTRA_CONTRACT_REGISTRAR_ROLE(); const chainConnectorRole2 = await messageProxyForMainnet.CHAIN_CONNECTOR_ROLE(); await messageProxyForMainnet.connect(deployer).grantRole(extraContractRegistrarRole, deployer.address); - await messageProxyForMainnet.connect(deployer).grantRole(chainConnectorRole2, await imaLinker.getAddress()); + await messageProxyForMainnet.connect(deployer).grantRole(chainConnectorRole2, imaLinker); // await messageProxyForMainnet.registerExtraContractForAll(depositBoxEth.address) // await messageProxyForMainnet.registerExtraContractForAll(depositBoxERC20.address) // await messageProxyForMainnet.registerExtraContractForAll(depositBoxERC721.address) - // await messageProxyForMainnet.registerExtraContractForAll(await communityPool.getAddress()) + // await messageProxyForMainnet.registerExtraContractForAll(communityPool) // IMA schain part deployment messageProxyForSchain = await deployMessageProxyForSchain(await keyStorage.getAddress(), schainName); await keyStorage.connect(deployer).setBlsCommonPublicKey(BLSPublicKey); tokenManagerLinker = await deployTokenManagerLinker(messageProxyForSchain, await imaLinker.getAddress()); - communityLocker = await deployCommunityLocker(schainName, await messageProxyForSchain.getAddress(), tokenManagerLinker, await communityPool.getAddress()); + communityLocker = await deployCommunityLocker(schainName, messageProxyForSchain, tokenManagerLinker, await communityPool.getAddress()); // tokenManagerEth = await deployTokenManagerEth( // schainName, - // await messageProxyForSchain.getAddress(), + // messageProxyForSchain, // tokenManagerLinker, // communityLocker, // depositBoxEth.address, // "0x0000000000000000000000000000000000000000"); - // tokenManagerERC20 = await deployTokenManagerERC20(schainName, await messageProxyForSchain.getAddress(), tokenManagerLinker, communityLocker, depositBoxERC20.address); - // tokenManagerERC721 = await deployTokenManagerERC721(schainName, await messageProxyForSchain.getAddress(), tokenManagerLinker, communityLocker, depositBoxERC721.address); + // tokenManagerERC20 = await deployTokenManagerERC20(schainName, messageProxyForSchain, tokenManagerLinker, communityLocker, depositBoxERC20.address); + // tokenManagerERC721 = await deployTokenManagerERC721(schainName, messageProxyForSchain, tokenManagerLinker, communityLocker, depositBoxERC721.address); await messageProxyForSchain.connect(deployer).grantRole(extraContractRegistrarRole, deployer.address); // await messageProxyForSchain.registerExtraContractForAll(tokenManagerEth.address) // await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC20.address) // await messageProxyForSchain.registerExtraContractForAll(tokenManagerERC721.address) - // await messageProxyForSchain.registerExtraContractForAll(await communityLocker.getAddress()) + // await messageProxyForSchain.registerExtraContractForAll(communityLocker) // ethERC20 = await deployEthErc20(tokenManagerEth); // await tokenManagerEth.connect(deployer).setEthErc20Address(ethERC20.address); const chainConnectorRole = await messageProxyForSchain.CHAIN_CONNECTOR_ROLE(); - await messageProxyForSchain.connect(deployer).grantRole(chainConnectorRole, await tokenManagerLinker.getAddress()); + await messageProxyForSchain.connect(deployer).grantRole(chainConnectorRole, tokenManagerLinker); // await tokenManagerERC20.connect(deployer).grantRole(await tokenManagerERC20.TOKEN_REGISTRAR_ROLE(), schainOwner.address); // await tokenManagerERC721.connect(deployer).grantRole(await tokenManagerERC721.TOKEN_REGISTRAR_ROLE(), schainOwner.address); @@ -230,11 +230,11 @@ describe("ERC721MintingFromSchainToMainnet", () => { // await lockAndDataForSchain.setContract("ERC20Module", erc20ModuleForSchain.address); // await lockAndDataForSchain.setContract("ERC721Module", erc721ModuleForSchain.address); // await lockAndDataForSchain.setContract("TokenManager", tokenManager.address); - // await lockAndDataForSchain.setContract("MessageProxy", await messageProxyForSchain.getAddress()); + // await lockAndDataForSchain.setContract("MessageProxy", messageProxyForSchain); // await lockAndDataForSchain.setContract("TokenFactory", tokenFactory.address); // IMA registration - await imaLinker.connectSchain(schainName, [await communityLocker.getAddress(), await tokenManagerLinker.getAddress()]); + await imaLinker.connectSchain(schainName, [communityLocker, tokenManagerLinker]); // await communityPool.connect(user).rechargeUserWallet(schainName, { value: 1e18.toString() }); // await lockAndDataForSchain.addDepositBox(depositBoxEth.address); // await lockAndDataForSchain.addDepositBox(depositBoxERC20.address); @@ -269,27 +269,27 @@ describe("ERC721MintingFromSchainToMainnet", () => { const extensionMainnetFactory = await ethers.getContractFactory("ERC721ReferenceMintAndMetadataMainnet"); extensionMainnet = await extensionMainnetFactory.deploy( - await messageProxyForMainnet.getAddress(), - await ERC721TokenOnMainnet.getAddress(), + messageProxyForMainnet, + ERC721TokenOnMainnet, schainName ) as ERC721ReferenceMintAndMetadataMainnet; extensionSchain = await extensionSchainFactory.deploy( - await messageProxyForSchain.getAddress(), - await ERC721TokenOnSchain.getAddress(), - await extensionMainnet.getAddress() + messageProxyForSchain, + ERC721TokenOnSchain, + extensionMainnet ) as ERC721ReferenceMintAndMetadataSchain; - await extensionMainnet.connect(deployer).setSenderContractOnSchain(await extensionSchain.getAddress()); + await extensionMainnet.connect(deployer).setSenderContractOnSchain(extensionSchain); // add minter role const minterRoleERC721 = await ERC721TokenOnMainnet.MINTER_ROLE(); - await ERC721TokenOnMainnet.grantRole(minterRoleERC721, await extensionMainnet.getAddress()); + await ERC721TokenOnMainnet.grantRole(minterRoleERC721, extensionMainnet); }); it("should not send message if not registered", async () => { await ERC721TokenOnSchain.connect(user).setTokenURI(1, "MyToken1"); - await ERC721TokenOnSchain.connect(user).approve(await extensionSchain.getAddress(), 1); + await ERC721TokenOnSchain.connect(user).approve(extensionSchain, 1); await extensionSchain.connect(user).sendTokenToMainnet(user.address, 1).should.be.eventually.rejectedWith("Sender contract is not registered"); }); @@ -297,22 +297,22 @@ describe("ERC721MintingFromSchainToMainnet", () => { const tokenURI = "MyToken1"; const mainnetHash = ethers.id("Mainnet"); await ERC721TokenOnSchain.connect(user).setTokenURI(1, tokenURI); - await ERC721TokenOnSchain.connect(user).approve(await extensionSchain.getAddress(), 1); - await messageProxyForSchain.connect(deployer).registerExtraContract("Mainnet", await extensionSchain.getAddress()); + await ERC721TokenOnSchain.connect(user).approve(extensionSchain, 1); + await messageProxyForSchain.connect(deployer).registerExtraContract("Mainnet", extensionSchain); const res = await extensionSchain.connect(user).sendTokenToMainnet(user.address, 1); const encodedData = ethers.AbiCoder.defaultAbiCoder().encode(["address", "uint", "string"], [user.address, 1, tokenURI]); await expect(res) .to.emit(messageProxyForSchain, "OutgoingMessage") - .withArgs(mainnetHash, 0, await extensionSchain.getAddress(), await extensionMainnet.getAddress(), encodedData); + .withArgs(mainnetHash, 0, extensionSchain, extensionMainnet, encodedData); }); it("should POST message for token 1", async () => { const dataToPost = await extensionSchain.connect(user).encodeParams(user.address, 1, "MyToken1"); const message = { data: dataToPost, - destinationContract: await extensionMainnet.getAddress(), - sender: await extensionSchain.getAddress(), + destinationContract: extensionMainnet, + sender: extensionSchain, }; // prepare BLS signature @@ -355,7 +355,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { const message = { data: dataToPost, destinationContract: user.address, - sender: await extensionSchain.getAddress(), + sender: extensionSchain, }; // prepare BLS signature @@ -395,8 +395,8 @@ describe("ERC721MintingFromSchainToMainnet", () => { const dataToPost = await extensionSchain.connect(user).encodeParams(user.address, 5, "MyToken5Unique"); const message = { data: dataToPost, - destinationContract: await extensionMainnet.getAddress(), - sender: await extensionSchain.getAddress(), + destinationContract: extensionMainnet, + sender: extensionSchain, }; // prepare BLS signature diff --git a/test/utils/deploy/mainnet/communityPool.ts b/test/utils/deploy/mainnet/communityPool.ts index 7aa5fd879..fc3221c02 100644 --- a/test/utils/deploy/mainnet/communityPool.ts +++ b/test/utils/deploy/mainnet/communityPool.ts @@ -10,10 +10,14 @@ export async function deployCommunityPool( const factory = await ethers.getContractFactory("CommunityPool"); const instance = await upgrades.deployProxy( factory, - [await contractManager.getAddress(), await linker.getAddress(), await messageProxy.getAddress()], + [ + await contractManager.getAddress(), + await linker.getAddress(), + await messageProxy.getAddress() + ], {"initializer": "initialize(address,address,address)"} ) as unknown as CommunityPool; - await linker.registerMainnetContract(await instance.getAddress()); - await messageProxy.setCommunityPool(await instance.getAddress()); + await linker.registerMainnetContract(instance); + await messageProxy.setCommunityPool(instance); return instance; -} \ No newline at end of file +} diff --git a/test/utils/deploy/mainnet/depositBoxERC1155.ts b/test/utils/deploy/mainnet/depositBoxERC1155.ts index 346859af5..fbc033bec 100644 --- a/test/utils/deploy/mainnet/depositBoxERC1155.ts +++ b/test/utils/deploy/mainnet/depositBoxERC1155.ts @@ -17,6 +17,6 @@ export async function deployDepositBoxERC1155( ], {"initializer": "initialize(address,address,address)"} ) as unknown as DepositBoxERC1155; - await linker.registerMainnetContract(await instance.getAddress()); + await linker.registerMainnetContract(instance); return instance; -} \ No newline at end of file +} diff --git a/test/utils/deploy/mainnet/depositBoxERC20.ts b/test/utils/deploy/mainnet/depositBoxERC20.ts index 8c4043220..27fb92d22 100644 --- a/test/utils/deploy/mainnet/depositBoxERC20.ts +++ b/test/utils/deploy/mainnet/depositBoxERC20.ts @@ -17,6 +17,6 @@ export async function deployDepositBoxERC20( ], {"initializer": "initialize(address,address,address)"} ) as unknown as DepositBoxERC20; - await linker.registerMainnetContract(await instance.getAddress()); + await linker.registerMainnetContract(instance); return instance; -} \ No newline at end of file +} diff --git a/test/utils/deploy/mainnet/depositBoxERC721.ts b/test/utils/deploy/mainnet/depositBoxERC721.ts index 8173630e9..2fa3b0a04 100644 --- a/test/utils/deploy/mainnet/depositBoxERC721.ts +++ b/test/utils/deploy/mainnet/depositBoxERC721.ts @@ -17,6 +17,6 @@ export async function deployDepositBoxERC721( ], {"initializer": "initialize(address,address,address)"} ) as unknown as DepositBoxERC721; - await linker.registerMainnetContract(await instance.getAddress()); + await linker.registerMainnetContract(instance); return instance; -} \ No newline at end of file +} diff --git a/test/utils/deploy/mainnet/depositBoxERC721WithMetadata.ts b/test/utils/deploy/mainnet/depositBoxERC721WithMetadata.ts index dbba0d6ac..8fed2b386 100644 --- a/test/utils/deploy/mainnet/depositBoxERC721WithMetadata.ts +++ b/test/utils/deploy/mainnet/depositBoxERC721WithMetadata.ts @@ -17,6 +17,6 @@ export async function deployDepositBoxERC721WithMetadata( ], {"initializer": "initialize(address,address,address)"} ) as unknown as DepositBoxERC721WithMetadata; - await linker.registerMainnetContract(await instance.getAddress()); + await linker.registerMainnetContract(instance); return instance; -} \ No newline at end of file +} diff --git a/test/utils/deploy/mainnet/depositBoxEth.ts b/test/utils/deploy/mainnet/depositBoxEth.ts index 727f782c9..956af2c97 100644 --- a/test/utils/deploy/mainnet/depositBoxEth.ts +++ b/test/utils/deploy/mainnet/depositBoxEth.ts @@ -17,6 +17,6 @@ export async function deployDepositBoxEth( ], {"initializer": "initialize(address,address,address)"} ) as unknown as DepositBoxEth; - await linker.registerMainnetContract(await instance.getAddress()); + await linker.registerMainnetContract(instance); return instance; -} \ No newline at end of file +} diff --git a/test/utils/deploy/mainnet/linker.ts b/test/utils/deploy/mainnet/linker.ts index 875b4023f..7aa6debd3 100644 --- a/test/utils/deploy/mainnet/linker.ts +++ b/test/utils/deploy/mainnet/linker.ts @@ -14,6 +14,6 @@ export async function deployLinker( ], {"initializer": "initialize(address,address)"} ) as unknown as Linker; - await instance.registerMainnetContract(await instance.getAddress()); + await instance.registerMainnetContract(instance); return instance; -} \ No newline at end of file +} diff --git a/test/utils/deploy/mainnet/messageProxyForMainnet.ts b/test/utils/deploy/mainnet/messageProxyForMainnet.ts index 228d42625..e169c9312 100644 --- a/test/utils/deploy/mainnet/messageProxyForMainnet.ts +++ b/test/utils/deploy/mainnet/messageProxyForMainnet.ts @@ -11,7 +11,7 @@ export async function deployMessageProxyForMainnet( return factory.attach(await contractManager.getContract(name)) as MessageProxyForMainnet; } else { const instance = await upgrades.deployProxy(factory, [await contractManager.getAddress()]) as unknown as MessageProxyForMainnet; - await contractManager.setContractsAddress(name, await instance.getAddress()); + await contractManager.setContractsAddress(name, instance); return instance; } -} \ No newline at end of file +} diff --git a/test/utils/deploy/schain/communityLocker.ts b/test/utils/deploy/schain/communityLocker.ts index f46f67fb2..51ee758a8 100644 --- a/test/utils/deploy/schain/communityLocker.ts +++ b/test/utils/deploy/schain/communityLocker.ts @@ -1,18 +1,23 @@ import { ethers, upgrades } from "hardhat"; -import { CommunityLocker, TokenManagerLinker } from "../../../../typechain"; +import { CommunityLocker, MessageProxyForSchain, TokenManagerLinker } from "../../../../typechain"; const name = "CommunityLocker"; export async function deployCommunityLocker( schainName: string, - messageProxyForSchain: string, + messageProxyForSchain: MessageProxyForSchain, tokenManagerLinker: TokenManagerLinker, communityPool: string ) { const factory = await ethers.getContractFactory(name); const instance = await upgrades.deployProxy( factory, - [schainName, messageProxyForSchain, await tokenManagerLinker.getAddress(), communityPool] + [ + schainName, + await messageProxyForSchain.getAddress(), + await tokenManagerLinker.getAddress(), + communityPool + ] ) as unknown as CommunityLocker; return instance; } diff --git a/test/utils/deploy/schain/tokenManagerERC1155.ts b/test/utils/deploy/schain/tokenManagerERC1155.ts index ee2f2636f..5580bfe0f 100644 --- a/test/utils/deploy/schain/tokenManagerERC1155.ts +++ b/test/utils/deploy/schain/tokenManagerERC1155.ts @@ -1,11 +1,11 @@ import { ethers, upgrades } from "hardhat"; -import { TokenManagerERC1155, TokenManagerLinker, CommunityLocker } from "../../../../typechain"; +import { TokenManagerERC1155, TokenManagerLinker, CommunityLocker, MessageProxyForSchain } from "../../../../typechain"; const name = "TokenManagerERC1155"; export async function deployTokenManagerERC1155( schainName: string, - messageProxyForSchain: string, + messageProxyForSchain: MessageProxyForSchain, tokenManagerLinker: TokenManagerLinker, communityLocker: CommunityLocker, newDepositBox: string @@ -15,7 +15,7 @@ export async function deployTokenManagerERC1155( factory, [ schainName, - messageProxyForSchain, + await messageProxyForSchain.getAddress(), await tokenManagerLinker.getAddress(), await communityLocker.getAddress(), newDepositBox diff --git a/test/utils/deploy/schain/tokenManagerERC20.ts b/test/utils/deploy/schain/tokenManagerERC20.ts index 2e582520f..1f9dda8e8 100644 --- a/test/utils/deploy/schain/tokenManagerERC20.ts +++ b/test/utils/deploy/schain/tokenManagerERC20.ts @@ -1,11 +1,11 @@ import { ethers, upgrades } from "hardhat"; -import { TokenManagerERC20, TokenManagerLinker, CommunityLocker } from "../../../../typechain"; +import { TokenManagerERC20, TokenManagerLinker, CommunityLocker, MessageProxyForSchain } from "../../../../typechain"; const name = "TokenManagerERC20"; export async function deployTokenManagerERC20( schainName: string, - messageProxyForSchain: string, + messageProxyForSchain: MessageProxyForSchain, tokenManagerLinker: TokenManagerLinker, communityLocker: CommunityLocker, newDepositBox: string @@ -15,7 +15,7 @@ export async function deployTokenManagerERC20( factory, [ schainName, - messageProxyForSchain, + await messageProxyForSchain.getAddress(), await tokenManagerLinker.getAddress(), await communityLocker.getAddress(), newDepositBox diff --git a/test/utils/deploy/schain/tokenManagerERC721.ts b/test/utils/deploy/schain/tokenManagerERC721.ts index 3e788fe0b..198543e42 100644 --- a/test/utils/deploy/schain/tokenManagerERC721.ts +++ b/test/utils/deploy/schain/tokenManagerERC721.ts @@ -1,11 +1,11 @@ import { ethers, upgrades } from "hardhat"; -import { TokenManagerERC721, TokenManagerLinker, CommunityLocker } from "../../../../typechain"; +import { TokenManagerERC721, TokenManagerLinker, CommunityLocker, MessageProxyForSchain } from "../../../../typechain"; const name = "TokenManagerERC721"; export async function deployTokenManagerERC721( schainName: string, - messageProxyForSchain: string, + messageProxyForSchain: MessageProxyForSchain, tokenManagerLinker: TokenManagerLinker, communityLocker: CommunityLocker, newDepositBox: string @@ -15,7 +15,7 @@ export async function deployTokenManagerERC721( factory, [ schainName, - messageProxyForSchain, + await messageProxyForSchain.getAddress(), await tokenManagerLinker.getAddress(), await communityLocker.getAddress(), newDepositBox diff --git a/test/utils/deploy/schain/tokenManagerERC721WithMetadata.ts b/test/utils/deploy/schain/tokenManagerERC721WithMetadata.ts index c9510508c..5a6108502 100644 --- a/test/utils/deploy/schain/tokenManagerERC721WithMetadata.ts +++ b/test/utils/deploy/schain/tokenManagerERC721WithMetadata.ts @@ -1,11 +1,11 @@ import { ethers, upgrades } from "hardhat"; -import { TokenManagerERC721WithMetadata, TokenManagerLinker, CommunityLocker } from "../../../../typechain"; +import { TokenManagerERC721WithMetadata, TokenManagerLinker, CommunityLocker, MessageProxyForSchain } from "../../../../typechain"; const name = "TokenManagerERC721WithMetadata"; export async function deployTokenManagerERC721WithMetadata( schainName: string, - messageProxyForSchain: string, + messageProxyForSchain: MessageProxyForSchain, tokenManagerLinker: TokenManagerLinker, communityLocker: CommunityLocker, newDepositBox: string @@ -15,7 +15,7 @@ export async function deployTokenManagerERC721WithMetadata( factory, [ schainName, - messageProxyForSchain, + await messageProxyForSchain.getAddress(), await tokenManagerLinker.getAddress(), await communityLocker.getAddress(), newDepositBox diff --git a/test/utils/deploy/schain/tokenManagerEth.ts b/test/utils/deploy/schain/tokenManagerEth.ts index 50b814317..2af3a232a 100644 --- a/test/utils/deploy/schain/tokenManagerEth.ts +++ b/test/utils/deploy/schain/tokenManagerEth.ts @@ -1,11 +1,11 @@ import { ethers, upgrades } from "hardhat"; -import { TokenManagerEth, TokenManagerLinker, CommunityLocker } from "../../../../typechain"; +import { TokenManagerEth, TokenManagerLinker, CommunityLocker, MessageProxyForSchain } from "../../../../typechain"; const name = "TokenManagerEth"; export async function deployTokenManagerEth( schainName: string, - messageProxyForSchain: string, + messageProxyForSchain: MessageProxyForSchain, tokenManagerLinker: TokenManagerLinker, communityLocker: CommunityLocker, newDepositBox: string, @@ -16,7 +16,7 @@ export async function deployTokenManagerEth( factory, [ schainName, - messageProxyForSchain, + await messageProxyForSchain.getAddress(), await tokenManagerLinker.getAddress(), await communityLocker.getAddress(), newDepositBox, diff --git a/test/utils/deploy/schain/tokenManagerLinker.ts b/test/utils/deploy/schain/tokenManagerLinker.ts index b569d79b2..11c8ff9bc 100644 --- a/test/utils/deploy/schain/tokenManagerLinker.ts +++ b/test/utils/deploy/schain/tokenManagerLinker.ts @@ -6,6 +6,12 @@ export async function deployTokenManagerLinker( newLinkerAddress: string ) { const factory = await ethers.getContractFactory("TokenManagerLinker"); - const instance = await upgrades.deployProxy(factory, [await messageProxyForSchain.getAddress(), newLinkerAddress]) as unknown as TokenManagerLinker; + const instance = await upgrades.deployProxy( + factory, + [ + await messageProxyForSchain.getAddress(), + newLinkerAddress + ] + ) as unknown as TokenManagerLinker; return instance; } diff --git a/test/utils/deploy/test/communityPoolTester.ts b/test/utils/deploy/test/communityPoolTester.ts index da44bc793..3803f4fe6 100644 --- a/test/utils/deploy/test/communityPoolTester.ts +++ b/test/utils/deploy/test/communityPoolTester.ts @@ -17,7 +17,7 @@ export async function deployCommunityPoolTester( ], {"initializer": "initialize(address,address,address)"} ) as unknown as CommunityPool; - await linker.registerMainnetContract(await instance.getAddress()); - await messageProxy.setCommunityPool(await instance.getAddress()); + await linker.registerMainnetContract(instance); + await messageProxy.setCommunityPool(instance); return instance; -} \ No newline at end of file +} diff --git a/test/utils/deploy/test/fallbackEthTester.ts b/test/utils/deploy/test/fallbackEthTester.ts index afcd47f63..8a9208cc5 100644 --- a/test/utils/deploy/test/fallbackEthTester.ts +++ b/test/utils/deploy/test/fallbackEthTester.ts @@ -14,4 +14,4 @@ export async function deployFallbackEthTester( schainName ) as FallbackEthTester; return instance; -} \ No newline at end of file +} diff --git a/test/utils/deploy/test/messageProxyForMainnetTester.ts b/test/utils/deploy/test/messageProxyForMainnetTester.ts index ec3be70ba..2a2ac35eb 100644 --- a/test/utils/deploy/test/messageProxyForMainnetTester.ts +++ b/test/utils/deploy/test/messageProxyForMainnetTester.ts @@ -14,7 +14,7 @@ export async function deployMessageProxyForMainnetTester( factory, [await contractManager.getAddress()] ) as unknown as MessageProxyForMainnetTester; - await contractManager.setContractsAddress(name, await instance.getAddress()); + await contractManager.setContractsAddress(name, instance); return instance; } -} \ No newline at end of file +} diff --git a/test/utils/deploy/test/messageProxyForSchainTester.ts b/test/utils/deploy/test/messageProxyForSchainTester.ts index 18d88f20c..742a6d55d 100644 --- a/test/utils/deploy/test/messageProxyForSchainTester.ts +++ b/test/utils/deploy/test/messageProxyForSchainTester.ts @@ -1,9 +1,9 @@ import { ethers } from "hardhat"; -import { MessageProxyForSchainTester } from "../../../../typechain"; +import { KeyStorage, MessageProxyForSchainTester } from "../../../../typechain"; const name = "MessageProxyForSchainTester"; -export async function deployMessageProxyForSchainTester(keyStorageAddress: string, schainName: string) { +export async function deployMessageProxyForSchainTester(keyStorageAddress: KeyStorage, schainName: string) { const factory = await ethers.getContractFactory(name); const instance = await factory.deploy(keyStorageAddress, schainName) as MessageProxyForSchainTester; return instance; diff --git a/test/utils/skale-manager-utils/contractManager.ts b/test/utils/skale-manager-utils/contractManager.ts index a01b0eafc..6c21724a2 100644 --- a/test/utils/skale-manager-utils/contractManager.ts +++ b/test/utils/skale-manager-utils/contractManager.ts @@ -17,30 +17,30 @@ export async function deployContractManager(contractManagerAddress: string) { } if (await instance.getContract("KeyStorage") === "0x0000000000000000000000000000000000000000") { const keyStorageInstance = await (await ethers.getContractFactory("KeyStorageMock")).deploy() as KeyStorageMock; - await instance.setContractsAddress("KeyStorage", await keyStorageInstance.getAddress()); + await instance.setContractsAddress("KeyStorage", keyStorageInstance); } if (await instance.getContract(nameNodes) === "0x0000000000000000000000000000000000000000") { const nodesInstance = await (await ethers.getContractFactory(nameNodes)).deploy() as Nodes; - await instance.setContractsAddress(nameNodes, await nodesInstance.getAddress()); + await instance.setContractsAddress(nameNodes, nodesInstance); } if (await instance.getContract(nameSchains) === "0x0000000000000000000000000000000000000000") { const schainsInstance = await (await ethers.getContractFactory(nameSchains)).deploy() as Schains; - await schainsInstance.addContractManager(await instance.getAddress()); - await instance.setContractsAddress(nameSchains, await schainsInstance.getAddress()); + await schainsInstance.addContractManager(instance); + await instance.setContractsAddress(nameSchains, schainsInstance); } if (await instance.getContract(nameSchainsInternal) === "0x0000000000000000000000000000000000000000") { const schainsInternalInstance = await (await ethers.getContractFactory(nameSchainsInternal)).deploy() as SchainsInternal; - await schainsInternalInstance.addContractManager(await instance.getAddress()); - await instance.setContractsAddress(nameSchainsInternal, await schainsInternalInstance.getAddress()); + await schainsInternalInstance.addContractManager(instance); + await instance.setContractsAddress(nameSchainsInternal, schainsInternalInstance); } if (await instance.getContract(nameSkaleVerifier) === "0x0000000000000000000000000000000000000000") { const skaleVerifierInstance = await (await ethers.getContractFactory(nameSkaleVerifier)).deploy() as SkaleVerifierMock; - await instance.setContractsAddress("SkaleVerifier", await skaleVerifierInstance.getAddress()); + await instance.setContractsAddress("SkaleVerifier", skaleVerifierInstance); } if (await instance.getContract(nameWallets) === "0x0000000000000000000000000000000000000000") { const walletsInstance = await (await ethers.getContractFactory(nameWallets)).deploy() as Wallets; - await walletsInstance.addContractManager(await instance.getAddress()); - await instance.setContractsAddress(nameWallets, await walletsInstance.getAddress()); + await walletsInstance.addContractManager(instance); + await instance.setContractsAddress(nameWallets, walletsInstance); } return instance; } diff --git a/test/utils/skale-manager-utils/keyStorage.ts b/test/utils/skale-manager-utils/keyStorage.ts index a0b03df6b..b5bc9ff2e 100644 --- a/test/utils/skale-manager-utils/keyStorage.ts +++ b/test/utils/skale-manager-utils/keyStorage.ts @@ -22,7 +22,7 @@ export async function setCommonPublicKey( if (await contractManager.getContract("KeyStorage") === "0x0000000000000000000000000000000000000000") { console.log("Schains Internal deployment"); keyStorageInstance = await factory.deploy() as KeyStorageMock; - await contractManager.setContractsAddress("KeyStorage", await keyStorageInstance.getAddress()); + await contractManager.setContractsAddress("KeyStorage", keyStorageInstance); } else { keyStorageInstance = factory.attach(await contractManager.getContract("KeyStorage")) as KeyStorageMock; } diff --git a/test/utils/skale-manager-utils/schainsInternal.ts b/test/utils/skale-manager-utils/schainsInternal.ts index 1ebcadd09..b0e8753a0 100644 --- a/test/utils/skale-manager-utils/schainsInternal.ts +++ b/test/utils/skale-manager-utils/schainsInternal.ts @@ -37,7 +37,7 @@ export async function isSchainActive( if (await contractManager.getContract(nameSchainsInternal) === "0x0000000000000000000000000000000000000000") { console.log("Schains Internal deployment"); schainsInternalInstance = await factory.deploy() as SchainsInternal; - await contractManager.setContractsAddress(nameSchainsInternal, await schainsInternalInstance.getAddress()); + await contractManager.setContractsAddress(nameSchainsInternal, schainsInternalInstance); } else { schainsInternalInstance = factory.attach(await contractManager.getContract(nameSchainsInternal)) as SchainsInternal; } diff --git a/test/utils/skale-manager-utils/wallets.ts b/test/utils/skale-manager-utils/wallets.ts index 84c3a80bd..3697b60b2 100644 --- a/test/utils/skale-manager-utils/wallets.ts +++ b/test/utils/skale-manager-utils/wallets.ts @@ -15,8 +15,8 @@ export async function rechargeSchainWallet( if (await contractManager.getContract(nameWallets) === "0x0000000000000000000000000000000000000000") { console.log("Schains Internal deployment"); walletsInstance = await walletsFactory.deploy() as Wallets; - await walletsInstance.addContractManager(await contractManager.getAddress()); - await contractManager.setContractsAddress(nameWallets, await walletsInstance.getAddress()); + await walletsInstance.addContractManager(contractManager); + await contractManager.setContractsAddress(nameWallets, walletsInstance); } else { walletsInstance = await walletsFactory.attach(await contractManager.getContract(nameWallets)) as Wallets; }