@ramp-kit/react 0.1.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Armando Cruz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # @ramp-kit/react
2
+
3
+ Drop-in React UI for LATAM fiat on/off-ramps on Stellar. Embeds a complete
4
+ onramp flow — live quote with countdown, PIX/SPEI deposit instructions, order
5
+ tracking to settlement — on top of any
6
+ [@ramp-kit/core](https://www.npmjs.com/package/@ramp-kit/core) provider
7
+ (Etherfuse, Manteca, or the built-in mock).
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @ramp-kit/core @ramp-kit/react
13
+ ```
14
+
15
+ React ≥ 18 is a peer dependency.
16
+
17
+ ## `<RampWidget />`
18
+
19
+ ```tsx
20
+ import { EtherfuseProvider } from "@ramp-kit/core";
21
+ import { RampWidget } from "@ramp-kit/react";
22
+
23
+ const provider = new EtherfuseProvider({ apiKey, environment: "sandbox" });
24
+
25
+ <RampWidget
26
+ provider={provider}
27
+ customerId={orgId}
28
+ fiatCurrency="BRL"
29
+ network="stellar"
30
+ walletAddress={userWallet}
31
+ assets={await provider.listAssets("stellar", { currency: "brl" })}
32
+ onOrderCreated={(id) => console.log("order", id)}
33
+ onSettled={(id) => console.log("funds delivered", id)}
34
+ />;
35
+ ```
36
+
37
+ The widget walks the user through a 3-step flow:
38
+
39
+ 1. **Amount** — amount + asset selection, live quote with expiry countdown
40
+ that re-quotes automatically when the provider's price expires.
41
+ 2. **Deposit** — rail-aware instructions (PIX charge vs. SPEI CLABE) with a
42
+ live status indicator polled until terminal state.
43
+ 3. **Done** — conversion summary and on-chain transaction hash.
44
+
45
+ ### Props
46
+
47
+ | Prop | Type | Description |
48
+ | --- | --- | --- |
49
+ | `provider` | `RampProvider` | Any @ramp-kit/core provider instance |
50
+ | `customerId` | `string` | Provider-side customer id (org UUID for Etherfuse, userAnyId for Manteca) |
51
+ | `fiatCurrency` | `"BRL" \| "MXN" \| …` | Fiat leg of the ramp |
52
+ | `network` | `Network` | Settlement network (default `"stellar"`) |
53
+ | `walletAddress` | `string?` | Destination wallet for onramps |
54
+ | `assets` | `RampAsset[]` | Assets to offer (from `provider.listAssets()`) |
55
+ | `onOrderCreated` | `(orderId) => void` | Fired when the order is accepted |
56
+ | `onSettled` | `(orderId) => void` | Fired when funds are delivered |
57
+
58
+ Styling: neutral inline styles plus `rk-` class names (`rk-widget`,
59
+ `rk-quote`, `rk-deposit`, `rk-done`) so you can theme it from your own CSS.
60
+
61
+ ## Hooks (build your own UI)
62
+
63
+ ```tsx
64
+ import { useQuote, useOrder } from "@ramp-kit/react";
65
+
66
+ // Live quote that refreshes itself when it expires
67
+ const { quote, loading, error, secondsLeft, refresh } = useQuote(provider, {
68
+ direction: "onramp",
69
+ fiatCurrency: "BRL",
70
+ assetIdentifier: usdc.identifier,
71
+ network: "stellar",
72
+ sourceAmount: "100",
73
+ customerId,
74
+ });
75
+
76
+ // Order polling that stops at settled/failed/cancelled
77
+ const { order, polling } = useOrder(provider, orderId);
78
+ ```
79
+
80
+ ## Instant development with the mock provider
81
+
82
+ ```tsx
83
+ import { MockProvider } from "@ramp-kit/core";
84
+
85
+ // Realistic lifecycle without credentials; auto-funds orders after 4s
86
+ const provider = new MockProvider({ autoFundMs: 4000 });
87
+ ```
88
+
89
+ Two demo apps (a full sandbox demo on Stellar Testnet and a second minimal
90
+ integration) live in the
91
+ [latam-ramp-kit repository](https://github.com/armandocodecr/latam-ramp-kit).
92
+
93
+ ## AI tooling
94
+
95
+ Building this integration with an AI coding agent? Install the kit's agent
96
+ skill (`npx skills add https://github.com/armandocodecr/latam-ramp-kit/tree/main/skills/ramp-kit`)
97
+ and the [@ramp-kit/mcp](https://www.npmjs.com/package/@ramp-kit/mcp) MCP
98
+ server — the agent gets integration knowledge, verified troubleshooting,
99
+ and live tools to quote and test orders against the sandbox.
100
+
101
+ MIT © [Armando Cruz](https://github.com/armandocodecr)
@@ -0,0 +1,23 @@
1
+ import type { FiatCurrency, Network, RampAsset, RampProvider } from "@ramp-kit/core";
2
+ export interface RampWidgetProps {
3
+ provider: RampProvider;
4
+ /** Provider-side customer id (org UUID for Etherfuse, userAnyId for Manteca). */
5
+ customerId: string;
6
+ fiatCurrency: FiatCurrency;
7
+ network?: Network;
8
+ /** Destination wallet address for onramps. */
9
+ walletAddress?: string;
10
+ /** Assets to offer. Fetch with provider.listAssets() and pass down. */
11
+ assets: RampAsset[];
12
+ onOrderCreated?: (orderId: string) => void;
13
+ onSettled?: (orderId: string) => void;
14
+ }
15
+ /**
16
+ * Embeddable onramp flow: amount + asset → live quote → order →
17
+ * deposit instructions → status tracking until settled.
18
+ *
19
+ * Neutral inline styles + `rk-` class names so it drops into any app
20
+ * and can be themed via CSS.
21
+ */
22
+ export declare function RampWidget({ provider, customerId, fiatCurrency, network, walletAddress, assets, onOrderCreated, onSettled, }: RampWidgetProps): import("react").JSX.Element;
23
+ //# sourceMappingURL=RampWidget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RampWidget.d.ts","sourceRoot":"","sources":["../src/RampWidget.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,OAAO,EAEP,SAAS,EACT,YAAY,EACb,MAAM,gBAAgB,CAAC;AAGxB,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,YAAY,CAAC;IACvB,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8CAA8C;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uEAAuE;IACvE,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAoBD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,OAAmB,EACnB,aAAa,EACb,MAAM,EACN,cAAc,EACd,SAAS,GACV,EAAE,eAAe,+BAkOjB"}
@@ -0,0 +1,241 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useState } from "react";
3
+ import { useQuote, useOrder } from "./hooks.js";
4
+ const STEPS = [
5
+ { key: "amount", label: "Amount" },
6
+ { key: "deposit", label: "Deposit" },
7
+ { key: "done", label: "Done" },
8
+ ];
9
+ const STATUS_LABEL = {
10
+ created: "Order created",
11
+ awaiting_deposit: "Waiting for your deposit",
12
+ awaiting_signature: "Waiting for your signature",
13
+ processing: "Exchanging & settling on-chain",
14
+ settled: "Funds delivered",
15
+ failed: "Order failed",
16
+ cancelled: "Order cancelled",
17
+ };
18
+ /**
19
+ * Embeddable onramp flow: amount + asset → live quote → order →
20
+ * deposit instructions → status tracking until settled.
21
+ *
22
+ * Neutral inline styles + `rk-` class names so it drops into any app
23
+ * and can be themed via CSS.
24
+ */
25
+ export function RampWidget({ provider, customerId, fiatCurrency, network = "stellar", walletAddress, assets, onOrderCreated, onSettled, }) {
26
+ const [amount, setAmount] = useState("");
27
+ const [assetId, setAssetId] = useState(assets[0]?.identifier ?? "");
28
+ const [orderId, setOrderId] = useState(null);
29
+ const [step, setStep] = useState("amount");
30
+ const [submitting, setSubmitting] = useState(false);
31
+ const [submitError, setSubmitError] = useState(null);
32
+ // Keep selection valid when the asset list changes (e.g. provider swap).
33
+ useEffect(() => {
34
+ if (!assets.some((a) => a.identifier === assetId)) {
35
+ setAssetId(assets[0]?.identifier ?? "");
36
+ }
37
+ // eslint-disable-next-line react-hooks/exhaustive-deps
38
+ }, [assets]);
39
+ const request = useMemo(() => {
40
+ if (!amount || Number(amount) <= 0 || !assetId)
41
+ return null;
42
+ return {
43
+ direction: "onramp",
44
+ fiatCurrency,
45
+ assetIdentifier: assetId,
46
+ network,
47
+ sourceAmount: amount,
48
+ customerId,
49
+ walletAddress,
50
+ };
51
+ }, [amount, assetId, fiatCurrency, network, customerId, walletAddress]);
52
+ const { quote, loading, error, secondsLeft } = useQuote(step === "amount" ? provider : null, request);
53
+ const { order } = useOrder(provider, orderId);
54
+ useEffect(() => {
55
+ if (order?.status === "settled") {
56
+ setStep("done");
57
+ onSettled?.(order.id);
58
+ }
59
+ // eslint-disable-next-line react-hooks/exhaustive-deps
60
+ }, [order?.status, order?.id]);
61
+ const confirm = async () => {
62
+ if (!quote)
63
+ return;
64
+ setSubmitting(true);
65
+ setSubmitError(null);
66
+ try {
67
+ const created = await provider.createOrder(quote);
68
+ setOrderId(created.id);
69
+ onOrderCreated?.(created.id);
70
+ setStep("deposit");
71
+ }
72
+ catch (err) {
73
+ const message = err.message;
74
+ // Sandbox accounts can be compliant yet lack rail provisioning.
75
+ setSubmitError(/proxy account/i.test(message)
76
+ ? `${message} — this bank account isn't provisioned for this rail; try another account`
77
+ : message);
78
+ }
79
+ finally {
80
+ setSubmitting(false);
81
+ }
82
+ };
83
+ const selectedAsset = assets.find((a) => a.identifier === assetId);
84
+ const stepIndex = STEPS.findIndex((s) => s.key === step);
85
+ const deposit = order?.depositInstructions;
86
+ const isTerminalFailure = order?.status === "failed" || order?.status === "cancelled";
87
+ return (_jsxs("div", { className: "rk-widget", style: styles.widget, children: [_jsx("div", { className: "rk-steps", style: styles.steps, children: STEPS.map((s, i) => (_jsxs("div", { style: styles.stepItem, children: [_jsx("div", { style: {
88
+ ...styles.stepDot,
89
+ ...(i < stepIndex ? styles.stepDotPast : {}),
90
+ ...(i === stepIndex ? styles.stepDotActive : {}),
91
+ }, children: i < stepIndex ? "✓" : i + 1 }), _jsx("span", { style: {
92
+ ...styles.stepLabel,
93
+ ...(i === stepIndex ? styles.stepLabelActive : {}),
94
+ }, children: s.label }), i < STEPS.length - 1 && _jsx("div", { style: styles.stepLine })] }, s.key))) }), step === "amount" && (_jsxs(_Fragment, { children: [_jsxs("label", { style: styles.label, children: ["You pay (", fiatCurrency, ")", _jsx("input", { style: styles.input, type: "number", min: "0", value: amount, placeholder: "100", onChange: (e) => setAmount(e.target.value) })] }), _jsxs("label", { style: styles.label, children: ["You receive", _jsx("select", { style: styles.input, value: assetId, onChange: (e) => setAssetId(e.target.value), children: assets.map((a) => (_jsxs("option", { value: a.identifier, children: [a.symbol, " \u00B7 ", a.network] }, a.identifier))) })] }), loading && _jsx("p", { style: styles.muted, children: "Fetching live quote\u2026" }), error && _jsx("p", { style: styles.error, children: error.message }), quote && !loading && (_jsxs("div", { className: "rk-quote", style: styles.quoteBox, children: [_jsxs("div", { style: styles.quoteRow, children: [_jsxs("span", { style: styles.big, children: ["\u2248 ", trim(quote.targetAmount), " ", selectedAsset?.symbol] }), _jsxs("span", { style: styles.pill, children: [secondsLeft, "s"] })] }), _jsx("div", { style: styles.countdownTrack, children: _jsx("div", { style: {
95
+ ...styles.countdownBar,
96
+ width: `${Math.min(100, (secondsLeft / 120) * 100)}%`,
97
+ } }) }), _jsxs("p", { style: styles.muted, children: ["Rate ", trim(quote.rate), quote.fees ? ` · fee ${quote.fees} ${fiatCurrency}` : ""] }), _jsx("button", { style: styles.button, disabled: submitting, onClick: confirm, children: submitting ? "Creating order…" : "Continue" }), submitError && _jsx("p", { style: styles.error, children: submitError })] }))] })), step === "deposit" && (_jsxs("div", { className: "rk-deposit", style: styles.depositBox, children: [deposit ? (_jsxs(_Fragment, { children: [_jsxs("div", { style: styles.quoteRow, children: [_jsx("span", { style: styles.railBadge, children: deposit.rail }), _jsxs("span", { style: styles.big, children: [deposit.amount, " ", deposit.currency] })] }), _jsx("p", { style: styles.muted, children: deposit.rail === "PIX"
98
+ ? "Pay this PIX charge to fund your order:"
99
+ : "Send the exact amount to this account:" }), _jsxs("p", { style: styles.mono, children: [deposit.address, deposit.alias ? ` · ${deposit.alias}` : ""] })] })) : (_jsx("p", { style: styles.muted, children: "Loading deposit instructions\u2026" })), _jsxs("div", { style: styles.statusRow, children: [_jsx("span", { style: {
100
+ ...styles.statusDot,
101
+ background: isTerminalFailure
102
+ ? "#c0392b"
103
+ : order?.status === "processing"
104
+ ? "#e67e22"
105
+ : "#3498db",
106
+ } }), _jsx("span", { style: styles.statusText, children: STATUS_LABEL[order?.status ?? "created"] })] }), isTerminalFailure && (_jsx("p", { style: styles.error, children: order?.failureReason ?? "Order failed" }))] })), step === "done" && (_jsxs("div", { className: "rk-done", style: styles.doneBox, children: [_jsx("div", { style: styles.doneIcon, children: "\u2713" }), _jsx("p", { style: styles.big, children: "Funds delivered" }), order?.quote && (_jsxs("p", { style: styles.muted, children: [order.quote.request.sourceAmount, " ", order.quote.request.fiatCurrency, " \u2192", " ", trim(order.quote.targetAmount), " ", selectedAsset?.symbol, " on", " ", network] })), order?.txHash && (_jsxs("p", { style: styles.mono, children: ["tx ", order.txHash.slice(0, 10), "\u2026", order.txHash.slice(-8)] }))] }))] }));
107
+ }
108
+ function trim(value) {
109
+ const n = Number(value);
110
+ return Number.isFinite(n) ? n.toLocaleString("en-US", { maximumFractionDigits: 4 }) : value;
111
+ }
112
+ const styles = {
113
+ widget: {
114
+ maxWidth: 400,
115
+ padding: 20,
116
+ borderRadius: 14,
117
+ border: "1px solid #e4e4e7",
118
+ background: "#fff",
119
+ fontFamily: "system-ui, sans-serif",
120
+ display: "flex",
121
+ flexDirection: "column",
122
+ gap: 14,
123
+ },
124
+ steps: { display: "flex", alignItems: "center", gap: 6 },
125
+ stepItem: { display: "flex", alignItems: "center", gap: 6, flex: "1 1 0" },
126
+ stepDot: {
127
+ width: 22,
128
+ height: 22,
129
+ borderRadius: "50%",
130
+ display: "flex",
131
+ alignItems: "center",
132
+ justifyContent: "center",
133
+ fontSize: 11,
134
+ fontWeight: 600,
135
+ background: "#f4f4f5",
136
+ color: "#71717a",
137
+ flexShrink: 0,
138
+ },
139
+ stepDotActive: { background: "#18181b", color: "#fff" },
140
+ stepDotPast: { background: "#dcfce7", color: "#16a34a" },
141
+ stepLabel: { fontSize: 12, color: "#a1a1aa" },
142
+ stepLabelActive: { color: "#18181b", fontWeight: 600 },
143
+ stepLine: { flex: 1, height: 1, background: "#e4e4e7" },
144
+ label: { display: "flex", flexDirection: "column", gap: 4, fontSize: 13, color: "#3f3f46" },
145
+ input: {
146
+ padding: 10,
147
+ borderRadius: 10,
148
+ border: "1px solid #d4d4d8",
149
+ fontSize: 16,
150
+ background: "#fff",
151
+ },
152
+ quoteBox: {
153
+ padding: 14,
154
+ borderRadius: 10,
155
+ background: "#fafafa",
156
+ border: "1px solid #f0f0f1",
157
+ display: "flex",
158
+ flexDirection: "column",
159
+ gap: 8,
160
+ },
161
+ quoteRow: {
162
+ display: "flex",
163
+ alignItems: "center",
164
+ justifyContent: "space-between",
165
+ gap: 8,
166
+ },
167
+ countdownTrack: {
168
+ height: 3,
169
+ borderRadius: 2,
170
+ background: "#e4e4e7",
171
+ overflow: "hidden",
172
+ },
173
+ countdownBar: {
174
+ height: "100%",
175
+ background: "#18181b",
176
+ transition: "width 1s linear",
177
+ },
178
+ pill: {
179
+ fontSize: 12,
180
+ padding: "2px 8px",
181
+ borderRadius: 999,
182
+ background: "#f4f4f5",
183
+ color: "#52525b",
184
+ fontVariantNumeric: "tabular-nums",
185
+ },
186
+ railBadge: {
187
+ fontSize: 12,
188
+ fontWeight: 700,
189
+ letterSpacing: 0.5,
190
+ padding: "3px 10px",
191
+ borderRadius: 999,
192
+ background: "#ecfdf5",
193
+ color: "#047857",
194
+ border: "1px solid #a7f3d0",
195
+ },
196
+ button: {
197
+ padding: "11px 16px",
198
+ borderRadius: 10,
199
+ border: "none",
200
+ background: "#18181b",
201
+ color: "#fff",
202
+ fontSize: 15,
203
+ fontWeight: 600,
204
+ cursor: "pointer",
205
+ },
206
+ depositBox: { display: "flex", flexDirection: "column", gap: 10 },
207
+ statusRow: { display: "flex", alignItems: "center", gap: 8, marginTop: 4 },
208
+ statusDot: { width: 8, height: 8, borderRadius: "50%", flexShrink: 0 },
209
+ statusText: { fontSize: 13, color: "#3f3f46" },
210
+ doneBox: {
211
+ display: "flex",
212
+ flexDirection: "column",
213
+ alignItems: "center",
214
+ gap: 6,
215
+ padding: "10px 0",
216
+ textAlign: "center",
217
+ },
218
+ doneIcon: {
219
+ width: 44,
220
+ height: 44,
221
+ borderRadius: "50%",
222
+ background: "#dcfce7",
223
+ color: "#16a34a",
224
+ display: "flex",
225
+ alignItems: "center",
226
+ justifyContent: "center",
227
+ fontSize: 22,
228
+ fontWeight: 700,
229
+ },
230
+ big: { fontSize: 19, fontWeight: 600, margin: 0, color: "#18181b" },
231
+ muted: { fontSize: 13, color: "#71717a", margin: 0 },
232
+ mono: {
233
+ fontFamily: "ui-monospace, monospace",
234
+ wordBreak: "break-all",
235
+ fontSize: 13,
236
+ color: "#3f3f46",
237
+ margin: 0,
238
+ },
239
+ error: { color: "#c0392b", fontSize: 13, margin: 0 },
240
+ };
241
+ //# sourceMappingURL=RampWidget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RampWidget.js","sourceRoot":"","sources":["../src/RampWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQrD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAkBhD,MAAM,KAAK,GAAwC;IACjD,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IAClC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IACpC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;CAC/B,CAAC;AAEF,MAAM,YAAY,GAA2B;IAC3C,OAAO,EAAE,eAAe;IACxB,gBAAgB,EAAE,0BAA0B;IAC5C,kBAAkB,EAAE,4BAA4B;IAChD,UAAU,EAAE,gCAAgC;IAC5C,OAAO,EAAE,iBAAiB;IAC1B,MAAM,EAAE,cAAc;IACtB,SAAS,EAAE,iBAAiB;CAC7B,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,OAAO,GAAG,SAAS,EACnB,aAAa,EACb,MAAM,EACN,cAAc,EACd,SAAS,GACO;IAChB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACzC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC;IACpE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAC5D,MAAM,C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B,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,GAAG;KAChB;IACD,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE;IACnE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE;IACpD,IAAI,EAAE;QACJ,UAAU,EAAE,yBAAyB;QACrC,SAAS,EAAE,WAAW;QACtB,QAAQ,EAAE,EAAE;QACZ,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,CAAC;KACV;IACD,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE;CACrD,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { QuoteRequest, RampOrder, RampProvider, RampQuote } from "@ramp-kit/core";
2
+ export interface UseQuoteResult {
3
+ quote: RampQuote | null;
4
+ loading: boolean;
5
+ error: Error | null;
6
+ /** Seconds until the current quote expires (0 when expired/none). */
7
+ secondsLeft: number;
8
+ refresh: () => void;
9
+ }
10
+ /**
11
+ * Fetch a quote and keep it fresh: re-quotes automatically when the
12
+ * provider-reported expiry passes (Etherfuse: 2 min, Manteca price locks:
13
+ * asset-dependent).
14
+ */
15
+ export declare function useQuote(provider: RampProvider | null, request: QuoteRequest | null, options?: {
16
+ autoRefresh?: boolean;
17
+ }): UseQuoteResult;
18
+ export interface UseOrderResult {
19
+ order: RampOrder | null;
20
+ error: Error | null;
21
+ /** True while the order is in a non-terminal state and being polled. */
22
+ polling: boolean;
23
+ }
24
+ /** Poll an order until it reaches a terminal state. */
25
+ export declare function useOrder(provider: RampProvider | null, orderId: string | null, options?: {
26
+ intervalMs?: number;
27
+ }): UseOrderResult;
28
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,SAAS,EACV,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,qEAAqE;IACrE,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,YAAY,GAAG,IAAI,EAC7B,OAAO,EAAE,YAAY,GAAG,IAAI,EAC5B,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACtC,cAAc,CAoDhB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,wEAAwE;IACxE,OAAO,EAAE,OAAO,CAAC;CAClB;AAID,uDAAuD;AACvD,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,YAAY,GAAG,IAAI,EAC7B,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GACpC,cAAc,CAsChB"}
package/dist/hooks.js ADDED
@@ -0,0 +1,99 @@
1
+ import { useCallback, useEffect, useRef, useState } from "react";
2
+ /**
3
+ * Fetch a quote and keep it fresh: re-quotes automatically when the
4
+ * provider-reported expiry passes (Etherfuse: 2 min, Manteca price locks:
5
+ * asset-dependent).
6
+ */
7
+ export function useQuote(provider, request, options = {}) {
8
+ const autoRefresh = options.autoRefresh ?? true;
9
+ const [quote, setQuote] = useState(null);
10
+ const [loading, setLoading] = useState(false);
11
+ const [error, setError] = useState(null);
12
+ const [secondsLeft, setSecondsLeft] = useState(0);
13
+ const [nonce, setNonce] = useState(0);
14
+ const refresh = useCallback(() => setNonce((n) => n + 1), []);
15
+ // Serialize to avoid re-fetch loops on caller-side object literals.
16
+ const requestKey = request ? JSON.stringify(request) : null;
17
+ useEffect(() => {
18
+ if (!provider || !requestKey)
19
+ return;
20
+ const parsed = JSON.parse(requestKey);
21
+ let cancelled = false;
22
+ setLoading(true);
23
+ setError(null);
24
+ provider
25
+ .getQuote(parsed)
26
+ .then((q) => {
27
+ if (!cancelled)
28
+ setQuote(q);
29
+ })
30
+ .catch((err) => {
31
+ if (!cancelled)
32
+ setError(err);
33
+ })
34
+ .finally(() => {
35
+ if (!cancelled)
36
+ setLoading(false);
37
+ });
38
+ return () => {
39
+ cancelled = true;
40
+ };
41
+ }, [provider, requestKey, nonce]);
42
+ // Countdown + auto-refresh on expiry.
43
+ useEffect(() => {
44
+ if (!quote)
45
+ return;
46
+ const tick = () => {
47
+ const left = Math.max(0, Math.floor((quote.expiresAt.getTime() - Date.now()) / 1000));
48
+ setSecondsLeft(left);
49
+ if (left === 0 && autoRefresh)
50
+ refresh();
51
+ };
52
+ tick();
53
+ const timer = setInterval(tick, 1000);
54
+ return () => clearInterval(timer);
55
+ }, [quote, autoRefresh, refresh]);
56
+ return { quote, loading, error, secondsLeft, refresh };
57
+ }
58
+ const TERMINAL_STATES = new Set(["settled", "failed", "cancelled"]);
59
+ /** Poll an order until it reaches a terminal state. */
60
+ export function useOrder(provider, orderId, options = {}) {
61
+ const intervalMs = options.intervalMs ?? 4000;
62
+ const [order, setOrder] = useState(null);
63
+ const [error, setError] = useState(null);
64
+ const [polling, setPolling] = useState(false);
65
+ const stopped = useRef(false);
66
+ useEffect(() => {
67
+ if (!provider || !orderId)
68
+ return;
69
+ stopped.current = false;
70
+ setPolling(true);
71
+ const poll = async () => {
72
+ try {
73
+ const o = await provider.getOrder(orderId);
74
+ if (stopped.current)
75
+ return;
76
+ setOrder(o);
77
+ if (TERMINAL_STATES.has(o.status)) {
78
+ setPolling(false);
79
+ return;
80
+ }
81
+ }
82
+ catch (err) {
83
+ if (!stopped.current)
84
+ setError(err);
85
+ }
86
+ if (!stopped.current) {
87
+ timer = setTimeout(poll, intervalMs);
88
+ }
89
+ };
90
+ let timer = setTimeout(poll, 0);
91
+ return () => {
92
+ stopped.current = true;
93
+ clearTimeout(timer);
94
+ setPolling(false);
95
+ };
96
+ }, [provider, orderId, intervalMs]);
97
+ return { order, error, polling };
98
+ }
99
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAiBjE;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CACtB,QAA6B,EAC7B,OAA4B,EAC5B,UAAqC,EAAE;IAEvC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,IAAI,CAAC;IAChD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAmB,IAAI,CAAC,CAAC;IAC3D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IACvD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAClD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEtC,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAE9D,oEAAoE;IACpE,MAAM,UAAU,GAAG,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C,OAAO,CAAC,CAAC;gBAC3C,IAAI,OAAO,CAAC,OAAO;oBAAE,OAAO;gBAC5B,QAAQ,CAAC,CAAC,CAAC,CAAC;gBACZ,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;oBAClC,UAAU,CAAC,KAAK,CAAC,CAAC;oBAClB,OAAO;gBACT,CAAC;YACH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,OAAO,CAAC,OAAO;oBAAE,QAAQ,CAAC,GAAY,CAAC,CAAC;YAC/C,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;gBACrB,KAAK,GAAG,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YACvC,CAAC;QACH,CAAC,CAAC;QAEF,IAAI,KAAK,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAChC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;YACvB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;IAEpC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { useQuote, useOrder } from "./hooks.js";
2
+ export type { UseQuoteResult, UseOrderResult } from "./hooks.js";
3
+ export { RampWidget } from "./RampWidget.js";
4
+ export type { RampWidgetProps } from "./RampWidget.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { useQuote, useOrder } from "./hooks.js";
2
+ export { RampWidget } from "./RampWidget.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@ramp-kit/react",
3
+ "version": "0.1.2",
4
+ "description": "React onramp widget and hooks for LATAM ramps on Stellar: 3-step embeddable flow with live quote countdown, PIX/SPEI deposit instructions and order tracking to settlement, over any @ramp-kit/core provider",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "LICENSE",
17
+ "README.md"
18
+ ],
19
+ "dependencies": {
20
+ "@ramp-kit/core": "0.1.2"
21
+ },
22
+ "peerDependencies": {
23
+ "react": ">=18"
24
+ },
25
+ "devDependencies": {
26
+ "@types/react": "^18.3.0",
27
+ "react": "^18.3.0",
28
+ "typescript": "^5.6.0"
29
+ },
30
+ "license": "MIT",
31
+ "author": "Armando Cruz (https://github.com/armandocodecr)",
32
+ "homepage": "https://github.com/armandocodecr/latam-ramp-kit#readme",
33
+ "bugs": {
34
+ "url": "https://github.com/armandocodecr/latam-ramp-kit/issues"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "sideEffects": false,
40
+ "keywords": [
41
+ "stellar",
42
+ "onramp",
43
+ "react",
44
+ "widget",
45
+ "latam",
46
+ "pix",
47
+ "ramp",
48
+ "usdc"
49
+ ],
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/armandocodecr/latam-ramp-kit.git",
53
+ "directory": "packages/react"
54
+ },
55
+ "scripts": {
56
+ "build": "tsc -p tsconfig.json",
57
+ "typecheck": "tsc -p tsconfig.json --noEmit"
58
+ }
59
+ }