@rhinestone/deposit-modal 0.0.0-dev-20260727145407 → 0.0.0-dev-20260727165236
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 +47 -5
- package/dist/{chunk-QMN3IYME.cjs → DepositModalReown-EI63MROO.cjs} +65 -10
- package/dist/{chunk-UMVDMKCX.mjs → DepositModalReown-ZU3CPDTC.mjs} +59 -4
- package/dist/{chunk-XIPHQRGF.cjs → chunk-CU65HAN5.cjs} +212 -289
- package/dist/{chunk-7S4WRVJ4.mjs → chunk-G5JWMTDR.mjs} +1 -1
- package/dist/{chunk-4F2BWS5E.mjs → chunk-GQXT6UL7.mjs} +1 -1
- package/dist/{chunk-RSLT2RQW.mjs → chunk-L4EOEP42.mjs} +3 -3
- package/dist/{chunk-KLTJCZCH.cjs → chunk-O35FIERS.cjs} +23 -59
- package/dist/{chunk-SE7ADCVW.cjs → chunk-QYYGX36T.cjs} +333 -333
- package/dist/{chunk-5I6LUZTB.cjs → chunk-UKN74GQZ.cjs} +2 -2
- package/dist/{chunk-DKU6CVY6.cjs → chunk-UOO6V5WZ.cjs} +78 -78
- package/dist/{chunk-V76RECLR.cjs → chunk-VULYPMCV.cjs} +68 -68
- package/dist/{chunk-ORYDX7FS.mjs → chunk-VXYJ432Q.mjs} +1 -37
- package/dist/{chunk-JLPVWF2O.mjs → chunk-WRSITJQ2.mjs} +143 -220
- package/dist/{chunk-A4VMWNDE.cjs → chunk-YGBHFYTW.cjs} +1 -1
- package/dist/{chunk-2HB26BWN.mjs → chunk-YNRJ643P.mjs} +2 -2
- package/dist/{chunk-CF5ZAKST.mjs → chunk-YVI7Q7P7.mjs} +5 -5
- package/dist/claim.cjs +5 -5
- package/dist/claim.d.cts +3 -6
- package/dist/claim.d.ts +3 -6
- 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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +9 -9
- package/dist/server.cjs +96 -0
- package/dist/server.d.cts +60 -0
- package/dist/server.d.ts +60 -0
- package/dist/server.mjs +96 -0
- package/dist/{types-Dt3ABm1K.d.cts → types-Cuyhz25e.d.cts} +71 -18
- package/dist/{types-Dt3ABm1K.d.ts → types-Cuyhz25e.d.ts} +71 -18
- 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 +11 -1
- package/dist/ClaimModalReown-DXYTMXIX.cjs +0 -35
- package/dist/ClaimModalReown-YFGZEVQO.mjs +0 -35
- package/dist/DepositModalReown-FLY7Y7PQ.mjs +0 -64
- package/dist/DepositModalReown-XTZ7I5IB.cjs +0 -64
package/README.md
CHANGED
|
@@ -80,7 +80,7 @@ The user picks the destination chain, token, recipient, and amount in the modal;
|
|
|
80
80
|
|
|
81
81
|
## Claim a failed deposit
|
|
82
82
|
|
|
83
|
-
`ClaimModal` lets
|
|
83
|
+
`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 — **no wallet connection is involved at any point**.
|
|
84
84
|
|
|
85
85
|
```tsx
|
|
86
86
|
import { ClaimModal } from "@rhinestone/deposit-modal/claim";
|
|
@@ -88,16 +88,58 @@ import { ClaimModal } from "@rhinestone/deposit-modal/claim";
|
|
|
88
88
|
<ClaimModal
|
|
89
89
|
isOpen={claimOpen}
|
|
90
90
|
onClose={() => setClaimOpen(false)}
|
|
91
|
-
|
|
92
|
-
// Optional lookup/
|
|
91
|
+
refundEndpoint="/api/refund"
|
|
92
|
+
// Optional lookup/destination prefills:
|
|
93
93
|
defaultSourceChain={42161}
|
|
94
94
|
defaultTxHash={depositTxHash}
|
|
95
|
-
defaultRecipient={address}
|
|
96
95
|
onLifecycle={(event) => console.log(event)}
|
|
97
96
|
/>
|
|
98
97
|
```
|
|
99
98
|
|
|
100
|
-
|
|
99
|
+
### Why you have to authorize it
|
|
100
|
+
|
|
101
|
+
Deposit accounts are owned by the Rhinestone service, so there is no user wallet that can sign for a refund — and when the deposit arrived from an exchange, the sender can't sign either. Whether a deposit belongs to a given user is something **only your app knows**: you authenticated them, and you chose the `recipient` you passed to the widget.
|
|
102
|
+
|
|
103
|
+
So `refundEndpoint` points at something you control. Two shapes:
|
|
104
|
+
|
|
105
|
+
**Your own backend** — same-origin, so the session cookie authenticates it. `createRefundHandler` does everything except the auth decision:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
// app/api/refund/route.ts
|
|
109
|
+
import { createRefundHandler } from "@rhinestone/deposit-modal/server";
|
|
110
|
+
|
|
111
|
+
export const POST = createRefundHandler({
|
|
112
|
+
apiKey: process.env.RHINESTONE_API_KEY!,
|
|
113
|
+
async authorize(request) {
|
|
114
|
+
const session = await getSession(request);
|
|
115
|
+
if (!session) return null; // → 401
|
|
116
|
+
return { recipient: session.depositRecipient }; // the one YOU passed the widget
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
It verifies the deposit really belongs to that recipient before spending your API key, and 403s otherwise. Return a `destination` from `authorize` to pin where funds go and take that choice away from the browser — the handler reports the effective destination back, so the modal's success screen and `complete` event name the address that was actually paid rather than the one the browser asked for.
|
|
122
|
+
|
|
123
|
+
If you write your own endpoint instead, echo a `destination` in the success body whenever you override the requested one, for the same reason.
|
|
124
|
+
|
|
125
|
+
**A deposit-widget-proxy** — cross-origin, so cookies don't travel. Set `REFUND_TOKEN_SECRET` on the proxy and mint a short-lived token instead:
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
<ClaimModal
|
|
129
|
+
refundEndpoint="https://your-proxy.example/deposits/refund"
|
|
130
|
+
getUserToken={(refund) =>
|
|
131
|
+
fetch("/api/refund-token", {
|
|
132
|
+
method: "POST",
|
|
133
|
+
body: JSON.stringify(refund),
|
|
134
|
+
}).then((r) => r.json()).then((r) => r.token)
|
|
135
|
+
}
|
|
136
|
+
/* … */
|
|
137
|
+
/>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Bind the token to the specific refund it authorizes, not just to the user — an identity-only token is a bearer credential spendable on any destination. See the deposit-widget-proxy README for the mint endpoint.
|
|
141
|
+
|
|
142
|
+
`GET /deposits` still needs to be proxied for the lookup step, as before.
|
|
101
143
|
|
|
102
144
|
## Fiat on-ramp (Swapped)
|
|
103
145
|
|
|
@@ -1,14 +1,23 @@
|
|
|
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 _chunkQYYGX36Tcjs = require('./chunk-QYYGX36T.cjs');
|
|
4
|
+
require('./chunk-VULYPMCV.cjs');
|
|
5
|
+
require('./chunk-UKN74GQZ.cjs');
|
|
3
6
|
|
|
4
|
-
var _chunkKLTJCZCHcjs = require('./chunk-KLTJCZCH.cjs');
|
|
5
7
|
|
|
6
8
|
|
|
9
|
+
var _chunkO35FIERScjs = require('./chunk-O35FIERS.cjs');
|
|
7
10
|
|
|
8
|
-
var _chunkA4VMWNDEcjs = require('./chunk-A4VMWNDE.cjs');
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
|
|
13
|
+
var _chunkYGBHFYTWcjs = require('./chunk-YGBHFYTW.cjs');
|
|
14
|
+
require('./chunk-XBNXKZHQ.cjs');
|
|
15
|
+
|
|
16
|
+
// src/DepositModalReown.tsx
|
|
11
17
|
var _react = require('react');
|
|
18
|
+
|
|
19
|
+
// src/core/reown.tsx
|
|
20
|
+
|
|
12
21
|
var _reactquery = require('@tanstack/react-query');
|
|
13
22
|
var _appkitadapterwagmi = require('@reown/appkit-adapter-wagmi');
|
|
14
23
|
var _appkitadaptersolana = require('@reown/appkit-adapter-solana');
|
|
@@ -59,7 +68,7 @@ var APPKIT_NETWORK_BY_ID = {
|
|
|
59
68
|
[_networks.katana.id]: _networks.katana,
|
|
60
69
|
[_networks.hyperEvm.id]: _networks.hyperEvm
|
|
61
70
|
};
|
|
62
|
-
var EVM_NETWORKS =
|
|
71
|
+
var EVM_NETWORKS = _chunkYGBHFYTWcjs.SUPPORTED_CHAINS.map((chain) => {
|
|
63
72
|
const network = APPKIT_NETWORK_BY_ID[chain.id];
|
|
64
73
|
if (!network) {
|
|
65
74
|
throw new Error(
|
|
@@ -78,14 +87,14 @@ function buildTransports(rpcUrls) {
|
|
|
78
87
|
const transports = {};
|
|
79
88
|
for (const network of EVM_NETWORKS) {
|
|
80
89
|
const id = Number(network.id);
|
|
81
|
-
transports[id] = _viem.http.call(void 0,
|
|
90
|
+
transports[id] = _viem.http.call(void 0, _chunkO35FIERScjs.rpcUrlFor.call(void 0, rpcUrls, id));
|
|
82
91
|
}
|
|
83
92
|
return transports;
|
|
84
93
|
}
|
|
85
94
|
function getEvmRpcFingerprint(rpcUrls) {
|
|
86
95
|
return EVM_NETWORKS.map((network) => {
|
|
87
96
|
const id = Number(network.id);
|
|
88
|
-
return `${id}=${_nullishCoalesce(
|
|
97
|
+
return `${id}=${_nullishCoalesce(_chunkO35FIERScjs.rpcUrlFor.call(void 0, rpcUrls, id), () => ( ""))}`;
|
|
89
98
|
}).join("|");
|
|
90
99
|
}
|
|
91
100
|
var cachedAdapter = null;
|
|
@@ -179,9 +188,9 @@ function useReownWallet() {
|
|
|
179
188
|
await switchChainAsync({ chainId });
|
|
180
189
|
}
|
|
181
190
|
} catch (err) {
|
|
182
|
-
if (
|
|
191
|
+
if (_chunkO35FIERScjs.isUnsupportedChainSwitchError.call(void 0, err)) {
|
|
183
192
|
throw new Error(
|
|
184
|
-
`Switch to ${
|
|
193
|
+
`Switch to ${_chunkYGBHFYTWcjs.getChainName.call(void 0, chainId)} in your wallet to continue`
|
|
185
194
|
);
|
|
186
195
|
}
|
|
187
196
|
throw err;
|
|
@@ -190,7 +199,53 @@ function useReownWallet() {
|
|
|
190
199
|
};
|
|
191
200
|
}
|
|
192
201
|
|
|
202
|
+
// src/DepositModalReown.tsx
|
|
203
|
+
|
|
204
|
+
var _react5 = require('@reown/appkit-adapter-solana/react');
|
|
205
|
+
|
|
206
|
+
function DepositModalWithReown(props) {
|
|
207
|
+
const reown = useReownWallet();
|
|
208
|
+
const enableSolana = _nullishCoalesce(props.enableSolana, () => ( true));
|
|
209
|
+
const { walletProvider: solanaWalletProvider } = _react3.useAppKitProvider.call(void 0,
|
|
210
|
+
enableSolana ? "solana" : "eip155"
|
|
211
|
+
);
|
|
212
|
+
const { connection: solanaConnection } = _react5.useAppKitConnection.call(void 0, );
|
|
213
|
+
const reownWithSolana = _react.useMemo.call(void 0,
|
|
214
|
+
() => ({
|
|
215
|
+
...reown,
|
|
216
|
+
solanaProvider: enableSolana && reown.isSolana ? solanaWalletProvider : void 0,
|
|
217
|
+
solanaConnection: enableSolana && reown.isSolana ? solanaConnection : void 0
|
|
218
|
+
}),
|
|
219
|
+
[enableSolana, reown, solanaWalletProvider, solanaConnection]
|
|
220
|
+
);
|
|
221
|
+
const handleConnect = _react.useCallback.call(void 0, () => {
|
|
222
|
+
reown.openConnect();
|
|
223
|
+
}, [reown.openConnect]);
|
|
224
|
+
const handleDisconnect = _react.useCallback.call(void 0, () => {
|
|
225
|
+
reown.disconnect();
|
|
226
|
+
}, [reown.disconnect]);
|
|
227
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
228
|
+
_chunkQYYGX36Tcjs.DepositModalInner,
|
|
229
|
+
{
|
|
230
|
+
...props,
|
|
231
|
+
reownWallet: reownWithSolana,
|
|
232
|
+
onConnect: handleConnect,
|
|
233
|
+
onDisconnect: handleDisconnect
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
function DepositModalReown(props) {
|
|
238
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
239
|
+
ReownWalletProvider,
|
|
240
|
+
{
|
|
241
|
+
projectId: props.reownAppId,
|
|
242
|
+
theme: props.theme,
|
|
243
|
+
enableSolana: props.enableSolana,
|
|
244
|
+
rpcUrls: props.rpcUrls,
|
|
245
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DepositModalWithReown, { ...props })
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
}
|
|
193
249
|
|
|
194
250
|
|
|
195
|
-
|
|
196
|
-
exports.ReownWalletProvider = ReownWalletProvider; exports.useReownWallet = useReownWallet;
|
|
251
|
+
exports.DepositModalReown = DepositModalReown;
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DepositModalInner
|
|
3
|
+
} from "./chunk-YVI7Q7P7.mjs";
|
|
4
|
+
import "./chunk-YNRJ643P.mjs";
|
|
5
|
+
import "./chunk-GQXT6UL7.mjs";
|
|
1
6
|
import {
|
|
2
7
|
isUnsupportedChainSwitchError,
|
|
3
8
|
rpcUrlFor
|
|
4
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VXYJ432Q.mjs";
|
|
5
10
|
import {
|
|
6
11
|
SUPPORTED_CHAINS,
|
|
7
12
|
getChainName
|
|
8
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-G5JWMTDR.mjs";
|
|
14
|
+
import "./chunk-OMREKQB2.mjs";
|
|
15
|
+
|
|
16
|
+
// src/DepositModalReown.tsx
|
|
17
|
+
import { useCallback, useMemo } from "react";
|
|
9
18
|
|
|
10
19
|
// src/core/reown.tsx
|
|
11
20
|
import { useState } from "react";
|
|
@@ -190,7 +199,53 @@ function useReownWallet() {
|
|
|
190
199
|
};
|
|
191
200
|
}
|
|
192
201
|
|
|
202
|
+
// src/DepositModalReown.tsx
|
|
203
|
+
import { useAppKitProvider } from "@reown/appkit/react";
|
|
204
|
+
import { useAppKitConnection } from "@reown/appkit-adapter-solana/react";
|
|
205
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
206
|
+
function DepositModalWithReown(props) {
|
|
207
|
+
const reown = useReownWallet();
|
|
208
|
+
const enableSolana = props.enableSolana ?? true;
|
|
209
|
+
const { walletProvider: solanaWalletProvider } = useAppKitProvider(
|
|
210
|
+
enableSolana ? "solana" : "eip155"
|
|
211
|
+
);
|
|
212
|
+
const { connection: solanaConnection } = useAppKitConnection();
|
|
213
|
+
const reownWithSolana = useMemo(
|
|
214
|
+
() => ({
|
|
215
|
+
...reown,
|
|
216
|
+
solanaProvider: enableSolana && reown.isSolana ? solanaWalletProvider : void 0,
|
|
217
|
+
solanaConnection: enableSolana && reown.isSolana ? solanaConnection : void 0
|
|
218
|
+
}),
|
|
219
|
+
[enableSolana, reown, solanaWalletProvider, solanaConnection]
|
|
220
|
+
);
|
|
221
|
+
const handleConnect = useCallback(() => {
|
|
222
|
+
reown.openConnect();
|
|
223
|
+
}, [reown.openConnect]);
|
|
224
|
+
const handleDisconnect = useCallback(() => {
|
|
225
|
+
reown.disconnect();
|
|
226
|
+
}, [reown.disconnect]);
|
|
227
|
+
return /* @__PURE__ */ jsx2(
|
|
228
|
+
DepositModalInner,
|
|
229
|
+
{
|
|
230
|
+
...props,
|
|
231
|
+
reownWallet: reownWithSolana,
|
|
232
|
+
onConnect: handleConnect,
|
|
233
|
+
onDisconnect: handleDisconnect
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
function DepositModalReown(props) {
|
|
238
|
+
return /* @__PURE__ */ jsx2(
|
|
239
|
+
ReownWalletProvider,
|
|
240
|
+
{
|
|
241
|
+
projectId: props.reownAppId,
|
|
242
|
+
theme: props.theme,
|
|
243
|
+
enableSolana: props.enableSolana,
|
|
244
|
+
rpcUrls: props.rpcUrls,
|
|
245
|
+
children: /* @__PURE__ */ jsx2(DepositModalWithReown, { ...props })
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
}
|
|
193
249
|
export {
|
|
194
|
-
|
|
195
|
-
useReownWallet
|
|
250
|
+
DepositModalReown
|
|
196
251
|
};
|