@gzeoneth/gov-tracker 0.2.1 → 0.3.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 (377) hide show
  1. package/README.md +129 -72
  2. package/dist/abis.d.ts +3 -0
  3. package/dist/abis.d.ts.map +1 -1
  4. package/dist/abis.js +30 -2
  5. package/dist/abis.js.map +1 -1
  6. package/dist/calldata/index.d.ts +1 -1
  7. package/dist/calldata/index.d.ts.map +1 -1
  8. package/dist/calldata/index.js.map +1 -1
  9. package/dist/calldata/parameter-decoder.d.ts.map +1 -1
  10. package/dist/calldata/parameter-decoder.js +8 -1
  11. package/dist/calldata/parameter-decoder.js.map +1 -1
  12. package/dist/calldata/signature-lookup.d.ts +17 -2
  13. package/dist/calldata/signature-lookup.d.ts.map +1 -1
  14. package/dist/calldata/signature-lookup.js +20 -2
  15. package/dist/calldata/signature-lookup.js.map +1 -1
  16. package/dist/cli/cli.d.ts +21 -0
  17. package/dist/cli/cli.d.ts.map +1 -0
  18. package/dist/cli/{monitor.js → cli.js} +372 -73
  19. package/dist/cli/cli.js.map +1 -0
  20. package/dist/cli/lib/cli.d.ts +54 -3
  21. package/dist/cli/lib/cli.d.ts.map +1 -1
  22. package/dist/cli/lib/cli.js +387 -78
  23. package/dist/cli/lib/cli.js.map +1 -1
  24. package/dist/cli/lib/concurrency.d.ts +20 -0
  25. package/dist/cli/lib/concurrency.d.ts.map +1 -0
  26. package/dist/cli/lib/concurrency.js +32 -0
  27. package/dist/cli/lib/concurrency.js.map +1 -0
  28. package/dist/cli/lib/json-state.d.ts +23 -0
  29. package/dist/cli/lib/json-state.d.ts.map +1 -1
  30. package/dist/cli/lib/json-state.js +51 -4
  31. package/dist/cli/lib/json-state.js.map +1 -1
  32. package/dist/cli/tui/App.d.ts +11 -0
  33. package/dist/cli/tui/App.d.ts.map +1 -0
  34. package/dist/cli/tui/App.js +123 -0
  35. package/dist/cli/tui/App.js.map +1 -0
  36. package/dist/cli/tui/components/CopyableText.d.ts +23 -0
  37. package/dist/cli/tui/components/CopyableText.d.ts.map +1 -0
  38. package/dist/cli/tui/components/CopyableText.js +49 -0
  39. package/dist/cli/tui/components/CopyableText.js.map +1 -0
  40. package/dist/cli/tui/components/Header.d.ts +20 -0
  41. package/dist/cli/tui/components/Header.d.ts.map +1 -0
  42. package/dist/cli/tui/components/Header.js +47 -0
  43. package/dist/cli/tui/components/Header.js.map +1 -0
  44. package/dist/cli/tui/components/KeyHelp.d.ts +19 -0
  45. package/dist/cli/tui/components/KeyHelp.d.ts.map +1 -0
  46. package/dist/cli/tui/components/KeyHelp.js +60 -0
  47. package/dist/cli/tui/components/KeyHelp.js.map +1 -0
  48. package/dist/cli/tui/components/ProposalRow.d.ts +11 -0
  49. package/dist/cli/tui/components/ProposalRow.d.ts.map +1 -0
  50. package/dist/cli/tui/components/ProposalRow.js +92 -0
  51. package/dist/cli/tui/components/ProposalRow.js.map +1 -0
  52. package/dist/cli/tui/components/ScrollIndicator.d.ts +19 -0
  53. package/dist/cli/tui/components/ScrollIndicator.d.ts.map +1 -0
  54. package/dist/cli/tui/components/ScrollIndicator.js +50 -0
  55. package/dist/cli/tui/components/ScrollIndicator.js.map +1 -0
  56. package/dist/cli/tui/components/SearchBar.d.ts +12 -0
  57. package/dist/cli/tui/components/SearchBar.d.ts.map +1 -0
  58. package/dist/cli/tui/components/SearchBar.js +36 -0
  59. package/dist/cli/tui/components/SearchBar.js.map +1 -0
  60. package/dist/cli/tui/components/Spinner.d.ts +10 -0
  61. package/dist/cli/tui/components/Spinner.d.ts.map +1 -0
  62. package/dist/cli/tui/components/Spinner.js +24 -0
  63. package/dist/cli/tui/components/Spinner.js.map +1 -0
  64. package/dist/cli/tui/components/StageProgress.d.ts +12 -0
  65. package/dist/cli/tui/components/StageProgress.d.ts.map +1 -0
  66. package/dist/cli/tui/components/StageProgress.js +41 -0
  67. package/dist/cli/tui/components/StageProgress.js.map +1 -0
  68. package/dist/cli/tui/components/StageRow.d.ts +12 -0
  69. package/dist/cli/tui/components/StageRow.d.ts.map +1 -0
  70. package/dist/cli/tui/components/StageRow.js +80 -0
  71. package/dist/cli/tui/components/StageRow.js.map +1 -0
  72. package/dist/cli/tui/components/StatusBadge.d.ts +12 -0
  73. package/dist/cli/tui/components/StatusBadge.d.ts.map +1 -0
  74. package/dist/cli/tui/components/StatusBadge.js +27 -0
  75. package/dist/cli/tui/components/StatusBadge.js.map +1 -0
  76. package/dist/cli/tui/components/ViewLayout.d.ts +22 -0
  77. package/dist/cli/tui/components/ViewLayout.d.ts.map +1 -0
  78. package/dist/cli/tui/components/ViewLayout.js +24 -0
  79. package/dist/cli/tui/components/ViewLayout.js.map +1 -0
  80. package/dist/cli/tui/components/VotingStats.d.ts +11 -0
  81. package/dist/cli/tui/components/VotingStats.d.ts.map +1 -0
  82. package/dist/cli/tui/components/VotingStats.js +87 -0
  83. package/dist/cli/tui/components/VotingStats.js.map +1 -0
  84. package/dist/cli/tui/hooks/index.d.ts +11 -0
  85. package/dist/cli/tui/hooks/index.d.ts.map +1 -0
  86. package/dist/cli/tui/hooks/index.js +18 -0
  87. package/dist/cli/tui/hooks/index.js.map +1 -0
  88. package/dist/cli/tui/hooks/useCache.d.ts +12 -0
  89. package/dist/cli/tui/hooks/useCache.d.ts.map +1 -0
  90. package/dist/cli/tui/hooks/useCache.js +52 -0
  91. package/dist/cli/tui/hooks/useCache.js.map +1 -0
  92. package/dist/cli/tui/hooks/useElectionData.d.ts +22 -0
  93. package/dist/cli/tui/hooks/useElectionData.d.ts.map +1 -0
  94. package/dist/cli/tui/hooks/useElectionData.js +133 -0
  95. package/dist/cli/tui/hooks/useElectionData.js.map +1 -0
  96. package/dist/cli/tui/hooks/useNavigation.d.ts +39 -0
  97. package/dist/cli/tui/hooks/useNavigation.d.ts.map +1 -0
  98. package/dist/cli/tui/hooks/useNavigation.js +173 -0
  99. package/dist/cli/tui/hooks/useNavigation.js.map +1 -0
  100. package/dist/cli/tui/hooks/useProposals.d.ts +10 -0
  101. package/dist/cli/tui/hooks/useProposals.d.ts.map +1 -0
  102. package/dist/cli/tui/hooks/useProposals.js +201 -0
  103. package/dist/cli/tui/hooks/useProposals.js.map +1 -0
  104. package/dist/cli/tui/hooks/useScrollableInput.d.ts +14 -0
  105. package/dist/cli/tui/hooks/useScrollableInput.d.ts.map +1 -0
  106. package/dist/cli/tui/hooks/useScrollableInput.js +44 -0
  107. package/dist/cli/tui/hooks/useScrollableInput.js.map +1 -0
  108. package/dist/cli/tui/hooks/useStageCalldata.d.ts +17 -0
  109. package/dist/cli/tui/hooks/useStageCalldata.d.ts.map +1 -0
  110. package/dist/cli/tui/hooks/useStageCalldata.js +77 -0
  111. package/dist/cli/tui/hooks/useStageCalldata.js.map +1 -0
  112. package/dist/cli/tui/index.d.ts +13 -0
  113. package/dist/cli/tui/index.d.ts.map +1 -0
  114. package/dist/cli/tui/index.js +96 -0
  115. package/dist/cli/tui/index.js.map +1 -0
  116. package/dist/cli/tui/ink-wrapper.d.ts +43 -0
  117. package/dist/cli/tui/ink-wrapper.d.ts.map +1 -0
  118. package/dist/cli/tui/ink-wrapper.js +41 -0
  119. package/dist/cli/tui/ink-wrapper.js.map +1 -0
  120. package/dist/cli/tui/types.d.ts +38 -0
  121. package/dist/cli/tui/types.d.ts.map +1 -0
  122. package/dist/cli/tui/types.js +6 -0
  123. package/dist/cli/tui/types.js.map +1 -0
  124. package/dist/cli/tui/utils/calldata-formatter.d.ts +7 -0
  125. package/dist/cli/tui/utils/calldata-formatter.d.ts.map +1 -0
  126. package/dist/cli/tui/utils/calldata-formatter.js +14 -0
  127. package/dist/cli/tui/utils/calldata-formatter.js.map +1 -0
  128. package/dist/cli/tui/utils/clipboard.d.ts +7 -0
  129. package/dist/cli/tui/utils/clipboard.d.ts.map +1 -0
  130. package/dist/cli/tui/utils/clipboard.js +46 -0
  131. package/dist/cli/tui/utils/clipboard.js.map +1 -0
  132. package/dist/cli/tui/utils/index.d.ts +16 -0
  133. package/dist/cli/tui/utils/index.d.ts.map +1 -0
  134. package/dist/cli/tui/utils/index.js +52 -0
  135. package/dist/cli/tui/utils/index.js.map +1 -0
  136. package/dist/cli/tui/utils/markdown-parser.d.ts +11 -0
  137. package/dist/cli/tui/utils/markdown-parser.d.ts.map +1 -0
  138. package/dist/cli/tui/utils/markdown-parser.js +77 -0
  139. package/dist/cli/tui/utils/markdown-parser.js.map +1 -0
  140. package/dist/cli/tui/utils/navigation.d.ts +17 -0
  141. package/dist/cli/tui/utils/navigation.d.ts.map +1 -0
  142. package/dist/cli/tui/utils/navigation.js +75 -0
  143. package/dist/cli/tui/utils/navigation.js.map +1 -0
  144. package/dist/cli/tui/utils/proposal-detail-helpers.d.ts +9 -0
  145. package/dist/cli/tui/utils/proposal-detail-helpers.d.ts.map +1 -0
  146. package/dist/cli/tui/utils/proposal-detail-helpers.js +21 -0
  147. package/dist/cli/tui/utils/proposal-detail-helpers.js.map +1 -0
  148. package/dist/cli/tui/utils/shortcuts.d.ts +17 -0
  149. package/dist/cli/tui/utils/shortcuts.d.ts.map +1 -0
  150. package/dist/cli/tui/utils/shortcuts.js +100 -0
  151. package/dist/cli/tui/utils/shortcuts.js.map +1 -0
  152. package/dist/cli/tui/utils/stage-formatter.d.ts +7 -0
  153. package/dist/cli/tui/utils/stage-formatter.d.ts.map +1 -0
  154. package/dist/cli/tui/utils/stage-formatter.js +14 -0
  155. package/dist/cli/tui/utils/stage-formatter.js.map +1 -0
  156. package/dist/cli/tui/utils/stage-status.d.ts +10 -0
  157. package/dist/cli/tui/utils/stage-status.d.ts.map +1 -0
  158. package/dist/cli/tui/utils/stage-status.js +64 -0
  159. package/dist/cli/tui/utils/stage-status.js.map +1 -0
  160. package/dist/cli/tui/utils/terminal.d.ts +18 -0
  161. package/dist/cli/tui/utils/terminal.d.ts.map +1 -0
  162. package/dist/cli/tui/utils/terminal.js +26 -0
  163. package/dist/cli/tui/utils/terminal.js.map +1 -0
  164. package/dist/cli/tui/utils/text.d.ts +7 -0
  165. package/dist/cli/tui/utils/text.d.ts.map +1 -0
  166. package/dist/cli/tui/utils/text.js +12 -0
  167. package/dist/cli/tui/utils/text.js.map +1 -0
  168. package/dist/cli/tui/utils/time.d.ts +19 -0
  169. package/dist/cli/tui/utils/time.d.ts.map +1 -0
  170. package/dist/cli/tui/utils/time.js +43 -0
  171. package/dist/cli/tui/utils/time.js.map +1 -0
  172. package/dist/cli/tui/views/CalldataView.d.ts +12 -0
  173. package/dist/cli/tui/views/CalldataView.d.ts.map +1 -0
  174. package/dist/cli/tui/views/CalldataView.js +110 -0
  175. package/dist/cli/tui/views/CalldataView.js.map +1 -0
  176. package/dist/cli/tui/views/DescriptionView.d.ts +12 -0
  177. package/dist/cli/tui/views/DescriptionView.d.ts.map +1 -0
  178. package/dist/cli/tui/views/DescriptionView.js +75 -0
  179. package/dist/cli/tui/views/DescriptionView.js.map +1 -0
  180. package/dist/cli/tui/views/ElectionView.d.ts +11 -0
  181. package/dist/cli/tui/views/ElectionView.d.ts.map +1 -0
  182. package/dist/cli/tui/views/ElectionView.js +193 -0
  183. package/dist/cli/tui/views/ElectionView.js.map +1 -0
  184. package/dist/cli/tui/views/HelpView.d.ts +10 -0
  185. package/dist/cli/tui/views/HelpView.d.ts.map +1 -0
  186. package/dist/cli/tui/views/HelpView.js +75 -0
  187. package/dist/cli/tui/views/HelpView.js.map +1 -0
  188. package/dist/cli/tui/views/ProposalDetail.d.ts +12 -0
  189. package/dist/cli/tui/views/ProposalDetail.d.ts.map +1 -0
  190. package/dist/cli/tui/views/ProposalDetail.js +103 -0
  191. package/dist/cli/tui/views/ProposalDetail.js.map +1 -0
  192. package/dist/cli/tui/views/ProposalList.d.ts +15 -0
  193. package/dist/cli/tui/views/ProposalList.d.ts.map +1 -0
  194. package/dist/cli/tui/views/ProposalList.js +154 -0
  195. package/dist/cli/tui/views/ProposalList.js.map +1 -0
  196. package/dist/cli/tui/views/SimulationView.d.ts +12 -0
  197. package/dist/cli/tui/views/SimulationView.d.ts.map +1 -0
  198. package/dist/cli/tui/views/SimulationView.js +110 -0
  199. package/dist/cli/tui/views/SimulationView.js.map +1 -0
  200. package/dist/cli/tui/views/StageView.d.ts +12 -0
  201. package/dist/cli/tui/views/StageView.d.ts.map +1 -0
  202. package/dist/cli/tui/views/StageView.js +109 -0
  203. package/dist/cli/tui/views/StageView.js.map +1 -0
  204. package/dist/cli/tui/views/registry.d.ts +18 -0
  205. package/dist/cli/tui/views/registry.d.ts.map +1 -0
  206. package/dist/cli/tui/views/registry.js +34 -0
  207. package/dist/cli/tui/views/registry.js.map +1 -0
  208. package/dist/constants.d.ts +44 -0
  209. package/dist/constants.d.ts.map +1 -1
  210. package/dist/constants.js +52 -1
  211. package/dist/constants.js.map +1 -1
  212. package/dist/data/bundled-cache.json +16408 -2561
  213. package/dist/deduplication.d.ts +132 -0
  214. package/dist/deduplication.d.ts.map +1 -0
  215. package/dist/deduplication.js +270 -0
  216. package/dist/deduplication.js.map +1 -0
  217. package/dist/discovery/governor-discovery.d.ts.map +1 -1
  218. package/dist/discovery/governor-discovery.js +52 -36
  219. package/dist/discovery/governor-discovery.js.map +1 -1
  220. package/dist/discovery/timelock-discovery.d.ts +15 -6
  221. package/dist/discovery/timelock-discovery.d.ts.map +1 -1
  222. package/dist/discovery/timelock-discovery.js +27 -11
  223. package/dist/discovery/timelock-discovery.js.map +1 -1
  224. package/dist/election/contracts.d.ts +8 -0
  225. package/dist/election/contracts.d.ts.map +1 -0
  226. package/dist/election/contracts.js +28 -0
  227. package/dist/election/contracts.js.map +1 -0
  228. package/dist/election/details.d.ts +15 -0
  229. package/dist/election/details.d.ts.map +1 -0
  230. package/dist/election/details.js +157 -0
  231. package/dist/election/details.js.map +1 -0
  232. package/dist/election/index.d.ts +11 -0
  233. package/dist/election/index.d.ts.map +1 -0
  234. package/dist/election/index.js +48 -0
  235. package/dist/election/index.js.map +1 -0
  236. package/dist/election/params.d.ts +13 -0
  237. package/dist/election/params.d.ts.map +1 -0
  238. package/dist/election/params.js +93 -0
  239. package/dist/election/params.js.map +1 -0
  240. package/dist/election/participants.d.ts +6 -0
  241. package/dist/election/participants.d.ts.map +1 -0
  242. package/dist/election/participants.js +104 -0
  243. package/dist/election/participants.js.map +1 -0
  244. package/dist/election/prepare.d.ts +10 -0
  245. package/dist/election/prepare.d.ts.map +1 -0
  246. package/dist/election/prepare.js +52 -0
  247. package/dist/election/prepare.js.map +1 -0
  248. package/dist/election/proposal-ids.d.ts +18 -0
  249. package/dist/election/proposal-ids.d.ts.map +1 -0
  250. package/dist/election/proposal-ids.js +77 -0
  251. package/dist/election/proposal-ids.js.map +1 -0
  252. package/dist/election/status.d.ts +15 -0
  253. package/dist/election/status.d.ts.map +1 -0
  254. package/dist/election/status.js +105 -0
  255. package/dist/election/status.js.map +1 -0
  256. package/dist/election/tracking.d.ts +28 -0
  257. package/dist/election/tracking.d.ts.map +1 -0
  258. package/dist/election/tracking.js +412 -0
  259. package/dist/election/tracking.js.map +1 -0
  260. package/dist/index.d.ts +31 -7
  261. package/dist/index.d.ts.map +1 -1
  262. package/dist/index.js +98 -9
  263. package/dist/index.js.map +1 -1
  264. package/dist/stages/builder.d.ts +4 -0
  265. package/dist/stages/builder.d.ts.map +1 -1
  266. package/dist/stages/builder.js +7 -0
  267. package/dist/stages/builder.js.map +1 -1
  268. package/dist/stages/l2-to-l1-message.d.ts +8 -1
  269. package/dist/stages/l2-to-l1-message.d.ts.map +1 -1
  270. package/dist/stages/l2-to-l1-message.js +79 -13
  271. package/dist/stages/l2-to-l1-message.js.map +1 -1
  272. package/dist/stages/proposal-created.d.ts +1 -0
  273. package/dist/stages/proposal-created.d.ts.map +1 -1
  274. package/dist/stages/proposal-created.js +1 -0
  275. package/dist/stages/proposal-created.js.map +1 -1
  276. package/dist/stages/proposal-queued.d.ts +1 -0
  277. package/dist/stages/proposal-queued.d.ts.map +1 -1
  278. package/dist/stages/proposal-queued.js +3 -1
  279. package/dist/stages/proposal-queued.js.map +1 -1
  280. package/dist/stages/retryables.js +2 -2
  281. package/dist/stages/retryables.js.map +1 -1
  282. package/dist/stages/timelock.d.ts +3 -1
  283. package/dist/stages/timelock.d.ts.map +1 -1
  284. package/dist/stages/timelock.js +10 -4
  285. package/dist/stages/timelock.js.map +1 -1
  286. package/dist/stages/utils.d.ts +7 -8
  287. package/dist/stages/utils.d.ts.map +1 -1
  288. package/dist/stages/utils.js +40 -27
  289. package/dist/stages/utils.js.map +1 -1
  290. package/dist/stages/voting.d.ts.map +1 -1
  291. package/dist/stages/voting.js +5 -4
  292. package/dist/stages/voting.js.map +1 -1
  293. package/dist/tracker/cache.d.ts +10 -6
  294. package/dist/tracker/cache.d.ts.map +1 -1
  295. package/dist/tracker/cache.js +39 -15
  296. package/dist/tracker/cache.js.map +1 -1
  297. package/dist/tracker/checkpoint-helpers.d.ts +80 -0
  298. package/dist/tracker/checkpoint-helpers.d.ts.map +1 -0
  299. package/dist/tracker/checkpoint-helpers.js +200 -0
  300. package/dist/tracker/checkpoint-helpers.js.map +1 -0
  301. package/dist/tracker/discovery.d.ts +40 -9
  302. package/dist/tracker/discovery.d.ts.map +1 -1
  303. package/dist/tracker/discovery.js +152 -15
  304. package/dist/tracker/discovery.js.map +1 -1
  305. package/dist/tracker/pipeline.d.ts.map +1 -1
  306. package/dist/tracker/pipeline.js +26 -11
  307. package/dist/tracker/pipeline.js.map +1 -1
  308. package/dist/tracker/query.d.ts +1 -0
  309. package/dist/tracker/query.d.ts.map +1 -1
  310. package/dist/tracker/query.js +14 -61
  311. package/dist/tracker/query.js.map +1 -1
  312. package/dist/tracker/state.d.ts +0 -10
  313. package/dist/tracker/state.d.ts.map +1 -1
  314. package/dist/tracker/state.js +1 -28
  315. package/dist/tracker/state.js.map +1 -1
  316. package/dist/tracker.d.ts +100 -8
  317. package/dist/tracker.d.ts.map +1 -1
  318. package/dist/tracker.js +405 -42
  319. package/dist/tracker.js.map +1 -1
  320. package/dist/types/config.d.ts +49 -0
  321. package/dist/types/config.d.ts.map +1 -1
  322. package/dist/types/core.d.ts +4 -2
  323. package/dist/types/core.d.ts.map +1 -1
  324. package/dist/types/election.d.ts +144 -1
  325. package/dist/types/election.d.ts.map +1 -1
  326. package/dist/types/index.d.ts +5 -7
  327. package/dist/types/index.d.ts.map +1 -1
  328. package/dist/types/index.js +2 -3
  329. package/dist/types/index.js.map +1 -1
  330. package/dist/types/stages.d.ts +79 -1
  331. package/dist/types/stages.d.ts.map +1 -1
  332. package/dist/types/stages.js.map +1 -1
  333. package/dist/types/tracking.d.ts +34 -4
  334. package/dist/types/tracking.d.ts.map +1 -1
  335. package/dist/utils/block-cache.d.ts +50 -0
  336. package/dist/utils/block-cache.d.ts.map +1 -0
  337. package/dist/utils/block-cache.js +80 -0
  338. package/dist/utils/block-cache.js.map +1 -0
  339. package/dist/utils/formatters.d.ts +91 -0
  340. package/dist/utils/formatters.d.ts.map +1 -0
  341. package/dist/utils/formatters.js +327 -0
  342. package/dist/utils/formatters.js.map +1 -0
  343. package/dist/utils/multicall.d.ts +52 -0
  344. package/dist/utils/multicall.d.ts.map +1 -0
  345. package/dist/utils/multicall.js +75 -0
  346. package/dist/utils/multicall.js.map +1 -0
  347. package/dist/utils/rpc-utils.d.ts +7 -1
  348. package/dist/utils/rpc-utils.d.ts.map +1 -1
  349. package/dist/utils/rpc-utils.js +43 -29
  350. package/dist/utils/rpc-utils.js.map +1 -1
  351. package/dist/utils/salt-computation.d.ts.map +1 -1
  352. package/dist/utils/salt-computation.js +33 -7
  353. package/dist/utils/salt-computation.js.map +1 -1
  354. package/dist/utils/sanitize.d.ts +28 -0
  355. package/dist/utils/sanitize.d.ts.map +1 -0
  356. package/dist/utils/sanitize.js +55 -0
  357. package/dist/utils/sanitize.js.map +1 -0
  358. package/dist/utils/stage-metadata.d.ts +0 -20
  359. package/dist/utils/stage-metadata.d.ts.map +1 -1
  360. package/dist/utils/stage-metadata.js +29 -44
  361. package/dist/utils/stage-metadata.js.map +1 -1
  362. package/dist/utils/timing.d.ts +13 -0
  363. package/dist/utils/timing.d.ts.map +1 -1
  364. package/dist/utils/timing.js +37 -1
  365. package/dist/utils/timing.js.map +1 -1
  366. package/package.json +29 -16
  367. package/dist/cli/monitor.d.ts +0 -3
  368. package/dist/cli/monitor.d.ts.map +0 -1
  369. package/dist/cli/monitor.js.map +0 -1
  370. package/dist/election.d.ts +0 -172
  371. package/dist/election.d.ts.map +0 -1
  372. package/dist/election.js +0 -467
  373. package/dist/election.js.map +0 -1
  374. package/dist/types/cross-chain.d.ts +0 -24
  375. package/dist/types/cross-chain.d.ts.map +0 -1
  376. package/dist/types/cross-chain.js +0 -6
  377. package/dist/types/cross-chain.js.map +0 -1
