@@ -9,10 +9,12 @@ import { getFirstAndLast } from "@/utils/strings";
99import { api } from "@/utils/api" ;
1010import { useUserStore } from "@/lib/zustand/user" ;
1111import { useSiteStore } from "@/lib/zustand/site" ;
12- import { buildMultisigWallet } from "@/utils/common" ;
12+ import { buildMultisigWallet , getWalletType } from "@/utils/common" ;
1313import { addressToNetwork } from "@/utils/multisigSDK" ;
1414
1515import { Button } from "@/components/ui/button" ;
16+ import { Badge } from "@/components/ui/badge" ;
17+ import { Archive } from "lucide-react" ;
1618import PageHeader from "@/components/common/page-header" ;
1719import CardUI from "@/components/common/card-content" ;
1820import RowLabelInfo from "@/components/common/row-label-info" ;
@@ -29,10 +31,21 @@ export default function PageWallets() {
2931 const [ showArchived , setShowArchived ] = useState ( false ) ;
3032 const userAddress = useUserStore ( ( state ) => state . userAddress ) ;
3133
34+ // Check wallet session authorization before enabling queries
35+ const { data : walletSession } = api . auth . getWalletSession . useQuery (
36+ { address : userAddress ?? "" } ,
37+ {
38+ enabled : ! ! userAddress && userAddress . length > 0 ,
39+ refetchOnWindowFocus : false ,
40+ } ,
41+ ) ;
42+ const isAuthorized = walletSession ?. authorized ?? false ;
43+
3244 const { data : newPendingWallets , isLoading : isLoadingNewWallets } = api . wallet . getUserNewWallets . useQuery (
3345 { address : userAddress ! } ,
3446 {
35- enabled : userAddress !== undefined ,
47+ // Only enable query when user is authorized (prevents 403 errors)
48+ enabled : userAddress !== undefined && isAuthorized ,
3649 retry : ( failureCount , error ) => {
3750 // Don't retry on authorization errors (403)
3851 if ( error && typeof error === "object" ) {
@@ -60,15 +73,24 @@ export default function PageWallets() {
6073 api . wallet . getUserNewWalletsNotOwner . useQuery (
6174 { address : userAddress ! } ,
6275 {
63- enabled : userAddress !== undefined ,
76+ // Only enable query when user is authorized (prevents 403 errors)
77+ enabled : userAddress !== undefined && isAuthorized ,
6478 retry : ( failureCount , error ) => {
6579 // Don't retry on authorization errors (403)
6680 if ( error && typeof error === "object" ) {
67- const err = error as { code ?: string ; message ?: string ; data ?: { code ?: string } } ;
81+ const err = error as {
82+ code ?: string ;
83+ message ?: string ;
84+ data ?: { code ?: string ; httpStatus ?: number } ;
85+ shape ?: { code ?: string ; message ?: string } ;
86+ } ;
87+ const errorMessage = err . message || err . shape ?. message || "" ;
6888 const isAuthError =
6989 err . code === "FORBIDDEN" ||
7090 err . data ?. code === "FORBIDDEN" ||
71- err . message ?. includes ( "Address mismatch" ) ;
91+ err . data ?. httpStatus === 403 ||
92+ err . shape ?. code === "FORBIDDEN" ||
93+ errorMessage . includes ( "Address mismatch" ) ;
7294 if ( isAuthError ) return false ;
7395 }
7496 return failureCount < 1 ;
@@ -216,6 +238,11 @@ function CardWallet({
216238 walletId : wallet . id ,
217239 } ) ;
218240
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+
219246 // Rebuild the multisig wallet to get the correct canonical address for display
220247 // This ensures we show the correct address even if wallet.address was built incorrectly
221248 const displayAddress = useMemo ( ( ) => {
@@ -240,6 +267,17 @@ function CardWallet({
240267 title = { `${ wallet . name } ${ wallet . isArchived ? " (Archived)" : "" } ` }
241268 description = { wallet . description }
242269 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+ }
243281 >
244282 < WalletBalance balance = { balance } loadingState = { loadingState } />
245283 < RowLabelInfo
0 commit comments