thirdweb 5.90.3 → 5.91.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/cjs/contract/deployment/utils/create-2-factory.js +7 -0
  2. package/dist/cjs/contract/deployment/utils/create-2-factory.js.map +1 -1
  3. package/dist/cjs/react/core/hooks/pay/useBuyWithCryptoQuote.js +1 -0
  4. package/dist/cjs/react/core/hooks/pay/useBuyWithCryptoQuote.js.map +1 -1
  5. package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js +0 -1
  6. package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
  7. package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +0 -1
  8. package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
  9. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +1 -1
  10. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
  11. package/dist/cjs/react/web/utils/usePreloadWalletProviders.js +1 -34
  12. package/dist/cjs/react/web/utils/usePreloadWalletProviders.js.map +1 -1
  13. package/dist/cjs/version.js +1 -1
  14. package/dist/cjs/wallets/in-app/native/auth/passkeys.js +4 -4
  15. package/dist/cjs/wallets/in-app/native/auth/passkeys.js.map +1 -1
  16. package/dist/cjs/wallets/in-app/native/ecosystem.js +1 -0
  17. package/dist/cjs/wallets/in-app/native/ecosystem.js.map +1 -1
  18. package/dist/cjs/wallets/in-app/native/in-app.js +1 -0
  19. package/dist/cjs/wallets/in-app/native/in-app.js.map +1 -1
  20. package/dist/cjs/wallets/in-app/native/native-connector.js +1 -1
  21. package/dist/cjs/wallets/in-app/native/native-connector.js.map +1 -1
  22. package/dist/cjs/wallets/in-app/web/ecosystem.js +1 -0
  23. package/dist/cjs/wallets/in-app/web/ecosystem.js.map +1 -1
  24. package/dist/cjs/wallets/in-app/web/in-app.js +26 -0
  25. package/dist/cjs/wallets/in-app/web/in-app.js.map +1 -1
  26. package/dist/cjs/wallets/in-app/web/lib/auth/passkeys.js +4 -4
  27. package/dist/cjs/wallets/in-app/web/lib/auth/passkeys.js.map +1 -1
  28. package/dist/cjs/wallets/in-app/web/lib/web-connector.js +2 -2
  29. package/dist/cjs/wallets/in-app/web/lib/web-connector.js.map +1 -1
  30. package/dist/esm/contract/deployment/utils/create-2-factory.js +7 -0
  31. package/dist/esm/contract/deployment/utils/create-2-factory.js.map +1 -1
  32. package/dist/esm/react/core/hooks/pay/useBuyWithCryptoQuote.js +1 -0
  33. package/dist/esm/react/core/hooks/pay/useBuyWithCryptoQuote.js.map +1 -1
  34. package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js +0 -1
  35. package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
  36. package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +0 -1
  37. package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
  38. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +1 -1
  39. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
  40. package/dist/esm/react/web/utils/usePreloadWalletProviders.js +1 -34
  41. package/dist/esm/react/web/utils/usePreloadWalletProviders.js.map +1 -1
  42. package/dist/esm/version.js +1 -1
  43. package/dist/esm/wallets/in-app/native/auth/passkeys.js +4 -4
  44. package/dist/esm/wallets/in-app/native/auth/passkeys.js.map +1 -1
  45. package/dist/esm/wallets/in-app/native/ecosystem.js +1 -0
  46. package/dist/esm/wallets/in-app/native/ecosystem.js.map +1 -1
  47. package/dist/esm/wallets/in-app/native/in-app.js +1 -0
  48. package/dist/esm/wallets/in-app/native/in-app.js.map +1 -1
  49. package/dist/esm/wallets/in-app/native/native-connector.js +1 -1
  50. package/dist/esm/wallets/in-app/native/native-connector.js.map +1 -1
  51. package/dist/esm/wallets/in-app/web/ecosystem.js +1 -0
  52. package/dist/esm/wallets/in-app/web/ecosystem.js.map +1 -1
  53. package/dist/esm/wallets/in-app/web/in-app.js +26 -0
  54. package/dist/esm/wallets/in-app/web/in-app.js.map +1 -1
  55. package/dist/esm/wallets/in-app/web/lib/auth/passkeys.js +4 -4
  56. package/dist/esm/wallets/in-app/web/lib/auth/passkeys.js.map +1 -1
  57. package/dist/esm/wallets/in-app/web/lib/web-connector.js +2 -2
  58. package/dist/esm/wallets/in-app/web/lib/web-connector.js.map +1 -1
  59. package/dist/types/contract/deployment/utils/create-2-factory.d.ts.map +1 -1
  60. package/dist/types/exports/storage.d.ts +1 -0
  61. package/dist/types/exports/storage.d.ts.map +1 -1
  62. package/dist/types/react/core/hooks/pay/useBuyWithCryptoQuote.d.ts.map +1 -1
  63. package/dist/types/react/web/ui/ConnectWallet/ConnectButton.d.ts.map +1 -1
  64. package/dist/types/react/web/ui/ConnectWallet/Modal/ConnectEmbed.d.ts.map +1 -1
  65. package/dist/types/react/web/utils/usePreloadWalletProviders.d.ts +1 -3
  66. package/dist/types/react/web/utils/usePreloadWalletProviders.d.ts.map +1 -1
  67. package/dist/types/version.d.ts +1 -1
  68. package/dist/types/wallets/ecosystem/types.d.ts +5 -0
  69. package/dist/types/wallets/ecosystem/types.d.ts.map +1 -1
  70. package/dist/types/wallets/in-app/core/wallet/types.d.ts +5 -0
  71. package/dist/types/wallets/in-app/core/wallet/types.d.ts.map +1 -1
  72. package/dist/types/wallets/in-app/native/auth/passkeys.d.ts +2 -1
  73. package/dist/types/wallets/in-app/native/auth/passkeys.d.ts.map +1 -1
  74. package/dist/types/wallets/in-app/native/ecosystem.d.ts.map +1 -1
  75. package/dist/types/wallets/in-app/native/in-app.d.ts.map +1 -1
  76. package/dist/types/wallets/in-app/native/native-connector.d.ts +2 -0
  77. package/dist/types/wallets/in-app/native/native-connector.d.ts.map +1 -1
  78. package/dist/types/wallets/in-app/web/ecosystem.d.ts.map +1 -1
  79. package/dist/types/wallets/in-app/web/in-app.d.ts +25 -0
  80. package/dist/types/wallets/in-app/web/in-app.d.ts.map +1 -1
  81. package/dist/types/wallets/in-app/web/lib/auth/passkeys.d.ts +2 -1
  82. package/dist/types/wallets/in-app/web/lib/auth/passkeys.d.ts.map +1 -1
  83. package/dist/types/wallets/in-app/web/lib/web-connector.d.ts +1 -1
  84. package/dist/types/wallets/in-app/web/lib/web-connector.d.ts.map +1 -1
  85. package/dist/types/wallets/in-app/web/types.d.ts +5 -0
  86. package/dist/types/wallets/in-app/web/types.d.ts.map +1 -1
  87. package/package.json +1 -1
  88. package/src/contract/deployment/utils/create-2-factory.ts +8 -0
  89. package/src/exports/storage.ts +1 -0
  90. package/src/react/core/hooks/pay/useBuyWithCryptoQuote.ts +1 -0
  91. package/src/react/web/ui/ConnectWallet/ConnectButton.tsx +0 -1
  92. package/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx +0 -1
  93. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx +1 -1
  94. package/src/react/web/utils/usePreloadWalletProviders.ts +1 -49
  95. package/src/version.ts +1 -1
  96. package/src/wallets/ecosystem/types.ts +5 -0
  97. package/src/wallets/in-app/core/wallet/types.ts +5 -0
  98. package/src/wallets/in-app/native/auth/passkeys.ts +5 -3
  99. package/src/wallets/in-app/native/ecosystem.ts +1 -0
  100. package/src/wallets/in-app/native/in-app.ts +1 -0
  101. package/src/wallets/in-app/native/native-connector.ts +3 -2
  102. package/src/wallets/in-app/web/ecosystem.ts +1 -0
  103. package/src/wallets/in-app/web/in-app.ts +26 -0
  104. package/src/wallets/in-app/web/lib/auth/passkeys.ts +5 -3
  105. package/src/wallets/in-app/web/lib/web-connector.ts +2 -1
  106. package/src/wallets/in-app/web/types.ts +6 -1
  107. package/src/wallets/smart/smart-wallet-integration-v07.test.ts +7 -5
