@rhinestone/deposit-modal 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +193 -29
  2. package/dist/{chunk-2JPB3PLB.mjs → DepositModalReown-6KUAO5ZC.mjs} +56 -4
  3. package/dist/{chunk-Q3W53BKR.cjs → DepositModalReown-XC5RIU7Z.cjs} +62 -10
  4. package/dist/{caip-C_ZYFIGa.d.cts → caip-523Zrc3r.d.cts} +1 -3
  5. package/dist/{caip-C_ZYFIGa.d.ts → caip-523Zrc3r.d.ts} +1 -3
  6. package/dist/{chunk-D3Y7ZBED.cjs → chunk-22RV33LK.cjs} +2170 -1460
  7. package/dist/chunk-4WB2FHGC.mjs +865 -0
  8. package/dist/chunk-A223BLVC.mjs +801 -0
  9. package/dist/{chunk-HQWZCOMS.cjs → chunk-DIX7M3SP.cjs} +232 -601
  10. package/dist/{chunk-T43VUEJH.mjs → chunk-E4G5BOZP.mjs} +167 -536
  11. package/dist/chunk-H577RJN5.cjs +801 -0
  12. package/dist/{chunk-DABKCJVL.mjs → chunk-ILT2PITN.mjs} +60 -3
  13. package/dist/{chunk-7KHEIMWD.mjs → chunk-KKHLNFSA.mjs} +2436 -1726
  14. package/dist/chunk-LGVJWVSS.mjs +81 -0
  15. package/dist/chunk-NEXUCY4B.cjs +11 -0
  16. package/dist/chunk-NMIMRASD.cjs +1785 -0
  17. package/dist/chunk-OSI2CFGL.mjs +11 -0
  18. package/dist/chunk-PAGMU4RQ.cjs +865 -0
  19. package/dist/chunk-T7LGQFP3.cjs +81 -0
  20. package/dist/chunk-VN4BLZYC.cjs +2273 -0
  21. package/dist/chunk-VOGZAZB2.mjs +2273 -0
  22. package/dist/chunk-WYXBY2MQ.mjs +1785 -0
  23. package/dist/{chunk-4NN7UTWQ.cjs → chunk-YEBXUUH3.cjs} +63 -6
  24. package/dist/claim.cjs +10 -0
  25. package/dist/claim.d.cts +8 -0
  26. package/dist/claim.d.ts +8 -0
  27. package/dist/claim.mjs +10 -0
  28. package/dist/constants.cjs +3 -3
  29. package/dist/constants.d.cts +4 -2
  30. package/dist/constants.d.ts +4 -2
  31. package/dist/constants.mjs +5 -5
  32. package/dist/deposit.cjs +8 -6
  33. package/dist/deposit.d.cts +2 -2
  34. package/dist/deposit.d.ts +2 -2
  35. package/dist/deposit.mjs +7 -5
  36. package/dist/index.cjs +22 -12
  37. package/dist/index.d.cts +15 -2
  38. package/dist/index.d.ts +15 -2
  39. package/dist/index.mjs +21 -11
  40. package/dist/polymarket.cjs +5 -6
  41. package/dist/polymarket.mjs +2 -3
  42. package/dist/server.cjs +96 -0
  43. package/dist/server.d.cts +65 -0
  44. package/dist/server.d.ts +65 -0
  45. package/dist/server.mjs +96 -0
  46. package/dist/styles.css +263 -12
  47. package/dist/types-C0SGf-21.d.cts +606 -0
  48. package/dist/types-C0SGf-21.d.ts +606 -0
  49. package/dist/withdraw.cjs +6 -5
  50. package/dist/withdraw.d.cts +3 -6
  51. package/dist/withdraw.d.ts +3 -6
  52. package/dist/withdraw.mjs +5 -4
  53. package/package.json +53 -6
  54. package/dist/DepositModalReown-4BSHOQ5Y.mjs +0 -63
  55. package/dist/DepositModalReown-UND3DEJH.cjs +0 -63
  56. package/dist/WithdrawModalReown-FVXSSGY5.mjs +0 -46
  57. package/dist/WithdrawModalReown-TVZWJKQI.cjs +0 -46
  58. package/dist/chunk-7OKA6GNA.cjs +0 -4537
  59. package/dist/chunk-NASHLEVQ.mjs +0 -4537
  60. package/dist/chunk-O5OKA27M.mjs +0 -800
  61. package/dist/chunk-U7SVYWVD.cjs +0 -800
  62. package/dist/chunk-WK5AFRSP.mjs +0 -295
  63. package/dist/chunk-XRWQMIBY.cjs +0 -295
  64. package/dist/types--LQWg_4W.d.cts +0 -468
  65. package/dist/types--LQWg_4W.d.ts +0 -468
