@gearbox-protocol/deploy-tools 5.14.2 → 5.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +185 -16
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -131227,7 +131227,7 @@ var require_chains = __commonJS({
131227
131227
  [exports2.CHAINS.Sonic]: "Sonic"
131228
131228
  // [CHAINS.Base]: "Polygon",
131229
131229
  };
131230
- var getNetworkType = (chainId, localAs = "Mainnet") => {
131230
+ var getNetworkType2 = (chainId, localAs = "Mainnet") => {
131231
131231
  const chainType = SUPPORTED_CHAINS2[chainId];
131232
131232
  if (chainId === exports2.CHAINS.Local) {
131233
131233
  return localAs;
@@ -131236,7 +131236,7 @@ var require_chains = __commonJS({
131236
131236
  }
131237
131237
  throw new Error("Unsupported network");
131238
131238
  };
131239
- exports2.getNetworkType = getNetworkType;
131239
+ exports2.getNetworkType = getNetworkType2;
131240
131240
  var isSupportedNetwork = (chainId) => chainId !== void 0 && !!SUPPORTED_CHAINS2[chainId];
131241
131241
  exports2.isSupportedNetwork = isSupportedNetwork;
131242
131242
  var detectNetwork2 = async (provider) => {
@@ -373952,6 +373952,13 @@ var CHAINS_BY_ID = {
373952
373952
  [base.id]: "Base",
373953
373953
  [sonic.id]: "Sonic"
373954
373954
  };
373955
+ var getNetworkType = (chainId) => {
373956
+ const chainType = CHAINS_BY_ID[chainId];
373957
+ if (chainType) {
373958
+ return chainType;
373959
+ }
373960
+ throw new Error("Unsupported network");
373961
+ };
373955
373962
  async function detectChain(transportOrRPC) {
373956
373963
  const transport = typeof transportOrRPC === "string" ? http(transportOrRPC) : transportOrRPC;
373957
373964
  const tempClient = createPublicClient({ transport });
@@ -406362,6 +406369,142 @@ var ForkTemplate = z.object({
406362
406369
  riskCuratorNames: z.array(z.string()).nullish().transform((v) => v?.length ? v : void 0)
406363
406370
  });
406364
406371
 
406372
+ // ../../packages/shared/dist/governor.js
406373
+ var GOVERNOR = {
406374
+ Mainnet: "0x29B97F37B3E0C704bCFD785F5b7bBa2A0B7df2c7",
406375
+ Arbitrum: "0xF0C89a0eDCD68B4176A26B3bf7574498DD3E6d09",
406376
+ Optimism: "0xF0C89a0eDCD68B4176A26B3bf7574498DD3E6d09",
406377
+ Base: NOT_DEPLOYED,
406378
+ Sonic: "0x1f3Ee385ce9A6333d73b61086349C4d0f5De0da8"
406379
+ };
406380
+ var EVENT_TO_STATUS = {
406381
+ QueueBatch: "queued",
406382
+ ExecuteBatch: "executed",
406383
+ CancelBatch: "canceled"
406384
+ };
406385
+ var GOVERNOR_EVENTS = [
406386
+ parseAbiItem("event QueueBatch(address indexed caller, uint256 indexed batchBlock)"),
406387
+ parseAbiItem("event ExecuteBatch(address indexed caller, uint256 indexed batchBlock)"),
406388
+ parseAbiItem("event CancelBatch(address indexed caller, uint256 indexed batchBlock)")
406389
+ ];
406390
+ var TimelockQueueTransaction = parseAbiItem("event QueueTransaction( bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta )");
406391
+ async function loadGovernorBatches(opts) {
406392
+ const { client, logger: logger2, governor: gov, fromBlock, toBlock } = opts;
406393
+ let governor = gov;
406394
+ if (!governor) {
406395
+ const chainId = await client.getChainId();
406396
+ const networkType = getNetworkType(chainId);
406397
+ governor = GOVERNOR[networkType];
406398
+ }
406399
+ const timelock = await client.readContract({
406400
+ address: governor,
406401
+ abi: iGovernorAbi,
406402
+ functionName: "timeLock"
406403
+ });
406404
+ logger2?.info({ timelock, governor, fromBlock, toBlock }, "reading from governor and timelock");
406405
+ let govLogs = await client.getLogs({
406406
+ address: governor,
406407
+ events: GOVERNOR_EVENTS,
406408
+ fromBlock,
406409
+ toBlock,
406410
+ strict: true
406411
+ });
406412
+ govLogs = govLogs.sort(compareLogs);
406413
+ const batches = /* @__PURE__ */ new Map();
406414
+ const batchesByTx = /* @__PURE__ */ new Map();
406415
+ for (const govLog of govLogs) {
406416
+ const { batchBlock } = govLog.args;
406417
+ const status = EVENT_TO_STATUS[govLog.eventName];
406418
+ let batch = batches.get(batchBlock);
406419
+ if (batch?.status === status) {
406420
+ throw new Error(`duplicate batch in block ${batchBlock}`);
406421
+ }
406422
+ if (!batch && (status === "canceled" || status === "executed")) {
406423
+ throw new Error(`batch in block ${batchBlock} is ${status} before queued`);
406424
+ }
406425
+ batch = batch ?? {
406426
+ block: batchBlock,
406427
+ status,
406428
+ queueTxHash: govLog.transactionHash,
406429
+ transactions: []
406430
+ };
406431
+ batch.status = status;
406432
+ batches.set(batchBlock, batch);
406433
+ batchesByTx.set(batch.queueTxHash.toLowerCase(), batch);
406434
+ }
406435
+ logger2?.debug(`loaded ${batches.size} governor batches, in ${govLogs.length} events`);
406436
+ let queue = [];
406437
+ const pageSize = 100000n;
406438
+ for (let start = fromBlock; start <= toBlock; start += pageSize) {
406439
+ let end = start + pageSize - 1n;
406440
+ if (end > toBlock) {
406441
+ end = toBlock;
406442
+ }
406443
+ const logs = await client.getLogs({
406444
+ address: timelock,
406445
+ event: parseAbiItem("event QueueTransaction( bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta )"),
406446
+ fromBlock: start,
406447
+ toBlock: end,
406448
+ strict: true
406449
+ });
406450
+ queue = queue.concat(logs);
406451
+ }
406452
+ queue = queue.sort(compareLogs);
406453
+ logger2?.debug(`loaded ${queue.length} queued timelock transactions`);
406454
+ for (const i of queue) {
406455
+ const { transactionHash } = i;
406456
+ const batch = batchesByTx.get(transactionHash.toLowerCase());
406457
+ if (batch) {
406458
+ batch.transactions.push(normalizeTimelockTx2(i));
406459
+ } else {
406460
+ logger2?.warn(`cannot find batch from transaction ${transactionHash}`);
406461
+ }
406462
+ }
406463
+ let result = Array.from(batches.values());
406464
+ result = result.sort((a, b) => a.block < b.block ? 1 : -1);
406465
+ return result.map((b) => ({
406466
+ id: `batch_${b.block}`,
406467
+ description: `batch in block ${b.block}`,
406468
+ type: "governor",
406469
+ transactions: b.transactions,
406470
+ status: b.status,
406471
+ block: b.block,
406472
+ queueTxHash: b.queueTxHash
406473
+ }));
406474
+ }
406475
+ function compareLogs(a, b) {
406476
+ if (a.blockNumber < b.blockNumber) {
406477
+ return -1;
406478
+ } else if (a.blockNumber > b.blockNumber) {
406479
+ return 1;
406480
+ } else {
406481
+ return a.logIndex - b.logIndex;
406482
+ }
406483
+ }
406484
+ function normalizeTimelockTx2(t) {
406485
+ const { data, eta, signature, target, value } = t.args;
406486
+ let funcSignature = signature;
406487
+ if (!funcSignature.startsWith("function")) {
406488
+ funcSignature = `function ${funcSignature}`;
406489
+ }
406490
+ const sighash = toFunctionSelector(funcSignature);
406491
+ const abiItem = parseAbiItem(funcSignature);
406492
+ const decoded = decodeAbiParameters(abiItem.inputs, data);
406493
+ return {
406494
+ target,
406495
+ value: value.toString(10),
406496
+ signature,
406497
+ parameters: abiItem.inputs.map((input, i) => ({
406498
+ name: input.name,
406499
+ // TODO(viem): check if empty name is ok
406500
+ type: input.type,
406501
+ value: decoded[i]
406502
+ })),
406503
+ data: data.replace("0x", sighash),
406504
+ eta: eta.toString(10)
406505
+ };
406506
+ }
406507
+
406365
406508
  // ../../packages/shared/dist/hex.js
406366
406509
  function hexEq(a, b) {
406367
406510
  const [aa, bb] = [a, b].map((s) => s.replace(/^0x/, "").toLowerCase());
@@ -410780,7 +410923,7 @@ __export(utilityContracts_exports, {
410780
410923
  BATCH_CHAIN: () => BATCH_CHAIN,
410781
410924
  BLACKLIST_HELPER: () => BLACKLIST_HELPER,
410782
410925
  CREATE2FACTORY: () => CREATE2FACTORY,
410783
- GOVERNOR: () => GOVERNOR,
410926
+ GOVERNOR: () => GOVERNOR2,
410784
410927
  MULTISIG: () => MULTISIG,
410785
410928
  ROUTER_CREATE2FACTORY: () => ROUTER_CREATE2FACTORY,
410786
410929
  ROUTER_MULTISIG_ADDRESS: () => ROUTER_MULTISIG_ADDRESS,
@@ -410802,13 +410945,7 @@ var TIMELOCK2 = {
410802
410945
  Base: NOT_DEPLOYED,
410803
410946
  Sonic: "0xAdbF876ce58CB65c99b18078353e1DCB16E69e84"
410804
410947
  };
410805
- var GOVERNOR = {
410806
- Mainnet: "0x29B97F37B3E0C704bCFD785F5b7bBa2A0B7df2c7",
410807
- Arbitrum: "0xF0C89a0eDCD68B4176A26B3bf7574498DD3E6d09",
410808
- Optimism: "0xF0C89a0eDCD68B4176A26B3bf7574498DD3E6d09",
410809
- Base: NOT_DEPLOYED,
410810
- Sonic: "0x1f3Ee385ce9A6333d73b61086349C4d0f5De0da8"
410811
- };
410948
+ var GOVERNOR2 = GOVERNOR;
410812
410949
  var BATCH_CHAIN = {
410813
410950
  Mainnet: "0xB900bDEf6eAc8C5D97F8e876aBC39573Cf6626b2",
410814
410951
  Arbitrum: "0xAEbaa1015D0bc250F5b38aac9b8f65E0668cE3c2",
@@ -411351,7 +411488,7 @@ var GEARBOX_V1_BLOCK = 13810899;
411351
411488
  // ../../packages/node/dist/Verifier.js
411352
411489
  var import_bytecode_utils2 = __toESM(require_main(), 1);
411353
411490
  var import_lib_sourcify = __toESM(require_main2(), 1);
411354
- var import_abi22 = __toESM(require_lib13(), 1);
411491
+ var import_abi23 = __toESM(require_lib13(), 1);
411355
411492
  var Verifier = class {
411356
411493
  logger;
411357
411494
  constructor() {
@@ -411426,8 +411563,8 @@ var Verifier = class {
411426
411563
  error: `Failed to match with creation bytecode: constructor ABI Inputs are missing`
411427
411564
  };
411428
411565
  }
411429
- const decodeResult = import_abi22.defaultAbiCoder.decode(constructorAbiParamInputs, abiEncodedConstructorArguments);
411430
- const encodeResult = import_abi22.defaultAbiCoder.encode(constructorAbiParamInputs, decodeResult);
411566
+ const decodeResult = import_abi23.defaultAbiCoder.decode(constructorAbiParamInputs, abiEncodedConstructorArguments);
411567
+ const encodeResult = import_abi23.defaultAbiCoder.encode(constructorAbiParamInputs, decodeResult);
411431
411568
  if (encodeResult !== abiEncodedConstructorArguments) {
411432
411569
  return {
411433
411570
  ...result,
@@ -415807,9 +415944,11 @@ var UpdateParser = class extends ProviderBase {
415807
415944
  }
415808
415945
  async parse(opts) {
415809
415946
  await this.init();
415810
- const { batchDir, safeTxHashes } = opts;
415947
+ const { batchDir, safeTxHashes, governor } = opts;
415811
415948
  if (batchDir) {
415812
415949
  await this.#parseBatchDir(batchDir, opts.unsafeMainnetMeta);
415950
+ } else if (governor) {
415951
+ await this.#parseGovernorQueue(governor === true ? void 0 : governor);
415813
415952
  } else {
415814
415953
  await this.#parseSafeTxHashes(safeTxHashes);
415815
415954
  }
@@ -415915,6 +416054,30 @@ var UpdateParser = class extends ProviderBase {
415915
416054
  this.#collectCreate2Addresses(parsed);
415916
416055
  return parsed;
415917
416056
  }
416057
+ async #parseGovernorQueue(fromBlock, toBlock) {
416058
+ this.logger.info("parsing governor queue");
416059
+ const latest = await this.client.getBlockNumber();
416060
+ const batches = await loadGovernorBatches({
416061
+ client: this.client,
416062
+ governor: this.address("GOVERNOR"),
416063
+ fromBlock: fromBlock ?? ADDRESS_PROVIDER_BLOCK[this.network],
416064
+ toBlock: toBlock ?? latest,
416065
+ logger: this.logger
416066
+ });
416067
+ const queued = batches.filter((b) => b.status === "queued");
416068
+ this.logger.debug(`loaded ${batches.length} batches, ${queued.length} queued`);
416069
+ for (let i = 0; i < queued.length; i++) {
416070
+ try {
416071
+ const parsed = await this.#parseNormalizedBatch(queued[i], i, queued.length);
416072
+ this.#output.batches.push(parsed);
416073
+ } catch (e) {
416074
+ this.#output.batches.push({
416075
+ id: queued[i].id,
416076
+ error: `${e}`.replaceAll("\n", "\\n")
416077
+ });
416078
+ }
416079
+ }
416080
+ }
415918
416081
  #collectCreate2Addresses(tx) {
415919
416082
  if (isDeployTransaction(tx)) {
415920
416083
  this.#collectCreate2Addresses(tx.constructorTransaction);
@@ -417443,7 +417606,7 @@ function getRenderer(opts) {
417443
417606
  var package_default = {
417444
417607
  name: "@gearbox-protocol/deploy-tools",
417445
417608
  description: "Gearbox deploy tools",
417446
- version: "5.14.2",
417609
+ version: "5.15.1",
417447
417610
  homepage: "https://gearbox.fi",
417448
417611
  keywords: [
417449
417612
  "gearbox"
@@ -417542,6 +417705,11 @@ function parse() {
417542
417705
  "--safe-tx-hashes [hash...]",
417543
417706
  "Safe tx hashes to get from safe api and verify"
417544
417707
  )
417708
+ ).addOption(
417709
+ new Option(
417710
+ "--governor [starting block]",
417711
+ "Parse governor queue starting from block (or entire queue if not specified)"
417712
+ )
417545
417713
  ).addOption(
417546
417714
  new Option(
417547
417715
  "--unsafe-mainnet-meta",
@@ -417566,7 +417734,8 @@ function parse() {
417566
417734
  const parser = new UpdateParser(opts, version_default);
417567
417735
  const result = await parser.parse({
417568
417736
  ...opts,
417569
- safeTxHashes: opts.safeTxHashes
417737
+ safeTxHashes: opts.safeTxHashes,
417738
+ governor: opts.governor ? opts.governor === true ? true : BigInt(opts.governor) : void 0
417570
417739
  });
417571
417740
  if (opts.outFile) {
417572
417741
  await writeFile7(opts.outFile, json_stringify(result), "utf-8");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/deploy-tools",
3
3
  "description": "Gearbox deploy tools",
4
- "version": "5.14.2",
4
+ "version": "5.15.1",
5
5
  "homepage": "https://gearbox.fi",
6
6
  "keywords": [
7
7
  "gearbox"