@gzeoneth/gov-tracker 0.2.1 → 0.3.0-beta.8f67631

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 +32 -8
  261. package/dist/index.d.ts.map +1 -1
  262. package/dist/index.js +101 -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 +23 -3
  363. package/dist/utils/timing.d.ts.map +1 -1
  364. package/dist/utils/timing.js +71 -7
  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
@@ -1,5 +1,23 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ /**
4
+ * Monitor CLI - Example SDK Usage
5
+ *
6
+ * NOTE: This is a CLI application that demonstrates SDK usage, not library code.
7
+ * It serves as both a reference implementation and a production-ready tool.
8
+ * Developers should treat this as an application of the SDK, not as part of the SDK API.
9
+ *
10
+ * Demonstrates how to use the governance tracking SDK for:
11
+ * - Discovering proposals and timelock operations
12
+ * - Tracking lifecycle stages
13
+ * - Preparing and executing transactions
14
+ *
15
+ * Usage: npx @gzeoneth/gov-tracker [run|track <tx-hash>|election|status] [options]
16
+ *
17
+ * Dependencies:
18
+ * - commander is an optional dependency required for CLI usage
19
+ * - dotenv is a dev dependency; .env files are loaded if available
20
+ */
3
21
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
22
  if (k2 === undefined) k2 = k;
5
23
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -37,27 +55,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
55
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
56
  };
39
57
  Object.defineProperty(exports, "__esModule", { value: true });
40
- /**
41
- * Monitor CLI - Example SDK Usage
42
- *
43
- * NOTE: This is a CLI application that demonstrates SDK usage, not library code.
44
- * It serves as both a reference implementation and a production-ready tool.
45
- * Developers should treat this as an application of the SDK, not as part of the SDK API.
46
- *
47
- * Demonstrates how to use the governance tracking SDK for:
48
- * - Discovering proposals and timelock operations
49
- * - Tracking lifecycle stages
50
- * - Preparing and executing transactions
51
- *
52
- * Usage: npx @gzeoneth/gov-tracker [run|track <tx-hash>|election|status] [options]
53
- */
54
- const dotenv = __importStar(require("dotenv"));
55
- dotenv.config();
58
+ // Load .env file if dotenv is available (dev dependency)
59
+ // Must be synchronous to ensure env vars are loaded before other imports access them
60
+ try {
61
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
62
+ require("dotenv").config();
63
+ }
64
+ catch (err) {
65
+ // Only ignore if module not found; re-throw other errors
66
+ const isModuleNotFound = err instanceof Error &&
67
+ "code" in err &&
68
+ err.code === "MODULE_NOT_FOUND";
69
+ if (!isModuleNotFound) {
70
+ throw err;
71
+ }
72
+ }
56
73
  const os = __importStar(require("os"));
57
74
  const path = __importStar(require("path"));
58
75
  const fs = __importStar(require("fs"));
59
76
  const debug_1 = __importDefault(require("debug"));
60
- const commander_1 = require("commander");
77
+ // Check for required CLI dependencies (optional in package.json)
78
+ let Command;
79
+ try {
80
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
81
+ const commander = require("commander");
82
+ Command = commander.Command;
83
+ }
84
+ catch {
85
+ console.error("Error: CLI requires 'commander' package.");
86
+ console.error("Install it with: yarn add commander");
87
+ process.exit(1);
88
+ }
61
89
  // Read version from package.json