@@ -1,468 +0,0 @@
1
- import { Address, Hex, WalletClient, PublicClient, Chain } from 'viem';
2
-
3
- interface SafeTransactionRequest {
4
- chainId: number;
5
- safeAddress: Address;
6
- safeTxHash: Hex;
7
- typedData: {
8
- domain: {
9
- chainId: number;
10
- verifyingContract: Address;
11
- };
12
- types: typeof SAFE_TX_TYPES;
13
- primaryType: "SafeTx";
14
- message: {
15
- to: Address;
16
- value: bigint;
17
- data: Hex;
18
- operation: number;
19
- safeTxGas: bigint;
20
- baseGas: bigint;
21
- gasPrice: bigint;
22
- gasToken: Address;
23
- refundReceiver: Address;
24
- nonce: bigint;
25
- };
26
- };
27
- }
28
- declare const SAFE_TX_TYPES: {
29
- readonly SafeTx: readonly [{
30
- readonly name: "to";
31
- readonly type: "address";
32
- }, {
33
- readonly name: "value";
34
- readonly type: "uint256";
35
- }, {
36
- readonly name: "data";
37
- readonly type: "bytes";
38
- }, {
39
- readonly name: "operation";
40
- readonly type: "uint8";
41
- }, {
42
- readonly name: "safeTxGas";
43
- readonly type: "uint256";
44
- }, {
45
- readonly name: "baseGas";
46
- readonly type: "uint256";
47
- }, {
48
- readonly name: "gasPrice";
49
- readonly type: "uint256";
50
- }, {
51
- readonly name: "gasToken";
52
- readonly type: "address";
53
- }, {
54
- readonly name: "refundReceiver";
55
- readonly type: "address";
56
- }, {
57
- readonly name: "nonce";
58
- readonly type: "uint256";
59
- }];
60
- };
61
-
62
- /**
63
- * Public config shape exposed on DepositModalProps. Each dapp defaults to
64
- * off — clients must explicitly opt in.
65
- */
66
- interface DappImportsConfig {
67
- polymarket?: boolean;
68
- }
69
-
70
- /**
71
- * Consumer-supplied RPC URL overrides, scoped to a single modal instance (see
72
- * {@link RpcUrlsProvider}). Threaded into every client the modal builds — EVM
73
- * public clients (`public-client.ts`), the wallet adapter's transports
74
- * (`reown.tsx`), and the Solana connection (`solana.ts`).
75
- *
76
- * Keyed by the same `number | "solana"` chain identifier the rest of the modal
77
- * uses (see `core/constants.ts`), so a single `rpcUrls` prop covers every
78
- * chain — EVM mainnets, Polygon (137, also feeds Polymarket reads), HyperEVM
79
- * (999), and Solana.
80
- */
81
- type ChainKey = number | "solana";
82
- type RpcUrlMap = Partial<Record<ChainKey, string>>;
83
-
84
- type Caip2ChainId = `eip155:${number}` | `solana:${string}`;
85
- type ChainId = number | "solana" | "hypercore" | Caip2ChainId;
86
- interface DepositModalTheme {
87
- mode?: "light" | "dark";
88
- radius?: "none" | "sm" | "md" | "lg" | "full";
89
- fontColor?: string;
90
- iconColor?: string;
91
- ctaColor?: string;
92
- ctaHoverColor?: string;
93
- borderColor?: string;
94
- backgroundColor?: string;
95
- }
96
- interface DepositModalUIConfig {
97
- showBackButton?: boolean;
98
- showHistoryButton?: boolean;
99
- maxDepositUsd?: number;
100
- minDepositUsd?: number;
101
- /**
102
- * When true the network/protocol fee is sponsored — the Review / Processing /
103
- * Success / Failure screens render the fee line-through and surface a
104
- * tooltip on the info icon explaining the sponsorship.
105
- */
106
- feeSponsored?: boolean;
107
- /**
108
- * Custom tooltip copy for the fee info icon. Defaults to a generic
109
- * "Fees are sponsored" / "Fees apply" message based on `feeSponsored`.
110
- */
111
- feeTooltip?: string;
112
- /**
113
- * Run the liquidity check before the amount step continues. Off by default:
114
- * the check adds an orchestrator round-trip per continue and its low/unavailable
115
- * result isn't surfaced anyway, so skipping it makes the route faster. Enable
116
- * to gate continue on liquidity and show the unavailable/check-failed warning.
117
- */
118
- checkLiquidity?: boolean;
119
- }
120
- interface ConnectedEventData {
121
- address: Address;
122
- smartAccount: Address;
123
- }
124
- interface DepositSubmittedEventData {
125
- txHash: string;
126
- sourceChain: ChainId | "unknown";
127
- amount: string;
128
- }
129
- interface DepositCompleteEventData {
130
- txHash: string;
131
- destinationTxHash?: string;
132
- amount: string;
133
- sourceChain: ChainId | "unknown";
134
- sourceToken?: string;
135
- targetChain: number | "solana";
136
- targetToken: string;
137
- }
138
- interface DepositFailedEventData {
139
- txHash: string;
140
- error?: string;
141
- }
142
- interface WithdrawSubmittedEventData {
143
- txHash: Hex;
144
- sourceChain: number;
145
- amount: string;
146
- safeAddress: Address;
147
- }
148
- interface WithdrawCompleteEventData {
149
- txHash: Hex;
150
- destinationTxHash?: Hex;
151
- amount: string;
152
- sourceChain: number;
153
- sourceToken: Address;
154
- targetChain: number;
155
- targetToken: Address;
156
- }
157
- interface WithdrawFailedEventData {
158
- txHash: Hex;
159
- error?: string;
160
- }
161
- interface ErrorEventData {
162
- message: string;
163
- code?: string;
164
- }
165
- interface OutputTokenRule {
166
- match: {
167
- chain?: string;
168
- token?: string;
169
- symbol?: string;
170
- };
171
- outputToken: string;
172
- }
173
- interface RouteConfig {
174
- sourceChains?: number[];
175
- sourceTokens?: string[];
176
- }
177
- interface FiatPaymentMethodOption {
178
- /**
179
- * Swapped's `payment_group` value (e.g. `creditcard`, `apple-pay`,
180
- * `bank-transfer`) from GET /api/v1/merchant/get_payment_methods. This exact
181
- * value is what the widget URL's `method` param prepopulates from — Apple Pay
182
- * is `apple-pay`, not `applepay`.
183
- */
184
- method: string;
185
- /** Row label shown in ConnectStep. */
186
- label: string;
187
- /** Optional sublabel under the row. */
188
- sublabel?: string;
189
- /** Optional icon name: `card` | `apple` | `bank`. Defaults to `card`. */
190
- icon?: "card" | "apple" | "bank";
191
- }
192
- interface DepositModalProps {
193
- dappWalletClient?: WalletClient | null;
194
- dappPublicClient?: PublicClient | null;
195
- dappAddress?: Address | null;
196
- targetChain: Chain | number | "solana";
197
- targetToken: Address | string;
198
- isOpen: boolean;
199
- onClose: () => void;
200
- inline?: boolean;
201
- closeOnOverlayClick?: boolean;
202
- sourceChain?: Chain | number;
203
- sourceToken?: Address;
204
- /**
205
- * Pre-fills the deposit amount. Either a USD-denominated number string
206
- * (e.g. "25") or the case-insensitive sentinel `"max"`, which fills the
207
- * full available balance once it loads (same as the Max preset).
208
- */
209
- defaultAmount?: string;
210
- recipient: Address | string;
211
- /**
212
- * The user's current in-app balance, in USD, as the consuming app displays
213
- * it. When provided, the amount screen shows a "Balance after deposit" row
214
- * (`appBalanceUsd + amount`) so the user sees their post-deposit app
215
- * balance. The row is hidden when this is omitted.
216
- */
217
- appBalanceUsd?: number;
218
- outputTokenRules?: OutputTokenRule[];
219
- rejectUnmapped?: boolean;
220
- backendUrl?: string;
221
- /**
222
- * Per-chain RPC URL overrides, keyed by EVM chain id plus the literal
223
- * `"solana"` key. Applied everywhere the modal reads chain state — EVM
224
- * public clients, the connected wallet's transports (avoiding the
225
- * rate-limited public defaults), Polygon/Polymarket reads, HyperEVM (999),
226
- * and the Solana connection. Chains left unset use their default RPC.
227
- */
228
- rpcUrls?: RpcUrlMap;
229
- rhinestoneApiKey?: string;
230
- signerAddress?: Address;
231
- sessionChainIds?: number[];
232
- forceRegister?: boolean;
233
- reownAppId?: string;
234
- enableSolana?: boolean;
235
- /**
236
- * Enable importing balances from third-party dapps. Each dapp defaults to
237
- * off — clients must explicitly opt in. When a dapp is enabled and the
238
- * connected wallet has a balance there, a new row appears on the deposit
239
- * entry screen.
240
- */
241
- dappImports?: DappImportsConfig;
242
- /**
243
- * Open the modal pre-routed into a dapp-import provider, skipping the
244
- * deposit-method home screen. Must name an enabled `dappImports` key
245
- * (e.g. "polymarket"); disabled/unknown values are a no-op. While the
246
- * provider's balances are checked the modal shows a loading skeleton;
247
- * if the flow turns out to be unreachable (no account, no balance, no
248
- * wallet) it falls back to the home screen.
249
- */
250
- initialDappImport?: keyof DappImportsConfig;
251
- /** Show fiat on-ramp option(s) that embed Swapped's iframe. Default: false. */
252
- enableFiatOnramp?: boolean;
253
- /** Show the Transfer Crypto / QR row. Default: true. */
254
- enableQrTransfer?: boolean;
255
- /**
256
- * One row per Swapped payment method (Pay with Card / Apple Pay / Bank
257
- * Transfer). When set, replaces the generic "Pay with Card" row.
258
- */
259
- fiatOnrampMethods?: FiatPaymentMethodOption[];
260
- /**
261
- * Show a "Connect exchange" row that opens Swapped Connect — the user
262
- * picks their CEX (Coinbase, Binance, Kraken…) or wallet inside the iframe
263
- * and Swapped pulls the crypto on-chain to the smart account. Default: false.
264
- */
265
- enableExchangeConnect?: boolean;
266
- onRequestConnect?: () => void;
267
- theme?: DepositModalTheme;
268
- uiConfig?: DepositModalUIConfig;
269
- allowedRoutes?: RouteConfig;
270
- className?: string;
271
- onReady?: () => void;
272
- /** Discriminated stream of deposit lifecycle transitions. */
273
- onLifecycle?: (event: DepositLifecycleEvent) => void;
274
- onEvent?: (event: DepositAnalyticsEvent) => void;
275
- onError?: (data: ErrorEventData) => void;
276
- debug?: boolean;
277
- }
278
- interface WithdrawModalProps {
279
- dappWalletClient?: WalletClient | null;
280
- dappPublicClient?: PublicClient | null;
281
- dappAddress?: Address | null;
282
- safeAddress: Address;
283
- sourceChain: Chain | number;
284
- sourceToken: Address;
285
- targetChain: Chain | number;
286
- targetToken: Address;
287
- recipient?: Address;
288
- defaultAmount?: string;
289
- isOpen: boolean;
290
- onClose: () => void;
291
- inline?: boolean;
292
- closeOnOverlayClick?: boolean;
293
- allowedRoutes?: RouteConfig;
294
- backendUrl?: string;
295
- /**
296
- * Per-chain RPC URL overrides, keyed by EVM chain id plus the literal
297
- * `"solana"` key. Applied to every chain read (EVM public clients and the
298
- * connected wallet's transports). Chains left unset use their default RPC.
299
- */
300
- rpcUrls?: RpcUrlMap;
301
- rhinestoneApiKey?: string;
302
- signerAddress?: Address;
303
- sessionChainIds?: number[];
304
- forceRegister?: boolean;
305
- reownAppId?: string;
306
- onSignTransaction?: (request: SafeTransactionRequest) => Promise<{
307
- signature: Hex;
308
- }>;
309
- onRequestConnect?: () => void;
310
- theme?: DepositModalTheme;
311
- uiConfig?: DepositModalUIConfig;
312
- className?: string;
313
- onReady?: () => void;
314
- /** Discriminated stream of withdraw lifecycle transitions. */
315
- onLifecycle?: (event: WithdrawLifecycleEvent) => void;
316
- onEvent?: (event: WithdrawAnalyticsEvent) => void;
317
- onError?: (data: ErrorEventData) => void;
318
- debug?: boolean;
319
- }
320
- interface AssetOption {
321
- id: string;
322
- chainId: number;
323
- token: Address;
324
- symbol: string;
325
- name: string;
326
- decimals: number;
327
- balance?: string;
328
- balanceUsd?: number;
329
- }
330
- /**
331
- * Discriminated union covering every deposit flow state transition the
332
- * consumer can observe. Consumers handle additions in a single switch; the
333
- * modal can add new event variants without changing the prop surface.
334
- */
335
- type DepositLifecycleEvent = {
336
- type: "connected";
337
- address: Address;
338
- smartAccount: Address;
339
- } | {
340
- type: "submitted";
341
- txHash: string;
342
- sourceChain: ChainId | "unknown";
343
- /** Source-token base units (e.g. "1100000" for 1.10 USDC). */
344
- amount: string;
345
- /**
346
- * Decimals of the source token, for converting `amount` to a
347
- * human-readable value. Omitted when the token is not recognised
348
- * (e.g. a QR deposit of an unlisted token).
349
- */
350
- sourceDecimals?: number;
351
- /**
352
- * USD equivalent of the deposit as entered in the modal (token units
353
- * for unpriced non-stablecoins). Omitted for flows without an amount
354
- * input (QR transfer, fiat onramp, exchange connect).
355
- */
356
- amountUsd?: string;
357
- } | {
358
- type: "complete";
359
- txHash: string;
360
- destinationTxHash?: string;
361
- /** Source-token base units (e.g. "1100000" for 1.10 USDC). */
362
- amount: string;
363
- sourceChain: ChainId | "unknown";
364
- sourceToken?: string;
365
- /**
366
- * Decimals of the source token, for converting `amount` to a
367
- * human-readable value. Omitted when the token is not recognised
368
- * (e.g. a QR deposit of an unlisted token).
369
- */
370
- sourceDecimals?: number;
371
- /**
372
- * USD equivalent of the deposit as entered in the modal (token units
373
- * for unpriced non-stablecoins). Omitted for flows without an amount
374
- * input (QR transfer, fiat onramp, exchange connect).
375
- */
376
- amountUsd?: string;
377
- targetChain: number | "solana";
378
- targetToken: string;
379
- } | {
380
- type: "failed";
381
- txHash: string;
382
- error?: string;
383
- } | {
384
- type: "balance-changed";
385
- totalUsd: number;
386
- } | {
387
- type: "smart-account-changed";
388
- evm: Address | null;
389
- solana: string | null;
390
- };
391
- type WithdrawLifecycleEvent = {
392
- type: "connected";
393
- address: Address;
394
- smartAccount: Address;
395
- } | {
396
- type: "submitted";
397
- txHash: Hex;
398
- sourceChain: number;
399
- amount: string;
400
- safeAddress: Address;
401
- } | {
402
- type: "complete";
403
- txHash: Hex;
404
- destinationTxHash?: Hex;
405
- amount: string;
406
- sourceChain: number;
407
- sourceToken: Address;
408
- targetChain: number;
409
- targetToken: Address;
410
- } | {
411
- type: "failed";
412
- txHash: Hex;
413
- error?: string;
414
- };
415
- /**
416
- * Telemetry events fired when screens open or CTAs are clicked.
417
- * Distinct from {@link DepositLifecycleEvent}, which tracks transaction state.
418
- */
419
- type DepositAnalyticsEvent = {
420
- type: "deposit_modal_connected_wallet_select_source_open";
421
- total_balance_in_external_wallet: number | null;
422
- pred_balance: number | null;
423
- } | {
424
- type: "deposit_modal_connected_wallet_select_source_cta_click";
425
- total_balance_in_external_wallet: number | null;
426
- pred_balance: number | null;
427
- cta_name: "token_selected";
428
- token_name: string;
429
- token_balance: string;
430
- } | {
431
- type: "deposit_modal_transfer_crypto_open";
432
- default_chain: string;
433
- default_token: string;
434
- pred_balance: number | null;
435
- } | {
436
- type: "deposit_modal_transfer_crypto_cta_click";
437
- default_chain: string;
438
- default_token: string;
439
- pred_balance: number | null;
440
- cta_name: "copy";
441
- } | {
442
- type: "deposit_modal_connected_wallet_enter_value_open";
443
- send_token: string;
444
- receive_token: string;
445
- pred_balance: number | null;
446
- } | {
447
- type: "deposit_modal_connected_wallet_enter_value_cta_click";
448
- send_token: string;
449
- receive_token: string;
450
- pred_balance: number | null;
451
- cta_name: "continue" | "25%" | "50%" | "75%" | "Max";
452
- };
453
- type WithdrawAnalyticsEvent = {
454
- type: "withdraw_modal_select_amount_open";
455
- pred_balance: number | null;
456
- default_token: string;
457
- default_chain: string;
458
- } | {
459
- type: "withdraw_modal_select_amount_cta_click";
460
- pred_balance: number | null;
461
- selected_token: string;
462
- selected_chain: string;
463
- amount: string;
464
- cta_name: "withdraw";
465
- };
466
- type ModalAnalyticsEvent = DepositAnalyticsEvent | WithdrawAnalyticsEvent;
467
-
468
- export type { AssetOption as A, ChainId as C, DappImportsConfig as D, ErrorEventData as E, ModalAnalyticsEvent as M, OutputTokenRule as O, RouteConfig as R, SafeTransactionRequest as S, WithdrawAnalyticsEvent as W, ConnectedEventData as a, DepositAnalyticsEvent as b, DepositCompleteEventData as c, DepositFailedEventData as d, DepositLifecycleEvent as e, DepositModalProps as f, DepositModalTheme as g, DepositModalUIConfig as h, DepositSubmittedEventData as i, RpcUrlMap as j, WithdrawCompleteEventData as k, WithdrawFailedEventData as l, WithdrawLifecycleEvent as m, WithdrawModalProps as n, WithdrawSubmittedEventData as o };