Skip to content

Commit 8625cba

Browse files
chore: update getChainByChainId -> getChainByChainIdAsync (#370)
1 parent 5479cdf commit 8625cba

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/server/utils/chain.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Static } from "@sinclair/typebox";
2-
import { allChains, getChainByChainId } from "@thirdweb-dev/chains";
2+
import { allChains, getChainByChainIdAsync } from "@thirdweb-dev/chains";
33
import { getConfig } from "../../utils/cache/getConfig";
44
import { networkResponseSchema } from "../../utils/cache/getSdk";
55

@@ -26,8 +26,9 @@ export const getChainIdFromChain = async (chain: string): Promise<number> => {
2626
if (!isNaN(parseInt(chain))) {
2727
const unknownChainId = parseInt(chain);
2828
try {
29+
const chain = await getChainByChainIdAsync(unknownChainId);
2930
// If the chain id is for a supported chain, use the chain id
30-
if (getChainByChainId(unknownChainId)) {
31+
if (chain) {
3132
chainId = unknownChainId;
3233
}
3334
} catch {
@@ -40,7 +41,7 @@ export const getChainIdFromChain = async (chain: string): Promise<number> => {
4041
);
4142
}
4243
}
43-
// If the chain id is unsupported, getChainByChainId will throw
44+
// If the chain id is unsupported, getChainByChainIdAsync will throw
4445
}
4546
} else {
4647
if (config?.chainOverrides) {

src/server/utils/wallets/getLocalWallet.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Static } from "@sinclair/typebox";
2-
import { Chain, getChainByChainId } from "@thirdweb-dev/chains";
3-
import { LocalWallet } from "@thirdweb-dev/wallets";
2+
import { getChainByChainIdAsync } from "@thirdweb-dev/chains";
3+
import { Chain, LocalWallet } from "@thirdweb-dev/wallets";
44
import { getWalletDetails } from "../../../db/wallets/getWalletDetails";
55
import { getConfig } from "../../../utils/cache/getConfig";
66
import { networkResponseSchema } from "../../../utils/cache/getSdk";
@@ -21,7 +21,7 @@ export const getLocalWallet = async ({
2121
const config = await getConfig();
2222
const CHAIN_OVERRIDES = config.chainOverrides;
2323
try {
24-
chain = getChainByChainId(chainId);
24+
chain = await getChainByChainIdAsync(chainId);
2525
} catch (error) {}
2626

2727
if (CHAIN_OVERRIDES) {

src/utils/cache/getSdk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Static, Type } from "@sinclair/typebox";
2-
import { getChainByChainId } from "@thirdweb-dev/chains";
2+
import { getChainByChainIdAsync } from "@thirdweb-dev/chains";
33
import { NetworkInput, ThirdwebSDK } from "@thirdweb-dev/sdk";
44
import * as fs from "fs";
55
import { PrismaTransaction } from "../../schema/prisma";
@@ -76,7 +76,7 @@ export const getSdk = async ({
7676

7777
let chain: NetworkInput | undefined = undefined;
7878
try {
79-
chain = getChainByChainId(chainId);
79+
chain = await getChainByChainIdAsync(chainId);
8080
} catch (error) {}
8181

8282
if (CHAIN_OVERRIDES) {

0 commit comments

Comments
 (0)