Skip to content

Commit d1e7560

Browse files
committed
fixup! feat(sdk): makes chain optional in smart wallet config
1 parent cadb36f commit d1e7560

File tree

3 files changed

+68
-4
lines changed

3 files changed

+68
-4
lines changed

packages/thirdweb/src/wallets/smart/lib/calls.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Chain } from "../../../chains/types.js";
2+
import { getCachedChain } from "../../../chains/utils.js";
23
import type { ThirdwebClient } from "../../../client/client.js";
34
import {
45
type ThirdwebContract,
@@ -29,7 +30,7 @@ import { DEFAULT_ACCOUNT_FACTORY_V0_6 } from "./constants.js";
2930
*/
3031
export async function predictSmartAccountAddress(args: {
3132
client: ThirdwebClient;
32-
chain: Chain;
33+
chain?: Chain;
3334
adminAddress: string;
3435
factoryAddress?: string;
3536
accountSalt?: string;
@@ -39,7 +40,7 @@ export async function predictSmartAccountAddress(args: {
3940
accountSalt: args.accountSalt,
4041
factoryContract: getContract({
4142
address: args.factoryAddress ?? DEFAULT_ACCOUNT_FACTORY_V0_6,
42-
chain: args.chain,
43+
chain: args.chain ?? getCachedChain(1),
4344
client: args.client,
4445
}),
4546
});

packages/thirdweb/src/wallets/smart/smart-wallet-integration-v07.test.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,31 @@ describe.runIf(process.env.TW_SECRET_KEY)(
7777
});
7878
});
7979

80-
it("can connect", async () => {
80+
it("can deploy with default chain", async () => {
81+
const wallet = smartWallet({
82+
gasless: true,
83+
factoryAddress: DEFAULT_ACCOUNT_FACTORY_V0_7,
84+
});
85+
const smartAccount = await wallet.connect({
86+
client: TEST_CLIENT,
87+
personalAccount,
88+
});
89+
expect(smartAccount.address).toHaveLength(42);
90+
91+
const signature = await smartAccount.signMessage({
92+
message: "hello world",
93+
});
94+
const isValid = await verifySignature({
95+
message: "hello world",
96+
signature,
97+
address: smartWalletAddress,
98+
chain: wallet.getChain(),
99+
client,
100+
});
101+
expect(isValid).toEqual(true);
102+
});
103+
104+
it("can predict account address", async () => {
81105
expect(smartWalletAddress).toHaveLength(42);
82106
const predictedAddress = await predictSmartAccountAddress({
83107
client,
@@ -88,6 +112,15 @@ describe.runIf(process.env.TW_SECRET_KEY)(
88112
expect(predictedAddress).toEqual(smartWalletAddress);
89113
});
90114

115+
it("can predict account address with default chain", async () => {
116+
const predictedAddress = await predictSmartAccountAddress({
117+
client,
118+
adminAddress: personalAccount.address,
119+
factoryAddress: DEFAULT_ACCOUNT_FACTORY_V0_7,
120+
});
121+
expect(predictedAddress).toEqual(smartWalletAddress);
122+
});
123+
91124
it("can sign a msg", async () => {
92125
const signature = await smartAccount.signMessage({
93126
message: "hello world",

packages/thirdweb/src/wallets/smart/smart-wallet-integration.test.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,29 @@ describe.runIf(process.env.TW_SECRET_KEY).sequential(
7474
});
7575
});
7676

77-
it("can connect", async () => {
77+
it("can deploy with default chain", async () => {
78+
const wallet = smartWallet({
79+
gasless: true,
80+
});
81+
const smartAccount = await wallet.connect({
82+
client: TEST_CLIENT,
83+
personalAccount,
84+
});
85+
expect(smartAccount.address).toHaveLength(42);
86+
const signature = await smartAccount.signMessage({
87+
message: "hello world",
88+
});
89+
const isValid = await verifySignature({
90+
message: "hello world",
91+
signature,
92+
address: smartWalletAddress,
93+
chain: wallet.getChain(),
94+
client,
95+
});
96+
expect(isValid).toEqual(true);
97+
});
98+
99+
it("can predict account address", async () => {
78100
expect(smartWalletAddress).toHaveLength(42);
79101
const predictedAddress = await predictSmartAccountAddress({
80102
client,
@@ -84,6 +106,14 @@ describe.runIf(process.env.TW_SECRET_KEY).sequential(
84106
expect(predictedAddress).toEqual(smartWalletAddress);
85107
});
86108

109+
it("can predict account address with default chain", async () => {
110+
const predictedAddress = await predictSmartAccountAddress({
111+
client,
112+
adminAddress: personalAccount.address,
113+
});
114+
expect(predictedAddress).toEqual(smartWalletAddress);
115+
});
116+
87117
it("can sign a msg", async () => {
88118
const signature = await smartAccount.signMessage({
89119
message: "hello world",

0 commit comments

Comments
 (0)