-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15660cf
commit d78f74e
Showing
5 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* eslint-disable no-await-in-loop, no-use-before-define, no-lonely-if */ | ||
/* eslint-disable no-console, no-inner-declarations, no-undef, import/no-unresolved */ | ||
import {expect} from "chai"; | ||
import path = require("path"); | ||
import fs = require("fs"); | ||
|
||
import * as dotenv from "dotenv"; | ||
dotenv.config({path: path.resolve(__dirname, "../../../.env")}); | ||
import {ethers, upgrades} from "hardhat"; | ||
const getRollupParams = require("./rollupDataParams.json"); | ||
import {PolygonRollupManager} from "../../typechain-types"; | ||
const pathOutputJson = path.join(__dirname, "./deploy_output.json"); | ||
const pathCreateRollupOutput = path.join(__dirname, "./create_rollup_output.json"); | ||
|
||
async function main() { | ||
const RollupManagerFactory = await ethers.getContractFactory("PolygonRollupManager"); | ||
|
||
const rollupManager = (await RollupManagerFactory.attach( | ||
getRollupParams.polygonRollupManagerAddress | ||
)) as PolygonRollupManager; | ||
|
||
const polygonZkEVMBridgeAddress = await rollupManager.bridgeAddress(); | ||
const polygonZkEVMGlobalExitRootAddress = await rollupManager.globalExitRootManager(); | ||
const polTokenAddress = await rollupManager.pol(); | ||
|
||
// FIlter first rollup ID ( the one on migration) | ||
const filter = rollupManager.filters.AddExistingRollup(1, undefined, undefined, undefined, undefined, undefined); | ||
const eventsAddRollup = await rollupManager.queryFilter(filter, 0, "latest"); | ||
|
||
const deploymentBlockNumber = eventsAddRollup[0].blockNumber; | ||
|
||
const deployOutput = { | ||
polygonRollupManagerAddress: rollupManager.target, | ||
polygonZkEVMBridgeAddress, | ||
polygonZkEVMGlobalExitRootAddress, | ||
polTokenAddress, | ||
deploymentBlockNumber, | ||
}; | ||
fs.writeFileSync(pathOutputJson, JSON.stringify(deployOutput, null, 1)); | ||
|
||
const filter2 = rollupManager.filters.CreateNewRollup( | ||
getRollupParams.rollupID, | ||
undefined, | ||
undefined, | ||
undefined, | ||
undefined | ||
); | ||
const eventsCreateNewRollup = await rollupManager.queryFilter(filter2, 0, "latest"); | ||
const {rollupID, rollupAddress, chainID, gasTokenAddress, rollupTypeID} = eventsCreateNewRollup[0].args; | ||
|
||
const filter3 = rollupManager.filters.AddNewRollupType( | ||
rollupTypeID, | ||
undefined, | ||
undefined, | ||
undefined, | ||
undefined, | ||
undefined | ||
); | ||
|
||
const eventsAddRollupType = await rollupManager.queryFilter(filter3, 0, "latest"); | ||
const {forkID, genesis, description} = eventsAddRollupType[0].args; | ||
|
||
// Add the first batch of the created rollup | ||
const outputCreateRollup = {} as any; | ||
outputCreateRollup.genesis = genesis; | ||
outputCreateRollup.createRollupBlock = eventsCreateNewRollup[0].blockNumber; | ||
outputCreateRollup.rollupAddress = rollupAddress; | ||
outputCreateRollup.consensusContract = description; | ||
|
||
fs.writeFileSync(pathCreateRollupOutput, JSON.stringify(outputCreateRollup, null, 1)); | ||
} | ||
|
||
main().catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); | ||
|
||
// OZ test functions | ||
function genOperation(target: any, value: any, data: any, predecessor: any, salt: any) { | ||
const id = ethers.solidityPackedKeccak256( | ||
["address", "uint256", "bytes", "uint256", "bytes32"], | ||
[target, value, data, predecessor, salt] | ||
); | ||
return { | ||
id, | ||
target, | ||
value, | ||
data, | ||
predecessor, | ||
salt, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"polygonRollupManagerAddress":"", | ||
"rollupID":0 | ||
} |