Skip to content

Commit 09a7399

Browse files
authored
Merge pull request #19 from QEDK/bugfix
Fix RLPReader overflow and add verification commands in deployment script
2 parents 4b07231 + 3ed8189 commit 09a7399

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

contracts/lib/RLPReader.sol

+4-1
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,15 @@ library RLPReader {
333333
dest += WORD_SIZE;
334334
}
335335

336+
if (len == 0) return;
337+
336338
// left over bytes. Mask is used to remove unwanted bytes from the word
337339
uint mask = 256 ** (WORD_SIZE - len) - 1;
340+
338341
assembly {
339342
let srcpart := and(mload(src), not(mask)) // zero out src
340343
let destpart := and(mload(dest), mask) // retrieve the bytes
341344
mstore(dest, or(destpart, srcpart))
342345
}
343346
}
344-
}
347+
}

scripts/deploychild.js

+16-22
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,46 @@ const config = require('../config/config.json')
33
const hre = require('hardhat')
44

55
async function main () {
6-
let fxChild
6+
let fxChild, erc20Token, erc721Token, erc1155Token
77

88
const network = await hre.ethers.provider.getNetwork()
99

1010
if (network.chainId === 137) { // Polygon Mainnet
1111
fxChild = config.mainnet.fxChild.address
12+
erc20Token = config.mainnet.fxERC20.address
13+
erc721Token = config.mainnet.fxERC721.address
14+
erc1155Token = config.mainnet.fxERC1155.address
1215
} else if (network.chainId === 80001) { // Mumbai Testnet
1316
fxChild = config.testnet.fxChild.address
17+
erc20Token = config.testnet.fxERC20.address
18+
erc721Token = config.testnet.fxERC721.address
19+
erc1155Token = config.testnet.fxERC1155.address
1420
} else {
1521
fxChild = process.env.FX_CHILD
22+
erc20Token = process.env.FX_ERC20
23+
erc721Token = process.env.FX_ERC721
24+
erc1155Token = process.env.FX_ERC1155
1625
}
1726

18-
const ERC20Token = await hre.ethers.getContractFactory('FxERC20')
19-
const erc20Token = await ERC20Token.deploy()
20-
console.log(erc20Token.deployTransaction)
21-
await erc20Token.deployTransaction.wait()
22-
console.log('FxERC20 deployed to:', erc20Token.address)
23-
2427
const ERC20 = await hre.ethers.getContractFactory('FxERC20ChildTunnel')
25-
const erc20 = await ERC20.deploy(fxChild, erc20Token.address)
28+
const erc20 = await ERC20.deploy(fxChild, erc20Token)
2629
await erc20.deployTransaction.wait()
2730
console.log('ERC20ChildTunnel deployed to:', erc20.address)
28-
29-
const ERC721Token = await hre.ethers.getContractFactory('FxERC721')
30-
const erc721Token = await ERC721Token.deploy()
31-
console.log(erc721Token.deployTransaction)
32-
await erc721Token.deployTransaction.wait()
33-
console.log('FxERC721 deployed to:', erc721Token.address)
31+
console.log('npx hardhat verify --network mumbai', erc20.address, fxChild, erc20Token)
3432

3533
const ERC721 = await hre.ethers.getContractFactory('FxERC721ChildTunnel')
36-
const erc721 = await ERC721.deploy(fxChild, erc721Token.address)
34+
const erc721 = await ERC721.deploy(fxChild, erc721Token)
3735
console.log(erc721.deployTransaction)
3836
await erc721.deployTransaction.wait()
3937
console.log('ERC721ChildTunnel deployed to:', erc721.address)
40-
41-
const ERC1155Token = await hre.ethers.getContractFactory('FxERC1155')
42-
const erc1155Token = await ERC1155Token.deploy()
43-
console.log(erc1155Token.deployTransaction)
44-
await erc1155Token.deployTransaction.wait()
45-
console.log('FxERC1155 deployed to:', erc1155Token.address)
38+
console.log('npx hardhat verify --network mumbai', erc721.address, fxChild, erc721Token)
4639

4740
const ERC1155 = await hre.ethers.getContractFactory('FxERC1155ChildTunnel')
48-
const erc1155 = await ERC1155.deploy(fxChild, erc1155Token.address)
41+
const erc1155 = await ERC1155.deploy(fxChild, erc1155Token)
4942
console.log(erc1155.deployTransaction)
5043
await erc1155.deployTransaction.wait()
5144
console.log('ERC1155ChildTunnel deployed to:', erc1155.address)
45+
console.log('npx hardhat verify --network mumbai', erc1155.address, fxChild, erc1155Token)
5246
}
5347

5448
main()

scripts/deployroot.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ const config = require('../config/config.json')
33
const hre = require('hardhat')
44

55
// Use your own deployed child tunnel addresses here instead!
6-
const fxERC20ChildTunnel = '0x918cc10cf2393bb9803f9d9D3219539a1e736dd9'
7-
const fxERC721ChildTunnel = '0xdC335C19868d49aCa554AA64d5ae8524A093De5b'
8-
const fxERC1155ChildTunnel = '0x46d40260e48A6164bbF24206D3AB9426a41D8664'
6+
const fxERC20ChildTunnel = '0x587C9FF1c528C7aeE2804Bf5301Dc2ec057A75a8'
7+
const fxERC721ChildTunnel = '0x96d26FCA4cB14e14CABc28eF8bc8Aba0E03702A8'
8+
const fxERC1155ChildTunnel = '0x24a16Db524d342968A11b9E1aD75b6D5eD002db7'
99

1010
async function main () {
1111
let fxRoot, checkpointManager, fxERC20, fxERC721, fxERC1155
@@ -38,6 +38,7 @@ async function main () {
3838
console.log(erc20.deployTransaction)
3939
await erc20.deployTransaction.wait()
4040
console.log('ERC20RootTunnel deployed to:', erc20.address)
41+
console.log('npx hardhat verify --network goerli', erc20.address, checkpointManager, fxRoot, fxERC20)
4142

4243
const setERC20Child = await erc20.setFxChildTunnel(fxERC20ChildTunnel)
4344
console.log(setERC20Child)
@@ -49,6 +50,7 @@ async function main () {
4950
console.log(erc721.deployTransaction)
5051
await erc721.deployTransaction.wait()
5152
console.log('ERC721RootTunnel deployed to:', erc721.address)
53+
console.log('npx hardhat verify --network goerli', erc721.address, checkpointManager, fxRoot, fxERC721)
5254

5355
const setERC721Child = await erc721.setFxChildTunnel(fxERC721ChildTunnel)
5456
console.log(setERC721Child)
@@ -60,6 +62,7 @@ async function main () {
6062
console.log(erc1155.deployTransaction)
6163
await erc1155.deployTransaction.wait()
6264
console.log('ERC1155RootTunnel deployed to:', erc1155.address)
65+
console.log('npx hardhat verify --network goerli', erc1155.address, checkpointManager, fxRoot, fxERC1155)
6366

6467
const setERC1155Child = await erc1155.setFxChildTunnel(fxERC1155ChildTunnel)
6568
console.log(setERC1155Child)

0 commit comments

Comments
 (0)