Skip to content

Commit dabe685

Browse files
committed
better messaging for v4 incompatible wallets
1 parent 37d9c31 commit dabe685

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/shared/utils/cache/get-contract.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { StatusCodes } from "http-status-codes";
33
import { createCustomError } from "../../../server/middleware/error";
44
import { abiSchema } from "../../../server/schemas/contract";
55
import { getSdk } from "./get-sdk";
6+
import { ThirdwebSDK } from "@thirdweb-dev/sdk";
67

78
const abiArraySchema = Type.Array(abiSchema);
89

@@ -21,7 +22,17 @@ export const getContract = async ({
2122
accountAddress,
2223
abi,
2324
}: GetContractParams) => {
24-
const sdk = await getSdk({ chainId, walletAddress, accountAddress });
25+
let sdk: ThirdwebSDK;
26+
27+
try {
28+
sdk = await getSdk({ chainId, walletAddress, accountAddress });
29+
} catch (e) {
30+
throw createCustomError(
31+
`Could not get SDK: ${e}`,
32+
StatusCodes.BAD_REQUEST,
33+
"INVALID_CHAIN_OR_WALLET_TYPE_FOR_ROUTE",
34+
);
35+
}
2536

2637
try {
2738
if (abi) {

0 commit comments

Comments
 (0)