Skip to content

Commit eb13968

Browse files
committed
fix errorr in dash board
1 parent 15c2718 commit eb13968

1 file changed

Lines changed: 14 additions & 27 deletions

File tree

gateway-web/app/hooks/useStarknetContract.ts

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -159,28 +159,6 @@ export const useStarknetContract = () => {
159159
[getContract]
160160
);
161161

162-
// Add these helpers at the top of your useStarknetContract file
163-
const unwrapCairoOption = (value: any): any => {
164-
if (value && typeof value === "object" && "Some" in value) {
165-
return value.Some;
166-
}
167-
if (value && typeof value === "object" && "None" in value) {
168-
return undefined;
169-
}
170-
return value;
171-
};
172-
173-
const mapContractWalletToWallet = (contractWallet: any): Wallet => {
174-
return {
175-
chain_symbol: unwrapCairoOption(contractWallet.chain_symbol) ?? "",
176-
address: unwrapCairoOption(contractWallet.wallet_address) ?? "",
177-
memo: unwrapCairoOption(contractWallet.memo),
178-
tag: unwrapCairoOption(contractWallet.tag),
179-
metadata: unwrapCairoOption(contractWallet.metadata),
180-
updated_at: unwrapCairoOption(contractWallet.updated_at) ?? Date.now(),
181-
};
182-
};
183-
184162
const getUserWallets = useCallback(
185163
async (username: string): Promise<Wallet[]> => {
186164
setLoading(true);
@@ -190,11 +168,20 @@ export const useStarknetContract = () => {
190168
const contract = getContract();
191169
const wallets = await contract.get_all_user_wallets(username);
192170

193-
const processedWallets = (wallets as any[]).map(
194-
mapContractWalletToWallet
195-
);
196-
197-
return processedWallets;
171+
return wallets.map((wallet: any) => ({
172+
chain_symbol: wallet.chain_symbol,
173+
address:
174+
typeof wallet.address === "bigint"
175+
? "0x" + wallet.address.toString(16)
176+
: wallet.address,
177+
memo: wallet.memo?.Some ?? wallet.memo?.variant?.Some ?? undefined,
178+
tag: wallet.tag?.Some ?? wallet.tag?.variant?.Some ?? undefined,
179+
metadata:
180+
wallet.metadata?.Some ??
181+
wallet.metadata?.variant?.Some ??
182+
undefined,
183+
updated_at: wallet.updated_at,
184+
}));
198185
} catch (err) {
199186
const errorMessage =
200187
err instanceof Error ? err.message : "Failed to get wallets";

0 commit comments

Comments
 (0)