@rhinestone/deposit-modal 0.12.2 → 0.13.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 +30 -16
  2. package/dist/ClaimModal-CREZO27I.mjs +11 -0
  3. package/dist/ClaimModal-JRIA32U2.cjs +11 -0
  4. package/dist/{DepositModalReown-TEC3MEZ4.mjs → DepositModalReown-3H75G3XQ.mjs} +44 -22
  5. package/dist/{DepositModalReown-VG66OTIU.cjs → DepositModalReown-YNNHLAV2.cjs} +57 -35
  6. package/dist/{QRCode-WUC652SH.mjs → QRCode-5RGIZZHL.mjs} +1 -1
  7. package/dist/{QRCode-5DXFNKI2.cjs → QRCode-JKXG4RHN.cjs} +2 -2
  8. package/dist/WithdrawModal-NVRX44IZ.mjs +10 -0
  9. package/dist/WithdrawModal-YYSBPCJJ.cjs +10 -0
  10. package/dist/{chunk-OIN4CXCP.cjs → chunk-2G2EIN4A.cjs} +1510 -896
  11. package/dist/{chunk-O7BCVQ6L.cjs → chunk-4KCSH4T3.cjs} +157 -199
  12. package/dist/{chunk-TM7VGHAG.cjs → chunk-5NUIKYSF.cjs} +83 -209
  13. package/dist/{chunk-UQIJU6HV.cjs → chunk-7N77GIP4.cjs} +102 -88
  14. package/dist/{chunk-J46WDSRD.mjs → chunk-COCBCQQC.mjs} +121 -86
  15. package/dist/chunk-CVGNCUVU.cjs +154 -0
  16. package/dist/{chunk-SDSKIJC7.mjs → chunk-DSIZNRWA.mjs} +1540 -926
  17. package/dist/{chunk-75DVGSAX.cjs → chunk-DW2EQA2U.cjs} +6 -3
  18. package/dist/{chunk-FXXUIK4E.mjs → chunk-EOMT5LKX.mjs} +374 -151
  19. package/dist/chunk-FZ5FZFIG.mjs +31 -0
  20. package/dist/chunk-GACIGCSN.cjs +31 -0
  21. package/dist/{chunk-HL5NUKZW.cjs → chunk-HOGZKHHY.cjs} +3 -3
  22. package/dist/{chunk-FLVLYO64.mjs → chunk-LTMMETAB.mjs} +29 -15
  23. package/dist/{chunk-2TPSF77V.mjs → chunk-OLCD75JK.mjs} +20 -146
  24. package/dist/{chunk-PWLEBV5V.cjs → chunk-RAADLTSW.cjs} +240 -205
  25. package/dist/{chunk-4ZXQPFNU.mjs → chunk-RN5VKWI6.mjs} +4 -1
  26. package/dist/{chunk-3STTWRAN.mjs → chunk-VUATPOWJ.mjs} +147 -189
  27. package/dist/{chunk-JE4R5VA3.mjs → chunk-XYJFEN5D.mjs} +1 -1
  28. package/dist/chunk-YREVFB64.mjs +154 -0
  29. package/dist/{chunk-BRYNGLDM.cjs → chunk-ZMT4ATHR.cjs} +437 -214
  30. package/dist/claim.cjs +7 -6
  31. package/dist/claim.d.cts +11 -3
  32. package/dist/claim.d.ts +11 -3
  33. package/dist/claim.mjs +6 -5
  34. package/dist/{constants-FuzG3h4m.d.cts → constants-DBrWhJWE.d.cts} +12 -7
  35. package/dist/{constants-FuzG3h4m.d.ts → constants-DBrWhJWE.d.ts} +12 -7
  36. package/dist/constants.cjs +3 -9
  37. package/dist/constants.d.cts +2 -3
  38. package/dist/constants.d.ts +2 -3
  39. package/dist/constants.mjs +4 -10
  40. package/dist/deposit.cjs +8 -8
  41. package/dist/deposit.d.cts +2 -2
  42. package/dist/deposit.d.ts +2 -2
  43. package/dist/deposit.mjs +7 -7
  44. package/dist/embed.cjs +1268 -0
  45. package/dist/embed.d.cts +177 -0
  46. package/dist/embed.d.ts +177 -0
  47. package/dist/embed.mjs +1268 -0
  48. package/dist/index.cjs +11 -16
  49. package/dist/index.d.cts +3 -3
  50. package/dist/index.d.ts +3 -3
  51. package/dist/index.mjs +14 -19
  52. package/dist/modal-ui-state-OD1RmKkK.d.cts +30 -0
  53. package/dist/modal-ui-state-OD1RmKkK.d.ts +30 -0
  54. package/dist/polymarket.cjs +17 -7
  55. package/dist/polymarket.mjs +13 -3
  56. package/dist/styles.css +124 -98
  57. package/dist/{types-oFblf65g.d.ts → types-B89I8_8H.d.ts} +27 -1
  58. package/dist/{types-BO4iP6fG.d.cts → types-nnDR4tqA.d.cts} +27 -1
  59. package/dist/withdraw.cjs +6 -6
  60. package/dist/withdraw.d.cts +11 -3
  61. package/dist/withdraw.d.ts +11 -3
  62. package/dist/withdraw.mjs +5 -5
  63. package/package.json +33 -1
  64. package/dist/chunk-IAGFDSNC.mjs +0 -11
  65. package/dist/chunk-L32UI7LA.cjs +0 -11
