thirdweb 5.109.2-nightly-f2121e9519719ef809986c919acc5069b5b7ce74-20251022000400 → 5.110.1

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 (130) hide show
  1. package/dist/cjs/adapters/eip1193/to-eip1193.js +120 -80
  2. package/dist/cjs/adapters/eip1193/to-eip1193.js.map +1 -1
  3. package/dist/cjs/exports/utils.js +5 -0
  4. package/dist/cjs/exports/utils.js.map +1 -1
  5. package/dist/cjs/extensions/airdrop/write/saveSnapshot.js +7 -1
  6. package/dist/cjs/extensions/airdrop/write/saveSnapshot.js.map +1 -1
  7. package/dist/cjs/extensions/common/read/getContractMetadata.js +7 -3
  8. package/dist/cjs/extensions/common/read/getContractMetadata.js.map +1 -1
  9. package/dist/cjs/react/native/ui/connect/SendScreen.js +1 -1
  10. package/dist/cjs/react/web/ui/Bridge/BuyWidget.js +1 -3
  11. package/dist/cjs/react/web/ui/Bridge/BuyWidget.js.map +1 -1
  12. package/dist/cjs/react/web/ui/Bridge/FundWallet.js +10 -8
  13. package/dist/cjs/react/web/ui/Bridge/FundWallet.js.map +1 -1
  14. package/dist/cjs/react/web/ui/prebuilt/thirdweb/ClaimButton/index.js +5 -2
  15. package/dist/cjs/react/web/ui/prebuilt/thirdweb/ClaimButton/index.js.map +1 -1
  16. package/dist/cjs/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.js +5 -2
  17. package/dist/cjs/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.js.map +1 -1
  18. package/dist/cjs/utils/contract/fetchContractMetadata.js.map +1 -1
  19. package/dist/cjs/utils/extensions/airdrop/fetch-proofs-erc1155.js +2 -1
  20. package/dist/cjs/utils/extensions/airdrop/fetch-proofs-erc1155.js.map +1 -1
  21. package/dist/cjs/utils/extensions/airdrop/fetch-proofs-erc20.js +2 -1
  22. package/dist/cjs/utils/extensions/airdrop/fetch-proofs-erc20.js.map +1 -1
  23. package/dist/cjs/utils/extensions/airdrop/fetch-proofs-erc721.js +2 -1
  24. package/dist/cjs/utils/extensions/airdrop/fetch-proofs-erc721.js.map +1 -1
  25. package/dist/cjs/utils/extensions/drops/get-claim-params.js +2 -1
  26. package/dist/cjs/utils/extensions/drops/get-claim-params.js.map +1 -1
  27. package/dist/cjs/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.js +7 -1
  28. package/dist/cjs/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.js.map +1 -1
  29. package/dist/cjs/utils/type-guards.js +25 -0
  30. package/dist/cjs/utils/type-guards.js.map +1 -1
  31. package/dist/cjs/version.js +1 -1
  32. package/dist/cjs/version.js.map +1 -1
  33. package/dist/cjs/wallets/in-app/core/eip5792/in-app-wallet-calls.js +6 -2
  34. package/dist/cjs/wallets/in-app/core/eip5792/in-app-wallet-calls.js.map +1 -1
  35. package/dist/cjs/wallets/in-app/core/eip7702/minimal-account.js +1 -0
  36. package/dist/cjs/wallets/in-app/core/eip7702/minimal-account.js.map +1 -1
  37. package/dist/cjs/wallets/in-app/core/wallet/enclave-wallet.js +1 -0
  38. package/dist/cjs/wallets/in-app/core/wallet/enclave-wallet.js.map +1 -1
  39. package/dist/cjs/wallets/smart/index.js +2 -0
  40. package/dist/cjs/wallets/smart/index.js.map +1 -1
  41. package/dist/esm/adapters/eip1193/to-eip1193.js +120 -80
  42. package/dist/esm/adapters/eip1193/to-eip1193.js.map +1 -1
  43. package/dist/esm/exports/utils.js +4 -0
  44. package/dist/esm/exports/utils.js.map +1 -1
  45. package/dist/esm/extensions/airdrop/write/saveSnapshot.js +7 -1
  46. package/dist/esm/extensions/airdrop/write/saveSnapshot.js.map +1 -1
  47. package/dist/esm/extensions/common/read/getContractMetadata.js +7 -3
  48. package/dist/esm/extensions/common/read/getContractMetadata.js.map +1 -1
  49. package/dist/esm/react/native/ui/connect/SendScreen.js +1 -1
  50. package/dist/esm/react/web/ui/Bridge/BuyWidget.js +1 -3
  51. package/dist/esm/react/web/ui/Bridge/BuyWidget.js.map +1 -1
  52. package/dist/esm/react/web/ui/Bridge/FundWallet.js +10 -8
  53. package/dist/esm/react/web/ui/Bridge/FundWallet.js.map +1 -1
  54. package/dist/esm/react/web/ui/prebuilt/thirdweb/ClaimButton/index.js +5 -2
  55. package/dist/esm/react/web/ui/prebuilt/thirdweb/ClaimButton/index.js.map +1 -1
  56. package/dist/esm/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.js +5 -2
  57. package/dist/esm/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.js.map +1 -1
  58. package/dist/esm/utils/contract/fetchContractMetadata.js.map +1 -1
  59. package/dist/esm/utils/extensions/airdrop/fetch-proofs-erc1155.js +2 -1
  60. package/dist/esm/utils/extensions/airdrop/fetch-proofs-erc1155.js.map +1 -1
  61. package/dist/esm/utils/extensions/airdrop/fetch-proofs-erc20.js +2 -1
  62. package/dist/esm/utils/extensions/airdrop/fetch-proofs-erc20.js.map +1 -1
  63. package/dist/esm/utils/extensions/airdrop/fetch-proofs-erc721.js +2 -1
  64. package/dist/esm/utils/extensions/airdrop/fetch-proofs-erc721.js.map +1 -1
  65. package/dist/esm/utils/extensions/drops/get-claim-params.js +2 -1
  66. package/dist/esm/utils/extensions/drops/get-claim-params.js.map +1 -1
  67. package/dist/esm/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.js +7 -1
  68. package/dist/esm/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.js.map +1 -1
  69. package/dist/esm/utils/type-guards.js +23 -1
  70. package/dist/esm/utils/type-guards.js.map +1 -1
  71. package/dist/esm/version.js +1 -1
  72. package/dist/esm/version.js.map +1 -1
  73. package/dist/esm/wallets/in-app/core/eip5792/in-app-wallet-calls.js +6 -2
  74. package/dist/esm/wallets/in-app/core/eip5792/in-app-wallet-calls.js.map +1 -1
  75. package/dist/esm/wallets/in-app/core/eip7702/minimal-account.js +1 -0
  76. package/dist/esm/wallets/in-app/core/eip7702/minimal-account.js.map +1 -1
  77. package/dist/esm/wallets/in-app/core/wallet/enclave-wallet.js +1 -0
  78. package/dist/esm/wallets/in-app/core/wallet/enclave-wallet.js.map +1 -1
  79. package/dist/esm/wallets/smart/index.js +2 -0
  80. package/dist/esm/wallets/smart/index.js.map +1 -1
  81. package/dist/scripts/bridge-widget.js +67 -67
  82. package/dist/types/adapters/eip1193/to-eip1193.d.ts.map +1 -1
  83. package/dist/types/exports/utils.d.ts +1 -0
  84. package/dist/types/exports/utils.d.ts.map +1 -1
  85. package/dist/types/extensions/airdrop/write/saveSnapshot.d.ts.map +1 -1
  86. package/dist/types/extensions/common/read/getContractMetadata.d.ts +3 -3
  87. package/dist/types/extensions/common/read/getContractMetadata.d.ts.map +1 -1
  88. package/dist/types/react/web/ui/Bridge/BuyWidget.d.ts.map +1 -1
  89. package/dist/types/react/web/ui/Bridge/FundWallet.d.ts.map +1 -1
  90. package/dist/types/react/web/ui/prebuilt/thirdweb/ClaimButton/index.d.ts.map +1 -1
  91. package/dist/types/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.d.ts.map +1 -1
  92. package/dist/types/utils/contract/fetchContractMetadata.d.ts +1 -1
  93. package/dist/types/utils/contract/fetchContractMetadata.d.ts.map +1 -1
  94. package/dist/types/utils/extensions/airdrop/fetch-proofs-erc1155.d.ts.map +1 -1
  95. package/dist/types/utils/extensions/airdrop/fetch-proofs-erc20.d.ts.map +1 -1
  96. package/dist/types/utils/extensions/airdrop/fetch-proofs-erc721.d.ts.map +1 -1
  97. package/dist/types/utils/extensions/drops/get-claim-params.d.ts.map +1 -1
  98. package/dist/types/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.d.ts.map +1 -1
  99. package/dist/types/utils/type-guards.d.ts +24 -0
  100. package/dist/types/utils/type-guards.d.ts.map +1 -1
  101. package/dist/types/version.d.ts +1 -1
  102. package/dist/types/version.d.ts.map +1 -1
  103. package/dist/types/wallets/in-app/core/eip5792/in-app-wallet-calls.d.ts +1 -0
  104. package/dist/types/wallets/in-app/core/eip5792/in-app-wallet-calls.d.ts.map +1 -1
  105. package/dist/types/wallets/in-app/core/eip7702/minimal-account.d.ts.map +1 -1
  106. package/dist/types/wallets/in-app/core/wallet/enclave-wallet.d.ts.map +1 -1
  107. package/dist/types/wallets/smart/index.d.ts.map +1 -1
  108. package/package.json +1 -1
  109. package/src/adapters/eip1193/to-eip1193.ts +123 -85
  110. package/src/exports/utils.ts +5 -0
  111. package/src/extensions/airdrop/write/saveSnapshot.ts +7 -1
  112. package/src/extensions/common/read/getContractMetadata.ts +12 -7
  113. package/src/react/native/ui/connect/SendScreen.tsx +1 -1
  114. package/src/react/web/ui/Bridge/BuyWidget.tsx +1 -3
  115. package/src/react/web/ui/Bridge/FundWallet.tsx +17 -14
  116. package/src/react/web/ui/prebuilt/thirdweb/ClaimButton/index.tsx +5 -2
  117. package/src/react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.tsx +5 -2
  118. package/src/utils/contract/fetchContractMetadata.ts +1 -2
  119. package/src/utils/extensions/airdrop/fetch-proofs-erc1155.ts +3 -1
  120. package/src/utils/extensions/airdrop/fetch-proofs-erc20.ts +2 -1
  121. package/src/utils/extensions/airdrop/fetch-proofs-erc721.ts +3 -1
  122. package/src/utils/extensions/drops/get-claim-params.ts +3 -1
  123. package/src/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.ts +7 -1
  124. package/src/utils/type-guard.test.ts +115 -0
  125. package/src/utils/type-guards.ts +37 -1
  126. package/src/version.ts +1 -1
  127. package/src/wallets/in-app/core/eip5792/in-app-wallet-calls.ts +11 -2
  128. package/src/wallets/in-app/core/eip7702/minimal-account.ts +1 -0
  129. package/src/wallets/in-app/core/wallet/enclave-wallet.ts +1 -0
  130. package/src/wallets/smart/index.ts +2 -0
