@@ -4,9 +4,14 @@ const SafeMath = artifacts.require(
44 'openzeppelin-solidity/contracts/math/SafeMath.sol'
55)
66const ChildChain = artifacts . require ( 'ChildChain' )
7+
8+ const ChildERC20Proxified = artifacts . require ( 'ChildERC20Proxified' )
9+ const ChildERC721Proxified = artifacts . require ( 'ChildERC721Proxified' )
10+ const ChildTokenProxy = artifacts . require ( 'ChildTokenProxy' )
11+
712const MRC20 = artifacts . require ( 'MRC20' )
813
9- module . exports = async function ( deployer , network , accounts ) {
14+ module . exports = async function ( deployer , _ , _ ) {
1015 deployer . then ( async ( ) => {
1116 await deployer . deploy ( SafeMath )
1217 await deployer . link ( SafeMath , [ ChildChain ] )
@@ -15,33 +20,50 @@ module.exports = async function(deployer, network, accounts) {
1520 const childChain = await ChildChain . deployed ( )
1621 const contractAddresses = utils . getContractAddresses ( )
1722
18- let MaticWeth = await childChain . addToken (
19- accounts [ 0 ] ,
20- contractAddresses . root . tokens . MaticWeth ,
21- 'ETH on Matic' ,
22- 'ETH' ,
23- 18 ,
24- false // _isERC721
25- )
23+ // Deploy MaticWeth (ERC20) child contract and its proxy.
24+ // Initialize the contract, update the child chain and map the token with its root contract.
25+ const childMaticWethProxified = await ChildERC20Proxified . new ( )
26+ console . log ( 'Child MaticWethProxified contract deployed' )
27+ const childMaticWethProxy = await ChildTokenProxy . new ( childMaticWethProxified . address )
28+ console . log ( 'Child MaticWeth proxy contract deployed' )
29+ const childMaticWeth = await ChildERC20Proxified . at ( childMaticWethProxy . address )
30+
31+ await childMaticWeth . initialize ( contractAddresses . root . tokens . MaticWeth , 'Eth on Matic' , 'ETH' , 18 )
32+ console . log ( 'Child MaticWeth contract initialized' )
33+ await childMaticWeth . changeChildChain ( childChain . address )
34+ console . log ( 'Child MaticWeth child chain updated' )
35+ await childChain . mapToken ( contractAddresses . root . tokens . MaticWeth , childMaticWeth . address , false )
36+ console . log ( 'Root and child MaticWeth contracts mapped' )
37+
38+ // Same thing for TestToken (ERC20).
39+ const childTestTokenProxified = await ChildERC20Proxified . new ( )
40+ console . log ( '\nChild TestTokenProxified contract deployed' )
41+ const childTestTokenProxy = await ChildTokenProxy . new ( childTestTokenProxified . address )
42+ console . log ( 'Child TestToken proxy contract deployed' )
43+ const childTestToken = await ChildERC20Proxified . at ( childTestTokenProxy . address )
44+
45+ await childTestToken . initialize ( contractAddresses . root . tokens . TestToken , 'Test Token' , 'TST' , 18 )
46+ console . log ( 'Child TestToken contract initialized' )
47+ await childTestToken . changeChildChain ( childChain . address )
48+ console . log ( 'Child TestToken child chain updated' )
49+ await childChain . mapToken ( contractAddresses . root . tokens . TestToken , childTestToken . address , false )
50+ console . log ( 'Root and child TestToken contracts mapped' )
2651
27- let TestToken = await childChain . addToken (
28- accounts [ 0 ] ,
29- contractAddresses . root . tokens . TestToken ,
30- 'Test Token' ,
31- 'TST' ,
32- 18 ,
33- false // _isERC721
34- )
52+ // Same thing for TestERC721.
53+ const childTestERC721Proxified = await ChildERC721Proxified . new ( )
54+ console . log ( '\nChild TestERC721Proxified contract deployed' )
55+ const childTestERC721Proxy = await ChildTokenProxy . new ( childTestERC721Proxified . address )
56+ console . log ( 'Child TestERC721 proxy contract deployed' )
57+ const childTestERC721 = await ChildERC721Proxified . at ( childTestERC721Proxy . address )
3558
36- let RootERC721 = await childChain . addToken (
37- accounts [ 0 ] ,
38- contractAddresses . root . tokens . RootERC721 ,
39- 'Test ERC721' ,
40- 'TST721' ,
41- 0 ,
42- true // _isERC721
43- )
59+ await childTestERC721 . initialize ( contractAddresses . root . tokens . RootERC721 , 'Test ERC721' , 'TST721' )
60+ console . log ( 'Child TestERC721 contract initialized' )
61+ await childTestERC721 . changeChildChain ( childChain . address )
62+ console . log ( 'Child TestERC721 child chain updated' )
63+ await childChain . mapToken ( contractAddresses . root . tokens . RootERC721 , childTestERC721 . address , true ) // ERC721
64+ console . log ( 'Root and child testERC721 contracts mapped' )
4465
66+ // Initialize and map MaticToken.
4567 const maticToken = await MRC20 . at ( '0x0000000000000000000000000000000000001010' )
4668 const maticOwner = await maticToken . owner ( )
4769 if ( maticOwner === '0x0000000000000000000000000000000000000000' ) {
@@ -51,12 +73,12 @@ module.exports = async function(deployer, network, accounts) {
5173 await childChain . mapToken ( contractAddresses . root . tokens . MaticToken , '0x0000000000000000000000000000000000001010' , false )
5274
5375 contractAddresses . child = {
54- ChildChain : ChildChain . address ,
76+ ChildChain : childChain . address ,
5577 tokens : {
56- MaticWeth : MaticWeth . logs . find ( log => log . event === 'NewToken' ) . args . token ,
78+ MaticWeth : childMaticWeth . address ,
5779 MaticToken : '0x0000000000000000000000000000000000001010' ,
58- TestToken : TestToken . logs . find ( log => log . event === 'NewToken' ) . args . token ,
59- RootERC721 : RootERC721 . logs . find ( log => log . event === 'NewToken' ) . args . token
80+ TestToken : childTestToken . address ,
81+ RootERC721 : childTestERC721 . address
6082 }
6183 }
6284 utils . writeContractAddresses ( contractAddresses )
0 commit comments