@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.
- 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 +31 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +98 -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 +13 -0
- package/dist/utils/timing.d.ts.map +1 -1
- package/dist/utils/timing.js +37 -1
- 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
package/dist/types/tracking.d.ts
CHANGED
|
@@ -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 {
|
|
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 @@
|
|
|
1
|
-
{"version":3,"file":"tracking.d.ts","sourceRoot":"","sources":["../../src/types/tracking.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"tracking.d.ts","sourceRoot":"","sources":["../../src/types/tracking.ts"],"names":[],"mappings":"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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,0BAA0B;QAC1B,IAAI,OAAO,EAAE,SAAS,EAAE,CAAC;YACvB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,8DAA8D;QAC9D,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;QACxD,CAAC;QAED,oEAAoE;QACpE,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,GAAM,EAAE,KAAQ,EAAE,WAAoB;QACxC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,0DAA0D;YAC1D,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,KAAK,CAAC,CAAC;QACxD,CAAC;aAAM,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,2DAA2D;YAC3D,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;QAC3C,CAAC;QACD,6DAA6D;IAC/D,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,GAAM,EAAE,WAAoB;QAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,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,CAI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AAM,EAAE,CAEnE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAQrF;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,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
|