Skip to content

Commit 286aa30

Browse files
committed
Include chain overrides for all chains and not just custom chains in RSCs (#5197)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on refactoring the code in the `getContractFromParams.ts` file to improve readability. It mainly involves reordering and aligning the code without changing the logic. ### Detailed summary - Removed unnecessary line breaks for better readability. - Maintained the structure of the `if` statements and the `try-catch` block. - Ensured consistent formatting for the `chainOverrides.find` function. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent bb44352 commit 286aa30

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_utils/getContractFromParams.ts

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,25 @@ export async function getContractPageParamsInfo(params: {
2020
// move on
2121
}
2222

23-
if (!chainMetadata) {
24-
const cookieStore = cookies();
25-
const localChainStoreValue = cookieStore.get(TW_LOCAL_CHAIN_STORE)?.value;
23+
const cookieStore = cookies();
24+
const localChainStoreValue = cookieStore.get(TW_LOCAL_CHAIN_STORE)?.value;
2625

27-
if (localChainStoreValue) {
28-
try {
29-
const chains = JSON.parse(decodeURIComponent(localChainStoreValue));
30-
if (typeof chains === "object" && Array.isArray(chains)) {
31-
const chainOverrides = chains as ChainMetadata[];
32-
const chain = chainOverrides.find(
33-
(c) =>
34-
c.slug === chainSlugOrId ||
35-
c.chainId === Number.parseInt(chainSlugOrId),
36-
);
37-
if (chain) {
38-
chainMetadata = chain;
39-
}
26+
if (localChainStoreValue) {
27+
try {
28+
const chains = JSON.parse(decodeURIComponent(localChainStoreValue));
29+
if (typeof chains === "object" && Array.isArray(chains)) {
30+
const chainOverrides = chains as ChainMetadata[];
31+
const chain = chainOverrides.find(
32+
(c) =>
33+
c.slug === chainSlugOrId ||
34+
c.chainId === Number.parseInt(chainSlugOrId),
35+
);
36+
if (chain) {
37+
chainMetadata = chain;
4038
}
41-
} catch {
42-
// noop
4339
}
40+
} catch {
41+
// noop
4442
}
4543
}
4644

0 commit comments

Comments
 (0)