@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
@@ -3,9 +3,9 @@
3
3
  */
4
4
  import { Chain, ChainId, StageType } from "./core";
5
5
  import { TrackedStage } from "./stages";
6
- import { CallScheduledData } from "./timelock";
6
+ import { CallScheduledData, TimelockLink } from "./timelock";
7
7
  import { ProposalType, ProposalData, ProposalState } from "./governor";
8
- import { TimelockState, TimelockLink } from "./timelock";
8
+ import { ElectionProposalStatus, SerializableNomineeDetails, SerializableMemberDetails } from "./election";
9
9
  export interface PrepareOptions {
10
10
  salt?: string;
11
11
  predecessor?: string;
@@ -61,10 +61,17 @@ export interface DiscoveryTrackingInput {
61
61
  type: "discovery";
62
62
  id: "watermarks";
63
63
  }
64
+ /**
65
+ * Input for tracking a Security Council election
66
+ */
67
+ export interface ElectionTrackingInput {
68
+ type: "election";
69
+ electionIndex: number;
70
+ }
64
71
  /**
65
72
  * Union type for all tracking entry points
66
73
  */
67
- export type TrackingInput = GovernorTrackingInput | TimelockTrackingInput | DiscoveryTrackingInput;
74
+ export type TrackingInput = GovernorTrackingInput | TimelockTrackingInput | DiscoveryTrackingInput | ElectionTrackingInput;
68
75
  /**
69
76
  * Hints for the next stage in the pipeline
70
77
  */
@@ -90,6 +97,8 @@ export interface StageTrackResult {
90
97
  export type DiscoveryKey = "constitutionalGovernor" | "nonConstitutionalGovernor" | "electionNomineeGovernor" | "electionMemberGovernor" | "l2ConstitutionalTimelock" | "l2NonConstitutionalTimelock";
91
98
  /** Discovery watermarks for incremental block scanning */
92
99
  export type DiscoveryWatermarks = Partial<Record<DiscoveryKey, number>>;
100
+ /** Block hashes for watermark reorg detection */
101
+ export type WatermarkHashes = Partial<Record<DiscoveryKey, string>>;
93
102
  /** Discovery targets configuration */
94
103
  export type DiscoveryTargets = Partial<Record<DiscoveryKey, boolean>>;
95
104
  /**
@@ -108,10 +117,30 @@ export interface TrackingCheckpoint {
108
117
  cachedData: {
109
118
  completedStages?: TrackedStage[];
110
119
  discoveryWatermarks?: DiscoveryWatermarks;
120
+ /** Block hashes for reorg detection */
121
+ watermarkHashes?: WatermarkHashes;
122
+ /** Election status for election checkpoints */
123
+ electionStatus?: ElectionProposalStatus;
124
+ /** Nominee election details for completed elections */
125
+ nomineeDetails?: SerializableNomineeDetails;
126
+ /** Member election details for completed elections */
127
+ memberDetails?: SerializableMemberDetails;
111
128
  };
112
129
  metadata?: {
113
130
  errorCount: number;
114
131
  lastTrackedAt: number;
132
+ /**
133
+ * Reference to the parent checkpoint that created this timelock operation.
134
+ * Used for deduplication when tracking results spawn child timelock operations.
135
+ *
136
+ * Examples:
137
+ * - Election executes → schedules to L2 timelock → sourceCheckpoint = "election:5"
138
+ * - Proposal queued → schedules to L2 timelock → sourceCheckpoint = "tx:0x..."
139
+ * - L2 timelock executed → schedules to L1 → child already tracked in stages, no need for separate key
140
+ *
141
+ * @see linkCheckpointToChild
142
+ */
143
+ sourceCheckpoint?: string;
115
144
  };
116
145
  }
117
146
  /**
@@ -146,9 +175,10 @@ export interface TrackingResult {
146
175
  isComplete: boolean;
147
176
  proposalType?: ProposalType;
148
177
  proposalData?: ProposalData;
149
- timelockState?: TimelockState;
150
178
  timelockLink?: TimelockLink;
151
179
  currentState?: ProposalState;
152
180
  isElection?: boolean;
181
+ /** Election status for election proposals - includes full lifecycle tracking */
182
+ electionStatus?: ElectionProposalStatus;
153
183
  }
154
184
  //# sourceMappingURL=tracking.d.ts.map
