Skip to content

Commit cf5ac82

Browse files
committed
Refactor wallet transaction components and enhance voting display
- Updated BallotCard and VoteButton components to improve error handling for wallet address retrieval, ensuring fallback to appWallet for legacy wallets. - Enhanced the TransactionCard component to display voting information with badges for different vote types (Yes, No, Abstain). - Improved layout and styling for transaction outputs and signer lists for better user experience. - Added functionality to copy signer addresses to clipboard with user feedback. - Refactored wallet access checks in the ballot router to streamline authorization logic.
1 parent a094395 commit cf5ac82

File tree

6 files changed

+352
-169
lines changed

6 files changed

+352
-169
lines changed

src/components/pages/wallet/governance/ballot/ballot.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ export default function BallotCard({
285285
const proxy = proxies.find((p: any) => p.id === selectedProxyId);
286286
if (!proxy) throw new Error("Proxy not found");
287287

288-
if (!multisigWallet) throw new Error("Multisig Wallet could not be built.");
289288
const meshTxBuilder = getTxBuilder(network);
290289
const proxyContract = new MeshProxyContract(
291290
{
@@ -314,7 +313,12 @@ export default function BallotCard({
314313
});
315314

316315
// Vote using proxy
317-
const txBuilder = await proxyContract.voteProxyDrep(votes, utxos, multisigWallet?.getScript().address);
316+
// Use multisig wallet address if available, otherwise fallback to appWallet (for legacy wallets)
317+
const proxyAddress = multisigWallet?.getScript().address || appWallet?.address;
318+
if (!proxyAddress) {
319+
throw new Error("Wallet address not found");
320+
}
321+
const txBuilder = await proxyContract.voteProxyDrep(votes, utxos, proxyAddress);
318322

319323
await newTransaction({
320324
txBuilder: txBuilder,
@@ -401,7 +405,6 @@ export default function BallotCard({
401405

402406
setLoading(true);
403407
try {
404-
if (!multisigWallet) throw new Error("Multisig Wallet could not be built.");
405408
// Use multisig wallet DRep ID if available (it handles no DRep keys by using payment script),
406409
// otherwise fallback to appWallet (for legacy wallets without multisigWallet)
407410
const dRepId = multisigWallet ? multisigWallet.getDRepId() : appWallet?.dRepId;

src/components/pages/wallet/governance/proposal/voteButtton.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,12 @@ export default function VoteButton({
154154
};
155155

156156
// Vote using proxy
157-
const txBuilderResult = await proxyContract.voteProxyDrep([voteData], utxos, multisigWallet?.getScript().address);
157+
// Use multisig wallet address if available, otherwise fallback to appWallet (for legacy wallets)
158+
const proxyAddress = multisigWallet?.getScript().address || appWallet?.address;
159+
if (!proxyAddress) {
160+
throw new Error("Wallet address not found");
161+
}
162+
const txBuilderResult = await proxyContract.voteProxyDrep([voteData], utxos, proxyAddress);
158163

159164
await newTransaction({
160165
txBuilder: txBuilderResult,
@@ -229,8 +234,6 @@ export default function VoteButton({
229234
setLoading(false);
230235
return;
231236
}
232-
if (!multisigWallet)
233-
throw new Error("Multisig Wallet could not be built.");
234237
// Use multisig wallet DRep ID if available (it handles no DRep keys by using payment script),
235238
// otherwise fallback to appWallet (for legacy wallets without multisigWallet)
236239
const dRepId = multisigWallet ? multisigWallet.getDRepId() : appWallet?.dRepId;

src/components/pages/wallet/new-transaction/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ export default function PageNewTransaction() {
178178
unit: outputs[i]!.unit,
179179
quantity: outputs[i]!.amount,
180180
},
181+
// if unit is not lovelace, add 1160000 lovelace as native assets are not allowed to be in an output alone.
182+
...(outputs[i]!.unit !== "lovelace" ? [{
183+
unit: "lovelace",
184+
quantity: "1160000",
185+
}] : [])
181186
]);
182187
}
183188
}

src/components/pages/wallet/transactions/index.tsx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,26 @@ export default function PageTransactions() {
2323
{pendingTransactions && pendingTransactions.length > 0 && (
2424
<>
2525
<SectionTitle>Pending Transactions</SectionTitle>
26-
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3">
27-
{pendingTransactions.map((tx) => {
28-
return (
29-
<TransactionCard
30-
key={tx.id}
31-
walletId={appWallet.id}
32-
transaction={tx}
33-
/>
34-
);
35-
})}
26+
<div className={`flex justify-center w-full`}>
27+
<div
28+
className={`grid gap-4 w-full ${
29+
pendingTransactions.length === 1
30+
? "max-w-2xl"
31+
: pendingTransactions.length === 2
32+
? "max-w-5xl sm:grid-cols-2"
33+
: "max-w-7xl sm:grid-cols-2 lg:grid-cols-3"
34+
}`}
35+
>
36+
{pendingTransactions.map((tx) => {
37+
return (
38+
<TransactionCard
39+
key={tx.id}
40+
walletId={appWallet.id}
41+
transaction={tx}
42+
/>
43+
);
44+
})}
45+
</div>
3646
</div>
3747
</>
3848
)}

0 commit comments

Comments
 (0)