Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/components/wallet/L3/services/TokenRecoveryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
removeToken
} from "./InventorySyncService";
import { IdentityManager } from "./IdentityManager";
import { RegistryService } from "./RegistryService";
// import { ServiceProvider } from "./ServiceProvider"; // TODO: Uncomment when aggregator token lookup is implemented
import type { TxfToken, TxfTransaction } from "./types/TxfTypes";
import { getCurrentStateHash, tokenToTxf } from "./TxfSerializer";
Expand Down Expand Up @@ -888,15 +889,28 @@ export class TokenRecoveryService {
// For now, create a placeholder token that marks this as recovered
// The actual reconstruction would need SDK integration

// Lookup registry for symbol and icon
let symbol = isNft ? "NFT" : "UCT";
let iconUrl: string | undefined = undefined;
if (coinId && !isNft) {
const registryService = RegistryService.getInstance();
const def = registryService.getCoinDefinition(coinId);
if (def) {
symbol = def.symbol || symbol;
iconUrl = registryService.getIconUrl(def) || undefined;
}
}

const token = new Token({
id: tokenId,
name: isNft ? "NFT (Recovered)" : "Token (Recovered)",
type: isNft ? "NFT" : "UCT",
name: isNft ? "NFT (Recovered)" : `${symbol} (Recovered)`,
type: isNft ? "NFT" : symbol,
timestamp: Date.now(),
status: TokenStatus.CONFIRMED,
amount: amount,
coinId: coinId,
symbol: isNft ? "NFT" : "UCT",
symbol,
iconUrl,
// Note: jsonData would need proper TxfToken reconstruction with proofs
});

Expand Down
20 changes: 17 additions & 3 deletions src/components/wallet/L3/services/TxfSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { Token, TokenStatus } from "../data/model";
import { RegistryService } from "./RegistryService";
import type { NametagData } from "./types/TxfTypes";
import {
type TxfStorageData,
Expand Down Expand Up @@ -148,16 +149,29 @@ export function txfToToken(tokenId: string, txf: TxfToken): Token {
const tokenType = txf.genesis.data.tokenType;
const isNft = tokenType === "455ad8720656b08e8dbd5bac1f3c73eeea5431565f6c1c3af742b1aa12d41d89";

// Lookup registry for symbol and icon
let symbol = isNft ? "NFT" : "UCT";
let iconUrl: string | undefined = undefined;
if (coinId && !isNft) {
const registryService = RegistryService.getInstance();
const def = registryService.getCoinDefinition(coinId);
if (def) {
symbol = def.symbol || symbol;
iconUrl = registryService.getIconUrl(def) || undefined;
}
}

return new Token({
id: tokenId,
name: isNft ? "NFT" : "Token",
type: isNft ? "NFT" : "UCT",
name: isNft ? "NFT" : symbol,
type: isNft ? "NFT" : symbol,
timestamp: Date.now(),
jsonData: JSON.stringify(txf),
status,
amount: totalAmount.toString(),
coinId,
symbol: isNft ? "NFT" : "UCT",
symbol,
iconUrl,
sizeBytes: JSON.stringify(txf).length,
});
}
Expand Down
20 changes: 17 additions & 3 deletions src/repositories/WalletRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { TombstoneEntry, TxfToken, TxfTransaction, InvalidatedNametagEntry,
import { v4 as uuidv4 } from "uuid";
import { STORAGE_KEYS, STORAGE_KEY_GENERATORS, STORAGE_KEY_PREFIXES } from "../config/storageKeys";
import { assertValidNametagData, sanitizeNametagForLogging, validateTokenJson } from "../utils/tokenValidation";
import { RegistryService } from "../components/wallet/L3/services/RegistryService";

// Re-export NametagData for backwards compatibility
export type { NametagData } from "../components/wallet/L3/services/types/TxfTypes";
Expand Down Expand Up @@ -1862,16 +1863,29 @@ export class WalletRepository {
const tokenType = txfToken.genesis?.data?.tokenType || "";
const isNft = tokenType === "455ad8720656b08e8dbd5bac1f3c73eeea5431565f6c1c3af742b1aa12d41d89";

// Lookup registry for symbol and icon
let symbol = isNft ? "NFT" : "UCT";
let iconUrl: string | undefined = undefined;
if (coinId && !isNft) {
const registryService = RegistryService.getInstance();
const def = registryService.getCoinDefinition(coinId);
if (def) {
symbol = def.symbol || symbol;
iconUrl = registryService.getIconUrl(def) || undefined;
}
}

const token = new Token({
id: tokenId,
name: isNft ? "NFT" : "Token",
type: isNft ? "NFT" : "UCT",
name: isNft ? "NFT" : symbol,
type: isNft ? "NFT" : symbol,
timestamp: Date.now(),
jsonData: JSON.stringify(txfToken),
status: TokenStatus.CONFIRMED,
amount: totalAmount.toString(),
coinId,
symbol: isNft ? "NFT" : "UCT",
symbol,
iconUrl,
sizeBytes: JSON.stringify(txfToken).length,
});

Expand Down
Loading