thirdweb 5.102.2 → 5.102.3

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 (126) hide show
  1. package/dist/cjs/bridge/Buy.js +7 -1
  2. package/dist/cjs/bridge/Buy.js.map +1 -1
  3. package/dist/cjs/bridge/Token.js +153 -0
  4. package/dist/cjs/bridge/Token.js.map +1 -0
  5. package/dist/cjs/bridge/index.js +3 -1
  6. package/dist/cjs/bridge/index.js.map +1 -1
  7. package/dist/cjs/extensions/erc1155/read/getNFTs.js +9 -2
  8. package/dist/cjs/extensions/erc1155/read/getNFTs.js.map +1 -1
  9. package/dist/cjs/extensions/erc721/read/getNFTs.js +9 -2
  10. package/dist/cjs/extensions/erc721/read/getNFTs.js.map +1 -1
  11. package/dist/cjs/pay/convert/cryptoToFiat.js +6 -38
  12. package/dist/cjs/pay/convert/cryptoToFiat.js.map +1 -1
  13. package/dist/cjs/pay/convert/fiatToCrypto.js +6 -38
  14. package/dist/cjs/pay/convert/fiatToCrypto.js.map +1 -1
  15. package/dist/cjs/pay/convert/get-token.js +19 -0
  16. package/dist/cjs/pay/convert/get-token.js.map +1 -0
  17. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +2 -2
  18. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  19. package/dist/cjs/react/core/utils/wallet.js +0 -48
  20. package/dist/cjs/react/core/utils/wallet.js.map +1 -1
  21. package/dist/cjs/react/native/ui/connect/ConnectedModal.js +5 -5
  22. package/dist/cjs/react/native/ui/connect/ConnectedModal.js.map +1 -1
  23. package/dist/cjs/react/web/ui/ConnectWallet/Details.js +7 -7
  24. package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
  25. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +2 -2
  26. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
  27. package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js +2 -2
  28. package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js.map +1 -1
  29. package/dist/cjs/version.js +1 -1
  30. package/dist/cjs/wallets/manager/index.js +1 -2
  31. package/dist/cjs/wallets/manager/index.js.map +1 -1
  32. package/dist/cjs/wallets/smart/is-smart-wallet.js +62 -5
  33. package/dist/cjs/wallets/smart/is-smart-wallet.js.map +1 -1
  34. package/dist/esm/bridge/Buy.js +7 -1
  35. package/dist/esm/bridge/Buy.js.map +1 -1
  36. package/dist/esm/bridge/Token.js +150 -0
  37. package/dist/esm/bridge/Token.js.map +1 -0
  38. package/dist/esm/bridge/index.js +1 -0
  39. package/dist/esm/bridge/index.js.map +1 -1
  40. package/dist/esm/extensions/erc1155/read/getNFTs.js +9 -2
  41. package/dist/esm/extensions/erc1155/read/getNFTs.js.map +1 -1
  42. package/dist/esm/extensions/erc721/read/getNFTs.js +9 -2
  43. package/dist/esm/extensions/erc721/read/getNFTs.js.map +1 -1
  44. package/dist/esm/pay/convert/cryptoToFiat.js +6 -38
  45. package/dist/esm/pay/convert/cryptoToFiat.js.map +1 -1
  46. package/dist/esm/pay/convert/fiatToCrypto.js +6 -38
  47. package/dist/esm/pay/convert/fiatToCrypto.js.map +1 -1
  48. package/dist/esm/pay/convert/get-token.js +16 -0
  49. package/dist/esm/pay/convert/get-token.js.map +1 -0
  50. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +1 -1
  51. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  52. package/dist/esm/react/core/utils/wallet.js +0 -47
  53. package/dist/esm/react/core/utils/wallet.js.map +1 -1
  54. package/dist/esm/react/native/ui/connect/ConnectedModal.js +5 -5
  55. package/dist/esm/react/native/ui/connect/ConnectedModal.js.map +1 -1
  56. package/dist/esm/react/web/ui/ConnectWallet/Details.js +7 -7
  57. package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
  58. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +1 -1
  59. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
  60. package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js +1 -1
  61. package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js.map +1 -1
  62. package/dist/esm/version.js +1 -1
  63. package/dist/esm/wallets/manager/index.js +1 -2
  64. package/dist/esm/wallets/manager/index.js.map +1 -1
  65. package/dist/esm/wallets/smart/is-smart-wallet.js +61 -5
  66. package/dist/esm/wallets/smart/is-smart-wallet.js.map +1 -1
  67. package/dist/types/bridge/Buy.d.ts +7 -1
  68. package/dist/types/bridge/Buy.d.ts.map +1 -1
  69. package/dist/types/bridge/Token.d.ts +140 -0
  70. package/dist/types/bridge/Token.d.ts.map +1 -0
  71. package/dist/types/bridge/index.d.ts +1 -0
  72. package/dist/types/bridge/index.d.ts.map +1 -1
  73. package/dist/types/extensions/erc1155/read/getNFTs.d.ts.map +1 -1
  74. package/dist/types/pay/convert/cryptoToFiat.d.ts.map +1 -1
  75. package/dist/types/pay/convert/fiatToCrypto.d.ts.map +1 -1
  76. package/dist/types/pay/convert/get-token.d.ts +3 -0
  77. package/dist/types/pay/convert/get-token.d.ts.map +1 -0
  78. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  79. package/dist/types/react/core/utils/wallet.d.ts +1 -5
  80. package/dist/types/react/core/utils/wallet.d.ts.map +1 -1
  81. package/dist/types/react/native/ui/connect/ConnectedModal.d.ts.map +1 -1
  82. package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
  83. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts.map +1 -1
  84. package/dist/types/version.d.ts +1 -1
  85. package/dist/types/wallets/manager/index.d.ts.map +1 -1
  86. package/dist/types/wallets/smart/is-smart-wallet.d.ts +5 -1
  87. package/dist/types/wallets/smart/is-smart-wallet.d.ts.map +1 -1
  88. package/package.json +1 -1
  89. package/src/bridge/Buy.ts +7 -1
  90. package/src/bridge/Token.test.ts +90 -0
  91. package/src/bridge/Token.ts +184 -0
  92. package/src/bridge/index.ts +1 -0
  93. package/src/extensions/erc1155/read/getNFTs.ts +8 -2
  94. package/src/extensions/erc721/read/getNFTs.ts +8 -2
  95. package/src/pay/convert/cryptoToFiat.test.ts +1 -18
  96. package/src/pay/convert/cryptoToFiat.ts +6 -52
  97. package/src/pay/convert/fiatToCrypto.test.ts +1 -18
  98. package/src/pay/convert/fiatToCrypto.ts +6 -51
  99. package/src/pay/convert/get-token.ts +24 -0
  100. package/src/react/core/hooks/transaction/useSendTransaction.ts +1 -1
  101. package/src/react/core/utils/wallet.ts +1 -49
  102. package/src/react/native/ui/connect/ConnectedModal.tsx +5 -5
  103. package/src/react/web/ui/ConnectWallet/Details.tsx +7 -7
  104. package/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx +1 -1
  105. package/src/react/web/ui/TransactionButton/DepositScreen.tsx +1 -1
  106. package/src/version.ts +1 -1
  107. package/src/wallets/manager/index.ts +1 -2
  108. package/src/wallets/smart/is-smart-wallet.test.ts +163 -1
  109. package/src/wallets/smart/is-smart-wallet.ts +62 -5
  110. package/dist/cjs/react/core/utils/isSmartWallet.js +0 -12
  111. package/dist/cjs/react/core/utils/isSmartWallet.js.map +0 -1
  112. package/dist/cjs/wallets/smart/get-smart-wallet-config.js +0 -23
  113. package/dist/cjs/wallets/smart/get-smart-wallet-config.js.map +0 -1
  114. package/dist/esm/react/core/utils/isSmartWallet.js +0 -9
  115. package/dist/esm/react/core/utils/isSmartWallet.js.map +0 -1
  116. package/dist/esm/wallets/smart/get-smart-wallet-config.js +0 -20
  117. package/dist/esm/wallets/smart/get-smart-wallet-config.js.map +0 -1
  118. package/dist/types/react/core/utils/isSmartWallet.d.ts +0 -3
  119. package/dist/types/react/core/utils/isSmartWallet.d.ts.map +0 -1
  120. package/dist/types/wallets/smart/get-smart-wallet-config.d.ts +0 -13
  121. package/dist/types/wallets/smart/get-smart-wallet-config.d.ts.map +0 -1
  122. package/src/react/core/utils/isSmartWallet.test.ts +0 -19
  123. package/src/react/core/utils/isSmartWallet.ts +0 -12
  124. package/src/react/core/utils/wallet.test.ts +0 -77
  125. package/src/wallets/smart/get-smart-wallet-config.test.ts +0 -67
  126. package/src/wallets/smart/get-smart-wallet-config.ts +0 -24