@@ -83,6 +83,7 @@ export function ecosystemWallet(
83
83
  return new InAppNativeConnector({
84
84
  client,
85
85
  ecosystem,
86
+ storage: createOptions?.storage,
86
87
  // TODO (enclave): passkeyDomain for ecosystem wallets
87
88
  });
88
89
  },
@@ -65,6 +65,7 @@ export function inAppWallet(
65
65
  return new InAppNativeConnector({
66
66
  client,
67
67
  passkeyDomain: createOptions?.auth?.passkeyDomain,
68
+ storage: createOptions?.storage,
68
69
  });
69
70
  },
70
71
  }) as Wallet<"inApp">;
@@ -1,5 +1,6 @@
1
1
  import type { ThirdwebClient } from "../../../client/client.js";
2
2
  import { stringify } from "../../../utils/json.js";
3
+ import type { AsyncStorage } from "../../../utils/storage/AsyncStorage.js";
3
4
  import { nativeLocalStorage } from "../../../utils/storage/nativeStorage.js";
4
5
  import type { Account } from "../../interfaces/wallet.js";
5
6
  import { getUserStatus } from "../core/actions/get-enclave-user-status.js";
@@ -37,11 +38,11 @@ import { sendOtp, verifyOtp } from "../web/lib/auth/otp.js";
37
38
  import { deleteActiveAccount, socialAuth } from "./auth/native-auth.js";
