From e67afdca0091ec8be7af1b3e0d0111e13db0e660 Mon Sep 17 00:00:00 2001 From: leovct Date: Fri, 17 Nov 2023 11:26:28 +0100 Subject: [PATCH 01/14] fix: initialise child ERC20 tokens --- migrations/5_deploy_child_contracts.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/migrations/5_deploy_child_contracts.js b/migrations/5_deploy_child_contracts.js index b7fd60283..e5b04caa0 100644 --- a/migrations/5_deploy_child_contracts.js +++ b/migrations/5_deploy_child_contracts.js @@ -27,6 +27,7 @@ module.exports = async function(deployer, network, accounts) { 18, false // _isERC721 ) + await MaticWeth.changeChildChain(ChildChain.address) let TestToken = await childChain.addToken( accounts[0], @@ -36,6 +37,7 @@ module.exports = async function(deployer, network, accounts) { 18, false // _isERC721 ) + await TestToken.changeChildChain(ChildChain.address) let RootERC721 = await childChain.addToken( accounts[0], @@ -45,6 +47,7 @@ module.exports = async function(deployer, network, accounts) { 0, true // _isERC721 ) + await RootERC721.changeChildChain(ChildChain.address) const maticToken = await MRC20.at('0x0000000000000000000000000000000000001010') const maticOwner = await maticToken.owner() From 17d9bcbbed844dc618576ceb80324ea6e3fe3572 Mon Sep 17 00:00:00 2001 From: leovct Date: Fri, 17 Nov 2023 12:25:55 +0100 Subject: [PATCH 02/14] test --- migrations/5_deploy_child_contracts.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/migrations/5_deploy_child_contracts.js b/migrations/5_deploy_child_contracts.js index e5b04caa0..f285f9e83 100644 --- a/migrations/5_deploy_child_contracts.js +++ b/migrations/5_deploy_child_contracts.js @@ -5,6 +5,7 @@ const SafeMath = artifacts.require( ) const ChildChain = artifacts.require('ChildChain') const MRC20 = artifacts.require('MRC20') +const ChildToken = artifacts.require('ChildToken') module.exports = async function(deployer, network, accounts) { if (deployer.network !== 'bor') { @@ -27,9 +28,9 @@ module.exports = async function(deployer, network, accounts) { 18, false // _isERC721 ) - await MaticWeth.changeChildChain(ChildChain.address) + //await MaticWeth.changeChildChain(ChildChain.address) - let TestToken = await childChain.addToken( + const addTestTokenToChildChainTx = await childChain.addToken( accounts[0], contractAddresses.root.tokens.TestToken, 'Test Token', @@ -37,7 +38,9 @@ module.exports = async function(deployer, network, accounts) { 18, false // _isERC721 ) - await TestToken.changeChildChain(ChildChain.address) + const childTestTokenAddress = addTestTokenToChildChainTx.logs.find(log => log.event === 'NewToken').args.token + const childTesTokenContract = await ChildToken.at(childTestTokenAddress) + await childTesTokenContract.changeChildChain(ChildChain.address, {from: ChildChain.address}) let RootERC721 = await childChain.addToken( accounts[0], @@ -47,7 +50,7 @@ module.exports = async function(deployer, network, accounts) { 0, true // _isERC721 ) - await RootERC721.changeChildChain(ChildChain.address) + //await RootERC721.changeChildChain(ChildChain.address) const maticToken = await MRC20.at('0x0000000000000000000000000000000000001010') const maticOwner = await maticToken.owner() From 5bfac7e7f06a0433a4df049b5d2f1b7ae463b766 Mon Sep 17 00:00:00 2001 From: leovct Date: Thu, 23 Nov 2023 18:10:55 +0100 Subject: [PATCH 03/14] fix: update child chain address of newly created tokens --- migrations/5_deploy_child_contracts.js | 31 +++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/migrations/5_deploy_child_contracts.js b/migrations/5_deploy_child_contracts.js index f285f9e83..ae78a7927 100644 --- a/migrations/5_deploy_child_contracts.js +++ b/migrations/5_deploy_child_contracts.js @@ -5,7 +5,8 @@ const SafeMath = artifacts.require( ) const ChildChain = artifacts.require('ChildChain') const MRC20 = artifacts.require('MRC20') -const ChildToken = artifacts.require('ChildToken') +const ChildERC20 = artifacts.require('ChildERC20') +const ChildERC721 = artifacts.require('ChildERC721') module.exports = async function(deployer, network, accounts) { if (deployer.network !== 'bor') { @@ -20,7 +21,7 @@ module.exports = async function(deployer, network, accounts) { const childChain = await ChildChain.deployed() const contractAddresses = utils.getContractAddresses() - let MaticWeth = await childChain.addToken( + const maticWethTx = await childChain.addToken( accounts[0], contractAddresses.root.tokens.MaticWeth, 'ETH on Matic', @@ -28,9 +29,11 @@ module.exports = async function(deployer, network, accounts) { 18, false // _isERC721 ) - //await MaticWeth.changeChildChain(ChildChain.address) + const maticWethAddress = maticWethTx.logs.find(log => log.event === 'NewToken').args.token + const maticWethContract = await ChildERC20.at(maticWethAddress) + await maticWethContract.changeChildChain(contractAddresses.child.ChildChain, {from: accounts[0]}) - const addTestTokenToChildChainTx = await childChain.addToken( + const testERC20Tx = await childChain.addToken( accounts[0], contractAddresses.root.tokens.TestToken, 'Test Token', @@ -38,11 +41,11 @@ module.exports = async function(deployer, network, accounts) { 18, false // _isERC721 ) - const childTestTokenAddress = addTestTokenToChildChainTx.logs.find(log => log.event === 'NewToken').args.token - const childTesTokenContract = await ChildToken.at(childTestTokenAddress) - await childTesTokenContract.changeChildChain(ChildChain.address, {from: ChildChain.address}) + const testERC20Address = testERC20Tx.logs.find(log => log.event === 'NewToken').args.token + const testERC20Contract = await ChildERC20.at(testERC20Address) + await testERC20Contract.changeChildChain(contractAddresses.child.ChildChain, {from: accounts[0]}) - let RootERC721 = await childChain.addToken( + const testERC721Tx = await childChain.addToken( accounts[0], contractAddresses.root.tokens.RootERC721, 'Test ERC721', @@ -50,7 +53,9 @@ module.exports = async function(deployer, network, accounts) { 0, true // _isERC721 ) - //await RootERC721.changeChildChain(ChildChain.address) + const testERC721Address = testERC721Tx.logs.find(log => log.event === 'NewToken').args.token + const testERC721Contract = await ChildERC721.at(maticWethAddress) + await testERC721Contract.changeChildChain(contractAddresses.child.ChildChain, {from: accounts[0]}) const maticToken = await MRC20.at('0x0000000000000000000000000000000000001010') const maticOwner = await maticToken.owner() @@ -61,12 +66,12 @@ module.exports = async function(deployer, network, accounts) { await childChain.mapToken(contractAddresses.root.tokens.MaticToken, '0x0000000000000000000000000000000000001010', false) contractAddresses.child = { - ChildChain: ChildChain.address, + ChildChain: childChain.address, tokens: { - MaticWeth: MaticWeth.logs.find(log => log.event === 'NewToken').args.token, + MaticWeth: maticWethAddress, MaticToken: '0x0000000000000000000000000000000000001010', - TestToken: TestToken.logs.find(log => log.event === 'NewToken').args.token, - RootERC721: RootERC721.logs.find(log => log.event === 'NewToken').args.token + TestToken: testERC20Address, + RootERC721: testERC721Address } } utils.writeContractAddresses(contractAddresses) From c8574960fdf732aec136b62ba99e95ea16997b7e Mon Sep 17 00:00:00 2001 From: leovct Date: Thu, 23 Nov 2023 18:14:41 +0100 Subject: [PATCH 04/14] chore: simplify --- migrations/5_deploy_child_contracts.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/migrations/5_deploy_child_contracts.js b/migrations/5_deploy_child_contracts.js index ae78a7927..9bd637279 100644 --- a/migrations/5_deploy_child_contracts.js +++ b/migrations/5_deploy_child_contracts.js @@ -31,7 +31,7 @@ module.exports = async function(deployer, network, accounts) { ) const maticWethAddress = maticWethTx.logs.find(log => log.event === 'NewToken').args.token const maticWethContract = await ChildERC20.at(maticWethAddress) - await maticWethContract.changeChildChain(contractAddresses.child.ChildChain, {from: accounts[0]}) + await maticWethContract.changeChildChain(childChain.address, {from: accounts[0]}) const testERC20Tx = await childChain.addToken( accounts[0], @@ -43,7 +43,7 @@ module.exports = async function(deployer, network, accounts) { ) const testERC20Address = testERC20Tx.logs.find(log => log.event === 'NewToken').args.token const testERC20Contract = await ChildERC20.at(testERC20Address) - await testERC20Contract.changeChildChain(contractAddresses.child.ChildChain, {from: accounts[0]}) + await testERC20Contract.changeChildChain(childChain.address, {from: accounts[0]}) const testERC721Tx = await childChain.addToken( accounts[0], @@ -55,7 +55,7 @@ module.exports = async function(deployer, network, accounts) { ) const testERC721Address = testERC721Tx.logs.find(log => log.event === 'NewToken').args.token const testERC721Contract = await ChildERC721.at(maticWethAddress) - await testERC721Contract.changeChildChain(contractAddresses.child.ChildChain, {from: accounts[0]}) + await testERC721Contract.changeChildChain(childChain.address, {from: accounts[0]}) const maticToken = await MRC20.at('0x0000000000000000000000000000000000001010') const maticOwner = await maticToken.owner() From a83f1beb45634a189cedffdd7d2ecc32f6a22f54 Mon Sep 17 00:00:00 2001 From: leovct Date: Thu, 23 Nov 2023 18:27:11 +0100 Subject: [PATCH 05/14] chore: rename variables --- migrations/5_deploy_child_contracts.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/migrations/5_deploy_child_contracts.js b/migrations/5_deploy_child_contracts.js index 9bd637279..5be9ce326 100644 --- a/migrations/5_deploy_child_contracts.js +++ b/migrations/5_deploy_child_contracts.js @@ -21,7 +21,7 @@ module.exports = async function(deployer, network, accounts) { const childChain = await ChildChain.deployed() const contractAddresses = utils.getContractAddresses() - const maticWethTx = await childChain.addToken( + const addTokenMaticWethTx = await childChain.addToken( accounts[0], contractAddresses.root.tokens.MaticWeth, 'ETH on Matic', @@ -29,11 +29,11 @@ module.exports = async function(deployer, network, accounts) { 18, false // _isERC721 ) - const maticWethAddress = maticWethTx.logs.find(log => log.event === 'NewToken').args.token - const maticWethContract = await ChildERC20.at(maticWethAddress) - await maticWethContract.changeChildChain(childChain.address, {from: accounts[0]}) + const maticWethAddress = addTokenMaticWethTx.logs.find(log => log.event === 'NewToken').args.token + const maticWeth = await ChildERC20.at(maticWethAddress) + await maticWeth.changeChildChain(childChain.address, {from: accounts[0]}) - const testERC20Tx = await childChain.addToken( + const addTokenTestERC20Tx = await childChain.addToken( accounts[0], contractAddresses.root.tokens.TestToken, 'Test Token', @@ -41,11 +41,11 @@ module.exports = async function(deployer, network, accounts) { 18, false // _isERC721 ) - const testERC20Address = testERC20Tx.logs.find(log => log.event === 'NewToken').args.token - const testERC20Contract = await ChildERC20.at(testERC20Address) - await testERC20Contract.changeChildChain(childChain.address, {from: accounts[0]}) + const testERC20Address = addTokenTestERC20Tx.logs.find(log => log.event === 'NewToken').args.token + const testERC20 = await ChildERC20.at(testERC20Address) + await testERC20.changeChildChain(childChain.address, {from: accounts[0]}) - const testERC721Tx = await childChain.addToken( + const addTokenTestERC721Tx = await childChain.addToken( accounts[0], contractAddresses.root.tokens.RootERC721, 'Test ERC721', @@ -53,9 +53,9 @@ module.exports = async function(deployer, network, accounts) { 0, true // _isERC721 ) - const testERC721Address = testERC721Tx.logs.find(log => log.event === 'NewToken').args.token - const testERC721Contract = await ChildERC721.at(maticWethAddress) - await testERC721Contract.changeChildChain(childChain.address, {from: accounts[0]}) + const testERC721Address = addTokenTestERC721Tx.logs.find(log => log.event === 'NewToken').args.token + const testERC721 = await ChildERC721.at(testERC721Address) + await testERC721.changeChildChain(childChain.address, {from: accounts[0]}) const maticToken = await MRC20.at('0x0000000000000000000000000000000000001010') const maticOwner = await maticToken.owner() From fbec4d0f9d2b402964c4c00b5d5e35460ba991dc Mon Sep 17 00:00:00 2001 From: leovct Date: Thu, 23 Nov 2023 19:20:47 +0100 Subject: [PATCH 06/14] test: update erc20/erc721 deployment --- migrations/5_deploy_child_contracts.js | 69 ++++++++++++-------------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/migrations/5_deploy_child_contracts.js b/migrations/5_deploy_child_contracts.js index 5be9ce326..3968f6626 100644 --- a/migrations/5_deploy_child_contracts.js +++ b/migrations/5_deploy_child_contracts.js @@ -5,8 +5,10 @@ const SafeMath = artifacts.require( ) const ChildChain = artifacts.require('ChildChain') const MRC20 = artifacts.require('MRC20') -const ChildERC20 = artifacts.require('ChildERC20') -const ChildERC721 = artifacts.require('ChildERC721') + +const ChildERC20Proxified = artifacts.require('ChildERC20Proxified') +const ChildERC721Proxified = artifacts.require('ChildERC721Proxified') +const ChildTokenProxy = artifacts.require('ChildTokenProxy') module.exports = async function(deployer, network, accounts) { if (deployer.network !== 'bor') { @@ -21,42 +23,33 @@ module.exports = async function(deployer, network, accounts) { const childChain = await ChildChain.deployed() const contractAddresses = utils.getContractAddresses() - const addTokenMaticWethTx = await childChain.addToken( - accounts[0], - contractAddresses.root.tokens.MaticWeth, - 'ETH on Matic', - 'ETH', - 18, - false // _isERC721 - ) - const maticWethAddress = addTokenMaticWethTx.logs.find(log => log.event === 'NewToken').args.token - const maticWeth = await ChildERC20.at(maticWethAddress) - await maticWeth.changeChildChain(childChain.address, {from: accounts[0]}) + // Deploy MaticWeth (ERC20) child contract and its proxy. + // Initialize the contract, update the child chain and map the token with its root contract. + const childMaticWethProxified = await deployer.deploy(ChildERC20Proxified) + const childMaticWethProxy = await deployer.deploy(ChildTokenProxy, childMaticWethProxified.address) + const childMaticWeth = await ChildERC20Proxified.at(childMaticWethProxy.address) + await childMaticWeth.initialize(contractAddresses.root.tokens.MaticWeth, 'Eth on Matic', 'ETH', 18) + await childMaticWeth.changeChildChain(childChain.address) + await childChain.mapToken(contractAddresses.root.tokens.MaticWeth, childMaticWeth.address, false) + - const addTokenTestERC20Tx = await childChain.addToken( - accounts[0], - contractAddresses.root.tokens.TestToken, - 'Test Token', - 'TST', - 18, - false // _isERC721 - ) - const testERC20Address = addTokenTestERC20Tx.logs.find(log => log.event === 'NewToken').args.token - const testERC20 = await ChildERC20.at(testERC20Address) - await testERC20.changeChildChain(childChain.address, {from: accounts[0]}) + // Same thing for TestToken (ERC20). + const childTestTokenProxified = await deployer.deploy(ChildERC20Proxified) + const childTestTokenProxy = await deployer.deploy(ChildTokenProxy, childTestTokenProxified.address) + const childTestToken = await ChildERC20Proxified.at(childTestTokenProxy.address) + await childTestToken.initialize(contractAddresses.root.tokens.TestToken, 'Test Token', 'TST', 18) + await childTestToken.changeChildChain(childChain.address) + await childChain.mapToken(contractAddresses.root.tokens.TestToken, childTestToken.address, false) - const addTokenTestERC721Tx = await childChain.addToken( - accounts[0], - contractAddresses.root.tokens.RootERC721, - 'Test ERC721', - 'TST721', - 0, - true // _isERC721 - ) - const testERC721Address = addTokenTestERC721Tx.logs.find(log => log.event === 'NewToken').args.token - const testERC721 = await ChildERC721.at(testERC721Address) - await testERC721.changeChildChain(childChain.address, {from: accounts[0]}) + // Same thing for TestERC721. + const childTestERC721Proxified = await deployer.deploy(ChildERC721Proxified) + const childTestERC721Proxy = await deployer.deploy(ChildTokenProxy, childTestERC721Proxified.address) + const childTestERC721 = await ChildERC721Proxified.at(childTestERC721Proxy.address) + await childTestERC721.initialize(contractAddresses.root.tokens.TestToken, 'Test ERC721', 'TST721', 0) + await childTestERC721.changeChildChain(childChain.address) + await childChain.mapToken(contractAddresses.root.tokens.RootERC721, childTestERC721.address, true) // ERC721 + // Initialize and map MaticToken. const maticToken = await MRC20.at('0x0000000000000000000000000000000000001010') const maticOwner = await maticToken.owner() if (maticOwner === '0x0000000000000000000000000000000000000000') { @@ -68,10 +61,10 @@ module.exports = async function(deployer, network, accounts) { contractAddresses.child = { ChildChain: childChain.address, tokens: { - MaticWeth: maticWethAddress, + MaticWeth: childMaticWeth.address, MaticToken: '0x0000000000000000000000000000000000001010', - TestToken: testERC20Address, - RootERC721: testERC721Address + TestToken: childTestToken.address, + RootERC721: childTestERC721.address } } utils.writeContractAddresses(contractAddresses) From 1e5994aae4f8af5462c3aeb969ffdeed516b2ef8 Mon Sep 17 00:00:00 2001 From: leovct Date: Thu, 23 Nov 2023 19:26:57 +0100 Subject: [PATCH 07/14] chore: typo --- migrations/5_deploy_child_contracts.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/migrations/5_deploy_child_contracts.js b/migrations/5_deploy_child_contracts.js index 3968f6626..c88e4a085 100644 --- a/migrations/5_deploy_child_contracts.js +++ b/migrations/5_deploy_child_contracts.js @@ -28,6 +28,7 @@ module.exports = async function(deployer, network, accounts) { const childMaticWethProxified = await deployer.deploy(ChildERC20Proxified) const childMaticWethProxy = await deployer.deploy(ChildTokenProxy, childMaticWethProxified.address) const childMaticWeth = await ChildERC20Proxified.at(childMaticWethProxy.address) + await childMaticWeth.initialize(contractAddresses.root.tokens.MaticWeth, 'Eth on Matic', 'ETH', 18) await childMaticWeth.changeChildChain(childChain.address) await childChain.mapToken(contractAddresses.root.tokens.MaticWeth, childMaticWeth.address, false) @@ -37,6 +38,7 @@ module.exports = async function(deployer, network, accounts) { const childTestTokenProxified = await deployer.deploy(ChildERC20Proxified) const childTestTokenProxy = await deployer.deploy(ChildTokenProxy, childTestTokenProxified.address) const childTestToken = await ChildERC20Proxified.at(childTestTokenProxy.address) + await childTestToken.initialize(contractAddresses.root.tokens.TestToken, 'Test Token', 'TST', 18) await childTestToken.changeChildChain(childChain.address) await childChain.mapToken(contractAddresses.root.tokens.TestToken, childTestToken.address, false) @@ -45,7 +47,8 @@ module.exports = async function(deployer, network, accounts) { const childTestERC721Proxified = await deployer.deploy(ChildERC721Proxified) const childTestERC721Proxy = await deployer.deploy(ChildTokenProxy, childTestERC721Proxified.address) const childTestERC721 = await ChildERC721Proxified.at(childTestERC721Proxy.address) - await childTestERC721.initialize(contractAddresses.root.tokens.TestToken, 'Test ERC721', 'TST721', 0) + + await childTestERC721.initialize(contractAddresses.root.tokens.RootERC721, 'Test ERC721', 'TST721', 0) await childTestERC721.changeChildChain(childChain.address) await childChain.mapToken(contractAddresses.root.tokens.RootERC721, childTestERC721.address, true) // ERC721 From 5e4c46e92c98634e2e63881310b126e0cb54c88c Mon Sep 17 00:00:00 2001 From: leovct Date: Thu, 23 Nov 2023 19:34:31 +0100 Subject: [PATCH 08/14] fix: small issue when initializing erc721 --- migrations/5_deploy_child_contracts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/5_deploy_child_contracts.js b/migrations/5_deploy_child_contracts.js index c88e4a085..001657988 100644 --- a/migrations/5_deploy_child_contracts.js +++ b/migrations/5_deploy_child_contracts.js @@ -48,7 +48,7 @@ module.exports = async function(deployer, network, accounts) { const childTestERC721Proxy = await deployer.deploy(ChildTokenProxy, childTestERC721Proxified.address) const childTestERC721 = await ChildERC721Proxified.at(childTestERC721Proxy.address) - await childTestERC721.initialize(contractAddresses.root.tokens.RootERC721, 'Test ERC721', 'TST721', 0) + await childTestERC721.initialize(contractAddresses.root.tokens.RootERC721, 'Test ERC721', 'TST721') await childTestERC721.changeChildChain(childChain.address) await childChain.mapToken(contractAddresses.root.tokens.RootERC721, childTestERC721.address, true) // ERC721 From d13b0a32b8ce42a4deddcb94f7dd51adba6ed2a5 Mon Sep 17 00:00:00 2001 From: leovct Date: Thu, 23 Nov 2023 20:05:45 +0100 Subject: [PATCH 09/14] chore: use `new` instead of `deploy` --- migrations/5_deploy_child_contracts.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/migrations/5_deploy_child_contracts.js b/migrations/5_deploy_child_contracts.js index 001657988..f6f8e2b91 100644 --- a/migrations/5_deploy_child_contracts.js +++ b/migrations/5_deploy_child_contracts.js @@ -25,8 +25,8 @@ module.exports = async function(deployer, network, accounts) { // Deploy MaticWeth (ERC20) child contract and its proxy. // Initialize the contract, update the child chain and map the token with its root contract. - const childMaticWethProxified = await deployer.deploy(ChildERC20Proxified) - const childMaticWethProxy = await deployer.deploy(ChildTokenProxy, childMaticWethProxified.address) + const childMaticWethProxified = await ChildERC20Proxified.new() + const childMaticWethProxy = await ChildTokenProxy.new(childMaticWethProxified.address) const childMaticWeth = await ChildERC20Proxified.at(childMaticWethProxy.address) await childMaticWeth.initialize(contractAddresses.root.tokens.MaticWeth, 'Eth on Matic', 'ETH', 18) @@ -35,8 +35,8 @@ module.exports = async function(deployer, network, accounts) { // Same thing for TestToken (ERC20). - const childTestTokenProxified = await deployer.deploy(ChildERC20Proxified) - const childTestTokenProxy = await deployer.deploy(ChildTokenProxy, childTestTokenProxified.address) + const childTestTokenProxified = await ChildERC20Proxified.new() + const childTestTokenProxy = await ChildTokenProxy.new(childTestTokenProxified.address) const childTestToken = await ChildERC20Proxified.at(childTestTokenProxy.address) await childTestToken.initialize(contractAddresses.root.tokens.TestToken, 'Test Token', 'TST', 18) @@ -44,8 +44,8 @@ module.exports = async function(deployer, network, accounts) { await childChain.mapToken(contractAddresses.root.tokens.TestToken, childTestToken.address, false) // Same thing for TestERC721. - const childTestERC721Proxified = await deployer.deploy(ChildERC721Proxified) - const childTestERC721Proxy = await deployer.deploy(ChildTokenProxy, childTestERC721Proxified.address) + const childTestERC721Proxified = await ChildERC721Proxified.new() + const childTestERC721Proxy = await ChildTokenProxy.new(childTestERC721Proxified.address) const childTestERC721 = await ChildERC721Proxified.at(childTestERC721Proxy.address) await childTestERC721.initialize(contractAddresses.root.tokens.RootERC721, 'Test ERC721', 'TST721') From 3912f06cf45e88e838ca682a5953198e89b4b493 Mon Sep 17 00:00:00 2001 From: leovct Date: Fri, 24 Nov 2023 16:21:20 +0100 Subject: [PATCH 10/14] chore: nit --- migrations/5_deploy_child_contracts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migrations/5_deploy_child_contracts.js b/migrations/5_deploy_child_contracts.js index f6f8e2b91..18f7726c0 100644 --- a/migrations/5_deploy_child_contracts.js +++ b/migrations/5_deploy_child_contracts.js @@ -4,12 +4,13 @@ const SafeMath = artifacts.require( 'openzeppelin-solidity/contracts/math/SafeMath.sol' ) const ChildChain = artifacts.require('ChildChain') -const MRC20 = artifacts.require('MRC20') const ChildERC20Proxified = artifacts.require('ChildERC20Proxified') const ChildERC721Proxified = artifacts.require('ChildERC721Proxified') const ChildTokenProxy = artifacts.require('ChildTokenProxy') +const MRC20 = artifacts.require('MRC20') + module.exports = async function(deployer, network, accounts) { if (deployer.network !== 'bor') { return @@ -33,7 +34,6 @@ module.exports = async function(deployer, network, accounts) { await childMaticWeth.changeChildChain(childChain.address) await childChain.mapToken(contractAddresses.root.tokens.MaticWeth, childMaticWeth.address, false) - // Same thing for TestToken (ERC20). const childTestTokenProxified = await ChildERC20Proxified.new() const childTestTokenProxy = await ChildTokenProxy.new(childTestTokenProxified.address) From 21b334ab32bc6c7e1d2e75d7f5a4d6fffbdabdfb Mon Sep 17 00:00:00 2001 From: leovct Date: Fri, 24 Nov 2023 16:46:42 +0100 Subject: [PATCH 11/14] test --- migrations/5_deploy_child_contracts.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/migrations/5_deploy_child_contracts.js b/migrations/5_deploy_child_contracts.js index 18f7726c0..a7dcbeb5e 100644 --- a/migrations/5_deploy_child_contracts.js +++ b/migrations/5_deploy_child_contracts.js @@ -11,7 +11,7 @@ const ChildTokenProxy = artifacts.require('ChildTokenProxy') const MRC20 = artifacts.require('MRC20') -module.exports = async function(deployer, network, accounts) { +module.exports = async function(deployer, _, _) { if (deployer.network !== 'bor') { return } @@ -27,30 +27,45 @@ module.exports = async function(deployer, network, accounts) { // Deploy MaticWeth (ERC20) child contract and its proxy. // Initialize the contract, update the child chain and map the token with its root contract. const childMaticWethProxified = await ChildERC20Proxified.new() + console.log('childMaticWethProxified deployed') const childMaticWethProxy = await ChildTokenProxy.new(childMaticWethProxified.address) + console.log('childMaticWethProxy deployed') const childMaticWeth = await ChildERC20Proxified.at(childMaticWethProxy.address) await childMaticWeth.initialize(contractAddresses.root.tokens.MaticWeth, 'Eth on Matic', 'ETH', 18) + console.log('childMaticWeth initialized') await childMaticWeth.changeChildChain(childChain.address) + console.log('childMaticWeth child chain updated') await childChain.mapToken(contractAddresses.root.tokens.MaticWeth, childMaticWeth.address, false) + console.log('root and child maticWeth mapped') // Same thing for TestToken (ERC20). const childTestTokenProxified = await ChildERC20Proxified.new() + console.log('childTestTokenProxified deployed') const childTestTokenProxy = await ChildTokenProxy.new(childTestTokenProxified.address) + console.log('childTestTokenProxy deployed') const childTestToken = await ChildERC20Proxified.at(childTestTokenProxy.address) await childTestToken.initialize(contractAddresses.root.tokens.TestToken, 'Test Token', 'TST', 18) + console.log('childTestToken initialized') await childTestToken.changeChildChain(childChain.address) + console.log('childTestToken child chain updated') await childChain.mapToken(contractAddresses.root.tokens.TestToken, childTestToken.address, false) + console.log('root and child testToken mapped') // Same thing for TestERC721. const childTestERC721Proxified = await ChildERC721Proxified.new() + console.log('childTestERC721Proxified deployed') const childTestERC721Proxy = await ChildTokenProxy.new(childTestERC721Proxified.address) + console.log('childTestERC721Proxy deployed') const childTestERC721 = await ChildERC721Proxified.at(childTestERC721Proxy.address) await childTestERC721.initialize(contractAddresses.root.tokens.RootERC721, 'Test ERC721', 'TST721') + console.log('childTestERC721 initialized') await childTestERC721.changeChildChain(childChain.address) + console.log('childTestERC721 child chain updated') await childChain.mapToken(contractAddresses.root.tokens.RootERC721, childTestERC721.address, true) // ERC721 + console.log('root and child testERC721 mapped') // Initialize and map MaticToken. const maticToken = await MRC20.at('0x0000000000000000000000000000000000001010') From 4bfa48e9008fc0e138e6970260889856832f4dbe Mon Sep 17 00:00:00 2001 From: leovct Date: Mon, 27 Nov 2023 10:32:04 +0100 Subject: [PATCH 12/14] chore: nit --- migrations/5_deploy_child_contracts.js | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/migrations/5_deploy_child_contracts.js b/migrations/5_deploy_child_contracts.js index a7dcbeb5e..29b2e3a42 100644 --- a/migrations/5_deploy_child_contracts.js +++ b/migrations/5_deploy_child_contracts.js @@ -27,45 +27,45 @@ module.exports = async function(deployer, _, _) { // Deploy MaticWeth (ERC20) child contract and its proxy. // Initialize the contract, update the child chain and map the token with its root contract. const childMaticWethProxified = await ChildERC20Proxified.new() - console.log('childMaticWethProxified deployed') + console.log('Child MaticWethProxified contract deployed') const childMaticWethProxy = await ChildTokenProxy.new(childMaticWethProxified.address) - console.log('childMaticWethProxy deployed') + console.log('Child MaticWeth proxy contract deployed') const childMaticWeth = await ChildERC20Proxified.at(childMaticWethProxy.address) await childMaticWeth.initialize(contractAddresses.root.tokens.MaticWeth, 'Eth on Matic', 'ETH', 18) - console.log('childMaticWeth initialized') + console.log('Child MaticWeth contract initialized') await childMaticWeth.changeChildChain(childChain.address) - console.log('childMaticWeth child chain updated') + console.log('Child MaticWeth child chain updated') await childChain.mapToken(contractAddresses.root.tokens.MaticWeth, childMaticWeth.address, false) - console.log('root and child maticWeth mapped') + console.log('Root and child MaticWeth contracts mapped') // Same thing for TestToken (ERC20). const childTestTokenProxified = await ChildERC20Proxified.new() - console.log('childTestTokenProxified deployed') + console.log('Child TestTokenProxified contract deployed') const childTestTokenProxy = await ChildTokenProxy.new(childTestTokenProxified.address) - console.log('childTestTokenProxy deployed') + console.log('Child TestToken proxy contract deployed') const childTestToken = await ChildERC20Proxified.at(childTestTokenProxy.address) await childTestToken.initialize(contractAddresses.root.tokens.TestToken, 'Test Token', 'TST', 18) - console.log('childTestToken initialized') + console.log('Child TestToken contract initialized') await childTestToken.changeChildChain(childChain.address) - console.log('childTestToken child chain updated') + console.log('Child TestToken child chain updated') await childChain.mapToken(contractAddresses.root.tokens.TestToken, childTestToken.address, false) - console.log('root and child testToken mapped') + console.log('Root and child TestToken contracts mapped') // Same thing for TestERC721. const childTestERC721Proxified = await ChildERC721Proxified.new() - console.log('childTestERC721Proxified deployed') + console.log('Child TestERC721Proxified contract deployed') const childTestERC721Proxy = await ChildTokenProxy.new(childTestERC721Proxified.address) - console.log('childTestERC721Proxy deployed') + console.log('Child TestERC721 proxy contract deployed') const childTestERC721 = await ChildERC721Proxified.at(childTestERC721Proxy.address) await childTestERC721.initialize(contractAddresses.root.tokens.RootERC721, 'Test ERC721', 'TST721') - console.log('childTestERC721 initialized') + console.log('Child TestERC721 contract initialized') await childTestERC721.changeChildChain(childChain.address) - console.log('childTestERC721 child chain updated') + console.log('Child TestERC721 child chain updated') await childChain.mapToken(contractAddresses.root.tokens.RootERC721, childTestERC721.address, true) // ERC721 - console.log('root and child testERC721 mapped') + console.log('Root and child testERC721 contracts mapped') // Initialize and map MaticToken. const maticToken = await MRC20.at('0x0000000000000000000000000000000000001010') From 334c53320efc485ef666cb521d3153a2c79fbb2b Mon Sep 17 00:00:00 2001 From: leovct Date: Mon, 27 Nov 2023 10:34:34 +0100 Subject: [PATCH 13/14] chore: update the other migration file --- deploy-migrations/4_deploy_child_contracts.js | 80 ++++++++++++------- 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/deploy-migrations/4_deploy_child_contracts.js b/deploy-migrations/4_deploy_child_contracts.js index 7194ea664..44e8f711e 100644 --- a/deploy-migrations/4_deploy_child_contracts.js +++ b/deploy-migrations/4_deploy_child_contracts.js @@ -4,9 +4,14 @@ const SafeMath = artifacts.require( 'openzeppelin-solidity/contracts/math/SafeMath.sol' ) const ChildChain = artifacts.require('ChildChain') + +const ChildERC20Proxified = artifacts.require('ChildERC20Proxified') +const ChildERC721Proxified = artifacts.require('ChildERC721Proxified') +const ChildTokenProxy = artifacts.require('ChildTokenProxy') + const MRC20 = artifacts.require('MRC20') -module.exports = async function(deployer, network, accounts) { +module.exports = async function(deployer, _, _) { deployer.then(async() => { await deployer.deploy(SafeMath) await deployer.link(SafeMath, [ChildChain]) @@ -15,33 +20,50 @@ module.exports = async function(deployer, network, accounts) { const childChain = await ChildChain.deployed() const contractAddresses = utils.getContractAddresses() - let MaticWeth = await childChain.addToken( - accounts[0], - contractAddresses.root.tokens.MaticWeth, - 'ETH on Matic', - 'ETH', - 18, - false // _isERC721 - ) + // Deploy MaticWeth (ERC20) child contract and its proxy. + // Initialize the contract, update the child chain and map the token with its root contract. + const childMaticWethProxified = await ChildERC20Proxified.new() + console.log('Child MaticWethProxified contract deployed') + const childMaticWethProxy = await ChildTokenProxy.new(childMaticWethProxified.address) + console.log('Child MaticWeth proxy contract deployed') + const childMaticWeth = await ChildERC20Proxified.at(childMaticWethProxy.address) + + await childMaticWeth.initialize(contractAddresses.root.tokens.MaticWeth, 'Eth on Matic', 'ETH', 18) + console.log('Child MaticWeth contract initialized') + await childMaticWeth.changeChildChain(childChain.address) + console.log('Child MaticWeth child chain updated') + await childChain.mapToken(contractAddresses.root.tokens.MaticWeth, childMaticWeth.address, false) + console.log('Root and child MaticWeth contracts mapped') + + // Same thing for TestToken (ERC20). + const childTestTokenProxified = await ChildERC20Proxified.new() + console.log('Child TestTokenProxified contract deployed') + const childTestTokenProxy = await ChildTokenProxy.new(childTestTokenProxified.address) + console.log('Child TestToken proxy contract deployed') + const childTestToken = await ChildERC20Proxified.at(childTestTokenProxy.address) + + await childTestToken.initialize(contractAddresses.root.tokens.TestToken, 'Test Token', 'TST', 18) + console.log('Child TestToken contract initialized') + await childTestToken.changeChildChain(childChain.address) + console.log('Child TestToken child chain updated') + await childChain.mapToken(contractAddresses.root.tokens.TestToken, childTestToken.address, false) + console.log('Root and child TestToken contracts mapped') - let TestToken = await childChain.addToken( - accounts[0], - contractAddresses.root.tokens.TestToken, - 'Test Token', - 'TST', - 18, - false // _isERC721 - ) + // Same thing for TestERC721. + const childTestERC721Proxified = await ChildERC721Proxified.new() + console.log('Child TestERC721Proxified contract deployed') + const childTestERC721Proxy = await ChildTokenProxy.new(childTestERC721Proxified.address) + console.log('Child TestERC721 proxy contract deployed') + const childTestERC721 = await ChildERC721Proxified.at(childTestERC721Proxy.address) - let RootERC721 = await childChain.addToken( - accounts[0], - contractAddresses.root.tokens.RootERC721, - 'Test ERC721', - 'TST721', - 0, - true // _isERC721 - ) + await childTestERC721.initialize(contractAddresses.root.tokens.RootERC721, 'Test ERC721', 'TST721') + console.log('Child TestERC721 contract initialized') + await childTestERC721.changeChildChain(childChain.address) + console.log('Child TestERC721 child chain updated') + await childChain.mapToken(contractAddresses.root.tokens.RootERC721, childTestERC721.address, true) // ERC721 + console.log('Root and child testERC721 contracts mapped') + // Initialize and map MaticToken. const maticToken = await MRC20.at('0x0000000000000000000000000000000000001010') const maticOwner = await maticToken.owner() if (maticOwner === '0x0000000000000000000000000000000000000000') { @@ -51,12 +73,12 @@ module.exports = async function(deployer, network, accounts) { await childChain.mapToken(contractAddresses.root.tokens.MaticToken, '0x0000000000000000000000000000000000001010', false) contractAddresses.child = { - ChildChain: ChildChain.address, + ChildChain: childChain.address, tokens: { - MaticWeth: MaticWeth.logs.find(log => log.event === 'NewToken').args.token, + MaticWeth: childMaticWeth.address, MaticToken: '0x0000000000000000000000000000000000001010', - TestToken: TestToken.logs.find(log => log.event === 'NewToken').args.token, - RootERC721: RootERC721.logs.find(log => log.event === 'NewToken').args.token + TestToken: childTestToken.address, + RootERC721: childTestERC721.address } } utils.writeContractAddresses(contractAddresses) From 861da06a63c9f5e75cfbc838754459862573a8f4 Mon Sep 17 00:00:00 2001 From: leovct Date: Mon, 27 Nov 2023 10:52:13 +0100 Subject: [PATCH 14/14] chore: nit --- deploy-migrations/4_deploy_child_contracts.js | 4 ++-- migrations/5_deploy_child_contracts.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deploy-migrations/4_deploy_child_contracts.js b/deploy-migrations/4_deploy_child_contracts.js index 44e8f711e..bccfbb1b4 100644 --- a/deploy-migrations/4_deploy_child_contracts.js +++ b/deploy-migrations/4_deploy_child_contracts.js @@ -37,7 +37,7 @@ module.exports = async function(deployer, _, _) { // Same thing for TestToken (ERC20). const childTestTokenProxified = await ChildERC20Proxified.new() - console.log('Child TestTokenProxified contract deployed') + console.log('\nChild TestTokenProxified contract deployed') const childTestTokenProxy = await ChildTokenProxy.new(childTestTokenProxified.address) console.log('Child TestToken proxy contract deployed') const childTestToken = await ChildERC20Proxified.at(childTestTokenProxy.address) @@ -51,7 +51,7 @@ module.exports = async function(deployer, _, _) { // Same thing for TestERC721. const childTestERC721Proxified = await ChildERC721Proxified.new() - console.log('Child TestERC721Proxified contract deployed') + console.log('\nChild TestERC721Proxified contract deployed') const childTestERC721Proxy = await ChildTokenProxy.new(childTestERC721Proxified.address) console.log('Child TestERC721 proxy contract deployed') const childTestERC721 = await ChildERC721Proxified.at(childTestERC721Proxy.address) diff --git a/migrations/5_deploy_child_contracts.js b/migrations/5_deploy_child_contracts.js index 29b2e3a42..b405cee3b 100644 --- a/migrations/5_deploy_child_contracts.js +++ b/migrations/5_deploy_child_contracts.js @@ -41,7 +41,7 @@ module.exports = async function(deployer, _, _) { // Same thing for TestToken (ERC20). const childTestTokenProxified = await ChildERC20Proxified.new() - console.log('Child TestTokenProxified contract deployed') + console.log('\nChild TestTokenProxified contract deployed') const childTestTokenProxy = await ChildTokenProxy.new(childTestTokenProxified.address) console.log('Child TestToken proxy contract deployed') const childTestToken = await ChildERC20Proxified.at(childTestTokenProxy.address) @@ -55,7 +55,7 @@ module.exports = async function(deployer, _, _) { // Same thing for TestERC721. const childTestERC721Proxified = await ChildERC721Proxified.new() - console.log('Child TestERC721Proxified contract deployed') + console.log('\nChild TestERC721Proxified contract deployed') const childTestERC721Proxy = await ChildTokenProxy.new(childTestERC721Proxified.address) console.log('Child TestERC721 proxy contract deployed') const childTestERC721 = await ChildERC721Proxified.at(childTestERC721Proxy.address)