@gzeoneth/gov-tracker 0.1.0

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 (203) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +201 -0
  3. package/dist/abis.d.ts +79 -0
  4. package/dist/abis.d.ts.map +1 -0
  5. package/dist/abis.js +159 -0
  6. package/dist/abis.js.map +1 -0
  7. package/dist/cli/lib/cli.d.ts +92 -0
  8. package/dist/cli/lib/cli.d.ts.map +1 -0
  9. package/dist/cli/lib/cli.js +562 -0
  10. package/dist/cli/lib/cli.js.map +1 -0
  11. package/dist/cli/lib/election-check.d.ts +46 -0
  12. package/dist/cli/lib/election-check.d.ts.map +1 -0
  13. package/dist/cli/lib/election-check.js +136 -0
  14. package/dist/cli/lib/election-check.js.map +1 -0
  15. package/dist/cli/lib/json-state.d.ts +100 -0
  16. package/dist/cli/lib/json-state.d.ts.map +1 -0
  17. package/dist/cli/lib/json-state.js +225 -0
  18. package/dist/cli/lib/json-state.js.map +1 -0
  19. package/dist/cli/monitor.d.ts +3 -0
  20. package/dist/cli/monitor.d.ts.map +1 -0
  21. package/dist/cli/monitor.js +442 -0
  22. package/dist/cli/monitor.js.map +1 -0
  23. package/dist/constants.d.ts +235 -0
  24. package/dist/constants.d.ts.map +1 -0
  25. package/dist/constants.js +293 -0
  26. package/dist/constants.js.map +1 -0
  27. package/dist/discovery/governor-discovery.d.ts +84 -0
  28. package/dist/discovery/governor-discovery.d.ts.map +1 -0
  29. package/dist/discovery/governor-discovery.js +310 -0
  30. package/dist/discovery/governor-discovery.js.map +1 -0
  31. package/dist/discovery/security-council.d.ts +68 -0
  32. package/dist/discovery/security-council.d.ts.map +1 -0
  33. package/dist/discovery/security-council.js +181 -0
  34. package/dist/discovery/security-council.js.map +1 -0
  35. package/dist/discovery/timelock-discovery.d.ts +99 -0
  36. package/dist/discovery/timelock-discovery.d.ts.map +1 -0
  37. package/dist/discovery/timelock-discovery.js +322 -0
  38. package/dist/discovery/timelock-discovery.js.map +1 -0
  39. package/dist/election.d.ts +172 -0
  40. package/dist/election.d.ts.map +1 -0
  41. package/dist/election.js +464 -0
  42. package/dist/election.js.map +1 -0
  43. package/dist/index.d.ts +56 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +164 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/stages/base.d.ts +127 -0
  48. package/dist/stages/base.d.ts.map +1 -0
  49. package/dist/stages/base.js +280 -0
  50. package/dist/stages/base.js.map +1 -0
  51. package/dist/stages/l2-to-l1-message.d.ts +108 -0
  52. package/dist/stages/l2-to-l1-message.d.ts.map +1 -0
  53. package/dist/stages/l2-to-l1-message.js +422 -0
  54. package/dist/stages/l2-to-l1-message.js.map +1 -0
  55. package/dist/stages/proposal-created.d.ts +20 -0
  56. package/dist/stages/proposal-created.d.ts.map +1 -0
  57. package/dist/stages/proposal-created.js +62 -0
  58. package/dist/stages/proposal-created.js.map +1 -0
  59. package/dist/stages/proposal-queued.d.ts +39 -0
  60. package/dist/stages/proposal-queued.d.ts.map +1 -0
  61. package/dist/stages/proposal-queued.js +131 -0
  62. package/dist/stages/proposal-queued.js.map +1 -0
  63. package/dist/stages/retryables.d.ts +79 -0
  64. package/dist/stages/retryables.d.ts.map +1 -0
  65. package/dist/stages/retryables.js +307 -0
  66. package/dist/stages/retryables.js.map +1 -0
  67. package/dist/stages/stage-builder.d.ts +46 -0
  68. package/dist/stages/stage-builder.d.ts.map +1 -0
  69. package/dist/stages/stage-builder.js +87 -0
  70. package/dist/stages/stage-builder.js.map +1 -0
  71. package/dist/stages/timelock.d.ts +100 -0
  72. package/dist/stages/timelock.d.ts.map +1 -0
  73. package/dist/stages/timelock.js +552 -0
  74. package/dist/stages/timelock.js.map +1 -0
  75. package/dist/stages/voting.d.ts +18 -0
  76. package/dist/stages/voting.d.ts.map +1 -0
  77. package/dist/stages/voting.js +109 -0
  78. package/dist/stages/voting.js.map +1 -0
  79. package/dist/tracker/context.d.ts +111 -0
  80. package/dist/tracker/context.d.ts.map +1 -0
  81. package/dist/tracker/context.js +264 -0
  82. package/dist/tracker/context.js.map +1 -0
  83. package/dist/tracker/discovery.d.ts +89 -0
  84. package/dist/tracker/discovery.d.ts.map +1 -0
  85. package/dist/tracker/discovery.js +228 -0
  86. package/dist/tracker/discovery.js.map +1 -0
  87. package/dist/tracker/execute.d.ts +44 -0
  88. package/dist/tracker/execute.d.ts.map +1 -0
  89. package/dist/tracker/execute.js +126 -0
  90. package/dist/tracker/execute.js.map +1 -0
  91. package/dist/tracker/index.d.ts +18 -0
  92. package/dist/tracker/index.d.ts.map +1 -0
  93. package/dist/tracker/index.js +70 -0
  94. package/dist/tracker/index.js.map +1 -0
  95. package/dist/tracker/pipeline.d.ts +47 -0
  96. package/dist/tracker/pipeline.d.ts.map +1 -0
  97. package/dist/tracker/pipeline.js +299 -0
  98. package/dist/tracker/pipeline.js.map +1 -0
  99. package/dist/tracker/query.d.ts +45 -0
  100. package/dist/tracker/query.d.ts.map +1 -0
  101. package/dist/tracker/query.js +159 -0
  102. package/dist/tracker/query.js.map +1 -0
  103. package/dist/tracker/state.d.ts +104 -0
  104. package/dist/tracker/state.d.ts.map +1 -0
  105. package/dist/tracker/state.js +287 -0
  106. package/dist/tracker/state.js.map +1 -0
  107. package/dist/tracker.d.ts +261 -0
  108. package/dist/tracker.d.ts.map +1 -0
  109. package/dist/tracker.js +556 -0
  110. package/dist/tracker.js.map +1 -0
  111. package/dist/types/config.d.ts +81 -0
  112. package/dist/types/config.d.ts.map +1 -0
  113. package/dist/types/config.js +6 -0
  114. package/dist/types/config.js.map +1 -0
  115. package/dist/types/core.d.ts +51 -0
  116. package/dist/types/core.d.ts.map +1 -0
  117. package/dist/types/core.js +6 -0
  118. package/dist/types/core.js.map +1 -0
  119. package/dist/types/cross-chain.d.ts +80 -0
  120. package/dist/types/cross-chain.d.ts.map +1 -0
  121. package/dist/types/cross-chain.js +6 -0
  122. package/dist/types/cross-chain.js.map +1 -0
  123. package/dist/types/election.d.ts +59 -0
  124. package/dist/types/election.d.ts.map +1 -0
  125. package/dist/types/election.js +6 -0
  126. package/dist/types/election.js.map +1 -0
  127. package/dist/types/governor.d.ts +71 -0
  128. package/dist/types/governor.d.ts.map +1 -0
  129. package/dist/types/governor.js +6 -0
  130. package/dist/types/governor.js.map +1 -0
  131. package/dist/types/index.d.ts +22 -0
  132. package/dist/types/index.d.ts.map +1 -0
  133. package/dist/types/index.js +21 -0
  134. package/dist/types/index.js.map +1 -0
  135. package/dist/types/stages.d.ts +189 -0
  136. package/dist/types/stages.d.ts.map +1 -0
  137. package/dist/types/stages.js +23 -0
  138. package/dist/types/stages.js.map +1 -0
  139. package/dist/types/timelock.d.ts +108 -0
  140. package/dist/types/timelock.d.ts.map +1 -0
  141. package/dist/types/timelock.js +6 -0
  142. package/dist/types/timelock.js.map +1 -0
  143. package/dist/types/tracking.d.ts +180 -0
  144. package/dist/types/tracking.d.ts.map +1 -0
  145. package/dist/types/tracking.js +6 -0
  146. package/dist/types/tracking.js.map +1 -0
  147. package/dist/types.d.ts +6 -0
  148. package/dist/types.d.ts.map +1 -0
  149. package/dist/types.js +22 -0
  150. package/dist/types.js.map +1 -0
  151. package/dist/utils/chain.d.ts +18 -0
  152. package/dist/utils/chain.d.ts.map +1 -0
  153. package/dist/utils/chain.js +34 -0
  154. package/dist/utils/chain.js.map +1 -0
  155. package/dist/utils/log-filters.d.ts +67 -0
  156. package/dist/utils/log-filters.d.ts.map +1 -0
  157. package/dist/utils/log-filters.js +116 -0
  158. package/dist/utils/log-filters.js.map +1 -0
  159. package/dist/utils/log-search.d.ts +76 -0
  160. package/dist/utils/log-search.d.ts.map +1 -0
  161. package/dist/utils/log-search.js +142 -0
  162. package/dist/utils/log-search.js.map +1 -0
  163. package/dist/utils/logger.d.ts +41 -0
  164. package/dist/utils/logger.d.ts.map +1 -0
  165. package/dist/utils/logger.js +50 -0
  166. package/dist/utils/logger.js.map +1 -0
  167. package/dist/utils/operation-id.d.ts +48 -0
  168. package/dist/utils/operation-id.d.ts.map +1 -0
  169. package/dist/utils/operation-id.js +102 -0
  170. package/dist/utils/operation-id.js.map +1 -0
  171. package/dist/utils/rpc-utils.d.ts +30 -0
  172. package/dist/utils/rpc-utils.d.ts.map +1 -0
  173. package/dist/utils/rpc-utils.js +99 -0
  174. package/dist/utils/rpc-utils.js.map +1 -0
  175. package/dist/utils/salt-computation.d.ts +78 -0
  176. package/dist/utils/salt-computation.d.ts.map +1 -0
  177. package/dist/utils/salt-computation.js +132 -0
  178. package/dist/utils/salt-computation.js.map +1 -0
  179. package/dist/utils/salt-resolver.d.ts +63 -0
  180. package/dist/utils/salt-resolver.d.ts.map +1 -0
  181. package/dist/utils/salt-resolver.js +144 -0
  182. package/dist/utils/salt-resolver.js.map +1 -0
  183. package/dist/utils/scoped-logger.d.ts +43 -0
  184. package/dist/utils/scoped-logger.d.ts.map +1 -0
  185. package/dist/utils/scoped-logger.js +72 -0
  186. package/dist/utils/scoped-logger.js.map +1 -0
  187. package/dist/utils/stage-helpers.d.ts +51 -0
  188. package/dist/utils/stage-helpers.d.ts.map +1 -0
  189. package/dist/utils/stage-helpers.js +143 -0
  190. package/dist/utils/stage-helpers.js.map +1 -0
  191. package/dist/utils/stage-metadata.d.ts +62 -0
  192. package/dist/utils/stage-metadata.d.ts.map +1 -0
  193. package/dist/utils/stage-metadata.js +140 -0
  194. package/dist/utils/stage-metadata.js.map +1 -0
  195. package/dist/utils/timing.d.ts +115 -0
  196. package/dist/utils/timing.d.ts.map +1 -0
  197. package/dist/utils/timing.js +303 -0
  198. package/dist/utils/timing.js.map +1 -0
  199. package/dist/utils/urls.d.ts +20 -0
  200. package/dist/utils/urls.d.ts.map +1 -0
  201. package/dist/utils/urls.js +51 -0
  202. package/dist/utils/urls.js.map +1 -0
  203. package/package.json +72 -0