@@ -1 +1 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AC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,UAAU,EAAE,kBAAkB,CAAC;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gFAAgF;IAChF,cAAc,CAAC,EAAE,sBAAsB,CAAC;CACzC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Block-scoped cache for RPC results
3
+ *
4
+ * Caches results that are immutable at a specific block number.
5
+ * Does NOT cache results queried at "latest" (mutable).
6
+ */
7
+ export interface BlockCacheOptions<T> {
8
+ /** Optional predicate to determine if result should be cached even without blockNumber */
9
+ isImmutable?: (value: T) => boolean;
10
+ }
11
+ /**
12
+ * A cache that stores values scoped by block number.
13
+ * Only caches when blockNumber is provided (immutable historical state),
14
+ * OR when the value passes the isImmutable predicate.
15
+ */
16
+ export declare class BlockScopedCache<K, V> {
17
+ private cache;
18
+ private isImmutable?;
19
+ constructor(options?: BlockCacheOptions<V>);
20
+ private makeKey;
21
+ /**
22
+ * Get a cached value.
23
+ * @param key - The cache key
24
+ * @param blockNumber - If provided, looks up block-scoped entry. If not, looks up "latest" entry.
25
+ * @param options.skipCache - If true, always returns undefined (forces fresh fetch)
26
+ */
27
+ get(key: K, blockNumber?: number, options?: {
28
+ skipCache?: boolean;
29
+ }): V | undefined;
30
+ /**
31
+ * Set a cached value.
32
+ * @param key - The cache key
33
+ * @param value - The value to cache
34
+ * @param blockNumber - If provided, caches as immutable block-scoped entry
35
+ */
36
+ set(key: K, value: V, blockNumber?: number): void;
37
+ /**
38
+ * Check if a value exists in cache.
39
+ */
40
+ has(key: K, blockNumber?: number): boolean;
41
+ /**
42
+ * Clear all cached entries.
43
+ */
44
+ clear(): void;
45
+ /**
46
+ * Get the number of cached entries.
47
+ */
48
+ get size(): number;
49
+ }
50
+ //# sourceMappingURL=block-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-cache.d.ts","sourceRoot":"","sources":["../../src/utils/block-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,0FAA0F;IAC1F,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;CACrC;AAED;;;;GAIG;AACH,qBAAa,gBAAgB,CAAC,CAAC,EAAE,CAAC;IAChC,OAAO,CAAC,KAAK,CAAwB;IACrC,OAAO,CAAC,WAAW,CAAC,CAAwB;gBAEhC,OAAO,GAAE,iBAAiB,CAAC,CAAC,CAAM;IAI9C,OAAO,CAAC,OAAO;IAKf;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,CAAC,GAAG,SAAS;IAgBnF;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAWjD;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO;IAI1C;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ /**
3
+ * Block-scoped cache for RPC results
4
+ *
5
+ * Caches results that are immutable at a specific block number.
6
+ * Does NOT cache results queried at "latest" (mutable).
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.BlockScopedCache = void 0;
10
+ /**
11
+ * A cache that stores values scoped by block number.
12
+ * Only caches when blockNumber is provided (immutable historical state),
13
+ * OR when the value passes the isImmutable predicate.
14
+ */
15
+ class BlockScopedCache {
16
+ constructor(options = {}) {
17
+ this.cache = new Map();
18
+ this.isImmutable = options.isImmutable;
19
+ }
20
+ makeKey(key, blockNumber) {
21
+ const keyStr = typeof key === "string" ? key : JSON.stringify(key);
22
+ return blockNumber !== undefined ? `${keyStr}:${blockNumber}` : keyStr;
23
+ }
24
+ /**
25
+ * Get a cached value.
26
+ * @param key - The cache key
27
+ * @param blockNumber - If provided, looks up block-scoped entry. If not, looks up "latest" entry.
28
+ * @param options.skipCache - If true, always returns undefined (forces fresh fetch)
29
+ */
30
+ get(key, blockNumber, options) {
31
+ // Skip cache if requested
32
+ if (options?.skipCache) {
33
+ return undefined;
34
+ }
35
+ // When blockNumber is provided, only check block-scoped cache
36
+ if (blockNumber !== undefined) {
37
+ return this.cache.get(this.makeKey(key, blockNumber));
38
+ }
39
+ // When no blockNumber, check if we have an immutable "latest" entry
40
+ const latestKey = this.makeKey(key);
41
+ return this.cache.get(latestKey);
42
+ }
43
+ /**
44
+ * Set a cached value.
45
+ * @param key - The cache key
46
+ * @param value - The value to cache
47
+ * @param blockNumber - If provided, caches as immutable block-scoped entry
48
+ */
49
+ set(key, value, blockNumber) {
50
+ if (blockNumber !== undefined) {
51
+ // Block-scoped: always cache (immutable historical state)
52
+ this.cache.set(this.makeKey(key, blockNumber), value);
53
+ }
54
+ else if (this.isImmutable?.(value)) {
55
+ // No blockNumber but value is immutable: cache as "latest"
56
+ this.cache.set(this.makeKey(key), value);
57
+ }
58
+ // Otherwise: don't cache (mutable state queried at "latest")
59
+ }
60
+ /**
61
+ * Check if a value exists in cache.
62
+ */
63
+ has(key, blockNumber) {
64
+ return this.cache.has(this.makeKey(key, blockNumber));
65
+ }
66
+ /**
67
+ * Clear all cached entries.
68
+ */
69
+ clear() {
70
+ this.cache.clear();
71
+ }
72
+ /**
73
+ * Get the number of cached entries.
74
+ */
75
+ get size() {
76
+ return this.cache.size;
77
+ }
78
+ }
79
+ exports.BlockScopedCache = BlockScopedCache;
80
+ //# sourceMappingURL=block-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-cache.js","sourceRoot":"","sources":["../../src/utils/block-cache.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAOH;;;;GAIG;AACH,MAAa,gBAAgB;IAI3B,YAAY,UAAgC,EAAE;QAHtC,UAAK,GAAG,IAAI,GAAG,EAAa,CAAC;QAInC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACzC,CAAC;IAEO,OAAO,CAAC,GAAM,EAAE,WAAoB;QAC1C,MAAM,MAAM,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACnE,OAAO,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IACzE,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,GAAM,EAAE,WAAoB,EAAE,OAAiC;QACjE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CAAC;CACF;AAxED,4CAwEC"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Pure formatting utilities for display and logging
3
+ *
4
+ * These functions have no React/Ink dependencies and can be used
5
+ * by both the SDK and TUI.
6
+ */
7
+ import type { TrackedStage, TrackingInput, DecodedCalldata } from "../types/index.js";
8
+ import type { Chain } from "../types/index.js";
9
+ /**
10
+ * Wrap text to fit within a given width, breaking at character boundaries
11
+ */
12
+ export declare function wrapText(text: string, width: number): string[];
13
+ /**
14
+ * Truncate text with ellipsis if it exceeds maxLen
15
+ */
16
+ export declare function truncate(str: string, maxLen: number): string;
17
+ /**
18
+ * Safely stringify a value, returning a fallback for complex objects
19
+ */
20
+ export declare function safeStringify(value: unknown): string;
21
+ /**
22
+ * Format an unknown value for display
23
+ */
24
+ export declare function formatValue(value: unknown): string;
25
+ /**
26
+ * Format a Unix timestamp to locale string
27
+ */
28
+ export declare function formatDate(timestamp: number | null): string;
29
+ /**
30
+ * Chain to chain ID mapping
31
+ */
32
+ export declare const CHAIN_TO_CHAIN_ID: Record<Chain, number>;
33
+ /**
34
+ * A formatted stage data item
35
+ */
36
+ export interface StageDataItem {
37
+ label: string;
38
+ value: string;
39
+ }
40
+ /**
41
+ * Format stage data for display, prioritizing important fields
42
+ */
43
+ export declare function formatStageData(stage: TrackedStage): StageDataItem[];
44
+ /**
45
+ * Extract transaction hash from tracking input
46
+ */
47
+ export declare function getTxHash(input: TrackingInput): string;
48
+ /**
49
+ * Get display-friendly proposal or operation ID from tracking input
50
+ */
51
+ export declare function getProposalIdDisplay(input: TrackingInput): string;
52
+ /**
53
+ * A formatted line for calldata display
54
+ */
55
+ export interface FormattedLine {
56
+ text: string;
57
+ indent: number;
58
+ foldable: boolean;
59
+ foldKey?: string;
60
+ foldedLineCount?: number;
61
+ isFoldedContent?: boolean;
62
+ }
63
+ /**
64
+ * Format decoded calldata into displayable lines
65
+ */
66
+ export declare function formatDecodedCalldata(decoded: DecodedCalldata, indent?: number, keyPrefix?: string): FormattedLine[];
67
+ /**
68
+ * Filter lines based on expanded fold keys
69
+ */
70
+ export declare function filterVisibleLines(allLines: FormattedLine[], expandedKeys: Set<string>): FormattedLine[];
71
+ /**
72
+ * Get all foldable keys from lines
73
+ */
74
+ export declare function getAllFoldableKeys(lines: FormattedLine[]): string[];
75
+ /**
76
+ * Toggle a fold key in the expanded set
77
+ */
78
+ export declare function toggleFoldKey(expandedKeys: Set<string>, foldKey: string): Set<string>;
79
+ /**
80
+ * Format duration in seconds to human-readable string
81
+ *
82
+ * Displays the two most significant time units (e.g., "2d 3h" or "5m 30s").
83
+ * Returns "now" for zero or negative values.
84
+ *
85
+ * @example
86
+ * formatDuration(90061) // => "1d 1h"
87
+ * formatDuration(3661) // => "1h 1m"
88
+ * formatDuration(65) // => "1m 5s"
89
+ */
90
+ export declare function formatDuration(seconds: number): string;
91
+ //# sourceMappingURL=formatters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../src/utils/formatters.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAM/C;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAO9D;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAI5D;AAMD;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAMpD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAYlD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,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AM,CAgBtD"}
@@ -0,0 +1,327 @@
1
+ "use strict";
2
+ /**
3
+ * Pure formatting utilities for display and logging
4
+ *
5
+ * These functions have no React/Ink dependencies and can be used
6
+ * by both the SDK and TUI.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.CHAIN_TO_CHAIN_ID = void 0;
10
+ exports.wrapText = wrapText;
11
+ exports.truncate = truncate;
12
+ exports.safeStringify = safeStringify;
13
+ exports.formatValue = formatValue;
14
+ exports.formatDate = formatDate;
15
+ exports.formatStageData = formatStageData;
16
+ exports.getTxHash = getTxHash;
17
+ exports.getProposalIdDisplay = getProposalIdDisplay;
18
+ exports.formatDecodedCalldata = formatDecodedCalldata;
19
+ exports.filterVisibleLines = filterVisibleLines;
20
+ exports.getAllFoldableKeys = getAllFoldableKeys;
21
+ exports.toggleFoldKey = toggleFoldKey;
22
+ exports.formatDuration = formatDuration;
23
+ const constants_js_1 = require("../constants.js");
24
+ // ============================================================================
25
+ // Text Utilities
26
+ // ============================================================================
27
+ /**
28
+ * Wrap text to fit within a given width, breaking at character boundaries
29
+ */
30
+ function wrapText(text, width) {
31
+ if (text.length <= width)
32
+ return [text];
33
+ const lines = [];
34
+ for (let i = 0; i < text.length; i += width) {
35
+ lines.push(text.slice(i, i + width));
36
+ }
37
+ return lines;
38
+ }
39
+ /**
40
+ * Truncate text with ellipsis if it exceeds maxLen
41
+ */
42
+ function truncate(str, maxLen) {
43
+ if (maxLen <= 1)
44
+ return str.length > 0 ? "..." : "";
45
+ if (str.length <= maxLen)
46
+ return str;
47
+ return str.slice(0, maxLen - 1) + "...";
48
+ }
49
+ // ============================================================================
50
+ // Value Formatting
51
+ // ============================================================================
52
+ /**
53
+ * Safely stringify a value, returning a fallback for complex objects
54
+ */
55
+ function safeStringify(value) {
56
+ try {
57
+ return JSON.stringify(value);
58
+ }
59
+ catch {
60
+ return "[complex object]";
61
+ }
62
+ }
63
+ /**
64
+ * Format an unknown value for display
65
+ */
66
+ function formatValue(value) {
67
+ if (value === null || value === undefined)
68
+ return "N/A";
69
+ if (typeof value === "string")
70
+ return value;
71
+ if (typeof value === "number")
72
+ return value.toString();
73
+ if (typeof value === "boolean")
74
+ return value ? "Yes" : "No";
75
+ if (Array.isArray(value)) {
76
+ if (value.length === 0)
77
+ return "[]";
78
+ if (value.length <= 3)
79
+ return safeStringify(value);
80
+ return `[${value.length} items]`;
81
+ }
82
+ if (typeof value === "object")
83
+ return safeStringify(value);
84
+ return String(value);
85
+ }
86
+ /**
87
+ * Format a Unix timestamp to locale string
88
+ */
89
+ function formatDate(timestamp) {
90
+ if (timestamp === null)
91
+ return "Unknown";
92
+ return new Date(timestamp).toLocaleString();
93
+ }
94
+ // ============================================================================
95
+ // Stage Formatting
96
+ // ============================================================================
97
+ /**
98
+ * Chain to chain ID mapping
99
+ */
100
+ exports.CHAIN_TO_CHAIN_ID = {
101
+ ethereum: constants_js_1.CHAIN_IDS.ETHEREUM,
102
+ arb1: constants_js_1.CHAIN_IDS.ARB_ONE,
103
+ nova: constants_js_1.CHAIN_IDS.NOVA,
104
+ unknown: constants_js_1.CHAIN_IDS.ETHEREUM,
105
+ };
106
+ /**
107
+ * Priority fields shown first in stage data
108
+ */
109
+ const STAGE_PRIORITY_FIELDS = [
110
+ "proposalId",
111
+ "operationId",
112
+ "proposer",
113
+ "description",
114
+ "proposalState",
115
+ "forVotes",
116
+ "againstVotes",
117
+ "abstainVotes",
118
+ "quorum",
119
+ "quorumReached",
120
+ "timelockAddress",
121
+ "eta",
122
+ "state",
123
+ "messageCount",
124
+ "ticketCount",
125
+ "redeemedCount",
126
+ ];
127
+ /**
128
+ * Fields to skip in stage data display
129
+ */
130
+ const STAGE_SKIP_FIELDS = [
131
+ "targets",
132
+ "values",
133
+ "calldatas",
134
+ "signatures",
135
+ "callScheduledData",
136
+ "_rawBytesArray",
137
+ ];
138
+ /**
139
+ * Format stage data for display, prioritizing important fields
140
+ */
141
+ function formatStageData(stage) {
142
+ const items = [];
143
+ const data = stage.data;
144
+ if (!data)
145
+ return items;
146
+ for (const field of STAGE_PRIORITY_FIELDS) {
147
+ if (field in data && data[field] !== undefined) {
148
+ let value = formatValue(data[field]);
149
+ if (field === "description" && value.length > 100) {
150
+ value = value.slice(0, 100) + "...";
151
+ }
152
+ items.push({ label: field, value });
153
+ }
154
+ }
155
+ for (const [key, value] of Object.entries(data)) {
156
+ if (STAGE_PRIORITY_FIELDS.includes(key))
157
+ continue;
158
+ if (STAGE_SKIP_FIELDS.includes(key))
159
+ continue;
160
+ if (value === undefined || value === null)
161
+ continue;
162
+ let formattedValue = formatValue(value);
163
+ if (formattedValue.length > 80) {
164
+ formattedValue = formattedValue.slice(0, 80) + "...";
165
+ }
166
+ items.push({ label: key, value: formattedValue });
167
+ }
168
+ return items;
169
+ }
170
+ // ============================================================================
171
+ // Tracking Input Helpers
172
+ // ============================================================================
173
+ /**
174
+ * Extract transaction hash from tracking input
175
+ */
176
+ function getTxHash(input) {
177
+ switch (input.type) {
178
+ case "governor":
179
+ return input.creationTxHash;
180
+ case "timelock":
181
+ return input.scheduledTxHash;
182
+ case "discovery":
183
+ case "election":
184
+ return "";
185
+ }
186
+ }
187
+ /**
188
+ * Get display-friendly proposal or operation ID from tracking input
189
+ */
190
+ function getProposalIdDisplay(input) {
191
+ switch (input.type) {
192
+ case "governor":
193
+ return input.proposalId;
194
+ case "timelock":
195
+ return input.operationId;
196
+ case "discovery":
197
+ return input.id;
198
+ case "election":
199
+ return `election-${input.electionIndex}`;
200
+ }
201
+ }
202
+ const CALLDATA_FOLD_THRESHOLD = 100;
203
+ function formatCalldataParameter(param, indent, keyPrefix) {
204
+ const lines = [];
205
+ const foldKey = `${keyPrefix}-${param.name}`;
206
+ let value = param.displayValue;
207
+ if (param.addressLabel) {
208
+ value = `${param.displayValue} [${param.addressLabel}]`;
209
+ }
210
+ const isFoldable = value.length > CALLDATA_FOLD_THRESHOLD;
211
+ const wrappedLines = isFoldable ? wrapText(value, 80) : [value];
212
+ lines.push({
213
+ text: `${param.name} (${param.type}): ${wrappedLines[0]}`,
214
+ indent,
215
+ foldable: isFoldable,
216
+ foldKey: isFoldable ? foldKey : undefined,
217
+ foldedLineCount: isFoldable ? wrappedLines.length - 1 : undefined,
218
+ });
219
+ if (isFoldable && wrappedLines.length > 1) {
220
+ for (let i = 1; i < wrappedLines.length; i++) {
221
+ lines.push({
222
+ text: wrappedLines[i],
223
+ indent: indent + 1,
224
+ foldable: false,
225
+ isFoldedContent: true,
226
+ foldKey,
227
+ });
228
+ }
229
+ }
230
+ if (param.nested) {
231
+ lines.push({ text: "|- [NESTED]", indent: indent + 1, foldable: false });
232
+ lines.push(...formatDecodedCalldata(param.nested, indent + 2, `${foldKey}-nested`));
233
+ }
234
+ if (param.nestedArray && param.nestedArray.length > 0) {
235
+ param.nestedArray.forEach((nested, i) => {
236
+ lines.push({ text: `[${i}]:`, indent: indent + 1, foldable: false });
237
+ lines.push(...formatDecodedCalldata(nested, indent + 2, `${foldKey}-arr-${i}`));
238
+ });
239
+ }
240
+ return lines;
241
+ }
242
+ /**
243
+ * Format decoded calldata into displayable lines
244
+ */
245
+ function formatDecodedCalldata(decoded, indent = 0, keyPrefix = "root") {
246
+ const lines = [];
247
+ let header;
248
+ if (decoded.isRetryable) {
249
+ header = `Retryable Ticket -> ${decoded.targetChain}`;
250
+ }
251
+ else if (decoded.signature) {
252
+ header = decoded.signature;
253
+ }
254
+ else {
255
+ header = `Unknown function (${decoded.selector})`;
256
+ }
257
+ lines.push({ text: header, indent, foldable: false });
258
+ if (decoded.parameters) {
259
+ decoded.parameters.forEach((param, i) => {
260
+ lines.push(...formatCalldataParameter(param, indent + 1, `${keyPrefix}-p${i}`));
261
+ });
262
+ }
263
+ return lines;
264
+ }
265
+ /**
266
+ * Filter lines based on expanded fold keys
267
+ */
268
+ function filterVisibleLines(allLines, expandedKeys) {
269
+ return allLines.filter((line) => {
270
+ if (!line.isFoldedContent)
271
+ return true;
272
+ return line.foldKey && expandedKeys.has(line.foldKey);
273
+ });
274
+ }
275
+ /**
276
+ * Get all foldable keys from lines
277
+ */
278
+ function getAllFoldableKeys(lines) {
279
+ return lines.filter((l) => l.foldable && l.foldKey).map((l) => l.foldKey);
280
+ }
281
+ /**
282
+ * Toggle a fold key in the expanded set
283
+ */
284
+ function toggleFoldKey(expandedKeys, foldKey) {
285
+ const next = new Set(expandedKeys);
286
+ if (next.has(foldKey)) {
287
+ next.delete(foldKey);
288
+ }
289
+ else {
290
+ next.add(foldKey);
291
+ }
292
+ return next;
293
+ }
294
+ // ============================================================================
295
+ // Duration Formatting
296
+ // ============================================================================
297
+ /**
298
+ * Format duration in seconds to human-readable string
299
+ *
300
+ * Displays the two most significant time units (e.g., "2d 3h" or "5m 30s").
301
+ * Returns "now" for zero or negative values.
302
+ *
303
+ * @example
304
+ * formatDuration(90061) // => "1d 1h"
305
+ * formatDuration(3661) // => "1h 1m"
306
+ * formatDuration(65) // => "1m 5s"
307
+ */
308
+ function formatDuration(seconds) {
309
+ if (seconds <= 0)
310
+ return "now";
311
+ const totalSeconds = Math.floor(seconds);
312
+ const days = Math.floor(totalSeconds / 86400);
313
+ const hours = Math.floor((totalSeconds % 86400) / 3600);
314
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
315
+ const secs = totalSeconds % 60;
316
+ const parts = [];
317
+ if (days > 0)
318
+ parts.push(`${days}d`);
319
+ if (hours > 0 && parts.length < 2)
320
+ parts.push(`${hours}h`);
321
+ if (minutes > 0 && parts.length < 2)
322
+ parts.push(`${minutes}m`);
323
+ if (secs > 0 && parts.length < 2)
324
+ parts.push(`${secs}s`);
325
+ return parts.join(" ") || "0s";
326
+ }
327
+ //# sourceMappingURL=formatters.js.map