Skip to content

Commit

Permalink
Merge pull request #345 from 0xPolygonHermez/feature/improve-upgrade-…
Browse files Browse the repository at this point in the history
…banana

decode timelock tx in upgrade-banana
  • Loading branch information
invocamanman authored Oct 15, 2024
2 parents 273cb68 + 8362931 commit 12bdfc7
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions upgrade/upgradeBanana/upgradeBanana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import {expect} from "chai";
import path = require("path");
import fs = require("fs");
import {utils} from "ffjavascript";

import * as dotenv from "dotenv";
dotenv.config({path: path.resolve(__dirname, "../../.env")});
Expand Down Expand Up @@ -136,7 +137,7 @@ async function main() {
);

// Upgrade to rollup manager
const PolygonRollupManagerFactory = await ethers.getContractFactory("PolygonRollupManager");
const PolygonRollupManagerFactory = await ethers.getContractFactory("PolygonRollupManager", deployer);
const implRollupManager = await upgrades.prepareUpgrade(rollupManagerAddress, PolygonRollupManagerFactory, {
constructorArgs: [globalExitRootManagerAddress, polAddress, bridgeAddress],
unsafeAllow: ["constructor", "state-variable-immutable"],
Expand Down Expand Up @@ -190,7 +191,43 @@ async function main() {
executeData,
timelockContractAdress: timelockAddress,
};
fs.writeFileSync(pathOutputJson, JSON.stringify(outputJson, null, 1));

// Decode the scheduleData for better readibility
const timelockTx = timelockContractFactory.interface.parseTransaction({data: scheduleData});
const paramsArray = timelockTx?.fragment.inputs;
const objectDecoded = {};

for (let i = 0; i < paramsArray?.length; i++) {
const currentParam = paramsArray[i];
objectDecoded[currentParam.name] = timelockTx?.args[i];

if (currentParam.name == "payloads") {
// for each payload
const payloads = timelockTx?.args[i];
for (let j = 0; j < payloads.length; j++) {
const data = payloads[j];
const decodedProxyAdmin = proxyAdmin.interface.parseTransaction({
data,
});

const resultDecodeProxyAdmin = {};
resultDecodeProxyAdmin.signature = decodedProxyAdmin?.signature;
resultDecodeProxyAdmin.selector = decodedProxyAdmin?.selector;

const paramsArrayData = decodedProxyAdmin?.fragment.inputs;

for (let n = 0; n < paramsArrayData?.length; n++) {
const currentParam = paramsArrayData[n];
resultDecodeProxyAdmin[currentParam.name] = decodedProxyAdmin?.args[n];
}
objectDecoded[`decodePayload_${j}`] = resultDecodeProxyAdmin;
}
}
}

outputJson.decodedScheduleData = objectDecoded;

fs.writeFileSync(pathOutputJson, JSON.stringify(utils.stringifyBigInts(outputJson), null, 1));
}

main().catch((e) => {
Expand Down

0 comments on commit 12bdfc7

Please sign in to comment.