@crossmint/wallets-sdk 1.0.0-beta.5 → 1.0.0-beta.7

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 (171) hide show
  1. package/README.md +175 -49
  2. package/dist/api/__tests__/constants.d.cts +1 -1
  3. package/dist/api/__tests__/constants.d.ts +1 -1
  4. package/dist/api/__tests__/test-utils.cjs +1 -1
  5. package/dist/api/__tests__/test-utils.d.cts +1 -1
  6. package/dist/api/__tests__/test-utils.d.ts +1 -1
  7. package/dist/api/__tests__/test-utils.js +1 -1
  8. package/dist/api/client.cjs +1 -1
  9. package/dist/api/client.d.cts +1 -1
  10. package/dist/api/client.d.ts +1 -1
  11. package/dist/api/client.js +1 -1
  12. package/dist/api/index.cjs +1 -1
  13. package/dist/api/index.d.cts +1 -1
  14. package/dist/api/index.d.ts +1 -1
  15. package/dist/api/index.js +1 -1
  16. package/dist/api/types.d.cts +1 -1
  17. package/dist/api/types.d.ts +1 -1
  18. package/dist/chains/chains.cjs +1 -1
  19. package/dist/chains/chains.js +1 -1
  20. package/dist/chunk-2AKP3GZ7.js +3 -0
  21. package/dist/{chunk-HPRRBZOO.cjs → chunk-2UJBCUG2.cjs} +1 -1
  22. package/dist/{chunk-5AMNTK5L.js → chunk-2X65YHU4.js} +1 -1
  23. package/dist/{chunk-ZXOKPK5Y.cjs → chunk-2XOKOXIL.cjs} +1 -1
  24. package/dist/{chunk-HJMLB3CZ.cjs → chunk-3AJ7OWQE.cjs} +1 -1
  25. package/dist/{chunk-YYHIRIRF.js → chunk-5QKUXVP3.js} +1 -1
  26. package/dist/chunk-5Z6QHCTT.cjs +3 -0
  27. package/dist/{chunk-GN7GYBJA.cjs → chunk-7O3CV5HX.cjs} +1 -1
  28. package/dist/{chunk-3LIYGJ26.js → chunk-A4ENPOX6.js} +1 -1
  29. package/dist/{chunk-FSW2NPEJ.cjs → chunk-BP3WBO3W.cjs} +1 -1
  30. package/dist/{chunk-QPNYLHYO.cjs → chunk-CKZPF7KE.cjs} +1 -1
  31. package/dist/{chunk-Y22BJFQT.cjs → chunk-CV5GT7CP.cjs} +1 -1
  32. package/dist/{chunk-2G7S3WW3.js → chunk-D3CCPMC3.js} +1 -1
  33. package/dist/chunk-D6SLJ5C2.cjs +1 -0
  34. package/dist/{chunk-DRTL6SPT.js → chunk-FNWSI6UN.js} +1 -1
  35. package/dist/{chunk-YNQPYZGU.js → chunk-HQVHXT3U.js} +1 -1
  36. package/dist/chunk-J7C3SSSQ.js +1 -0
  37. package/dist/{chunk-EPJRLPAI.cjs → chunk-JJKL6FU2.cjs} +1 -1
  38. package/dist/{chunk-MXNC4GJQ.cjs → chunk-JMCNCVQN.cjs} +1 -1
  39. package/dist/{chunk-MCVOUQFZ.cjs → chunk-LECLHOLK.cjs} +1 -1
  40. package/dist/{chunk-65HJGWCL.js → chunk-LLQEZP55.js} +1 -1
  41. package/dist/{chunk-OYHK6BIR.js → chunk-MKKB6W5V.js} +1 -1
  42. package/dist/{chunk-QZ5WUDCX.js → chunk-MTKY5MIE.js} +1 -1
  43. package/dist/{chunk-JSE5PYVY.cjs → chunk-NR4PS5NF.cjs} +1 -1
  44. package/dist/{chunk-DWEJKOHG.js → chunk-OYPXGE5H.js} +1 -1
  45. package/dist/{chunk-I2PY7FD5.cjs → chunk-P3ZA2ACP.cjs} +1 -1
  46. package/dist/{chunk-V3PIHRNQ.cjs → chunk-RKMOWHVB.cjs} +1 -1
  47. package/dist/{chunk-AT4UIPAG.js → chunk-SAXV4RQK.js} +1 -1
  48. package/dist/{chunk-H7AD7AFJ.js → chunk-SG4NRUNV.js} +1 -1
  49. package/dist/{chunk-CW2GPBXZ.cjs → chunk-V5A3FGH2.cjs} +1 -1
  50. package/dist/chunk-VADIEIDS.js +1 -0
  51. package/dist/{chunk-6Z2HKIQA.cjs → chunk-VDT2DSTW.cjs} +1 -1
  52. package/dist/{chunk-XVNWOU37.js → chunk-Y2OIXWOS.js} +1 -1
  53. package/dist/{chunk-CV3WPOEA.js → chunk-Z5BYVIWY.js} +1 -1
  54. package/dist/index.cjs +1 -1
  55. package/dist/index.d.cts +1 -1
  56. package/dist/index.d.ts +1 -1
  57. package/dist/index.js +1 -1
  58. package/dist/logger/index.cjs +1 -1
  59. package/dist/logger/index.js +1 -1
  60. package/dist/logger/init.cjs +1 -1
  61. package/dist/logger/init.js +1 -1
  62. package/dist/sdk.cjs +1 -1
  63. package/dist/sdk.d.cts +1 -2
  64. package/dist/sdk.d.ts +1 -2
  65. package/dist/sdk.js +1 -1
  66. package/dist/signers/device.d.cts +1 -1
  67. package/dist/signers/device.d.ts +1 -1
  68. package/dist/signers/evm-api-key.d.cts +1 -1
  69. package/dist/signers/evm-api-key.d.ts +1 -1
  70. package/dist/signers/evm-external-wallet.d.cts +1 -1
  71. package/dist/signers/evm-external-wallet.d.ts +1 -1
  72. package/dist/signers/external-wallet-signer.d.cts +1 -1
  73. package/dist/signers/external-wallet-signer.d.ts +1 -1
  74. package/dist/signers/index.cjs +1 -1
  75. package/dist/signers/index.d.cts +1 -1
  76. package/dist/signers/index.d.ts +1 -1
  77. package/dist/signers/index.js +1 -1
  78. package/dist/signers/non-custodial/index.cjs +1 -1
  79. package/dist/signers/non-custodial/index.d.cts +1 -1
  80. package/dist/signers/non-custodial/index.d.ts +1 -1
  81. package/dist/signers/non-custodial/index.js +1 -1
  82. package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
  83. package/dist/signers/non-custodial/ncs-evm-signer.d.cts +1 -1
  84. package/dist/signers/non-custodial/ncs-evm-signer.d.ts +1 -1
  85. package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
  86. package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
  87. package/dist/signers/non-custodial/ncs-signer.d.cts +1 -1
  88. package/dist/signers/non-custodial/ncs-signer.d.ts +1 -1
  89. package/dist/signers/non-custodial/ncs-signer.js +1 -1
  90. package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
  91. package/dist/signers/non-custodial/ncs-solana-signer.d.cts +1 -1
  92. package/dist/signers/non-custodial/ncs-solana-signer.d.ts +1 -1
  93. package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
  94. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
  95. package/dist/signers/non-custodial/ncs-stellar-signer.d.cts +1 -1
  96. package/dist/signers/non-custodial/ncs-stellar-signer.d.ts +1 -1
  97. package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
  98. package/dist/signers/passkey.d.cts +1 -1
  99. package/dist/signers/passkey.d.ts +1 -1
  100. package/dist/signers/server/assemble-server-signer.d.cts +1 -1
  101. package/dist/signers/server/assemble-server-signer.d.ts +1 -1
  102. package/dist/signers/server/evm-server-signer.d.cts +1 -1
  103. package/dist/signers/server/evm-server-signer.d.ts +1 -1
  104. package/dist/signers/server/helpers/derive-server-signer.d.cts +1 -1
  105. package/dist/signers/server/helpers/derive-server-signer.d.ts +1 -1
  106. package/dist/signers/server/helpers/index.d.cts +1 -1
  107. package/dist/signers/server/helpers/index.d.ts +1 -1
  108. package/dist/signers/server/index.d.cts +1 -1
  109. package/dist/signers/server/index.d.ts +1 -1
  110. package/dist/signers/server/solana-server-signer.d.cts +1 -1
  111. package/dist/signers/server/solana-server-signer.d.ts +1 -1
  112. package/dist/signers/server/stellar-server-signer.d.cts +1 -1
  113. package/dist/signers/server/stellar-server-signer.d.ts +1 -1
  114. package/dist/signers/solana-api-key.d.cts +1 -1
  115. package/dist/signers/solana-api-key.d.ts +1 -1
  116. package/dist/signers/solana-external-wallet.d.cts +1 -1
  117. package/dist/signers/solana-external-wallet.d.ts +1 -1
  118. package/dist/signers/stellar-external-wallet.d.cts +1 -1
  119. package/dist/signers/stellar-external-wallet.d.ts +1 -1
  120. package/dist/signers/types.d.cts +1 -1
  121. package/dist/signers/types.d.ts +1 -1
  122. package/dist/{types-DmDAqO_P.d.cts → types-DfT-EHk3.d.cts} +2 -1
  123. package/dist/{types-BTh6aKMQ.d.ts → types-vcGYTcL0.d.ts} +2 -1
  124. package/dist/utils/constants.cjs +1 -1
  125. package/dist/utils/constants.js +1 -1
  126. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
  127. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
  128. package/dist/utils/device-signers/createDeviceSigner.d.cts +2 -2
  129. package/dist/utils/device-signers/createDeviceSigner.d.ts +2 -2
  130. package/dist/utils/device-signers/index.cjs +1 -1
  131. package/dist/utils/device-signers/index.d.cts +1 -1
  132. package/dist/utils/device-signers/index.d.ts +1 -1
  133. package/dist/utils/device-signers/index.js +1 -1
  134. package/dist/utils/signer-locator.d.cts +1 -1
  135. package/dist/utils/signer-locator.d.ts +1 -1
  136. package/dist/utils/signer-mapping.cjs +1 -1
  137. package/dist/utils/signer-mapping.d.cts +6 -2
  138. package/dist/utils/signer-mapping.d.ts +6 -2
  139. package/dist/utils/signer-mapping.js +1 -1
  140. package/dist/wallets/__tests__/test-helpers.cjs +1 -1
  141. package/dist/wallets/__tests__/test-helpers.d.cts +1 -1
  142. package/dist/wallets/__tests__/test-helpers.d.ts +1 -1
  143. package/dist/wallets/__tests__/test-helpers.js +1 -1
  144. package/dist/wallets/evm.cjs +1 -1
  145. package/dist/wallets/evm.d.cts +1 -1
  146. package/dist/wallets/evm.d.ts +1 -1
  147. package/dist/wallets/evm.js +1 -1
  148. package/dist/wallets/solana.cjs +1 -1
  149. package/dist/wallets/solana.d.cts +1 -1
  150. package/dist/wallets/solana.d.ts +1 -1
  151. package/dist/wallets/solana.js +1 -1
  152. package/dist/wallets/stellar.cjs +1 -1
  153. package/dist/wallets/stellar.d.cts +1 -1
  154. package/dist/wallets/stellar.d.ts +1 -1
  155. package/dist/wallets/stellar.js +1 -1
  156. package/dist/wallets/types.d.cts +1 -1
  157. package/dist/wallets/types.d.ts +1 -1
  158. package/dist/wallets/wallet-factory.cjs +1 -1
  159. package/dist/wallets/wallet-factory.d.cts +1 -1
  160. package/dist/wallets/wallet-factory.d.ts +1 -1
  161. package/dist/wallets/wallet-factory.js +1 -1
  162. package/dist/wallets/wallet.cjs +1 -1
  163. package/dist/wallets/wallet.d.cts +16 -9
  164. package/dist/wallets/wallet.d.ts +16 -9
  165. package/dist/wallets/wallet.js +1 -1
  166. package/package.json +1 -1
  167. package/dist/chunk-34LCOL3F.js +0 -1
  168. package/dist/chunk-BTSOX4OO.js +0 -1
  169. package/dist/chunk-CA2NUPQP.js +0 -1
  170. package/dist/chunk-JGFVDY5U.cjs +0 -1
  171. package/dist/chunk-OXR3FJF4.cjs +0 -1
