Skip to content

Commit

Permalink
add decodedScheduleData tool change delay timelock
Browse files Browse the repository at this point in the history
  • Loading branch information
laisolizq committed Dec 5, 2024
1 parent 8fa4f45 commit 02b1859
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions tools/changeDelayTimelock/changeDelayTimelock.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* 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 {utils} from "ffjavascript";
import path = require("path");
import fs = require("fs");

Expand Down Expand Up @@ -72,7 +72,35 @@ async function main() {
parameters: parameters.newMinDelay
}

await fs.writeFileSync(pathOutputJson, JSON.stringify(outputJson, null, 1));
// Decode the scheduleData for better readability
const timelockTx = timelockContractFactory.interface.parseTransaction({data: scheduleData});
const paramsArray = timelockTx?.fragment.inputs as any;
const objectDecoded = {} as any;

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

if (currentParam.name == "data") {
const decodedTimelockTx = timelockContractFactory.interface.parseTransaction({
data: timelockTx?.args[i],
});
const objectDecodedData = {} as any;
const paramsArrayData = decodedTimelockTx?.fragment.inputs as any;

objectDecodedData.signature = decodedTimelockTx?.signature;
objectDecodedData.selector = decodedTimelockTx?.selector;

for (let j = 0; j < paramsArrayData?.length; j++) {
const currentParam = paramsArrayData[j];
objectDecodedData[currentParam.name] = decodedTimelockTx?.args[j];
}
objectDecoded["decodedData"] = objectDecodedData;
}
}
outputJson.decodedScheduleData = objectDecoded;

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

// OZ test functions
Expand Down

0 comments on commit 02b1859

Please sign in to comment.