@@ -5,6 +5,7 @@ import { NATIVE_TOKEN_ADDRESS } from "../../../../../../constants/addresses.js";
5
5
  import { formatNumber } from "../../../../../../utils/formatNumber.js";
6
6
  import { toTokens } from "../../../../../../utils/units.js";
7
7
  import type { Account } from "../../../../../../wallets/interfaces/wallet.js";
8
+ import { hasSponsoredTransactionsEnabled } from "../../../../../../wallets/smart/is-smart-wallet.js";
8
9
  import { useCustomTheme } from "../../../../../core/design-system/CustomThemeProvider.js";
9
10
  import {
10
11
  fontSize,
@@ -16,7 +17,6 @@ import { useChainMetadata } from "../../../../../core/hooks/others/useChainQuery
16
17
  import { useWalletBalance } from "../../../../../core/hooks/others/useWalletBalance.js";
17
18
  import { useActiveAccount } from "../../../../../core/hooks/wallets/useActiveAccount.js";
18
19
  import { useActiveWallet } from "../../../../../core/hooks/wallets/useActiveWallet.js";
19
- import { hasSponsoredTransactionsEnabled } from "../../../../../core/utils/wallet.js";
20
20
  import { ErrorState } from "../../../../wallets/shared/ErrorState.js";
21
21
  import { LoadingScreen } from "../../../../wallets/shared/LoadingScreen.js";
22
22
  import type { PayEmbedConnectOptions } from "../../../PayEmbed.js";
@@ -4,6 +4,7 @@ import type { PreparedTransaction } from "../../../../transaction/prepare-transa
4
4
  import { shortenAddress } from "../../../../utils/address.js";
5
5
  import { formatNumber } from "../../../../utils/formatNumber.js";
6
6
  import { toTokens } from "../../../../utils/units.js";
7
+ import { hasSponsoredTransactionsEnabled } from "../../../../wallets/smart/is-smart-wallet.js";
7
8
  import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
8
9
  import {
9
10
  fontSize,
@@ -13,7 +14,6 @@ import {
13
14
  } from "../../../core/design-system/index.js";
14
15
  import { useActiveAccount } from "../../../core/hooks/wallets/useActiveAccount.js";
15
16
  import { useActiveWallet } from "../../../core/hooks/wallets/useActiveWallet.js";
16
- import { hasSponsoredTransactionsEnabled } from "../../../core/utils/wallet.js";
17
17
  import { ErrorState } from "../../wallets/shared/ErrorState.js";
18
18
  import { LoadingScreen } from "../../wallets/shared/LoadingScreen.js";
19
19
  import { CoinsIcon } from "../ConnectWallet/icons/CoinsIcon.js";
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.102.2";
1
+ export const version = "5.102.3";
@@ -1,7 +1,6 @@
1
1
  import type { Chain } from "../../chains/types.js";
2
2
  import { cacheChains } from "../../chains/utils.js";
3
3
  import type { ThirdwebClient } from "../../client/client.js";
4
- import { hasSmartAccount } from "../../react/core/utils/isSmartWallet.js";
5
4
  import { computedStore } from "../../reactive/computedStore.js";
6
5
  import { effect } from "../../reactive/effect.js";
7
6
  import { createStore } from "../../reactive/store.js";
@@ -135,7 +134,7 @@ export function createConnectionManager(storage: AsyncStorage) {
135
134
  }
136
135
 
137
136
  const activeWallet = await (async () => {
138
- if (options?.accountAbstraction && !hasSmartAccount(wallet)) {
137
+ if (options?.accountAbstraction && !isSmartWallet(wallet)) {
139
138
  return await handleSmartWalletConnection(
140
139
  wallet,
141
140
  options.client,
@@ -1,6 +1,9 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
  import type { Wallet } from "../interfaces/wallet.js";
3
- import { isSmartWallet } from "./is-smart-wallet.js";
3
+ import {
4
+ hasSponsoredTransactionsEnabled,
5
+ isSmartWallet,
6
+ } from "./is-smart-wallet.js";
4
7
 
5
8
  describe("isSmartWallet", () => {
6
9
  it("should return true for smart wallet ID", () => {
@@ -22,6 +25,34 @@ describe("isSmartWallet", () => {
22
25
  expect(isSmartWallet(wallet)).toBe(true);
23
26
  });
24
27
 
28
+ it("should return true for wallet with EIP7702 config", () => {
29
+ const wallet = {
30
+ id: "inApp",
31
+ getConfig: () => ({
32
+ executionMode: {
33
+ mode: "EIP7702",
34
+ },
35
+ }),
36
+ } as Wallet;
37
+ expect(isSmartWallet(wallet)).toBe(true);
38
+ });
39
+
40
+ it("should return true for wallet with EIP4337 config", () => {
41
+ const wallet = {
42
+ id: "inApp",
43
+ getConfig: () => ({
44
+ executionMode: {
45
+ mode: "EIP4337",
46
+ smartAccount: {
47
+ chain: { id: 1, name: "test", rpc: "test" },
48
+ sponsorGas: true,
49
+ },
50
+ },
51
+ }),
52
+ } as Wallet;
53
+ expect(isSmartWallet(wallet)).toBe(true);
54
+ });
55
+
25
56
  it("should return false for non-smart wallet", () => {
26
57
  const wallet = {
27
58
  id: "inApp",
@@ -56,3 +87,134 @@ describe("isSmartWallet", () => {
56
87
  expect(isSmartWallet(wallet)).toBe(false);
57
88
  });
58
89
  });
90
+
91
+ describe("hasSponsoredTransactionsEnabled", () => {
92
+ it("should return false for undefined wallet", () => {
93
+ expect(hasSponsoredTransactionsEnabled(undefined)).toBe(false);
94
+ });
95
+
96
+ it("should handle smart wallet with sponsorGas config", () => {
97
+ const mockSmartWallet = {
98
+ id: "smart",
99
+ getConfig: () => ({ sponsorGas: true }),
100
+ } as Wallet;
101
+ expect(hasSponsoredTransactionsEnabled(mockSmartWallet)).toBe(true);
102
+
103
+ const mockSmartWalletDisabled = {
104
+ id: "smart",
105
+ getConfig: () => ({ sponsorGas: false }),
106
+ } as Wallet;
107
+ expect(hasSponsoredTransactionsEnabled(mockSmartWalletDisabled)).toBe(
108
+ false,
109
+ );
110
+ });
111
+
112
+ it("should handle smart wallet with gasless config", () => {
113
+ const mockSmartWallet = {
114
+ id: "smart",
115
+ getConfig: () => ({ gasless: true }),
116
+ } as Wallet;
117
+ expect(hasSponsoredTransactionsEnabled(mockSmartWallet)).toBe(true);
118
+ });
119
+
120
+ it("should handle inApp wallet with smartAccount config", () => {
121
+ const mockInAppWallet = {
122
+ id: "inApp",
123
+ getConfig: () => ({
124
+ smartAccount: {
125
+ sponsorGas: true,
126
+ },
127
+ }),
128
+ } as Wallet;
129
+ expect(hasSponsoredTransactionsEnabled(mockInAppWallet)).toBe(true);
130
+
131
+ const mockInAppWalletDisabled = {
132
+ id: "inApp",
133
+ getConfig: () => ({
134
+ smartAccount: {
135
+ sponsorGas: false,
136
+ },
137
+ }),
138
+ } as Wallet;
139
+ expect(hasSponsoredTransactionsEnabled(mockInAppWalletDisabled)).toBe(
140
+ false,
141
+ );
142
+ });
143
+
144
+ it("should handle inApp wallet with EIP7702 config", () => {
145
+ const mockInAppWallet = {
146
+ id: "inApp",
147
+ getConfig: () => ({
148
+ executionMode: {
149
+ mode: "EIP7702",
150
+ sponsorGas: true,
151
+ },
152
+ }),
153
+ } as Wallet;
154
+ expect(hasSponsoredTransactionsEnabled(mockInAppWallet)).toBe(true);
155
+
156
+ const mockInAppWalletDisabled = {
157
+ id: "inApp",
158
+ getConfig: () => ({
159
+ executionMode: {
160
+ mode: "EIP7702",
161
+ },
162
+ }),
163
+ } as Wallet;
164
+ expect(hasSponsoredTransactionsEnabled(mockInAppWalletDisabled)).toBe(
165
+ false,
166
+ );
167
+ });
168
+
169
+ it("should handle inApp wallet with EIP4337 config", () => {
170
+ const mockInAppWallet = {
171
+ id: "inApp",
172
+ getConfig: () => ({
173
+ executionMode: {
174
+ mode: "EIP4337",
175
+ smartAccount: {
176
+ chain: { id: 1, name: "test", rpc: "test" },
177
+ sponsorGas: true,
178
+ },
179
+ },
180
+ }),
181
+ } as Wallet;
182
+ expect(hasSponsoredTransactionsEnabled(mockInAppWallet)).toBe(true);
183
+
184
+ const mockInAppWalletDisabled = {
185
+ id: "inApp",
186
+ getConfig: () => ({
187
+ executionMode: {
188
+ mode: "EIP4337",
189
+ smartAccount: {
190
+ chain: { id: 1, name: "test", rpc: "test" },
191
+ sponsorGas: false,
192
+ },
193
+ },
194
+ }),
195
+ } as Wallet;
196
+ expect(hasSponsoredTransactionsEnabled(mockInAppWalletDisabled)).toBe(
197
+ false,
198
+ );
199
+ });
200
+
201
+ it("should handle inApp wallet with gasless config", () => {
202
+ const mockInAppWallet = {
203
+ id: "inApp",
204
+ getConfig: () => ({
205
+ smartAccount: {
206
+ gasless: true,
207
+ },
208
+ }),
209
+ } as Wallet;
210
+ expect(hasSponsoredTransactionsEnabled(mockInAppWallet)).toBe(true);
211
+ });
212
+
213
+ it("should return false for regular wallet without smart account config", () => {
214
+ const mockRegularWallet = {
215
+ id: "inApp",
216
+ getConfig: () => ({}),
217
+ } as Wallet;
218
+ expect(hasSponsoredTransactionsEnabled(mockRegularWallet)).toBe(false);
219
+ });
220
+ });
@@ -1,3 +1,4 @@
1
+ import { isEcosystemWallet } from "../ecosystem/is-ecosystem-wallet.js";
1
2
  import type { Wallet } from "../interfaces/wallet.js";
2
3
 
3
4
  /**
@@ -7,15 +8,71 @@ import type { Wallet } from "../interfaces/wallet.js";
7
8
  * @returns {boolean} True if the wallet is a smart wallet, false otherwise.
8
9
  * @internal
9
10
  */
10
- export function isSmartWallet(wallet: Wallet): boolean {
11
- if (wallet.id === "smart") {
12
- return true;
11
+ export function isSmartWallet(activeWallet?: Wallet): boolean {
12
+ if (!activeWallet) {
13
+ return false;
13
14
  }
14
15
 
15
- const config = wallet.getConfig();
16
- if (!!config && "smartAccount" in config && !!config.smartAccount) {
16
+ if (activeWallet.id === "smart") {
17
17
  return true;
18
18
  }
19
19
 
20
+ if (activeWallet.id === "inApp" || isEcosystemWallet(activeWallet)) {
21
+ const options = (activeWallet as Wallet<"inApp">).getConfig();
22
+ if (options && "smartAccount" in options && options.smartAccount) {
23
+ return true;
24
+ }
25
+ if (options?.executionMode) {
26
+ const execMode = options.executionMode;
27
+ return execMode.mode === "EIP4337" || execMode.mode === "EIP7702";
28
+ }
29
+ }
20
30
  return false;
21
31
  }
32
+
33
+ /**
34
+ * @internal
35
+ */
36
+ export function hasSponsoredTransactionsEnabled(wallet: Wallet | undefined) {
37
+ if (!wallet) {
38
+ return false;
39
+ }
40
+ let sponsoredTransactionsEnabled = false;
41
+ if (wallet && wallet.id === "smart") {
42
+ const options = (wallet as Wallet<"smart">).getConfig();
43
+ if ("sponsorGas" in options) {
44
+ sponsoredTransactionsEnabled = options.sponsorGas;
45
+ }
46
+ if ("gasless" in options) {
47
+ sponsoredTransactionsEnabled = options.gasless;
48
+ }
49
+ }
50
+ if (wallet && (wallet.id === "inApp" || isEcosystemWallet(wallet))) {
51
+ const options = (wallet as Wallet<"inApp">).getConfig();
52
+ if (options && "smartAccount" in options && options.smartAccount) {
53
+ const smartOptions = options.smartAccount;
54
+ if ("sponsorGas" in smartOptions) {
55
+ sponsoredTransactionsEnabled = smartOptions.sponsorGas;
56
+ }
57
+ if ("gasless" in smartOptions) {
58
+ sponsoredTransactionsEnabled = smartOptions.gasless;
59
+ }
60
+ }
61
+ if (options?.executionMode) {
62
+ const execMode = options.executionMode;
63
+ if (execMode.mode === "EIP4337") {
64
+ const smartOptions = execMode.smartAccount;
65
+ if (smartOptions && "sponsorGas" in smartOptions) {
66
+ sponsoredTransactionsEnabled = smartOptions.sponsorGas;
67
+ }
68
+ if (smartOptions && "gasless" in smartOptions) {
69
+ sponsoredTransactionsEnabled = smartOptions.gasless;
70
+ }
71
+ }
72
+ if (execMode.mode === "EIP7702") {
73
+ sponsoredTransactionsEnabled = execMode.sponsorGas || false;
74
+ }
75
+ }
76
+ }
77
+ return sponsoredTransactionsEnabled;
78
+ }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasSmartAccount = hasSmartAccount;
4
- const is_ecosystem_wallet_js_1 = require("../../../wallets/ecosystem/is-ecosystem-wallet.js");
5
- function hasSmartAccount(activeWallet) {
6
- const config = activeWallet?.getConfig();
7
- return (activeWallet !== undefined &&
8
- (activeWallet.id === "smart" ||
9
- (activeWallet.id === "inApp" && !!config && "smartAccount" in config) ||
10
- ((0, is_ecosystem_wallet_js_1.isEcosystemWallet)(activeWallet) && !!config && "smartAccount" in config)));
11
- }
12
- //# sourceMappingURL=isSmartWallet.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isSmartWallet.js","sourceRoot":"","sources":["../../../../../src/react/core/utils/isSmartWallet.ts"],"names":[],"mappings":";;AAGA,0CAQC;AAXD,8FAAsF;AAGtF,SAAgB,eAAe,CAAC,YAAqB;IACnD,MAAM,MAAM,GAAG,YAAY,EAAE,SAAS,EAAE,CAAC;IACzC,OAAO,CACL,YAAY,KAAK,SAAS;QAC1B,CAAC,YAAY,CAAC,EAAE,KAAK,OAAO;YAC1B,CAAC,YAAY,CAAC,EAAE,KAAK,OAAO,IAAI,CAAC,CAAC,MAAM,IAAI,cAAc,IAAI,MAAM,CAAC;YACrE,CAAC,IAAA,0CAAiB,EAAC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,cAAc,IAAI,MAAM,CAAC,CAAC,CAC7E,CAAC;AACJ,CAAC"}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSmartWallet = getSmartWallet;
4
- /**
5
- * Gets the smart wallet configuration for a given wallet.
6
- *
7
- * @param {Wallet} wallet - The wallet to check.
8
- * @returns {SmartWalletOptions} The smart wallet configuration.
9
- *
10
- * @throws {Error} If the wallet is not a smart wallet.
11
- * @internal
12
- */
13
- function getSmartWallet(wallet) {
14
- if (wallet.id === "smart") {
15
- return wallet.getConfig();
16
- }
17
- const config = wallet.getConfig();
18
- if (!!config && "smartAccount" in config && !!config?.smartAccount) {
19
- return config.smartAccount;
20
- }
21
- throw new Error("Wallet is not a smart wallet");
22
- }
23
- //# sourceMappingURL=get-smart-wallet-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-smart-wallet-config.js","sourceRoot":"","sources":["../../../../src/wallets/smart/get-smart-wallet-config.ts"],"names":[],"mappings":";;AAYA,wCAWC;AApBD;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAAC,MAAc;IAC3C,IAAI,MAAM,CAAC,EAAE,KAAK,OAAO,EAAE,CAAC;QAC1B,OAAQ,MAA0B,CAAC,SAAS,EAAE,CAAC;IACjD,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IAClC,IAAI,CAAC,CAAC,MAAM,IAAI,cAAc,IAAI,MAAM,IAAI,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC;QACnE,OAAO,MAAM,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;AAClD,CAAC"}
@@ -1,9 +0,0 @@
1
- import { isEcosystemWallet } from "../../../wallets/ecosystem/is-ecosystem-wallet.js";
2
- export function hasSmartAccount(activeWallet) {
3
- const config = activeWallet?.getConfig();
4
- return (activeWallet !== undefined &&
5
- (activeWallet.id === "smart" ||
6
- (activeWallet.id === "inApp" && !!config && "smartAccount" in config) ||
7
- (isEcosystemWallet(activeWallet) && !!config && "smartAccount" in config)));
8
- }
9
- //# sourceMappingURL=isSmartWallet.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isSmartWallet.js","sourceRoot":"","sources":["../../../../../src/react/core/utils/isSmartWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mDAAmD,CAAC;AAGtF,MAAM,UAAU,eAAe,CAAC,YAAqB;IACnD,MAAM,MAAM,GAAG,YAAY,EAAE,SAAS,EAAE,CAAC;IACzC,OAAO,CACL,YAAY,KAAK,SAAS;QAC1B,CAAC,YAAY,CAAC,EAAE,KAAK,OAAO;YAC1B,CAAC,YAAY,CAAC,EAAE,KAAK,OAAO,IAAI,CAAC,CAAC,MAAM,IAAI,cAAc,IAAI,MAAM,CAAC;YACrE,CAAC,iBAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,cAAc,IAAI,MAAM,CAAC,CAAC,CAC7E,CAAC;AACJ,CAAC"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Gets the smart wallet configuration for a given wallet.
3
- *
4
- * @param {Wallet} wallet - The wallet to check.
5
- * @returns {SmartWalletOptions} The smart wallet configuration.
6
- *
7
- * @throws {Error} If the wallet is not a smart wallet.
8
- * @internal
9
- */
10
- export function getSmartWallet(wallet) {
11
- if (wallet.id === "smart") {
12
- return wallet.getConfig();
13
- }
14
- const config = wallet.getConfig();
15
- if (!!config && "smartAccount" in config && !!config?.smartAccount) {
16
- return config.smartAccount;
17
- }
18
- throw new Error("Wallet is not a smart wallet");
19
- }
20
- //# sourceMappingURL=get-smart-wallet-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-smart-wallet-config.js","sourceRoot":"","sources":["../../../../src/wallets/smart/get-smart-wallet-config.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,IAAI,MAAM,CAAC,EAAE,KAAK,OAAO,EAAE,CAAC;QAC1B,OAAQ,MAA0B,CAAC,SAAS,EAAE,CAAC;IACjD,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IAClC,IAAI,CAAC,CAAC,MAAM,IAAI,cAAc,IAAI,MAAM,IAAI,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC;QACnE,OAAO,MAAM,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;AAClD,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { Wallet } from "../../../wallets/interfaces/wallet.js";
2
- export declare function hasSmartAccount(activeWallet?: Wallet): boolean;
3
- //# sourceMappingURL=isSmartWallet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isSmartWallet.d.ts","sourceRoot":"","sources":["../../../../../src/react/core/utils/isSmartWallet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAEpE,wBAAgB,eAAe,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAQ9D"}
@@ -1,13 +0,0 @@
1
- import type { Wallet } from "../interfaces/wallet.js";
2
- import type { SmartWalletOptions } from "./types.js";
3
- /**
4
- * Gets the smart wallet configuration for a given wallet.
5
- *
6
- * @param {Wallet} wallet - The wallet to check.
7
- * @returns {SmartWalletOptions} The smart wallet configuration.
8
- *
9
- * @throws {Error} If the wallet is not a smart wallet.
10
- * @internal
11
- */
12
- export declare function getSmartWallet(wallet: Wallet): SmartWalletOptions;
13
- //# sourceMappingURL=get-smart-wallet-config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-smart-wallet-config.d.ts","sourceRoot":"","sources":["../../../../src/wallets/smart/get-smart-wallet-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAWjE"}
@@ -1,19 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { ANVIL_CHAIN } from "~test/chains.js";
3
- import { createWallet } from "../../../wallets/create-wallet.js";
4
- import { hasSmartAccount } from "./isSmartWallet.js";
5
-
6
- describe("isSmartWallet", () => {
7
- it("should work if id is inApp and has smartAccount in wallet config", () => {
8
- const wallet = createWallet("inApp", {
9
- smartAccount: {
10
- chain: ANVIL_CHAIN,
11
- sponsorGas: true,
12
- overrides: {
13
- bundlerUrl: "your-bundler-url",
14
- },
15
- },
16
- });
17
- expect(hasSmartAccount(wallet)).toBe(true);
18
- });
19
- });
@@ -1,12 +0,0 @@
1
- import { isEcosystemWallet } from "../../../wallets/ecosystem/is-ecosystem-wallet.js";
2
- import type { Wallet } from "../../../wallets/interfaces/wallet.js";
3
-
4
- export function hasSmartAccount(activeWallet?: Wallet): boolean {
5
- const config = activeWallet?.getConfig();
6
- return (
7
- activeWallet !== undefined &&
8
- (activeWallet.id === "smart" ||
9
- (activeWallet.id === "inApp" && !!config && "smartAccount" in config) ||
10
- (isEcosystemWallet(activeWallet) && !!config && "smartAccount" in config))
11
- );
12
- }
@@ -1,77 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import type { Wallet } from "../../../wallets/interfaces/wallet";
3
- import { hasSponsoredTransactionsEnabled } from "./wallet";
4
-
5
- describe("hasSponsoredTransactionsEnabled", () => {
6
- it("should return false for undefined wallet", () => {
7
- expect(hasSponsoredTransactionsEnabled(undefined)).toBe(false);
8
- });
9
-
10
- it("should handle smart wallet with sponsorGas config", () => {
11
- const mockSmartWallet = {
12
- id: "smart",
13
- getConfig: () => ({ sponsorGas: true }),
14
- } as Wallet;
15
- expect(hasSponsoredTransactionsEnabled(mockSmartWallet)).toBe(true);
16
-
17
- const mockSmartWalletDisabled = {
18
- id: "smart",
19
- getConfig: () => ({ sponsorGas: false }),
20
- } as Wallet;
21
- expect(hasSponsoredTransactionsEnabled(mockSmartWalletDisabled)).toBe(
22
- false,
23
- );
24
- });
25
-
26
- it("should handle smart wallet with gasless config", () => {
27
- const mockSmartWallet = {
28
- id: "smart",
29
- getConfig: () => ({ gasless: true }),
30
- } as Wallet;
31
- expect(hasSponsoredTransactionsEnabled(mockSmartWallet)).toBe(true);
32
- });
33
-
34
- it("should handle inApp wallet with smartAccount config", () => {
35
- const mockInAppWallet = {
36
- id: "inApp",
37
- getConfig: () => ({
38
- smartAccount: {
39
- sponsorGas: true,
40
- },
41
- }),
42
- } as Wallet;
43
- expect(hasSponsoredTransactionsEnabled(mockInAppWallet)).toBe(true);
44
-
45
- const mockInAppWalletDisabled = {
46
- id: "inApp",
47
- getConfig: () => ({
48
- smartAccount: {
49
- sponsorGas: false,
50
- },
51
- }),
52
- } as Wallet;
53
- expect(hasSponsoredTransactionsEnabled(mockInAppWalletDisabled)).toBe(
54
- false,
55
- );
56
- });
57
-
58
- it("should handle inApp wallet with gasless config", () => {
59
- const mockInAppWallet = {
60
- id: "inApp",
61
- getConfig: () => ({
62
- smartAccount: {
63
- gasless: true,
64
- },
65
- }),
66
- } as Wallet;
67
- expect(hasSponsoredTransactionsEnabled(mockInAppWallet)).toBe(true);
68
- });
69
-
70
- it("should return false for regular wallet without smart account config", () => {
71
- const mockRegularWallet = {
72
- id: "inApp",
73
- getConfig: () => ({}),
74
- } as Wallet;
75
- expect(hasSponsoredTransactionsEnabled(mockRegularWallet)).toBe(false);
76
- });
77
- });
@@ -1,67 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { optimism } from "../../chains/chain-definitions/optimism.js";
3
- import type { Wallet } from "../interfaces/wallet.js";
4
- import { getSmartWallet } from "./get-smart-wallet-config.js";
5
- import type { SmartWalletOptions } from "./types.js";
6
-
7
- describe("getSmartWallet", () => {
8
- const mockSmartWalletConfig: SmartWalletOptions = {
9
- chain: optimism,
10
- sponsorGas: false,
11
- };
12
-
13
- it("should return config for smart wallet ID", () => {
14
- const wallet = {
15
- id: "smart",
16
- getConfig: () => mockSmartWalletConfig,
17
- } as Wallet<"smart">;
18
-
19
- expect(getSmartWallet(wallet)).toBe(mockSmartWalletConfig);
20
- });
21
-
22
- it("should return smartAccount config for wallet with smartAccount", () => {
23
- const wallet = {
24
- id: "inApp",
25
- getConfig: () => ({
26
- smartAccount: mockSmartWalletConfig,
27
- }),
28
- } as Wallet;
29
-
30
- expect(getSmartWallet(wallet)).toBe(mockSmartWalletConfig);
31
- });
32
-
33
- it("should throw error for non-smart wallet", () => {
34
- const wallet = {
35
- id: "inApp",
36
- getConfig: () => ({}),
37
- } as Wallet;
38
-
39
- expect(() => getSmartWallet(wallet)).toThrow(
40
- "Wallet is not a smart wallet",
41
- );
42
- });
43
-
44
- it("should throw error when getConfig returns null", () => {
45
- const wallet = {
46
- id: "inApp",
47
- getConfig: () => null,
48
- // biome-ignore lint/suspicious/noExplicitAny: Testing invalid config
49
- } as any as Wallet;
50
-
51
- expect(() => getSmartWallet(wallet)).toThrow(
52
- "Wallet is not a smart wallet",
53
- );
54
- });
55
-
56
- it("should throw error when smartAccount is null", () => {
57
- const wallet = {
58
- id: "inApp",
59
- getConfig: () => ({ smartAccount: null }),
60
- // biome-ignore lint/suspicious/noExplicitAny: Testing invalid config
61
- } as any as Wallet;
62
-
63
- expect(() => getSmartWallet(wallet)).toThrow(
64
- "Wallet is not a smart wallet",
65
- );
66
- });
67
- });
@@ -1,24 +0,0 @@
1
- import type { Wallet } from "../interfaces/wallet.js";
2
- import type { SmartWalletOptions } from "./types.js";
3
-
4
- /**
5
- * Gets the smart wallet configuration for a given wallet.
6
- *
7
- * @param {Wallet} wallet - The wallet to check.
8
- * @returns {SmartWalletOptions} The smart wallet configuration.
9
- *
10
- * @throws {Error} If the wallet is not a smart wallet.
11
- * @internal
12
- */
13
- export function getSmartWallet(wallet: Wallet): SmartWalletOptions {
14
- if (wallet.id === "smart") {
15
- return (wallet as Wallet<"smart">).getConfig();
16
- }
17
-
18
- const config = wallet.getConfig();
19
- if (!!config && "smartAccount" in config && !!config?.smartAccount) {
20
- return config.smartAccount;
21
- }
22
-
23
- throw new Error("Wallet is not a smart wallet");
24
- }