@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.
- package/README.md +129 -72
- package/dist/abis.d.ts +3 -0
- package/dist/abis.d.ts.map +1 -1
- package/dist/abis.js +30 -2
- package/dist/abis.js.map +1 -1
- package/dist/calldata/index.d.ts +1 -1
- package/dist/calldata/index.d.ts.map +1 -1
- package/dist/calldata/index.js.map +1 -1
- package/dist/calldata/parameter-decoder.d.ts.map +1 -1
- package/dist/calldata/parameter-decoder.js +8 -1
- package/dist/calldata/parameter-decoder.js.map +1 -1
- package/dist/calldata/signature-lookup.d.ts +17 -2
- package/dist/calldata/signature-lookup.d.ts.map +1 -1
- package/dist/calldata/signature-lookup.js +20 -2
- package/dist/calldata/signature-lookup.js.map +1 -1
- package/dist/cli/cli.d.ts +21 -0
- package/dist/cli/cli.d.ts.map +1 -0
- package/dist/cli/{monitor.js → cli.js} +372 -73
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/lib/cli.d.ts +54 -3
- package/dist/cli/lib/cli.d.ts.map +1 -1
- package/dist/cli/lib/cli.js +387 -78
- package/dist/cli/lib/cli.js.map +1 -1
- package/dist/cli/lib/concurrency.d.ts +20 -0
- package/dist/cli/lib/concurrency.d.ts.map +1 -0
- package/dist/cli/lib/concurrency.js +32 -0
- package/dist/cli/lib/concurrency.js.map +1 -0
- package/dist/cli/lib/json-state.d.ts +23 -0
- package/dist/cli/lib/json-state.d.ts.map +1 -1
- package/dist/cli/lib/json-state.js +51 -4
- package/dist/cli/lib/json-state.js.map +1 -1
- package/dist/cli/tui/App.d.ts +11 -0
- package/dist/cli/tui/App.d.ts.map +1 -0
- package/dist/cli/tui/App.js +123 -0
- package/dist/cli/tui/App.js.map +1 -0
- package/dist/cli/tui/components/CopyableText.d.ts +23 -0
- package/dist/cli/tui/components/CopyableText.d.ts.map +1 -0
- package/dist/cli/tui/components/CopyableText.js +49 -0
- package/dist/cli/tui/components/CopyableText.js.map +1 -0
- package/dist/cli/tui/components/Header.d.ts +20 -0
- package/dist/cli/tui/components/Header.d.ts.map +1 -0
- package/dist/cli/tui/components/Header.js +47 -0
- package/dist/cli/tui/components/Header.js.map +1 -0
- package/dist/cli/tui/components/KeyHelp.d.ts +19 -0
- package/dist/cli/tui/components/KeyHelp.d.ts.map +1 -0
- package/dist/cli/tui/components/KeyHelp.js +60 -0
- package/dist/cli/tui/components/KeyHelp.js.map +1 -0
- package/dist/cli/tui/components/ProposalRow.d.ts +11 -0
- package/dist/cli/tui/components/ProposalRow.d.ts.map +1 -0
- package/dist/cli/tui/components/ProposalRow.js +92 -0
- package/dist/cli/tui/components/ProposalRow.js.map +1 -0
- package/dist/cli/tui/components/ScrollIndicator.d.ts +19 -0
- package/dist/cli/tui/components/ScrollIndicator.d.ts.map +1 -0
- package/dist/cli/tui/components/ScrollIndicator.js +50 -0
- package/dist/cli/tui/components/ScrollIndicator.js.map +1 -0
- package/dist/cli/tui/components/SearchBar.d.ts +12 -0
- package/dist/cli/tui/components/SearchBar.d.ts.map +1 -0
- package/dist/cli/tui/components/SearchBar.js +36 -0
- package/dist/cli/tui/components/SearchBar.js.map +1 -0
- package/dist/cli/tui/components/Spinner.d.ts +10 -0
- package/dist/cli/tui/components/Spinner.d.ts.map +1 -0
- package/dist/cli/tui/components/Spinner.js +24 -0
- package/dist/cli/tui/components/Spinner.js.map +1 -0
- package/dist/cli/tui/components/StageProgress.d.ts +12 -0
- package/dist/cli/tui/components/StageProgress.d.ts.map +1 -0
- package/dist/cli/tui/components/StageProgress.js +41 -0
- package/dist/cli/tui/components/StageProgress.js.map +1 -0
- package/dist/cli/tui/components/StageRow.d.ts +12 -0
- package/dist/cli/tui/components/StageRow.d.ts.map +1 -0
- package/dist/cli/tui/components/StageRow.js +80 -0
- package/dist/cli/tui/components/StageRow.js.map +1 -0
- package/dist/cli/tui/components/StatusBadge.d.ts +12 -0
- package/dist/cli/tui/components/StatusBadge.d.ts.map +1 -0
- package/dist/cli/tui/components/StatusBadge.js +27 -0
- package/dist/cli/tui/components/StatusBadge.js.map +1 -0
- package/dist/cli/tui/components/ViewLayout.d.ts +22 -0
- package/dist/cli/tui/components/ViewLayout.d.ts.map +1 -0
- package/dist/cli/tui/components/ViewLayout.js +24 -0
- package/dist/cli/tui/components/ViewLayout.js.map +1 -0
- package/dist/cli/tui/components/VotingStats.d.ts +11 -0
- package/dist/cli/tui/components/VotingStats.d.ts.map +1 -0
- package/dist/cli/tui/components/VotingStats.js +87 -0
- package/dist/cli/tui/components/VotingStats.js.map +1 -0
- package/dist/cli/tui/hooks/index.d.ts +11 -0
- package/dist/cli/tui/hooks/index.d.ts.map +1 -0
- package/dist/cli/tui/hooks/index.js +18 -0
- package/dist/cli/tui/hooks/index.js.map +1 -0
- package/dist/cli/tui/hooks/useCache.d.ts +12 -0
- package/dist/cli/tui/hooks/useCache.d.ts.map +1 -0
- package/dist/cli/tui/hooks/useCache.js +52 -0
- package/dist/cli/tui/hooks/useCache.js.map +1 -0
- package/dist/cli/tui/hooks/useElectionData.d.ts +22 -0
- package/dist/cli/tui/hooks/useElectionData.d.ts.map +1 -0
- package/dist/cli/tui/hooks/useElectionData.js +133 -0
- package/dist/cli/tui/hooks/useElectionData.js.map +1 -0
- package/dist/cli/tui/hooks/useNavigation.d.ts +39 -0
- package/dist/cli/tui/hooks/useNavigation.d.ts.map +1 -0
- package/dist/cli/tui/hooks/useNavigation.js +173 -0
- package/dist/cli/tui/hooks/useNavigation.js.map +1 -0
- package/dist/cli/tui/hooks/useProposals.d.ts +10 -0
- package/dist/cli/tui/hooks/useProposals.d.ts.map +1 -0
- package/dist/cli/tui/hooks/useProposals.js +201 -0
- package/dist/cli/tui/hooks/useProposals.js.map +1 -0
- package/dist/cli/tui/hooks/useScrollableInput.d.ts +14 -0
- package/dist/cli/tui/hooks/useScrollableInput.d.ts.map +1 -0
- package/dist/cli/tui/hooks/useScrollableInput.js +44 -0
- package/dist/cli/tui/hooks/useScrollableInput.js.map +1 -0
- package/dist/cli/tui/hooks/useStageCalldata.d.ts +17 -0
- package/dist/cli/tui/hooks/useStageCalldata.d.ts.map +1 -0
- package/dist/cli/tui/hooks/useStageCalldata.js +77 -0
- package/dist/cli/tui/hooks/useStageCalldata.js.map +1 -0
- package/dist/cli/tui/index.d.ts +13 -0
- package/dist/cli/tui/index.d.ts.map +1 -0
- package/dist/cli/tui/index.js +96 -0
- package/dist/cli/tui/index.js.map +1 -0
- package/dist/cli/tui/ink-wrapper.d.ts +43 -0
- package/dist/cli/tui/ink-wrapper.d.ts.map +1 -0
- package/dist/cli/tui/ink-wrapper.js +41 -0
- package/dist/cli/tui/ink-wrapper.js.map +1 -0
- package/dist/cli/tui/types.d.ts +38 -0
- package/dist/cli/tui/types.d.ts.map +1 -0
- package/dist/cli/tui/types.js +6 -0
- package/dist/cli/tui/types.js.map +1 -0
- package/dist/cli/tui/utils/calldata-formatter.d.ts +7 -0
- package/dist/cli/tui/utils/calldata-formatter.d.ts.map +1 -0
- package/dist/cli/tui/utils/calldata-formatter.js +14 -0
- package/dist/cli/tui/utils/calldata-formatter.js.map +1 -0
- package/dist/cli/tui/utils/clipboard.d.ts +7 -0
- package/dist/cli/tui/utils/clipboard.d.ts.map +1 -0
- package/dist/cli/tui/utils/clipboard.js +46 -0
- package/dist/cli/tui/utils/clipboard.js.map +1 -0
- package/dist/cli/tui/utils/index.d.ts +16 -0
- package/dist/cli/tui/utils/index.d.ts.map +1 -0
- package/dist/cli/tui/utils/index.js +52 -0
- package/dist/cli/tui/utils/index.js.map +1 -0
- package/dist/cli/tui/utils/markdown-parser.d.ts +11 -0
- package/dist/cli/tui/utils/markdown-parser.d.ts.map +1 -0
- package/dist/cli/tui/utils/markdown-parser.js +77 -0
- package/dist/cli/tui/utils/markdown-parser.js.map +1 -0
- package/dist/cli/tui/utils/navigation.d.ts +17 -0
- package/dist/cli/tui/utils/navigation.d.ts.map +1 -0
- package/dist/cli/tui/utils/navigation.js +75 -0
- package/dist/cli/tui/utils/navigation.js.map +1 -0
- package/dist/cli/tui/utils/proposal-detail-helpers.d.ts +9 -0
- package/dist/cli/tui/utils/proposal-detail-helpers.d.ts.map +1 -0
- package/dist/cli/tui/utils/proposal-detail-helpers.js +21 -0
- package/dist/cli/tui/utils/proposal-detail-helpers.js.map +1 -0
- package/dist/cli/tui/utils/shortcuts.d.ts +17 -0
- package/dist/cli/tui/utils/shortcuts.d.ts.map +1 -0
- package/dist/cli/tui/utils/shortcuts.js +100 -0
- package/dist/cli/tui/utils/shortcuts.js.map +1 -0
- package/dist/cli/tui/utils/stage-formatter.d.ts +7 -0
- package/dist/cli/tui/utils/stage-formatter.d.ts.map +1 -0
- package/dist/cli/tui/utils/stage-formatter.js +14 -0
- package/dist/cli/tui/utils/stage-formatter.js.map +1 -0
- package/dist/cli/tui/utils/stage-status.d.ts +10 -0
- package/dist/cli/tui/utils/stage-status.d.ts.map +1 -0
- package/dist/cli/tui/utils/stage-status.js +64 -0
- package/dist/cli/tui/utils/stage-status.js.map +1 -0
- package/dist/cli/tui/utils/terminal.d.ts +18 -0
- package/dist/cli/tui/utils/terminal.d.ts.map +1 -0
- package/dist/cli/tui/utils/terminal.js +26 -0
- package/dist/cli/tui/utils/terminal.js.map +1 -0
- package/dist/cli/tui/utils/text.d.ts +7 -0
- package/dist/cli/tui/utils/text.d.ts.map +1 -0
- package/dist/cli/tui/utils/text.js +12 -0
- package/dist/cli/tui/utils/text.js.map +1 -0
- package/dist/cli/tui/utils/time.d.ts +19 -0
- package/dist/cli/tui/utils/time.d.ts.map +1 -0
- package/dist/cli/tui/utils/time.js +43 -0
- package/dist/cli/tui/utils/time.js.map +1 -0
- package/dist/cli/tui/views/CalldataView.d.ts +12 -0
- package/dist/cli/tui/views/CalldataView.d.ts.map +1 -0
- package/dist/cli/tui/views/CalldataView.js +110 -0
- package/dist/cli/tui/views/CalldataView.js.map +1 -0
- package/dist/cli/tui/views/DescriptionView.d.ts +12 -0
- package/dist/cli/tui/views/DescriptionView.d.ts.map +1 -0
- package/dist/cli/tui/views/DescriptionView.js +75 -0
- package/dist/cli/tui/views/DescriptionView.js.map +1 -0
- package/dist/cli/tui/views/ElectionView.d.ts +11 -0
- package/dist/cli/tui/views/ElectionView.d.ts.map +1 -0
- package/dist/cli/tui/views/ElectionView.js +193 -0
- package/dist/cli/tui/views/ElectionView.js.map +1 -0
- package/dist/cli/tui/views/HelpView.d.ts +10 -0
- package/dist/cli/tui/views/HelpView.d.ts.map +1 -0
- package/dist/cli/tui/views/HelpView.js +75 -0
- package/dist/cli/tui/views/HelpView.js.map +1 -0
- package/dist/cli/tui/views/ProposalDetail.d.ts +12 -0
- package/dist/cli/tui/views/ProposalDetail.d.ts.map +1 -0
- package/dist/cli/tui/views/ProposalDetail.js +103 -0
- package/dist/cli/tui/views/ProposalDetail.js.map +1 -0
- package/dist/cli/tui/views/ProposalList.d.ts +15 -0
- package/dist/cli/tui/views/ProposalList.d.ts.map +1 -0
- package/dist/cli/tui/views/ProposalList.js +154 -0
- package/dist/cli/tui/views/ProposalList.js.map +1 -0
- package/dist/cli/tui/views/SimulationView.d.ts +12 -0
- package/dist/cli/tui/views/SimulationView.d.ts.map +1 -0
- package/dist/cli/tui/views/SimulationView.js +110 -0
- package/dist/cli/tui/views/SimulationView.js.map +1 -0
- package/dist/cli/tui/views/StageView.d.ts +12 -0
- package/dist/cli/tui/views/StageView.d.ts.map +1 -0
- package/dist/cli/tui/views/StageView.js +109 -0
- package/dist/cli/tui/views/StageView.js.map +1 -0
- package/dist/cli/tui/views/registry.d.ts +18 -0
- package/dist/cli/tui/views/registry.d.ts.map +1 -0
- package/dist/cli/tui/views/registry.js +34 -0
- package/dist/cli/tui/views/registry.js.map +1 -0
- package/dist/constants.d.ts +44 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +52 -1
- package/dist/constants.js.map +1 -1
- package/dist/data/bundled-cache.json +16408 -2561
- package/dist/deduplication.d.ts +132 -0
- package/dist/deduplication.d.ts.map +1 -0
- package/dist/deduplication.js +270 -0
- package/dist/deduplication.js.map +1 -0
- package/dist/discovery/governor-discovery.d.ts.map +1 -1
- package/dist/discovery/governor-discovery.js +52 -36
- package/dist/discovery/governor-discovery.js.map +1 -1
- package/dist/discovery/timelock-discovery.d.ts +15 -6
- package/dist/discovery/timelock-discovery.d.ts.map +1 -1
- package/dist/discovery/timelock-discovery.js +27 -11
- package/dist/discovery/timelock-discovery.js.map +1 -1
- package/dist/election/contracts.d.ts +8 -0
- package/dist/election/contracts.d.ts.map +1 -0
- package/dist/election/contracts.js +28 -0
- package/dist/election/contracts.js.map +1 -0
- package/dist/election/details.d.ts +15 -0
- package/dist/election/details.d.ts.map +1 -0
- package/dist/election/details.js +157 -0
- package/dist/election/details.js.map +1 -0
- package/dist/election/index.d.ts +11 -0
- package/dist/election/index.d.ts.map +1 -0
- package/dist/election/index.js +48 -0
- package/dist/election/index.js.map +1 -0
- package/dist/election/params.d.ts +13 -0
- package/dist/election/params.d.ts.map +1 -0
- package/dist/election/params.js +93 -0
- package/dist/election/params.js.map +1 -0
- package/dist/election/participants.d.ts +6 -0
- package/dist/election/participants.d.ts.map +1 -0
- package/dist/election/participants.js +104 -0
- package/dist/election/participants.js.map +1 -0
- package/dist/election/prepare.d.ts +10 -0
- package/dist/election/prepare.d.ts.map +1 -0
- package/dist/election/prepare.js +52 -0
- package/dist/election/prepare.js.map +1 -0
- package/dist/election/proposal-ids.d.ts +18 -0
- package/dist/election/proposal-ids.d.ts.map +1 -0
- package/dist/election/proposal-ids.js +77 -0
- package/dist/election/proposal-ids.js.map +1 -0
- package/dist/election/status.d.ts +15 -0
- package/dist/election/status.d.ts.map +1 -0
- package/dist/election/status.js +105 -0
- package/dist/election/status.js.map +1 -0
- package/dist/election/tracking.d.ts +28 -0
- package/dist/election/tracking.d.ts.map +1 -0
- package/dist/election/tracking.js +412 -0
- package/dist/election/tracking.js.map +1 -0
- package/dist/index.d.ts +32 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +101 -9
- package/dist/index.js.map +1 -1
- package/dist/stages/builder.d.ts +4 -0
- package/dist/stages/builder.d.ts.map +1 -1
- package/dist/stages/builder.js +7 -0
- package/dist/stages/builder.js.map +1 -1
- package/dist/stages/l2-to-l1-message.d.ts +8 -1
- package/dist/stages/l2-to-l1-message.d.ts.map +1 -1
- package/dist/stages/l2-to-l1-message.js +79 -13
- package/dist/stages/l2-to-l1-message.js.map +1 -1
- package/dist/stages/proposal-created.d.ts +1 -0
- package/dist/stages/proposal-created.d.ts.map +1 -1
- package/dist/stages/proposal-created.js +1 -0
- package/dist/stages/proposal-created.js.map +1 -1
- package/dist/stages/proposal-queued.d.ts +1 -0
- package/dist/stages/proposal-queued.d.ts.map +1 -1
- package/dist/stages/proposal-queued.js +3 -1
- package/dist/stages/proposal-queued.js.map +1 -1
- package/dist/stages/retryables.js +2 -2
- package/dist/stages/retryables.js.map +1 -1
- package/dist/stages/timelock.d.ts +3 -1
- package/dist/stages/timelock.d.ts.map +1 -1
- package/dist/stages/timelock.js +10 -4
- package/dist/stages/timelock.js.map +1 -1
- package/dist/stages/utils.d.ts +7 -8
- package/dist/stages/utils.d.ts.map +1 -1
- package/dist/stages/utils.js +40 -27
- package/dist/stages/utils.js.map +1 -1
- package/dist/stages/voting.d.ts.map +1 -1
- package/dist/stages/voting.js +5 -4
- package/dist/stages/voting.js.map +1 -1
- package/dist/tracker/cache.d.ts +10 -6
- package/dist/tracker/cache.d.ts.map +1 -1
- package/dist/tracker/cache.js +39 -15
- package/dist/tracker/cache.js.map +1 -1
- package/dist/tracker/checkpoint-helpers.d.ts +80 -0
- package/dist/tracker/checkpoint-helpers.d.ts.map +1 -0
- package/dist/tracker/checkpoint-helpers.js +200 -0
- package/dist/tracker/checkpoint-helpers.js.map +1 -0
- package/dist/tracker/discovery.d.ts +40 -9
- package/dist/tracker/discovery.d.ts.map +1 -1
- package/dist/tracker/discovery.js +152 -15
- package/dist/tracker/discovery.js.map +1 -1
- package/dist/tracker/pipeline.d.ts.map +1 -1
- package/dist/tracker/pipeline.js +26 -11
- package/dist/tracker/pipeline.js.map +1 -1
- package/dist/tracker/query.d.ts +1 -0
- package/dist/tracker/query.d.ts.map +1 -1
- package/dist/tracker/query.js +14 -61
- package/dist/tracker/query.js.map +1 -1
- package/dist/tracker/state.d.ts +0 -10
- package/dist/tracker/state.d.ts.map +1 -1
- package/dist/tracker/state.js +1 -28
- package/dist/tracker/state.js.map +1 -1
- package/dist/tracker.d.ts +100 -8
- package/dist/tracker.d.ts.map +1 -1
- package/dist/tracker.js +405 -42
- package/dist/tracker.js.map +1 -1
- package/dist/types/config.d.ts +49 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/core.d.ts +4 -2
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/election.d.ts +144 -1
- package/dist/types/election.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -3
- package/dist/types/index.js.map +1 -1
- package/dist/types/stages.d.ts +79 -1
- package/dist/types/stages.d.ts.map +1 -1
- package/dist/types/stages.js.map +1 -1
- package/dist/types/tracking.d.ts +34 -4
- package/dist/types/tracking.d.ts.map +1 -1
- package/dist/utils/block-cache.d.ts +50 -0
- package/dist/utils/block-cache.d.ts.map +1 -0
- package/dist/utils/block-cache.js +80 -0
- package/dist/utils/block-cache.js.map +1 -0
- package/dist/utils/formatters.d.ts +91 -0
- package/dist/utils/formatters.d.ts.map +1 -0
- package/dist/utils/formatters.js +327 -0
- package/dist/utils/formatters.js.map +1 -0
- package/dist/utils/multicall.d.ts +52 -0
- package/dist/utils/multicall.d.ts.map +1 -0
- package/dist/utils/multicall.js +75 -0
- package/dist/utils/multicall.js.map +1 -0
- package/dist/utils/rpc-utils.d.ts +7 -1
- package/dist/utils/rpc-utils.d.ts.map +1 -1
- package/dist/utils/rpc-utils.js +43 -29
- package/dist/utils/rpc-utils.js.map +1 -1
- package/dist/utils/salt-computation.d.ts.map +1 -1
- package/dist/utils/salt-computation.js +33 -7
- package/dist/utils/salt-computation.js.map +1 -1
- package/dist/utils/sanitize.d.ts +28 -0
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/dist/utils/sanitize.js +55 -0
- package/dist/utils/sanitize.js.map +1 -0
- package/dist/utils/stage-metadata.d.ts +0 -20
- package/dist/utils/stage-metadata.d.ts.map +1 -1
- package/dist/utils/stage-metadata.js +29 -44
- package/dist/utils/stage-metadata.js.map +1 -1
- package/dist/utils/timing.d.ts +23 -3
- package/dist/utils/timing.d.ts.map +1 -1
- package/dist/utils/timing.js +71 -7
- package/dist/utils/timing.js.map +1 -1
- package/package.json +29 -16
- package/dist/cli/monitor.d.ts +0 -3
- package/dist/cli/monitor.d.ts.map +0 -1
- package/dist/cli/monitor.js.map +0 -1
- package/dist/election.d.ts +0 -172
- package/dist/election.d.ts.map +0 -1
- package/dist/election.js +0 -467
- package/dist/election.js.map +0 -1
- package/dist/types/cross-chain.d.ts +0 -24
- package/dist/types/cross-chain.d.ts.map +0 -1
- package/dist/types/cross-chain.js +0 -6
- 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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
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
|
|
248
|
+
const program = new Command()
|
|
221
249
|
.name("gov-tracker")
|
|
222
|
-
.description(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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
|
|
347
|
-
(0, json_state_1.writeDashboardState)((0, json_state_1.buildDashboardState)(
|
|
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 --
|
|
416
|
-
|
|
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 } =
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
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
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
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
|
-
//
|
|
474
|
-
if (
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
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
|
|
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.
|
|
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
|
-
|
|
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("--
|
|
587
|
-
.
|
|
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=
|
|
921
|
+
//# sourceMappingURL=cli.js.map
|