@@ -7,13 +7,14 @@
7
7
  *
8
8
  * Provides RPC option parsing, provider creation, transaction execution,
9
9
  * and the core monitoring cycle. This is monitor-specific code, not part of the SDK.
10
+ *
11
+ * Dependencies:
12
+ * - commander is an optional dependency required for CLI usage
10
13
  */
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.loopOptions = exports.gasOptions = exports.chunkingOptions = exports.executionOptions = exports.cacheOptions = exports.verboseOption = exports.rpcOptions = exports.DEFAULT_L2_GAS_SETTINGS = exports.MAX_CONSECUTIVE_ERRORS = exports.DEFAULT_MAX_AGE_DAYS = exports.DEFAULT_BLOCK_LAG = exports.isElectionGovernor = void 0;
15
+ exports.loopOptions = exports.gasOptions = exports.chunkingOptions = exports.executionOptions = exports.cacheOptions = exports.verboseOption = exports.rpcOptions = exports.HEALTH_CHECK_TIMEOUT_MS = exports.DEFAULT_L2_GAS_SETTINGS = exports.MAX_CONSECUTIVE_ERRORS = exports.DEFAULT_MAX_AGE_DAYS = exports.DEFAULT_BLOCK_LAG = exports.isElectionGovernor = void 0;
16
16
  exports.addOptions = addOptions;
