@rhinestone/deposit-modal 0.0.0-dev-20260730114422 → 0.0.0-dev-20260730153145
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.
- package/README.md +58 -20
- package/dist/{DepositModalReown-KKQ7XR2V.cjs → DepositModalReown-U5EHFQRK.cjs} +9 -9
- package/dist/{DepositModalReown-X4QTYV2Z.mjs → DepositModalReown-YDELSYCS.mjs} +5 -5
- package/dist/{chunk-WQRS2OQV.cjs → chunk-2MNDZ4E6.cjs} +187 -106
- package/dist/{chunk-KIHBZIYT.mjs → chunk-4GMACNN7.mjs} +1 -1
- package/dist/{chunk-KD6TEGL3.mjs → chunk-BDRGXYDX.mjs} +138 -57
- package/dist/{chunk-AJLUXRZ3.mjs → chunk-BHLLQUWO.mjs} +2 -6
- package/dist/{chunk-4F764346.cjs → chunk-J4ZCXBCL.cjs} +57 -57
- package/dist/{chunk-7SWH5QF4.mjs → chunk-JPSMRSOQ.mjs} +4 -4
- package/dist/chunk-LFQMZS5O.cjs +11 -0
- package/dist/{chunk-TC6345EX.mjs → chunk-LG5JKKA2.mjs} +1 -1
- package/dist/{chunk-EUQEECI3.cjs → chunk-LX2IDGJU.cjs} +21 -25
- package/dist/{chunk-YOYJEFX5.cjs → chunk-OKMLSIBM.cjs} +3 -3
- package/dist/{chunk-NB2NKQTC.cjs → chunk-R5R7Z74J.cjs} +67 -67
- package/dist/{chunk-LZDJX5MF.cjs → chunk-RODMYHXE.cjs} +259 -259
- package/dist/{chunk-CRQ7NNQL.mjs → chunk-TMRHKSUO.mjs} +2 -2
- package/dist/chunk-ZED6TQNS.mjs +11 -0
- package/dist/claim.cjs +5 -5
- package/dist/claim.d.cts +4 -31
- package/dist/claim.d.ts +4 -31
- package/dist/claim.mjs +4 -4
- package/dist/constants.cjs +2 -2
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/deposit.cjs +6 -6
- package/dist/deposit.d.cts +2 -2
- package/dist/deposit.d.ts +2 -2
- package/dist/deposit.mjs +5 -5
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +7 -7
- package/dist/{types-CcAjRzzz.d.cts → types-C0SGf-21.d.cts} +78 -14
- package/dist/{types-CcAjRzzz.d.ts → types-C0SGf-21.d.ts} +78 -14
- package/dist/withdraw.cjs +5 -5
- package/dist/withdraw.d.cts +2 -2
- package/dist/withdraw.d.ts +2 -2
- package/dist/withdraw.mjs +4 -4
- package/package.json +1 -1
- package/dist/chunk-E3NNJMG2.cjs +0 -6
- package/dist/chunk-FE2EJOG2.mjs +0 -6
package/README.md
CHANGED
|
@@ -103,7 +103,9 @@ The user picks the destination chain, token, recipient, and amount in the modal;
|
|
|
103
103
|
|
|
104
104
|
## Claim a failed deposit
|
|
105
105
|
|
|
106
|
-
`ClaimModal` lets a user get a failed or rejected EVM deposit sent back to them on its source chain. They paste the deposit's transaction hash and name a destination
|
|
106
|
+
`ClaimModal` lets a user get a failed or rejected EVM deposit sent back to them on its source chain. They paste the deposit's transaction hash and name a destination, and there is no chain to pick: the hash is looked up across every chain, including ones the deposit flow itself doesn't list.
|
|
107
|
+
|
|
108
|
+
**The modal never runs a connect step** — it has no wallet UI and asks for no provider. It does need a signature from the deposit's `recipient`, which it requests through `signRecovery` using whatever wallet your app already holds for that user. For an embedded wallet that is headless and the user sees nothing but the confirmation your own SDK shows.
|
|
107
109
|
|
|
108
110
|
```tsx
|
|
109
111
|
import { ClaimModal } from "@rhinestone/deposit-modal/claim";
|
|
@@ -111,7 +113,7 @@ import { ClaimModal } from "@rhinestone/deposit-modal/claim";
|
|
|
111
113
|
<ClaimModal
|
|
112
114
|
isOpen={claimOpen}
|
|
113
115
|
onClose={() => setClaimOpen(false)}
|
|
114
|
-
|
|
116
|
+
signRecovery={({ typedData }) => wallet.signTypedData(typedData)}
|
|
115
117
|
backendUrl={process.env.NEXT_PUBLIC_DEPOSIT_PROXY_URL}
|
|
116
118
|
// Optional prefills:
|
|
117
119
|
defaultTxHash={depositTxHash}
|
|
@@ -120,14 +122,62 @@ import { ClaimModal } from "@rhinestone/deposit-modal/claim";
|
|
|
120
122
|
/>
|
|
121
123
|
```
|
|
122
124
|
|
|
123
|
-
### Why
|
|
125
|
+
### Why the user signs
|
|
126
|
+
|
|
127
|
+
Deposit accounts are owned by the Rhinestone service, so the account holding the
|
|
128
|
+
funds has no user key and cannot sign for its own refund. But the deposit's
|
|
129
|
+
`recipient` — the in-app wallet the funds were headed to — *is* a key your user
|
|
130
|
+
holds. So that is what authorizes the recovery.
|
|
131
|
+
|
|
132
|
+
`signRecovery` is handed the exact typed data to sign plus the `signer` address the
|
|
133
|
+
processor will verify against, and returns a signature:
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
<ClaimModal
|
|
137
|
+
isOpen={isOpen}
|
|
138
|
+
onClose={() => setIsOpen(false)}
|
|
139
|
+
backendUrl={process.env.NEXT_PUBLIC_DEPOSIT_PROXY_URL}
|
|
140
|
+
signRecovery={({ typedData }) => wallet.signTypedData(typedData)}
|
|
141
|
+
/>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Return whatever that address's own verifier accepts:
|
|
145
|
+
|
|
146
|
+
| recipient is | return |
|
|
147
|
+
|---|---|
|
|
148
|
+
| embedded EOA (Privy, Turnkey, Dynamic) | `signTypedData` — the raw 65-byte signature |
|
|
149
|
+
| deployed smart account | a signature valid under its ERC-1271 `isValidSignature` |
|
|
150
|
+
| undeployed smart account | an ERC-6492 wrapper — `SignatureErc6492.wrap` from `ox/erc6492`, which ships with viem |
|
|
151
|
+
|
|
152
|
+
A raw owner signature is usually **not** enough for a smart account: a Safe expects
|
|
153
|
+
its own message wrapping, so go through your account SDK rather than signing the
|
|
154
|
+
struct directly with the owner key.
|
|
155
|
+
|
|
156
|
+
Your app needs no backend and no shared secret for any of this. The request goes
|
|
157
|
+
straight from the browser through your `deposit-widget-proxy`, which adds only the
|
|
158
|
+
project API key — and that key cannot move funds through this route without a valid
|
|
159
|
+
signature, so there is no privilege for a page to borrow.
|
|
160
|
+
|
|
161
|
+
Two properties fall out of signing that are worth knowing:
|
|
124
162
|
|
|
125
|
-
|
|
163
|
+
- **The destination is inside the signed struct.** The processor cannot pay anywhere
|
|
164
|
+
else, so the success screen states what the user signed rather than trusting the
|
|
165
|
+
endpoint to report where the money went. `defaultRefundDestination` only *seeds*
|
|
166
|
+
the field; whatever the user submits is what they sign.
|
|
167
|
+
- **Failures carry a structured code**, so the modal knows when a retry helps. A
|
|
168
|
+
verification outage is retryable; a rejected signature or a deposit already
|
|
169
|
+
claimed is not. HTTP status alone can't separate those.
|
|
126
170
|
|
|
127
|
-
|
|
171
|
+
### If your users can't sign
|
|
172
|
+
|
|
173
|
+
A lost embedded wallet, or a `recipient` your app controls rather than the user, both
|
|
174
|
+
leave nothing to sign with. `createRefundHandler` from
|
|
175
|
+
`@rhinestone/deposit-modal/server` is still exported for that case — it authorizes on
|
|
176
|
+
your say-so instead, verifying the deposit belongs to the recipient you name before
|
|
177
|
+
spending your API key:
|
|
128
178
|
|
|
129
179
|
```ts
|
|
130
|
-
//
|
|
180
|
+
// your own route, driving your own UI
|
|
131
181
|
import { createRefundHandler } from "@rhinestone/deposit-modal/server";
|
|
132
182
|
|
|
133
183
|
export const POST = createRefundHandler({
|
|
@@ -135,25 +185,13 @@ export const POST = createRefundHandler({
|
|
|
135
185
|
async authorize(request) {
|
|
136
186
|
const session = await getSession(request);
|
|
137
187
|
if (!session) return null; // → 401
|
|
138
|
-
// The deposit `recipient` you passed the widget. Used ONLY to prove the
|
|
139
|
-
// deposit is this user's — it does not decide where the money goes.
|
|
140
188
|
return { depositRecipient: session.depositRecipient };
|
|
141
189
|
},
|
|
142
190
|
});
|
|
143
191
|
```
|
|
144
192
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
`defaultRefundDestination` on the modal only *seeds* that field and the user can edit it; `refundDestination` from `authorize` overrides whatever they submitted.
|
|
148
|
-
|
|
149
|
-
If you write your own endpoint instead, echo a `destination` in the success body whenever you override the requested one, for the same reason.
|
|
150
|
-
|
|
151
|
-
There is deliberately no cross-origin variant. A `deposit-widget-proxy` authenticates
|
|
152
|
-
nobody, so it cannot decide which user a deposit belongs to; pointing
|
|
153
|
-
`refundEndpoint` at another origin would also drop the session cookie, since `fetch`
|
|
154
|
-
omits credentials cross-origin. Mount the handler in your own backend instead — if
|
|
155
|
-
you can authenticate the user well enough to mint a token for a proxy, you can
|
|
156
|
-
authorize the refund directly, with one contract rather than two.
|
|
193
|
+
The modal does not drive this path — you'd build that UI yourself, or route the user
|
|
194
|
+
to support.
|
|
157
195
|
|
|
158
196
|
`GET /deposits` still needs to be proxied for the lookup step, as before.
|
|
159
197
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
3
|
+
var _chunkRODMYHXEcjs = require('./chunk-RODMYHXE.cjs');
|
|
4
|
+
require('./chunk-R5R7Z74J.cjs');
|
|
5
|
+
require('./chunk-OKMLSIBM.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
10
|
-
require('./chunk-
|
|
9
|
+
var _chunkLX2IDGJUcjs = require('./chunk-LX2IDGJU.cjs');
|
|
10
|
+
require('./chunk-LFQMZS5O.cjs');
|
|
11
11
|
require('./chunk-YEBXUUH3.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
@@ -88,14 +88,14 @@ function buildTransports(rpcUrls) {
|
|
|
88
88
|
const transports = {};
|
|
89
89
|
for (const network of EVM_NETWORKS) {
|
|
90
90
|
const id = Number(network.id);
|
|
91
|
-
transports[id] = _viem.http.call(void 0,
|
|
91
|
+
transports[id] = _viem.http.call(void 0, _chunkLX2IDGJUcjs.rpcUrlFor.call(void 0, rpcUrls, id));
|
|
92
92
|
}
|
|
93
93
|
return transports;
|
|
94
94
|
}
|
|
95
95
|
function getEvmRpcFingerprint(rpcUrls) {
|
|
96
96
|
return EVM_NETWORKS.map((network) => {
|
|
97
97
|
const id = Number(network.id);
|
|
98
|
-
return `${id}=${_nullishCoalesce(
|
|
98
|
+
return `${id}=${_nullishCoalesce(_chunkLX2IDGJUcjs.rpcUrlFor.call(void 0, rpcUrls, id), () => ( ""))}`;
|
|
99
99
|
}).join("|");
|
|
100
100
|
}
|
|
101
101
|
var cachedAdapter = null;
|
|
@@ -189,7 +189,7 @@ function useReownWallet() {
|
|
|
189
189
|
await switchChainAsync({ chainId });
|
|
190
190
|
}
|
|
191
191
|
} catch (err) {
|
|
192
|
-
if (
|
|
192
|
+
if (_chunkLX2IDGJUcjs.isUnsupportedChainSwitchError.call(void 0, err)) {
|
|
193
193
|
throw new Error(
|
|
194
194
|
`Switch to ${_chunkH577RJN5cjs.getChainName.call(void 0, chainId)} in your wallet to continue`
|
|
195
195
|
);
|
|
@@ -223,7 +223,7 @@ function DepositModalWithReown(props) {
|
|
|
223
223
|
reown.disconnect();
|
|
224
224
|
}, [reown.disconnect]);
|
|
225
225
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
226
|
-
|
|
226
|
+
_chunkRODMYHXEcjs.DepositModalInner,
|
|
227
227
|
{
|
|
228
228
|
...props,
|
|
229
229
|
reownWallet: reownWithSolana,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DepositModalInner
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-JPSMRSOQ.mjs";
|
|
4
|
+
import "./chunk-LG5JKKA2.mjs";
|
|
5
|
+
import "./chunk-4GMACNN7.mjs";
|
|
6
6
|
import {
|
|
7
7
|
isUnsupportedChainSwitchError,
|
|
8
8
|
rpcUrlFor
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-BHLLQUWO.mjs";
|
|
10
|
+
import "./chunk-ZED6TQNS.mjs";
|
|
11
11
|
import "./chunk-ILT2PITN.mjs";
|
|
12
12
|
import {
|
|
13
13
|
SUPPORTED_CHAINS,
|