thirdweb 5.64.5 → 5.65.0-nightly-7a9713e877eb20b4e0d95964125b295feafc931a-20241102000323

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 (236) hide show
  1. package/dist/cjs/auth/core/verify-jwt.js +2 -1
  2. package/dist/cjs/auth/core/verify-jwt.js.map +1 -1
  3. package/dist/cjs/extensions/erc721/drops/write/claimToBatch.js +8 -7
  4. package/dist/cjs/extensions/erc721/drops/write/claimToBatch.js.map +1 -1
  5. package/dist/cjs/pay/buyWithCrypto/getQuote.js +2 -1
  6. package/dist/cjs/pay/buyWithCrypto/getQuote.js.map +1 -1
  7. package/dist/cjs/pay/buyWithCrypto/getTransfer.js +2 -1
  8. package/dist/cjs/pay/buyWithCrypto/getTransfer.js.map +1 -1
  9. package/dist/cjs/pay/buyWithFiat/getQuote.js +2 -1
  10. package/dist/cjs/pay/buyWithFiat/getQuote.js.map +1 -1
  11. package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js +14 -0
  12. package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
  13. package/dist/cjs/react/web/ui/ConnectWallet/Details.js +5 -4
  14. package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
  15. package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewAssets.js +29 -11
  16. package/dist/cjs/react/web/ui/ConnectWallet/screens/ViewAssets.js.map +1 -1
  17. package/dist/cjs/rpc/rpc.js +2 -1
  18. package/dist/cjs/rpc/rpc.js.map +1 -1
  19. package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js +1 -10
  20. package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
  21. package/dist/cjs/utils/extensions/airdrop/process-snapshot-erc1155.js +3 -2
  22. package/dist/cjs/utils/extensions/airdrop/process-snapshot-erc1155.js.map +1 -1
  23. package/dist/cjs/utils/extensions/airdrop/process-snapshot-erc20.js +3 -2
  24. package/dist/cjs/utils/extensions/airdrop/process-snapshot-erc20.js.map +1 -1
  25. package/dist/cjs/utils/extensions/airdrop/process-snapshot-erc721.js +3 -2
  26. package/dist/cjs/utils/extensions/airdrop/process-snapshot-erc721.js.map +1 -1
  27. package/dist/cjs/utils/extensions/drops/process-override-list.js +3 -2
  28. package/dist/cjs/utils/extensions/drops/process-override-list.js.map +1 -1
  29. package/dist/cjs/utils/jwt/encode-jwt.js +5 -2
  30. package/dist/cjs/utils/jwt/encode-jwt.js.map +1 -1
  31. package/dist/cjs/utils/storage/walletStorage.js +4 -3
  32. package/dist/cjs/utils/storage/walletStorage.js.map +1 -1
  33. package/dist/cjs/version.js +1 -1
  34. package/dist/cjs/version.js.map +1 -1
  35. package/dist/cjs/wallets/in-app/core/authentication/authEndpoint.js +2 -1
  36. package/dist/cjs/wallets/in-app/core/authentication/authEndpoint.js.map +1 -1
  37. package/dist/cjs/wallets/in-app/core/authentication/guest.js +2 -1
  38. package/dist/cjs/wallets/in-app/core/authentication/guest.js.map +1 -1
  39. package/dist/cjs/wallets/in-app/core/authentication/jwt.js +2 -1
  40. package/dist/cjs/wallets/in-app/core/authentication/jwt.js.map +1 -1
  41. package/dist/cjs/wallets/in-app/core/authentication/linkAccount.js +2 -1
  42. package/dist/cjs/wallets/in-app/core/authentication/linkAccount.js.map +1 -1
  43. package/dist/cjs/wallets/in-app/core/authentication/passkeys.js +3 -2
  44. package/dist/cjs/wallets/in-app/core/authentication/passkeys.js.map +1 -1
  45. package/dist/cjs/wallets/in-app/core/authentication/siwe.js +2 -1
  46. package/dist/cjs/wallets/in-app/core/authentication/siwe.js.map +1 -1
  47. package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js +2 -1
  48. package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
  49. package/dist/cjs/wallets/in-app/native/helpers/api/fetchers.js +5 -4
  50. package/dist/cjs/wallets/in-app/native/helpers/api/fetchers.js.map +1 -1
  51. package/dist/cjs/wallets/in-app/native/helpers/errors.js +2 -1
  52. package/dist/cjs/wallets/in-app/native/helpers/errors.js.map +1 -1
  53. package/dist/cjs/wallets/in-app/native/helpers/storage/local.js +2 -1
  54. package/dist/cjs/wallets/in-app/native/helpers/storage/local.js.map +1 -1
  55. package/dist/cjs/wallets/in-app/native/helpers/wallet/migration.js +4 -3
  56. package/dist/cjs/wallets/in-app/native/helpers/wallet/migration.js.map +1 -1
  57. package/dist/cjs/wallets/in-app/native/helpers/wallet/recoveryCode.js +5 -4
  58. package/dist/cjs/wallets/in-app/native/helpers/wallet/recoveryCode.js.map +1 -1
  59. package/dist/cjs/wallets/in-app/web/lib/auth/otp.js +3 -2
  60. package/dist/cjs/wallets/in-app/web/lib/auth/otp.js.map +1 -1
  61. package/dist/cjs/wallets/manager/index.js +4 -3
  62. package/dist/cjs/wallets/manager/index.js.map +1 -1
  63. package/dist/cjs/wallets/smart/lib/bundler.js +1 -1
  64. package/dist/cjs/wallets/smart/lib/bundler.js.map +1 -1
  65. package/dist/cjs/wallets/smart/lib/paymaster.js +2 -1
  66. package/dist/cjs/wallets/smart/lib/paymaster.js.map +1 -1
  67. package/dist/cjs/wallets/smart/smart-wallet.js +14 -10
  68. package/dist/cjs/wallets/smart/smart-wallet.js.map +1 -1
  69. package/dist/cjs/wallets/wallet-connect/controller.js +2 -1
  70. package/dist/cjs/wallets/wallet-connect/controller.js.map +1 -1
  71. package/dist/cjs/wallets/wallet-connect/receiver/session-store.js +3 -2
  72. package/dist/cjs/wallets/wallet-connect/receiver/session-store.js.map +1 -1
  73. package/dist/esm/auth/core/verify-jwt.js +2 -1
  74. package/dist/esm/auth/core/verify-jwt.js.map +1 -1
  75. package/dist/esm/extensions/erc721/drops/write/claimToBatch.js +8 -7
  76. package/dist/esm/extensions/erc721/drops/write/claimToBatch.js.map +1 -1
  77. package/dist/esm/pay/buyWithCrypto/getQuote.js +2 -1
  78. package/dist/esm/pay/buyWithCrypto/getQuote.js.map +1 -1
  79. package/dist/esm/pay/buyWithCrypto/getTransfer.js +2 -1
  80. package/dist/esm/pay/buyWithCrypto/getTransfer.js.map +1 -1
  81. package/dist/esm/pay/buyWithFiat/getQuote.js +2 -1
  82. package/dist/esm/pay/buyWithFiat/getQuote.js.map +1 -1
  83. package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js +14 -0
  84. package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
  85. package/dist/esm/react/web/ui/ConnectWallet/Details.js +5 -4
  86. package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
  87. package/dist/esm/react/web/ui/ConnectWallet/screens/ViewAssets.js +30 -12
  88. package/dist/esm/react/web/ui/ConnectWallet/screens/ViewAssets.js.map +1 -1
  89. package/dist/esm/rpc/rpc.js +2 -1
  90. package/dist/esm/rpc/rpc.js.map +1 -1
  91. package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js +1 -10
  92. package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
  93. package/dist/esm/utils/extensions/airdrop/process-snapshot-erc1155.js +3 -2
  94. package/dist/esm/utils/extensions/airdrop/process-snapshot-erc1155.js.map +1 -1
  95. package/dist/esm/utils/extensions/airdrop/process-snapshot-erc20.js +3 -2
  96. package/dist/esm/utils/extensions/airdrop/process-snapshot-erc20.js.map +1 -1
  97. package/dist/esm/utils/extensions/airdrop/process-snapshot-erc721.js +3 -2
  98. package/dist/esm/utils/extensions/airdrop/process-snapshot-erc721.js.map +1 -1
  99. package/dist/esm/utils/extensions/drops/process-override-list.js +3 -2
  100. package/dist/esm/utils/extensions/drops/process-override-list.js.map +1 -1
  101. package/dist/esm/utils/jwt/encode-jwt.js +5 -2
  102. package/dist/esm/utils/jwt/encode-jwt.js.map +1 -1
  103. package/dist/esm/utils/storage/walletStorage.js +4 -3
  104. package/dist/esm/utils/storage/walletStorage.js.map +1 -1
  105. package/dist/esm/version.js +1 -1
  106. package/dist/esm/version.js.map +1 -1
  107. package/dist/esm/wallets/in-app/core/authentication/authEndpoint.js +2 -1
  108. package/dist/esm/wallets/in-app/core/authentication/authEndpoint.js.map +1 -1
  109. package/dist/esm/wallets/in-app/core/authentication/guest.js +2 -1
  110. package/dist/esm/wallets/in-app/core/authentication/guest.js.map +1 -1
  111. package/dist/esm/wallets/in-app/core/authentication/jwt.js +2 -1
  112. package/dist/esm/wallets/in-app/core/authentication/jwt.js.map +1 -1
  113. package/dist/esm/wallets/in-app/core/authentication/linkAccount.js +2 -1
  114. package/dist/esm/wallets/in-app/core/authentication/linkAccount.js.map +1 -1
  115. package/dist/esm/wallets/in-app/core/authentication/passkeys.js +3 -2
  116. package/dist/esm/wallets/in-app/core/authentication/passkeys.js.map +1 -1
  117. package/dist/esm/wallets/in-app/core/authentication/siwe.js +2 -1
  118. package/dist/esm/wallets/in-app/core/authentication/siwe.js.map +1 -1
  119. package/dist/esm/wallets/in-app/core/wallet/in-app-core.js +2 -1
  120. package/dist/esm/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
  121. package/dist/esm/wallets/in-app/native/helpers/api/fetchers.js +5 -4
  122. package/dist/esm/wallets/in-app/native/helpers/api/fetchers.js.map +1 -1
  123. package/dist/esm/wallets/in-app/native/helpers/errors.js +2 -1
  124. package/dist/esm/wallets/in-app/native/helpers/errors.js.map +1 -1
  125. package/dist/esm/wallets/in-app/native/helpers/storage/local.js +2 -1
  126. package/dist/esm/wallets/in-app/native/helpers/storage/local.js.map +1 -1
  127. package/dist/esm/wallets/in-app/native/helpers/wallet/migration.js +4 -3
  128. package/dist/esm/wallets/in-app/native/helpers/wallet/migration.js.map +1 -1
  129. package/dist/esm/wallets/in-app/native/helpers/wallet/recoveryCode.js +5 -4
  130. package/dist/esm/wallets/in-app/native/helpers/wallet/recoveryCode.js.map +1 -1
  131. package/dist/esm/wallets/in-app/web/lib/auth/otp.js +3 -2
  132. package/dist/esm/wallets/in-app/web/lib/auth/otp.js.map +1 -1
  133. package/dist/esm/wallets/manager/index.js +4 -3
  134. package/dist/esm/wallets/manager/index.js.map +1 -1
  135. package/dist/esm/wallets/smart/lib/bundler.js +1 -1
  136. package/dist/esm/wallets/smart/lib/bundler.js.map +1 -1
  137. package/dist/esm/wallets/smart/lib/paymaster.js +2 -1
  138. package/dist/esm/wallets/smart/lib/paymaster.js.map +1 -1
  139. package/dist/esm/wallets/smart/smart-wallet.js +14 -10
  140. package/dist/esm/wallets/smart/smart-wallet.js.map +1 -1
  141. package/dist/esm/wallets/wallet-connect/controller.js +2 -1
  142. package/dist/esm/wallets/wallet-connect/controller.js.map +1 -1
  143. package/dist/esm/wallets/wallet-connect/receiver/session-store.js +3 -2
  144. package/dist/esm/wallets/wallet-connect/receiver/session-store.js.map +1 -1
  145. package/dist/types/auth/core/verify-jwt.d.ts.map +1 -1
  146. package/dist/types/extensions/erc721/drops/write/claimToBatch.d.ts.map +1 -1
  147. package/dist/types/pay/buyWithCrypto/getQuote.d.ts.map +1 -1
  148. package/dist/types/pay/buyWithCrypto/getTransfer.d.ts.map +1 -1
  149. package/dist/types/pay/buyWithFiat/getQuote.d.ts.map +1 -1
  150. package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts +7 -0
  151. package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts.map +1 -1
  152. package/dist/types/react/web/ui/ConnectWallet/ConnectButton.d.ts +14 -0
  153. package/dist/types/react/web/ui/ConnectWallet/ConnectButton.d.ts.map +1 -1
  154. package/dist/types/react/web/ui/ConnectWallet/Details.d.ts +7 -0
  155. package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
  156. package/dist/types/react/web/ui/ConnectWallet/screens/ViewAssets.d.ts +5 -0
  157. package/dist/types/react/web/ui/ConnectWallet/screens/ViewAssets.d.ts.map +1 -1
  158. package/dist/types/rpc/rpc.d.ts.map +1 -1
  159. package/dist/types/utils/any-evm/zksync/isZkSyncChain.d.ts.map +1 -1
  160. package/dist/types/utils/extensions/airdrop/process-snapshot-erc1155.d.ts.map +1 -1
  161. package/dist/types/utils/extensions/airdrop/process-snapshot-erc20.d.ts.map +1 -1
  162. package/dist/types/utils/extensions/airdrop/process-snapshot-erc721.d.ts.map +1 -1
  163. package/dist/types/utils/extensions/drops/process-override-list.d.ts.map +1 -1
  164. package/dist/types/utils/jwt/encode-jwt.d.ts.map +1 -1
  165. package/dist/types/utils/storage/walletStorage.d.ts.map +1 -1
  166. package/dist/types/version.d.ts +1 -1
  167. package/dist/types/version.d.ts.map +1 -1
  168. package/dist/types/wallets/in-app/core/authentication/authEndpoint.d.ts.map +1 -1
  169. package/dist/types/wallets/in-app/core/authentication/guest.d.ts.map +1 -1
  170. package/dist/types/wallets/in-app/core/authentication/jwt.d.ts.map +1 -1
  171. package/dist/types/wallets/in-app/core/authentication/linkAccount.d.ts.map +1 -1
  172. package/dist/types/wallets/in-app/core/authentication/passkeys.d.ts.map +1 -1
  173. package/dist/types/wallets/in-app/core/authentication/siwe.d.ts.map +1 -1
  174. package/dist/types/wallets/in-app/core/wallet/in-app-core.d.ts.map +1 -1
  175. package/dist/types/wallets/in-app/native/helpers/api/fetchers.d.ts.map +1 -1
  176. package/dist/types/wallets/in-app/native/helpers/errors.d.ts.map +1 -1
  177. package/dist/types/wallets/in-app/native/helpers/storage/local.d.ts.map +1 -1
  178. package/dist/types/wallets/in-app/native/helpers/wallet/migration.d.ts.map +1 -1
  179. package/dist/types/wallets/in-app/native/helpers/wallet/recoveryCode.d.ts.map +1 -1
  180. package/dist/types/wallets/in-app/web/lib/auth/otp.d.ts.map +1 -1
  181. package/dist/types/wallets/manager/index.d.ts.map +1 -1
  182. package/dist/types/wallets/smart/lib/paymaster.d.ts.map +1 -1
  183. package/dist/types/wallets/smart/smart-wallet.d.ts.map +1 -1
  184. package/dist/types/wallets/wallet-connect/controller.d.ts.map +1 -1
  185. package/dist/types/wallets/wallet-connect/receiver/session-store.d.ts.map +1 -1
  186. package/package.json +1 -1
  187. package/src/auth/core/verify-jwt.ts +2 -1
  188. package/src/extensions/erc1155/drop1155.test.ts +12 -1
  189. package/src/extensions/erc1155/token1155.test.ts +12 -1
  190. package/src/extensions/erc1155/write/mintAdditionalSupplyToBatch.test.ts +0 -1
  191. package/src/extensions/erc20/drop20.test.ts +11 -2
  192. package/src/extensions/erc721/drop721.test.ts +10 -7
  193. package/src/extensions/erc721/drops/write/claimToBatch.ts +10 -11
  194. package/src/extensions/erc721/read/getNFT.test.ts +0 -67
  195. package/src/extensions/erc721/read/getNFTs.test.ts +0 -32
  196. package/src/extensions/erc721/token721.test.ts +115 -0
  197. package/src/extensions/prebuilts/deploy-erc721.test.ts +0 -42
  198. package/src/pay/buyWithCrypto/getQuote.ts +2 -1
  199. package/src/pay/buyWithCrypto/getTransfer.ts +2 -1
  200. package/src/pay/buyWithFiat/getQuote.ts +2 -1
  201. package/src/react/core/hooks/connection/ConnectButtonProps.ts +8 -0
  202. package/src/react/web/ui/ConnectWallet/ConnectButton.tsx +14 -0
  203. package/src/react/web/ui/ConnectWallet/Details.tsx +30 -16
  204. package/src/react/web/ui/ConnectWallet/screens/ViewAssets.tsx +46 -24
  205. package/src/rpc/rpc.ts +2 -1
  206. package/src/utils/any-evm/zksync/isZkSyncChain.ts +1 -9
  207. package/src/utils/extensions/airdrop/process-snapshot-erc1155.ts +3 -2
  208. package/src/utils/extensions/airdrop/process-snapshot-erc20.ts +3 -2
  209. package/src/utils/extensions/airdrop/process-snapshot-erc721.ts +3 -2
  210. package/src/utils/extensions/drops/process-override-list.ts +3 -2
  211. package/src/utils/jwt/encode-jwt.ts +5 -5
  212. package/src/utils/nft/fetch-token-metadata.test.ts +2 -1
  213. package/src/utils/storage/walletStorage.ts +4 -3
  214. package/src/version.ts +1 -1
  215. package/src/wallets/in-app/core/authentication/authEndpoint.ts +2 -1
  216. package/src/wallets/in-app/core/authentication/guest.ts +2 -1
  217. package/src/wallets/in-app/core/authentication/jwt.ts +2 -1
  218. package/src/wallets/in-app/core/authentication/linkAccount.ts +2 -1
  219. package/src/wallets/in-app/core/authentication/passkeys.ts +3 -2
  220. package/src/wallets/in-app/core/authentication/siwe.ts +2 -1
  221. package/src/wallets/in-app/core/wallet/in-app-core.ts +2 -1
  222. package/src/wallets/in-app/native/helpers/api/fetchers.ts +5 -4
  223. package/src/wallets/in-app/native/helpers/errors.ts +3 -1
  224. package/src/wallets/in-app/native/helpers/storage/local.ts +2 -1
  225. package/src/wallets/in-app/native/helpers/wallet/migration.ts +4 -3
  226. package/src/wallets/in-app/native/helpers/wallet/recoveryCode.ts +5 -4
  227. package/src/wallets/in-app/web/lib/auth/otp.ts +3 -2
  228. package/src/wallets/manager/index.ts +4 -3
  229. package/src/wallets/smart/lib/bundler.ts +1 -1
  230. package/src/wallets/smart/lib/paymaster.ts +2 -1
  231. package/src/wallets/smart/smart-wallet.ts +19 -13
  232. package/src/wallets/wallet-connect/controller.ts +2 -1
  233. package/src/wallets/wallet-connect/receiver/session-store.ts +3 -6
  234. package/src/extensions/erc721/write/mintTo.test.ts +0 -69
  235. package/src/extensions/prebuilts/deploy-erc1155.test.ts +0 -54
  236. package/src/extensions/prebuilts/deploy-erc20.test.ts +0 -56