@@ -167,6 +167,9 @@ export function FundWallet(props: FundWalletProps) {
167
167
  const actionLabel = isReceiverDifferentFromActiveWallet ? "Pay" : "Buy";
168
168
  const isMobile = useIsMobile();
169
169
 
170
+ // if no receiver address is set - wallet must be connected because the user's wallet is the receiver
171
+ const showConnectButton = !props.receiverAddress && !activeWalletInfo;
172
+
170
173
  return (
171
174
  <WithHeader
172
175
  client={props.client}
@@ -283,7 +286,20 @@ export function FundWallet(props: FundWalletProps) {
283
286
  )}
284
287
 
285
288
  {/* Continue Button */}
286
- {activeWalletInfo ? (
289
+ {showConnectButton ? (
290
+ <ConnectButton
291
+ client={props.client}
292
+ connectButton={{
293
+ label: props.buttonLabel || actionLabel,
294
+ style: {
295
+ width: "100%",
296
+ borderRadius: radius.full,
297
+ },
298
+ }}
299
+ theme={theme}
300
+ {...props.connectOptions}
301
+ />
302
+ ) : (
287
303
  <Button
288
304
  disabled={!receiver}
289
305
  fullWidth
@@ -316,19 +332,6 @@ export function FundWallet(props: FundWalletProps) {
316
332
  >
317
333
  {props.buttonLabel || actionLabel}
318
334
  </Button>
319
- ) : (
320
- <ConnectButton
321
- client={props.client}
322
- connectButton={{
323
- label: props.buttonLabel || actionLabel,
324
- style: {
325
- width: "100%",
326
- borderRadius: radius.full,
327
- },
328
- }}
329
- theme={theme}
330
- {...props.connectOptions}
331
- />
332
335
  )}
333
336
 
334
337
  {props.showThirdwebBranding ? (
@@ -8,6 +8,7 @@ import { getContractMetadata } from "../../../../../../extensions/common/read/ge
8
8
  import { getNFT } from "../../../../../../extensions/erc1155/read/getNFT.js";
9
9
  import type { PreparedTransaction } from "../../../../../../transaction/prepare-transaction.js";
10
10
  import type { BaseTransactionOptions } from "../../../../../../transaction/types.js";
11
+ import { isString } from "../../../../../../utils/type-guards.js";
11
12
  import type { Account } from "../../../../../../wallets/interfaces/wallet.js";
12
13
  import { useReadContract } from "../../../../../core/hooks/contract/useReadContract.js";
13
14
  import { useActiveAccount } from "../../../../../core/hooks/wallets/useActiveAccount.js";
@@ -191,8 +192,10 @@ async function getPayMetadata(
191
192
  };
192
193
  }
193
194
  return {
194
- image: contractMetadata?.image,
195
- name: contractMetadata?.name,
195
+ image: isString(contractMetadata?.image)
196
+ ? contractMetadata.image
197
+ : undefined,
198
+ name: isString(contractMetadata?.name) ? contractMetadata.name : undefined,
196
199
  };
197
200
  }
198
201
 
@@ -11,6 +11,7 @@ import {
11
11
  createListing,
12
12
  } from "../../../../../../extensions/marketplace/direct-listings/write/createListing.js";
13
13
  import type { BaseTransactionOptions } from "../../../../../../transaction/types.js";
14
+ import { isString } from "../../../../../../utils/type-guards.js";
14
15
  import { useReadContract } from "../../../../../core/hooks/contract/useReadContract.js";
15
16
  import type { TransactionButtonProps } from "../../../../../core/hooks/transaction/transaction-button-utils.js";
16
17
  import { useActiveAccount } from "../../../../../core/hooks/wallets/useActiveAccount.js";
@@ -228,7 +229,9 @@ async function getPayMetadata(
228
229
  }
229
230
 
230
231
  return {
231
- image: contractMetadata?.image,
232
- name: contractMetadata?.name,
232
+ image: isString(contractMetadata?.image)
233
+ ? contractMetadata.image
234
+ : undefined,
235
+ name: isString(contractMetadata?.name) ? contractMetadata.name : undefined,
233
236
  };
234
237
  }
@@ -18,8 +18,7 @@ export type FetchContractMetadata = {
18
18
  */
19
19
  export async function fetchContractMetadata(
20
20
  options: FetchContractMetadata,
21
- // biome-ignore lint/suspicious/noExplicitAny: TODO: fix any
22
- ): Promise<{ [key: string]: any } | undefined> {
21
+ ): Promise<{ [key: string]: unknown } | undefined> {
23
22
  const { client, uri } = options;
24
23
 
25
24
  // handle case where the URI is a base64 encoded JSON
@@ -3,6 +3,7 @@ import { getContractMetadata } from "../../../extensions/common/read/getContract
3
3
  import { MerkleTree } from "../../../merkletree/MerkleTree.js";
4
4
  import { download } from "../../../storage/download.js";
5
5
  import type { Address } from "../../address.js";
6
+ import { isRecord } from "../../type-guards.js";
6
7
  import { hashEntryERC1155 } from "./hash-entry-erc1155.js";
7
8
  import type {
8
9
  ClaimProofERC1155,
@@ -54,7 +55,8 @@ export async function fetchProofsERC1155(options: {
54
55
  const metadata = await getContractMetadata({
55
56
  contract,
56
57
  });
57
- const merkleData: Record<string, string> = metadata.merkle || {};
58
+
59
+ const merkleData = isRecord(metadata.merkle) ? metadata.merkle : {};
58
60
  const snapshotUri = merkleData[merkleRoot];
59
61
 
60
62
  if (!snapshotUri) {
@@ -3,6 +3,7 @@ import { getContractMetadata } from "../../../extensions/common/read/getContract
3
3
  import { MerkleTree } from "../../../merkletree/MerkleTree.js";
4
4
  import { download } from "../../../storage/download.js";
5
5
  import type { Address } from "../../address.js";
6
+ import { isRecord } from "../../type-guards.js";
6
7
  import { convertQuantity } from "../drops/convert-quantity.js";
7
8
  import { hashEntryERC20 } from "./hash-entry-erc20.js";
8
9
  import type {
@@ -56,7 +57,7 @@ export async function fetchProofsERC20(options: {
56
57
  const metadata = await getContractMetadata({
57
58
  contract,
58
59
  });
59
- const merkleData: Record<string, string> = metadata.merkle || {};
60
+ const merkleData = isRecord(metadata.merkle) ? metadata.merkle : {};
60
61
  const snapshotUri = merkleData[merkleRoot];
61
62
 
62
63
  if (!snapshotUri) {
@@ -3,6 +3,7 @@ import { getContractMetadata } from "../../../extensions/common/read/getContract
3
3
  import { MerkleTree } from "../../../merkletree/MerkleTree.js";
4
4
  import { download } from "../../../storage/download.js";
5
5
  import type { Address } from "../../address.js";
6
+ import { isRecord } from "../../type-guards.js";
6
7
  import { hashEntryERC721 } from "./hash-entry-erc721.js";
7
8
  import type {
8
9
  ClaimProofERC721,
@@ -54,7 +55,8 @@ export async function fetchProofsERC721(options: {
54
55
  const metadata = await getContractMetadata({
55
56
  contract,
56
57
  });
57
- const merkleData: Record<string, string> = metadata.merkle || {};
58
+
59
+ const merkleData = isRecord(metadata.merkle) ? metadata.merkle : {};
58
60
  const snapshotUri = merkleData[merkleRoot];
59
61
 
60
62
  if (!snapshotUri) {
@@ -6,6 +6,7 @@ import {
6
6
  import type { ThirdwebContract } from "../../../contract/contract.js";
7
7
  import { getContractMetadata } from "../../../extensions/common/read/getContractMetadata.js";
8
8
  import type { Hex } from "../../encoding/hex.js";
9
+ import { isRecord } from "../../type-guards.js";
9
10
  import type { ClaimCondition, OverrideProof } from "./types.js";
10
11
 
11
12
  export type GetClaimParamsOptions = {
@@ -118,7 +119,8 @@ export async function getClaimParams(options: GetClaimParamsOptions) {
118
119
  const metadata = await getContractMetadata({
119
120
  contract: options.contract,
120
121
  });
121
- const merkleData: Record<string, string> = metadata.merkle || {};
122
+
123
+ const merkleData = isRecord(metadata.merkle) ? metadata.merkle : {};
122
124
  const snapshotUri = merkleData[cc.merkleRoot];
123
125
 
124
126
  if (!snapshotUri) {
@@ -5,6 +5,7 @@ import type { SetClaimConditionsParams as GeneratedParams } from "../../../exten
5
5
  import { upload } from "../../../storage/upload.js";
6
6
  import { dateToSeconds } from "../../date.js";
7
7
  import { type Hex, toHex } from "../../encoding/hex.js";
8
+ import { isRecord } from "../../type-guards.js";
8
9
  import { convertErc20Amount } from "../convert-erc20-amount.js";
9
10
  import { processOverrideList } from "./process-override-list.js";
10
11
  import type { ClaimConditionsInput } from "./types.js";
@@ -74,7 +75,12 @@ export async function getMulticallSetClaimConditionTransactions(options: {
74
75
  });
75
76
  // keep the old merkle roots from other tokenIds
76
77
  for (const key of Object.keys(metadata.merkle || {})) {
77
- merkleInfos[key] = metadata.merkle[key];
78
+ const merkleInfo = isRecord(metadata.merkle)
79
+ ? metadata.merkle[key]
80
+ : undefined;
81
+ if (merkleInfo) {
82
+ merkleInfos[key] = merkleInfo;
83
+ }
78
84
  }
79
85
  const mergedMetadata = {
80
86
  ...metadata,
@@ -0,0 +1,115 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import {
4
+ isObject,
5
+ isObjectWithKeys,
6
+ isRecord,
7
+ isString,
8
+ } from "./type-guards.js";
9
+
10
+ describe("isObject", () => {
11
+ it("returns true for plain objects", () => {
12
+ expect(isObject({})).toBe(true);
13
+ expect(isObject({ a: 1 })).toBe(true);
14
+ });
15
+
16
+ it("returns true for non-null object-like values (arrays, dates, maps)", () => {
17
+ expect(isObject([])).toBe(true);
18
+ expect(isObject(new Date())).toBe(true);
19
+ expect(isObject(new Map())).toBe(true);
20
+ });
21
+
22
+ it("returns false for primitives, functions and null/undefined", () => {
23
+ expect(isObject(null)).toBe(false);
24
+ expect(isObject(undefined)).toBe(false);
25
+ expect(isObject(123)).toBe(false);
26
+ expect(isObject("str")).toBe(false);
27
+ expect(isObject(true)).toBe(false);
28
+ expect(isObject(() => {})).toBe(false);
29
+ });
30
+ });
31
+
32
+ describe("isString", () => {
33
+ it("returns true for string primitives", () => {
34
+ expect(isString("" as unknown)).toBe(true);
35
+ expect(isString("hello" as unknown)).toBe(true);
36
+ });
37
+
38
+ it("returns false for non-strings and String objects", () => {
39
+ // String objects are typeof "object"
40
+ // eslint-disable-next-line no-new-wrappers
41
+ expect(isString(new String("x") as unknown)).toBe(false);
42
+ expect(isString(1 as unknown)).toBe(false);
43
+ expect(isString({} as unknown)).toBe(false);
44
+ expect(isString([] as unknown)).toBe(false);
45
+ expect(isString(null as unknown)).toBe(false);
46
+ expect(isString(undefined as unknown)).toBe(false);
47
+ });
48
+ });
49
+
50
+ describe("isObjectWithKeys", () => {
51
+ it("returns true when object has all specified keys", () => {
52
+ const value = { a: 1, b: 2 } as const;
53
+ expect(isObjectWithKeys(value, ["a"])).toBe(true);
54
+ expect(isObjectWithKeys(value, ["a", "b"])).toBe(true);
55
+ });
56
+
57
+ it("returns false when any specified key is missing", () => {
58
+ const value = { a: 1 } as const;
59
+ expect(isObjectWithKeys(value, ["a", "b"])).toBe(false);
60
+ });
61
+
62
+ it("defaults to just checking object-ness when no keys are provided", () => {
63
+ expect(isObjectWithKeys({})).toBe(true);
64
+ expect(isObjectWithKeys([])).toBe(true);
65
+ expect(isObjectWithKeys(123 as unknown)).toBe(false);
66
+ });
67
+
68
+ it("works with arrays when keys exist on the array", () => {
69
+ const arr = ["x"];
70
+ expect(isObjectWithKeys(arr, ["0"])).toBe(true);
71
+ expect(isObjectWithKeys(arr, ["length"])).toBe(true);
72
+ expect(isObjectWithKeys([], ["0"])).toBe(false);
73
+ });
74
+ });
75
+
76
+ describe("isRecord", () => {
77
+ it("returns true for plain object with string values (default)", () => {
78
+ expect(isRecord({})).toBe(true);
79
+ expect(isRecord({ a: "x", b: "y" })).toBe(true);
80
+ });
81
+
82
+ it("returns false for arrays and non-objects", () => {
83
+ expect(isRecord([] as unknown)).toBe(false);
84
+ expect(isRecord(1 as unknown)).toBe(false);
85
+ expect(isRecord(null as unknown)).toBe(false);
86
+ expect(isRecord(undefined as unknown)).toBe(false);
87
+ });
88
+
89
+ it("returns false when any value is not a string (default guards)", () => {
90
+ expect(isRecord({ a: 1 })).toBe(false);
91
+ expect(isRecord({ a: "x", b: 2 as unknown as string })).toBe(false);
92
+ });
93
+
94
+ it("respects a custom value guard (numbers)", () => {
95
+ const numberGuard = (v: unknown): v is number => typeof v === "number";
96
+ expect(isRecord({ a: 1, b: 2 }, { value: numberGuard })).toBe(true);
97
+ expect(isRecord({ a: 1, b: "x" }, { value: numberGuard })).toBe(false);
98
+ });
99
+
100
+ it("applies a custom key guard", () => {
101
+ const keyStartsWithA = (k: unknown): k is string =>
102
+ typeof k === "string" && k.startsWith("a");
103
+ expect(
104
+ isRecord({ apple: "x", aardvark: "y" }, { key: keyStartsWithA }),
105
+ ).toBe(true);
106
+ expect(isRecord({ banana: "x" }, { key: keyStartsWithA })).toBe(false);
107
+ });
108
+
109
+ it("objects with only symbol keys are considered records (no enumerable string keys)", () => {
110
+ const s = Symbol("s");
111
+ const obj = { [s]: "x" } as Record<symbol, string>;
112
+ // Object.entries ignores symbol keys; guard will see zero entries
113
+ expect(isRecord(obj)).toBe(true);
114
+ });
115
+ });
@@ -4,10 +4,20 @@
4
4
  * @returns True if the value is an object, false otherwise.
5
5
  * @internal
6
6
  */
7
- function isObject(value: unknown): value is object {
7
+ export function isObject(value: unknown): value is object {
8
8
  return typeof value === "object" && value !== null;
9
9
  }
10
10
 
11
+ /**
12
+ * Checks if a value is a string.
13
+ * @param value - The value to check.
14
+ * @returns True if the value is a string, false otherwise.
15
+ * @internal
16
+ */
17
+ export function isString(value: unknown): value is string {
18
+ return typeof value === "string";
19
+ }
20
+
11
21
  /**
12
22
  * Checks if a value is an object with specified keys.
13
23
  * @param value - The value to check.
@@ -21,3 +31,29 @@ export function isObjectWithKeys<key extends string>(
21
31
  ): value is Record<key, unknown> {
22
32
  return isObject(value) && keys.every((key) => key in value);
23
33
  }
34
+
35
+ /**
36
+ * Checks if a value is a record with string values.
37
+ * @param value - The value to check.
38
+ * @returns True if the value is a record with string values, false otherwise.
39
+ * @internal
40
+ */
41
+ export function isRecord<
42
+ K extends string | number | symbol = string,
43
+ V = string,
44
+ T extends Record<K, V> = Record<K, V>,
45
+ >(
46
+ value: unknown,
47
+ guards?: {
48
+ key?: (k: unknown) => k is K;
49
+ value?: (v: unknown) => v is V;
50
+ },
51
+ ): value is T {
52
+ const keyGuard = guards?.key ?? isString;
53
+ const valueGuard = guards?.value ?? isString;
54
+ return (
55
+ isObject(value) &&
56
+ !Array.isArray(value) &&
57
+ Object.entries(value).every(([k, v]) => keyGuard(k) && valueGuard(v))
58
+ );
59
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.109.2-nightly-f2121e9519719ef809986c919acc5069b5b7ce74-20251022000400";
1
+ export const version = "5.110.1";
@@ -4,6 +4,7 @@ import { eth_getTransactionReceipt } from "../../../../rpc/actions/eth_getTransa
4
4
  import { getRpcClient } from "../../../../rpc/rpc.js";
5
5
  import { sendAndConfirmTransaction } from "../../../../transaction/actions/send-and-confirm-transaction.js";
6
6
  import { sendBatchTransaction } from "../../../../transaction/actions/send-batch-transaction.js";
7
+ import type { SendTransactionOptions } from "../../../../transaction/actions/send-transaction.js";
7
8
  import { LruMap } from "../../../../utils/caching/lru.js";
8
9
  import type { Hex } from "../../../../utils/encoding/hex.js";
9
10
  import { randomBytesHex } from "../../../../utils/random.js";
@@ -22,21 +23,29 @@ const bundlesToTransactions = new LruMap<Hex[]>(1000);
22
23
  export async function inAppWalletSendCalls(args: {
23
24
  account: Account;
24
25
  calls: PreparedSendCall[];
26
+ chain: Chain;
25
27
  }): Promise<string> {
26
28
  const { account, calls } = args;
27
29
 
30
+ const transactions: SendTransactionOptions["transaction"][] = calls.map(
31
+ (call) => ({
32
+ ...call,
33
+ chain: args.chain,
34
+ }),
35
+ );
36
+
28
37
  const hashes: Hex[] = [];
29
38
  const id = randomBytesHex(65);
30
39
  bundlesToTransactions.set(id, hashes);
31
40
  if (account.sendBatchTransaction) {
32
41
  const receipt = await sendBatchTransaction({
33
42
  account,
34
- transactions: calls,
43
+ transactions,
35
44
  });
36
45
  hashes.push(receipt.transactionHash);
37
46
  bundlesToTransactions.set(id, hashes);
38
47
  } else {
39
- for (const tx of calls) {
48
+ for (const tx of transactions) {
40
49
  const receipt = await sendAndConfirmTransaction({
41
50
  account,
42
51
  transaction: tx,
@@ -341,6 +341,7 @@ export const create7702MinimalAccount = (args: {
341
341
  const id = await inAppWalletSendCalls({
342
342
  account: minimalAccount,
343
343
  calls: options.calls,
344
+ chain,
344
345
  });
345
346
  return { chain, client, id };
346
347
  },
@@ -277,6 +277,7 @@ export class EnclaveWallet implements IWebWallet {
277
277
  const id = await inAppWalletSendCalls({
278
278
  account: account,
279
279
  calls: options.calls,
280
+ chain,
280
281
  });
281
282
  return { chain, client, id };
282
283
  },
@@ -379,6 +379,7 @@ async function createSmartAccount(
379
379
  const id = await inAppWalletSendCalls({
380
380
  account: account,
381
381
  calls: options.calls,
382
+ chain,
382
383
  });
383
384
  return { chain, client, id };
384
385
  },
@@ -556,6 +557,7 @@ function createZkSyncAccount(args: {
556
557
  const id = await inAppWalletSendCalls({
557
558
  account: account,
558
559
  calls: options.calls,
560
+ chain,
559
561
  });
560
562
  return { chain, client, id };
561
563
  },