Skip to content

Commit 85d6074

Browse files
committed
[BLD-277] Fix Server Wallets balance fetching for custom chains (#8026)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on refactoring the code to utilize a new hook, `useGetV5DashboardChain`, which replaces the previous `defineChain` function in multiple files. This change enhances the code's readability and maintainability by standardizing the method of retrieving chain information. ### Detailed summary - Replaced `defineChain` with `useGetV5DashboardChain` in `useAbiProcessing.ts`. - Updated the `chain` variable initialization in `ServerWalletTableRow` to use `useV5DashboardChain`. - Modified the `chain` parameter in `WalletBalanceCell` to utilize `useV5DashboardChain` instead of `defineChain`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Unified chain handling across wallet tables and webhook ABI processing using a new dashboard adapter, improving consistency and reliability. * Streamlined balance and smart account address resolution to reduce redundant computations and potential mismatches. * Internal imports and hooks updated without changing public interfaces or user workflows. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 2f6f3a0 commit 85d6074

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/transactions/server-wallets/wallet-table/wallet-table-ui.client.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import {
99
XIcon,
1010
} from "lucide-react";
1111
import Link from "next/link";
12-
import { useMemo, useState } from "react";
13-
import { defineChain, type ThirdwebClient } from "thirdweb";
12+
import { useState } from "react";
13+
import type { ThirdwebClient } from "thirdweb";
1414
import { useWalletBalance } from "thirdweb/react";
1515
import {
1616
DEFAULT_ACCOUNT_FACTORY_V0_7,
@@ -48,6 +48,7 @@ import {
4848
TableRow,
4949
} from "@/components/ui/table";
5050
import { ToolTipLabel } from "@/components/ui/tooltip";
51+
import { useV5DashboardChain } from "@/hooks/chains/v5-adapter";
5152
import { WalletProductIcon } from "@/icons/WalletProductIcon";
5253
import { cn } from "@/lib/utils";
5354
import CreateServerWallet from "../components/create-server-wallet.client";
@@ -277,10 +278,7 @@ function ServerWalletTableRow(props: {
277278
const { wallet, project, teamSlug, client, chainId, showSmartAccount } =
278279
props;
279280

280-
const chain = useMemo(() => {
281-
// eslint-disable-next-line no-restricted-syntax
282-
return defineChain(chainId);
283-
}, [chainId]);
281+
const chain = useV5DashboardChain(chainId);
284282

285283
const smartAccountAddressQuery = useQuery({
286284
queryFn: async () => {
@@ -458,10 +456,10 @@ function WalletBalanceCell(props: {
458456
chainId: number;
459457
client: ThirdwebClient;
460458
}) {
459+
const chain = useV5DashboardChain(props.chainId);
461460
const balance = useWalletBalance({
462461
address: props.address,
463-
// eslint-disable-next-line no-restricted-syntax
464-
chain: defineChain(props.chainId),
462+
chain: chain,
465463
client: props.client,
466464
});
467465

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/hooks/useAbiProcessing.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import { useQuery } from "@tanstack/react-query";
44
import { useMemo } from "react";
55
import type { ThirdwebClient } from "thirdweb";
6-
import { defineChain } from "thirdweb/chains";
76
import { getContract, resolveAbiFromContractApi } from "thirdweb/contract";
7+
import { useGetV5DashboardChain } from "@/hooks/chains/v5-adapter";
88
import { parseAddresses } from "../utils/webhookPayloadUtils";
99
import type {
1010
AbiData,
@@ -29,6 +29,7 @@ export function useAbiMultiFetch({
2929
) => EventSignature[] | FunctionSignature[];
3030
type: "event" | "transaction";
3131
}) {
32+
const getChain = useGetV5DashboardChain();
3233
const pairs = useMemo(() => {
3334
const result: { chainId: string; address: string }[] = [];
3435
const seen = new Set<string>();
@@ -54,8 +55,7 @@ export function useAbiMultiFetch({
5455
return Promise.all(
5556
pairs.map(async ({ chainId, address }) => {
5657
try {
57-
// eslint-disable-next-line no-restricted-syntax
58-
const chainObj = defineChain(Number(chainId));
58+
const chainObj = getChain(Number(chainId));
5959
const contract = getContract({
6060
address,
6161
chain: chainObj,

0 commit comments

Comments
 (0)