@@ -0,0 +1,154 @@
1
+ import {
2
+ debugError,
3
+ debugLog
4
+ } from "./chunk-EOMT5LKX.mjs";
5
+ import {
6
+ serviceHeaders
7
+ } from "./chunk-FZ5FZFIG.mjs";
8
+
9
+ // src/core/recovery.ts
10
+ var RECOVER_DOMAIN = {
11
+ name: "Rhinestone Deposit Recovery",
12
+ version: "1"
13
+ };
14
+ var RECOVER_TYPES = {
15
+ RecoverDeposit: [
16
+ { name: "depositId", type: "uint256" },
17
+ { name: "destination", type: "address" }
18
+ ]
19
+ };
20
+ var RecoveryError = class extends Error {
21
+ constructor(message, status, code, retryable = false) {
22
+ super(message);
23
+ this.name = "RecoveryError";
24
+ this.status = status;
25
+ this.code = code;
26
+ this.retryable = retryable;
27
+ }
28
+ };
29
+ function formatRecoveryError(status, code, serverMessage) {
30
+ switch (code) {
31
+ case "DEPOSIT_NOT_RECOVERABLE":
32
+ return {
33
+ message: "This deposit can't be recovered \u2014 it may already have been claimed.",
34
+ retryable: false
35
+ };
36
+ case "RECOVERY_UNSUPPORTED":
37
+ return {
38
+ message: "This deposit can't be recovered automatically. Contact support to get your funds back.",
39
+ retryable: false
40
+ };
41
+ case "SIGNATURE_INVALID":
42
+ return {
43
+ message: "That signature wasn't accepted for this wallet. Contact support to recover this deposit.",
44
+ retryable: false
45
+ };
46
+ case "VERIFICATION_UNAVAILABLE":
47
+ return {
48
+ message: "Couldn't verify your signature just now. Try again shortly.",
49
+ retryable: true
50
+ };
51
+ case "REFUND_RECONCILIATION_REQUIRED":
52
+ return {
53
+ message: "Your recovery is being reviewed. Contact support with this deposit if it doesn't arrive.",
54
+ retryable: false
55
+ };
56
+ case "REFUND_FAILED":
57
+ return {
58
+ message: serverMessage ?? "The recovery couldn't be completed. Please try again or contact support.",
59
+ retryable: true
60
+ };
61
+ default:
62
+ if (status === 0) {
63
+ return {
64
+ message: "Couldn't reach the recovery service. Check your connection and try again.",
65
+ retryable: true
66
+ };
67
+ }
68
+ return {
69
+ message: serverMessage ?? "The recovery couldn't be completed. Please try again or contact support.",
70
+ retryable: true
71
+ };
72
+ }
73
+ }
74
+ async function submitSignedRecovery(params) {
75
+ const { backendUrl, chainId, depositId, signer, destination, signRecovery, debug } = params;
76
+ const scope = "service:recovery";
77
+ const typedData = {
78
+ domain: RECOVER_DOMAIN,
79
+ types: RECOVER_TYPES,
80
+ primaryType: "RecoverDeposit",
81
+ message: { depositId: BigInt(depositId), destination }
82
+ };
83
+ let signature;
84
+ try {
85
+ signature = await signRecovery({
86
+ typedData,
87
+ chainId,
88
+ signer,
89
+ depositId,
90
+ destination
91
+ });
92
+ } catch (error) {
93
+ debugError(debug, scope, "signRecovery:failed", error);
94
+ throw new RecoveryError(
95
+ "Signature request was declined. Approve it in your wallet to recover this deposit.",
96
+ 0,
97
+ void 0,
98
+ true
99
+ );
100
+ }
101
+ if (!signature) {
102
+ throw new RecoveryError(
103
+ "Signature request was declined. Approve it in your wallet to recover this deposit.",
104
+ 0,
105
+ void 0,
106
+ true
107
+ );
108
+ }
109
+ const url = `${backendUrl.replace(/\/$/, "")}/deposits/recover`;
110
+ debugLog(debug, scope, "submitSignedRecovery:request", {
111
+ url,
112
+ depositId,
113
+ signer
114
+ });
115
+ let response;
116
+ try {
117
+ response = await fetch(url, {
118
+ method: "POST",
119
+ // The shared const, so recovery carries `x-deposit-modal-version` like
120
+ // every other backend call. Without it this path would be invisible in the
121
+ // per-client version telemetry the processor records.
122
+ headers: serviceHeaders(),
123
+ // `depositId` as a string: it is a uint256 upstream and JSON numbers lose
124
+ // precision well before that range.
125
+ body: JSON.stringify({ depositId, destination, signature })
126
+ });
127
+ } catch (error) {
128
+ debugError(debug, scope, "submitSignedRecovery:network", error);
129
+ const { message, retryable } = formatRecoveryError(0);
130
+ throw new RecoveryError(message, 0, void 0, retryable);
131
+ }
132
+ if (!response.ok) {
133
+ const body = await response.json().catch(() => ({}));
134
+ debugError(debug, scope, "submitSignedRecovery:failed", body, {
135
+ status: response.status
136
+ });
137
+ const { message, retryable } = formatRecoveryError(
138
+ response.status,
139
+ body.code,
140
+ body.error
141
+ );
142
+ throw new RecoveryError(message, response.status, body.code, retryable);
143
+ }
144
+ const result = await response.json();
145
+ debugLog(debug, scope, "submitSignedRecovery:success", {
146
+ transactionHash: result.transactionHash
147
+ });
148
+ return result;
149
+ }
150
+
151
+ export {
152
+ RecoveryError,
153
+ submitSignedRecovery
154
+ };