@gzeoneth/gov-tracker 0.1.1-0 → 0.1.1-2
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 -65
- 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 -76
- 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 +3 -3
- 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/stages/voting.d.ts.map +1 -1
- package/dist/stages/voting.js +15 -4
- package/dist/stages/voting.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 +49 -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/types/stages.d.ts +4 -0
- package/dist/types/stages.d.ts.map +1 -1
- package/dist/types/stages.js.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 +1 -1
- 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,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Address Aliasing
|
|
3
|
-
*
|
|
4
|
-
* Calculates aliased addresses for L1→L2 message sender context.
|
|
5
|
-
* When an L1 contract sends a message to L2, Arbitrum applies an address offset.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Address alias offset applied by Arbitrum for L1→L2 messages
|
|
9
|
-
* Formula: aliased = (address + offset) % 2^160
|
|
10
|
-
*/
|
|
11
|
-
export declare const ADDRESS_ALIAS_OFFSET: bigint;
|
|
12
|
-
/**
|
|
13
|
-
* L1 Timelock address
|
|
14
|
-
*/
|
|
15
|
-
export declare const L1_TIMELOCK_ADDRESS = "0xE6841D92B0C345144506576eC13ECf5103aC7f49";
|
|
16
|
-
/**
|
|
17
|
-
* Calculate the aliased address for L1→L2 messaging
|
|
18
|
-
*
|
|
19
|
-
* When an L1 contract sends a message to L2, its address is aliased
|
|
20
|
-
* to prevent it from impersonating existing L2 contracts.
|
|
21
|
-
*
|
|
22
|
-
* @param l1Address - L1 contract address
|
|
23
|
-
* @returns Aliased address on L2
|
|
24
|
-
*/
|
|
25
|
-
export declare function calculateAddressAlias(l1Address: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* Get the aliased address for the L1 Timelock
|
|
28
|
-
*
|
|
29
|
-
* This is the "from" address to use when simulating retryable
|
|
30
|
-
* ticket redemptions on L2.
|
|
31
|
-
*
|
|
32
|
-
* @returns Aliased L1 Timelock address
|
|
33
|
-
*/
|
|
34
|
-
export declare function getL1TimelockAlias(): string;
|
|
35
|
-
//# sourceMappingURL=address-alias.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"address-alias.d.ts","sourceRoot":"","sources":["../../src/simulation/address-alias.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAAuD,CAAC;AAEzF;;GAEG;AACH,eAAO,MAAM,mBAAmB,+CAA+C,CAAC;AAEhF;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAI/D;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Address Aliasing
|
|
4
|
-
*
|
|
5
|
-
* Calculates aliased addresses for L1→L2 message sender context.
|
|
6
|
-
* When an L1 contract sends a message to L2, Arbitrum applies an address offset.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.L1_TIMELOCK_ADDRESS = exports.ADDRESS_ALIAS_OFFSET = void 0;
|
|
10
|
-
exports.calculateAddressAlias = calculateAddressAlias;
|
|
11
|
-
exports.getL1TimelockAlias = getL1TimelockAlias;
|
|
12
|
-
/**
|
|
13
|
-
* Address alias offset applied by Arbitrum for L1→L2 messages
|
|
14
|
-
* Formula: aliased = (address + offset) % 2^160
|
|
15
|
-
*/
|
|
16
|
-
exports.ADDRESS_ALIAS_OFFSET = BigInt("0x1111000000000000000000000000000000001111");
|
|
17
|
-
/**
|
|
18
|
-
* L1 Timelock address
|
|
19
|
-
*/
|
|
20
|
-
exports.L1_TIMELOCK_ADDRESS = "0xE6841D92B0C345144506576eC13ECf5103aC7f49";
|
|
21
|
-
/**
|
|
22
|
-
* Calculate the aliased address for L1→L2 messaging
|
|
23
|
-
*
|
|
24
|
-
* When an L1 contract sends a message to L2, its address is aliased
|
|
25
|
-
* to prevent it from impersonating existing L2 contracts.
|
|
26
|
-
*
|
|
27
|
-
* @param l1Address - L1 contract address
|
|
28
|
-
* @returns Aliased address on L2
|
|
29
|
-
*/
|
|
30
|
-
function calculateAddressAlias(l1Address) {
|
|
31
|
-
const address = BigInt(l1Address);
|
|
32
|
-
const alias = (address + exports.ADDRESS_ALIAS_OFFSET) % BigInt(2 ** 160);
|
|
33
|
-
return "0x" + alias.toString(16).padStart(40, "0");
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Get the aliased address for the L1 Timelock
|
|
37
|
-
*
|
|
38
|
-
* This is the "from" address to use when simulating retryable
|
|
39
|
-
* ticket redemptions on L2.
|
|
40
|
-
*
|
|
41
|
-
* @returns Aliased L1 Timelock address
|
|
42
|
-
*/
|
|
43
|
-
function getL1TimelockAlias() {
|
|
44
|
-
return calculateAddressAlias(exports.L1_TIMELOCK_ADDRESS);
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=address-alias.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"address-alias.js","sourceRoot":"","sources":["../../src/simulation/address-alias.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAsBH,sDAIC;AAUD,gDAEC;AApCD;;;GAGG;AACU,QAAA,oBAAoB,GAAG,MAAM,CAAC,4CAA4C,CAAC,CAAC;AAEzF;;GAEG;AACU,QAAA,mBAAmB,GAAG,4CAA4C,CAAC;AAEhF;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CAAC,SAAiB;IACrD,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;IAClC,MAAM,KAAK,GAAG,CAAC,OAAO,GAAG,4BAAoB,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;IAClE,OAAO,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,kBAAkB;IAChC,OAAO,qBAAqB,CAAC,2BAAmB,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Salt Resolution for Timelock Execution
|
|
3
|
-
*
|
|
4
|
-
* Salt resolution hierarchy:
|
|
5
|
-
* 1. options.salt (explicit override)
|
|
6
|
-
* 2. stage.data.salt (cached from tracking)
|
|
7
|
-
* 3. Security Council: generateSalt(members, nonce)
|
|
8
|
-
* 4. Governor: keccak256(description)
|
|
9
|
-
* 5. HashZero (0x00...00) - last resort for operations that use default salt
|
|
10
|
-
* 6. FAIL - throw error if no salt matches the operation ID
|
|
11
|
-
*
|
|
12
|
-
* Each resolved salt is validated against the expected operation ID before use.
|
|
13
|
-
* If validation fails, the next option in the hierarchy is tried.
|
|
14
|
-
*/
|
|
15
|
-
import { ethers } from "ethers";
|
|
16
|
-
import { PrepareOptions, TrackedStage } from "../types";
|
|
17
|
-
import { saltFromDescription, saltForSecurityCouncil } from "../utils/operation-id";
|
|
18
|
-
export { saltFromDescription, saltForSecurityCouncil };
|
|
19
|
-
/**
|
|
20
|
-
* Resolved prepare options with required salt and predecessor
|
|
21
|
-
*/
|
|
22
|
-
export type ResolvedExecuteOptions = Required<Pick<PrepareOptions, "salt" | "predecessor">> & Omit<PrepareOptions, "salt" | "predecessor">;
|
|
23
|
-
/**
|
|
24
|
-
* Candidate salts in priority order for validation
|
|
25
|
-
*/
|
|
26
|
-
export interface SaltCandidate {
|
|
27
|
-
salt: string;
|
|
28
|
-
source: "explicit" | "cached" | "security-council" | "description" | "hash-zero";
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Get all candidate salts from a TrackedStage in priority order.
|
|
32
|
-
*
|
|
33
|
-
* Returns an array of salt candidates to try, in order of priority.
|
|
34
|
-
* The caller is responsible for validating each salt against the operation ID.
|
|
35
|
-
*
|
|
36
|
-
* @param stage - The stage being prepared (L2_TIMELOCK or L1_TIMELOCK)
|
|
37
|
-
* @param options - Preparation options (can include explicit salt override)
|
|
38
|
-
* @param provider - Provider for on-chain salt generation
|
|
39
|
-
* @param allStages - All tracked stages (used to extract context from other stages)
|
|
40
|
-
*/
|
|
41
|
-
export declare function getSaltCandidates(stage: TrackedStage, options?: PrepareOptions, provider?: ethers.providers.Provider, allStages?: TrackedStage[]): Promise<SaltCandidate[]>;
|
|
42
|
-
/**
|
|
43
|
-
* Error thrown when salt cannot be resolved from available sources.
|
|
44
|
-
* This prevents silent failures that would cause mysterious on-chain errors.
|
|
45
|
-
*/
|
|
46
|
-
export declare class SaltResolutionError extends Error {
|
|
47
|
-
readonly attemptedSources: SaltCandidate["source"][];
|
|
48
|
-
readonly stageType: string;
|
|
49
|
-
constructor(message: string, attemptedSources: SaltCandidate["source"][], stageType: string);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Get prepare options with resolved salt for a stage.
|
|
53
|
-
*
|
|
54
|
-
* IMPORTANT: Throws SaltResolutionError if salt cannot be resolved from any source.
|
|
55
|
-
*
|
|
56
|
-
* @param stage - The stage being prepared
|
|
57
|
-
* @param options - Preparation options
|
|
58
|
-
* @param provider - Provider for on-chain operations
|
|
59
|
-
* @param allStages - All tracked stages (used to extract context)
|
|
60
|
-
* @throws {SaltResolutionError} if no salt can be resolved
|
|
61
|
-
*/
|
|
62
|
-
export declare function resolveExecuteOptionsForStage(stage: TrackedStage, options?: PrepareOptions, provider?: ethers.providers.Provider, allStages?: TrackedStage[]): Promise<ResolvedExecuteOptions>;
|
|
63
|
-
//# sourceMappingURL=salt-resolver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"salt-resolver.d.ts","sourceRoot":"","sources":["../../src/utils/salt-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,MAAM,EAAa,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAgB,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAIpF,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,GACzF,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,GAAG,QAAQ,GAAG,kBAAkB,GAAG,aAAa,GAAG,WAAW,CAAC;CAClF;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,YAAY,EACnB,OAAO,GAAE,cAAmB,EAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,EACpC,SAAS,CAAC,EAAE,YAAY,EAAE,GACzB,OAAO,CAAC,aAAa,EAAE,CAAC,CAsE1B;AAED;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;aAG1B,gBAAgB,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE;aAC3C,SAAS,EAAE,MAAM;gBAFjC,OAAO,EAAE,MAAM,EACC,gBAAgB,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,EAC3C,SAAS,EAAE,MAAM;CAKpC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,6BAA6B,CACjD,KAAK,EAAE,YAAY,EACnB,OAAO,GAAE,cAAmB,EAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,EACpC,SAAS,CAAC,EAAE,YAAY,EAAE,GACzB,OAAO,CAAC,sBAAsB,CAAC,CA4BjC"}
|
|
@@ -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;AAzKD,mCAA2C;AAC3C,oCAAsE;AACtE,wDAAoF;AAI3E,oGAJA,kCAAmB,OAIA;AAAE,uGAJA,qCAAsB,OAIA;AAHpD,oEAA4E;AAmB5E;;;;;;;;;;GAUG;AACI,KAAK,U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