@@ -0,0 +1,235 @@
1
+ /**
2
+ * Constants for Arbitrum Governance Stage Tracking SDK
3
+ *
4
+ * Centralized location for all addresses, timing, and configuration constants.
5
+ */
6
+ import type { ChunkingConfig, RetryConfig, ProposalState, DiscoveryTargets } from "./types";
7
+ /**
8
+ * Key Arbitrum governance contract addresses
9
+ *
10
+ * Naming aligned with governance documentation:
11
+ * - Constitutional: Core Governor / Core Timelock (requires L1 round-trip)
12
+ * - Non-Constitutional: Treasury Governor / Treasury Timelock (L2 only)
13
+ *
14
+ * @see https://docs.arbitrum.foundation/concepts/lifecycle-anatomy-aip-proposal
15
+ */
16
+ export declare const ADDRESSES: {
17
+ readonly CONSTITUTIONAL_GOVERNOR: "0xf07DeD9dC292157749B6Fd268E37DF6EA38395B9";
18
+ readonly NON_CONSTITUTIONAL_GOVERNOR: "0x789fC99093B09aD01C34DC7251D0C89ce743e5a4";
19
+ readonly ELECTION_NOMINEE_GOVERNOR: "0x8a1cDA8dee421cD06023470608605934c16A05a0";
20
+ readonly ELECTION_MEMBER_GOVERNOR: "0x467923B9AE90BDB36BA88eCA11604D45F13b712C";
21
+ readonly L2_CONSTITUTIONAL_TIMELOCK: "0x34d45e99f7D8c45ed05B5cA72D54bbD1fb3F98f0";
22
+ readonly L2_NON_CONSTITUTIONAL_TIMELOCK: "0xbFc1FECa8B09A5c5D3EFfE7429eBE24b9c09EF58";
23
+ readonly L1_TIMELOCK: "0xE6841D92B0C345144506576eC13ECf5103aC7f49";
24
+ readonly ARB1_DELAYED_INBOX: "0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f";
25
+ readonly NOVA_DELAYED_INBOX: "0xc4448b71118c9071Bcb9734A0EAc55D18A153949";
26
+ readonly SECURITY_COUNCIL_MANAGER: "0xD509E5f5aEe2A205F554f36E8a7d56094494eDFC";
27
+ readonly ARB_SYS: "0x0000000000000000000000000000000000000064";
28
+ readonly ARB_RETRYABLE_TX: "0x000000000000000000000000000000000000006E";
29
+ readonly ARB1_OUTBOX: "0x0B9857ae2D4A3DBe74ffE1d7DF045bb7F96E4840";
30
+ readonly NOVA_OUTBOX: "0xD4B80C3D7240325D18E645B49e6535A3Bf95cc58";
31
+ readonly RETRYABLE_TICKET_MAGIC: "0xa723C008e76E379c55599D2E4d93879BeaFDa79C";
32
+ };
33
+ /**
34
+ * Check if a governor address is an election governor (nominee or member election)
35
+ *
36
+ * Election governors have different lifecycle handling - they don't use timelocks
37
+ * and are often filtered separately in monitoring applications.
38
+ */
39
+ export declare function isElectionGovernor(governorAddress: string): boolean;
40
+ /**
41
+ * Build default discovery targets for tracker.discoverAll()
42
+ *
43
+ * Returns a DiscoveryTargets object with sensible defaults. By default,
44
+ * all governors and timelocks are enabled. Use options to customize.
45
+ *
46
+ * @param options.includeElections - Include election governors (default: true)
47
+ * @param options.governorsOnly - Only include governors, skip timelocks (default: false)
48
+ * @param options.timelocksOnly - Only include timelocks, skip governors (default: false)
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * // All targets (default)
53
+ * const targets = buildDefaultTargets();
54
+ *
55
+ * // Skip elections
56
+ * const targets = buildDefaultTargets({ includeElections: false });
57
+ *
58
+ * // Only governors
59
+ * const targets = buildDefaultTargets({ governorsOnly: true });
60
+ * ```
61
+ */
62
+ export declare function buildDefaultTargets(options?: {
63
+ includeElections?: boolean;
64
+ governorsOnly?: boolean;
65
+ timelocksOnly?: boolean;
66
+ }): DiscoveryTargets;
67
+ /**
68
+ * Chain IDs for supported networks
69
+ */
70
+ export declare const CHAIN_IDS: {
71
+ readonly ETHEREUM: 1;
72
+ readonly ARB_ONE: 42161;
73
+ readonly NOVA: 42170;
74
+ };
75
+ /**
76
+ * Default public RPC URLs
77
+ *
78
+ * These are rate-limited public endpoints. For production use,
79
+ * configure dedicated RPC URLs via environment variables.
80
+ */
81
+ export declare const DEFAULT_RPC_URLS: {
82
+ readonly ARB_ONE: "https://arb1.arbitrum.io/rpc";
83
+ readonly NOVA: "https://nova.arbitrum.io/rpc";
84
+ };
85
+ /**
86
+ * Pre-computed event topic hashes for efficient log filtering
87
+ */
88
+ export declare const EVENT_TOPICS: {
89
+ readonly PROPOSAL_CREATED: string;
90
+ readonly PROPOSAL_QUEUED: string;
91
+ readonly PROPOSAL_EXECUTED: string;
92
+ readonly VOTE_CAST: string;
93
+ readonly VOTE_CAST_WITH_PARAMS: string;
94
+ readonly PROPOSAL_EXTENDED: string;
95
+ readonly CALL_SCHEDULED: string;
96
+ readonly CALL_EXECUTED: string;
97
+ readonly CANCELLED: string;
98
+ readonly MIN_DELAY_CHANGE: string;
99
+ readonly L2_TO_L1_TX: string;
100
+ readonly TICKET_CREATED: string;
101
+ readonly REDEEM_SCHEDULED: string;
102
+ readonly SECURITY_COUNCIL_COHORT_REPLACED: string;
103
+ };
104
+ /**
105
+ * Average block times in seconds
106
+ *
107
+ * NOTE: L2 block times are variable (0.25s-2s) depending on sequencer load.
108
+ * These are conservative estimates for ETA calculations. Actual timing may vary.
109
+ */
110
+ export declare const BLOCK_TIMES: {
111
+ /** ~12 seconds per block on Ethereum mainnet */
112
+ readonly L1: 12;
113
+ /** Conservative estimate for Arbitrum One (actual: 0.25s-2s) */
114
+ readonly L2: 0.5;
115
+ /** Same as Arbitrum One */
116
+ readonly NOVA: 0.5;
117
+ };
118
+ /**
119
+ * Key timing constants for governance lifecycle
120
+ *
121
+ * Reference: https://docs.arbitrum.foundation/concepts/lifecycle-anatomy-aip-proposal
122
+ */
123
+ export declare const TIMING: {
124
+ /** Maximum voting period in L2 blocks (approximately 14 days) */
125
+ readonly MAX_VOTING_PERIOD_BLOCKS_L2: 6500000;
126
+ /** Arbitrum challenge period in L1 blocks (approximately 6.4 days) */
127
+ readonly CHALLENGE_PERIOD_BLOCKS_L1: 45818;
128
+ /** L2 Constitutional timelock delay in seconds (8 days) */
129
+ readonly L2_CONSTITUTIONAL_TIMELOCK_DELAY_SECONDS: 691200;
130
+ /** L2 Non-Constitutional timelock delay in seconds (3 days) */
131
+ readonly L2_NON_CONSTITUTIONAL_TIMELOCK_DELAY_SECONDS: 259200;
132
+ /** L1 timelock delay in seconds (3 days) */
133
+ readonly L1_TIMELOCK_DELAY_SECONDS: 259200;
134
+ /** L1 timelock delay in L1 blocks (~21,600 blocks at 12s/block) */
135
+ readonly L1_TIMELOCK_DELAY_BLOCKS_L1: 21600;
136
+ /** Retryable ticket lifetime in seconds (7 days) */
137
+ readonly RETRYABLE_LIFETIME_SECONDS: 604800;
138
+ /** Voting extension period in days (for late quorum) */
139
+ readonly VOTING_EXTENSION_DAYS: 2;
140
+ /** Milliseconds in one day */
141
+ readonly MS_PER_DAY: number;
142
+ /** Security Council target nominee count per cohort */
143
+ readonly SECURITY_COUNCIL_TARGET_NOMINEES: 6;
144
+ };
145
+ /**
146
+ * Standard governance stage durations in days
147
+ *
148
+ * These are the expected durations for each stage in the normal proposal flow.
149
+ * Based on: https://docs.arbitrum.foundation/concepts/lifecycle-anatomy-aip-proposal
150
+ *
151
+ * On-chain only timing (excludes off-chain temperature check period):
152
+ * - Constitutional: ~34 days (voting + 8d L2 timelock + challenge + 3d L1 timelock)
153
+ * - Non-Constitutional: ~21 days (voting + 3d L2 timelock + L2 execution)
154
+ */
155
+ export declare const GOVERNANCE_STAGE_DURATION_DAYS: {
156
+ /** On-chain vote duration: 16 days (14 days base + 2 days extension buffer) */
157
+ readonly VOTING: 16;
158
+ /** L2 Constitutional timelock delay: 8 days */
159
+ readonly L2_CONSTITUTIONAL_TIMELOCK: 8;
160
+ /** L2 Non-Constitutional timelock delay: 3 days */
161
+ readonly L2_NON_CONSTITUTIONAL_TIMELOCK: 3;
162
+ /** L2 execution: typically same block as delay expiry */
163
+ readonly L2_EXECUTION: 0;
164
+ /** Challenge period: ~6.4 days (45818 L1 blocks * 12s/block) */
165
+ readonly CHALLENGE_PERIOD: 6.4;
166
+ /** L1 timelock delay: 3 days */
167
+ readonly L1_TIMELOCK: 3;
168
+ /** L1 execution + retryable: typically same day */
169
+ readonly L1_EXECUTION: 0;
170
+ /** Total on-chain duration for Constitutional proposals: ~34 days */
171
+ readonly TOTAL_ONCHAIN_CONSTITUTIONAL: 34;
172
+ /** Total on-chain duration for Non-Constitutional proposals: ~21 days */
173
+ readonly TOTAL_ONCHAIN_NON_CONSTITUTIONAL: 21;
174
+ };
175
+ /**
176
+ * Block chunk sizes for log searches
177
+ */
178
+ export declare const CHUNK_SIZES: {
179
+ /** L2 (Arbitrum One) chunk size: 10M blocks */
180
+ readonly L2: 10000000;
181
+ /** L1 (Ethereum) chunk size: 10K blocks */
182
+ readonly L1: 10000;
183
+ /** Nova chunk size: 10M blocks */
184
+ readonly NOVA: 10000000;
185
+ /** Delay between chunk queries in milliseconds */
186
+ readonly DELAY_MS: 100;
187
+ };
188
+ /**
189
+ * Default chunking configuration
190
+ */
191
+ export declare const DEFAULT_CHUNKING_CONFIG: ChunkingConfig;
192
+ /**
193
+ * Default retry configuration for RPC calls
194
+ */
195
+ export declare const DEFAULT_RETRY_CONFIG: RetryConfig;
196
+ /**
197
+ * Governance deployment blocks - earliest possible blocks for governance events
198
+ *
199
+ * Use these as fallback startBlock when no specific block hint is available.
200
+ * These are conservative (early) estimates to ensure no events are missed.
201
+ *
202
+ * Arbitrum DAO launched March 2023:
203
+ * - L2 governance deployment: ~block 70M on Arbitrum One
204
+ * - L1 timelock deployment: ~block 16.8M on Ethereum mainnet
205
+ */
206
+ export declare const GOVERNANCE_START_BLOCKS: {
207
+ /** L2 (Arbitrum One) governance deployment block - March 2023 */
208
+ readonly L2: 70000000;
209
+ /** L1 (Ethereum mainnet) timelock deployment block - March 2023 */
210
+ readonly L1: 16800000;
211
+ /** Nova governance deployment block (same timeframe as L2) */
212
+ readonly NOVA: 1000000;
213
+ };
214
+ /**
215
+ * Map OpenZeppelin Governor state number to ProposalState string
216
+ *
217
+ * Used by governor.state() to convert numeric state to readable string.
218
+ */
219
+ export declare const PROPOSAL_STATE_MAP: Record<number, ProposalState>;
220
+ /**
221
+ * Numeric proposal state values from OpenZeppelin Governor
222
+ *
223
+ * Use these constants instead of magic numbers when checking proposal state.
224
+ */
225
+ export declare const PROPOSAL_STATE: {
226
+ readonly PENDING: 0;
227
+ readonly ACTIVE: 1;
228
+ readonly CANCELED: 2;
229
+ readonly DEFEATED: 3;
230
+ readonly SUCCEEDED: 4;
231
+ readonly QUEUED: 5;
232
+ readonly EXPIRED: 6;
233
+ readonly EXECUTED: 7;
234
+ };
235
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAI5F;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;CAoCZ,CAAC;AAEX;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAMnE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAC5C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GAAG,gBAAgB,CAanB;AAED;;GAEG;AACH,eAAO,MAAM,SAAS;;;;CAIZ,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;CAGnB,CAAC;AAIX;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;CAoCf,CAAC;AAIX;;;;;GAKG;AACH,eAAO,MAAM,WAAW;IACtB,gDAAgD;;IAEhD,gEAAgE;;IAEhE,2BAA2B;;CAEnB,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,MAAM;IACjB,iEAAiE;;IAGjE,sEAAsE;;IAGtE,2DAA2D;;IAG3D,+DAA+D;;IAG/D,4CAA4C;;IAG5C,mEAAmE;;IAGnE,oDAAoD;;IAGpD,wDAAwD;;IAGxD,8BAA8B;;IAG9B,uDAAuD;;CAE/C,CAAC;AAEX;;;;;;;;;GASG;AACH,eAAO,MAAM,8BAA8B;IACzC,+EAA+E;;IAE/E,+CAA+C;;IAE/C,mDAAmD;;IAEnD,yDAAyD;;IAEzD,gEAAgE;;IAEhE,gCAAgC;;IAEhC,mDAAmD;;IAEnD,qEAAqE;;IAErE,yEAAyE;;CAEjE,CAAC;AAIX;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB,+CAA+C;;IAE/C,2CAA2C;;IAE3C,kCAAkC;;IAElC,kDAAkD;;CAE1C,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAKrC,CAAC;AAIF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAKlC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB;IAClC,iEAAiE;;IAEjE,mEAAmE;;IAEnE,8DAA8D;;CAEtD,CAAC;AAIX;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAS5D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;;;;;;CASjB,CAAC"}
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+ /**
3
+ * Constants for Arbitrum Governance Stage Tracking SDK
4
+ *
5
+ * Centralized location for all addresses, timing, and configuration constants.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.PROPOSAL_STATE = exports.PROPOSAL_STATE_MAP = exports.GOVERNANCE_START_BLOCKS = exports.DEFAULT_RETRY_CONFIG = exports.DEFAULT_CHUNKING_CONFIG = exports.CHUNK_SIZES = exports.GOVERNANCE_STAGE_DURATION_DAYS = exports.TIMING = exports.BLOCK_TIMES = exports.EVENT_TOPICS = exports.DEFAULT_RPC_URLS = exports.CHAIN_IDS = exports.ADDRESSES = void 0;
9
+ exports.isElectionGovernor = isElectionGovernor;
10
+ exports.buildDefaultTargets = buildDefaultTargets;
11
+ const ethers_1 = require("ethers");
12
+ // Contract Addresses
13
+ /**
14
+ * Key Arbitrum governance contract addresses
15
+ *
16
+ * Naming aligned with governance documentation:
17
+ * - Constitutional: Core Governor / Core Timelock (requires L1 round-trip)
18
+ * - Non-Constitutional: Treasury Governor / Treasury Timelock (L2 only)
19
+ *
20
+ * @see https://docs.arbitrum.foundation/concepts/lifecycle-anatomy-aip-proposal
21
+ */
22
+ exports.ADDRESSES = {
23
+ // Governors
24
+ CONSTITUTIONAL_GOVERNOR: "0xf07DeD9dC292157749B6Fd268E37DF6EA38395B9",
25
+ NON_CONSTITUTIONAL_GOVERNOR: "0x789fC99093B09aD01C34DC7251D0C89ce743e5a4",
26
+ // Election Governors (Security Council)
27
+ ELECTION_NOMINEE_GOVERNOR: "0x8a1cDA8dee421cD06023470608605934c16A05a0",
28
+ ELECTION_MEMBER_GOVERNOR: "0x467923B9AE90BDB36BA88eCA11604D45F13b712C",
29
+ // L2 Timelocks
30
+ L2_CONSTITUTIONAL_TIMELOCK: "0x34d45e99f7D8c45ed05B5cA72D54bbD1fb3F98f0",
31
+ L2_NON_CONSTITUTIONAL_TIMELOCK: "0xbFc1FECa8B09A5c5D3EFfE7429eBE24b9c09EF58",
32
+ // L1 Timelock
33
+ L1_TIMELOCK: "0xE6841D92B0C345144506576eC13ECf5103aC7f49",
34
+ // Delayed Inboxes (for retryable detection)
35
+ ARB1_DELAYED_INBOX: "0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f",
36
+ NOVA_DELAYED_INBOX: "0xc4448b71118c9071Bcb9734A0EAc55D18A153949",
37
+ // Security Council Manager
38
+ SECURITY_COUNCIL_MANAGER: "0xD509E5f5aEe2A205F554f36E8a7d56094494eDFC",
39
+ // ArbSys precompile (for L2→L1 messages and block info)
40
+ ARB_SYS: "0x0000000000000000000000000000000000000064",
41
+ // ArbRetryableTx precompile (for retryable redemption)
42
+ ARB_RETRYABLE_TX: "0x000000000000000000000000000000000000006E",
43
+ // Outbox (for L2→L1 execution)
44
+ ARB1_OUTBOX: "0x0B9857ae2D4A3DBe74ffE1d7DF045bb7F96E4840",
45
+ NOVA_OUTBOX: "0xD4B80C3D7240325D18E645B49e6535A3Bf95cc58",
46
+ // L1ArbitrumTimelock magic address for retryable ticket detection
47
+ // When a timelock operation's target is this address, the call is a retryable ticket
48
+ RETRYABLE_TICKET_MAGIC: "0xa723C008e76E379c55599D2E4d93879BeaFDa79C",
49
+ };
50
+ /**
51
+ * Check if a governor address is an election governor (nominee or member election)
52
+ *
53
+ * Election governors have different lifecycle handling - they don't use timelocks
54
+ * and are often filtered separately in monitoring applications.
55
+ */
56
+ function isElectionGovernor(governorAddress) {
57
+ const addr = governorAddress.toLowerCase();
58
+ return (addr === exports.ADDRESSES.ELECTION_NOMINEE_GOVERNOR.toLowerCase() ||
59
+ addr === exports.ADDRESSES.ELECTION_MEMBER_GOVERNOR.toLowerCase());
60
+ }
61
+ /**
62
+ * Build default discovery targets for tracker.discoverAll()
63
+ *
64
+ * Returns a DiscoveryTargets object with sensible defaults. By default,
65
+ * all governors and timelocks are enabled. Use options to customize.
66
+ *
67
+ * @param options.includeElections - Include election governors (default: true)
68
+ * @param options.governorsOnly - Only include governors, skip timelocks (default: false)
69
+ * @param options.timelocksOnly - Only include timelocks, skip governors (default: false)
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * // All targets (default)
74
+ * const targets = buildDefaultTargets();
75
+ *
76
+ * // Skip elections
77
+ * const targets = buildDefaultTargets({ includeElections: false });
78
+ *
79
+ * // Only governors
80
+ * const targets = buildDefaultTargets({ governorsOnly: true });
81
+ * ```
82
+ */
83
+ function buildDefaultTargets(options) {
84
+ const includeElections = options?.includeElections ?? true;
85
+ const governorsOnly = options?.governorsOnly ?? false;
86
+ const timelocksOnly = options?.timelocksOnly ?? false;
87
+ return {
88
+ constitutionalGovernor: !timelocksOnly,
89
+ nonConstitutionalGovernor: !timelocksOnly,
90
+ electionNomineeGovernor: !timelocksOnly && includeElections,
91
+ electionMemberGovernor: !timelocksOnly && includeElections,
92
+ l2ConstitutionalTimelock: !governorsOnly,
93
+ l2NonConstitutionalTimelock: !governorsOnly,
94
+ };
95
+ }
96
+ /**
97
+ * Chain IDs for supported networks
98
+ */
99
+ exports.CHAIN_IDS = {
100
+ ETHEREUM: 1,
101
+ ARB_ONE: 42161,
102
+ NOVA: 42170,
103
+ };
104
+ /**
105
+ * Default public RPC URLs
106
+ *
107
+ * These are rate-limited public endpoints. For production use,
108
+ * configure dedicated RPC URLs via environment variables.
109
+ */
110
+ exports.DEFAULT_RPC_URLS = {
111
+ ARB_ONE: "https://arb1.arbitrum.io/rpc",
112
+ NOVA: "https://nova.arbitrum.io/rpc",
113
+ };
114
+ // Event Topics (Pre-computed keccak256 hashes)
115
+ /**
116
+ * Pre-computed event topic hashes for efficient log filtering
117
+ */
118
+ exports.EVENT_TOPICS = {
119
+ // Governor events
120
+ PROPOSAL_CREATED: ethers_1.ethers.utils.id("ProposalCreated(uint256,address,address[],uint256[],string[],bytes[],uint256,uint256,string)"),
121
+ PROPOSAL_QUEUED: ethers_1.ethers.utils.id("ProposalQueued(uint256,uint256)"),
122
+ PROPOSAL_EXECUTED: ethers_1.ethers.utils.id("ProposalExecuted(uint256)"),
123
+ VOTE_CAST: ethers_1.ethers.utils.id("VoteCast(address,uint256,uint8,uint256,string)"),
124
+ VOTE_CAST_WITH_PARAMS: ethers_1.ethers.utils.id("VoteCastWithParams(address,uint256,uint8,uint256,string,bytes)"),
125
+ PROPOSAL_EXTENDED: ethers_1.ethers.utils.id("ProposalExtended(uint256,uint64)"),
126
+ // Timelock events
127
+ CALL_SCHEDULED: ethers_1.ethers.utils.id("CallScheduled(bytes32,uint256,address,uint256,bytes,bytes32,uint256)"),
128
+ CALL_EXECUTED: ethers_1.ethers.utils.id("CallExecuted(bytes32,uint256,address,uint256,bytes)"),
129
+ CANCELLED: ethers_1.ethers.utils.id("Cancelled(bytes32)"),
130
+ MIN_DELAY_CHANGE: ethers_1.ethers.utils.id("MinDelayChange(uint256,uint256)"),
131
+ // L2→L1 message
132
+ L2_TO_L1_TX: ethers_1.ethers.utils.id("L2ToL1Tx(address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes)"),
133
+ // Retryable
134
+ TICKET_CREATED: ethers_1.ethers.utils.id("InboxMessageDelivered(uint256,bytes)"),
135
+ REDEEM_SCHEDULED: ethers_1.ethers.utils.id("RedeemScheduled(bytes32,bytes32,uint64,uint64,address,address,uint256,uint256,bytes)"),
136
+ // Security Council
137
+ SECURITY_COUNCIL_COHORT_REPLACED: ethers_1.ethers.utils.id("SecurityCouncilCohortReplaced(address[],address[])"),
138
+ };
139
+ // Timing Constants
140
+ /**
141
+ * Average block times in seconds
142
+ *
143
+ * NOTE: L2 block times are variable (0.25s-2s) depending on sequencer load.
144
+ * These are conservative estimates for ETA calculations. Actual timing may vary.
145
+ */
146
+ exports.BLOCK_TIMES = {
147
+ /** ~12 seconds per block on Ethereum mainnet */
148
+ L1: 12,
149
+ /** Conservative estimate for Arbitrum One (actual: 0.25s-2s) */
150
+ L2: 0.5,
151
+ /** Same as Arbitrum One */
152
+ NOVA: 0.5,
153
+ };
154
+ /**
155
+ * Key timing constants for governance lifecycle
156
+ *
157
+ * Reference: https://docs.arbitrum.foundation/concepts/lifecycle-anatomy-aip-proposal
158
+ */
159
+ exports.TIMING = {
160
+ /** Maximum voting period in L2 blocks (approximately 14 days) */
161
+ MAX_VOTING_PERIOD_BLOCKS_L2: 6500000,
162
+ /** Arbitrum challenge period in L1 blocks (approximately 6.4 days) */
163
+ CHALLENGE_PERIOD_BLOCKS_L1: 45818,
164
+ /** L2 Constitutional timelock delay in seconds (8 days) */
165
+ L2_CONSTITUTIONAL_TIMELOCK_DELAY_SECONDS: 691200,
166
+ /** L2 Non-Constitutional timelock delay in seconds (3 days) */
167
+ L2_NON_CONSTITUTIONAL_TIMELOCK_DELAY_SECONDS: 259200,
168
+ /** L1 timelock delay in seconds (3 days) */
169
+ L1_TIMELOCK_DELAY_SECONDS: 259200,
170
+ /** L1 timelock delay in L1 blocks (~21,600 blocks at 12s/block) */
171
+ L1_TIMELOCK_DELAY_BLOCKS_L1: 21600,
172
+ /** Retryable ticket lifetime in seconds (7 days) */
173
+ RETRYABLE_LIFETIME_SECONDS: 604800,
174
+ /** Voting extension period in days (for late quorum) */
175
+ VOTING_EXTENSION_DAYS: 2,
176
+ /** Milliseconds in one day */
177
+ MS_PER_DAY: 24 * 60 * 60 * 1000,
178
+ /** Security Council target nominee count per cohort */
179
+ SECURITY_COUNCIL_TARGET_NOMINEES: 6,
180
+ };
181
+ /**
182
+ * Standard governance stage durations in days
183
+ *
184
+ * These are the expected durations for each stage in the normal proposal flow.
185
+ * Based on: https://docs.arbitrum.foundation/concepts/lifecycle-anatomy-aip-proposal
186
+ *
187
+ * On-chain only timing (excludes off-chain temperature check period):
188
+ * - Constitutional: ~34 days (voting + 8d L2 timelock + challenge + 3d L1 timelock)
189
+ * - Non-Constitutional: ~21 days (voting + 3d L2 timelock + L2 execution)
190
+ */
191
+ exports.GOVERNANCE_STAGE_DURATION_DAYS = {
192
+ /** On-chain vote duration: 16 days (14 days base + 2 days extension buffer) */
193
+ VOTING: 16,
194
+ /** L2 Constitutional timelock delay: 8 days */
195
+ L2_CONSTITUTIONAL_TIMELOCK: 8,
196
+ /** L2 Non-Constitutional timelock delay: 3 days */
197
+ L2_NON_CONSTITUTIONAL_TIMELOCK: 3,
198
+ /** L2 execution: typically same block as delay expiry */
199
+ L2_EXECUTION: 0,
200
+ /** Challenge period: ~6.4 days (45818 L1 blocks * 12s/block) */
201
+ CHALLENGE_PERIOD: 6.4,
202
+ /** L1 timelock delay: 3 days */
203
+ L1_TIMELOCK: 3,
204
+ /** L1 execution + retryable: typically same day */
205
+ L1_EXECUTION: 0,
206
+ /** Total on-chain duration for Constitutional proposals: ~34 days */
207
+ TOTAL_ONCHAIN_CONSTITUTIONAL: 34,
208
+ /** Total on-chain duration for Non-Constitutional proposals: ~21 days */
209
+ TOTAL_ONCHAIN_NON_CONSTITUTIONAL: 21,
210
+ };
211
+ // Chunking Configuration
212
+ /**
213
+ * Block chunk sizes for log searches
214
+ */
215
+ exports.CHUNK_SIZES = {
216
+ /** L2 (Arbitrum One) chunk size: 10M blocks */
217
+ L2: 10000000,
218
+ /** L1 (Ethereum) chunk size: 10K blocks */
219
+ L1: 10000,
220
+ /** Nova chunk size: 10M blocks */
221
+ NOVA: 10000000,
222
+ /** Delay between chunk queries in milliseconds */
223
+ DELAY_MS: 100,
224
+ };
225
+ /**
226
+ * Default chunking configuration
227
+ */
228
+ exports.DEFAULT_CHUNKING_CONFIG = {
229
+ l2ChunkSize: exports.CHUNK_SIZES.L2,
230
+ l1ChunkSize: exports.CHUNK_SIZES.L1,
231
+ novaChunkSize: exports.CHUNK_SIZES.NOVA,
232
+ delayBetweenChunks: exports.CHUNK_SIZES.DELAY_MS,
233
+ };
234
+ // Retry Configuration
235
+ /**
236
+ * Default retry configuration for RPC calls
237
+ */
238
+ exports.DEFAULT_RETRY_CONFIG = {
239
+ maxRetries: 3,
240
+ initialDelay: 1000,
241
+ maxDelay: 16000,
242
+ backoffMultiplier: 2,
243
+ };
244
+ /**
245
+ * Governance deployment blocks - earliest possible blocks for governance events
246
+ *
247
+ * Use these as fallback startBlock when no specific block hint is available.
248
+ * These are conservative (early) estimates to ensure no events are missed.
249
+ *
250
+ * Arbitrum DAO launched March 2023:
251
+ * - L2 governance deployment: ~block 70M on Arbitrum One
252
+ * - L1 timelock deployment: ~block 16.8M on Ethereum mainnet
253
+ */
254
+ exports.GOVERNANCE_START_BLOCKS = {
255
+ /** L2 (Arbitrum One) governance deployment block - March 2023 */
256
+ L2: 70000000,
257
+ /** L1 (Ethereum mainnet) timelock deployment block - March 2023 */
258
+ L1: 16800000,
259
+ /** Nova governance deployment block (same timeframe as L2) */
260
+ NOVA: 1000000,
261
+ };
262
+ // Governor State Mapping
263
+ /**
264
+ * Map OpenZeppelin Governor state number to ProposalState string
265
+ *
266
+ * Used by governor.state() to convert numeric state to readable string.
267
+ */
268
+ exports.PROPOSAL_STATE_MAP = {
269
+ 0: "Pending",
270
+ 1: "Active",
271
+ 2: "Canceled",
272
+ 3: "Defeated",
273
+ 4: "Succeeded",
274
+ 5: "Queued",
275
+ 6: "Expired",
276
+ 7: "Executed",
277
+ };
278
+ /**
279
+ * Numeric proposal state values from OpenZeppelin Governor
280
+ *
281
+ * Use these constants instead of magic numbers when checking proposal state.
282
+ */
283
+ exports.PROPOSAL_STATE = {
284
+ PENDING: 0,
285
+ ACTIVE: 1,
286
+ CANCELED: 2,
287
+ DEFEATED: 3,
288
+ SUCCEEDED: 4,
289
+ QUEUED: 5,
290
+ EXPIRED: 6,
291
+ EXECUTED: 7,
292
+ };
293
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AA4DH,gDAMC;AAwBD,kDAiBC;AAzGD,mCAAgC;AAGhC,qBAAqB;AAErB;;;;;;;;GAQG;AACU,QAAA,SAAS,GAAG;IACvB,YAAY;IACZ,uBAAuB,EAAE,4CAA4C;IACrE,2BAA2B,EAAE,4CAA4C;IAEzE,wCAAwC;IACxC,yBAAyB,EAAE,4CAA4C;IACvE,wBAAwB,EAAE,4CAA4C;IAEtE,eAAe;IACf,0BAA0B,EAAE,4CAA4C;IACxE,8BAA8B,EAAE,4CAA4C;IAE5E,cAAc;IACd,WAAW,EAAE,4CAA4C;IAEzD,4CAA4C;IAC5C,kBAAkB,EAAE,4CAA4C;IAChE,kBAAkB,EAAE,4CAA4C;IAEhE,2BAA2B;IAC3B,wBAAwB,EAAE,4CAA4C;IAEtE,wDAAwD;IACxD,OAAO,EAAE,4CAA4C;IAErD,uDAAuD;IACvD,gBAAgB,EAAE,4CAA4C;IAE9D,+BAA+B;IAC/B,WAAW,EAAE,4CAA4C;IACzD,WAAW,EAAE,4CAA4C;IAEzD,kEAAkE;IAClE,qFAAqF;IACrF,sBAAsB,EAAE,4CA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ACU,QAAA,oBAAoB,GAAgB;IAC/C,UAAU,EAAE,CAAC;IACb,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE,KAAK;IACf,iBAAiB,EAAE,CAAC;CACrB,CAAC;AAEF;;;;;;;;;GASG;AACU,QAAA,uBAAuB,GAAG;IACrC,iEAAiE;IACjE,EAAE,EAAE,QAAU;IACd,mEAAmE;IACnE,EAAE,EAAE,QAAU;IACd,8DAA8D;IAC9D,IAAI,EAAE,OAAS;CACP,CAAC;AAEX,yBAAyB;AAEzB;;;;GAIG;AACU,QAAA,kBAAkB,GAAkC;IAC/D,CAAC,EAAE,SAAS;IACZ,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,WAAW;IACd,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,SAAS;IACZ,CAAC,EAAE,UAAU;CACd,CAAC;AAEF;;;;GAIG;AACU,QAAA,cAAc,GAAG;IAC5B,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC;IACX,SAAS,EAAE,CAAC;IACZ,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;CACH,CAAC"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Governor discovery module
3
+ *
4
+ * Find proposals, detect governor type, parse ProposalCreated events.
5
+ * Also includes proposal discovery functions for block range scanning.
6
+ */
7
+ import { BigNumber, ethers } from "ethers";
8
+ import { GovernorCapability, ProposalType, ProposalData, ProposalState, VotingData, SearchHint } from "../types";
9
+ /** Discovered proposal from ProposalCreated event */
10
+ export interface DiscoveredProposal {
11
+ governorAddress: string;
12
+ proposalId: string;
13
+ creationTxHash: string;
14
+ creationBlock: number;
15
+ }
16
+ /**
17
+ * Detect governor type from address
18
+ */
19
+ export declare function detectProposalType(governorAddress: string): ProposalType;
20
+ /**
21
+ * Check if a governor type is a Security Council election governor
22
+ */
23
+ export declare function isElectionProposal(proposalType: ProposalType): boolean;
24
+ /**
25
+ * Detect governor capabilities by probing the contract
26
+ *
27
+ * This function determines the execution path for proposals:
28
+ * - WITH_TIMELOCK: Governor -> L2Timelock -> (optional L1 round-trip)
29
+ * - WITH_VETTING: Same as WITH_TIMELOCK but with vetting period
30
+ * - NO_TIMELOCK: Direct governor.execute() without timelock
31
+ *
32
+ * The detection order matters:
33
+ * 1. Check for timelock() first - most governors have this
34
+ * 2. Check for nomineeVetter() - only Security Council Nominee Election Governor
35
+ * 3. Default to NO_TIMELOCK - Security Council Member Election Governor
36
+ */
37
+ export declare function detectGovernorCapabilities(governorAddress: string, provider: ethers.providers.Provider): Promise<GovernorCapability>;
38
+ /**
39
+ * Get the timelock address for a governor
40
+ */
41
+ export declare function getTimelockAddress(governorAddress: string, provider: ethers.providers.Provider): Promise<string>;
42
+ /**
43
+ * Get proposal state from governor contract
44
+ */
45
+ export declare function getProposalState(governorAddress: string, proposalId: string, provider: ethers.providers.Provider): Promise<ProposalState>;
46
+ /**
47
+ * Parse ProposalCreated event data
48
+ */
49
+ export declare function parseProposalCreatedEvent(log: ethers.providers.Log): ProposalData | null;
50
+ /**
51
+ * Find ProposalCreated event by proposal ID
52
+ *
53
+ * @param hint - Search optimization hint. Default is backward search from current block.
54
+ */
55
+ export declare function findProposalCreatedEvent(governorAddress: string, proposalId: string, provider: ethers.providers.Provider, hint?: SearchHint): Promise<ProposalData | null>;
56
+ /**
57
+ * Find ProposalCreated event by transaction hash
58
+ */
59
+ export declare function findProposalByTxHash(txHash: string, provider: ethers.providers.Provider): Promise<ProposalData | null>;
60
+ /**
61
+ * Get voting information for a proposal
62
+ */
63
+ export declare function getVotingData(governorAddress: string, proposalId: string, provider: ethers.providers.Provider): Promise<VotingData>;
64
+ /**
65
+ * Find ProposalQueued event for a proposal
66
+ *
67
+ * Note: ProposalQueued(uint256 proposalId, uint256 eta) has NON-INDEXED parameters,
68
+ * so we cannot filter by proposalId in topics. We must search for all ProposalQueued
69
+ * events and decode the data to find the matching proposalId.
70
+ *
71
+ * @param hint - Search optimization hint. Default is backward search from current block.
72
+ */
73
+ export declare function findProposalQueuedEvent(governorAddress: string, proposalId: string, provider: ethers.providers.Provider, hint?: SearchHint): Promise<{
74
+ blockNumber: number;
75
+ txHash: string;
76
+ eta: BigNumber;
77
+ } | null>;
78
+ /** Discover proposals from a governor in a block range */
79
+ export declare function discoverProposals(governorAddress: string, fromBlock: number, toBlock: number, provider: ethers.providers.Provider, options?: {
80
+ chunkSize?: number;
81
+ }): Promise<DiscoveredProposal[]>;
82
+ /** Discover a proposal by transaction hash */
83
+ export declare function discoverProposalByTxHash(txHash: string, provider: ethers.providers.Provider): Promise<DiscoveredProposal | null>;
84
+ //# sourceMappingURL=governor-discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"governor-discovery.d.ts","sourceRoot":"","sources":["../../src/discovery/governor-discovery.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,UAAU,EACV,UAAU,EAEX,MAAM,UAAU,CAAC;AAkBlB,qDAAqD;AACrD,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,MAAM,GAAG,YAAY,CAQxE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAEtE;AAoBD;;;;;;;;;;;;GAYG;AACH,wBAAsB,0BAA0B,CAC9C,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,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