17
+ exports.validateCliOptions = validateCliOptions;
17
18
  exports.parseGasSettings = parseGasSettings;
18
19
  exports.parseChunkingConfig = parseChunkingConfig;
19
20
  exports.createProvidersFromOptions = createProvidersFromOptions;
@@ -24,13 +25,17 @@ exports.formatDryRun = formatDryRun;
24
25
  exports.formatMultiplePreparedTransactions = formatMultiplePreparedTransactions;
25
26
  exports.formatTrackingResult = formatTrackingResult;
26
27
  exports.formatCacheStatus = formatCacheStatus;
28
+ exports.formatElectionResult = formatElectionResult;
29
+ exports.displayTrackingResult = displayTrackingResult;
27
30
  exports.isShuttingDown = isShuttingDown;
28
31
  exports.runWithLoop = runWithLoop;
32
+ exports.filterCheckpointsByTargets = filterCheckpointsByTargets;
33
+ exports.calculateFilteredStats = calculateFilteredStats;
29
34
  exports.runMonitorCycle = runMonitorCycle;
30
35
  exports.trackAndPrepare = trackAndPrepare;
31
36
  const commander_1 = require("commander");
32
37
  const ethers_1 = require("ethers");
33
- const p_limit_1 = __importDefault(require("p-limit"));
38
+ const concurrency_1 = require("./concurrency");
34
39
  const index_1 = require("../../index");
