@gzeoneth/gov-tracker 0.1.1-1 → 0.1.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.
- package/LICENSE +13 -14
- package/README.md +5 -5
- package/dist/calldata/address-utils.d.ts +4 -3
- package/dist/calldata/address-utils.d.ts.map +1 -1
- package/dist/calldata/address-utils.js +3 -3
- package/dist/calldata/address-utils.js.map +1 -1
- package/dist/calldata/decoder.d.ts +2 -1
- package/dist/calldata/decoder.d.ts.map +1 -1
- package/dist/calldata/decoder.js +65 -72
- package/dist/calldata/decoder.js.map +1 -1
- package/dist/calldata/extraction.d.ts +17 -0
- package/dist/calldata/extraction.d.ts.map +1 -0
- package/dist/calldata/extraction.js +56 -0
- package/dist/calldata/extraction.js.map +1 -0
- package/dist/calldata/index.d.ts +4 -3
- package/dist/calldata/index.d.ts.map +1 -1
- package/dist/calldata/index.js +4 -5
- package/dist/calldata/index.js.map +1 -1
- package/dist/calldata/parameter-decoder.d.ts +2 -1
- package/dist/calldata/parameter-decoder.d.ts.map +1 -1
- package/dist/calldata/parameter-decoder.js +47 -77
- package/dist/calldata/parameter-decoder.js.map +1 -1
- package/dist/calldata/retryable-ticket.d.ts +3 -10
- package/dist/calldata/retryable-ticket.d.ts.map +1 -1
- package/dist/calldata/retryable-ticket.js +13 -31
- package/dist/calldata/retryable-ticket.js.map +1 -1
- package/dist/calldata/signature-lookup.d.ts +0 -7
- package/dist/calldata/signature-lookup.d.ts.map +1 -1
- package/dist/calldata/signature-lookup.js +0 -11
- package/dist/calldata/signature-lookup.js.map +1 -1
- package/dist/cli/monitor.js +20 -21
- package/dist/cli/monitor.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -10
- package/dist/index.js.map +1 -1
- package/dist/simulation/index.d.ts +0 -1
- package/dist/simulation/index.d.ts.map +1 -1
- package/dist/simulation/index.js +1 -7
- package/dist/simulation/index.js.map +1 -1
- package/dist/simulation/simulation-data.d.ts +2 -1
- package/dist/simulation/simulation-data.d.ts.map +1 -1
- package/dist/simulation/simulation-data.js +61 -59
- package/dist/simulation/simulation-data.js.map +1 -1
- package/dist/stages/timelock.d.ts.map +1 -1
- package/dist/stages/timelock.js +18 -6
- package/dist/stages/timelock.js.map +1 -1
- package/dist/tracker/query.js +1 -1
- package/dist/tracker/query.js.map +1 -1
- package/dist/tracker/state.js +1 -1
- package/dist/tracker/state.js.map +1 -1
- package/dist/types/calldata.d.ts +45 -10
- package/dist/types/calldata.d.ts.map +1 -1
- package/dist/types/core.d.ts +11 -0
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/simulation.d.ts +1 -1
- package/dist/types/simulation.d.ts.map +1 -1
- package/dist/utils/operation-id.d.ts +12 -23
- package/dist/utils/operation-id.d.ts.map +1 -1
- package/dist/utils/operation-id.js +29 -52
- package/dist/utils/operation-id.js.map +1 -1
- package/dist/utils/urls.d.ts +0 -15
- package/dist/utils/urls.d.ts.map +1 -1
- package/dist/utils/urls.js +0 -30
- package/dist/utils/urls.js.map +1 -1
- package/package.json +2 -2
- package/dist/simulation/address-alias.d.ts +0 -35
- package/dist/simulation/address-alias.d.ts.map +0 -1
- package/dist/simulation/address-alias.js +0 -46
- package/dist/simulation/address-alias.js.map +0 -1
- package/dist/utils/salt-resolver.d.ts +0 -63
- package/dist/utils/salt-resolver.d.ts.map +0 -1
- package/dist/utils/salt-resolver.js +0 -144
- package/dist/utils/salt-resolver.js.map +0 -1
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Salt Resolution for Timelock Execution
|
|
4
|
-
*
|
|
5
|
-
* Salt resolution hierarchy:
|
|
6
|
-
* 1. options.salt (explicit override)
|
|
7
|
-
* 2. stage.data.salt (cached from tracking)
|
|
8
|
-
* 3. Security Council: generateSalt(members, nonce)
|
|
9
|
-
* 4. Governor: keccak256(description)
|
|
10
|
-
* 5. HashZero (0x00...00) - last resort for operations that use default salt
|
|
11
|
-
* 6. FAIL - throw error if no salt matches the operation ID
|
|
12
|
-
*
|
|
13
|
-
* Each resolved salt is validated against the expected operation ID before use.
|
|
14
|
-
* If validation fails, the next option in the hierarchy is tried.
|
|
15
|
-
*/
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.SaltResolutionError = exports.saltForSecurityCouncil = exports.saltFromDescription = void 0;
|
|
18
|
-
exports.getSaltCandidates = getSaltCandidates;
|
|
19
|
-
exports.resolveExecuteOptionsForStage = resolveExecuteOptionsForStage;
|
|
20
|
-
const ethers_1 = require("ethers");
|
|
21
|
-
const types_1 = require("../types");
|
|
22
|
-
const operation_id_1 = require("../utils/operation-id");
|
|
23
|
-
Object.defineProperty(exports, "saltFromDescription", { enumerable: true, get: function () { return operation_id_1.saltFromDescription; } });
|
|
24
|
-
Object.defineProperty(exports, "saltForSecurityCouncil", { enumerable: true, get: function () { return operation_id_1.saltForSecurityCouncil; } });
|
|
25
|
-
const security_council_1 = require("../discovery/security-council");
|
|
26
|
-
/**
|
|
27
|
-
* Get all candidate salts from a TrackedStage in priority order.
|
|
28
|
-
*
|
|
29
|
-
* Returns an array of salt candidates to try, in order of priority.
|
|
30
|
-
* The caller is responsible for validating each salt against the operation ID.
|
|
31
|
-
*
|
|
32
|
-
* @param stage - The stage being prepared (L2_TIMELOCK or L1_TIMELOCK)
|
|
33
|
-
* @param options - Preparation options (can include explicit salt override)
|
|
34
|
-
* @param provider - Provider for on-chain salt generation
|
|
35
|
-
* @param allStages - All tracked stages (used to extract context from other stages)
|
|
36
|
-
*/
|
|
37
|
-
async function getSaltCandidates(stage, options = {}, provider, allStages) {
|
|
38
|
-
const candidates = [];
|
|
39
|
-
// 1. Explicit user override (highest priority)
|
|
40
|
-
if (options.salt) {
|
|
41
|
-
candidates.push({ salt: options.salt, source: "explicit" });
|
|
42
|
-
}
|
|
43
|
-
// Try to get typed stage data from any timelock stage type
|
|
44
|
-
const stageData = (0, types_1.getStageData)(stage, "L2_TIMELOCK") ?? (0, types_1.getStageData)(stage, "L1_TIMELOCK");
|
|
45
|
-
// 2. Cached salt from tracking
|
|
46
|
-
if (stageData?.salt) {
|
|
47
|
-
candidates.push({ salt: stageData.salt, source: "cached" });
|
|
48
|
-
}
|
|
49
|
-
// 3. Decoded salt from L2→L1 message (L1 timelock scheduling call)
|
|
50
|
-
// This is the actual salt that was sent to L1 - 100% accurate!
|
|
51
|
-
// This was decoded during L2_TO_L1_MESSAGE tracking and stored in stage data
|
|
52
|
-
if (allStages && stage.type === "L1_TIMELOCK") {
|
|
53
|
-
const l2ToL1Stage = allStages.find((s) => s.type === "L2_TO_L1_MESSAGE");
|
|
54
|
-
if (l2ToL1Stage) {
|
|
55
|
-
const l2ToL1Data = (0, types_1.getStageData)(l2ToL1Stage, "L2_TO_L1_MESSAGE");
|
|
56
|
-
if (l2ToL1Data?.l1TimelockSalt) {
|
|
57
|
-
candidates.push({ salt: l2ToL1Data.l1TimelockSalt, source: "cached" });
|
|
58
|
-
// Also use the decoded predecessor if available and not overridden
|
|
59
|
-
if (!options.predecessor && l2ToL1Data.l1TimelockPredecessor) {
|
|
60
|
-
options.predecessor = l2ToL1Data.l1TimelockPredecessor;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
// 4. Security Council: use on-chain generation
|
|
66
|
-
// Security Council data is enriched in L2_TIMELOCK stage during tracking
|
|
67
|
-
const members = stageData?.securityCouncilMembers;
|
|
68
|
-
const nonce = stageData?.securityCouncilNonce;
|
|
69
|
-
if (members?.length && nonce !== undefined) {
|
|
70
|
-
const nonceValue = ethers_1.BigNumber.isBigNumber(nonce) ? nonce : ethers_1.BigNumber.from(nonce);
|
|
71
|
-
try {
|
|
72
|
-
const scSalt = provider
|
|
73
|
-
? await (0, security_council_1.generateSecurityCouncilSalt)(members, nonceValue, provider)
|
|
74
|
-
: (0, operation_id_1.saltForSecurityCouncil)(members, nonceValue);
|
|
75
|
-
candidates.push({ salt: scSalt, source: "security-council" });
|
|
76
|
-
}
|
|
77
|
-
catch {
|
|
78
|
-
// Skip if security council salt generation fails
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
// 5. Derive from proposal description
|
|
82
|
-
// Description is stored in PROPOSAL_CREATED stage, extract it if allStages provided
|
|
83
|
-
let description;
|
|
84
|
-
if (allStages) {
|
|
85
|
-
const proposalStage = allStages.find((s) => s.type === "PROPOSAL_CREATED");
|
|
86
|
-
if (proposalStage) {
|
|
87
|
-
const proposalData = (0, types_1.getStageData)(proposalStage, "PROPOSAL_CREATED");
|
|
88
|
-
description = proposalData?.description;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
// Fallback to options or stage data (for backward compatibility)
|
|
92
|
-
description = description ?? options.description ?? stageData?.description;
|
|
93
|
-
if (description) {
|
|
94
|
-
candidates.push({ salt: (0, operation_id_1.saltFromDescription)(description), source: "description" });
|
|
95
|
-
}
|
|
96
|
-
// 6. HashZero as last resort
|
|
97
|
-
candidates.push({ salt: ethers_1.ethers.constants.HashZero, source: "hash-zero" });
|
|
98
|
-
return candidates;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Error thrown when salt cannot be resolved from available sources.
|
|
102
|
-
* This prevents silent failures that would cause mysterious on-chain errors.
|
|
103
|
-
*/
|
|
104
|
-
class SaltResolutionError extends Error {
|
|
105
|
-
constructor(message, attemptedSources, stageType) {
|
|
106
|
-
super(message);
|
|
107
|
-
this.attemptedSources = attemptedSources;
|
|
108
|
-
this.stageType = stageType;
|
|
109
|
-
this.name = "SaltResolutionError";
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
exports.SaltResolutionError = SaltResolutionError;
|
|
113
|
-
/**
|
|
114
|
-
* Get prepare options with resolved salt for a stage.
|
|
115
|
-
*
|
|
116
|
-
* IMPORTANT: Throws SaltResolutionError if salt cannot be resolved from any source.
|
|
117
|
-
*
|
|
118
|
-
* @param stage - The stage being prepared
|
|
119
|
-
* @param options - Preparation options
|
|
120
|
-
* @param provider - Provider for on-chain operations
|
|
121
|
-
* @param allStages - All tracked stages (used to extract context)
|
|
122
|
-
* @throws {SaltResolutionError} if no salt can be resolved
|
|
123
|
-
*/
|
|
124
|
-
async function resolveExecuteOptionsForStage(stage, options = {}, provider, allStages) {
|
|
125
|
-
const candidates = await getSaltCandidates(stage, options, provider, allStages);
|
|
126
|
-
// If only HashZero is available, it means no actual salt source was found
|
|
127
|
-
// This should be an error because we don't know the correct salt
|
|
128
|
-
const hasActualSaltSource = candidates.some((c) => c.source !== "hash-zero");
|
|
129
|
-
if (!hasActualSaltSource) {
|
|
130
|
-
const attemptedSources = candidates.map((c) => c.source);
|
|
131
|
-
throw new SaltResolutionError(`Cannot resolve salt for stage ${stage.type}. ` +
|
|
132
|
-
`Attempted sources: ${attemptedSources.length > 0 ? attemptedSources.join(", ") : "none available"}. ` +
|
|
133
|
-
`Provide an explicit salt via options.salt or ensure stage.data contains the required salt source ` +
|
|
134
|
-
`(description for governor proposals, securityCouncilMembers+nonce for SC updates).`, attemptedSources, stage.type);
|
|
135
|
-
}
|
|
136
|
-
const resolvedSalt = candidates[0]?.salt ?? ethers_1.ethers.constants.HashZero;
|
|
137
|
-
return {
|
|
138
|
-
...options,
|
|
139
|
-
salt: resolvedSalt,
|
|
140
|
-
predecessor: options.predecessor ?? ethers_1.ethers.constants.HashZero,
|
|
141
|
-
skipSaltValidation: options.skipSaltValidation ?? false,
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
//# sourceMappingURL=salt-resolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"salt-resolver.js","sourceRoot":"","sources":["../../src/utils/salt-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAmCH,8CA2EC;AA4BD,sEAiCC;AAz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