Skip to content

Commit 50cdb65

Browse files
committed
gov action improvements
1 parent f12e5e2 commit 50cdb65

6 files changed

Lines changed: 1114 additions & 75 deletions

File tree

src/features/builder/TransactionActions.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ export function TransactionActions() {
9393
const allCertificates = [...builderCertificates];
9494

9595
console.log('Step 4: Assembling transaction...');
96-
const { txBody, error } = assembleTransaction({
96+
const { txBody, txWitnessSet, error } = assembleTransaction({
9797
certificates: allCertificates,
9898
txBodyElements: builderTxBodyElements,
9999
utxos: utxos as Parameters<typeof assembleTransaction>[0]['utxos'],
100100
changeAddress: changeAddress,
101-
network: buildNetwork
101+
network: buildNetwork,
102102
});
103103

104104
if (error || !txBody) {
@@ -119,7 +119,7 @@ export function TransactionActions() {
119119
console.log('Fee calculated:', fee.toString());
120120

121121
console.log('Step 6: Serializing transaction...');
122-
const txHex = serializeTransaction(txBody);
122+
const txHex = serializeTransaction(txBody, txWitnessSet);
123123
console.log('Transaction serialized, hex length:', txHex.length);
124124

125125
freeTransactionBody(txBody);

src/features/builder/TransactionSummary.tsx

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,34 @@ import { Badge } from '@/components/ui/badge';
88
import { ScrollArea } from '@/components/ui/scroll-area';
99
import { Separator } from '@/components/ui/separator';
1010
import { X, Copy, CheckCircle2, FileText, Vote, Settings } from 'lucide-react';
11-
import { useAppStore } from '@/lib/store';
11+
import { useAppStore, type BuilderTxBodyElement } from '@/lib/store';
1212
import { toast } from 'sonner';
13+
import { formatAda } from '@/lib/utils/ada';
14+
15+
function summarizeTxBodyElement(el: BuilderTxBodyElement): string {
16+
if (el.type === 'ProposalProcedures') {
17+
const kind = el.data?.kind;
18+
if (kind === 'info') {
19+
const deposit = el.data?.deposit;
20+
try {
21+
return `Info · ${formatAda(BigInt(String(deposit ?? 0)))} ada`;
22+
} catch {
23+
return 'Info';
24+
}
25+
}
26+
if (kind === 'parameter-change') {
27+
const cm = el.data?.costModels as { PlutusV1?: number[]; PlutusV2?: number[]; PlutusV3?: number[] } | undefined;
28+
const langs = cm
29+
? Object.keys(cm).filter((k): k is 'PlutusV1' | 'PlutusV2' | 'PlutusV3' =>
30+
['PlutusV1', 'PlutusV2', 'PlutusV3'].includes(k))
31+
: [];
32+
return `Parameter Change${langs.length ? ` · ${langs.join(', ')}` : ''}`;
33+
}
34+
// 'cbor' or missing — fall through to legacy hex-snippet behaviour.
35+
}
36+
const first = Object.values(el.data ?? {})[0];
37+
return first ? String(first).slice(0, 20) : 'Element';
38+
}
1339

1440
export function TransactionSummary() {
1541
const { builderCertificates, builderTxBodyElements, builtTxHex, removeCertificate, removeTxBodyElement } = useAppStore();
@@ -257,7 +283,7 @@ export function TransactionSummary() {
257283
</div>
258284
</div>
259285
)}
260-
{Object.entries(groupedTxBodyElements).filter(([key, items]) =>
286+
{Object.entries(groupedTxBodyElements).filter(([key, items]) =>
261287
!['inputs', 'outputs', 'fees'].includes(key) && items.length > 0
262288
).map(([key, items]) => (
263289
<div key={key}>
@@ -272,7 +298,7 @@ export function TransactionSummary() {
272298
{getTxBodyElementLabel(el.type)}
273299
</Badge>
274300
<span className="text-xs text-muted-foreground truncate">
275-
{Object.values(el.data)[0] ? String(Object.values(el.data)[0]).slice(0, 20) : 'Element'}
301+
{summarizeTxBodyElement(el)}
276302
</span>
277303
</div>
278304
<Button variant="ghost" size="sm" onClick={() => removeTxBodyElement(el.id)}>

0 commit comments

Comments
 (0)