@@ -3,6 +3,7 @@ import type { LoginPayload } from "../../../../auth/core/types.js";
3
3
  import type { Chain } from "../../../../chains/types.js";
4
4
  import type { ThirdwebClient } from "../../../../client/client.js";
5
5
  import { getClientFetch } from "../../../../utils/fetch.js";
6
+ import { stringify } from "../../../../utils/json.js";
6
7
  import type { Wallet } from "../../../interfaces/wallet.js";
7
8
  import type { Ecosystem } from "../wallet/types.js";
8
9
  import { getLoginCallbackUrl, getLoginUrl } from "./getLoginPath.js";
@@ -50,7 +51,7 @@ export async function siweAuthenticate(args: {
50
51
  headers: {
51
52
  "Content-Type": "application/json",
52
53
  },
53
- body: JSON.stringify({
54
+ body: stringify({
54
55
  signature,
55
56
  payload,
56
57
  }),
@@ -2,6 +2,7 @@ import { trackConnect } from "../../../../analytics/track/connect.js";
2
2
  import type { Chain } from "../../../../chains/types.js";
3
3
  import { getCachedChainIfExists } from "../../../../chains/utils.js";
4
4
  import type { ThirdwebClient } from "../../../../client/client.js";
5
+ import { stringify } from "../../../../utils/json.js";
5
6
  import { getEcosystemInfo } from "../../../ecosystem/get-ecosystem-wallet-auth-options.js";
6
7
  import type { Account, Wallet } from "../../../interfaces/wallet.js";
7
8
  import { createWalletEmitter } from "../../../wallet-emitter.js";
@@ -22,7 +23,7 @@ export async function getOrCreateInAppWalletConnector(
22
23
  connectorFactory: (client: ThirdwebClient) => Promise<InAppConnector>,
23
24
  ecosystem?: Ecosystem,
24
25
  ) {
25
- const key = JSON.stringify({ clientId: client.clientId, ecosystem });
26
+ const key = stringify({ clientId: client.clientId, ecosystem });
26
27
  if (connectorCache.has(key)) {
27
28
  return connectorCache.get(key) as InAppConnector;
28
29
  }
@@ -1,6 +1,7 @@
1
1
  import type { ThirdwebClient } from "../../../../../client/client.js";
2
2
  import type { Hex } from "../../../../../utils/encoding/hex.js";
3
3
  import { getClientFetch } from "../../../../../utils/fetch.js";
4
+ import { stringify } from "../../../../../utils/json.js";
4
5
  import { randomBytesHex } from "../../../../../utils/random.js";
5
6
  import type { ClientScopedStorage } from "../../../core/authentication/client-scoped-storage.js";
6
7
  import type { UserDetailsApiType } from "../../../core/authentication/types.js";
@@ -35,7 +36,7 @@ export const verifyClientId = async (client: ThirdwebClient) => {
35
36
  headers: {
36
37
  ...getSessionHeaders(),
37
38
  },
38
- body: JSON.stringify({ clientId: client.clientId, parentDomain: "" }),
39
+ body: stringify({ clientId: client.clientId, parentDomain: "" }),
39
40
  });
40
41
  if (!resp.ok) {
41
42
  const error = await resp.json();
@@ -155,7 +156,7 @@ export async function storeUserShares({
155
156
  props: {
156
157
  method: "POST",
157
158
  headers: { "Content-Type": "application/json" },
158
- body: JSON.stringify({
159
+ body: stringify({
159
160
  walletAddress,
160
161
  maybeEncryptedRecoveryShares,
161
162
  authShare,
@@ -168,7 +169,7 @@ export async function storeUserShares({
168
169
  const error = await resp.json();
169
170
 
170
171
  throw new Error(
171
- `Something went wrong storing user wallet shares: ${JSON.stringify(
172
+ `Something went wrong storing user wallet shares: ${stringify(
172
173
  error.message,
173
174
  null,
174
175
  2,
@@ -193,7 +194,7 @@ export async function getUserShares(args: {
193
194
  if (!resp.ok) {
194
195
  const error = await resp.json();
195
196
  throw new Error(
196
- `Something went wrong getting user's wallet: ${JSON.stringify(
197
+ `Something went wrong getting user's wallet: ${stringify(
197
198
  error.message,
198
199
  null,
199
200
  2,
@@ -1,3 +1,5 @@
1
+ import { stringify } from "../../../../utils/json.js";
2
+
1
3
  export const ErrorMessages = {
2
4
  invalidOtp:
3
5
  "Your OTP code is invalid or expired. Please request a new code or try again.",
@@ -8,5 +10,5 @@ export const createErrorMessage = (message: string, error: unknown): string => {
8
10
  if (error instanceof Error) {
9
11
  return `${message}: ${error.message}`;
10
12
  }
11
- return `${message}: ${JSON.stringify(error)}`;
13
+ return `${message}: ${stringify(error)}`;
12
14
  };
@@ -1,4 +1,5 @@
1
1
  import AsyncStorage from "@react-native-async-storage/async-storage";
2
+ import { stringify } from "../../../../../utils/json.js";
2
3
  import {
3
4
  DEVICE_SHARE_LOCAL_STORAGE_NAME,
4
5
  WALLET_USER_DETAILS_LOCAL_STORAGE_NAME,
@@ -65,7 +66,7 @@ export async function setWallerUserDetails({
65
66
  await setItemInAsyncStorage(
66
67
  // ! Keep this in sync with getWalletUserDetails function below
67
68
  name,
68
- JSON.stringify({ userId, email: newEmail }),
69
+ stringify({ userId, email: newEmail }),
69
70
  );
70
71
  }
71
72
 
@@ -4,6 +4,7 @@ import QuickCrypto from "react-native-quick-crypto";
4
4
  import type { ThirdwebClient } from "../../../../../client/client.js";
5
5
  import { getThirdwebBaseUrl } from "../../../../../utils/domains.js";
6
6
  import { stringToBytes } from "../../../../../utils/encoding/to-bytes.js";
7
+ import { stringify } from "../../../../../utils/json.js";
7
8
  import { randomBytesBuffer } from "../../../../../utils/random.js";
8
9
  import {
9
10
  concatUint8Arrays,
@@ -72,7 +73,7 @@ export async function migrateToEnclaveWallet(args: {
72
73
  });
73
74
  if (!idTokenResponse.ok) {
74
75
  throw new Error(
75
- `Failed to fetch id token from Cognito: ${JSON.stringify(
76
+ `Failed to fetch id token from Cognito: ${stringify(
76
77
  await idTokenResponse.json(),
77
78
  null,
78
79
  2,
@@ -164,7 +165,7 @@ async function executeMigration(args: {
164
165
  url: `${getThirdwebBaseUrl("inAppWallet")}/api/v1/enclave-wallet/migrate`,
165
166
  props: {
166
167
  method: "POST",
167
- body: JSON.stringify({
168
+ body: stringify({
168
169
  address: args.address,
169
170
  kmsCiphertextB64: args.kmsCiphertextB64,
170
171
  encryptedPrivateKeyB64: args.encryptedPrivateKeyB64,
@@ -175,7 +176,7 @@ async function executeMigration(args: {
175
176
  });
176
177
  if (!migrationResponse.ok) {
177
178
  throw new Error(
178
- `Failed to migrate to enclave wallet: ${JSON.stringify(
179
+ `Failed to migrate to enclave wallet: ${stringify(
179
180
  await migrationResponse.json(),
180
181
  )}`,
181
182
  );
@@ -5,6 +5,7 @@ import {
5
5
  } from "@aws-sdk/credential-providers";
6
6
  import type { ThirdwebClient } from "../../../../../client/client.js";
7
7
  import { stringToBytes } from "../../../../../utils/encoding/to-bytes.js";
8
+ import { stringify } from "../../../../../utils/json.js";
8
9
  import type { ClientScopedStorage } from "../../../core/authentication/client-scoped-storage.js";
9
10
  import { authFetchEmbeddedWalletUser } from "../api/fetchers.js";
10
11
  import {
@@ -31,7 +32,7 @@ export async function getCognitoRecoveryPasswordV1(args: {
31
32
  });
32
33
  if (!idTokenResponse.ok) {
33
34
  throw new Error(
34
- `Failed to fetch id token from Cognito: ${JSON.stringify(
35
+ `Failed to fetch id token from Cognito: ${stringify(
35
36
  await idTokenResponse.json(),
36
37
  null,
37
38
  2,
@@ -61,7 +62,7 @@ export async function getCognitoRecoveryPasswordV1(args: {
61
62
  const params = {
62
63
  FunctionName: GENERATE_RECOVERY_PASSWORD_LAMBDA_FUNCTION_V1,
63
64
  Payload: stringToBytes(
64
- JSON.stringify({
65
+ stringify({
65
66
  accessToken,
66
67
  idToken,
67
68
  }),
@@ -92,7 +93,7 @@ export async function getCognitoRecoveryPasswordV2(args: {
92
93
  });
93
94
  if (!idTokenResponse.ok) {
94
95
  throw new Error(
95
- `Failed to fetch id token from Cognito: ${JSON.stringify(
96
+ `Failed to fetch id token from Cognito: ${stringify(
96
97
  await idTokenResponse.json(),
97
98
  null,
98
99
  2,
@@ -121,7 +122,7 @@ export async function getCognitoRecoveryPasswordV2(args: {
121
122
  const params = {
122
123
  FunctionName: GENERATE_RECOVERY_PASSWORD_LAMBDA_FUNCTION_V2,
123
124
  Payload: stringToBytes(
124
- JSON.stringify({
125
+ stringify({
125
126
  token: lambdaToken,
126
127
  }),
127
128
  ),
@@ -1,4 +1,5 @@
1
1
  import type { ThirdwebClient } from "../../../../../client/client.js";
2
+ import { stringify } from "../../../../../utils/json.js";
2
3
  import {
3
4
  getLoginCallbackUrl,
4
5
  getLoginUrl,
@@ -46,7 +47,7 @@ export const sendOtp = async (args: PreAuthArgsType): Promise<void> => {
46
47
  const response = await fetch(url, {
47
48
  method: "POST",
48
49
  headers,
49
- body: JSON.stringify(body),
50
+ body: stringify(body),
50
51
  });
51
52
 
52
53
  if (!response.ok) {
@@ -103,7 +104,7 @@ export const verifyOtp = async (
103
104
  const response = await fetch(url, {
104
105
  method: "POST",
105
106
  headers,
106
- body: JSON.stringify(body),
107
+ body: stringify(body),
107
108
  });
108
109
 
109
110
  if (!response.ok) {
@@ -5,6 +5,7 @@ import { hasSmartAccount } from "../../react/core/utils/isSmartWallet.js";
5
5
  import { computedStore } from "../../reactive/computedStore.js";
6
6
  import { effect } from "../../reactive/effect.js";
7
7
  import { createStore } from "../../reactive/store.js";
8
+ import { stringify } from "../../utils/json.js";
8
9
  import type { AsyncStorage } from "../../utils/storage/AsyncStorage.js";
9
10
  import { deleteConnectParamsFromStorage } from "../../utils/storage/walletStorage.js";
10
11
  import type { Account, Wallet } from "../interfaces/wallet.js";
@@ -216,7 +217,7 @@ export function createConnectionManager(storage: AsyncStorage) {
216
217
  () => {
217
218
  const _chain = activeWalletChainStore.getValue();
218
219
  if (_chain) {
219
- storage.setItem(LAST_ACTIVE_CHAIN, JSON.stringify(_chain));
220
+ storage.setItem(LAST_ACTIVE_CHAIN, stringify(_chain));
220
221
  } else {
221
222
  storage.removeItem(LAST_ACTIVE_CHAIN);
222
223
  }
@@ -231,7 +232,7 @@ export function createConnectionManager(storage: AsyncStorage) {
231
232
  const accounts = connectedWallets.getValue();
232
233
  const ids = accounts.map((acc) => acc?.id).filter((c) => !!c) as string[];
233
234
 
234
- storage.setItem(CONNECTED_WALLET_IDS, JSON.stringify(ids));
235
+ storage.setItem(CONNECTED_WALLET_IDS, stringify(ids));
235
236
  },
236
237
  [connectedWallets],
237
238
  false,
@@ -276,7 +277,7 @@ export function createConnectionManager(storage: AsyncStorage) {
276
277
  const allChainsSame = chains.every((c) => {
277
278
  const definedChain = currentMapVal.get(c.id);
278
279
  // basically a deep equal check
279
- return JSON.stringify(definedChain) === JSON.stringify(c);
280
+ return stringify(definedChain) === stringify(c);
280
281
  });
281
282
 
282
283
  if (allChainsSame) {
@@ -290,7 +290,7 @@ async function sendBundlerRequest(args: {
290
290
  if (!response.ok || res.error) {
291
291
  let error = res.error || response.statusText;
292
292
  if (typeof error === "object") {
293
- error = JSON.stringify(error);
293
+ error = stringify(error);
294
294
  }
295
295
  const code = res.code || "UNKNOWN";
296
296
 
@@ -2,6 +2,7 @@ import type { Chain } from "../../../chains/types.js";
2
2
  import type { ThirdwebClient } from "../../../client/client.js";
3
3
  import { hexToBigInt } from "../../../utils/encoding/hex.js";
4
4
  import { getClientFetch } from "../../../utils/fetch.js";
5
+ import { stringify } from "../../../utils/json.js";
5
6
  import type {
6
7
  PaymasterResult,
7
8
  UserOperationV06,
@@ -59,7 +60,7 @@ export async function getPaymasterAndData(args: {
59
60
  const response = await fetchWithHeaders(paymasterUrl, {
60
61
  method: "POST",
61
62
  headers,
62
- body: JSON.stringify({
63
+ body: stringify({
63
64
  jsonrpc: "2.0",
64
65
  id: 1,
65
66
  method: "pm_sponsorUserOperation",
@@ -2,6 +2,7 @@ import { trackConnect } from "../../analytics/track/connect.js";
2
2
  import type { Chain } from "../../chains/types.js";
3
3
  import { getCachedChainIfExists } from "../../chains/utils.js";
4
4
  import { getContract } from "../../contract/contract.js";
5
+ import { isZkSyncChain } from "../../utils/any-evm/zksync/isZkSyncChain.js";
5
6
  import { isContractDeployed } from "../../utils/bytecode/is-contract-deployed.js";
6
7
  import type { Account, Wallet } from "../interfaces/wallet.js";
7
8
  import { createWalletEmitter } from "../wallet-emitter.js";
@@ -202,19 +203,24 @@ export function smartWallet(
202
203
  if (!lastConnectOptions) {
203
204
  throw new Error("Cannot switch chain without a previous connection");
204
205
  }
205
- // check if factory is deployed
206
- const factory = getContract({
207
- address:
208
- createOptions.factoryAddress ||
209
- getDefaultAccountFactory(createOptions.overrides?.entrypointAddress),
210
- chain: newChain,
211
- client: lastConnectOptions.client,
212
- });
213
- const isDeployed = await isContractDeployed(factory);
214
- if (!isDeployed) {
215
- throw new Error(
216
- `Factory contract not deployed on chain: ${newChain.id}`,
217
- );
206
+ const isZksyncChain = await isZkSyncChain(newChain);
207
+ if (!isZksyncChain) {
208
+ // check if factory is deployed
209
+ const factory = getContract({
210
+ address:
211
+ createOptions.factoryAddress ||
212
+ getDefaultAccountFactory(
213
+ createOptions.overrides?.entrypointAddress,
214
+ ),
215
+ chain: newChain,
216
+ client: lastConnectOptions.client,
217
+ });
218
+ const isDeployed = await isContractDeployed(factory);
219
+ if (!isDeployed) {
220
+ throw new Error(
221
+ `Factory contract not deployed on chain: ${newChain.id}`,
222
+ );
223
+ }
218
224
  }
219
225
  const { connectSmartWallet } = await import("./index.js");
220
226
  const [connectedAccount, connectedChain] = await connectSmartWallet(
@@ -24,6 +24,7 @@ import {
24
24
  stringToHex,
25
25
  uint8ArrayToHex,
26
26
  } from "../../utils/encoding/hex.js";
27
+ import { stringify } from "../../utils/json.js";
27
28
  import { parseTypedData } from "../../utils/signatures/helpers/parseTypedData.js";
28
29
  import type { AsyncStorage } from "../../utils/storage/AsyncStorage.js";
29
30
  import {
@@ -536,7 +537,7 @@ function setRequestedChainsIds(
536
537
  chains: number[] | undefined,
537
538
  storage: AsyncStorage,
538
539
  ) {
539
- storage?.setItem(storageKeys.requestedChains, JSON.stringify(chains));
540
+ storage?.setItem(storageKeys.requestedChains, stringify(chains));
540
541
  }
541
542
 
542
543
  /**
@@ -1,3 +1,4 @@
1
+ import { stringify } from "../../../utils/json.js";
1
2
  import { ClientScopedStorage } from "../../in-app/core/authentication/client-scoped-storage.js";
2
3
  import type { WalletConnectSession } from "./types.js";
3
4
 
@@ -45,9 +46,7 @@ export async function saveSession(
45
46
  await walletConnectSessions.getWalletConnectSessions();
46
47
  const sessions = JSON.parse(stringifiedSessions ?? "[]");
47
48
  sessions.push(session);
48
- await walletConnectSessions.saveWalletConnectSessions(
49
- JSON.stringify(sessions),
50
- );
49
+ await walletConnectSessions.saveWalletConnectSessions(stringify(sessions));
51
50
  }
52
51
 
53
52
  /**
@@ -65,9 +64,7 @@ export async function removeSession(
65
64
  const newSessions = sessions.filter(
66
65
  (s: WalletConnectSession) => s.topic !== session.topic,
67
66
  );
68
- await walletConnectSessions.saveWalletConnectSessions(
69
- JSON.stringify(newSessions),
70
- );
67
+ await walletConnectSessions.saveWalletConnectSessions(stringify(newSessions));
71
68
  }
72
69
 
73
70
  /**
@@ -1,69 +0,0 @@
1
- import { beforeEach, describe, expect, it } from "vitest";
2
- import { ANVIL_CHAIN } from "~test/chains.js";
3
- import { TEST_CLIENT } from "~test/test-clients.js";
4
- import { TEST_ACCOUNT_A } from "~test/test-wallets.js";
5
-
6
- import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
7
- import {
8
- type ThirdwebContract,
9
- getContract,
10
- } from "../../../contract/contract.js";
11
- import { deployERC721Contract } from "../../../extensions/prebuilts/deploy-erc721.js";
12
- import { sendAndConfirmTransaction } from "../../../transaction/actions/send-and-confirm-transaction.js";
13
- import { tokenURI } from "../__generated__/IERC721A/read/tokenURI.js";
14
- import { getNFT } from "../read/getNFT.js";
15
- import { mintTo } from "./mintTo.js";
16
-
17
- let contract: ThirdwebContract;
18
- const account = TEST_ACCOUNT_A;
19
- const client = TEST_CLIENT;
20
- const chain = ANVIL_CHAIN;
21
-
22
- describe.runIf(!!process.env.TW_SECRET_KEY)("erc721 mintTo extension", () => {
23
- beforeEach(async () => {
24
- const address = await deployERC721Contract({
25
- client,
26
- chain,
27
- account,
28
- type: "TokenERC721",
29
- params: {
30
- name: "NFTDrop",
31
- contractURI: TEST_CONTRACT_URI,
32
- },
33
- });
34
- contract = getContract({
35
- address,
36
- client,
37
- chain,
38
- });
39
- });
40
-
41
- it("should mint an nft when passed an object", async () => {
42
- const transaction = mintTo({
43
- contract,
44
- nft: { name: "token 0" },
45
- to: account.address,
46
- });
47
- await sendAndConfirmTransaction({
48
- transaction,
49
- account,
50
- });
51
-
52
- const nft = await getNFT({ contract, tokenId: 0n });
53
- expect(nft.metadata.name).toBe("token 0");
54
- });
55
-
56
- it("should mint an nft when passed a string", async () => {
57
- const transaction = mintTo({
58
- contract,
59
- nft: "ipfs://fake-token-uri",
60
- to: account.address,
61
- });
62
- await sendAndConfirmTransaction({
63
- transaction,
64
- account,
65
- });
66
- const _uri = await tokenURI({ contract, tokenId: 0n });
67
- expect(_uri).toBe("ipfs://fake-token-uri");
68
- });
69
- });
@@ -1,54 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { ANVIL_CHAIN } from "../../../test/src/chains.js";
3
- import { TEST_CLIENT } from "../../../test/src/test-clients.js";
4
- import { TEST_ACCOUNT_B } from "../../../test/src/test-wallets.js";
5
- import { getContract } from "../../contract/contract.js";
6
- import { name } from "../common/read/name.js";
7
- import { deployERC1155Contract } from "./deploy-erc1155.js";
8
-
9
- const account = TEST_ACCOUNT_B;
10
-
11
- describe.runIf(process.env.TW_SECRET_KEY)("deployERC1155", () => {
12
- it("should deploy ERC1155 drop", async () => {
13
- const address = await deployERC1155Contract({
14
- client: TEST_CLIENT,
15
- chain: ANVIL_CHAIN,
16
- account,
17
- type: "DropERC1155",
18
- params: {
19
- name: "EditionDrop",
20
- symbol: "NFTD",
21
- },
22
- });
23
- expect(address).toBeDefined();
24
- const deployedName = await name({
25
- contract: getContract({
26
- client: TEST_CLIENT,
27
- chain: ANVIL_CHAIN,
28
- address,
29
- }),
30
- });
31
- expect(deployedName).toBe("EditionDrop");
32
- });
33
-
34
- it("should deploy ERC1155 token", async () => {
35
- const address = await deployERC1155Contract({
36
- client: TEST_CLIENT,
37
- chain: ANVIL_CHAIN,
38
- account,
39
- type: "TokenERC1155",
40
- params: {
41
- name: "Edition",
42
- },
43
- });
44
- expect(address).toBeDefined();
45
- const deployedName = await name({
46
- contract: getContract({
47
- client: TEST_CLIENT,
48
- chain: ANVIL_CHAIN,
49
- address,
50
- }),
51
- });
52
- expect(deployedName).toBe("Edition");
53
- });
54
- });
@@ -1,56 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { ANVIL_CHAIN } from "../../../test/src/chains.js";
3
- import { TEST_CLIENT } from "../../../test/src/test-clients.js";
4
- import { TEST_ACCOUNT_D } from "../../../test/src/test-wallets.js";
5
- import { getContract } from "../../contract/contract.js";
6
- import { name } from "../common/read/name.js";
7
- import { deployERC20Contract } from "./deploy-erc20.js";
8
-
9
- const account = TEST_ACCOUNT_D;
10
-
11
- // skip this test suite if there is no secret key available to test with
12
- // TODO: remove reliance on secret key during unit tests entirely
13
- describe.runIf(process.env.TW_SECRET_KEY)("deployERC20", () => {
14
- it("should deploy ERC20 drop", async () => {
15
- const address = await deployERC20Contract({
16
- client: TEST_CLIENT,
17
- chain: ANVIL_CHAIN,
18
- account,
19
- type: "DropERC20",
20
- params: {
21
- name: "TokenDrop",
22
- symbol: "NFTD",
23
- },
24
- });
25
- expect(address).toBeDefined();
26
- const deployedName = await name({
27
- contract: getContract({
28
- client: TEST_CLIENT,
29
- chain: ANVIL_CHAIN,
30
- address,
31
- }),
32
- });
33
- expect(deployedName).toBe("TokenDrop");
34
- });
35
-
36
- it("should deploy ERC20 token", async () => {
37
- const address = await deployERC20Contract({
38
- client: TEST_CLIENT,
39
- chain: ANVIL_CHAIN,
40
- account,
41
- type: "TokenERC20",
42
- params: {
43
- name: "Token",
44
- },
45
- });
46
- expect(address).toBeDefined();
47
- const deployedName = await name({
48
- contract: getContract({
49
- client: TEST_CLIENT,
50
- chain: ANVIL_CHAIN,
51
- address,
52
- }),
53
- });
54
- expect(deployedName).toBe("Token");
55
- });
56
- });