Skip to content

Commit 48553c5

Browse files
authored
Pass chain for local wallet (#145)
1 parent 5eff958 commit 48553c5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

core/sdk/sdk.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export const getSDK = async (
183183
}
184184

185185
const wallet = getAwsKmsWallet({ awsKmsKeyId });
186+
// Note: if wallet has a chain, it will get used instead of chain specified here
186187
sdk = await ThirdwebSDK.fromWallet(wallet, chain, {
187188
secretKey: THIRDWEB_API_SECRET_KEY,
188189
supportedChains: RPC_OVERRIDES,
@@ -198,14 +199,16 @@ export const getSDK = async (
198199
}
199200

200201
const signer = getGcpKmsSigner({ gcpKmsKeyId, gcpKmsKeyVersionId });
202+
// Note: if signer has a chain, it will get used instead of chain specified here
201203
sdk = ThirdwebSDK.fromSigner(signer, chain, {
202204
secretKey: THIRDWEB_API_SECRET_KEY,
203205
supportedChains: RPC_OVERRIDES,
204206
});
205207
cacheSdk(chain.name, sdk, walletAddress);
206208
return sdk;
207209
} else if (walletType === WalletType.local) {
208-
const wallet = await getLocalWallet({ walletAddress });
210+
const wallet = await getLocalWallet({ chain, walletAddress });
211+
// Note: chain doesn't actually get respected here, comes from wallet
209212
sdk = await ThirdwebSDK.fromWallet(wallet, chain, {
210213
secretKey: THIRDWEB_API_SECRET_KEY,
211214
supportedChains: RPC_OVERRIDES,

server/utils/wallets/getLocalWallet.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
import { Chain } from "@thirdweb-dev/chains";
12
import { LocalWallet } from "@thirdweb-dev/wallets";
23
import { LocalFileStorage } from "../../../core";
34
import { env } from "../../../core/env";
45

56
interface GetLocalWalletParams {
7+
chain: Chain;
68
walletAddress: string;
79
}
810

911
export const getLocalWallet = async ({
12+
chain,
1013
walletAddress,
1114
}: GetLocalWalletParams) => {
12-
const wallet = new LocalWallet();
15+
const wallet = new LocalWallet({ chain });
1316
await wallet.load({
1417
strategy: "encryptedJson",
1518
password: env.THIRDWEB_API_SECRET_KEY,

0 commit comments

Comments
 (0)