@gzeoneth/gov-tracker 0.2.1-alpha.cli-preview.375ef6c → 0.2.1-alpha.cli-preview.99d3341
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 +37 -3
- package/dist/abis.d.ts.map +1 -1
- package/dist/abis.js +22 -1
- package/dist/abis.js.map +1 -1
- package/dist/cli/cli.js +206 -12
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/lib/cli.d.ts +9 -1
- package/dist/cli/lib/cli.d.ts.map +1 -1
- package/dist/cli/lib/cli.js +80 -4
- package/dist/cli/lib/cli.js.map +1 -1
- package/dist/cli/tui/hooks/index.d.ts +4 -0
- package/dist/cli/tui/hooks/index.d.ts.map +1 -1
- package/dist/cli/tui/hooks/index.js +5 -1
- package/dist/cli/tui/hooks/index.js.map +1 -1
- package/dist/cli/tui/hooks/useElectionData.d.ts +14 -0
- package/dist/cli/tui/hooks/useElectionData.d.ts.map +1 -0
- package/dist/cli/tui/hooks/useElectionData.js +86 -0
- package/dist/cli/tui/hooks/useElectionData.js.map +1 -0
- package/dist/cli/tui/hooks/useElectionDetails.d.ts +18 -0
- package/dist/cli/tui/hooks/useElectionDetails.d.ts.map +1 -0
- package/dist/cli/tui/hooks/useElectionDetails.js +47 -0
- package/dist/cli/tui/hooks/useElectionDetails.js.map +1 -0
- package/dist/cli/tui/hooks/useNavigation.d.ts.map +1 -1
- package/dist/cli/tui/hooks/useNavigation.js +65 -119
- package/dist/cli/tui/hooks/useNavigation.js.map +1 -1
- package/dist/cli/tui/hooks/useProposals.d.ts.map +1 -1
- package/dist/cli/tui/hooks/useProposals.js +74 -80
- package/dist/cli/tui/hooks/useProposals.js.map +1 -1
- package/dist/cli/tui/hooks/useTracker.d.ts.map +1 -1
- package/dist/cli/tui/hooks/useTracker.js +36 -41
- package/dist/cli/tui/hooks/useTracker.js.map +1 -1
- package/dist/cli/tui/utils/calldata-formatter.d.ts +17 -0
- package/dist/cli/tui/utils/calldata-formatter.d.ts.map +1 -0
- package/dist/cli/tui/utils/calldata-formatter.js +91 -0
- package/dist/cli/tui/utils/calldata-formatter.js.map +1 -0
- package/dist/cli/tui/utils/help-data.d.ts +15 -0
- package/dist/cli/tui/utils/help-data.d.ts.map +1 -0
- package/dist/cli/tui/utils/help-data.js +88 -0
- package/dist/cli/tui/utils/help-data.js.map +1 -0
- package/dist/cli/tui/utils/index.d.ts +11 -0
- package/dist/cli/tui/utils/index.d.ts.map +1 -1
- package/dist/cli/tui/utils/index.js +24 -1
- package/dist/cli/tui/utils/index.js.map +1 -1
- 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 +100 -0
- package/dist/cli/tui/utils/markdown-parser.js.map +1 -0
- package/dist/cli/tui/utils/proposal-detail-helpers.d.ts +17 -0
- package/dist/cli/tui/utils/proposal-detail-helpers.d.ts.map +1 -0
- package/dist/cli/tui/utils/proposal-detail-helpers.js +46 -0
- package/dist/cli/tui/utils/proposal-detail-helpers.js.map +1 -0
- package/dist/cli/tui/utils/settings-data.d.ts +36 -0
- package/dist/cli/tui/utils/settings-data.d.ts.map +1 -0
- package/dist/cli/tui/utils/settings-data.js +220 -0
- package/dist/cli/tui/utils/settings-data.js.map +1 -0
- package/dist/cli/tui/utils/stage-formatter.d.ts +13 -0
- package/dist/cli/tui/utils/stage-formatter.d.ts.map +1 -0
- package/dist/cli/tui/utils/stage-formatter.js +100 -0
- package/dist/cli/tui/utils/stage-formatter.js.map +1 -0
- package/dist/cli/tui/views/CalldataView.d.ts.map +1 -1
- package/dist/cli/tui/views/CalldataView.js +50 -117
- package/dist/cli/tui/views/CalldataView.js.map +1 -1
- package/dist/cli/tui/views/DescriptionView.d.ts.map +1 -1
- package/dist/cli/tui/views/DescriptionView.js +1 -85
- package/dist/cli/tui/views/DescriptionView.js.map +1 -1
- package/dist/cli/tui/views/ElectionView.d.ts.map +1 -1
- package/dist/cli/tui/views/ElectionView.js +268 -165
- package/dist/cli/tui/views/ElectionView.js.map +1 -1
- package/dist/cli/tui/views/HelpView.d.ts.map +1 -1
- package/dist/cli/tui/views/HelpView.js +1 -73
- package/dist/cli/tui/views/HelpView.js.map +1 -1
- package/dist/cli/tui/views/ProposalDetail.d.ts.map +1 -1
- package/dist/cli/tui/views/ProposalDetail.js +51 -78
- package/dist/cli/tui/views/ProposalDetail.js.map +1 -1
- package/dist/cli/tui/views/ProposalList.d.ts.map +1 -1
- package/dist/cli/tui/views/ProposalList.js +73 -64
- package/dist/cli/tui/views/ProposalList.js.map +1 -1
- package/dist/cli/tui/views/SettingsView.d.ts.map +1 -1
- package/dist/cli/tui/views/SettingsView.js +67 -122
- package/dist/cli/tui/views/SettingsView.js.map +1 -1
- package/dist/cli/tui/views/SimulationView.d.ts.map +1 -1
- package/dist/cli/tui/views/SimulationView.js +23 -20
- package/dist/cli/tui/views/SimulationView.js.map +1 -1
- package/dist/cli/tui/views/StageView.d.ts.map +1 -1
- package/dist/cli/tui/views/StageView.js +28 -114
- package/dist/cli/tui/views/StageView.js.map +1 -1
- 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/election.d.ts +141 -1
- package/dist/election.d.ts.map +1 -1
- package/dist/election.js +505 -88
- package/dist/election.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -3
- 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/voting.d.ts.map +1 -1
- package/dist/stages/voting.js +5 -4
- package/dist/stages/voting.js.map +1 -1
- package/dist/tracker/discovery.d.ts +39 -8
- package/dist/tracker/discovery.d.ts.map +1 -1
- package/dist/tracker/discovery.js +141 -12
- package/dist/tracker/discovery.js.map +1 -1
- package/dist/tracker.d.ts +24 -4
- package/dist/tracker.d.ts.map +1 -1
- package/dist/tracker.js +57 -8
- package/dist/tracker.js.map +1 -1
- package/dist/types/core.d.ts +1 -1
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/election.d.ts +88 -0
- package/dist/types/election.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/stages.d.ts +6 -0
- package/dist/types/stages.d.ts.map +1 -1
- package/dist/types/stages.js.map +1 -1
- package/dist/types/tracking.d.ts +27 -1
- package/dist/types/tracking.d.ts.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 +35 -0
- package/dist/utils/timing.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,90 +19,6 @@ function getDescription(proposal) {
|
|
|
19
19
|
}
|
|
20
20
|
return "No description available";
|
|
21
21
|
}
|
|
22
|
-
function parseMarkdown(text, width) {
|
|
23
|
-
const result = [];
|
|
24
|
-
const lines = text.split("\n");
|
|
25
|
-
// Guard against very narrow terminals
|
|
26
|
-
const safeWidth = Math.max(20, width);
|
|
27
|
-
for (const rawLine of lines) {
|
|
28
|
-
const trimmed = rawLine.trim();
|
|
29
|
-
// Empty line
|
|
30
|
-
if (trimmed.length === 0) {
|
|
31
|
-
result.push({ text: "", type: "normal", indent: 0 });
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
// Horizontal rule
|
|
35
|
-
if (/^[-*_]{3,}$/.test(trimmed)) {
|
|
36
|
-
result.push({ text: "─".repeat(Math.min(safeWidth - 4, 60)), type: "separator", indent: 0 });
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
// Headers
|
|
40
|
-
if (trimmed.startsWith("### ")) {
|
|
41
|
-
result.push({ text: trimmed.slice(4), type: "h3", indent: 0 });
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
if (trimmed.startsWith("## ")) {
|
|
45
|
-
result.push({ text: trimmed.slice(3), type: "h2", indent: 0 });
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (trimmed.startsWith("# ")) {
|
|
49
|
-
result.push({ text: trimmed.slice(2), type: "h1", indent: 0 });
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
// Bullet points
|
|
53
|
-
if (/^[-*+] /.test(trimmed)) {
|
|
54
|
-
const bulletText = trimmed.slice(2);
|
|
55
|
-
wrapTextToLines(bulletText, safeWidth - 6, "bullet", 2, result);
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
// Numbered lists
|
|
59
|
-
if (/^\d+\. /.test(trimmed)) {
|
|
60
|
-
const match = trimmed.match(/^(\d+)\. /);
|
|
61
|
-
if (match) {
|
|
62
|
-
const numText = trimmed.slice(match[0].length);
|
|
63
|
-
const textWidth = safeWidth - 6;
|
|
64
|
-
result.push({ text: `${match[1]}. ${numText.slice(0, textWidth)}`, type: "bullet", indent: 0 });
|
|
65
|
-
if (numText.length > textWidth) {
|
|
66
|
-
wrapTextToLines(numText.slice(textWidth), textWidth, "normal", 3, result);
|
|
67
|
-
}
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// Code blocks (just show as-is with code styling)
|
|
72
|
-
if (trimmed.startsWith("```")) {
|
|
73
|
-
continue; // Skip code fence markers
|
|
74
|
-
}
|
|
75
|
-
// Links - simplify [text](url) to just text
|
|
76
|
-
const processedLine = trimmed.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1");
|
|
77
|
-
// Normal paragraph
|
|
78
|
-
wrapTextToLines(processedLine, safeWidth - 4, "normal", 0, result);
|
|
79
|
-
}
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
function wrapTextToLines(text, width, type, indent, result) {
|
|
83
|
-
const safeWidth = Math.max(10, width);
|
|
84
|
-
const words = text.split(/\s+/);
|
|
85
|
-
let currentLine = "";
|
|
86
|
-
for (const word of words) {
|
|
87
|
-
if (currentLine.length === 0) {
|
|
88
|
-
currentLine = word;
|
|
89
|
-
}
|
|
90
|
-
else if (currentLine.length + 1 + word.length <= safeWidth) {
|
|
91
|
-
currentLine += " " + word;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
result.push({ text: currentLine, type, indent });
|
|
95
|
-
currentLine = word;
|
|
96
|
-
// Continuation lines of bullets get extra indent
|
|
97
|
-
if (type === "bullet" && indent === 2) {
|
|
98
|
-
indent = 4;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (currentLine.length > 0) {
|
|
103
|
-
result.push({ text: currentLine, type, indent });
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
22
|
const RESERVED_LINES = 8;
|
|
107
23
|
function FormattedLineComponent({ line }) {
|
|
108
24
|
const indent = " ".repeat(line.indent);
|
|
@@ -139,7 +55,7 @@ function DescriptionView({ proposal, navigation, }) {
|
|
|
139
55
|
const { state } = navigation;
|
|
140
56
|
const description = getDescription(proposal);
|
|
141
57
|
const terminalWidth = process.stdout.columns || 80;
|
|
142
|
-
const lines = (0, ink_wrapper_js_1.useMemo)(() => parseMarkdown(description, terminalWidth - 4), [description, terminalWidth]);
|
|
58
|
+
const lines = (0, ink_wrapper_js_1.useMemo)(() => (0, index_js_1.parseMarkdown)(description, terminalWidth - 4), [description, terminalWidth]);
|
|
143
59
|
const visibleCount = (0, index_js_1.getVisibleRows)(RESERVED_LINES);
|
|
144
60
|
const visibleLines = lines.slice(state.scrollOffset, state.scrollOffset + visibleCount);
|
|
145
61
|
(0, ink_wrapper_js_1.useInput)((input, key) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DescriptionView.js","sourceRoot":"","sources":["../../../../src/cli/tui/views/DescriptionView.tsx"],"names":[],"mappings":";AAAA;;GAEG;;
|
|
1
|
+
{"version":3,"file":"DescriptionView.js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qCAAC,mCAAc,IACb,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,WAAW,EAAE,YAAY,EACzB,UAAU,EAAE,KAAK,CAAC,MAAM,GACxB,CACE,CACP;QACD,qCAAC,uCAAkB,IAAC,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,IAAI,EAAC,OAAO,GAAG;QACpE,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAC7B,qCAAC,sBAAsB,IAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,GAAI,CAC/C,CAAC;QACF,qCAAC,0CAAqB,IACpB,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,WAAW,EAAE,YAAY,EACzB,UAAU,EAAE,KAAK,CAAC,MAAM,EACxB,IAAI,EAAC,OAAO,GACZ,CACS,CACd,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElectionView.d.ts","sourceRoot":"","sources":["../../../../src/cli/tui/views/ElectionView.tsx"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"ElectionView.d.ts","sourceRoot":"","sources":["../../../../src/cli/tui/views/ElectionView.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAiBvD,UAAU,iBAAiB;IACzB,UAAU,EAAE,mBAAmB,CAAC;IAChC,SAAS,CAAC,EAAE,cAAc,CAAC;CAC5B;AA4MD,wBAAgB,YAAY,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,iBAAiB,GAAG,KAAK,CAAC,YAAY,CAsK7F"}
|
|
@@ -5,193 +5,296 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ElectionView = ElectionView;
|
|
7
7
|
const ink_wrapper_js_1 = require("../ink-wrapper.js");
|
|
8
|
-
const react_1 = require("react");
|
|
9
8
|
const ViewLayout_js_1 = require("../components/ViewLayout.js");
|
|
10
|
-
const
|
|
9
|
+
const ScrollIndicator_js_1 = require("../components/ScrollIndicator.js");
|
|
10
|
+
const index_js_1 = require("../utils/index.js");
|
|
11
|
+
const useElectionData_js_1 = require("../hooks/useElectionData.js");
|
|
12
|
+
const useElectionDetails_js_1 = require("../hooks/useElectionDetails.js");
|
|
13
|
+
const PHASE_COLORS = {
|
|
14
|
+
COMPLETED: "green",
|
|
15
|
+
MEMBER_ELECTION: "yellow",
|
|
16
|
+
NOMINEE_SELECTION: "yellow",
|
|
17
|
+
VETTING_PERIOD: "cyan",
|
|
18
|
+
PENDING_EXECUTION: "magenta",
|
|
19
|
+
NOT_STARTED: "gray",
|
|
20
|
+
};
|
|
21
|
+
const PHASE_ICONS = {
|
|
22
|
+
COMPLETED: "✓",
|
|
23
|
+
MEMBER_ELECTION: "●",
|
|
24
|
+
NOMINEE_SELECTION: "●",
|
|
25
|
+
VETTING_PERIOD: "◐",
|
|
26
|
+
PENDING_EXECUTION: "→",
|
|
27
|
+
NOT_STARTED: "○",
|
|
28
|
+
};
|
|
11
29
|
function formatTimestamp(ts) {
|
|
12
30
|
return new Date(ts * 1000).toLocaleString();
|
|
13
31
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
function formatVotes(votes) {
|
|
33
|
+
const str = votes.toString();
|
|
34
|
+
const WEI_DECIMALS = 18;
|
|
35
|
+
if (str.length <= WEI_DECIMALS)
|
|
36
|
+
return str;
|
|
37
|
+
const intPart = str.slice(0, str.length - WEI_DECIMALS);
|
|
38
|
+
return intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
39
|
+
}
|
|
40
|
+
function buildStatusLines(status) {
|
|
41
|
+
const lines = [];
|
|
42
|
+
const cohortName = status.cohort === 0 ? "FIRST" : "SECOND";
|
|
43
|
+
lines.push({ text: "Security Council Election Status", bold: true });
|
|
44
|
+
lines.push({ text: ` Election Count: ${status.electionCount}` });
|
|
45
|
+
lines.push({ text: ` Current Cohort: ${cohortName}`, color: status.cohort === 0 ? "cyan" : "magenta" });
|
|
46
|
+
lines.push({ text: ` Can Create: ${status.canCreateElection ? "Yes" : "No"}`, color: status.canCreateElection ? "green" : "gray" });
|
|
47
|
+
if (!status.canCreateElection) {
|
|
48
|
+
lines.push({ text: ` Next Election: ${formatTimestamp(status.nextElectionTimestamp)} (${status.timeUntilElection})` });
|
|
49
|
+
}
|
|
50
|
+
lines.push({ text: "" });
|
|
51
|
+
return lines;
|
|
52
|
+
}
|
|
53
|
+
function buildListLines(proposals, selectedIndex) {
|
|
54
|
+
const lines = [];
|
|
55
|
+
for (let i = 0; i < proposals.length; i++) {
|
|
56
|
+
const election = proposals[i];
|
|
57
|
+
const isSelected = i === selectedIndex;
|
|
58
|
+
const icon = PHASE_ICONS[election.phase] ?? "○";
|
|
59
|
+
const phaseColor = PHASE_COLORS[election.phase] ?? "gray";
|
|
60
|
+
const prefix = isSelected ? "> " : " ";
|
|
61
|
+
const phaseName = election.phase.replace(/_/g, " ");
|
|
62
|
+
lines.push({
|
|
63
|
+
text: `${prefix}${icon} Election #${election.electionIndex} - ${phaseName}`,
|
|
64
|
+
color: isSelected ? "cyan" : phaseColor,
|
|
65
|
+
bold: isSelected,
|
|
66
|
+
});
|
|
67
|
+
if (isSelected) {
|
|
68
|
+
const cohortName = election.cohort === 0 ? "FIRST" : "SECOND";
|
|
69
|
+
lines.push({ text: ` Cohort: ${cohortName}`, color: "gray" });
|
|
70
|
+
if (election.nomineeProposalId) {
|
|
71
|
+
lines.push({ text: ` Nominee State: ${election.nomineeProposalState}`, color: "gray" });
|
|
72
|
+
}
|
|
73
|
+
if (election.memberProposalId) {
|
|
74
|
+
lines.push({ text: ` Member State: ${election.memberProposalState}`, color: "gray" });
|
|
75
|
+
}
|
|
76
|
+
const nomineeColor = election.compliantNomineeCount >= election.targetNomineeCount ? "green" : "yellow";
|
|
77
|
+
lines.push({
|
|
78
|
+
text: ` Compliant Nominees: ${election.compliantNomineeCount}/${election.targetNomineeCount}`,
|
|
79
|
+
color: nomineeColor,
|
|
80
|
+
});
|
|
81
|
+
if (election.isInVettingPeriod) {
|
|
82
|
+
lines.push({ text: ` In vetting period until block ${election.vettingDeadline}`, color: "cyan" });
|
|
83
|
+
}
|
|
84
|
+
if (election.canProceedToMemberPhase) {
|
|
85
|
+
lines.push({ text: " Ready to trigger member election!", color: "green" });
|
|
86
|
+
}
|
|
87
|
+
if (election.canExecuteMember) {
|
|
88
|
+
lines.push({ text: " Ready to execute member election!", color: "green" });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return lines;
|
|
93
|
+
}
|
|
94
|
+
function buildDetailLines(election, nomineeDetails, memberDetails) {
|
|
95
|
+
const lines = [];
|
|
96
|
+
const icon = PHASE_ICONS[election.phase] ?? "○";
|
|
97
|
+
const phaseColor = PHASE_COLORS[election.phase] ?? "gray";
|
|
98
|
+
const phaseName = election.phase.replace(/_/g, " ");
|
|
99
|
+
const cohortName = election.cohort === 0 ? "FIRST" : "SECOND";
|
|
100
|
+
lines.push({ text: `${icon} Election #${election.electionIndex} - ${phaseName}`, color: phaseColor, bold: true });
|
|
101
|
+
lines.push({ text: "" });
|
|
102
|
+
lines.push({ text: ` Cohort: ${cohortName}` });
|
|
103
|
+
if (election.nomineeProposalId) {
|
|
104
|
+
lines.push({ text: ` Nominee Proposal ID: ${election.nomineeProposalId}`, dimColor: true });
|
|
105
|
+
}
|
|
106
|
+
if (election.memberProposalId) {
|
|
107
|
+
lines.push({ text: ` Member Proposal ID: ${election.memberProposalId}`, dimColor: true });
|
|
108
|
+
}
|
|
109
|
+
if (nomineeDetails) {
|
|
110
|
+
lines.push({ text: "" });
|
|
111
|
+
lines.push({ text: " ── Nominee Phase ──", color: "cyan", bold: true });
|
|
112
|
+
lines.push({ text: ` Quorum: ${formatVotes(nomineeDetails.quorumThreshold)} votes` });
|
|
113
|
+
lines.push({ text: ` Target: ${nomineeDetails.targetNomineeCount} nominees needed` });
|
|
114
|
+
if (nomineeDetails.contenders.length > 0) {
|
|
115
|
+
lines.push({ text: "" });
|
|
116
|
+
lines.push({ text: ` Contenders (${nomineeDetails.contenders.length})`, color: "yellow" });
|
|
117
|
+
for (const contender of nomineeDetails.contenders.slice(0, 10)) {
|
|
118
|
+
lines.push({ text: ` ${contender.address} (block ${contender.registeredAtBlock})`, color: "gray" });
|
|
119
|
+
}
|
|
120
|
+
if (nomineeDetails.contenders.length > 10) {
|
|
121
|
+
lines.push({ text: ` ... and ${nomineeDetails.contenders.length - 10} more`, color: "gray" });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (nomineeDetails.compliantNominees.length > 0) {
|
|
125
|
+
lines.push({ text: "" });
|
|
126
|
+
lines.push({ text: ` Qualified Nominees (${nomineeDetails.compliantNominees.length})`, color: "green" });
|
|
127
|
+
for (const nominee of nomineeDetails.compliantNominees.slice(0, 10)) {
|
|
128
|
+
lines.push({ text: ` ${nominee.address} ${formatVotes(nominee.votesReceived)} votes`, color: "gray" });
|
|
129
|
+
}
|
|
130
|
+
if (nomineeDetails.compliantNominees.length > 10) {
|
|
131
|
+
lines.push({ text: ` ... and ${nomineeDetails.compliantNominees.length - 10} more`, color: "gray" });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (nomineeDetails.excludedNominees.length > 0) {
|
|
135
|
+
lines.push({ text: "" });
|
|
136
|
+
lines.push({ text: ` Excluded (${nomineeDetails.excludedNominees.length})`, color: "red" });
|
|
137
|
+
for (const nominee of nomineeDetails.excludedNominees.slice(0, 5)) {
|
|
138
|
+
lines.push({ text: ` ${nominee.address} (excluded)`, color: "gray" });
|
|
139
|
+
}
|
|
140
|
+
if (nomineeDetails.excludedNominees.length > 5) {
|
|
141
|
+
lines.push({ text: ` ... and ${nomineeDetails.excludedNominees.length - 5} more`, color: "gray" });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
27
144
|
}
|
|
145
|
+
if (memberDetails) {
|
|
146
|
+
lines.push({ text: "" });
|
|
147
|
+
lines.push({ text: " ── Member Phase ──", color: "magenta", bold: true });
|
|
148
|
+
lines.push({ text: ` Full Weight Deadline: block ${memberDetails.fullWeightDeadline}` });
|
|
149
|
+
lines.push({ text: ` Proposal Deadline: block ${memberDetails.proposalDeadline}` });
|
|
150
|
+
if (memberDetails.nominees.length > 0) {
|
|
151
|
+
lines.push({ text: "" });
|
|
152
|
+
lines.push({ text: ` Candidates by Weight (${memberDetails.nominees.length})`, color: "yellow" });
|
|
153
|
+
for (const nominee of memberDetails.nominees.slice(0, 12)) {
|
|
154
|
+
const rank = `#${nominee.rank.toString().padStart(2)}`;
|
|
155
|
+
const winner = nominee.isWinner ? " [WINNER]" : "";
|
|
156
|
+
const color = nominee.isWinner ? "green" : "gray";
|
|
157
|
+
lines.push({ text: ` ${rank} ${nominee.address} ${formatVotes(nominee.weightReceived)}${winner}`, color });
|
|
158
|
+
}
|
|
159
|
+
if (memberDetails.nominees.length > 12) {
|
|
160
|
+
lines.push({ text: ` ... and ${memberDetails.nominees.length - 12} more`, color: "gray" });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (memberDetails.winners.length > 0) {
|
|
164
|
+
lines.push({ text: "" });
|
|
165
|
+
lines.push({ text: ` Elected Members (${memberDetails.winners.length})`, color: "green" });
|
|
166
|
+
for (const winner of memberDetails.winners) {
|
|
167
|
+
lines.push({ text: ` ✓ ${winner}`, color: "green" });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return lines;
|
|
28
172
|
}
|
|
173
|
+
const RESERVED_LINES = 8;
|
|
29
174
|
function ElectionView({ navigation, providers }) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
37
|
-
const [selectedIndex, setSelectedIndex] = (0, react_1.useState)(0);
|
|
38
|
-
// Reset selection when proposals change to avoid out-of-bounds index
|
|
39
|
-
(0, react_1.useEffect)(() => {
|
|
175
|
+
const data = (0, useElectionData_js_1.useElectionData)(providers);
|
|
176
|
+
const { details, loadDetails, clearDetails } = (0, useElectionDetails_js_1.useElectionDetails)(providers);
|
|
177
|
+
const [selectedIndex, setSelectedIndex] = (0, ink_wrapper_js_1.useState)(0);
|
|
178
|
+
const [showDetails, setShowDetails] = (0, ink_wrapper_js_1.useState)(false);
|
|
179
|
+
const [scrollOffset, setScrollOffset] = (0, ink_wrapper_js_1.useState)(0);
|
|
180
|
+
(0, ink_wrapper_js_1.useEffect)(() => {
|
|
40
181
|
setSelectedIndex(0);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return;
|
|
182
|
+
setShowDetails(false);
|
|
183
|
+
setScrollOffset(0);
|
|
184
|
+
clearDetails();
|
|
185
|
+
}, [data.proposals.length, clearDetails]);
|
|
186
|
+
const selectedElection = data.proposals[selectedIndex];
|
|
187
|
+
const lines = (0, ink_wrapper_js_1.useMemo)(() => {
|
|
188
|
+
const result = [];
|
|
189
|
+
const selected = data.proposals[selectedIndex];
|
|
190
|
+
if (data.status) {
|
|
191
|
+
result.push(...buildStatusLines(data.status));
|
|
52
192
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
: null,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
catch (err) {
|
|
91
|
-
if (!cancelled) {
|
|
92
|
-
setData({
|
|
93
|
-
status: null,
|
|
94
|
-
proposals: [],
|
|
95
|
-
loading: false,
|
|
96
|
-
error: err instanceof Error ? err.message : String(err),
|
|
97
|
-
warning: null,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
loadElectionData();
|
|
103
|
-
return () => {
|
|
104
|
-
cancelled = true;
|
|
105
|
-
};
|
|
106
|
-
}, [providers]);
|
|
107
|
-
(0, ink_wrapper_js_1.useInput)((input, key) => {
|
|
108
|
-
if (input === "b" || key.escape) {
|
|
193
|
+
const headerText = showDetails ? "Recent Elections • Press b to go back" : "Recent Elections • Press Enter for details";
|
|
194
|
+
result.push({ text: headerText, bold: true });
|
|
195
|
+
result.push({ text: "" });
|
|
196
|
+
if (data.proposals.length === 0) {
|
|
197
|
+
result.push({ text: " No elections found", color: "gray" });
|
|
198
|
+
}
|
|
199
|
+
else if (showDetails && selected) {
|
|
200
|
+
if (details.loading) {
|
|
201
|
+
result.push({ text: " Loading election details...", color: "cyan" });
|
|
202
|
+
}
|
|
203
|
+
else if (details.error) {
|
|
204
|
+
result.push({ text: ` Error: ${details.error}`, color: "red" });
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
result.push(...buildDetailLines(selected, details.nomineeDetails, details.memberDetails));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
result.push(...buildListLines(data.proposals, selectedIndex));
|
|
212
|
+
}
|
|
213
|
+
return result;
|
|
214
|
+
}, [data.status, data.proposals, selectedIndex, showDetails, details]);
|
|
215
|
+
const visibleCount = (0, index_js_1.getVisibleRows)(RESERVED_LINES);
|
|
216
|
+
const visibleLines = lines.slice(scrollOffset, scrollOffset + visibleCount);
|
|
217
|
+
const hasMore = scrollOffset + visibleCount < lines.length;
|
|
218
|
+
const hasLess = scrollOffset > 0;
|
|
219
|
+
const handleBackOrEscape = () => {
|
|
220
|
+
if (showDetails) {
|
|
221
|
+
setShowDetails(false);
|
|
222
|
+
setScrollOffset(0);
|
|
223
|
+
clearDetails();
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
109
226
|
navigation.back();
|
|
110
227
|
}
|
|
111
|
-
|
|
228
|
+
};
|
|
229
|
+
const handleDetailScroll = (input, key) => {
|
|
230
|
+
const maxOffset = Math.max(0, lines.length - visibleCount);
|
|
231
|
+
const PAGE_SIZE = 10;
|
|
232
|
+
if (key.upArrow || input === "k") {
|
|
233
|
+
setScrollOffset((prev) => Math.max(0, prev - 1));
|
|
234
|
+
}
|
|
235
|
+
else if (key.downArrow || input === "j") {
|
|
236
|
+
setScrollOffset((prev) => Math.min(maxOffset, prev + 1));
|
|
237
|
+
}
|
|
238
|
+
else if (key.pageUp || (key.ctrl && input === "u")) {
|
|
239
|
+
setScrollOffset((prev) => Math.max(0, prev - PAGE_SIZE));
|
|
240
|
+
}
|
|
241
|
+
else if (key.pageDown || (key.ctrl && input === "d")) {
|
|
242
|
+
setScrollOffset((prev) => Math.min(maxOffset, prev + PAGE_SIZE));
|
|
243
|
+
}
|
|
244
|
+
else if (input === "g") {
|
|
245
|
+
setScrollOffset(0);
|
|
246
|
+
}
|
|
247
|
+
else if (input === "G") {
|
|
248
|
+
setScrollOffset(maxOffset);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const handleListNavigation = (input, key) => {
|
|
252
|
+
if (data.proposals.length === 0)
|
|
253
|
+
return;
|
|
254
|
+
const maxIndex = data.proposals.length - 1;
|
|
255
|
+
if (key.upArrow || input === "k") {
|
|
112
256
|
setSelectedIndex((prev) => Math.max(0, prev - 1));
|
|
113
257
|
}
|
|
114
|
-
else if (
|
|
115
|
-
setSelectedIndex((prev) => Math.min(
|
|
258
|
+
else if (key.downArrow || input === "j") {
|
|
259
|
+
setSelectedIndex((prev) => Math.min(maxIndex, prev + 1));
|
|
116
260
|
}
|
|
117
261
|
else if (input === "g") {
|
|
118
262
|
setSelectedIndex(0);
|
|
119
263
|
}
|
|
120
|
-
else if (input === "G"
|
|
121
|
-
setSelectedIndex(
|
|
264
|
+
else if (input === "G") {
|
|
265
|
+
setSelectedIndex(maxIndex);
|
|
266
|
+
}
|
|
267
|
+
else if ((key.return || input === "l") && selectedElection && providers) {
|
|
268
|
+
setShowDetails(true);
|
|
269
|
+
setScrollOffset(0);
|
|
270
|
+
loadDetails(selectedElection.electionIndex);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
(0, ink_wrapper_js_1.useInput)((input, key) => {
|
|
274
|
+
if (input === "b" || key.escape) {
|
|
275
|
+
handleBackOrEscape();
|
|
276
|
+
return;
|
|
122
277
|
}
|
|
123
|
-
|
|
278
|
+
if (input === "?") {
|
|
124
279
|
navigation.goToHelp();
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (showDetails) {
|
|
283
|
+
handleDetailScroll(input, key);
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
handleListNavigation(input, key);
|
|
125
287
|
}
|
|
126
288
|
});
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
warning && (ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, { marginBottom: 1 },
|
|
289
|
+
return (ink_wrapper_js_1.React.createElement(ViewLayout_js_1.ViewLayout, { view: "election", hasProviders: !!providers, isTracking: data.loading || details.loading, loading: data.loading, loadingText: "Loading election status...", skeletonType: "detail", error: data.error },
|
|
290
|
+
data.warning && (ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, { marginBottom: 1 },
|
|
130
291
|
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: "yellow" },
|
|
131
292
|
"[Warning] ",
|
|
132
|
-
warning))),
|
|
133
|
-
|
|
134
|
-
ink_wrapper_js_1.React.createElement(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, null, status.electionCount)),
|
|
139
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, null,
|
|
140
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: "gray" }, "Current Cohort: "),
|
|
141
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: status.cohort === 0 ? "cyan" : "magenta" }, status.cohort === 0 ? "FIRST" : "SECOND")),
|
|
142
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, null,
|
|
143
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: "gray" }, "Can Create Election: "),
|
|
144
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: status.canCreateElection ? "green" : "gray" }, status.canCreateElection ? "Yes" : "No")),
|
|
145
|
-
!status.canCreateElection && (ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, null,
|
|
146
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: "gray" }, "Next Election: "),
|
|
147
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, null, formatTimestamp(status.nextElectionTimestamp)),
|
|
148
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: "gray" },
|
|
149
|
-
" (",
|
|
150
|
-
status.timeUntilElection,
|
|
151
|
-
")")))))),
|
|
152
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, { flexDirection: "column" },
|
|
153
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { bold: true }, "Recent Elections"),
|
|
154
|
-
proposals.length === 0 ? (ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: "gray", marginLeft: 1 }, "No elections found")) : (proposals.map((election, i) => (ink_wrapper_js_1.React.createElement(ElectionItem, { key: election.electionIndex, election: election, isSelected: i === selectedIndex })))))));
|
|
155
|
-
}
|
|
156
|
-
function getPhaseColor(phase) {
|
|
157
|
-
if (phase === "COMPLETED")
|
|
158
|
-
return "green";
|
|
159
|
-
if (phase === "NOT_STARTED")
|
|
160
|
-
return "gray";
|
|
161
|
-
return "yellow";
|
|
162
|
-
}
|
|
163
|
-
function ElectionItem({ election, isSelected }) {
|
|
164
|
-
return (ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, { marginLeft: 1, flexDirection: "column" },
|
|
165
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, null,
|
|
166
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: isSelected ? "cyan" : undefined }, isSelected ? "> " : " "),
|
|
167
|
-
ink_wrapper_js_1.React.createElement(PhaseIcon, { phase: election.phase }),
|
|
168
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, null, " "),
|
|
169
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: isSelected ? "cyan" : undefined, bold: isSelected },
|
|
170
|
-
"Election #",
|
|
171
|
-
election.electionIndex),
|
|
172
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: "gray" }, " - "),
|
|
173
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: getPhaseColor(election.phase) }, election.phase.replace(/_/g, " "))),
|
|
174
|
-
isSelected && (ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, { marginLeft: 4, flexDirection: "column" },
|
|
175
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, null,
|
|
176
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: "gray" }, "Cohort: "),
|
|
177
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, null, election.cohort === 0 ? "FIRST" : "SECOND")),
|
|
178
|
-
election.nomineeProposalId && (ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, null,
|
|
179
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: "gray" }, "Nominee State: "),
|
|
180
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, null, election.nomineeProposalState))),
|
|
181
|
-
election.memberProposalId && (ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, null,
|
|
182
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: "gray" }, "Member State: "),
|
|
183
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, null, election.memberProposalState))),
|
|
184
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, null,
|
|
185
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: "gray" }, "Compliant Nominees: "),
|
|
186
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: election.compliantNomineeCount >= election.targetNomineeCount ? "green" : "yellow" },
|
|
187
|
-
election.compliantNomineeCount,
|
|
188
|
-
"/",
|
|
189
|
-
election.targetNomineeCount)),
|
|
190
|
-
election.isInVettingPeriod && (ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, null,
|
|
191
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: "cyan" },
|
|
192
|
-
"In vetting period until block ",
|
|
193
|
-
election.vettingDeadline))),
|
|
194
|
-
election.canProceedToMemberPhase && (ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, null,
|
|
195
|
-
ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { color: "green" }, "Ready to trigger member election!")))))));
|
|
293
|
+
data.warning))),
|
|
294
|
+
lines.length > visibleCount && (ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Box, { marginBottom: 1 },
|
|
295
|
+
ink_wrapper_js_1.React.createElement(ScrollIndicator_js_1.ScrollPosition, { scrollOffset: scrollOffset, visibleRows: visibleCount, totalItems: lines.length }))),
|
|
296
|
+
hasLess && ink_wrapper_js_1.React.createElement(ScrollIndicator_js_1.ScrollIndicatorTop, { scrollOffset: scrollOffset, unit: "lines" }),
|
|
297
|
+
visibleLines.map((line, i) => (ink_wrapper_js_1.React.createElement(ink_wrapper_js_1.Text, { key: i, color: line.color, bold: line.bold, dimColor: line.dimColor }, line.text))),
|
|
298
|
+
hasMore && (ink_wrapper_js_1.React.createElement(ScrollIndicator_js_1.ScrollIndicatorBottom, { scrollOffset: scrollOffset, visibleRows: visibleCount, totalItems: lines.length, unit: "lines" }))));
|
|
196
299
|
}
|
|
197
300
|
//# sourceMappingURL=ElectionView.js.map
|