62
90
  function getPackageVersion() {
63
91
  const candidates = [
@@ -217,16 +245,16 @@ function createProgressCallback() {
217
245
  console.log(` [${currentIndex + 1}/${totalStages}] ${(0, index_1.formatStageTitle)(stage.type)} (${stage.chain}): ${stage.status}`);
218
246
  };
219
247
  }
220
- const program = new commander_1.Command()
248
+ const program = new Command()
221
249
  .name("gov-tracker")
222
- .description("Track and execute Arbitrum DAO governance proposal lifecycle stages")
250
+ .description(`Track and execute Arbitrum DAO governance proposal lifecycle stages\nVersion: ${getPackageVersion()}`)
223
251
  .version(getPackageVersion());
224
252
  // ============================================================================
225
253
  // Run Command
226
254
  // ============================================================================
227
255
  const runCmd = program
228
- .command("run")
229
- .description("Discover, track, and optionally prepare/execute");
256
+ .command("run", { isDefault: true })
257
+ .description("Discover, track, and optionally prepare/execute (default command)");
230
258
  (0, cli_1.addOptions)(runCmd, cli_1.rpcOptions);
231
259
  (0, cli_1.addOptions)(runCmd, cli_1.executionOptions);
232
260
  (0, cli_1.addOptions)(runCmd, (0, cli_1.chunkingOptions)(index_1.CHUNK_SIZES.L1, index_1.CHUNK_SIZES.L2));
@@ -243,17 +271,23 @@ runCmd
243
271
  .option("--json-output <path>", "Write JSON state for dashboard integration")
244
272
  .option("--election", "Also check for Security Council elections each cycle")
245
273
  .option("--concurrency <n>", "Number of concurrent tracking operations", "1")
274
+ .option("--track-core", "Track constitutional (core) governor proposals")
275
+ .option("--track-treasury", "Track non-constitutional (treasury) governor proposals")
276
+ .option("--track-timelocks", "Track L2 timelock operations (direct schedules)")
277
+ .option("--track-elections", "Track election governor proposals")
246
278
  .action(async (opts) => {
247
279
  if (opts.verbose)
248
280
  debug_1.default.enable("gov-tracker:*");
281
+ (0, cli_1.validateCliOptions)(opts, "run");
249
282
  (0, cli_1.requirePrivateKeyForWrite)(opts);
250
283
  const providers = (0, cli_1.createProvidersFromOptions)(opts);
251
284
  const chunkingConfig = (0, cli_1.parseChunkingConfig)(opts, index_1.CHUNK_SIZES.DELAY_MS);
252
- // --no-cache disables cache entirely
285
+ // --no-cache disables cache entirely; use autoFlush: false for batch writes
253
286
  const cachePath = opts.noCache ? undefined : opts.cache;
287
+ const cache = cachePath ? new index_1.FileCache(cachePath, { autoFlush: false }) : undefined;
254
288
  const tracker = (0, index_1.createTracker)({
255
289
  ...providers,
256
- cachePath,
290
+ cache,
257
291
  chunkingConfig,
258
292
  onProgress: createProgressCallback(),
259
293
  });
@@ -269,6 +303,25 @@ runCmd
269
303
  const intervalMs = parseInt(opts.interval, 10) * 1000;
270
304
  const concurrency = parseInt(opts.concurrency, 10);
271
305
  const gasSettings = (0, cli_1.parseGasSettings)(opts);
306
+ // Build discovery targets from --track-* flags
307
+ // If any --track-* flag is specified, only track those; otherwise track all
308
+ const hasTrackFlags = opts.trackCore || opts.trackTreasury || opts.trackTimelocks || opts.trackElections;
309
+ // Detect what types are being tracked
310
+ const trackingProposals = !hasTrackFlags || opts.trackCore || opts.trackTreasury;
311
+ const trackingTimelocks = !hasTrackFlags || opts.trackTimelocks;
312
+ const trackingElections = !hasTrackFlags || opts.trackElections;
313
+ // Detect elections-only mode (only --track-elections, no other --track-* flags)
314
+ const electionsOnly = opts.trackElections && !opts.trackCore && !opts.trackTreasury && !opts.trackTimelocks;
315
+ const discoveryTargets = hasTrackFlags
316
+ ? {
317
+ constitutionalGovernor: opts.trackCore,
318
+ nonConstitutionalGovernor: opts.trackTreasury,
319
+ l2ConstitutionalTimelock: opts.trackTimelocks,
320
+ l2NonConstitutionalTimelock: opts.trackTimelocks,
321
+ electionNomineeGovernor: opts.trackElections,
322
+ electionMemberGovernor: opts.trackElections,
323
+ }
324
+ : (0, index_1.buildDefaultTargets)();
272
325
  if (opts.verbose) {
273
326
  if (startBlock !== undefined)
274
327
  console.log(`Starting discovery from block ${startBlock}`);
@@ -277,6 +330,12 @@ runCmd
277
330
  console.log(`Max consecutive errors before skip: ${cli_1.MAX_CONSECUTIVE_ERRORS}`);
278
331
  if (concurrency > 1)
279
332
  console.log(`Concurrency: ${concurrency}`);
333
+ if (hasTrackFlags) {
334
+ const enabled = Object.entries(discoveryTargets)
335
+ .filter(([, v]) => v)
336
+ .map(([k]) => k);
337
+ console.log(`Tracking targets: ${enabled.join(", ")}`);
338
+ }
280
339
  console.log(`L2 gas: ${gasSettings.maxFeePerGas} gwei maxFee, ${gasSettings.maxPriorityFeePerGas} gwei priority`);
281
340
  }
282
341
  if (signer)
@@ -284,12 +343,17 @@ runCmd
284
343
  // Track whether this is the first cycle (for startBlock override)
285
344
  let isFirstCycle = true;
286
345
  async function runCycle() {
287
- console.log("Discovering proposals and operations...\n");
346
+ if (electionsOnly) {
347
+ console.log("Tracking elections...\n");
348
+ }
349
+ else {
350
+ console.log("Discovering proposals and operations...\n");
351
+ }
288
352
  let electionsSkipped = 0;
289
353
  // Only use startBlock on the first cycle; subsequent cycles resume from watermarks
290
354
  const cycleStartBlock = isFirstCycle ? startBlock : undefined;
291
355
  isFirstCycle = false;
292
- const { result, proposals, timelockOps } = await (0, cli_1.runMonitorCycle)(tracker, providers, {
356
+ const { result, proposals, timelockOps, elections } = await (0, cli_1.runMonitorCycle)(tracker, providers, {
293
357
  prepare: opts.prepare || opts.write || opts.prepareCompleted || opts.preparePending,
294
358
  prepareCompleted: opts.prepareCompleted,
295
359
  preparePending: opts.preparePending,
@@ -297,6 +361,9 @@ runCmd
297
361
  blockLag,
298
362
  maxAgeDays,
299
363
  concurrency,
364
+ targets: discoveryTargets,
365
+ electionsOnly,
366
+ forceElections: opts.force,
300
367
  onTrack: async (r) => {
301
368
  // Skip showing complete elections
302
369
  if (r.result?.isElection && r.result?.isComplete) {
@@ -305,7 +372,7 @@ runCmd
305
372
  }
306
373
  if (r.result) {
307
374
  console.log(`\n[${r.key}]`);
308
- console.log((0, cli_1.formatTrackingResult)(r.result));
375
+ (0, cli_1.displayTrackingResult)(r.result);
309
376
  }
310
377
  else if (r.error) {
311
378
  console.log(`\n[${r.key}] ERROR: ${r.error}`);
@@ -337,14 +404,36 @@ runCmd
337
404
  // Skip output if shutting down
338
405
  if ((0, cli_1.isShuttingDown)())
339
406
  return;
340
- const stats = await tracker.getStats();
341
- console.log(`\nFound ${proposals.length} new proposals, ${timelockOps.length} new ops | ` +
342
- `Incomplete: ${stats.proposals.active} proposals, ${stats.timelocks.active} timelocks | ` +
343
- `Tracked: ${result.tracked}, Prepared: ${result.prepared}` +
344
- (electionsSkipped > 0 ? ` (${electionsSkipped} elections skipped)` : ""));
407
+ // Get checkpoints and calculate filtered stats based on enabled targets
408
+ const checkpoints = await tracker.getAllCheckpoints();
409
+ const stats = (0, cli_1.calculateFilteredStats)(checkpoints, discoveryTargets);
410
+ // Build summary based on what was tracked this run
411
+ if (electionsOnly) {
412
+ // Elections-only mode: count from tracked elections, not cache
413
+ const electionComplete = elections.filter((e) => e.phase === "COMPLETED").length;
414
+ console.log(`\nTracked ${elections.length} elections (${electionComplete}/${elections.length} complete)`);
415
+ }
416
+ else {
417
+ // Discovery mode: show stats for tracked types only
418
+ const electionSummary = trackingElections && elections.length > 0
419
+ ? `, ${elections.length} elections (${stats.elections.complete}/${stats.elections.total} complete)`
420
+ : "";
421
+ // Build incomplete stats for tracked types
422
+ const incompleteParts = [];
423
+ if (trackingProposals && stats.proposals.active > 0) {
424
+ incompleteParts.push(`${stats.proposals.active} proposals`);
425
+ }
426
+ if (trackingTimelocks && stats.timelocks.active > 0) {
427
+ incompleteParts.push(`${stats.timelocks.active} timelocks`);
428
+ }
429
+ const incompleteSummary = incompleteParts.length > 0 ? ` | Incomplete: ${incompleteParts.join(", ")}` : "";
430
+ console.log(`\nFound ${proposals.length} new proposals, ${timelockOps.length} new ops${electionSummary}${incompleteSummary} | ` +
431
+ `Tracked: ${result.tracked}, Prepared: ${result.prepared}` +
432
+ (electionsSkipped > 0 ? ` (${electionsSkipped} elections skipped)` : ""));
433
+ }
345
434
  if (opts.jsonOutput) {
346
- const checkpoints = await tracker.getAllCheckpoints();
347
- (0, json_state_1.writeDashboardState)((0, json_state_1.buildDashboardState)(checkpoints), opts.jsonOutput);
435
+ const filteredCheckpoints = (0, cli_1.filterCheckpointsByTargets)(checkpoints, discoveryTargets);
436
+ (0, json_state_1.writeDashboardState)((0, json_state_1.buildDashboardState)(filteredCheckpoints), opts.jsonOutput);
348
437
  if (opts.verbose)
349
438
  console.log(`JSON state written to ${opts.jsonOutput}`);
350
439
  }
@@ -377,6 +466,8 @@ runCmd
377
466
  intervalMs,
378
467
  healthCheckUrl: opts.healthCheckUrl,
379
468
  });
469
+ // Flush cache at end (single write instead of per-item)
470
+ await cache?.flush();
380
471
  });
381
472
  // ============================================================================
382
473
  // Track Command
@@ -394,11 +485,13 @@ trackCmd
394
485
  .addOption(cli_1.cacheOptions.force)
395
486
  .addOption(cli_1.cacheOptions.noCache)
396
487
  .addOption(cli_1.verboseOption)
488
+ .option("-i, --inspect", "Decode and inspect calldata (with tracking)")
397
489
  .option("--inspect-only", "Decode and inspect calldata without tracking")
398
490
  .option("--show-simulation", "Show simulation data for each call")
399
491
  .action(async (txHash, opts) => {
400
492
  if (opts.verbose)
401
493
  debug_1.default.enable("gov-tracker:*");
494
+ (0, cli_1.validateCliOptions)(opts, "track");
402
495
  (0, cli_1.requirePrivateKeyForWrite)(opts);
403
496
  try {
404
497
  const providers = (0, cli_1.createProvidersFromOptions)(opts);
@@ -412,14 +505,19 @@ trackCmd
412
505
  if (opts.force)
413
506
  console.log(`Force: ignoring cached data`);
414
507
  }
415
- // Use cache unless --force or --no-cache is specified
416
- const cachePath = opts.noCache ? undefined : opts.force ? undefined : opts.cache;
508
+ // Use cache unless --no-cache is specified
509
+ // --force clears the cache entry before tracking but still writes results
510
+ const cachePath = opts.noCache ? undefined : opts.cache;
417
511
  const tracker = (0, index_1.createTracker)({
418
512
  ...providers,
419
513
  cachePath,
420
514
  chunkingConfig,
421
515
  onProgress: opts.verbose ? createProgressCallback() : undefined,
422
516
  });
517
+ // Clear all cache entries for this tx if --force to ensure fresh tracking
518
+ if (opts.force && cachePath) {
519
+ await tracker.clearTxCacheEntries(txHash);
520
+ }
423
521
  let calldatas = [];
424
522
  let targets = [];
425
523
  let values = [];
@@ -447,38 +545,41 @@ trackCmd
447
545
  // Normal tracking flow
448
546
  console.log(`Tracking from tx: ${txHash}\n`);
449
547
  const shouldPrepare = opts.prepare || opts.write || opts.prepareCompleted || opts.preparePending;
450
- const { results, preparations, preparedTransactions } = !opts.inspectOnly
451
- ? await (0, cli_1.trackAndPrepare)(tracker, txHash, {
452
- prepare: shouldPrepare,
453
- prepareCompleted: opts.prepareCompleted,
454
- preparePending: opts.preparePending,
455
- }, providers)
456
- : { results: [], preparations: [], preparedTransactions: [] };
548
+ const { results, preparations, preparedTransactions } = await (0, cli_1.trackAndPrepare)(tracker, txHash, {
549
+ prepare: shouldPrepare,
550
+ prepareCompleted: opts.prepareCompleted,
551
+ preparePending: opts.preparePending,
552
+ }, providers);
553
+ if (results.length === 0) {
554
+ console.error("No proposal or timelock operation found in transaction");
555
+ process.exit(1);
556
+ }
457
557
  // Format tracking output
458
- if (!opts.inspectOnly) {
459
- results.forEach((r, i) => {
460
- const label = results.length > 1 ? `Operation ${i + 1}/${results.length}` : undefined;
461
- console.log((0, cli_1.formatTrackingResult)(r, label));
462
- });
463
- // Show all prepared transactions
464
- if (preparedTransactions.length > 0) {
465
- console.log(`\n${(0, cli_1.formatMultiplePreparedTransactions)(preparedTransactions)}`);
466
- }
467
- // Show preparation errors
468
- const failedPreparations = preparations.filter((p) => !p.success);
469
- failedPreparations.forEach((prep) => {
470
- console.log(`\n[PREPARE ERROR] ${prep.error}`);
471
- });
558
+ for (let i = 0; i < results.length; i++) {
559
+ const r = results[i];
560
+ const label = results.length > 1 ? `Operation ${i + 1}/${results.length}` : undefined;
561
+ (0, cli_1.displayTrackingResult)(r, label);
472
562
  }
473
- // Extract calldata for decoding
474
- if (results.length > 0 && results[0].stages.length > 0) {
475
- const { calldatas: extractedCalldatas, targets: extractedTargets, values: extractedValues, } = (0, calldata_1.extractCalldataFromStage)(results[0].stages[0]);
476
- calldatas = extractedCalldatas;
477
- targets = extractedTargets;
478
- values = extractedValues;
563
+ // Show all prepared transactions
564
+ if (preparedTransactions.length > 0) {
565
+ console.log(`\n${(0, cli_1.formatMultiplePreparedTransactions)(preparedTransactions)}`);
566
+ }
567
+ // Show preparation errors
568
+ const failedPreparations = preparations.filter((p) => !p.success);
569
+ failedPreparations.forEach((prep) => {
570
+ console.log(`\n[PREPARE ERROR] ${prep.error}`);
571
+ });
572
+ // Extract calldata for decoding (if --inspect or --show-simulation)
573
+ if (opts.inspect || opts.showSimulation) {
574
+ if (results.length > 0 && results[0].stages.length > 0) {
575
+ const { calldatas: extractedCalldatas, targets: extractedTargets, values: extractedValues, } = (0, calldata_1.extractCalldataFromStage)(results[0].stages[0]);
576
+ calldatas = extractedCalldatas;
577
+ targets = extractedTargets;
578
+ values = extractedValues;
579
+ }
479
580
  }
480
581
  // Execute if --write (only when not in inspect-only mode)
481
- if (opts.write && preparedTransactions.length > 0 && !opts.inspectOnly) {
582
+ if (opts.write && preparedTransactions.length > 0) {
482
583
  const signer = (0, cli_1.createSigner)(opts.privateKey);
483
584
  console.log(`\n=== Executing with ${signer.address} ===`);
484
585
  let currentPreparedTxs = preparedTransactions;
@@ -500,12 +601,13 @@ trackCmd
500
601
  break;
501
602
  console.log(`\nRe-tracking to find next stages...`);
502
603
  const retracked = await (0, cli_1.trackAndPrepare)(tracker, txHash, { prepare: true }, providers);
503
- retracked.results.forEach((r, i) => {
604
+ for (let i = 0; i < retracked.results.length; i++) {
605
+ const r = retracked.results[i];
504
606
  const label = retracked.results.length > 1
505
607
  ? `Operation ${i + 1}/${retracked.results.length}`
506
608
  : undefined;
507
- console.log((0, cli_1.formatTrackingResult)(r, label));
508
- });
609
+ (0, cli_1.displayTrackingResult)(r, label);
610
+ }
509
611
  if (retracked.preparedTransactions.length > 0) {
510
612
  console.log(`\n${(0, cli_1.formatMultiplePreparedTransactions)(retracked.preparedTransactions)}`);
511
613
  }
@@ -518,7 +620,7 @@ trackCmd
518
620
  }
519
621
  }
520
622
  // Decode and display calldata if requested
521
- if (opts.showSimulation || opts.inspectOnly) {
623
+ if (opts.showSimulation || opts.inspectOnly || opts.inspect) {
522
624
  if (calldatas.length === 0) {
523
625
  console.error("No calldata available for decoding");
524
626
  process.exit(1);
@@ -561,16 +663,19 @@ program
561
663
  .addOption(cli_1.cacheOptions.cache(DEFAULT_CACHE_PATH))
562
664
  .option("--json", "Output as JSON")
563
665
  .action(async (opts) => {
564
- const { watermarks, checkpoints } = await index_1.ProposalStageTracker.readCacheStatus(opts.cache);
666
+ const { watermarks, checkpoints, elections } = await index_1.ProposalStageTracker.readCacheStatus(opts.cache);
565
667
  if (opts.json) {
566
668
  const checkpointsObj = {};
567
669
  for (const [key, checkpoint] of checkpoints) {
568
670
  checkpointsObj[key] = checkpoint;
569
671
  }
672
+ for (const [index, checkpoint] of elections) {
673
+ checkpointsObj[`election:${index}`] = checkpoint;
674
+ }
570
675
  console.log(JSON.stringify({ watermarks, checkpoints: checkpointsObj }, null, 2));
571
676
  }
572
677
  else {
573
- console.log((0, cli_1.formatCacheStatus)(checkpoints));
678
+ console.log((0, cli_1.formatCacheStatus)(checkpoints, elections));
574
679
  }
575
680
  });
576
681
  // ============================================================================
@@ -578,19 +683,181 @@ program
578
683
  // ============================================================================
579
684
  const electionCmd = program
580
685
  .command("election")
581
- .description("Check Security Council election status");
686
+ .description("Check Security Council election status and track elections");
582
687
  (0, cli_1.addOptions)(electionCmd, cli_1.rpcOptions);
583
688
  (0, cli_1.addOptions)(electionCmd, cli_1.loopOptions);
689
+ (0, cli_1.addOptions)(electionCmd, cli_1.executionOptions);
584
690
  electionCmd
691
+ .addOption(cli_1.cacheOptions.cache(DEFAULT_CACHE_PATH))
692
+ .addOption(cli_1.cacheOptions.noCache)
693
+ .addOption(cli_1.cacheOptions.force)
585
694
  .addOption(cli_1.verboseOption)
586
- .option("--write", "Create election if ready (requires --private-key)")
587
- .addOption(new commander_1.Option("--private-key <key>", "Private key for execution").env("PRIVATE_KEY"))
695
+ .option("--list", "List all elections with their statuses")
696
+ .option("--track <index>", "Track a specific election by index")
697
+ .option("--details", "Show detailed nominee/member info (use with --track)")
588
698
  .action(async (opts) => {
589
699
  if (opts.verbose)
590
700
  debug_1.default.enable("gov-tracker:*");
591
701
  (0, cli_1.requirePrivateKeyForWrite)(opts);
592
702
  const providers = (0, cli_1.createProvidersFromOptions)(opts);
593
703
  const signer = opts.write ? (0, cli_1.createSigner)(opts.privateKey) : null;
704
+ // Create tracker with cache (unless --no-cache)
705
+ const cachePath = opts.noCache ? undefined : opts.cache;
706
+ const tracker = (0, index_1.createTracker)({
707
+ ...providers,
708
+ cachePath,
709
+ });
710
+ // Import election tracking functions for detailed queries
711
+ const { getNomineeElectionDetails, getMemberElectionDetails, prepareMemberElectionTrigger, prepareMemberElectionExecution, } = await Promise.resolve().then(() => __importStar(require("../index")));
712
+ // --list: Show all elections (uses cached data for completed elections)
713
+ if (opts.list) {
714
+ console.log("Fetching all elections...\n");
715
+ // Use --force to bypass cache and re-track all elections
716
+ const elections = await tracker.trackAllElections({ force: opts.force });
717
+ if (elections.length === 0) {
718
+ console.log("No elections found.");
719
+ return;
720
+ }
721
+ console.log(`=== Security Council Elections (${elections.length} total) ===\n`);
722
+ for (const election of elections) {
723
+ const cohortName = election.cohort === 0 ? "First" : "Second";
724
+ console.log(`Election #${election.electionIndex}`);
725
+ console.log(` Phase: ${election.phase}`);
726
+ console.log(` Cohort: ${cohortName} (${election.cohort})`);
727
+ console.log(` Compliant Nominees: ${election.compliantNomineeCount}/${election.targetNomineeCount}`);
728
+ if (election.nomineeProposalId) {
729
+ console.log(` Nominee Proposal: ${election.nomineeProposalState}`);
730
+ }
731
+ if (election.memberProposalId) {
732
+ console.log(` Member Proposal: ${election.memberProposalState}`);
733
+ }
734
+ if (election.canProceedToMemberPhase) {
735
+ console.log(` → Ready to trigger member election`);
736
+ }
737
+ if (election.canExecuteMember) {
738
+ console.log(` → Ready to execute member election`);
739
+ }
740
+ console.log("");
741
+ }
742
+ return;
743
+ }
744
+ // --track <index>: Track specific election (uses cache unless --force)
745
+ if (opts.track !== undefined) {
746
+ const electionIndex = parseInt(opts.track, 10);
747
+ console.log(`Tracking election #${electionIndex}...\n`);
748
+ const election = await tracker.trackElection(electionIndex, { force: opts.force });
749
+ // Use shared formatter for consistent output with stages
750
+ console.log((0, cli_1.formatElectionResult)(election));
751
+ // Show detailed info if requested
752
+ if (opts.details) {
753
+ console.log(`\n--- Detailed Information ---`);
754
+ if (election.nomineeProposalId) {
755
+ const nomineeDetails = await getNomineeElectionDetails(electionIndex, providers.l2Provider);
756
+ if (nomineeDetails) {
757
+ console.log(`\nNominee Election Details:`);
758
+ console.log(` Contenders: ${nomineeDetails.contenders.length}`);
759
+ console.log(` Total Nominees: ${nomineeDetails.nominees.length}`);
760
+ console.log(` Compliant: ${nomineeDetails.compliantNominees.length}`);
761
+ console.log(` Excluded: ${nomineeDetails.excludedNominees.length}`);
762
+ console.log(` Quorum Threshold: ${nomineeDetails.quorumThreshold.toString()} votes`);
763
+ if (nomineeDetails.contenders.length > 0) {
764
+ console.log(`\n Registered Contenders (${nomineeDetails.contenders.length}):`);
765
+ for (const contender of nomineeDetails.contenders) {
766
+ const extra = opts.verbose ? ` (block ${contender.registeredAtBlock})` : "";
767
+ console.log(` ${contender.address}${extra}`);
768
+ }
769
+ }
770
+ if (nomineeDetails.compliantNominees.length > 0) {
771
+ console.log(`\n Qualified Nominees (${nomineeDetails.compliantNominees.length}):`);
772
+ for (const nominee of nomineeDetails.compliantNominees) {
773
+ const extra = opts.verbose && nominee.nominatedAtBlock
774
+ ? ` (block ${nominee.nominatedAtBlock})`
775
+ : "";
776
+ console.log(` ${nominee.address}: ${nominee.votesReceived.toString()} votes${extra}`);
777
+ }
778
+ }
779
+ if (nomineeDetails.excludedNominees.length > 0) {
780
+ console.log(`\n Excluded Nominees (${nomineeDetails.excludedNominees.length}):`);
781
+ for (const nominee of nomineeDetails.excludedNominees) {
782
+ const extra = opts.verbose && nominee.excludedAtBlock
783
+ ? ` (block ${nominee.excludedAtBlock})`
784
+ : "";
785
+ console.log(` ${nominee.address}: excluded${extra}`);
786
+ }
787
+ }
788
+ }
789
+ }
790
+ if (election.memberProposalId) {
791
+ const memberDetails = await getMemberElectionDetails(electionIndex, providers.l2Provider);
792
+ if (memberDetails) {
793
+ console.log(`\nMember Election Details:`);
794
+ console.log(` Full Weight Deadline: block ${memberDetails.fullWeightDeadline}`);
795
+ console.log(` Proposal Deadline: block ${memberDetails.proposalDeadline}`);
796
+ if (memberDetails.nominees.length > 0) {
797
+ console.log(`\n Candidates by Weight (${memberDetails.nominees.length}):`);
798
+ for (const nominee of memberDetails.nominees) {
799
+ const winnerTag = nominee.isWinner ? " [WINNER]" : "";
800
+ console.log(` #${nominee.rank} ${nominee.address}: ${nominee.weightReceived.toString()}${winnerTag}`);
801
+ }
802
+ }
803
+ if (memberDetails.winners.length > 0) {
804
+ console.log(`\n Elected Members (${memberDetails.winners.length}):`);
805
+ for (const winner of memberDetails.winners) {
806
+ console.log(` ${winner}`);
807
+ }
808
+ }
809
+ }
810
+ }
811
+ }
812
+ function getActionStatus(isReady, isPending, isCompleted) {
813
+ if (isReady)
814
+ return "READY";
815
+ if (isCompleted)
816
+ return "COMPLETED";
817
+ if (isPending)
818
+ return "PENDING";
819
+ return "PENDING";
820
+ }
821
+ // Should we show/prepare this action based on flags?
822
+ function shouldShowAction(status) {
823
+ // Always show READY actions
824
+ if (status === "READY")
825
+ return true;
826
+ // Otherwise, only if --prepare* flags match the status
827
+ if (opts.preparePending && status === "PENDING")
828
+ return true;
829
+ if (opts.prepareCompleted && status === "COMPLETED")
830
+ return true;
831
+ return false;
832
+ }
833
+ // Helper to prepare and optionally execute an election action
834
+ async function handleElectionAction(actionName, prepareFunc, status) {
835
+ if (!shouldShowAction(status))
836
+ return;
837
+ console.log(`\n[ACTION] ${actionName} (${status})`);
838
+ const prepared = await prepareFunc();
839
+ if (!prepared)
840
+ return;
841
+ console.log((0, cli_1.formatDryRun)(prepared));
842
+ if (signer && opts.write && status === "READY") {
843
+ const execResult = await (0, cli_1.executeTransaction)(prepared, signer, providers);
844
+ if (execResult.success) {
845
+ console.log(`\n[EXECUTED] ${actionName} succeeded! Tx: ${execResult.txHash}`);
846
+ }
847
+ else {
848
+ console.error(`\n[ERROR] Execution failed: ${execResult.error}`);
849
+ }
850
+ }
851
+ }
852
+ // Trigger member election
853
+ const triggerStatus = getActionStatus(election.canProceedToMemberPhase, election.phase === "VETTING_PERIOD" && !election.canProceedToMemberPhase, election.memberProposalId !== null);
854
+ await handleElectionAction("Trigger member election", () => prepareMemberElectionTrigger(election, providers.l2Provider), triggerStatus);
855
+ // Execute member election
856
+ const executeStatus = getActionStatus(election.canExecuteMember, election.phase === "MEMBER_ELECTION" && !election.canExecuteMember, election.phase === "COMPLETED");
857
+ await handleElectionAction("Execute member election - install new council", () => prepareMemberElectionExecution(election, providers.l2Provider), executeStatus);
858
+ return;
859
+ }
860
+ // Default: Check election status (original behavior)
594
861
  async function checkElection() {
595
862
  try {
596
863
  const result = await (0, election_check_1.checkAndExecuteElection)(providers, signer, {
@@ -618,5 +885,37 @@ electionCmd
618
885
  healthCheckUrl: opts.healthCheckUrl,
619
886
  });
620
887
  });
888
+ // ============================================================================
889
+ // UI Command - Interactive TUI
890
+ // ============================================================================
891
+ program
892
+ .command("ui")
893
+ .description("Interactive TUI for browsing proposals (cache-only)")
894
+ .addOption(cli_1.cacheOptions.cache(DEFAULT_CACHE_PATH))
895
+ .addOption(cli_1.verboseOption)
896
+ .option("--log-file <path>", "Write debug logs to file (for debugging TUI)")
897
+ .option("--debug-namespaces <pattern>", "Debug namespaces to enable (default: gov-tracker:*)")
898
+ .action(async (opts) => {
899
+ try {
900
+ const { runTui } = await Promise.resolve().then(() => __importStar(require("./tui")));
901
+ const debugNamespaces = opts.debugNamespaces || "gov-tracker:*";
902
+ if (opts.logFile || opts.verbose) {
903
+ debug_1.default.enable(debugNamespaces);
904
+ }
905
+ await runTui({
906
+ cachePath: opts.cache,
907
+ verbose: opts.verbose,
908
+ logFile: opts.logFile,
909
+ });
910
+ }
911
+ catch (error) {
912
+ if (error.code === "MODULE_NOT_FOUND") {
913
+ console.error("Error: TUI requires 'ink' and 'react' packages.");
914
+ console.error("Install them with: yarn add ink react");
915
+ process.exit(1);
916
+ }
917
+ throw error;
918
+ }
919
+ });
621
920
  program.parse();
622
- //# sourceMappingURL=monitor.js.map
921
+ //# sourceMappingURL=cli.js.map