35
40
  Object.defineProperty(exports, "isElectionGovernor", { enumerable: true, get: function () { return index_1.isElectionGovernor; } });
36
41
  const logger_1 = require("../../utils/logger");
@@ -50,6 +55,8 @@ exports.DEFAULT_L2_GAS_SETTINGS = {
50
55
  /** Max priority fee per gas in gwei */
51
56
  maxPriorityFeePerGas: 0,
52
57
  };
58
+ /** Health check timeout in milliseconds */
59
+ exports.HEALTH_CHECK_TIMEOUT_MS = 5000;
53
60
  // ============================================================================
54
61
  // RPC Configuration
55
62
  // ============================================================================
@@ -64,12 +71,12 @@ exports.rpcOptions = [
64
71
  /**
65
72
  * Verbose logging option - enables debug output
66
73
  */
67
- exports.verboseOption = new commander_1.Option("--verbose", "Enable verbose logging");
74
+ exports.verboseOption = new commander_1.Option("-v, --verbose", "Enable verbose logging");
68
75
  /**
69
76
  * Cache-related options for commands that use the tracker cache
70
77
  */
71
78
  exports.cacheOptions = {
72
- /** Cache file path option (default is set in monitor.ts) */
79
+ /** Cache file path option (default is set in cli.ts) */
73
80
  cache: (defaultPath) => new commander_1.Option("--cache <path>", "Cache file").default(defaultPath),
74
81
  /** Force flag to bypass cache and re-track from scratch */
75
82
  force: new commander_1.Option("--force", "Force refresh, ignoring cached data"),
@@ -80,8 +87,8 @@ exports.cacheOptions = {
80
87
  * Execution-related options for commands that can prepare/execute transactions
81
88
  */
82
89
  exports.executionOptions = [
83
- new commander_1.Option("--prepare", "Prepare transactions for ready stages (dry-run)"),
84
- new commander_1.Option("--write", "Execute prepared transactions (requires --private-key)"),
90
+ new commander_1.Option("-p, --prepare", "Prepare transactions for ready stages (dry-run)"),
91
+ new commander_1.Option("-w, --write", "Execute prepared transactions (requires --private-key)"),
85
92
  new commander_1.Option("--private-key <key>", "Private key for execution").env("PRIVATE_KEY"),
86
93
  new commander_1.Option("--prepare-completed", "Prepare completed stages (for historical validation)"),
87
94
  new commander_1.Option("--prepare-pending", "Prepare pending stages (waiting for delays)"),
@@ -112,6 +119,59 @@ exports.loopOptions = [
112
119
  function addOptions(cmd, opts) {
113
120
  opts.forEach((o) => cmd.addOption(o));
114
121
  }
122
+ /**
123
+ * Validate CLI options for contradictions and conflicts.
124
+ * Throws an error if conflicting options are detected.
125
+ */
126
+ function validateCliOptions(opts, command) {
127
+ const errors = [];
128
+ // Cache conflicts
129
+ if (opts.cache && opts.noCache) {
130
+ errors.push({
131
+ flags: ["--cache", "--no-cache"],
132
+ message: "--cache and --no-cache are mutually exclusive",
133
+ });
134
+ }
135
+ // --force overrides --start-block (warn, not error)
136
+ if (opts.force && opts.startBlock) {
137
+ errors.push({
138
+ flags: ["--force", "--start-block"],
139
+ message: "--force resets discovery to block 0, overriding --start-block",
140
+ });
141
+ }
142
+ // Track command specific validations
143
+ if (command === "track") {
144
+ // --inspect and --inspect-only are mutually exclusive
145
+ if (opts.inspect && opts.inspectOnly) {
146
+ errors.push({
147
+ flags: ["--inspect", "--inspect-only"],
148
+ message: "--inspect and --inspect-only are mutually exclusive",
149
+ });
150
+ }
151
+ // --inspect-only skips tracking, so execution options don't make sense
152
+ if (opts.inspectOnly) {
153
+ const conflictingFlags = [];
154
+ if (opts.prepare)
155
+ conflictingFlags.push("--prepare");
156
+ if (opts.write)
157
+ conflictingFlags.push("--write");
158
+ if (opts.prepareCompleted)
159
+ conflictingFlags.push("--prepare-completed");
160
+ if (opts.preparePending)
161
+ conflictingFlags.push("--prepare-pending");
162
+ if (conflictingFlags.length > 0) {
163
+ errors.push({
164
+ flags: ["--inspect-only", ...conflictingFlags],
165
+ message: `--inspect-only skips tracking; ${conflictingFlags.join(", ")} require tracking`,
166
+ });
167
+ }
168
+ }
169
+ }
170
+ if (errors.length > 0) {
171
+ const messages = errors.map((e) => ` ${e.flags.join(" + ")}: ${e.message}`);
172
+ throw new Error(`Conflicting options detected:\n${messages.join("\n")}`);
173
+ }
174
+ }
115
175
  /**
116
176
  * Parse gas settings from CLI options
117
177
  */
@@ -138,10 +198,21 @@ function parseChunkingConfig(opts, delayMs) {
138
198
  }
139
199
  function createProvidersFromOptions(opts) {
140
200
  const l2Rpc = opts.l2Rpc || process.env.ARB1_RPC || index_1.DEFAULT_RPC_URLS.ARB_ONE;
141
- const l1Rpc = opts.l1Rpc || process.env.ETH_RPC;
201
+ const l1Rpc = opts.l1Rpc || process.env.ETH_RPC || index_1.DEFAULT_RPC_URLS.ETHEREUM;
142
202
  const novaRpc = opts.novaRpc || process.env.NOVA_RPC || index_1.DEFAULT_RPC_URLS.NOVA;
143
- if (!l1Rpc) {
144
- throw new Error("L1 RPC URL required (--l1-rpc or ETH_RPC env var)");
203
+ // Warn when using default public RPCs (no env var or CLI option provided)
204
+ const warnings = [];
205
+ if (!opts.l1Rpc && !process.env.ETH_RPC) {
206
+ warnings.push("Using public RPC URL for Ethereum (ETH_RPC not set)");
207
+ }
208
+ if (!opts.l2Rpc && !process.env.ARB1_RPC) {
209
+ warnings.push("Using public RPC URL for Arbitrum One (ARB1_RPC not set)");
210
+ }
211
+ if (!opts.novaRpc && !process.env.NOVA_RPC) {
212
+ warnings.push("Using public RPC URL for Nova (NOVA_RPC not set)");
213
+ }
214
+ if (warnings.length > 0) {
215
+ console.warn(`Warning: ${warnings.join("; ")}. Public RPCs may have rate limits.`);
145
216
  }
146
217
  // Use StaticJsonRpcProvider to avoid automatic chainId detection on every call
147
218
  return {
@@ -327,57 +398,114 @@ function formatTrackingResult(result, label) {
327
398
  }
328
399
  return lines.join("\n").concat("\n");
329
400
  }
330
- function formatCacheStatus(checkpoints) {
331
- let proposalTotal = 0, proposalComplete = 0, proposalActive = 0, proposalFailed = 0;
332
- let timelockTotal = 0, timelockComplete = 0, timelockActive = 0, timelockFailed = 0;
333
- let electionTotal = 0, electionComplete = 0;
334
- for (const [, checkpoint] of checkpoints) {
335
- const stages = checkpoint.cachedData?.completedStages ?? [];
336
- const isComplete = stages.length > 0 && (0, index_1.areAllStagesComplete)(stages);
337
- const errorCount = checkpoint.metadata?.errorCount ?? 0;
338
- const isFailed = errorCount >= exports.MAX_CONSECUTIVE_ERRORS;
339
- const input = checkpoint.input;
340
- if (input.type === "governor") {
341
- if ((0, index_1.isElectionGovernor)(input.governorAddress)) {
342
- electionTotal++;
343
- if (isComplete)
344
- electionComplete++;
401
+ function formatCacheStatus(checkpoints, elections) {
402
+ const stats = (0, index_1.computeCacheStats)(checkpoints, elections, exports.MAX_CONSECUTIVE_ERRORS);
403
+ const lines = [
404
+ `Total cached: ${stats.total}`,
405
+ ``,
406
+ `Proposals: ${stats.proposals.total}`,
407
+ ` Complete: ${stats.proposals.complete}`,
408
+ ` Active: ${stats.proposals.active}`,
409
+ ];
410
+ if (stats.proposals.errored > 0)
411
+ lines.push(` Failed: ${stats.proposals.errored}`);
412
+ lines.push(``, `Timelock Ops: ${stats.timelocks.total}`, ` Complete: ${stats.timelocks.complete}`, ` Active: ${stats.timelocks.active}`);
413
+ if (stats.timelocks.errored > 0)
414
+ lines.push(` Failed: ${stats.timelocks.errored}`);
415
+ if (stats.elections.total > 0) {
416
+ const active = stats.elections.total - stats.elections.complete;
417
+ lines.push(``, `Elections: ${stats.elections.total}`, ` Complete: ${stats.elections.complete}`, ` Active: ${active}`);
418
+ }
419
+ return lines.join("\n");
420
+ }
421
+ /**
422
+ * Format an election status for CLI output
423
+ */
424
+ function formatElectionResult(election) {
425
+ const lines = [];
426
+ const cohortName = election.cohort === 0 ? "First" : "Second";
427
+ const phaseName = election.phase.replace(/_/g, " ");
428
+ lines.push(`[Election #${election.electionIndex}]`);
429
+ lines.push(`Phase: ${phaseName}`);
430
+ lines.push(`Cohort: ${cohortName}`);
431
+ lines.push(`Complete: ${election.phase === "COMPLETED"}`);
432
+ lines.push(`Stages: ${election.stages?.length ?? 0}`);
433
+ lines.push("");
434
+ if (election.stages && election.stages.length > 0) {
435
+ for (let i = 0; i < election.stages.length; i++) {
436
+ const stage = election.stages[i];
437
+ const statusStr = stage.status;
438
+ const title = (0, index_1.formatStageTitle)(stage.type);
439
+ const eta = (0, index_1.calculateExpectedEta)(election.stages, i);
440
+ let line = ` ${title}: ${statusStr}`;
441
+ if (eta)
442
+ line += ` | ETA: ${new Date(eta * 1000).toISOString()}`;
443
+ lines.push(line);
444
+ for (const tx of stage.transactions) {
445
+ lines.push(` tx: ${tx.hash}`);
446
+ const url = (0, index_1.getStageTransactionUrl)(tx);
447
+ if (url)
448
+ lines.push(` ${url}`);
345
449
  }
346
- else {
347
- proposalTotal++;
348
- if (isComplete)
349
- proposalComplete++;
350
- else if (isFailed)
351
- proposalFailed++;
352
- else
353
- proposalActive++;
450
+ }
451
+ }
452
+ // Show timelock operation ID if tracked (useful for cross-referencing)
453
+ if (election.timelockOperationId) {
454
+ lines.push(` Timelock Op: ${election.timelockOperationId}`);
455
+ }
456
+ if (election.canProceedToMemberPhase) {
457
+ lines.push("");
458
+ lines.push(" → Ready to trigger member election");
459
+ }
460
+ if (election.canExecuteMember) {
461
+ lines.push("");
462
+ lines.push(" → Ready to execute member election");
463
+ }
464
+ if (election.canCreateElection) {
465
+ lines.push("");
466
+ lines.push(" → Ready to create election");
467
+ }
468
+ lines.push("");
469
+ return lines.join("\n");
470
+ }
471
+ /**
472
+ * Display a tracking result, automatically switching to election display for election proposals.
473
+ * Handles the election auto-switch logic internally, falling back to formatTrackingResult for non-elections.
474
+ *
475
+ * @param result - Tracking result to display
476
+ * @param label - Optional label prefix
477
+ */
478
+ function displayTrackingResult(result, label) {
479
+ if (result.isElection && result.electionStatus) {
480
+ const election = result.electionStatus;
481
+ const cohortName = election.cohort === 0 ? "First" : "Second";
482
+ console.log(`=== Election #${election.electionIndex} ===`);
483
+ console.log(`Phase: ${election.phase}`);
484
+ console.log(`Cohort: ${cohortName} (${election.cohort})`);
485
+ console.log(`Compliant Nominees: ${election.compliantNomineeCount}/${election.targetNomineeCount}`);
486
+ if (election.nomineeProposalId) {
487
+ console.log(`\nElection ID: ${election.nomineeProposalId}`);
488
+ console.log(`\nNominee Phase:`);
489
+ console.log(` State: ${election.nomineeProposalState}`);
490
+ if (election.vettingDeadline) {
491
+ console.log(` Vetting Deadline: block ${election.vettingDeadline}`);
354
492
  }
493
+ console.log(` In Vetting Period: ${election.isInVettingPeriod ? "YES" : "NO"}`);
355
494
  }
356
- else if (input.type === "timelock") {
357
- timelockTotal++;
358
- if (isComplete)
359
- timelockComplete++;
360
- else if (isFailed)
361
- timelockFailed++;
362
- else
363
- timelockActive++;
495
+ if (election.memberProposalId) {
496
+ console.log(`\nMember Phase:`);
497
+ console.log(` State: ${election.memberProposalState}`);
364
498
  }
499
+ if (election.canProceedToMemberPhase) {
500
+ console.log(`\n→ Ready to trigger member election`);
501
+ }
502
+ if (election.canExecuteMember) {
503
+ console.log(`\n→ Ready to execute member election`);
504
+ }
505
+ console.log("");
506
+ return;
365
507
  }
366
- const lines = [
367
- `Total cached: ${checkpoints.size}`,
368
- ``,
369
- `Proposals: ${proposalTotal}`,
370
- ` Complete: ${proposalComplete}`,
371
- ` Active: ${proposalActive}`,
372
- ];
373
- if (proposalFailed > 0)
374
- lines.push(` Failed: ${proposalFailed}`);
375
- lines.push(``, `Timelock Ops: ${timelockTotal}`, ` Complete: ${timelockComplete}`, ` Active: ${timelockActive}`);
376
- if (timelockFailed > 0)
377
- lines.push(` Failed: ${timelockFailed}`);
378
- if (electionTotal > 0)
379
- lines.push(``, `Elections: ${electionTotal} (${electionComplete} complete)`);
380
- return lines.join("\n");
508
+ console.log(formatTrackingResult(result, label));
381
509
  }
382
510
  // ============================================================================
383
511
  // Loop Runner
@@ -426,10 +554,13 @@ async function runWithLoop(cycleFn, options) {
426
554
  }
427
555
  if (options.healthCheckUrl) {
428
556
  try {
429
- await fetch(options.healthCheckUrl, { method: "GET" });
557
+ const controller = new AbortController();
558
+ const timeoutId = setTimeout(() => controller.abort(), exports.HEALTH_CHECK_TIMEOUT_MS);
559
+ await fetch(options.healthCheckUrl, { method: "GET", signal: controller.signal });
560
+ clearTimeout(timeoutId);
430
561
  }
431
562
  catch {
432
- // Silently ignore health check errors
563
+ // Silently ignore health check errors (including timeouts)
433
564
  }
434
565
  }
435
566
  if (running)
@@ -533,27 +664,193 @@ function shortScope(key) {
533
664
  }
534
665
  return key;
535
666
  }
667
+ /**
668
+ * Check if a checkpoint matches the enabled discovery targets.
669
+ * Used to filter incomplete checkpoints to only re-track types that are enabled.
670
+ */
671
+ function checkpointMatchesTargets(checkpoint, targets) {
672
+ if (checkpoint.input.type === "governor") {
673
+ const governorAddress = checkpoint.input.governorAddress;
674
+ // Skip election governors - they're handled separately
675
+ if ((0, index_1.isElectionGovernor)(governorAddress))
676
+ return false;
677
+ // Check if constitutional or non-constitutional governor is enabled
678
+ const isCore = (0, index_1.isConstitutional)(governorAddress);
679
+ return isCore ? !!targets.constitutionalGovernor : !!targets.nonConstitutionalGovernor;
680
+ }
681
+ if (checkpoint.input.type === "timelock") {
682
+ // Timelock operations: check if the corresponding timelock target is enabled
683
+ const timelockAddress = checkpoint.input.timelockAddress;
684
+ const isCore = (0, index_1.isConstitutional)(timelockAddress);
685
+ return isCore ? !!targets.l2ConstitutionalTimelock : !!targets.l2NonConstitutionalTimelock;
686
+ }
687
+ if (checkpoint.input.type === "election") {
688
+ return !!targets.electionNomineeGovernor || !!targets.electionMemberGovernor;
689
+ }
690
+ // Discovery checkpoints don't need re-tracking
691
+ return false;
692
+ }
693
+ /**
694
+ * Filter checkpoints to only include those matching enabled discovery targets.
695
+ * Used for JSON output and stats to ensure we only show tracked types.
696
+ */
697
+ function filterCheckpointsByTargets(checkpoints, targets) {
698
+ const filtered = new Map();
699
+ for (const [key, checkpoint] of checkpoints) {
700
+ if (checkpointMatchesTargets(checkpoint, targets)) {
701
+ filtered.set(key, checkpoint);
702
+ }
703
+ }
704
+ return filtered;
705
+ }
706
+ /**
707
+ * Calculate stats filtered by enabled discovery targets.
708
+ * Only counts checkpoints that match the enabled governors/timelocks.
709
+ */
710
+ function calculateFilteredStats(checkpoints, targets, maxErrorCount = 5) {
711
+ let proposalTotal = 0, proposalComplete = 0, proposalActive = 0, proposalErrored = 0;
712
+ let timelockTotal = 0, timelockComplete = 0, timelockActive = 0, timelockErrored = 0;
713
+ let electionTotal = 0, electionComplete = 0;
714
+ for (const [, checkpoint] of checkpoints) {
715
+ const complete = (0, index_1.isCheckpointComplete)(checkpoint);
716
+ const errored = (0, index_1.isCheckpointErrored)(checkpoint, maxErrorCount);
717
+ const inputType = checkpoint.input.type;
718
+ if (inputType === "governor") {
719
+ const governorAddress = checkpoint.input.governorAddress;
720
+ if ((0, index_1.isElectionGovernor)(governorAddress))
721
+ continue;
722
+ const isCore = (0, index_1.isConstitutional)(governorAddress);
723
+ const matchesTarget = isCore
724
+ ? !!targets.constitutionalGovernor
725
+ : !!targets.nonConstitutionalGovernor;
726
+ if (!matchesTarget)
727
+ continue;
728
+ proposalTotal++;
729
+ if (complete)
730
+ proposalComplete++;
731
+ else if (errored)
732
+ proposalErrored++;
733
+ else
734
+ proposalActive++;
735
+ }
736
+ else if (inputType === "timelock") {
737
+ const timelockAddress = checkpoint.input.timelockAddress;
738
+ const isCore = (0, index_1.isConstitutional)(timelockAddress);
739
+ const matchesTarget = isCore
740
+ ? !!targets.l2ConstitutionalTimelock
741
+ : !!targets.l2NonConstitutionalTimelock;
742
+ if (!matchesTarget)
743
+ continue;
744
+ timelockTotal++;
745
+ if (complete)
746
+ timelockComplete++;
747
+ else if (errored)
748
+ timelockErrored++;
749
+ else
750
+ timelockActive++;
751
+ }
752
+ else if (inputType === "election") {
753
+ // Only count elections if election tracking is enabled
754
+ if (!targets.electionNomineeGovernor && !targets.electionMemberGovernor)
755
+ continue;
756
+ electionTotal++;
757
+ if (complete)
758
+ electionComplete++;
759
+ }
760
+ }
761
+ return {
762
+ total: proposalTotal + timelockTotal + electionTotal,
763
+ proposals: {
764
+ total: proposalTotal,
765
+ complete: proposalComplete,
766
+ active: proposalActive,
767
+ errored: proposalErrored,
768
+ },
769
+ timelocks: {
770
+ total: timelockTotal,
771
+ complete: timelockComplete,
772
+ active: timelockActive,
773
+ errored: timelockErrored,
774
+ },
775
+ elections: { total: electionTotal, complete: electionComplete },
776
+ };
777
+ }
536
778
  async function runMonitorCycle(tracker, providers, options = {}) {
779
+ const result = { tracked: 0, prepared: 0, errors: 0, retracked: 0 };
780
+ // Fast path: elections-only mode skips discovery entirely
781
+ if (options.electionsOnly) {
782
+ const elections = [];
783
+ if (!isShuttingDown()) {
784
+ try {
785
+ // Use tracker's cached method - completed elections use cache (0 RPC calls)
786
+ // Use forceElections to bypass cache when --force is specified
787
+ const allElections = await tracker.trackAllElections({ force: options.forceElections });
788
+ for (const electionStatus of allElections) {
789
+ elections.push(electionStatus);
790
+ // Print each election
791
+ console.log(formatElectionResult(electionStatus));
792
+ }
793
+ }
794
+ catch (err) {
795
+ console.error("Election tracking failed:", err);
796
+ }
797
+ }
798
+ return {
799
+ result,
800
+ proposals: [],
801
+ timelockOps: [],
802
+ watermarks: {},
803
+ elections,
804
+ };
805
+ }
537
806
  const l2Provider = providers.l2Provider;
538
807
  const tipBlock = await l2Provider.getBlockNumber();
539
808
  const blockLag = options.blockLag ?? exports.DEFAULT_BLOCK_LAG;
540
809
  const currentBlock = Math.max(0, tipBlock - blockLag);
541
810
  const concurrency = options.concurrency ?? 1;
542
- const limit = (0, p_limit_1.default)(concurrency);
543
- // Optional startBlock override (watermarks are exclusive, so subtract 1)
544
- const startBlockWatermarks = options.startBlock
545
- ? {
811
+ const limit = (0, concurrency_1.pLimit)(concurrency);
812
+ const maxAgeDays = options.maxAgeDays ?? exports.DEFAULT_MAX_AGE_DAYS;
813
+ // Calculate startBlock based on maxAgeDays if not explicitly provided
814
+ // ~7200 blocks per day on Arbitrum (12s block time on L1, ~250ms on L2)
815
+ const BLOCKS_PER_DAY = 86400 / 0.25; // ~345,600 blocks/day on Arbitrum One
816
+ let startBlockWatermarks;
817
+ // Load existing watermarks to determine scan range
818
+ const loadedWatermarks = await tracker.loadWatermarks();
819
+ const hasWatermarks = Object.values(loadedWatermarks.watermarks).some((v) => v !== undefined);
820
+ if (options.startBlock !== undefined) {
821
+ // Explicit startBlock override (watermarks are exclusive, so subtract 1)
822
+ startBlockWatermarks = {
546
823
  constitutionalGovernor: options.startBlock - 1,
547
824
  nonConstitutionalGovernor: options.startBlock - 1,
548
825
  electionNomineeGovernor: options.startBlock - 1,
549
826
  electionMemberGovernor: options.startBlock - 1,
550
827
  l2ConstitutionalTimelock: options.startBlock - 1,
551
828
  l2NonConstitutionalTimelock: options.startBlock - 1,
552
- }
553
- : undefined;
554
- const targets = (0, index_1.buildDefaultTargets)();
829
+ };
830
+ console.log(`Discovery: blocks ${options.startBlock} → ${currentBlock}`);
831
+ }
832
+ else if (!hasWatermarks) {
833
+ // No cache - calculate start block from maxAgeDays
834
+ const defaultStartBlock = Math.max(0, currentBlock - Math.floor(maxAgeDays * BLOCKS_PER_DAY));
835
+ startBlockWatermarks = {
836
+ constitutionalGovernor: defaultStartBlock,
837
+ nonConstitutionalGovernor: defaultStartBlock,
838
+ electionNomineeGovernor: defaultStartBlock,
839
+ electionMemberGovernor: defaultStartBlock,
840
+ l2ConstitutionalTimelock: defaultStartBlock,
841
+ l2NonConstitutionalTimelock: defaultStartBlock,
842
+ };
843
+ console.log(`No cached watermarks. Discovery: blocks ${defaultStartBlock} → ${currentBlock} (~${maxAgeDays} days)`);
844
+ }
845
+ else {
846
+ // Cached watermarks exist - calculate effective range from min watermark
847
+ const watermarkBlocks = Object.values(loadedWatermarks.watermarks).filter((v) => v !== undefined);
848
+ const minWatermark = Math.min(...watermarkBlocks);
849
+ const blockRange = currentBlock - minWatermark;
850
+ console.log(`Discovery: blocks ${minWatermark} → ${currentBlock} (${blockRange.toLocaleString()} blocks)`);
851
+ }
852
+ const targets = options.targets ?? (0, index_1.buildDefaultTargets)();
555
853
  const discoveryResult = await tracker.discoverAll(targets, currentBlock, startBlockWatermarks);
556
- const result = { tracked: 0, prepared: 0, errors: 0, retracked: 0 };
557
854
  const trackedKeys = new Set();
558
855
  const trackedOperationIds = new Set();
559
856
  async function track(key, trackFn) {
@@ -607,7 +904,6 @@ async function runMonitorCycle(tracker, providers, options = {}) {
607
904
  });
608
905
  }
609
906
  // Query incomplete checkpoints first to avoid duplicate tracking
610
- const maxAgeDays = options.maxAgeDays ?? exports.DEFAULT_MAX_AGE_DAYS;
611
907
  const incompleteCheckpoints = await tracker.queryIncompleteCheckpoints({
612
908
  maxAgeDays,
613
909
  maxErrorCount: exports.MAX_CONSECUTIVE_ERRORS,
@@ -638,14 +934,10 @@ async function runMonitorCycle(tracker, providers, options = {}) {
638
934
  },
639
935
  });
640
936
  }
641
- // 1b. Incomplete governor checkpoints to re-track (excluding elections)
642
- const nonElectionCheckpoints = incompleteCheckpoints.filter(({ checkpoint }) => {
643
- if (checkpoint.input.type === "governor")
644
- return !(0, index_1.isElectionGovernor)(checkpoint.input.governorAddress);
645
- return true;
646
- });
647
- result.retracked = nonElectionCheckpoints.length;
648
- for (const { key, checkpoint } of nonElectionCheckpoints) {
937
+ // 1b. Incomplete checkpoints to re-track (filtered by enabled targets)
938
+ const targetMatchingCheckpoints = incompleteCheckpoints.filter(({ checkpoint }) => checkpointMatchesTargets(checkpoint, targets));
939
+ result.retracked = targetMatchingCheckpoints.length;
940
+ for (const { key, checkpoint } of targetMatchingCheckpoints) {
649
941
  if (checkpoint.input.type === "governor") {
650
942
  proposalTasks.push({
651
943
  key,
@@ -683,7 +975,7 @@ async function runMonitorCycle(tracker, providers, options = {}) {
683
975
  });
684
976
  }
685
977
  // 2b. Incomplete timelock checkpoints to re-track
686
- for (const { key, checkpoint } of nonElectionCheckpoints) {
978
+ for (const { key, checkpoint } of targetMatchingCheckpoints) {
687
979
  if (checkpoint.input.type === "timelock") {
688
980
  const operationId = checkpoint.input.operationId;
689
981
  // Skip if already tracked via proposal
@@ -699,11 +991,28 @@ async function runMonitorCycle(tracker, providers, options = {}) {
699
991
  }
700
992
  // Run timelock tasks
701
993
  await Promise.all(timelockTasks.map((task) => limit(() => track(task.key, task.fn))));
994
+ // Phase 3: Track elections (only if election targets are enabled)
995
+ const elections = [];
996
+ const shouldTrackElections = targets.electionNomineeGovernor || targets.electionMemberGovernor;
997
+ if (shouldTrackElections && !isShuttingDown()) {
998
+ try {
999
+ // Use tracker's cached method - completed elections use cache (0 RPC calls)
1000
+ const allElections = await tracker.trackAllElections({ force: options.forceElections });
1001
+ for (const electionStatus of allElections) {
1002
+ elections.push(electionStatus);
1003
+ }
1004
+ }
1005
+ catch (err) {
1006
+ // Election tracking is non-critical, log and continue
1007
+ console.error("Election tracking failed:", err);
1008
+ }
1009
+ }
702
1010
  return {
703
1011
  result,
704
1012
  proposals: discoveryResult.proposals,
705
1013
  timelockOps: discoveryResult.timelockOps,
706
1014
  watermarks: discoveryResult.watermarks,
1015
+ elections,
707
1016
  };
708
1017
  }
709
1018
  // ============================================================================