38
39
  import { logoutUser } from "./helpers/auth/logout.js";
39
40
  import { ShardedWallet } from "./helpers/wallet/sharded-wallet.js";
40
-
41
41
  type NativeConnectorOptions = {
42
42
  client: ThirdwebClient;
43
43
  ecosystem?: Ecosystem;
44
44
  passkeyDomain?: string;
45
+ storage?: AsyncStorage;
45
46
  };
46
47
 
47
48
  export class InAppNativeConnector implements InAppConnector {
@@ -56,7 +57,7 @@ export class InAppNativeConnector implements InAppConnector {
56
57
  this.passkeyDomain = options.passkeyDomain;
57
58
  this.ecosystem = options.ecosystem;
58
59
  this.storage = new ClientScopedStorage({
59
- storage: nativeLocalStorage,
60
+ storage: options.storage ?? nativeLocalStorage,
60
61
  clientId: this.client.clientId,
61
62
  ecosystem: options.ecosystem,
62
63
  });
@@ -73,6 +73,7 @@ export function ecosystemWallet(
73
73
  return new InAppWebConnector({
74
74
  client,
75
75
  ecosystem,
76
+ storage: createOptions?.storage,
76
77
  });
77
78
  },
78
79
  }) as Wallet<EcosystemWalletId>;
@@ -222,6 +222,31 @@ import { createInAppWallet } from "../core/wallet/in-app-core.js";
222
222
  * });
