Skip to content

Commit 7dcd832

Browse files
committed
Refactor wallet components and enhance DRep ID handling
- Updated CardUI to conditionally render larger titles for wallet info cards based on class names. - Improved DRep ID retrieval logic across multiple components to ensure consistent fallback to appWallet for legacy wallets. - Added wallet type detection to enhance user experience with badge displays for Summon and Legacy wallets. - Refactored transaction components to utilize truncateTokenSymbol for better token symbol presentation. - Enhanced layout and styling for transaction cards and balance displays for improved user interaction.
1 parent ec1a976 commit 7dcd832

File tree

25 files changed

+554
-636
lines changed

25 files changed

+554
-636
lines changed

src/components/common/card-content.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ export default function CardUI({
1616
cardClassName?: string;
1717
headerDom?: ReactNode;
1818
}) {
19+
// Make title larger for wallet info card (col-span-2)
20+
const isLargeTitle = cardClassName?.includes('col-span-2');
21+
1922
return (
2023
<Card className={`w-full max-w-4xl ${cardClassName}`}>
2124
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
22-
<CardTitle className="text-xl font-medium">{title}</CardTitle>
25+
<CardTitle className={isLargeTitle ? "text-2xl sm:text-3xl font-semibold" : "text-xl font-medium"}>{title}</CardTitle>
2326
{headerDom && headerDom}
2427
{icon && (
2528
<>
@@ -33,7 +36,7 @@ export default function CardUI({
3336
</>
3437
)}
3538
</CardHeader>
36-
<CardContent className="overflow-y-auto max-h-[calc(100vh-200px)]">
39+
<CardContent>
3740
<div className="mt-1 flex flex-col gap-2">
3841
{description && (
3942
<p className="text-sm text-muted-foreground">{description}</p>

src/components/common/overall-layout/mobile-wrappers/wallet-data-loader-wrapper.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,9 @@ export default function WalletDataLoaderWrapper({
160160
}
161161

162162
function dRepIds() {
163-
// Use multisig wallet DRep ID if available, otherwise fallback to appWallet
164-
const dRepId = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepId() : appWallet?.dRepId;
163+
// Use multisig wallet DRep ID if available (it handles no DRep keys by using payment script),
164+
// otherwise fallback to appWallet (for legacy wallets without multisigWallet)
165+
const dRepId = multisigWallet ? multisigWallet.getDRepId() : appWallet?.dRepId;
165166
if (!dRepId) return null;
166167
return getDRepIds(dRepId);
167168
}

src/components/multisig/proxy/ProxyOverview.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { memo, useState, useEffect } from "react";
2+
import { truncateTokenSymbol } from "@/utils/strings";
23
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
34
import { Badge } from "@/components/ui/badge";
45
import { Button } from "@/components/ui/button";
@@ -270,7 +271,7 @@ const ProxyCard = memo(function ProxyCard({
270271
<div className="text-sm space-y-1">
271272
{displayBalance.map((asset: any, index: number) => (
272273
<div key={index} className="flex justify-between">
273-
<span>{asset.unit === "lovelace" ? "ADA" : asset.unit}:</span>
274+
<span>{asset.unit === "lovelace" ? "ADA" : truncateTokenSymbol(asset.unit)}:</span>
274275
<span className="font-mono">
275276
{asset.unit === "lovelace"
276277
? `${(parseFloat(asset.quantity) / 1000000).toFixed(6)} ADA`

src/components/multisig/proxy/ProxySpend.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { memo } from "react";
2+
import { truncateTokenSymbol } from "@/utils/strings";
23
import { Button } from "@/components/ui/button";
34
import { Input } from "@/components/ui/input";
45
import { Label } from "@/components/ui/label";
@@ -139,7 +140,7 @@ const ProxySpend = memo(function ProxySpend({
139140
<div key={index} className="flex items-center justify-between p-3 border rounded-lg bg-muted/50">
140141
<div className="flex items-center gap-2">
141142
<Badge variant="secondary">
142-
{asset.unit === "lovelace" ? "ADA" : asset.unit}
143+
{asset.unit === "lovelace" ? "ADA" : truncateTokenSymbol(asset.unit)}
143144
</Badge>
144145
<span className="font-mono text-sm">
145146
{asset.unit === "lovelace"

src/components/pages/homepage/wallets/index.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import { getFirstAndLast } from "@/utils/strings";
99
import { api } from "@/utils/api";
1010
import { useUserStore } from "@/lib/zustand/user";
1111
import { useSiteStore } from "@/lib/zustand/site";
12-
import { buildMultisigWallet } from "@/utils/common";
12+
import { buildMultisigWallet, getWalletType } from "@/utils/common";
1313
import { addressToNetwork } from "@/utils/multisigSDK";
1414

1515
import { Button } from "@/components/ui/button";
16+
import { Badge } from "@/components/ui/badge";
17+
import { Archive } from "lucide-react";
1618
import PageHeader from "@/components/common/page-header";
1719
import CardUI from "@/components/common/card-content";
1820
import RowLabelInfo from "@/components/common/row-label-info";
@@ -236,6 +238,11 @@ function CardWallet({
236238
walletId: wallet.id,
237239
});
238240

241+
// Check wallet type for badge display using centralized detection
242+
const walletType = getWalletType(wallet);
243+
const isSummonWallet = walletType === 'summon';
244+
const isLegacyWallet = walletType === 'legacy';
245+
239246
// Rebuild the multisig wallet to get the correct canonical address for display
240247
// This ensures we show the correct address even if wallet.address was built incorrectly
241248
const displayAddress = useMemo(() => {
@@ -260,6 +267,17 @@ function CardWallet({
260267
title={`${wallet.name}${wallet.isArchived ? " (Archived)" : ""}`}
261268
description={wallet.description}
262269
cardClassName=""
270+
headerDom={
271+
isSummonWallet ? (
272+
<Badge
273+
variant="outline"
274+
className="text-xs bg-orange-600/10 border-orange-600/30 text-orange-700 dark:text-orange-400"
275+
>
276+
<Archive className="h-3 w-3 mr-1" />
277+
Summon
278+
</Badge>
279+
) : undefined
280+
}
263281
>
264282
<WalletBalance balance={balance} loadingState={loadingState} />
265283
<RowLabelInfo

src/components/pages/homepage/wallets/new-wallet-flow/ready/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { api } from "@/utils/api";
66
import { useToast } from "@/hooks/use-toast";
77
import { useUserStore } from "@/lib/zustand/user";
88
import { useSiteStore } from "@/lib/zustand/site";
9-
import { buildWallet } from "@/hooks/common";
9+
import { buildWallet } from "@/utils/common";
1010

1111
import PageHeader from "@/components/common/page-header";
1212
import {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,9 @@ export default function BallotCard({
402402
setLoading(true);
403403
try {
404404
if (!multisigWallet) throw new Error("Multisig Wallet could not be built.");
405-
const dRepId = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepId() : appWallet?.dRepId;
405+
// Use multisig wallet DRep ID if available (it handles no DRep keys by using payment script),
406+
// otherwise fallback to appWallet (for legacy wallets without multisigWallet)
407+
const dRepId = multisigWallet ? multisigWallet.getDRepId() : appWallet?.dRepId;
406408
if (!dRepId) {
407409
setAlert("DRep not found");
408410
toast({

src/components/pages/wallet/governance/card-info.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ export default function CardInfo({ appWallet, manualUtxos }: { appWallet: Wallet
5656
} | null>(null);
5757

5858
// Get DRep info for standard mode
59-
const currentDrepId = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepId() : appWallet?.dRepId;
59+
// Use multisig wallet DRep ID if available (it handles no DRep keys by using payment script),
60+
// otherwise fallback to appWallet (for legacy wallets without multisigWallet)
61+
const currentDrepId = multisigWallet ? multisigWallet.getDRepId() : appWallet?.dRepId;
6062
const currentDrepInfo = drepInfo;
6163

6264

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ export default function VoteButton({
231231
}
232232
if (!multisigWallet)
233233
throw new Error("Multisig Wallet could not be built.");
234-
const dRepId = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepId() : appWallet?.dRepId;
234+
// Use multisig wallet DRep ID if available (it handles no DRep keys by using payment script),
235+
// otherwise fallback to appWallet (for legacy wallets without multisigWallet)
236+
const dRepId = multisigWallet ? multisigWallet.getDRepId() : appWallet?.dRepId;
235237
if (!dRepId) {
236238
setAlert("DRep not found");
237239
toast({

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ export default function AllProposals({ appWallet, utxos, selectedBallotId, onSel
8383
const order = "desc";
8484

8585
// Get DRep ID for fetching voting history (proxy mode or standard mode)
86-
const standardDrepId = multisigWallet?.getKeysByRole(3) ? multisigWallet?.getDRepId() : appWallet?.dRepId;
86+
// Use multisig wallet DRep ID if available (it handles no DRep keys by using payment script),
87+
// otherwise fallback to appWallet (for legacy wallets without multisigWallet)
88+
const standardDrepId = multisigWallet ? multisigWallet.getDRepId() : appWallet?.dRepId;
8789

8890
// Get proxy DRep ID if proxy is enabled
8991
useEffect(() => {

0 commit comments

Comments
 (0)