@gzeoneth/gov-tracker 0.2.1-beta.b2eeb41 → 0.2.1-beta.c266765
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/README.md +41 -2
- package/dist/abis.d.ts.map +1 -1
- package/dist/abis.js +22 -1
- package/dist/abis.js.map +1 -1
- package/dist/cli/cli.js +206 -12
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/lib/cli.d.ts +9 -1
- package/dist/cli/lib/cli.d.ts.map +1 -1
- package/dist/cli/lib/cli.js +80 -4
- package/dist/cli/lib/cli.js.map +1 -1
- package/dist/data/bundled-cache.json +1155 -962
- package/dist/deduplication.d.ts +132 -0
- package/dist/deduplication.d.ts.map +1 -0
- package/dist/deduplication.js +270 -0
- package/dist/deduplication.js.map +1 -0
- package/dist/election.d.ts +141 -1
- package/dist/election.d.ts.map +1 -1
- package/dist/election.js +505 -88
- package/dist/election.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -3
- package/dist/index.js.map +1 -1
- package/dist/stages/builder.d.ts +4 -0
- package/dist/stages/builder.d.ts.map +1 -1
- package/dist/stages/builder.js +7 -0
- package/dist/stages/builder.js.map +1 -1
- package/dist/stages/voting.d.ts.map +1 -1
- package/dist/stages/voting.js +5 -4
- package/dist/stages/voting.js.map +1 -1
- package/dist/tracker/discovery.d.ts +39 -8
- package/dist/tracker/discovery.d.ts.map +1 -1
- package/dist/tracker/discovery.js +141 -12
- package/dist/tracker/discovery.js.map +1 -1
- package/dist/tracker.d.ts +24 -4
- package/dist/tracker.d.ts.map +1 -1
- package/dist/tracker.js +57 -8
- package/dist/tracker.js.map +1 -1
- package/dist/types/core.d.ts +1 -1
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/election.d.ts +88 -0
- package/dist/types/election.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/stages.d.ts +6 -0
- package/dist/types/stages.d.ts.map +1 -1
- package/dist/types/stages.js.map +1 -1
- package/dist/types/tracking.d.ts +27 -1
- package/dist/types/tracking.d.ts.map +1 -1
- package/dist/utils/timing.d.ts +13 -0
- package/dist/utils/timing.d.ts.map +1 -1
- package/dist/utils/timing.js +35 -0
- package/dist/utils/timing.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkpoint Deduplication Helpers
|
|
3
|
+
*
|
|
4
|
+
* Both regular governance proposals and Security Council elections can create
|
|
5
|
+
* "child" timelock operations that get tracked separately. This module provides
|
|
6
|
+
* utilities to identify, link, and filter these relationships.
|
|
7
|
+
*
|
|
8
|
+
* ## How Duplication Occurs
|
|
9
|
+
*
|
|
10
|
+
* **Proposals:**
|
|
11
|
+
* 1. Proposal is tracked with key `tx:{creation_hash}`
|
|
12
|
+
* 2. Proposal queues to L2 timelock → creates child timelock operation
|
|
13
|
+
* 3. If L2 timelock op is discovered separately, it gets key `tx:{schedule_hash}`
|
|
14
|
+
*
|
|
15
|
+
* **Elections:**
|
|
16
|
+
* 1. Election is tracked with key `election:{index}`
|
|
17
|
+
* 2. Member election execute → SecurityCouncilManager.replaceCohort()
|
|
18
|
+
* 3. This schedules to L2 Constitutional timelock → creates child timelock op
|
|
19
|
+
* 4. If discovered separately, gets key `tx:{schedule_hash}`
|
|
20
|
+
*
|
|
21
|
+
* ## Deduplication Strategy
|
|
22
|
+
*
|
|
23
|
+
* Child checkpoints have `metadata.sourceCheckpoint` set to their parent key.
|
|
24
|
+
* Use `filterChildCheckpoints()` to exclude children when listing all tracked items.
|
|
25
|
+
*
|
|
26
|
+
* @module deduplication
|
|
27
|
+
*/
|
|
28
|
+
import { TrackingCheckpoint, TrackingResult, CacheAdapter } from "./types";
|
|
29
|
+
/**
|
|
30
|
+
* Check if a timelock operation calldata involves Security Council management
|
|
31
|
+
*
|
|
32
|
+
* @param operationData - Calldata of the timelock operation
|
|
33
|
+
* @returns True if this likely originated from an election
|
|
34
|
+
*/
|
|
35
|
+
export declare function isSecurityCouncilTimelockOp(operationData: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Link a child checkpoint to its parent
|
|
38
|
+
*
|
|
39
|
+
* Updates the child checkpoint's metadata to reference its parent.
|
|
40
|
+
* This enables filtering out child checkpoints when displaying tracked items.
|
|
41
|
+
*
|
|
42
|
+
* @param childKey - Cache key for the child checkpoint (e.g., "tx:0x...")
|
|
43
|
+
* @param parentKey - Cache key for the parent (e.g., "election:5" or "tx:0x...")
|
|
44
|
+
* @param cache - Cache adapter to update
|
|
45
|
+
*/
|
|
46
|
+
export declare function linkCheckpointToChild(childKey: string, parentKey: string, cache: CacheAdapter): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Get the parent checkpoint key for a child, if it exists
|
|
49
|
+
*
|
|
50
|
+
* @param childKey - Cache key to check
|
|
51
|
+
* @param cache - Cache adapter to read from
|
|
52
|
+
* @returns Parent key or null if not a child
|
|
53
|
+
*/
|
|
54
|
+
export declare function getParentCheckpoint(childKey: string, cache: CacheAdapter): Promise<string | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Check if a checkpoint is a child of another checkpoint
|
|
57
|
+
*
|
|
58
|
+
* @param key - Cache key to check
|
|
59
|
+
* @param cache - Cache adapter to read from
|
|
60
|
+
* @returns True if this checkpoint has a parent
|
|
61
|
+
*/
|
|
62
|
+
export declare function isChildCheckpoint(key: string, cache: CacheAdapter): Promise<boolean>;
|
|
63
|
+
/**
|
|
64
|
+
* Filter out child checkpoints from tracking results
|
|
65
|
+
*
|
|
66
|
+
* Use this when displaying tracked items to avoid showing duplicates.
|
|
67
|
+
* Children are operations that were spawned by a parent proposal/election.
|
|
68
|
+
*
|
|
69
|
+
* @param results - Array of tracking results to filter
|
|
70
|
+
* @returns Results with child checkpoints removed
|
|
71
|
+
*/
|
|
72
|
+
export declare function filterChildCheckpoints(results: TrackingResult[]): TrackingResult[];
|
|
73
|
+
/**
|
|
74
|
+
* Get all child checkpoints and their parents
|
|
75
|
+
*
|
|
76
|
+
* @param cache - Cache adapter to read from
|
|
77
|
+
* @returns Map of child key to parent key
|
|
78
|
+
*/
|
|
79
|
+
export declare function getChildToParentMap(cache: CacheAdapter): Promise<Map<string, string>>;
|
|
80
|
+
/**
|
|
81
|
+
* Get all children for a given parent checkpoint
|
|
82
|
+
*
|
|
83
|
+
* @param parentKey - The parent checkpoint key
|
|
84
|
+
* @param cache - Cache adapter to read from
|
|
85
|
+
* @returns Array of child checkpoint keys
|
|
86
|
+
*/
|
|
87
|
+
export declare function getChildCheckpoints(parentKey: string, cache: CacheAdapter): Promise<string[]>;
|
|
88
|
+
/**
|
|
89
|
+
* Deduplication statistics
|
|
90
|
+
*/
|
|
91
|
+
export interface DeduplicationStats {
|
|
92
|
+
/** Total checkpoints (excluding watermarks) */
|
|
93
|
+
totalCheckpoints: number;
|
|
94
|
+
/** Root checkpoints (no parent) */
|
|
95
|
+
rootCheckpoints: number;
|
|
96
|
+
/** Child checkpoints (have a parent) */
|
|
97
|
+
childCheckpoints: number;
|
|
98
|
+
/** Breakdown by parent type */
|
|
99
|
+
parentTypes: {
|
|
100
|
+
/** Children of election checkpoints */
|
|
101
|
+
fromElections: number;
|
|
102
|
+
/** Children of proposal/timelock checkpoints */
|
|
103
|
+
fromProposals: number;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get deduplication statistics for the cache
|
|
108
|
+
*
|
|
109
|
+
* @param cache - Cache adapter to analyze
|
|
110
|
+
* @returns Statistics about checkpoint relationships
|
|
111
|
+
*/
|
|
112
|
+
export declare function getDeduplicationStats(cache: CacheAdapter): Promise<DeduplicationStats>;
|
|
113
|
+
/**
|
|
114
|
+
* Find potential parent for a timelock checkpoint
|
|
115
|
+
*
|
|
116
|
+
* Searches for elections or proposals that may have created this timelock operation.
|
|
117
|
+
*
|
|
118
|
+
* @param timelockCheckpoint - The timelock checkpoint to find a parent for
|
|
119
|
+
* @param cache - Cache adapter to search
|
|
120
|
+
* @returns Parent key or null if no parent found
|
|
121
|
+
*/
|
|
122
|
+
export declare function findPotentialParent(timelockCheckpoint: TrackingCheckpoint, cache: CacheAdapter): Promise<string | null>;
|
|
123
|
+
/**
|
|
124
|
+
* Auto-link orphaned timelock checkpoints to their parents
|
|
125
|
+
*
|
|
126
|
+
* Scans for timelock checkpoints without parents and attempts to find and link them.
|
|
127
|
+
*
|
|
128
|
+
* @param cache - Cache adapter to update
|
|
129
|
+
* @returns Number of newly linked checkpoints
|
|
130
|
+
*/
|
|
131
|
+
export declare function autoLinkOrphanedCheckpoints(cache: CacheAdapter): Promise<number>;
|
|
132
|
+
//# sourceMappingURL=deduplication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deduplication.d.ts","sourceRoot":"","sources":["../src/deduplication.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAyB3E;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAI1E;AAED;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGxB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAG1F;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE,CAElF;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAY3F;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,MAAM,EAAE,CAAC,CAYnB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,+CAA+C;IAC/C,gBAAgB,EAAE,MAAM,CAAC;IACzB,mCAAmC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,wCAAwC;IACxC,gBAAgB,EAAE,MAAM,CAAC;IACzB,+BAA+B;IAC/B,WAAW,EAAE;QACX,uCAAuC;QACvC,aAAa,EAAE,MAAM,CAAC;QACtB,gDAAgD;QAChD,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAoC5F;AAED;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,kBAAkB,EAAE,kBAAkB,EACtC,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiCxB;AAED;;;;;;;GAOG;AACH,wBAAsB,2BAA2B,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CA0BtF"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Checkpoint Deduplication Helpers
|
|
4
|
+
*
|
|
5
|
+
* Both regular governance proposals and Security Council elections can create
|
|
6
|
+
* "child" timelock operations that get tracked separately. This module provides
|
|
7
|
+
* utilities to identify, link, and filter these relationships.
|
|
8
|
+
*
|
|
9
|
+
* ## How Duplication Occurs
|
|
10
|
+
*
|
|
11
|
+
* **Proposals:**
|
|
12
|
+
* 1. Proposal is tracked with key `tx:{creation_hash}`
|
|
13
|
+
* 2. Proposal queues to L2 timelock → creates child timelock operation
|
|
14
|
+
* 3. If L2 timelock op is discovered separately, it gets key `tx:{schedule_hash}`
|
|
15
|
+
*
|
|
16
|
+
* **Elections:**
|
|
17
|
+
* 1. Election is tracked with key `election:{index}`
|
|
18
|
+
* 2. Member election execute → SecurityCouncilManager.replaceCohort()
|
|
19
|
+
* 3. This schedules to L2 Constitutional timelock → creates child timelock op
|
|
20
|
+
* 4. If discovered separately, gets key `tx:{schedule_hash}`
|
|
21
|
+
*
|
|
22
|
+
* ## Deduplication Strategy
|
|
23
|
+
*
|
|
24
|
+
* Child checkpoints have `metadata.sourceCheckpoint` set to their parent key.
|
|
25
|
+
* Use `filterChildCheckpoints()` to exclude children when listing all tracked items.
|
|
26
|
+
*
|
|
27
|
+
* @module deduplication
|
|
28
|
+
*/
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.isSecurityCouncilTimelockOp = isSecurityCouncilTimelockOp;
|
|
31
|
+
exports.linkCheckpointToChild = linkCheckpointToChild;
|
|
32
|
+
exports.getParentCheckpoint = getParentCheckpoint;
|
|
33
|
+
exports.isChildCheckpoint = isChildCheckpoint;
|
|
34
|
+
exports.filterChildCheckpoints = filterChildCheckpoints;
|
|
35
|
+
exports.getChildToParentMap = getChildToParentMap;
|
|
36
|
+
exports.getChildCheckpoints = getChildCheckpoints;
|
|
37
|
+
exports.getDeduplicationStats = getDeduplicationStats;
|
|
38
|
+
exports.findPotentialParent = findPotentialParent;
|
|
39
|
+
exports.autoLinkOrphanedCheckpoints = autoLinkOrphanedCheckpoints;
|
|
40
|
+
const constants_1 = require("./constants");
|
|
41
|
+
const logger_1 = require("./utils/logger");
|
|
42
|
+
const log = logger_1.loggers.tracker;
|
|
43
|
+
/** Helper to get cache keys as array (handles sync and async returns) */
|
|
44
|
+
async function getCacheKeysAsync(cache) {
|
|
45
|
+
if (typeof cache.keys !== "function")
|
|
46
|
+
return [];
|
|
47
|
+
const result = cache.keys();
|
|
48
|
+
// Handle Promise<string[]>
|
|
49
|
+
if (result instanceof Promise) {
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
// Handle IterableIterator<string> or string[]
|
|
53
|
+
if (Symbol.iterator in Object(result)) {
|
|
54
|
+
return [...result];
|
|
55
|
+
}
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Check if a timelock operation calldata involves Security Council management
|
|
60
|
+
*
|
|
61
|
+
* @param operationData - Calldata of the timelock operation
|
|
62
|
+
* @returns True if this likely originated from an election
|
|
63
|
+
*/
|
|
64
|
+
function isSecurityCouncilTimelockOp(operationData) {
|
|
65
|
+
const scManagerAddress = constants_1.ADDRESSES.SECURITY_COUNCIL_MANAGER?.toLowerCase();
|
|
66
|
+
if (!scManagerAddress)
|
|
67
|
+
return false;
|
|
68
|
+
return operationData.toLowerCase().includes(scManagerAddress.slice(2));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Link a child checkpoint to its parent
|
|
72
|
+
*
|
|
73
|
+
* Updates the child checkpoint's metadata to reference its parent.
|
|
74
|
+
* This enables filtering out child checkpoints when displaying tracked items.
|
|
75
|
+
*
|
|
76
|
+
* @param childKey - Cache key for the child checkpoint (e.g., "tx:0x...")
|
|
77
|
+
* @param parentKey - Cache key for the parent (e.g., "election:5" or "tx:0x...")
|
|
78
|
+
* @param cache - Cache adapter to update
|
|
79
|
+
*/
|
|
80
|
+
async function linkCheckpointToChild(childKey, parentKey, cache) {
|
|
81
|
+
const checkpoint = await cache.get(childKey);
|
|
82
|
+
if (!checkpoint) {
|
|
83
|
+
log("Cannot link - child checkpoint %s not found", childKey);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// Initialize metadata if not present, then set sourceCheckpoint
|
|
87
|
+
checkpoint.metadata = checkpoint.metadata ?? { errorCount: 0, lastTrackedAt: Date.now() };
|
|
88
|
+
checkpoint.metadata.sourceCheckpoint = parentKey;
|
|
89
|
+
await cache.set(childKey, checkpoint);
|
|
90
|
+
log("Linked %s as child of %s", childKey, parentKey);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get the parent checkpoint key for a child, if it exists
|
|
94
|
+
*
|
|
95
|
+
* @param childKey - Cache key to check
|
|
96
|
+
* @param cache - Cache adapter to read from
|
|
97
|
+
* @returns Parent key or null if not a child
|
|
98
|
+
*/
|
|
99
|
+
async function getParentCheckpoint(childKey, cache) {
|
|
100
|
+
const checkpoint = await cache.get(childKey);
|
|
101
|
+
return checkpoint?.metadata?.sourceCheckpoint ?? null;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Check if a checkpoint is a child of another checkpoint
|
|
105
|
+
*
|
|
106
|
+
* @param key - Cache key to check
|
|
107
|
+
* @param cache - Cache adapter to read from
|
|
108
|
+
* @returns True if this checkpoint has a parent
|
|
109
|
+
*/
|
|
110
|
+
async function isChildCheckpoint(key, cache) {
|
|
111
|
+
const parent = await getParentCheckpoint(key, cache);
|
|
112
|
+
return parent !== null;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Filter out child checkpoints from tracking results
|
|
116
|
+
*
|
|
117
|
+
* Use this when displaying tracked items to avoid showing duplicates.
|
|
118
|
+
* Children are operations that were spawned by a parent proposal/election.
|
|
119
|
+
*
|
|
120
|
+
* @param results - Array of tracking results to filter
|
|
121
|
+
* @returns Results with child checkpoints removed
|
|
122
|
+
*/
|
|
123
|
+
function filterChildCheckpoints(results) {
|
|
124
|
+
return results.filter((r) => r.checkpoint.metadata?.sourceCheckpoint === undefined);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Get all child checkpoints and their parents
|
|
128
|
+
*
|
|
129
|
+
* @param cache - Cache adapter to read from
|
|
130
|
+
* @returns Map of child key to parent key
|
|
131
|
+
*/
|
|
132
|
+
async function getChildToParentMap(cache) {
|
|
133
|
+
const result = new Map();
|
|
134
|
+
const keys = await getCacheKeysAsync(cache);
|
|
135
|
+
for (const key of keys) {
|
|
136
|
+
const checkpoint = await cache.get(key);
|
|
137
|
+
if (checkpoint?.metadata?.sourceCheckpoint) {
|
|
138
|
+
result.set(key, checkpoint.metadata.sourceCheckpoint);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get all children for a given parent checkpoint
|
|
145
|
+
*
|
|
146
|
+
* @param parentKey - The parent checkpoint key
|
|
147
|
+
* @param cache - Cache adapter to read from
|
|
148
|
+
* @returns Array of child checkpoint keys
|
|
149
|
+
*/
|
|
150
|
+
async function getChildCheckpoints(parentKey, cache) {
|
|
151
|
+
const children = [];
|
|
152
|
+
const keys = await getCacheKeysAsync(cache);
|
|
153
|
+
for (const key of keys) {
|
|
154
|
+
const checkpoint = await cache.get(key);
|
|
155
|
+
if (checkpoint?.metadata?.sourceCheckpoint === parentKey) {
|
|
156
|
+
children.push(key);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return children;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get deduplication statistics for the cache
|
|
163
|
+
*
|
|
164
|
+
* @param cache - Cache adapter to analyze
|
|
165
|
+
* @returns Statistics about checkpoint relationships
|
|
166
|
+
*/
|
|
167
|
+
async function getDeduplicationStats(cache) {
|
|
168
|
+
const keys = await getCacheKeysAsync(cache);
|
|
169
|
+
let totalCheckpoints = 0;
|
|
170
|
+
let childCheckpoints = 0;
|
|
171
|
+
let fromElections = 0;
|
|
172
|
+
let fromProposals = 0;
|
|
173
|
+
for (const key of keys) {
|
|
174
|
+
// Skip watermarks
|
|
175
|
+
if (key === "discovery:watermarks")
|
|
176
|
+
continue;
|
|
177
|
+
totalCheckpoints++;
|
|
178
|
+
const checkpoint = await cache.get(key);
|
|
179
|
+
const source = checkpoint?.metadata?.sourceCheckpoint;
|
|
180
|
+
if (source) {
|
|
181
|
+
childCheckpoints++;
|
|
182
|
+
if (source.startsWith("election:")) {
|
|
183
|
+
fromElections++;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
fromProposals++;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
totalCheckpoints,
|
|
192
|
+
rootCheckpoints: totalCheckpoints - childCheckpoints,
|
|
193
|
+
childCheckpoints,
|
|
194
|
+
parentTypes: {
|
|
195
|
+
fromElections,
|
|
196
|
+
fromProposals,
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Find potential parent for a timelock checkpoint
|
|
202
|
+
*
|
|
203
|
+
* Searches for elections or proposals that may have created this timelock operation.
|
|
204
|
+
*
|
|
205
|
+
* @param timelockCheckpoint - The timelock checkpoint to find a parent for
|
|
206
|
+
* @param cache - Cache adapter to search
|
|
207
|
+
* @returns Parent key or null if no parent found
|
|
208
|
+
*/
|
|
209
|
+
async function findPotentialParent(timelockCheckpoint, cache) {
|
|
210
|
+
if (timelockCheckpoint.input.type !== "timelock")
|
|
211
|
+
return null;
|
|
212
|
+
const keys = await getCacheKeysAsync(cache);
|
|
213
|
+
const timelockAddr = timelockCheckpoint.input.timelockAddress?.toLowerCase();
|
|
214
|
+
// Check if it's from L2 Constitutional timelock (elections schedule here)
|
|
215
|
+
const isL2ConstitutionalTimelock = timelockAddr === constants_1.ADDRESSES.L2_CONSTITUTIONAL_TIMELOCK?.toLowerCase();
|
|
216
|
+
if (isL2ConstitutionalTimelock) {
|
|
217
|
+
// Search completed elections that might have created this
|
|
218
|
+
for (const key of keys) {
|
|
219
|
+
if (!key.startsWith("election:"))
|
|
220
|
+
continue;
|
|
221
|
+
const electionCheckpoint = await cache.get(key);
|
|
222
|
+
const status = electionCheckpoint?.cachedData?.electionStatus;
|
|
223
|
+
// Completed elections with executed member proposals create timelock ops
|
|
224
|
+
if (status?.phase === "COMPLETED" && status.memberProposalId) {
|
|
225
|
+
// This election completed and may have created this timelock op
|
|
226
|
+
// Without more detailed tracking of the execution tx, we can't be 100% sure
|
|
227
|
+
// but this is a reasonable heuristic
|
|
228
|
+
return key;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// For non-constitutional timelocks or if no election found, search proposals
|
|
233
|
+
// This would require more complex tracking of proposal execution
|
|
234
|
+
// For now, return null and let the user manually link if needed
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Auto-link orphaned timelock checkpoints to their parents
|
|
239
|
+
*
|
|
240
|
+
* Scans for timelock checkpoints without parents and attempts to find and link them.
|
|
241
|
+
*
|
|
242
|
+
* @param cache - Cache adapter to update
|
|
243
|
+
* @returns Number of newly linked checkpoints
|
|
244
|
+
*/
|
|
245
|
+
async function autoLinkOrphanedCheckpoints(cache) {
|
|
246
|
+
const keys = await getCacheKeysAsync(cache);
|
|
247
|
+
let linkedCount = 0;
|
|
248
|
+
for (const key of keys) {
|
|
249
|
+
if (!key.startsWith("tx:"))
|
|
250
|
+
continue;
|
|
251
|
+
const checkpoint = await cache.get(key);
|
|
252
|
+
if (!checkpoint)
|
|
253
|
+
continue;
|
|
254
|
+
// Skip if already linked
|
|
255
|
+
if (checkpoint.metadata?.sourceCheckpoint)
|
|
256
|
+
continue;
|
|
257
|
+
// Skip if not a timelock checkpoint
|
|
258
|
+
if (checkpoint.input.type !== "timelock")
|
|
259
|
+
continue;
|
|
260
|
+
// Try to find a parent
|
|
261
|
+
const parentKey = await findPotentialParent(checkpoint, cache);
|
|
262
|
+
if (parentKey) {
|
|
263
|
+
await linkCheckpointToChild(key, parentKey, cache);
|
|
264
|
+
linkedCount++;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
log("Auto-linked %d orphaned checkpoints", linkedCount);
|
|
268
|
+
return linkedCount;
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=deduplication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deduplication.js","sourceRoot":"","sources":["../src/deduplication.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;AAiCH,kEAIC;AAYD,sDAiBC;AASD,kDAMC;AASD,8CAGC;AAWD,wDAEC;AAQD,kDAYC;AASD,kDAeC;AA2BD,sDAoCC;AAWD,kDAoCC;AAUD,kEA0BC;AArSD,2CAAwC;AACxC,2CAAyC;AAEzC,MAAM,GAAG,GAAG,gBAAO,CAAC,OAAO,CAAC;AAE5B,yEAAyE;AACzE,KAAK,UAAU,iBAAiB,CAAC,KAAmB;IAClD,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU;QAAE,OAAO,EAAE,CAAC;IAEhD,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAE5B,2BAA2B;IAC3B,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,8CAA8C;IAC9C,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,OAAO,CAAC,GAAI,MAA2B,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,2BAA2B,CAAC,aAAqB;IAC/D,MAAM,gBAAgB,GAAG,qBAAS,CAAC,wBAAwB,EAAE,WAAW,EAAE,CAAC;IAC3E,IAAI,CAAC,gBAAgB;QAAE,OAAO,KAAK,CAAC;IACpC,OAAO,aAAa,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,qBAAqB,CACzC,QAAgB,EAChB,SAAiB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|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module election
|
|
8
8
|
*/
|
|
9
9
|
import { ethers, BigNumber } from "ethers";
|
|
10
|
-
import { PreparedTransaction, ElectionProposalStatus, ElectionStatus } from "./types";
|
|
10
|
+
import { PreparedTransaction, ElectionProposalStatus, ElectionStatus, ElectionContender, ElectionNominee, NomineeElectionDetails, MemberElectionDetails } from "./types";
|
|
11
11
|
/**
|
|
12
12
|
* Prepared election creation transaction
|
|
13
13
|
*/
|
|
@@ -121,6 +121,7 @@ export declare function trackElectionProposal(electionIndex: number, l2Provider:
|
|
|
121
121
|
* Get the proposal ID for a given election index
|
|
122
122
|
*
|
|
123
123
|
* Uses getProposeArgs to get proposal parameters and hashProposal to calculate the proposal ID.
|
|
124
|
+
* Verifies the proposal exists by checking state() - returns null if proposal doesn't exist.
|
|
124
125
|
*
|
|
125
126
|
* @param electionIndex - Election index
|
|
126
127
|
* @param provider - L2 provider
|
|
@@ -128,6 +129,15 @@ export declare function trackElectionProposal(electionIndex: number, l2Provider:
|
|
|
128
129
|
* @returns Proposal ID or null if election not yet created
|
|
129
130
|
*/
|
|
130
131
|
export declare function getElectionProposalId(electionIndex: number, provider: ethers.providers.Provider, nomineeGovernorAddress?: string): Promise<string | null>;
|
|
132
|
+
/**
|
|
133
|
+
* Get the member election proposal ID for a given election index
|
|
134
|
+
*
|
|
135
|
+
* @param electionIndex - Election index
|
|
136
|
+
* @param provider - L2 provider
|
|
137
|
+
* @param memberGovernorAddress - Optional governor address override
|
|
138
|
+
* @returns Member proposal ID as string
|
|
139
|
+
*/
|
|
140
|
+
export declare function getMemberElectionProposalId(electionIndex: number, provider: ethers.providers.Provider, memberGovernorAddress?: string): Promise<string>;
|
|
131
141
|
/**
|
|
132
142
|
* Get the proposal parameters for an election proposal
|
|
133
143
|
*
|
|
@@ -169,4 +179,134 @@ export declare function getElectionProposalParams(electionIndex: number, provide
|
|
|
169
179
|
* ```
|
|
170
180
|
*/
|
|
171
181
|
export declare function prepareMemberElectionTrigger(electionStatus: Pick<ElectionProposalStatus, "electionIndex" | "canProceedToMemberPhase">, provider: ethers.providers.Provider, nomineeGovernorAddress?: string): Promise<PreparedTransaction | null>;
|
|
182
|
+
/**
|
|
183
|
+
* Get proposal parameters for a member election
|
|
184
|
+
*
|
|
185
|
+
* Retrieves the targets, values, calldatas, and description hash needed to
|
|
186
|
+
* execute a member election proposal.
|
|
187
|
+
*
|
|
188
|
+
* @param electionIndex - Election index
|
|
189
|
+
* @param provider - L2 provider
|
|
190
|
+
* @param memberGovernorAddress - Optional governor address override
|
|
191
|
+
* @returns Proposal parameters or null if not found
|
|
192
|
+
*/
|
|
193
|
+
export declare function getMemberElectionProposalParams(electionIndex: number, provider: ethers.providers.Provider, memberGovernorAddress?: string): Promise<ElectionProposalParams | null>;
|
|
194
|
+
/**
|
|
195
|
+
* Prepare a transaction to execute member election result
|
|
196
|
+
*
|
|
197
|
+
* After member voting succeeds, calling execute() on the MemberElectionGovernor
|
|
198
|
+
* installs the new Security Council members.
|
|
199
|
+
*
|
|
200
|
+
* @param electionStatus - Status from trackElectionProposal (must have canExecuteMember=true)
|
|
201
|
+
* @param provider - L2 provider
|
|
202
|
+
* @param memberGovernorAddress - Optional governor address override
|
|
203
|
+
* @returns Prepared transaction or null if not ready
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* const status = await trackElectionProposal(5, l2Provider, l1Provider);
|
|
208
|
+
*
|
|
209
|
+
* if (status.canExecuteMember) {
|
|
210
|
+
* const prepared = await prepareMemberElectionExecution(status, l2Provider);
|
|
211
|
+
* if (prepared) {
|
|
212
|
+
* const tx = await signer.sendTransaction({
|
|
213
|
+
* to: prepared.to,
|
|
214
|
+
* data: prepared.data,
|
|
215
|
+
* });
|
|
216
|
+
* await tx.wait();
|
|
217
|
+
* console.log("New Security Council members installed!");
|
|
218
|
+
* }
|
|
219
|
+
* }
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
export declare function prepareMemberElectionExecution(electionStatus: Pick<ElectionProposalStatus, "electionIndex" | "canExecuteMember">, provider: ethers.providers.Provider, memberGovernorAddress?: string): Promise<PreparedTransaction | null>;
|
|
223
|
+
/**
|
|
224
|
+
* Find the election index for a given proposal ID
|
|
225
|
+
*
|
|
226
|
+
* Searches through elections to find which one contains the given proposal ID
|
|
227
|
+
* (either as nominee or member proposal).
|
|
228
|
+
*
|
|
229
|
+
* @param proposalId - The proposal ID to find
|
|
230
|
+
* @param l2Provider - L2 provider
|
|
231
|
+
* @param l1Provider - L1 provider (needed for trackElectionProposal)
|
|
232
|
+
* @returns Election index or null if not found
|
|
233
|
+
*/
|
|
234
|
+
export declare function getElectionIndexForProposalId(proposalId: string, l2Provider: ethers.providers.Provider, l1Provider: ethers.providers.Provider): Promise<number | null>;
|
|
235
|
+
/**
|
|
236
|
+
* Track all active elections (not yet completed)
|
|
237
|
+
*
|
|
238
|
+
* Returns election statuses for all elections that are still in progress.
|
|
239
|
+
*
|
|
240
|
+
* @param l2Provider - L2 provider
|
|
241
|
+
* @param l1Provider - L1 provider
|
|
242
|
+
* @returns Array of election statuses for active elections
|
|
243
|
+
*/
|
|
244
|
+
export declare function trackAllElections(l2Provider: ethers.providers.Provider, l1Provider: ethers.providers.Provider): Promise<ElectionProposalStatus[]>;
|
|
245
|
+
/**
|
|
246
|
+
* Track only incomplete elections (not yet completed)
|
|
247
|
+
*
|
|
248
|
+
* Returns election statuses for elections that are still in progress.
|
|
249
|
+
* Completed elections are excluded.
|
|
250
|
+
*
|
|
251
|
+
* @param l2Provider - L2 provider
|
|
252
|
+
* @param l1Provider - L1 provider
|
|
253
|
+
* @returns Array of election statuses for incomplete elections
|
|
254
|
+
*/
|
|
255
|
+
export declare function trackIncompleteElections(l2Provider: ethers.providers.Provider, l1Provider: ethers.providers.Provider): Promise<ElectionProposalStatus[]>;
|
|
256
|
+
/**
|
|
257
|
+
* Get all contenders who registered for a nominee election
|
|
258
|
+
*
|
|
259
|
+
* Fetches ContenderAdded events to build the list of registered contenders.
|
|
260
|
+
*
|
|
261
|
+
* @param proposalId - Nominee election proposal ID
|
|
262
|
+
* @param provider - L2 provider
|
|
263
|
+
* @param nomineeGovernorAddress - Optional governor address override
|
|
264
|
+
* @returns Array of contenders with registration info
|
|
265
|
+
*/
|
|
266
|
+
export declare function getContenders(proposalId: string, provider: ethers.providers.Provider, nomineeGovernorAddress?: string): Promise<ElectionContender[]>;
|
|
267
|
+
/**
|
|
268
|
+
* Get all nominees for a nominee election with their vote counts
|
|
269
|
+
*
|
|
270
|
+
* Fetches nominee list from contract and enriches with vote data.
|
|
271
|
+
*
|
|
272
|
+
* @param proposalId - Nominee election proposal ID
|
|
273
|
+
* @param provider - L2 provider
|
|
274
|
+
* @param nomineeGovernorAddress - Optional governor address override
|
|
275
|
+
* @returns Array of nominees with vote and exclusion data
|
|
276
|
+
*/
|
|
277
|
+
export declare function getNomineesWithVotes(proposalId: string, provider: ethers.providers.Provider, nomineeGovernorAddress?: string): Promise<ElectionNominee[]>;
|
|
278
|
+
/**
|
|
279
|
+
* Get excluded nominees with exclusion details
|
|
280
|
+
*
|
|
281
|
+
* Fetches NomineeExcluded events to get exclusion information.
|
|
282
|
+
*
|
|
283
|
+
* @param proposalId - Nominee election proposal ID
|
|
284
|
+
* @param provider - L2 provider
|
|
285
|
+
* @param nomineeGovernorAddress - Optional governor address override
|
|
286
|
+
* @returns Array of excluded nominees with exclusion tx info
|
|
287
|
+
*/
|
|
288
|
+
export declare function getExcludedNominees(proposalId: string, provider: ethers.providers.Provider, nomineeGovernorAddress?: string): Promise<ElectionNominee[]>;
|
|
289
|
+
/**
|
|
290
|
+
* Get detailed nominee election information
|
|
291
|
+
*
|
|
292
|
+
* Aggregates contenders, nominees, excluded nominees, and voting data.
|
|
293
|
+
*
|
|
294
|
+
* @param electionIndex - Election index
|
|
295
|
+
* @param provider - L2 provider
|
|
296
|
+
* @param nomineeGovernorAddress - Optional governor address override
|
|
297
|
+
* @returns Detailed nominee election data or null if not found
|
|
298
|
+
*/
|
|
299
|
+
export declare function getNomineeElectionDetails(electionIndex: number, provider: ethers.providers.Provider, nomineeGovernorAddress?: string): Promise<NomineeElectionDetails | null>;
|
|
300
|
+
/**
|
|
301
|
+
* Get member election results with weighted votes
|
|
302
|
+
*
|
|
303
|
+
* Fetches top nominees (winners) and their weighted vote totals.
|
|
304
|
+
*
|
|
305
|
+
* @param electionIndex - Election index
|
|
306
|
+
* @param provider - L2 provider
|
|
307
|
+
* @param memberGovernorAddress - Optional governor address override
|
|
308
|
+
* @param nomineeGovernorAddress - Optional nominee governor address override
|
|
309
|
+
* @returns Detailed member election data or null if not found
|
|
310
|
+
*/
|
|
311
|
+
export declare function getMemberElectionDetails(electionIndex: number, provider: ethers.providers.Provider, memberGovernorAddress?: string, nomineeGovernorAddress?: string): Promise<MemberElectionDetails | null>;
|
|
172
312
|
//# sourceMappingURL=election.d.ts.map
|
package/dist/election.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"election.d.ts","sourceRoot":"","sources":["../src/election.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAG3C,OAAO,EACL,mBAAmB,EAKnB,sBAAsB,EACtB,cAAc,
|
|
1
|
+
{"version":3,"file":"election.d.ts","sourceRoot":"","sources":["../src/election.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAG3C,OAAO,EACL,mBAAmB,EAKnB,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,eAAe,EAEf,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAajB;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,0BAA0B;IAC1B,WAAW,EAAE,mBAAmB,CAAC;IACjC,mCAAmC;IACnC,aAAa,EAAE,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