223
223
  * ```
224
224
  *
225
+ * ### Override storage for the wallet state
226
+ *
227
+ * By default, wallet state is stored in the browser's local storage. You can override this behavior by providing a custom storage object, useful for server side integrations.
228
+ *
229
+ * ```ts
230
+ * import { inAppWallet } from "thirdweb/wallets";
231
+ * import { AsyncStorage } from "thirdweb/storage";
232
+ *
233
+ * const myStorage: AsyncStorage = {
234
+ * getItem: async (key) => {
235
+ * return customGet(`CUSTOM_STORAGE_KEY${key}`);
236
+ * },
237
+ * setItem: async (key, value) => {
238
+ * return customSet(`CUSTOM_STORAGE_KEY${key}`, value);
239
+ * },
240
+ * removeItem: async (key) => {
241
+ * return customRemove(`CUSTOM_STORAGE_KEY${key}`);
242
+ * },
243
+ * };
244
+ *
245
+ * const wallet = inAppWallet({
246
+ * storage: myStorage,
247
+ * });
248
+ * ```
249
+ *
225
250
  * @returns The created in-app wallet.
226
251
  * @wallet
227
252
  */
@@ -235,6 +260,7 @@ export function inAppWallet(
235
260
  return new InAppWebConnector({
236
261
  client,
237
262
  passkeyDomain: createOptions?.auth?.passkeyDomain,
263
+ storage: createOptions?.storage,
238
264
  });
239
265
  },
240
266
  }) as Wallet<"inApp">;
@@ -1,5 +1,6 @@
1
1
  import { client, parsers } from "@passwordless-id/webauthn";
2
2
  import type { ThirdwebClient } from "../../../../../client/client.js";
3
+ import type { AsyncStorage } from "../../../../../utils/storage/AsyncStorage.js";
3
4
  import { webLocalStorage } from "../../../../../utils/storage/webStorage.js";
4
5
  import {
5
6
  base64ToString,
@@ -83,12 +84,13 @@ export class PasskeyWebClient implements PasskeyClient {
83
84
  export async function hasStoredPasskey(
84
85
  client: ThirdwebClient,
85
86
  ecosystemId?: EcosystemWalletId,
87
+ storage?: AsyncStorage,
86
88
  ) {
87
- const storage = new ClientScopedStorage({
88
- storage: webLocalStorage, // TODO (passkey) react native variant of this fn
89
+ const clientStorage = new ClientScopedStorage({
90
+ storage: storage ?? webLocalStorage, // TODO (passkey) react native variant of this fn
89
91
  clientId: client.clientId,
90
92
  ecosystem: ecosystemId ? { id: ecosystemId } : undefined,
91
93
  });
92
- const credId = await storage.getPasskeyCredentialId();
94
+ const credId = await clientStorage.getPasskeyCredentialId();
93
95
  return !!credId;
94
96
  }
@@ -74,6 +74,7 @@ export class InAppWebConnector implements InAppConnector {
74
74
  onAuthSuccess,
75
75
  ecosystem,
76
76
  passkeyDomain,
77
+ storage,
77
78
  }: InAppWalletConstructorType) {
78
79
  if (this.isClientIdLegacyPaper(client.clientId)) {
79
80
  throw new Error(
@@ -85,7 +86,7 @@ export class InAppWebConnector implements InAppConnector {
85
86
  this.ecosystem = ecosystem;
86
87
  this.passkeyDomain = passkeyDomain;
87
88
  this.storage = new ClientScopedStorage({
88
- storage: webLocalStorage,
89
+ storage: storage ?? webLocalStorage,
89
90
  clientId: client.clientId,
90
91
  ecosystem: ecosystem,
91
92
  });
@@ -2,11 +2,11 @@
2
2
  // types for class constructors still a little messy right now.
3
3
 
4
4
  import type { ThirdwebClient } from "../../../client/client.js";
5
+ import type { AsyncStorage } from "../../../utils/storage/AsyncStorage.js";
5
6
  import type { AuthAndWalletRpcReturnType } from "../core/authentication/types.js";
6
7
  import type { Ecosystem } from "../core/wallet/types.js";
7
8
  import type { InAppWalletIframeCommunicator } from "./utils/iFrameCommunication/InAppWalletIframeCommunicator.js";
8
9
 
9
- // Open to PRs from whoever sees this and knows of a cleaner way to handle things
10
10
  type ClientIdConstructorType = {
11
11
  /**
12
12
  * the clientId of your API Key. You can create an API key by creating a project on thirdweb dashboard.
@@ -29,6 +29,11 @@ export type InAppWalletConstructorType = ClientIdConstructorType & {
29
29
  * The domain of the passkey to use for authentication
30
30
  */
31
31
  passkeyDomain?: string;
32
+
33
+ /**
34
+ * The storage to use for storing wallet state
35
+ */
36
+ storage?: AsyncStorage;
32
37
  };
33
38
 
34
39
  export type ClientIdWithQuerierType = ClientIdConstructorType & {
@@ -8,8 +8,8 @@ import { parseEventLogs } from "../../event/actions/parse-logs.js";
8
8
  import { TEST_WALLET_A } from "~test/addresses.js";
9
9
  import { verifyEip1271Signature } from "../../auth/verify-hash.js";
10
10
  import { verifyTypedData } from "../../auth/verify-typed-data.js";
11
+ import { arbitrumSepolia } from "../../chains/chain-definitions/arbitrum-sepolia.js";
11
12
  import { baseSepolia } from "../../chains/chain-definitions/base-sepolia.js";
12
- import { sepolia } from "../../chains/chain-definitions/sepolia.js";
13
13
  import {
14
14
  addAdmin,
15
15
  adminUpdatedEvent,
@@ -41,12 +41,12 @@ let smartWalletAddress: string;
41
41
  let personalAccount: Account;
42
42
  let accountContract: ThirdwebContract;
43
43
 
44
- const chain = sepolia;
44
+ const chain = arbitrumSepolia;
45
45
  const client = TEST_CLIENT;
46
46
  const contract = getContract({
47
47
  client,
48
48
  chain,
49
- address: "0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8",
49
+ address: "0x6A7a26c9a595E6893C255C9dF0b593e77518e0c3",
50
50
  });
51
51
 
52
52
  describe.runIf(process.env.TW_SECRET_KEY).sequential(
@@ -132,6 +132,8 @@ describe.runIf(process.env.TW_SECRET_KEY).sequential(
132
132
  });
133
133
  await new Promise((resolve) => setTimeout(resolve, 3000)); // pause for a second to prevent race condition
134
134
 
135
+ expect(await isContractDeployed(accountContract)).toEqual(true);
136
+
135
137
  const signature = await smartAccount.signMessage({
136
138
  message: "hello world",
137
139
  });
@@ -201,10 +203,10 @@ describe.runIf(process.env.TW_SECRET_KEY).sequential(
201
203
  });
202
204
 
203
205
  await expect(tx).rejects.toMatchInlineSnapshot(`
204
- [TransactionError: Execution Reverted: {"code":3,"message":"execution reverted: Not authorized"}
206
+ [TransactionError: Error - Not authorized
205
207
 
206
208
  contract: ${contract.address}
207
- chainId: 11155111]
209
+ chainId: 421614]
208
210
  `);
209
211
  });
210
212