package/README.md CHANGED
@@ -1,47 +1,98 @@
1
- # Wallets SDK
1
+ # @crossmint/wallets-sdk
2
2
 
3
- A Typescript SDK to interact with Crossmint Wallets. This SDK enables developers to easily create and manage wallets on Solana and EVM chains.
3
+ Typescript SDK for creating and managing [Crossmint Wallets](https://docs.crossmint.com) on EVM, Solana, and Stellar chains.
4
4
 
5
- Get a Crossmint client API key from [here](https://docs.crossmint.com/introduction/platform/api-keys/client-side) and add it to your `.env` file. Make sure your API key has all scopes for `Wallet API`, and `Users`.
5
+ ## Prerequisites
6
+
7
+ Get a Crossmint API key from the [developer console](https://docs.crossmint.com/introduction/platform/api-keys). Ensure your key has the **Wallet API** scopes enabled.
8
+
9
+ - **Client-side** (browser): Use a client API key
10
+ - **Server-side** (Node.js): Use a server API key
6
11
 
7
12
  ## Installation
8
13
 
9
14
  ```bash
10
- pnpm install @crossmint/wallets-sdk
15
+ npm install @crossmint/wallets-sdk
16
+ # or
17
+ pnpm add @crossmint/wallets-sdk
18
+ # or
19
+ yarn add @crossmint/wallets-sdk
11
20
  ```
12
21
 
13
- ## Usage
22
+ ## Quick Start
23
+
24
+ ### Server-side (Node.js)
14
25
 
15
26
  ```ts
16
- import { CrossmintWallets, createCrossmint } from "@crossmint/wallets-sdk";
27
+ import { createCrossmint, CrossmintWallets } from "@crossmint/wallets-sdk";
17
28
 
18
- const crossmint = createCrossmint({
19
- apiKey: "<your-client-OR-server-api-key>",
20
- experimental_customAuth: {
21
- jwt: "<your-jwt>", // required for client-side calls, optional for server-side calls
22
- },
23
- });
24
- const crossmintWallets = CrossmintWallets.from(crossmint);
25
- const wallet = await crossmintWallets.getOrCreateWallet({
26
- chain: "<your-chain>",
27
- signer: {
28
- type: "email",
29
- email: "<your-email>",
30
- onAuthRequired: async (needsAuth, sendOtp, verifyOtp, reject) => {
31
- if (needsAuth) {
32
- await sendOtp();
33
- // Prompt the user to check their email for the OTP code.
34
- // Once the user provides the OTP, pass it to verifyOtp(otp).
35
- // NOTE: If using our React/React Native SDK, this is handled automatically by the provider.
36
- }
37
- },
38
- },
29
+ const crossmint = createCrossmint({ apiKey: "<YOUR_SERVER_API_KEY>" });
30
+ const wallets = CrossmintWallets.from(crossmint);
31
+
32
+ // Create a wallet with a server signer
33
+ const wallet = await wallets.createWallet({
34
+ chain: "base-sepolia",
35
+ recovery: { type: "server", secret: "<RECOVERY_SECRET>" },
39
36
  });
40
37
 
41
38
  console.log(wallet.address);
39
+
40
+ // Send tokens
41
+ const tx = await wallet.send("0xRecipientAddress", "usdc", "10");
42
+ console.log(tx.explorerLink);
42
43
  ```
43
44
 
44
- ### Get wallet balances
45
+ ### Client-side (Headless)
46
+
47
+ For client-side usage without React, you can use the SDK directly with JWT authentication:
48
+
49
+ ```ts
50
+ import { createCrossmint, CrossmintWallets } from "@crossmint/wallets-sdk";
51
+
52
+ const crossmint = createCrossmint({ apiKey: "<YOUR_CLIENT_API_KEY>" });
53
+ crossmint.setJwt("<USER_JWT>");
54
+
55
+ const wallets = CrossmintWallets.from(crossmint);
56
+
57
+ const wallet = await wallets.getWallet({ chain: "base-sepolia" });
58
+ console.log(wallet.address);
59
+ ```
60
+
61
+ > For React apps, use [`@crossmint/client-sdk-react-ui`](https://www.npmjs.com/package/@crossmint/client-sdk-react-ui) which provides `CrossmintWalletProvider`, hooks, and built-in UI for OTP and passkey flows.
62
+
63
+ ## Core Concepts
64
+
65
+ ### Signers
66
+
67
+ Wallets SDK uses a two-tier signer model:
68
+
69
+ - **Recovery signer** — High-security, used for wallet recovery and adding new signers. Supports email OTP, phone OTP, external wallet, or server key.
70
+ - **Operational signer** — Low-friction, used for day-to-day signing. The default is the **device signer**, which uses hardware-backed keys (no OTP needed). Also supports passkey, server key, and external wallet.
71
+
72
+ When no operational signer is available, the recovery signer automatically serves as a fallback for signing.
73
+
74
+ ### Wallet Lifecycle
75
+
76
+ ```ts
77
+ // Create a new wallet
78
+ const wallet = await wallets.createWallet({
79
+ chain: "base-sepolia",
80
+ recovery: { type: "email", email: "user@example.com" },
81
+ signers: [{ type: "device" }], // optional — device is the default
82
+ });
83
+
84
+ // Retrieve an existing wallet (client-side)
85
+ const wallet = await wallets.getWallet({ chain: "base-sepolia" });
86
+
87
+ // Retrieve an existing wallet (server-side)
88
+ const wallet = await wallets.getWallet("0xWalletAddress", {
89
+ chain: "base-sepolia",
90
+ });
91
+ ```
92
+
93
+ ## Usage
94
+
95
+ ### Balances
45
96
 
46
97
  ```ts
47
98
  const balances = await wallet.balances();
@@ -50,47 +101,122 @@ console.log(balances.nativeToken.amount);
50
101
  console.log(balances.usdc.amount);
51
102
  ```
52
103
 
53
- ### Transfer
104
+ ### Send Tokens
54
105
 
55
106
  ```ts
56
- const transaction = await wallet.send(recipient, "usdc", "100");
107
+ const tx = await wallet.send("0xRecipient", "usdc", "100");
108
+ console.log(tx.explorerLink);
109
+ ```
110
+
111
+ ### Transfers
112
+
113
+ ```ts
114
+ const transfers = await wallet.transfers({
115
+ tokens: "usdc",
116
+ status: "successful",
117
+ });
118
+ ```
57
119
 
58
- console.log(transaction.explorerLink);
120
+ ### NFTs
121
+
122
+ ```ts
123
+ const nfts = await wallet.nfts({ perPage: 10, page: 1 });
59
124
  ```
60
125
 
61
- ### Get wallet activity
126
+ ### Chain-Specific Transactions
62
127
 
63
128
  ```ts
64
- const activity = await wallet.experimental_activity();
129
+ import { EVMWallet, SolanaWallet, StellarWallet } from "@crossmint/wallets-sdk";
130
+
131
+ // EVM — smart contract interaction
132
+ const evmWallet = EVMWallet.from(wallet);
133
+ const tx = await evmWallet.sendTransaction({
134
+ to: "0xContractAddress",
135
+ abi: contractAbi,
136
+ functionName: "mint",
137
+ args: [1],
138
+ value: 0n,
139
+ });
140
+
141
+ // EVM — sign a message
142
+ const sig = await evmWallet.signMessage({ message: "Hello" });
143
+
144
+ // EVM — viem public client
145
+ const client = evmWallet.getViemClient();
146
+
147
+ // Solana
148
+ const solWallet = SolanaWallet.from(wallet);
149
+ const solTx = await solWallet.sendTransaction({
150
+ serializedTransaction: "<base64-encoded-transaction>",
151
+ });
65
152
 
66
- console.log(activity.events);
153
+ // Stellar
154
+ const stellarWallet = StellarWallet.from(wallet);
155
+ const stellarTx = await stellarWallet.sendTransaction({
156
+ contractId: "C...",
157
+ method: "transfer",
158
+ args: { to: "G...", amount: "1000000" },
159
+ });
67
160
  ```
68
161
 
69
- ### Signers
162
+ ### Signer Management
70
163
 
71
164
  ```ts
72
- // Add a signer
73
- await wallet.addSigner({ signer: "<signer-address>" });
165
+ // Add a new signer
166
+ await wallet.addSigner({ type: "server", secret: "<SECRET>" });
74
167
 
168
+ // List signers
75
169
  const signers = await wallet.signers();
170
+ console.log(signers); // [{ type: "device", locator: "device:...", status: "success" }, ...]
76
171
 
77
- console.log(signers);
172
+ // Set the active signer
173
+ await wallet.useSigner({ type: "server", secret: "<SECRET>" });
174
+
175
+ // Recovery flow (new device)
176
+ if (wallet.needsRecovery()) {
177
+ await wallet.recover(); // uses recovery signer to register a new device signer
178
+ }
78
179
  ```
79
180
 
80
- ### Create custom transactions
181
+ ### Transaction Approval (Prepare-Only Mode)
182
+
183
+ For flows that require multi-step approval:
81
184
 
82
185
  ```ts
83
- import { SolanaWallet, EVMWallet } from "@crossmint/wallets-sdk";
186
+ // Create a transaction without auto-approving
187
+ const pendingTx = await wallet.send("0xRecipient", "usdc", "10", {
188
+ prepareOnly: true,
189
+ });
190
+ console.log(pendingTx.transactionId);
84
191
 
85
- // Solana
86
- const solanaWallet = SolanaWallet.from(wallet);
87
- const solTx = await solanaWallet.sendTransaction({ transaction: "<serialized-or-non-serialized-transaction>" });
192
+ // Approve later
193
+ const result = await wallet.approve({
194
+ transactionId: pendingTx.transactionId,
195
+ });
196
+ ```
88
197
 
89
- console.log(solTx.explorerLink);
198
+ ## Signer Types
90
199
 
91
- // EVM
92
- const evmWallet = EVMWallet.from(wallet);
93
- const evmTx = await evmWallet.sendTransaction({ transaction: "<serialized-or-non-serialized-transaction>" });
200
+ | Type | Use Case | Platforms |
201
+ |---|---|---|
202
+ | `device` | Default day-to-day signer. Hardware-backed, no OTP. | Browser, React Native |
203
+ | `server` | Server-side automated operations (AI agents, backends). | Node.js |
204
+ | `email` | OTP-based recovery signer. | All |
205
+ | `phone` | OTP-based recovery signer. | All |
206
+ | `passkey` | WebAuthn/FIDO2 biometric signer. | Browser (EVM only) |
207
+ | `external-wallet` | Bring-your-own key (MetaMask, KMS, etc). | All |
94
208
 
95
- console.log(evmTx.explorerLink);
96
- ```
209
+ ## React / React Native
210
+
211
+ For React applications, use [`@crossmint/client-sdk-react-ui`](https://www.npmjs.com/package/@crossmint/client-sdk-react-ui) which provides wallet providers, hooks (`useWallet`, `useWalletOtpSigner`), and built-in UI for OTP and passkey flows.
212
+
213
+ For React Native, see [`@crossmint/client-sdk-react-native-ui`](https://www.npmjs.com/package/@crossmint/client-sdk-react-native-ui).
214
+
215
+ ## Documentation
216
+
217
+ - [Crossmint Wallets Docs](https://docs.crossmint.com)
218
+ - [SDK Reference](https://docs.crossmint.com/sdk-reference/wallets)
219
+
220
+ ## License
221
+
222
+ Apache-2.0
@@ -1,4 +1,4 @@
1
- import { a2 as WalletLocator } from '../../types-DmDAqO_P.cjs';
1
+ import { a3 as WalletLocator } from '../../types-DfT-EHk3.cjs';
2
2
  import 'viem';
3
3
  import '../gen/types.gen.cjs';
4
4
  import 'ox';
@@ -1,4 +1,4 @@
1
- import { a2 as WalletLocator } from '../../types-BTh6aKMQ.js';
1
+ import { a3 as WalletLocator } from '../../types-vcGYTcL0.js';
2
2
  import 'viem';
3
3
  import '../gen/types.gen.js';
4
4
  import 'ox';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJ33QM2IDcjs = require('../../chunk-J33QM2ID.cjs');var _chunkEPJRLPAIcjs = require('../../chunk-EPJRLPAI.cjs');require('../../chunk-T3U46LK3.cjs');require('../../chunk-CW2GPBXZ.cjs');require('../../chunk-Y22BJFQT.cjs');var _chunk2GKPWQBQcjs = require('../../chunk-2GKPWQBQ.cjs');var _vitest = require('vitest');var b=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:_vitest.vi.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j= exports.createMockSuccessResponse =e=>b({data:e}),P= exports.createMockErrorResponse =(e,t=400,n="Bad Request")=>b({data:e,status:t,ok:!1,statusText:n}),B= exports.createMockCrossmint =(e={})=>{let t=_chunk2GKPWQBQcjs.a.call(void 0, {apiKey:_chunkJ33QM2IDcjs.m},e);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},t),{setJwt:_vitest.vi.fn().mockReturnThis()})},L= exports.createTestApiClient =e=>new (0, _chunkEPJRLPAIcjs.a)(e||B()),K= exports.createServerSideApiClient =()=>{let e=L();return Object.defineProperty(e,"isServerSide",{get:()=>!0,configurable:!0}),e},Y= exports.extractFetchCall =e=>{let t=e.mock.calls;if(t.length===0)return;let n=t[t.length-1];return{path:n[0],options:n[1]}},N= exports.expectRequestPath =(e,t)=>{_vitest.expect.call(void 0, e==null?void 0:e.path).toBe(t)},V= exports.expectCommonHeaders =e=>{_vitest.expect.call(void 0, e["Content-Type"]).toBe("application/json")},q= exports.expectRequestBody =(e,t)=>{_vitest.expect.call(void 0, e.body).toBe(JSON.stringify(t))},z= exports.validateRequest =(e,t,n)=>{_vitest.expect.call(void 0, e).toBeDefined(),e&&(N(e,t),e.options.headers&&V(e.options.headers),n!==void 0&&e.options&&q(e.options,n))},X= exports.testHttpErrorResponse =(e,t,n,s)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockResolvedValue(P(n,s));let a=yield e();_vitest.expect.call(void 0, u(a)).toBe(!0),u(a)&&(_vitest.expect.call(void 0, a.error).toBe(!0),n.message&&_vitest.expect.call(void 0, a.message).toBe(n.message))}),Z= exports.testCommonHttpErrors =(s,a,...o)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of _chunkJ33QM2IDcjs.a){if(n.includes(c))continue;let l={error:!0,message:g};t.mockResolvedValueOnce(P(l,c));let m=yield e();_vitest.expect.call(void 0, u(m)).toBe(!0)}}),Q= exports.testNetworkError =(e,t)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockRejectedValue(new Error("Network error")),yield _vitest.expect.call(void 0, e()).rejects.toThrow("Network error")}),ee= exports.testInvalidJsonResponse =(e,t)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let n={json:_vitest.vi.fn().mockRejectedValue(new Error("Invalid JSON")),ok:!0,status:200};t.mockResolvedValue(n),yield _vitest.expect.call(void 0, e()).rejects.toThrow()}),te= exports.testTimeoutError =(e,t)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockImplementation(()=>new Promise((n,s)=>setTimeout(()=>s(new Error("Request timeout")),0))),yield _vitest.expect.call(void 0, e()).rejects.toThrow("Request timeout")}),ne= exports.testMalformedResponse =(e,t,n)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockResolvedValue(j(n));let s=yield e();_vitest.expect.call(void 0, s).toEqual(n)}),se= exports.createMockWalletResponse =(e={})=>_chunk2GKPWQBQcjs.a.call(void 0, {address:_chunkJ33QM2IDcjs.b.evmAddress,chainType:"evm",type:"smart",config:{adminSigner:{type:"external-wallet",address:_chunkJ33QM2IDcjs.k.EVM_TEST}}},e),oe= exports.createMockSendResponse =(e={})=>_chunk2GKPWQBQcjs.a.call(void 0, {id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function u(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function h(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),re= exports.isValidEthereumAddress =e=>/^0x[a-fA-F0-9]{40}$/.test(e),ae= exports.isValidSolanaAddress =e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ie= exports.createIntegrationApiClient =(e,t,n={})=>{let s=_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {apiKey:e},t&&{overrideBaseUrl:t}),n),a=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},s),{setJwt:()=>a});return new (0, _chunkEPJRLPAIcjs.a)(a)},v= exports.TestDataFactory =class{constructor(){this.wallets=[];this.transactions=[]}addWallet(t){t&&!this.wallets.includes(t)&&this.wallets.push(t)}addTransaction(t){t&&!this.transactions.includes(t)&&this.transactions.push(t)}getWallet(t=0){return this.wallets[t]}getTransaction(t=0){return this.transactions[t]}hasWallets(){return this.wallets.length>0}clear(){this.wallets=[],this.transactions=[]}};function ce(s,a){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:l="default"}=n,m=g||`userId:integration-${l}-${Date.now()}`,f=yield e.createWallet(_chunk2GKPWQBQcjs.a.call(void 0, {chainType:o,type:c},g&&{owner:m}));if(h(f))return t.addWallet(f.address),f.address})}function pe(e,t,n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=yield e.createWallet(n);return h(s)&&t.addWallet(s.address),s})}function ue(e,t){_vitest.expect.call(void 0, u(e)).toBe(!0),t&&_vitest.expect.call(void 0, e.message).toBeDefined()}function le(e){_vitest.expect.call(void 0, h(e)).toBe(!0)}function de(e){_vitest.expect.call(void 0, $(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(u(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(_chunkJ33QM2IDcjs.i),c}),U= exports.approveTransaction =(a,o,c,...g)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,[a,o,c,...g],function*(e,t,n,s=_chunkJ33QM2IDcjs.l.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(u(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},C=yield e.approveTransaction(t,n,O);if(u(C))throw new Error(`Failed to approve transaction: ${C.message||"Unknown error"}`);yield x(_chunkJ33QM2IDcjs.j);continue}yield x(_chunkJ33QM2IDcjs.i)}let l=yield e.getTransaction(t,n);if(u(l))throw new Error(`Transaction not found after retries: ${l.message||"Unknown error"}`);if(!("status"in l))throw new Error("Transaction response missing status property");return l}),me= exports.fundWalletAndWait =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){return I(e,t,n,s,a)}),fe= exports.sendTokenAndApprove =(e,t,n,s,a)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(u(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),ge= exports.ensureWalletFunded =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});exports.TestDataFactory = v; exports.approveTransaction = U; exports.createIntegrationApiClient = ie; exports.createMockCrossmint = B; exports.createMockErrorResponse = P; exports.createMockResponse = b; exports.createMockSendResponse = oe; exports.createMockSuccessResponse = j; exports.createMockWalletResponse = se; exports.createServerSideApiClient = K; exports.createTestApiClient = L; exports.createTestWallet = pe; exports.delay = x; exports.ensureWalletExists = ce; exports.ensureWalletFunded = ge; exports.expectCommonHeaders = V; exports.expectErrorResponse = ue; exports.expectRequestBody = q; exports.expectRequestPath = N; exports.expectSuccessTransactionResponse = de; exports.expectSuccessWalletResponse = le; exports.extractFetchCall = Y; exports.fundWallet = I; exports.fundWalletAndWait = me; exports.isErrorResponse = u; exports.isSuccessTransactionResponse = $; exports.isSuccessWalletResponse = h; exports.isValidEthereumAddress = re; exports.isValidSolanaAddress = ae; exports.sendTokenAndApprove = fe; exports.testCommonHttpErrors = Z; exports.testHttpErrorResponse = X; exports.testInvalidJsonResponse = ee; exports.testMalformedResponse = ne; exports.testNetworkError = Q; exports.testTimeoutError = te; exports.validateRequest = z;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJ33QM2IDcjs = require('../../chunk-J33QM2ID.cjs');var _chunkJJKL6FU2cjs = require('../../chunk-JJKL6FU2.cjs');require('../../chunk-T3U46LK3.cjs');require('../../chunk-V5A3FGH2.cjs');require('../../chunk-CV5GT7CP.cjs');var _chunk2GKPWQBQcjs = require('../../chunk-2GKPWQBQ.cjs');var _vitest = require('vitest');var b=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:_vitest.vi.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j= exports.createMockSuccessResponse =e=>b({data:e}),P= exports.createMockErrorResponse =(e,t=400,n="Bad Request")=>b({data:e,status:t,ok:!1,statusText:n}),B= exports.createMockCrossmint =(e={})=>{let t=_chunk2GKPWQBQcjs.a.call(void 0, {apiKey:_chunkJ33QM2IDcjs.m},e);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},t),{setJwt:_vitest.vi.fn().mockReturnThis()})},L= exports.createTestApiClient =e=>new (0, _chunkJJKL6FU2cjs.a)(e||B()),K= exports.createServerSideApiClient =()=>{let e=L();return Object.defineProperty(e,"isServerSide",{get:()=>!0,configurable:!0}),e},Y= exports.extractFetchCall =e=>{let t=e.mock.calls;if(t.length===0)return;let n=t[t.length-1];return{path:n[0],options:n[1]}},N= exports.expectRequestPath =(e,t)=>{_vitest.expect.call(void 0, e==null?void 0:e.path).toBe(t)},V= exports.expectCommonHeaders =e=>{_vitest.expect.call(void 0, e["Content-Type"]).toBe("application/json")},q= exports.expectRequestBody =(e,t)=>{_vitest.expect.call(void 0, e.body).toBe(JSON.stringify(t))},z= exports.validateRequest =(e,t,n)=>{_vitest.expect.call(void 0, e).toBeDefined(),e&&(N(e,t),e.options.headers&&V(e.options.headers),n!==void 0&&e.options&&q(e.options,n))},X= exports.testHttpErrorResponse =(e,t,n,s)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockResolvedValue(P(n,s));let a=yield e();_vitest.expect.call(void 0, u(a)).toBe(!0),u(a)&&(_vitest.expect.call(void 0, a.error).toBe(!0),n.message&&_vitest.expect.call(void 0, a.message).toBe(n.message))}),Z= exports.testCommonHttpErrors =(s,a,...o)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of _chunkJ33QM2IDcjs.a){if(n.includes(c))continue;let l={error:!0,message:g};t.mockResolvedValueOnce(P(l,c));let m=yield e();_vitest.expect.call(void 0, u(m)).toBe(!0)}}),Q= exports.testNetworkError =(e,t)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockRejectedValue(new Error("Network error")),yield _vitest.expect.call(void 0, e()).rejects.toThrow("Network error")}),ee= exports.testInvalidJsonResponse =(e,t)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let n={json:_vitest.vi.fn().mockRejectedValue(new Error("Invalid JSON")),ok:!0,status:200};t.mockResolvedValue(n),yield _vitest.expect.call(void 0, e()).rejects.toThrow()}),te= exports.testTimeoutError =(e,t)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockImplementation(()=>new Promise((n,s)=>setTimeout(()=>s(new Error("Request timeout")),0))),yield _vitest.expect.call(void 0, e()).rejects.toThrow("Request timeout")}),ne= exports.testMalformedResponse =(e,t,n)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockResolvedValue(j(n));let s=yield e();_vitest.expect.call(void 0, s).toEqual(n)}),se= exports.createMockWalletResponse =(e={})=>_chunk2GKPWQBQcjs.a.call(void 0, {address:_chunkJ33QM2IDcjs.b.evmAddress,chainType:"evm",type:"smart",config:{adminSigner:{type:"external-wallet",address:_chunkJ33QM2IDcjs.k.EVM_TEST}}},e),oe= exports.createMockSendResponse =(e={})=>_chunk2GKPWQBQcjs.a.call(void 0, {id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function u(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function h(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),re= exports.isValidEthereumAddress =e=>/^0x[a-fA-F0-9]{40}$/.test(e),ae= exports.isValidSolanaAddress =e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ie= exports.createIntegrationApiClient =(e,t,n={})=>{let s=_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {apiKey:e},t&&{overrideBaseUrl:t}),n),a=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},s),{setJwt:()=>a});return new (0, _chunkJJKL6FU2cjs.a)(a)},v= exports.TestDataFactory =class{constructor(){this.wallets=[];this.transactions=[]}addWallet(t){t&&!this.wallets.includes(t)&&this.wallets.push(t)}addTransaction(t){t&&!this.transactions.includes(t)&&this.transactions.push(t)}getWallet(t=0){return this.wallets[t]}getTransaction(t=0){return this.transactions[t]}hasWallets(){return this.wallets.length>0}clear(){this.wallets=[],this.transactions=[]}};function ce(s,a){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:l="default"}=n,m=g||`userId:integration-${l}-${Date.now()}`,f=yield e.createWallet(_chunk2GKPWQBQcjs.a.call(void 0, {chainType:o,type:c},g&&{owner:m}));if(h(f))return t.addWallet(f.address),f.address})}function pe(e,t,n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=yield e.createWallet(n);return h(s)&&t.addWallet(s.address),s})}function ue(e,t){_vitest.expect.call(void 0, u(e)).toBe(!0),t&&_vitest.expect.call(void 0, e.message).toBeDefined()}function le(e){_vitest.expect.call(void 0, h(e)).toBe(!0)}function de(e){_vitest.expect.call(void 0, $(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(u(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(_chunkJ33QM2IDcjs.i),c}),U= exports.approveTransaction =(a,o,c,...g)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,[a,o,c,...g],function*(e,t,n,s=_chunkJ33QM2IDcjs.l.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(u(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},C=yield e.approveTransaction(t,n,O);if(u(C))throw new Error(`Failed to approve transaction: ${C.message||"Unknown error"}`);yield x(_chunkJ33QM2IDcjs.j);continue}yield x(_chunkJ33QM2IDcjs.i)}let l=yield e.getTransaction(t,n);if(u(l))throw new Error(`Transaction not found after retries: ${l.message||"Unknown error"}`);if(!("status"in l))throw new Error("Transaction response missing status property");return l}),me= exports.fundWalletAndWait =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){return I(e,t,n,s,a)}),fe= exports.sendTokenAndApprove =(e,t,n,s,a)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(u(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),ge= exports.ensureWalletFunded =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});exports.TestDataFactory = v; exports.approveTransaction = U; exports.createIntegrationApiClient = ie; exports.createMockCrossmint = B; exports.createMockErrorResponse = P; exports.createMockResponse = b; exports.createMockSendResponse = oe; exports.createMockSuccessResponse = j; exports.createMockWalletResponse = se; exports.createServerSideApiClient = K; exports.createTestApiClient = L; exports.createTestWallet = pe; exports.delay = x; exports.ensureWalletExists = ce; exports.ensureWalletFunded = ge; exports.expectCommonHeaders = V; exports.expectErrorResponse = ue; exports.expectRequestBody = q; exports.expectRequestPath = N; exports.expectSuccessTransactionResponse = de; exports.expectSuccessWalletResponse = le; exports.extractFetchCall = Y; exports.fundWallet = I; exports.fundWalletAndWait = me; exports.isErrorResponse = u; exports.isSuccessTransactionResponse = $; exports.isSuccessWalletResponse = h; exports.isValidEthereumAddress = re; exports.isValidSolanaAddress = ae; exports.sendTokenAndApprove = fe; exports.testCommonHttpErrors = Z; exports.testHttpErrorResponse = X; exports.testInvalidJsonResponse = ee; exports.testMalformedResponse = ne; exports.testNetworkError = Q; exports.testTimeoutError = te; exports.validateRequest = z;
@@ -1,7 +1,7 @@
1
1
  import { MockedFunction } from 'vitest';
2
2
  import { Crossmint } from '@crossmint/common-sdk-base';
3
3
  import { ApiClient } from '../client.cjs';
4
- import { a5 as CreateWalletResponse, a6 as SendResponse, a7 as CreateWalletParams, a2 as WalletLocator, U as FundWalletResponse, a8 as GetTransactionResponse } from '../../types-DmDAqO_P.cjs';
4
+ import { a5 as CreateWalletResponse, a6 as SendResponse, a7 as CreateWalletParams, a3 as WalletLocator, Y as FundWalletResponse, a8 as GetTransactionResponse } from '../../types-DfT-EHk3.cjs';
5
5
  import '../../chains/chains.cjs';
6
6
  import 'viem';
7
7
  import '../gen/types.gen.cjs';
@@ -1,7 +1,7 @@
1
1
  import { MockedFunction } from 'vitest';
2
2
  import { Crossmint } from '@crossmint/common-sdk-base';
3
3
  import { ApiClient } from '../client.js';
4
- import { a5 as CreateWalletResponse, a6 as SendResponse, a7 as CreateWalletParams, a2 as WalletLocator, U as FundWalletResponse, a8 as GetTransactionResponse } from '../../types-BTh6aKMQ.js';
4
+ import { a5 as CreateWalletResponse, a6 as SendResponse, a7 as CreateWalletParams, a3 as WalletLocator, Y as FundWalletResponse, a8 as GetTransactionResponse } from '../../types-vcGYTcL0.js';
5
5
  import '../../chains/chains.js';
6
6
  import 'viem';
7
7
  import '../gen/types.gen.js';
@@ -1 +1 @@
1
- import{a as A,b as F,i as R,j as E,k as M,l as W,m as S}from"../../chunk-DIGDDKSF.js";import{a as w}from"../../chunk-YNQPYZGU.js";import"../../chunk-EXC7TCGL.js";import"../../chunk-5AMNTK5L.js";import"../../chunk-34LCOL3F.js";import{a as p,b as k,g as i}from"../../chunk-J3R36SGJ.js";import{expect as r,vi as y}from"vitest";var b=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:y.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j=e=>b({data:e}),P=(e,t=400,n="Bad Request")=>b({data:e,status:t,ok:!1,statusText:n}),B=(e={})=>{let t=p({apiKey:S},e);return k(p({},t),{setJwt:y.fn().mockReturnThis()})},L=e=>new w(e||B()),Y=()=>{let e=L();return Object.defineProperty(e,"isServerSide",{get:()=>!0,configurable:!0}),e},z=e=>{let t=e.mock.calls;if(t.length===0)return;let n=t[t.length-1];return{path:n[0],options:n[1]}},N=(e,t)=>{r(e==null?void 0:e.path).toBe(t)},V=e=>{r(e["Content-Type"]).toBe("application/json")},q=(e,t)=>{r(e.body).toBe(JSON.stringify(t))},X=(e,t,n)=>{r(e).toBeDefined(),e&&(N(e,t),e.options.headers&&V(e.options.headers),n!==void 0&&e.options&&q(e.options,n))},Z=(e,t,n,s)=>i(void 0,null,function*(){t.mockResolvedValue(P(n,s));let a=yield e();r(u(a)).toBe(!0),u(a)&&(r(a.error).toBe(!0),n.message&&r(a.message).toBe(n.message))}),Q=(s,a,...o)=>i(void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of A){if(n.includes(c))continue;let l={error:!0,message:g};t.mockResolvedValueOnce(P(l,c));let m=yield e();r(u(m)).toBe(!0)}}),ee=(e,t)=>i(void 0,null,function*(){t.mockRejectedValue(new Error("Network error")),yield r(e()).rejects.toThrow("Network error")}),te=(e,t)=>i(void 0,null,function*(){let n={json:y.fn().mockRejectedValue(new Error("Invalid JSON")),ok:!0,status:200};t.mockResolvedValue(n),yield r(e()).rejects.toThrow()}),ne=(e,t)=>i(void 0,null,function*(){t.mockImplementation(()=>new Promise((n,s)=>setTimeout(()=>s(new Error("Request timeout")),0))),yield r(e()).rejects.toThrow("Request timeout")}),se=(e,t,n)=>i(void 0,null,function*(){t.mockResolvedValue(j(n));let s=yield e();r(s).toEqual(n)}),oe=(e={})=>p({address:F.evmAddress,chainType:"evm",type:"smart",config:{adminSigner:{type:"external-wallet",address:M.EVM_TEST}}},e),re=(e={})=>p({id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function u(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function h(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),ae=e=>/^0x[a-fA-F0-9]{40}$/.test(e),ie=e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ce=(e,t,n={})=>{let s=p(p({apiKey:e},t&&{overrideBaseUrl:t}),n),a=k(p({},s),{setJwt:()=>a});return new w(a)},v=class{constructor(){this.wallets=[];this.transactions=[]}addWallet(t){t&&!this.wallets.includes(t)&&this.wallets.push(t)}addTransaction(t){t&&!this.transactions.includes(t)&&this.transactions.push(t)}getWallet(t=0){return this.wallets[t]}getTransaction(t=0){return this.transactions[t]}hasWallets(){return this.wallets.length>0}clear(){this.wallets=[],this.transactions=[]}};function pe(s,a){return i(this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:l="default"}=n,m=g||`userId:integration-${l}-${Date.now()}`,f=yield e.createWallet(p({chainType:o,type:c},g&&{owner:m}));if(h(f))return t.addWallet(f.address),f.address})}function ue(e,t,n){return i(this,null,function*(){let s=yield e.createWallet(n);return h(s)&&t.addWallet(s.address),s})}function le(e,t){r(u(e)).toBe(!0),t&&r(e.message).toBeDefined()}function de(e){r(h(e)).toBe(!0)}function me(e){r($(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(u(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(R),c}),U=(a,o,c,...g)=>i(void 0,[a,o,c,...g],function*(e,t,n,s=W.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(u(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},C=yield e.approveTransaction(t,n,O);if(u(C))throw new Error(`Failed to approve transaction: ${C.message||"Unknown error"}`);yield x(E);continue}yield x(R)}let l=yield e.getTransaction(t,n);if(u(l))throw new Error(`Transaction not found after retries: ${l.message||"Unknown error"}`);if(!("status"in l))throw new Error("Transaction response missing status property");return l}),fe=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){return I(e,t,n,s,a)}),ge=(e,t,n,s,a)=>i(void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(u(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),Te=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});export{v as TestDataFactory,U as approveTransaction,ce as createIntegrationApiClient,B as createMockCrossmint,P as createMockErrorResponse,b as createMockResponse,re as createMockSendResponse,j as createMockSuccessResponse,oe as createMockWalletResponse,Y as createServerSideApiClient,L as createTestApiClient,ue as createTestWallet,x as delay,pe as ensureWalletExists,Te as ensureWalletFunded,V as expectCommonHeaders,le as expectErrorResponse,q as expectRequestBody,N as expectRequestPath,me as expectSuccessTransactionResponse,de as expectSuccessWalletResponse,z as extractFetchCall,I as fundWallet,fe as fundWalletAndWait,u as isErrorResponse,$ as isSuccessTransactionResponse,h as isSuccessWalletResponse,ae as isValidEthereumAddress,ie as isValidSolanaAddress,ge as sendTokenAndApprove,Q as testCommonHttpErrors,Z as testHttpErrorResponse,te as testInvalidJsonResponse,se as testMalformedResponse,ee as testNetworkError,ne as testTimeoutError,X as validateRequest};
1
+ import{a as A,b as F,i as R,j as E,k as M,l as W,m as S}from"../../chunk-DIGDDKSF.js";import{a as w}from"../../chunk-HQVHXT3U.js";import"../../chunk-EXC7TCGL.js";import"../../chunk-2X65YHU4.js";import"../../chunk-J7C3SSSQ.js";import{a as p,b as k,g as i}from"../../chunk-J3R36SGJ.js";import{expect as r,vi as y}from"vitest";var b=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:y.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j=e=>b({data:e}),P=(e,t=400,n="Bad Request")=>b({data:e,status:t,ok:!1,statusText:n}),B=(e={})=>{let t=p({apiKey:S},e);return k(p({},t),{setJwt:y.fn().mockReturnThis()})},L=e=>new w(e||B()),Y=()=>{let e=L();return Object.defineProperty(e,"isServerSide",{get:()=>!0,configurable:!0}),e},z=e=>{let t=e.mock.calls;if(t.length===0)return;let n=t[t.length-1];return{path:n[0],options:n[1]}},N=(e,t)=>{r(e==null?void 0:e.path).toBe(t)},V=e=>{r(e["Content-Type"]).toBe("application/json")},q=(e,t)=>{r(e.body).toBe(JSON.stringify(t))},X=(e,t,n)=>{r(e).toBeDefined(),e&&(N(e,t),e.options.headers&&V(e.options.headers),n!==void 0&&e.options&&q(e.options,n))},Z=(e,t,n,s)=>i(void 0,null,function*(){t.mockResolvedValue(P(n,s));let a=yield e();r(u(a)).toBe(!0),u(a)&&(r(a.error).toBe(!0),n.message&&r(a.message).toBe(n.message))}),Q=(s,a,...o)=>i(void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of A){if(n.includes(c))continue;let l={error:!0,message:g};t.mockResolvedValueOnce(P(l,c));let m=yield e();r(u(m)).toBe(!0)}}),ee=(e,t)=>i(void 0,null,function*(){t.mockRejectedValue(new Error("Network error")),yield r(e()).rejects.toThrow("Network error")}),te=(e,t)=>i(void 0,null,function*(){let n={json:y.fn().mockRejectedValue(new Error("Invalid JSON")),ok:!0,status:200};t.mockResolvedValue(n),yield r(e()).rejects.toThrow()}),ne=(e,t)=>i(void 0,null,function*(){t.mockImplementation(()=>new Promise((n,s)=>setTimeout(()=>s(new Error("Request timeout")),0))),yield r(e()).rejects.toThrow("Request timeout")}),se=(e,t,n)=>i(void 0,null,function*(){t.mockResolvedValue(j(n));let s=yield e();r(s).toEqual(n)}),oe=(e={})=>p({address:F.evmAddress,chainType:"evm",type:"smart",config:{adminSigner:{type:"external-wallet",address:M.EVM_TEST}}},e),re=(e={})=>p({id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function u(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function h(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),ae=e=>/^0x[a-fA-F0-9]{40}$/.test(e),ie=e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ce=(e,t,n={})=>{let s=p(p({apiKey:e},t&&{overrideBaseUrl:t}),n),a=k(p({},s),{setJwt:()=>a});return new w(a)},v=class{constructor(){this.wallets=[];this.transactions=[]}addWallet(t){t&&!this.wallets.includes(t)&&this.wallets.push(t)}addTransaction(t){t&&!this.transactions.includes(t)&&this.transactions.push(t)}getWallet(t=0){return this.wallets[t]}getTransaction(t=0){return this.transactions[t]}hasWallets(){return this.wallets.length>0}clear(){this.wallets=[],this.transactions=[]}};function pe(s,a){return i(this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:l="default"}=n,m=g||`userId:integration-${l}-${Date.now()}`,f=yield e.createWallet(p({chainType:o,type:c},g&&{owner:m}));if(h(f))return t.addWallet(f.address),f.address})}function ue(e,t,n){return i(this,null,function*(){let s=yield e.createWallet(n);return h(s)&&t.addWallet(s.address),s})}function le(e,t){r(u(e)).toBe(!0),t&&r(e.message).toBeDefined()}function de(e){r(h(e)).toBe(!0)}function me(e){r($(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(u(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(R),c}),U=(a,o,c,...g)=>i(void 0,[a,o,c,...g],function*(e,t,n,s=W.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(u(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},C=yield e.approveTransaction(t,n,O);if(u(C))throw new Error(`Failed to approve transaction: ${C.message||"Unknown error"}`);yield x(E);continue}yield x(R)}let l=yield e.getTransaction(t,n);if(u(l))throw new Error(`Transaction not found after retries: ${l.message||"Unknown error"}`);if(!("status"in l))throw new Error("Transaction response missing status property");return l}),fe=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){return I(e,t,n,s,a)}),ge=(e,t,n,s,a)=>i(void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(u(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),Te=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});export{v as TestDataFactory,U as approveTransaction,ce as createIntegrationApiClient,B as createMockCrossmint,P as createMockErrorResponse,b as createMockResponse,re as createMockSendResponse,j as createMockSuccessResponse,oe as createMockWalletResponse,Y as createServerSideApiClient,L as createTestApiClient,ue as createTestWallet,x as delay,pe as ensureWalletExists,Te as ensureWalletFunded,V as expectCommonHeaders,le as expectErrorResponse,q as expectRequestBody,N as expectRequestPath,me as expectSuccessTransactionResponse,de as expectSuccessWalletResponse,z as extractFetchCall,I as fundWallet,fe as fundWalletAndWait,u as isErrorResponse,$ as isSuccessTransactionResponse,h as isSuccessWalletResponse,ae as isValidEthereumAddress,ie as isValidSolanaAddress,ge as sendTokenAndApprove,Q as testCommonHttpErrors,Z as testHttpErrorResponse,te as testInvalidJsonResponse,se as testMalformedResponse,ee as testNetworkError,ne as testTimeoutError,X as validateRequest};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEPJRLPAIcjs = require('../chunk-EPJRLPAI.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-CW2GPBXZ.cjs');require('../chunk-Y22BJFQT.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunkEPJRLPAIcjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJJKL6FU2cjs = require('../chunk-JJKL6FU2.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-V5A3FGH2.cjs');require('../chunk-CV5GT7CP.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunkJJKL6FU2cjs.a;
@@ -1,5 +1,5 @@
1
1
  import { CrossmintApiClient, Crossmint, APIKeyEnvironmentPrefix } from '@crossmint/common-sdk-base';
2
- import { a7 as CreateWalletParams, a5 as CreateWalletResponse, a2 as WalletLocator, ad as GetWalletResponse, ae as CreateTransactionParams, af as CreateTransactionResponse, ag as ApproveTransactionParams, ah as ApproveTransactionResponse, a8 as GetTransactionResponse, ai as CreateSignatureParams, aj as CreateSignatureResponse, ak as ApproveSignatureParams, a4 as ApproveSignatureResponse, al as GetSignatureResponse, V as GetTransactionsResponse, am as GetTransfersResponse, an as GetBalanceResponse, ao as FundWalletParams, U as FundWalletResponse, ap as RegisterSignerParams, aq as RegisterSignerResponse, ar as GetSignerResponse, as as SendParams, a6 as SendResponse } from '../types-DmDAqO_P.cjs';
2
+ import { a7 as CreateWalletParams, a5 as CreateWalletResponse, a3 as WalletLocator, ad as GetWalletResponse, ae as CreateTransactionParams, af as CreateTransactionResponse, ag as ApproveTransactionParams, ah as ApproveTransactionResponse, a8 as GetTransactionResponse, ai as CreateSignatureParams, aj as CreateSignatureResponse, ak as ApproveSignatureParams, a4 as ApproveSignatureResponse, al as GetSignatureResponse, Z as GetTransactionsResponse, am as GetTransfersResponse, an as GetBalanceResponse, ao as FundWalletParams, Y as FundWalletResponse, ap as RegisterSignerParams, aq as RegisterSignerResponse, ar as GetSignerResponse, as as SendParams, a6 as SendResponse } from '../types-DfT-EHk3.cjs';
3
3
  import { Chain } from '../chains/chains.cjs';
4
4
  import 'viem';
5
5
  import './gen/types.gen.cjs';
@@ -1,5 +1,5 @@
1
1
  import { CrossmintApiClient, Crossmint, APIKeyEnvironmentPrefix } from '@crossmint/common-sdk-base';
2
- import { a7 as CreateWalletParams, a5 as CreateWalletResponse, a2 as WalletLocator, ad as GetWalletResponse, ae as CreateTransactionParams, af as CreateTransactionResponse, ag as ApproveTransactionParams, ah as ApproveTransactionResponse, a8 as GetTransactionResponse, ai as CreateSignatureParams, aj as CreateSignatureResponse, ak as ApproveSignatureParams, a4 as ApproveSignatureResponse, al as GetSignatureResponse, V as GetTransactionsResponse, am as GetTransfersResponse, an as GetBalanceResponse, ao as FundWalletParams, U as FundWalletResponse, ap as RegisterSignerParams, aq as RegisterSignerResponse, ar as GetSignerResponse, as as SendParams, a6 as SendResponse } from '../types-BTh6aKMQ.js';
2
+ import { a7 as CreateWalletParams, a5 as CreateWalletResponse, a3 as WalletLocator, ad as GetWalletResponse, ae as CreateTransactionParams, af as CreateTransactionResponse, ag as ApproveTransactionParams, ah as ApproveTransactionResponse, a8 as GetTransactionResponse, ai as CreateSignatureParams, aj as CreateSignatureResponse, ak as ApproveSignatureParams, a4 as ApproveSignatureResponse, al as GetSignatureResponse, Z as GetTransactionsResponse, am as GetTransfersResponse, an as GetBalanceResponse, ao as FundWalletParams, Y as FundWalletResponse, ap as RegisterSignerParams, aq as RegisterSignerResponse, ar as GetSignerResponse, as as SendParams, a6 as SendResponse } from '../types-vcGYTcL0.js';
3
3
  import { Chain } from '../chains/chains.js';
4
4
  import 'viem';
5
5
  import './gen/types.gen.js';
@@ -1 +1 @@
1
- import{a}from"../chunk-YNQPYZGU.js";import"../chunk-EXC7TCGL.js";import"../chunk-5AMNTK5L.js";import"../chunk-34LCOL3F.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
1
+ import{a}from"../chunk-HQVHXT3U.js";import"../chunk-EXC7TCGL.js";import"../chunk-2X65YHU4.js";import"../chunk-J7C3SSSQ.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-6HXIZLEQ.cjs');var _chunkEPJRLPAIcjs = require('../chunk-EPJRLPAI.cjs');require('../chunk-ECAM5KTH.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-CW2GPBXZ.cjs');require('../chunk-Y22BJFQT.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunkEPJRLPAIcjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-6HXIZLEQ.cjs');var _chunkJJKL6FU2cjs = require('../chunk-JJKL6FU2.cjs');require('../chunk-ECAM5KTH.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-V5A3FGH2.cjs');require('../chunk-CV5GT7CP.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunkJJKL6FU2cjs.a;
@@ -1,5 +1,5 @@
1
1
  export { ApiClient } from './client.cjs';
2
- export { ak as ApproveSignatureParams, a4 as ApproveSignatureResponse, ag as ApproveTransactionParams, ah as ApproveTransactionResponse, ai as CreateSignatureParams, aj as CreateSignatureResponse, ae as CreateTransactionParams, af as CreateTransactionResponse, av as CreateTransactionSuccessResponse, a7 as CreateWalletParams, a5 as CreateWalletResponse, ao as FundWalletParams, U as FundWalletResponse, an as GetBalanceResponse, aw as GetBalanceSuccessResponse, al as GetSignatureResponse, ar as GetSignerResponse, ay as GetSignersResponse, a8 as GetTransactionResponse, X as GetTransactionSuccessResponse, V as GetTransactionsResponse, am as GetTransfersResponse, ad as GetWalletResponse, at as GetWalletSuccessResponse, au as RecoverySignerConfig, ax as RegisterSignerChain, ap as RegisterSignerParams, R as RegisterSignerPasskeyParams, aq as RegisterSignerResponse, as as SendParams, a6 as SendResponse, K as Signer, T as Transfers, a2 as WalletLocator } from '../types-DmDAqO_P.cjs';
2
+ export { ak as ApproveSignatureParams, a4 as ApproveSignatureResponse, ag as ApproveTransactionParams, ah as ApproveTransactionResponse, ai as CreateSignatureParams, aj as CreateSignatureResponse, ae as CreateTransactionParams, af as CreateTransactionResponse, av as CreateTransactionSuccessResponse, a7 as CreateWalletParams, a5 as CreateWalletResponse, ao as FundWalletParams, Y as FundWalletResponse, an as GetBalanceResponse, aw as GetBalanceSuccessResponse, al as GetSignatureResponse, ar as GetSignerResponse, ay as GetSignersResponse, a8 as GetTransactionResponse, _ as GetTransactionSuccessResponse, Z as GetTransactionsResponse, am as GetTransfersResponse, ad as GetWalletResponse, at as GetWalletSuccessResponse, au as RecoverySignerConfig, ax as RegisterSignerChain, ap as RegisterSignerParams, R as RegisterSignerPasskeyParams, aq as RegisterSignerResponse, as as SendParams, a6 as SendResponse, N as Signer, T as Transfers, a3 as WalletLocator } from '../types-DfT-EHk3.cjs';
3
3
  import '@crossmint/common-sdk-base';
4
4
  import '../chains/chains.cjs';
5
5
  import 'viem';
@@ -1,5 +1,5 @@
1
1
  export { ApiClient } from './client.js';
2
- export { ak as ApproveSignatureParams, a4 as ApproveSignatureResponse, ag as ApproveTransactionParams, ah as ApproveTransactionResponse, ai as CreateSignatureParams, aj as CreateSignatureResponse, ae as CreateTransactionParams, af as CreateTransactionResponse, av as CreateTransactionSuccessResponse, a7 as CreateWalletParams, a5 as CreateWalletResponse, ao as FundWalletParams, U as FundWalletResponse, an as GetBalanceResponse, aw as GetBalanceSuccessResponse, al as GetSignatureResponse, ar as GetSignerResponse, ay as GetSignersResponse, a8 as GetTransactionResponse, X as GetTransactionSuccessResponse, V as GetTransactionsResponse, am as GetTransfersResponse, ad as GetWalletResponse, at as GetWalletSuccessResponse, au as RecoverySignerConfig, ax as RegisterSignerChain, ap as RegisterSignerParams, R as RegisterSignerPasskeyParams, aq as RegisterSignerResponse, as as SendParams, a6 as SendResponse, K as Signer, T as Transfers, a2 as WalletLocator } from '../types-BTh6aKMQ.js';
2
+ export { ak as ApproveSignatureParams, a4 as ApproveSignatureResponse, ag as ApproveTransactionParams, ah as ApproveTransactionResponse, ai as CreateSignatureParams, aj as CreateSignatureResponse, ae as CreateTransactionParams, af as CreateTransactionResponse, av as CreateTransactionSuccessResponse, a7 as CreateWalletParams, a5 as CreateWalletResponse, ao as FundWalletParams, Y as FundWalletResponse, an as GetBalanceResponse, aw as GetBalanceSuccessResponse, al as GetSignatureResponse, ar as GetSignerResponse, ay as GetSignersResponse, a8 as GetTransactionResponse, _ as GetTransactionSuccessResponse, Z as GetTransactionsResponse, am as GetTransfersResponse, ad as GetWalletResponse, at as GetWalletSuccessResponse, au as RecoverySignerConfig, ax as RegisterSignerChain, ap as RegisterSignerParams, R as RegisterSignerPasskeyParams, aq as RegisterSignerResponse, as as SendParams, a6 as SendResponse, N as Signer, T as Transfers, a3 as WalletLocator } from '../types-vcGYTcL0.js';
3
3
  import '@crossmint/common-sdk-base';
4
4
  import '../chains/chains.js';
5
5
  import 'viem';
package/dist/api/index.js CHANGED
@@ -1 +1 @@
1
- import"../chunk-5IFDVB4Y.js";import{a}from"../chunk-YNQPYZGU.js";import"../chunk-KBJA7JDT.js";import"../chunk-EXC7TCGL.js";import"../chunk-5AMNTK5L.js";import"../chunk-34LCOL3F.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
1
+ import"../chunk-5IFDVB4Y.js";import{a}from"../chunk-HQVHXT3U.js";import"../chunk-KBJA7JDT.js";import"../chunk-EXC7TCGL.js";import"../chunk-2X65YHU4.js";import"../chunk-J7C3SSSQ.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
@@ -1,6 +1,6 @@
1
1
  import 'viem';
2
2
  import './gen/types.gen.cjs';
3
- export { ak as ApproveSignatureParams, a4 as ApproveSignatureResponse, ag as ApproveTransactionParams, ah as ApproveTransactionResponse, ai as CreateSignatureParams, aj as CreateSignatureResponse, ae as CreateTransactionParams, af as CreateTransactionResponse, av as CreateTransactionSuccessResponse, a7 as CreateWalletParams, a5 as CreateWalletResponse, ao as FundWalletParams, U as FundWalletResponse, an as GetBalanceResponse, aw as GetBalanceSuccessResponse, al as GetSignatureResponse, ar as GetSignerResponse, ay as GetSignersResponse, a8 as GetTransactionResponse, X as GetTransactionSuccessResponse, V as GetTransactionsResponse, am as GetTransfersResponse, ad as GetWalletResponse, at as GetWalletSuccessResponse, au as RecoverySignerConfig, ax as RegisterSignerChain, ap as RegisterSignerParams, R as RegisterSignerPasskeyParams, aq as RegisterSignerResponse, as as SendParams, a6 as SendResponse, K as Signer, T as Transfers, a2 as WalletLocator } from '../types-DmDAqO_P.cjs';
3
+ export { ak as ApproveSignatureParams, a4 as ApproveSignatureResponse, ag as ApproveTransactionParams, ah as ApproveTransactionResponse, ai as CreateSignatureParams, aj as CreateSignatureResponse, ae as CreateTransactionParams, af as CreateTransactionResponse, av as CreateTransactionSuccessResponse, a7 as CreateWalletParams, a5 as CreateWalletResponse, ao as FundWalletParams, Y as FundWalletResponse, an as GetBalanceResponse, aw as GetBalanceSuccessResponse, al as GetSignatureResponse, ar as GetSignerResponse, ay as GetSignersResponse, a8 as GetTransactionResponse, _ as GetTransactionSuccessResponse, Z as GetTransactionsResponse, am as GetTransfersResponse, ad as GetWalletResponse, at as GetWalletSuccessResponse, au as RecoverySignerConfig, ax as RegisterSignerChain, ap as RegisterSignerParams, R as RegisterSignerPasskeyParams, aq as RegisterSignerResponse, as as SendParams, a6 as SendResponse, N as Signer, T as Transfers, a3 as WalletLocator } from '../types-DfT-EHk3.cjs';
4
4
  import '../chains/chains.cjs';
5
5
  import 'ox';
6
6
  import '@crossmint/client-sdk-window';
@@ -1,6 +1,6 @@
1
1
  import 'viem';
2
2
  import './gen/types.gen.js';
3
- export { ak as ApproveSignatureParams, a4 as ApproveSignatureResponse, ag as ApproveTransactionParams, ah as ApproveTransactionResponse, ai as CreateSignatureParams, aj as CreateSignatureResponse, ae as CreateTransactionParams, af as CreateTransactionResponse, av as CreateTransactionSuccessResponse, a7 as CreateWalletParams, a5 as CreateWalletResponse, ao as FundWalletParams, U as FundWalletResponse, an as GetBalanceResponse, aw as GetBalanceSuccessResponse, al as GetSignatureResponse, ar as GetSignerResponse, ay as GetSignersResponse, a8 as GetTransactionResponse, X as GetTransactionSuccessResponse, V as GetTransactionsResponse, am as GetTransfersResponse, ad as GetWalletResponse, at as GetWalletSuccessResponse, au as RecoverySignerConfig, ax as RegisterSignerChain, ap as RegisterSignerParams, R as RegisterSignerPasskeyParams, aq as RegisterSignerResponse, as as SendParams, a6 as SendResponse, K as Signer, T as Transfers, a2 as WalletLocator } from '../types-BTh6aKMQ.js';
3
+ export { ak as ApproveSignatureParams, a4 as ApproveSignatureResponse, ag as ApproveTransactionParams, ah as ApproveTransactionResponse, ai as CreateSignatureParams, aj as CreateSignatureResponse, ae as CreateTransactionParams, af as CreateTransactionResponse, av as CreateTransactionSuccessResponse, a7 as CreateWalletParams, a5 as CreateWalletResponse, ao as FundWalletParams, Y as FundWalletResponse, an as GetBalanceResponse, aw as GetBalanceSuccessResponse, al as GetSignatureResponse, ar as GetSignerResponse, ay as GetSignersResponse, a8 as GetTransactionResponse, _ as GetTransactionSuccessResponse, Z as GetTransactionsResponse, am as GetTransfersResponse, ad as GetWalletResponse, at as GetWalletSuccessResponse, au as RecoverySignerConfig, ax as RegisterSignerChain, ap as RegisterSignerParams, R as RegisterSignerPasskeyParams, aq as RegisterSignerResponse, as as SendParams, a6 as SendResponse, N as Signer, T as Transfers, a3 as WalletLocator } from '../types-vcGYTcL0.js';
4
4
  import '../chains/chains.js';
5
5
  import 'ox';
6
6
  import '@crossmint/client-sdk-window';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkMXNC4GJQcjs = require('../chunk-MXNC4GJQ.cjs');require('../chunk-GEY574TH.cjs');require('../chunk-UE3WVHTM.cjs');require('../chunk-5X4EOJFG.cjs');require('../chunk-HRUMWG2F.cjs');require('../chunk-IR5WN6FQ.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-CW2GPBXZ.cjs');require('../chunk-Y22BJFQT.cjs');require('../chunk-2GKPWQBQ.cjs');exports.isMainnetChain = _chunkMXNC4GJQcjs.c; exports.isTestnetChain = _chunkMXNC4GJQcjs.b; exports.isValidChain = _chunkMXNC4GJQcjs.e; exports.mainnetToTestnet = _chunkMXNC4GJQcjs.d; exports.toViemChain = _chunkMXNC4GJQcjs.a; exports.validateChainForEnvironment = _chunkMXNC4GJQcjs.f;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJMCNCVQNcjs = require('../chunk-JMCNCVQN.cjs');require('../chunk-GEY574TH.cjs');require('../chunk-UE3WVHTM.cjs');require('../chunk-5X4EOJFG.cjs');require('../chunk-HRUMWG2F.cjs');require('../chunk-IR5WN6FQ.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-V5A3FGH2.cjs');require('../chunk-CV5GT7CP.cjs');require('../chunk-2GKPWQBQ.cjs');exports.isMainnetChain = _chunkJMCNCVQNcjs.c; exports.isTestnetChain = _chunkJMCNCVQNcjs.b; exports.isValidChain = _chunkJMCNCVQNcjs.e; exports.mainnetToTestnet = _chunkJMCNCVQNcjs.d; exports.toViemChain = _chunkJMCNCVQNcjs.a; exports.validateChainForEnvironment = _chunkJMCNCVQNcjs.f;
@@ -1 +1 @@
1
- import{a,b,c,d,e,f}from"../chunk-3LIYGJ26.js";import"../chunk-S3DYQVRD.js";import"../chunk-KUP7H7X2.js";import"../chunk-FT5EVMLB.js";import"../chunk-SVIKBM3S.js";import"../chunk-KKQBZXFE.js";import"../chunk-EXC7TCGL.js";import"../chunk-455NK5LB.js";import"../chunk-5AMNTK5L.js";import"../chunk-34LCOL3F.js";import"../chunk-J3R36SGJ.js";export{c as isMainnetChain,b as isTestnetChain,e as isValidChain,d as mainnetToTestnet,a as toViemChain,f as validateChainForEnvironment};
1
+ import{a,b,c,d,e,f}from"../chunk-A4ENPOX6.js";import"../chunk-S3DYQVRD.js";import"../chunk-KUP7H7X2.js";import"../chunk-FT5EVMLB.js";import"../chunk-SVIKBM3S.js";import"../chunk-KKQBZXFE.js";import"../chunk-EXC7TCGL.js";import"../chunk-455NK5LB.js";import"../chunk-2X65YHU4.js";import"../chunk-J7C3SSSQ.js";import"../chunk-J3R36SGJ.js";export{c as isMainnetChain,b as isTestnetChain,e as isValidChain,d as mainnetToTestnet,a as toViemChain,f as validateChainForEnvironment};
@@ -0,0 +1,3 @@
1
+ import{a as ae}from"./chunk-N4IWDL6M.js";import{a as W}from"./chunk-GOXB2RBF.js";import{b as G,c as M}from"./chunk-VADIEIDS.js";import{a as q}from"./chunk-LLQEZP55.js";import{b as L}from"./chunk-RBSMBO4T.js";import{a as ie}from"./chunk-SG4NRUNV.js";import{f as ne}from"./chunk-A4ENPOX6.js";import{B as te,d as j,e as _,j as H,n as U,q as K,r as V,s as z,t as Y,u as J,v as Q,w as X,x as Z,y as ee,z as re}from"./chunk-EXC7TCGL.js";import{a as s}from"./chunk-2X65YHU4.js";import{d as B}from"./chunk-J7C3SSSQ.js";import{a as C,b as I,c as x,d as n,e as E,f as w,g as d}from"./chunk-J3R36SGJ.js";import{isValidAddress as se,WithLoggerContext as P}from"@crossmint/common-sdk-base";var f,m,g,b,k,T,N,O,R,A=class{constructor(e,r){E(this,f);E(this,m);E(this,g);E(this,b);E(this,k);E(this,T,!1);E(this,N,!1);E(this,O);E(this,R,null);let{chain:t,address:i,owner:c,options:p,alias:h,recovery:l,signers:a,signer:o}=e;w(this,g,r),this.chain=t,this.address=i,this.owner=c,w(this,m,p),this.alias=h,w(this,b,l),w(this,k,a!=null?a:[]),w(this,f,o),w(this,O,this.initDefaultSigner())}get signer(){return n(this,f)}initDeviceSigner(){return d(this,null,function*(){var i;let e=(i=n(this,m))==null?void 0:i.deviceSignerKeyStorage;if(e==null||this.chain==="solana")return;let r={type:"device"};try{yield this.resolveDeviceSignerAvailability(r)}catch(c){s.error("wallet.initDeviceSigner.error",{error:c}),w(this,T,!0);return}let t=this.buildInternalSignerConfig(r);w(this,f,yield this.assembleFullSigner(t,e))})}initDefaultSigner(){return d(this,null,function*(){if(n(this,f)==null&&(yield this.initDeviceSigner(),!(n(this,f)!=null||n(this,T))))try{if(n(this,k).length===0){let e=this.buildInternalSignerConfig(n(this,b));w(this,f,yield this.assembleFullSigner(e))}else if(n(this,k).length===1){let e=this.buildInternalSignerConfig(n(this,k)[0]);w(this,f,yield this.assembleFullSigner(e))}}catch(e){s.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:n(this,b).type,signerCount:n(this,k).length,error:e})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return n(e,b)}static getInitialSigners(e){return n(e,k)}get apiClient(){return n(this,g)}get options(){return n(this,m)}get recovery(){return n(this,b)}balances(e){return d(this,null,function*(){s.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t;switch(this.chain){case"solana":t="sol";break;case"stellar":t="xlm";break;default:t="eth";break}let i=[t,"usdc",...e!=null?e:[]],c=yield n(this,g).getBalance(this.address,{chains:[r],tokens:i});if("error"in c)throw s.error("wallet.balances.error",{error:c}),new Error(`Failed to get balances for wallet: ${JSON.stringify(c.message)}`);return s.info("wallet.balances.success"),this.transformBalanceResponse(c,t,e)})}stagingFund(e,r){return d(this,null,function*(){s.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw s.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return s.info("wallet.stagingFund.success"),t})}transformBalanceResponse(e,r,t){let i=a=>{var S,v,F,$,D;let o=(S=a.chains)==null?void 0:S[this.chain],u={};return this.chain==="solana"&&o!=null&&"mintHash"in o?u={mintHash:o.mintHash}:this.chain==="stellar"&&o!=null&&"contractId"in o?u={contractId:o.contractId}:o!=null&&"contractAddress"in o&&(u={contractAddress:o.contractAddress}),C({symbol:(v=a.symbol)!=null?v:"",name:(F=a.name)!=null?F:"",amount:($=a.amount)!=null?$:"0",decimals:a.decimals,rawAmount:(D=a.rawAmount)!=null?D:"0"},u)},c=e.find(a=>a.symbol===r),p=e.find(a=>a.symbol==="usdc"),h=e.filter(a=>{var o;return a.symbol!==r&&a.symbol!=="usdc"&&(t==null||t.includes((o=a.symbol)!=null?o:""))}),l=a=>{let o={symbol:a,name:a,amount:"0",decimals:0,rawAmount:"0"},u={};return this.chain==="solana"?u={mintHash:void 0}:this.chain==="stellar"?u={contractId:void 0}:u={contractAddress:void 0},C(C({},o),u)};return{nativeToken:c!=null?i(c):l(r),usdc:p!=null?i(p):l("usdc"),tokens:h.map(i)}}nfts(e){return d(this,null,function*(){return yield n(this,g).getNfts(I(C({},e),{chain:this.chain,address:this.address}))})}transactions(){return d(this,null,function*(){let e=yield n(this,g).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return d(this,null,function*(){let r=yield n(this,g).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.error)}`);return r})}transfers(e){return d(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e==null?void 0:e.tokens,status:e==null?void 0:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,i){return d(this,null,function*(){let c=this.resolveChainForEnvironment(),p=ce(e),h=de(r,c),l=Number(t);if(Number.isNaN(l)||!Number.isFinite(l)||l<=0)throw new z(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);s.info("wallet.send.start",C({recipient:p,token:h,amount:t},(i==null?void 0:i.transactionType)!=null?{transactionType:i.transactionType}:{})),yield this.preAuthIfNeeded();let a=this.requireSigner(),o;(i==null?void 0:i.signer)==null?o=a.locator():typeof i.signer=="string"?o=i.signer:o=`server:${L(i.signer,this.chain,n(this,g).projectId,n(this,g).environment).derivedAddress}`;let u=C({recipient:p,amount:t,signer:o},(i==null?void 0:i.transactionType)!=null?{transactionType:i.transactionType}:{}),S=yield n(this,g).send(this.walletLocator,h,u);if("message"in S)throw s.error("wallet.send.error",{error:S}),new Y(`Failed to send token: ${JSON.stringify(S.message)}`);if((i==null?void 0:i.prepareOnly)===!0)return s.info("wallet.send.prepared",{transactionId:S.id}),{hash:void 0,explorerLink:void 0,transactionId:S.id};let v=yield this.approveTransactionAndWait(S.id);return s.info("wallet.send.success",{transactionId:S.id,hash:v.hash}),v})}approveTransaction(e){return d(this,null,function*(){return console.warn("approveTransaction is deprecated. Use approve instead. This method will be removed in the next major version."),yield this.approve(e)})}approve(e){return d(this,null,function*(){if(this.requireSigner(),s.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return s.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return s.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw s.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return d(this,null,function*(){var p,h;s.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?`server:${L(e,this.chain,n(this,g).projectId,n(this,g).environment).derivedAddress}`:e,i=this.signer,c=this.buildInternalSignerConfig(n(this,b));w(this,f,q(this.chain,c,(p=n(this,m))==null?void 0:p.deviceSignerKeyStorage));try{let l=typeof t=="string"||t.type==="passkey"?t:t.type==="device"&&"publicKey"in t&&t.publicKey!=null?{type:"device",publicKey:t.publicKey,name:t.name}:W(t),a=yield n(this,g).registerSigner(this.walletLocator,{signer:l,chain:this.chain==="solana"||this.chain==="stellar"?void 0:this.chain});if("error"in a)throw s.error("wallet.addSigner.error",{error:a}),new Error(`Failed to register signer: ${JSON.stringify(a.message)}`);let o=G(a,this.chain);if(this.chain==="solana"||this.chain==="stellar"){if(!("transaction"in a)||a.transaction==null)throw s.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");let u=a.transaction.id;if(o==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);return r!=null&&r.prepareOnly?(s.info("wallet.addSigner.prepared",{transactionId:u}),I(C({},o),{transactionId:u})):(yield this.approveTransactionAndWait(u),s.info("wallet.addSigner.success",{transactionId:u}),I(C({},o),{status:"success"}))}else{if(!("chains"in a))throw s.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");let u=(h=a.chains)==null?void 0:h[this.chain];if(o==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let S=M(a,this.chain);if(r!=null&&r.prepareOnly){let v=(S==null?void 0:S.type)==="signature"?S.id:void 0;return s.info("wallet.addSigner.prepared",{signatureId:v}),I(C({},o),{signatureId:v})}if((S==null?void 0:S.type)==="signature")yield this.approveSignatureAndWait(S.id),s.info("wallet.addSigner.success",{signatureId:S.id});else{if((u==null?void 0:u.status)==="failed")throw new Error(`Signer registration failed for chain ${this.chain}`);s.info("wallet.addSigner.success")}return I(C({},o),{status:"success"})}}finally{w(this,f,i)}})}useSigner(e){return d(this,null,function*(){s.info("wallet.useSigner.start"),this.validateSignerInput(e),e.type==="device"?yield this.resolveDeviceSignerAvailability(e):yield this.resolveNonDeviceSigner(e);let r=this.buildInternalSignerConfig(e),t=W(e);w(this,f,yield this.assembleFullSigner(r)),s.info("wallet.useSigner.success",{signerLocator:t})})}resolveNonDeviceSigner(e){return d(this,null,function*(){if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e)){w(this,T,!1);return}throw new Error("No passkey signer is registered on this wallet.")}let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r)){w(this,T,!1);return}if(this.isRecoverySigner(e)){w(this,T,!1);return}throw new Error(`Signer "${r}" is not registered in this wallet.`)})}tryAutoSelectPasskey(e){return d(this,null,function*(){let t=(yield this.signers()).filter(i=>i.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){if(e.type==="server"){let{derivedAddress:r}=L(e,this.chain,n(this,g).projectId,n(this,g).environment);return`server:${r}`}return W(e)}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return d(this,null,function*(){return(yield this.signers()).some(t=>t.locator===e)})}isSignerApproved(e){return d(this,null,function*(){var t;return((t=(yield this.getSignerState(e)).signer)==null?void 0:t.status)==="success"})}needsRecovery(){return n(this,T)}recover(){return d(this,null,function*(){var p,h,l,a;if(s.info("wallet.recover.start"),n(this,f)==null&&(yield this.initDeviceSigner()),((p=n(this,f))==null?void 0:p.type)!=="device"){s.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"});return}if(n(this,N)){s.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}let e=n(this,f),r=()=>{w(this,T,!1),w(this,N,!0)};if(e.status==="success"){s.info("wallet.recover.skipped",{reason:"Device signer already approved"}),r();return}let t=yield this.getSignerState(e.locator());if(e.status=(h=t.signer)==null?void 0:h.status,t.pendingOperation!=null){let o=n(this,f),u=this.buildInternalSignerConfig(n(this,b));w(this,f,q(this.chain,u,(l=n(this,m))==null?void 0:l.deviceSignerKeyStorage));try{t.pendingOperation.type==="signature"?yield this.approveSignatureAndWait(t.pendingOperation.id):yield this.approveTransactionAndWait(t.pendingOperation.id)}finally{w(this,f,o)}e.status="success",s.info("wallet.recover.device.success",{signerLocator:e.locator(),resumed:!0}),r();return}if(e.status==="success"){s.info("wallet.recover.skipped",{reason:"Device signer already approved"}),r();return}let i=(a=n(this,m))==null?void 0:a.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required to recover a device signer");let c=yield ae(i,this.address);try{yield this.addSigner(c)}catch(o){throw s.error("wallet.recover.device.error",{error:o}),yield i.deleteKey(this.address),o}w(this,f,yield this.assembleFullSigner({type:"device",locator:c.locator,address:this.address},i)),s.info("wallet.recover.device.success",{signerLocator:c.locator}),r()})}signers(){return d(this,null,function*(){var c,p;s.info("wallet.signers.start");let e=yield n(this,g).getWallet(this.walletLocator);if("error"in e)throw s.error("wallet.signers.error",{error:e}),new _(JSON.stringify(e));if(e.type!=="smart"||e.chainType!=="evm"&&e.chainType!=="solana"&&e.chainType!=="stellar")throw s.error("wallet.signers.error",{error:`Wallet type ${e.type} not supported`}),new j(`Wallet type ${e.type} not supported`);let r=(p=(c=e==null?void 0:e.config)==null?void 0:c.delegatedSigners)!=null?p:[],i=(yield Promise.all(r.map(h=>d(this,null,function*(){try{return(yield this.getSignerState(h.locator)).signer}catch(l){return null}})))).filter(h=>h!=null);return s.info("wallet.signers.success",{count:i.length}),i})}get walletLocator(){if(n(this,g).isServerSide)return this.address;{let e;switch(this.chain){case"stellar":e="me:stellar:smart";break;case"solana":e="me:solana:smart";break;default:e="me:evm:smart";break}let r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}requireSigner(){if(n(this,f)==null)throw n(this,k).length>1?new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations."):n(this,b).type==="server"?new Error(`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
2
+ Example: wallet.useSigner({ type: "server", secret: process.env.YOUR_SERVER_SECRET })`):n(this,b).type==="external-wallet"?new Error(`No signer is set. External wallet signers require calling wallet.useSigner() with the onSign callback before signing operations.
3
+ Example: wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... })`):new Error("This wallet is read-only because no signer was provided. Operations that require signing (send, approve, addSigner, etc.) are not available.");return n(this,f)}preAuthIfNeeded(){return d(this,null,function*(){yield n(this,O),n(this,R)==null&&w(this,R,this.recover());try{yield n(this,R)}finally{w(this,R,null)}let e=this.requireSigner();e instanceof ie&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=n(this,b);if(r==null||r.type!==e.type||e.type==="device")return!1;if(e.type==="passkey")return!0;if(e.type==="server"&&r.type==="server"){let t=L(e,this.chain,n(this,g).projectId,n(this,g).environment).derivedAddress,i=L(r,this.chain,n(this,g).projectId,n(this,g).environment).derivedAddress;return t===i}return W(e)===W(r)}validateSignerInput(e){switch(e.type){case"email":if(!("email"in e)||e.email==null)throw new Error("Email signer requires an email address");break;case"phone":if(!("phone"in e)||e.phone==null)throw new Error("Phone signer requires a phone number");break;case"external-wallet":if(!("address"in e)||e.address==null)throw new Error("External wallet signer requires a wallet address");if(!("onSign"in e)||typeof e.onSign!="function")throw new Error("External wallet signer requires an onSign callback");break;case"passkey":case"device":case"api-key":break;default:break}}resolveDeviceSignerAvailability(e){return d(this,null,function*(){var p;let r=(p=n(this,m))==null?void 0:p.deviceSignerKeyStorage;if(r==null)throw new Error("Device signer key storage is required for device signers");let t=yield r.getKey(this.address);if(t!=null){e.locator=`device:${t}`;return}let c=(yield this.signers()).filter(h=>h.locator.startsWith("device:"));for(let h of c){let l=h.locator.replace("device:","");if(yield r.hasKey(l)){yield r.mapAddressToKey(this.address,l),e.locator=h.locator;return}}w(this,T,!0),w(this,N,!1)})}assembleFullSigner(i){return d(this,arguments,function*(e,r=(t=>(t=n(this,m))==null?void 0:t.deviceSignerKeyStorage)()){var h;let c=q(this.chain,e,r),p=yield this.getSignerState(c.locator());return c.status=(h=p.signer)==null?void 0:h.status,c})}getSignerState(e){return d(this,null,function*(){let r=null;try{r=yield n(this,g).getSigner(this.walletLocator,e)}catch(i){return{response:null,signer:null,pendingOperation:null}}if(r==null||typeof r!="object"||"error"in r)return{response:null,signer:null,pendingOperation:null};let t=G(r,this.chain);return{response:r,signer:t,pendingOperation:M(r,this.chain)}})}buildInternalSignerConfig(e){var r,t,i,c,p,h;switch(e.type){case"email":return{type:"email",email:e.email,locator:`email:${e.email}`,address:this.address,crossmint:n(this,g).crossmint,clientTEEConnection:(r=n(this,m))==null?void 0:r.clientTEEConnection,onAuthRequired:(i=(t=n(this,m))==null?void 0:t.callbacks)==null?void 0:i.onAuthRequired};case"phone":return{type:"phone",phone:e.phone,locator:`phone:${e.phone}`,address:this.address,crossmint:n(this,g).crossmint,clientTEEConnection:(c=n(this,m))==null?void 0:c.clientTEEConnection,onAuthRequired:(h=(p=n(this,m))==null?void 0:p.callbacks)==null?void 0:h.onAuthRequired};case"passkey":{let l="id"in e&&e.id?e.id:"";return{type:"passkey",id:l,locator:`passkey:${l}`,name:"name"in e?e.name:void 0,publicKey:"publicKey"in e?e.publicKey:void 0,onCreatePasskey:e.onCreatePasskey,onSignWithPasskey:e.onSignWithPasskey}}case"device":return{type:"device",locator:"locator"in e&&e.locator?e.locator:void 0,address:this.address};case"external-wallet":return I(C({},e),{locator:`external-wallet:${e.address}`});case"api-key":return{type:"api-key",locator:"api-key",address:this.address};case"server":{let{derivedKeyBytes:l,derivedAddress:a}=L(e,this.chain,n(this,g).projectId,n(this,g).environment);return{type:"server",derivedKeyBytes:l,locator:`server:${a}`,address:a}}default:throw new Error(`Unknown signer type: ${e==null?void 0:e.type}`)}}get isSolanaWallet(){return this.chain==="solana"}resolveChainForEnvironment(){let e=ne(this.chain,n(this,g).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return d(this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return d(this,null,function*(){let t=yield this.approveSignatureInternal(e,r);return!("error"in t)&&t.status==="success"&&t.outputSignature!=null?{signature:t.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return d(this,null,function*(){var l,a;if(this.isSolanaWallet)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=this.requireSigner(),i=yield n(this,g).getSignature(this.walletLocator,e);if("error"in i)throw new K(JSON.stringify(i));if(t.type==="api-key")return i;if((r==null?void 0:r.approval)!=null){let o=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,o)}let c=(l=i.approvals)==null?void 0:l.pending;if(c==null)return i;let p=[...(a=r==null?void 0:r.additionalSigners)!=null?a:[],t],h=yield Promise.all(c.map(o=>d(this,null,function*(){let u=p.find(v=>v.locator()===o.signer.locator);if(u==null)throw new H(`Signer ${o.signer.locator} not found in pending approvals`);let S=yield u.signMessage(o.message);return I(C({},S),{signer:u.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,h)})}approveTransactionInternal(e,r){return d(this,null,function*(){var l,a,o,u,S;let t=yield n(this,g).getTransaction(this.walletLocator,e);if("error"in t)throw new J(JSON.stringify(t));yield(o=(a=(l=n(this,m))==null?void 0:l.callbacks)==null?void 0:a.onTransactionStart)==null?void 0:o.call(a);let i=this.requireSigner();if(i.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let v=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,v)}let c=(u=t.approvals)==null?void 0:u.pending;if(c==null)return t;let p=[...(S=r==null?void 0:r.additionalSigners)!=null?S:[],i],h=yield Promise.all(c.map(v=>d(this,null,function*(){let F=p.find(le=>le.locator()===v.signer.locator);if(F==null)throw new H(`Signer ${v.signer.locator} not found in pending approvals`);let $=F.type==="device",D=t.chainType==="solana"&&"transaction"in t.onChain&&!$?t.onChain.transaction:v.message,oe=yield F.signTransaction(D);return I(C({},oe),{signer:F.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,h)})}executeApproveTransactionWithErrorHandling(e,r){return d(this,null,function*(){s.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield n(this,g).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw new re(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return d(this,null,function*(){let t=yield n(this,g).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw new V(JSON.stringify(t));return t})}waitForSignature(e){return d(this,null,function*(){let r=null;do if(yield new Promise(t=>setTimeout(t,B)),r=yield n(this,g).getSignature(this.walletLocator,e),"error"in r)throw new K(JSON.stringify(r));while(r===null||r.status==="pending");if(r.status==="failed")throw new U("Signature signing failed");if(!r.outputSignature)throw new K("Signature not available");return{signature:r.outputSignature,signatureId:e}})}waitForTransaction(p){return d(this,arguments,function*(e,r=6e4,{backoffMultiplier:t=1.1,maxBackoffMs:i=2e3,initialBackoffMs:c=B}={}){var u,S;s.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:r});let h=Date.now(),l;do{if(Date.now()-h>r)throw new Q("Transaction confirmation timeout");if(l=yield n(this,g).getTransaction(this.walletLocator,e),l.error)throw new J(JSON.stringify(l));yield this.sleep(c),c=Math.min(c*t,i)}while(l.status==="pending");if(l.status==="failed")throw new X(`Transaction sending failed: ${JSON.stringify(l.error)}`);if(l.status==="awaiting-approval")throw new Z("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let a="txHash"in l.onChain&&typeof l.onChain.txHash=="string"?l.onChain.txHash:void 0,o=(u=l.onChain.txId)!=null?u:a;if(o==null)throw new ee("Transaction hash not found on transaction response");return{hash:o,explorerLink:(S=l.onChain.explorerLink)!=null?S:"",transactionId:l.id}})}sleep(e){return d(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};f=new WeakMap,m=new WeakMap,g=new WeakMap,b=new WeakMap,k=new WeakMap,T=new WeakMap,N=new WeakMap,O=new WeakMap,R=new WeakMap,x([P({logger:s,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"balances",1),x([P({logger:s,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"stagingFund",1),x([P({logger:s,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"send",1),x([P({logger:s,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"approve",1),x([P({logger:s,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"addSigner",1),x([P({logger:s,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"useSigner",1),x([P({logger:s,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"recover",1),x([P({logger:s,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"signers",1);function ce(y){if(typeof y=="string"){if(!se(y))throw new te(`Invalid recipient address: "${y}". Expected a valid EVM (0x...), Solana (base58), or Stellar (G.../C...) address.`);return y}if("email"in y)return`email:${y.email}`;if("x"in y)return`x:${y.x}`;if("twitter"in y)return`twitter:${y.twitter}`;if("phone"in y)return`phoneNumber:${y.phone}`;if("userId"in y)return`userId:${y.userId}`;throw new Error("Invalid recipient locator")}function de(y,e){return se(y)?`${e}:${y}`:`${e}:${y.toLowerCase()}`}export{A as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGN7GYBJAcjs = require('./chunk-GN7GYBJA.cjs');var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkEPJRLPAIcjs = require('./chunk-EPJRLPAI.cjs');var _chunkCW2GPBXZcjs = require('./chunk-CW2GPBXZ.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunkCW2GPBXZcjs.b.call(void 0, e.apiKey);let t=new (0, _chunkEPJRLPAIcjs.a)(e);this.walletFactory=new (0, _chunkGN7GYBJAcjs.a)(t),_chunkCW2GPBXZcjs.a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield _chunkYHV3672Rcjs.a.call(void 0, e,t)})}createPasskeySigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};exports.a = _commonsdkbase.createCrossmint; exports.b = o;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk7O3CV5HXcjs = require('./chunk-7O3CV5HX.cjs');var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkJJKL6FU2cjs = require('./chunk-JJKL6FU2.cjs');var _chunkV5A3FGH2cjs = require('./chunk-V5A3FGH2.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunkV5A3FGH2cjs.b.call(void 0, e.apiKey);let t=new (0, _chunkJJKL6FU2cjs.a)(e);this.walletFactory=new (0, _chunk7O3CV5HXcjs.a)(t),_chunkV5A3FGH2cjs.a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield _chunkYHV3672Rcjs.a.call(void 0, e,t)})}createPasskeySigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};exports.a = _commonsdkbase.createCrossmint; exports.b = o;
@@ -1 +1 @@
1
- import{b as n,c as i}from"./chunk-34LCOL3F.js";import{SdkLogger as d,BrowserDatadogSink as k,detectPlatform as g,validateAPIKey as l,ServerDatadogSink as m}from"@crossmint/common-sdk-base";var t=new d;function f(s){let o=g(),e=l(s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:i,packageVersion:n,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new k(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new m(a);t.addSink(r);break}default:break}}export{t as a,f as b};
1
+ import{b as n,c as i}from"./chunk-J7C3SSSQ.js";import{SdkLogger as d,BrowserDatadogSink as k,detectPlatform as g,validateAPIKey as l,ServerDatadogSink as m}from"@crossmint/common-sdk-base";var t=new d;function f(s){let o=g(),e=l(s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:i,packageVersion:n,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new k(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new m(a);t.addSink(r);break}default:break}}export{t as a,f as b};