@pollar/react 0.10.1-rc.1 → 0.10.1-rc.3
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/dist/index.d.mts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +130 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -308,7 +308,14 @@ interface KycModalTemplateProps {
|
|
|
308
308
|
}
|
|
309
309
|
declare function KycModalTemplate({ theme, accentColor, step, providers, selectedProvider, session, kycStatus, isLoading, onSelectProvider, onDoneVerifying, onClose, }: KycModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
310
310
|
|
|
311
|
-
type RampStep = 'input' | 'loading_quote' | 'select_route' | 'status' | 'error';
|
|
311
|
+
type RampStep = 'input' | 'loading_quote' | 'select_route' | 'contact' | 'status' | 'error';
|
|
312
|
+
/** A field a provider declares (via the quote) that the client must collect. */
|
|
313
|
+
interface RampFieldSpec {
|
|
314
|
+
key: string;
|
|
315
|
+
label: string;
|
|
316
|
+
type: 'text' | 'email' | 'tel';
|
|
317
|
+
bankType?: 'CLABE' | 'PIX' | 'PSE' | 'ACH';
|
|
318
|
+
}
|
|
312
319
|
interface RampWidgetTemplateProps {
|
|
313
320
|
theme: string;
|
|
314
321
|
accentColor: string;
|
|
@@ -317,6 +324,8 @@ interface RampWidgetTemplateProps {
|
|
|
317
324
|
amount: string;
|
|
318
325
|
currency: string;
|
|
319
326
|
country: string;
|
|
327
|
+
requiredFields: RampFieldSpec[];
|
|
328
|
+
fieldValues: Record<string, string>;
|
|
320
329
|
countries: RampCountry[];
|
|
321
330
|
countriesLoading: boolean;
|
|
322
331
|
refreshing: boolean;
|
|
@@ -326,22 +335,24 @@ interface RampWidgetTemplateProps {
|
|
|
326
335
|
txStatus: RampTxStatus | null;
|
|
327
336
|
kycUrl: string | null;
|
|
328
337
|
stellarTxHash: string | null;
|
|
338
|
+
depositInstructions: Record<string, unknown> | null;
|
|
329
339
|
canComplete: boolean;
|
|
330
340
|
completing: boolean;
|
|
331
341
|
errorMsg: string | null;
|
|
332
342
|
onDirectionChange: (d: RampDirection) => void;
|
|
333
343
|
onAmountChange: (v: string) => void;
|
|
334
|
-
|
|
344
|
+
onFieldChange: (key: string, value: string) => void;
|
|
335
345
|
onCountryChange: (v: string) => void;
|
|
336
346
|
onFindRoute: () => void;
|
|
337
347
|
onSelectQuote: (q: RampQuote) => void;
|
|
348
|
+
onContactContinue: () => void;
|
|
338
349
|
onOpenKyc: () => void;
|
|
339
350
|
onCompleteWithdraw: () => void;
|
|
340
351
|
onRetry: () => void;
|
|
341
352
|
onRefresh: () => void;
|
|
342
353
|
onClose: () => void;
|
|
343
354
|
}
|
|
344
|
-
declare function RampWidgetTemplate({ theme, accentColor, step, direction, amount, currency, country, countries, countriesLoading, refreshing, quotes, isLoading, provider, txStatus, kycUrl, stellarTxHash, canComplete, completing, errorMsg, onDirectionChange, onAmountChange,
|
|
355
|
+
declare function RampWidgetTemplate({ theme, accentColor, step, direction, amount, currency, country, requiredFields, fieldValues, countries, countriesLoading, refreshing, quotes, isLoading, provider, txStatus, kycUrl, stellarTxHash, depositInstructions, canComplete, completing, errorMsg, onDirectionChange, onAmountChange, onFieldChange, onCountryChange, onFindRoute, onSelectQuote, onContactContinue, onOpenKyc, onCompleteWithdraw, onRetry, onRefresh, onClose, }: RampWidgetTemplateProps): react_jsx_runtime.JSX.Element;
|
|
345
356
|
|
|
346
357
|
interface TransactionModalTemplateProps {
|
|
347
358
|
theme: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -308,7 +308,14 @@ interface KycModalTemplateProps {
|
|
|
308
308
|
}
|
|
309
309
|
declare function KycModalTemplate({ theme, accentColor, step, providers, selectedProvider, session, kycStatus, isLoading, onSelectProvider, onDoneVerifying, onClose, }: KycModalTemplateProps): react_jsx_runtime.JSX.Element;
|
|
310
310
|
|
|
311
|
-
type RampStep = 'input' | 'loading_quote' | 'select_route' | 'status' | 'error';
|
|
311
|
+
type RampStep = 'input' | 'loading_quote' | 'select_route' | 'contact' | 'status' | 'error';
|
|
312
|
+
/** A field a provider declares (via the quote) that the client must collect. */
|
|
313
|
+
interface RampFieldSpec {
|
|
314
|
+
key: string;
|
|
315
|
+
label: string;
|
|
316
|
+
type: 'text' | 'email' | 'tel';
|
|
317
|
+
bankType?: 'CLABE' | 'PIX' | 'PSE' | 'ACH';
|
|
318
|
+
}
|
|
312
319
|
interface RampWidgetTemplateProps {
|
|
313
320
|
theme: string;
|
|
314
321
|
accentColor: string;
|
|
@@ -317,6 +324,8 @@ interface RampWidgetTemplateProps {
|
|
|
317
324
|
amount: string;
|
|
318
325
|
currency: string;
|
|
319
326
|
country: string;
|
|
327
|
+
requiredFields: RampFieldSpec[];
|
|
328
|
+
fieldValues: Record<string, string>;
|
|
320
329
|
countries: RampCountry[];
|
|
321
330
|
countriesLoading: boolean;
|
|
322
331
|
refreshing: boolean;
|
|
@@ -326,22 +335,24 @@ interface RampWidgetTemplateProps {
|
|
|
326
335
|
txStatus: RampTxStatus | null;
|
|
327
336
|
kycUrl: string | null;
|
|
328
337
|
stellarTxHash: string | null;
|
|
338
|
+
depositInstructions: Record<string, unknown> | null;
|
|
329
339
|
canComplete: boolean;
|
|
330
340
|
completing: boolean;
|
|
331
341
|
errorMsg: string | null;
|
|
332
342
|
onDirectionChange: (d: RampDirection) => void;
|
|
333
343
|
onAmountChange: (v: string) => void;
|
|
334
|
-
|
|
344
|
+
onFieldChange: (key: string, value: string) => void;
|
|
335
345
|
onCountryChange: (v: string) => void;
|
|
336
346
|
onFindRoute: () => void;
|
|
337
347
|
onSelectQuote: (q: RampQuote) => void;
|
|
348
|
+
onContactContinue: () => void;
|
|
338
349
|
onOpenKyc: () => void;
|
|
339
350
|
onCompleteWithdraw: () => void;
|
|
340
351
|
onRetry: () => void;
|
|
341
352
|
onRefresh: () => void;
|
|
342
353
|
onClose: () => void;
|
|
343
354
|
}
|
|
344
|
-
declare function RampWidgetTemplate({ theme, accentColor, step, direction, amount, currency, country, countries, countriesLoading, refreshing, quotes, isLoading, provider, txStatus, kycUrl, stellarTxHash, canComplete, completing, errorMsg, onDirectionChange, onAmountChange,
|
|
355
|
+
declare function RampWidgetTemplate({ theme, accentColor, step, direction, amount, currency, country, requiredFields, fieldValues, countries, countriesLoading, refreshing, quotes, isLoading, provider, txStatus, kycUrl, stellarTxHash, depositInstructions, canComplete, completing, errorMsg, onDirectionChange, onAmountChange, onFieldChange, onCountryChange, onFindRoute, onSelectQuote, onContactContinue, onOpenKyc, onCompleteWithdraw, onRetry, onRefresh, onClose, }: RampWidgetTemplateProps): react_jsx_runtime.JSX.Element;
|
|
345
356
|
|
|
346
357
|
interface TransactionModalTemplateProps {
|
|
347
358
|
theme: string;
|
package/dist/index.js
CHANGED
|
@@ -1035,7 +1035,7 @@ var PollarModalFooter = () => {
|
|
|
1035
1035
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-footer-name", children: "Pollar" }),
|
|
1036
1036
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-footer-version", children: [
|
|
1037
1037
|
"v",
|
|
1038
|
-
"0.10.1-rc.
|
|
1038
|
+
"0.10.1-rc.3"
|
|
1039
1039
|
] })
|
|
1040
1040
|
] })
|
|
1041
1041
|
] });
|
|
@@ -2471,6 +2471,33 @@ var STATUS_LABEL = {
|
|
|
2471
2471
|
completed: "Completed",
|
|
2472
2472
|
failed: "Failed"
|
|
2473
2473
|
};
|
|
2474
|
+
var INSTRUCTION_LABELS = {
|
|
2475
|
+
br_code: "Pix code",
|
|
2476
|
+
account_holder_name: "Account holder",
|
|
2477
|
+
bank_name: "Bank",
|
|
2478
|
+
bank_address: "Bank address",
|
|
2479
|
+
bank_account_number: "Account number",
|
|
2480
|
+
bank_routing_number: "Routing number",
|
|
2481
|
+
iban: "IBAN",
|
|
2482
|
+
bic: "BIC",
|
|
2483
|
+
clabe: "CLABE",
|
|
2484
|
+
amount: "Amount",
|
|
2485
|
+
currency: "Currency",
|
|
2486
|
+
payment_rails: "Rails"
|
|
2487
|
+
};
|
|
2488
|
+
function flattenInstructions(instr) {
|
|
2489
|
+
const out = [];
|
|
2490
|
+
for (const [k, v] of Object.entries(instr)) {
|
|
2491
|
+
let value = "";
|
|
2492
|
+
if (typeof v === "string" || typeof v === "number") value = String(v);
|
|
2493
|
+
else if (Array.isArray(v))
|
|
2494
|
+
value = v.filter((x) => typeof x === "string" || typeof x === "number").join(", ");
|
|
2495
|
+
else continue;
|
|
2496
|
+
if (!value) continue;
|
|
2497
|
+
out.push({ key: k, label: INSTRUCTION_LABELS[k] ?? k, value });
|
|
2498
|
+
}
|
|
2499
|
+
return out;
|
|
2500
|
+
}
|
|
2474
2501
|
function RampWidgetTemplate({
|
|
2475
2502
|
theme,
|
|
2476
2503
|
accentColor,
|
|
@@ -2479,6 +2506,8 @@ function RampWidgetTemplate({
|
|
|
2479
2506
|
amount,
|
|
2480
2507
|
currency,
|
|
2481
2508
|
country,
|
|
2509
|
+
requiredFields,
|
|
2510
|
+
fieldValues,
|
|
2482
2511
|
countries,
|
|
2483
2512
|
countriesLoading,
|
|
2484
2513
|
refreshing,
|
|
@@ -2488,15 +2517,17 @@ function RampWidgetTemplate({
|
|
|
2488
2517
|
txStatus,
|
|
2489
2518
|
kycUrl,
|
|
2490
2519
|
stellarTxHash,
|
|
2520
|
+
depositInstructions,
|
|
2491
2521
|
canComplete,
|
|
2492
2522
|
completing,
|
|
2493
2523
|
errorMsg,
|
|
2494
2524
|
onDirectionChange,
|
|
2495
2525
|
onAmountChange,
|
|
2496
|
-
|
|
2526
|
+
onFieldChange,
|
|
2497
2527
|
onCountryChange,
|
|
2498
2528
|
onFindRoute,
|
|
2499
2529
|
onSelectQuote,
|
|
2530
|
+
onContactContinue,
|
|
2500
2531
|
onOpenKyc,
|
|
2501
2532
|
onCompleteWithdraw,
|
|
2502
2533
|
onRetry,
|
|
@@ -2528,6 +2559,7 @@ function RampWidgetTemplate({
|
|
|
2528
2559
|
input: direction === "onramp" ? "Buy crypto" : "Sell crypto",
|
|
2529
2560
|
loading_quote: "Finding best route",
|
|
2530
2561
|
select_route: "Select provider",
|
|
2562
|
+
contact: "Your details",
|
|
2531
2563
|
status: direction === "onramp" ? "Complete your deposit" : "Complete your withdrawal",
|
|
2532
2564
|
error: "Something went wrong"
|
|
2533
2565
|
};
|
|
@@ -2535,6 +2567,7 @@ function RampWidgetTemplate({
|
|
|
2535
2567
|
input: direction === "onramp" ? "Enter the amount you want to deposit" : "Enter the amount you want to withdraw",
|
|
2536
2568
|
loading_quote: "Comparing providers in real time\u2026",
|
|
2537
2569
|
select_route: "All prices include fees",
|
|
2570
|
+
contact: `${provider || "This provider"} needs your name and email to verify you`,
|
|
2538
2571
|
status: `Finish the flow at ${provider || "the provider"} to continue`,
|
|
2539
2572
|
error: "Please try again"
|
|
2540
2573
|
};
|
|
@@ -2592,36 +2625,6 @@ function RampWidgetTemplate({
|
|
|
2592
2625
|
}
|
|
2593
2626
|
)
|
|
2594
2627
|
] }),
|
|
2595
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-input-row", children: [
|
|
2596
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-field", children: [
|
|
2597
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-ramp-label", children: "Amount" }),
|
|
2598
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2599
|
-
"input",
|
|
2600
|
-
{
|
|
2601
|
-
type: "number",
|
|
2602
|
-
className: "pollar-ramp-input",
|
|
2603
|
-
placeholder: "0.00",
|
|
2604
|
-
value: amount,
|
|
2605
|
-
min: "0",
|
|
2606
|
-
onChange: (e) => onAmountChange(e.target.value)
|
|
2607
|
-
}
|
|
2608
|
-
)
|
|
2609
|
-
] }),
|
|
2610
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-field", style: { maxWidth: 90 }, children: [
|
|
2611
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-ramp-label", children: "Currency" }),
|
|
2612
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2613
|
-
"input",
|
|
2614
|
-
{
|
|
2615
|
-
type: "text",
|
|
2616
|
-
className: "pollar-ramp-input",
|
|
2617
|
-
placeholder: "MXN",
|
|
2618
|
-
value: currency,
|
|
2619
|
-
maxLength: 5,
|
|
2620
|
-
onChange: (e) => onCurrencyChange(e.target.value.toUpperCase())
|
|
2621
|
-
}
|
|
2622
|
-
)
|
|
2623
|
-
] })
|
|
2624
|
-
] }),
|
|
2625
2628
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-field", children: [
|
|
2626
2629
|
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-ramp-label", children: "Country" }),
|
|
2627
2630
|
countriesLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-input pollar-ramp-input-loading", children: "Loading countries\u2026" }) : countries.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "No ramp providers available on this network yet." }) : /* @__PURE__ */ jsxRuntime.jsx("select", { className: "pollar-ramp-input", value: country, onChange: (e) => onCountryChange(e.target.value), children: countries.map((c) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: c.code, children: [
|
|
@@ -2631,6 +2634,23 @@ function RampWidgetTemplate({
|
|
|
2631
2634
|
c.currency ? ` \u2014 ${c.currency}` : ""
|
|
2632
2635
|
] }, c.code)) })
|
|
2633
2636
|
] }),
|
|
2637
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-field", children: [
|
|
2638
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { className: "pollar-ramp-label", children: [
|
|
2639
|
+
"Amount",
|
|
2640
|
+
currency ? ` (${currency})` : ""
|
|
2641
|
+
] }),
|
|
2642
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2643
|
+
"input",
|
|
2644
|
+
{
|
|
2645
|
+
type: "number",
|
|
2646
|
+
className: "pollar-ramp-input",
|
|
2647
|
+
placeholder: "0.00",
|
|
2648
|
+
value: amount,
|
|
2649
|
+
min: "0",
|
|
2650
|
+
onChange: (e) => onAmountChange(e.target.value)
|
|
2651
|
+
}
|
|
2652
|
+
)
|
|
2653
|
+
] }),
|
|
2634
2654
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-actions", children: [
|
|
2635
2655
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onClose, children: "Cancel" }),
|
|
2636
2656
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2653,6 +2673,34 @@ function RampWidgetTemplate({
|
|
|
2653
2673
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-route-list", children: quotes.map((q, i) => /* @__PURE__ */ jsxRuntime.jsx(RouteDisplay, { quote: q, onSelect: onSelectQuote }, i)) }),
|
|
2654
2674
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onClose, children: "Cancel" })
|
|
2655
2675
|
] }),
|
|
2676
|
+
step === "contact" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2677
|
+
requiredFields.map((f) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-field", children: [
|
|
2678
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-ramp-label", children: f.label }),
|
|
2679
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2680
|
+
"input",
|
|
2681
|
+
{
|
|
2682
|
+
type: f.type,
|
|
2683
|
+
className: "pollar-ramp-input",
|
|
2684
|
+
value: fieldValues[f.key] ?? "",
|
|
2685
|
+
autoComplete: f.type === "email" ? "email" : "off",
|
|
2686
|
+
onChange: (e) => onFieldChange(f.key, e.target.value)
|
|
2687
|
+
}
|
|
2688
|
+
)
|
|
2689
|
+
] }, f.key)),
|
|
2690
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-actions", children: [
|
|
2691
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onRetry, children: "Back" }),
|
|
2692
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2693
|
+
"button",
|
|
2694
|
+
{
|
|
2695
|
+
type: "button",
|
|
2696
|
+
className: "pollar-btn-primary",
|
|
2697
|
+
disabled: requiredFields.some((f) => !(fieldValues[f.key] ?? "").trim()) || isLoading,
|
|
2698
|
+
onClick: onContactContinue,
|
|
2699
|
+
children: isLoading ? "Starting\u2026" : "Continue"
|
|
2700
|
+
}
|
|
2701
|
+
)
|
|
2702
|
+
] })
|
|
2703
|
+
] }),
|
|
2656
2704
|
step === "status" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment", children: [
|
|
2657
2705
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-field", children: [
|
|
2658
2706
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-payment-label", children: "Provider" }),
|
|
@@ -2670,6 +2718,10 @@ function RampWidgetTemplate({
|
|
|
2670
2718
|
stellarTxHash.slice(-8)
|
|
2671
2719
|
] }) })
|
|
2672
2720
|
] }),
|
|
2721
|
+
depositInstructions && txStatus !== "completed" && flattenInstructions(depositInstructions).map(({ key, label, value }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-field", children: [
|
|
2722
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-payment-label", children: label }),
|
|
2723
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-payment-value", children: /* @__PURE__ */ jsxRuntime.jsx("code", { style: { wordBreak: "break-all" }, children: value }) })
|
|
2724
|
+
] }, key)),
|
|
2673
2725
|
kycUrl && txStatus !== "completed" && /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-btn-primary", onClick: onOpenKyc, children: [
|
|
2674
2726
|
"Continue at ",
|
|
2675
2727
|
provider
|
|
@@ -2688,6 +2740,9 @@ function RampWidgetTemplate({
|
|
|
2688
2740
|
] });
|
|
2689
2741
|
}
|
|
2690
2742
|
var TERMINAL = ["completed", "failed"];
|
|
2743
|
+
function requiredFieldsOf(quote) {
|
|
2744
|
+
return quote.requiredFields ?? [];
|
|
2745
|
+
}
|
|
2691
2746
|
function RampWidget({ onClose }) {
|
|
2692
2747
|
const { getClient, signTx, wallet, styles } = usePollar();
|
|
2693
2748
|
const walletAddress = wallet?.address ?? "";
|
|
@@ -2698,16 +2753,20 @@ function RampWidget({ onClose }) {
|
|
|
2698
2753
|
const [amount, setAmount] = react.useState("");
|
|
2699
2754
|
const [currency, setCurrency] = react.useState("");
|
|
2700
2755
|
const [country, setCountry] = react.useState("");
|
|
2756
|
+
const [fieldValues, setFieldValues] = react.useState({});
|
|
2757
|
+
const setFieldValue = (key, value) => setFieldValues((v) => ({ ...v, [key]: value }));
|
|
2701
2758
|
const [countries, setCountries] = react.useState([]);
|
|
2702
2759
|
const [countriesLoading, setCountriesLoading] = react.useState(true);
|
|
2703
2760
|
const [refreshing, setRefreshing] = react.useState(false);
|
|
2704
2761
|
const [quotes, setQuotes] = react.useState([]);
|
|
2762
|
+
const [selectedQuote, setSelectedQuote] = react.useState(null);
|
|
2705
2763
|
const [isLoading, setIsLoading] = react.useState(false);
|
|
2706
2764
|
const [txId, setTxId] = react.useState(null);
|
|
2707
2765
|
const [provider, setProvider] = react.useState("");
|
|
2708
2766
|
const [kycUrl, setKycUrl] = react.useState(null);
|
|
2709
2767
|
const [txStatus, setTxStatus] = react.useState(null);
|
|
2710
2768
|
const [stellarTxHash, setStellarTxHash] = react.useState(null);
|
|
2769
|
+
const [depositInstructions, setDepositInstructions] = react.useState(null);
|
|
2711
2770
|
const [completing, setCompleting] = react.useState(false);
|
|
2712
2771
|
const [errorMsg, setErrorMsg] = react.useState(null);
|
|
2713
2772
|
const directionRef = react.useRef(direction);
|
|
@@ -2723,6 +2782,8 @@ function RampWidget({ onClose }) {
|
|
|
2723
2782
|
setTxStatus(tx.status);
|
|
2724
2783
|
if (tx.stellarTxHash) setStellarTxHash(tx.stellarTxHash);
|
|
2725
2784
|
if (tx.kycUrl) setKycUrl(tx.kycUrl);
|
|
2785
|
+
const di = tx.depositInstructions;
|
|
2786
|
+
if (di) setDepositInstructions(di);
|
|
2726
2787
|
if (TERMINAL.includes(tx.status)) clearInterval(id);
|
|
2727
2788
|
} catch {
|
|
2728
2789
|
}
|
|
@@ -2770,6 +2831,8 @@ function RampWidget({ onClose }) {
|
|
|
2770
2831
|
setTxStatus(tx.status);
|
|
2771
2832
|
if (tx.stellarTxHash) setStellarTxHash(tx.stellarTxHash);
|
|
2772
2833
|
if (tx.kycUrl) setKycUrl(tx.kycUrl);
|
|
2834
|
+
const di = tx.depositInstructions;
|
|
2835
|
+
if (di) setDepositInstructions(di);
|
|
2773
2836
|
}
|
|
2774
2837
|
} catch {
|
|
2775
2838
|
} finally {
|
|
@@ -2779,11 +2842,13 @@ function RampWidget({ onClose }) {
|
|
|
2779
2842
|
function resetToInput() {
|
|
2780
2843
|
setStep("input");
|
|
2781
2844
|
setQuotes([]);
|
|
2845
|
+
setSelectedQuote(null);
|
|
2782
2846
|
setTxId(null);
|
|
2783
2847
|
setProvider("");
|
|
2784
2848
|
setKycUrl(null);
|
|
2785
2849
|
setTxStatus(null);
|
|
2786
2850
|
setStellarTxHash(null);
|
|
2851
|
+
setDepositInstructions(null);
|
|
2787
2852
|
setErrorMsg(null);
|
|
2788
2853
|
}
|
|
2789
2854
|
async function resumeWithSignature(id, ps) {
|
|
@@ -2809,6 +2874,7 @@ function RampWidget({ onClose }) {
|
|
|
2809
2874
|
setKycUrl(result.kycUrl ?? null);
|
|
2810
2875
|
setTxStatus(result.status);
|
|
2811
2876
|
setStellarTxHash(result.stellarTxHash ?? null);
|
|
2877
|
+
setDepositInstructions(result.depositInstructions ?? null);
|
|
2812
2878
|
setStep("status");
|
|
2813
2879
|
}
|
|
2814
2880
|
async function handleFindRoute() {
|
|
@@ -2832,12 +2898,33 @@ function RampWidget({ onClose }) {
|
|
|
2832
2898
|
setIsLoading(false);
|
|
2833
2899
|
}
|
|
2834
2900
|
}
|
|
2835
|
-
|
|
2901
|
+
function handleSelectQuote(quote) {
|
|
2902
|
+
setSelectedQuote(quote);
|
|
2903
|
+
setErrorMsg(null);
|
|
2904
|
+
const fields = requiredFieldsOf(quote);
|
|
2905
|
+
const missing = fields.some((f) => !(fieldValues[f.key] ?? "").trim());
|
|
2906
|
+
if (fields.length > 0 && missing) {
|
|
2907
|
+
setStep("contact");
|
|
2908
|
+
return;
|
|
2909
|
+
}
|
|
2910
|
+
void startRamp(quote);
|
|
2911
|
+
}
|
|
2912
|
+
function handleContactContinue() {
|
|
2913
|
+
if (selectedQuote) void startRamp(selectedQuote);
|
|
2914
|
+
}
|
|
2915
|
+
async function startRamp(quote) {
|
|
2836
2916
|
setIsLoading(true);
|
|
2837
2917
|
setErrorMsg(null);
|
|
2838
2918
|
try {
|
|
2839
2919
|
const base = { quoteId: quote.quoteId, amount: Number(amount), currency, country };
|
|
2840
|
-
|
|
2920
|
+
if (walletAddress) base.walletAddress = walletAddress;
|
|
2921
|
+
for (const f of requiredFieldsOf(quote)) {
|
|
2922
|
+
const val = (fieldValues[f.key] ?? "").trim();
|
|
2923
|
+
if (!val) continue;
|
|
2924
|
+
if (f.bankType) base.bankDetails = { type: f.bankType, value: val };
|
|
2925
|
+
else base[f.key] = val;
|
|
2926
|
+
}
|
|
2927
|
+
const result = direction === "onramp" ? await client.createOnRamp(base) : await client.createOffRamp(base);
|
|
2841
2928
|
await applyResult(result);
|
|
2842
2929
|
} catch (e) {
|
|
2843
2930
|
setErrorMsg(e instanceof Error ? e.message : "Failed to start the ramp.");
|
|
@@ -2881,6 +2968,8 @@ function RampWidget({ onClose }) {
|
|
|
2881
2968
|
amount,
|
|
2882
2969
|
currency,
|
|
2883
2970
|
country,
|
|
2971
|
+
requiredFields: selectedQuote ? requiredFieldsOf(selectedQuote) : [],
|
|
2972
|
+
fieldValues,
|
|
2884
2973
|
countries,
|
|
2885
2974
|
countriesLoading,
|
|
2886
2975
|
refreshing,
|
|
@@ -2890,15 +2979,17 @@ function RampWidget({ onClose }) {
|
|
|
2890
2979
|
txStatus,
|
|
2891
2980
|
kycUrl,
|
|
2892
2981
|
stellarTxHash,
|
|
2982
|
+
depositInstructions,
|
|
2893
2983
|
canComplete,
|
|
2894
2984
|
completing,
|
|
2895
2985
|
errorMsg,
|
|
2896
2986
|
onDirectionChange: setDirection,
|
|
2897
2987
|
onAmountChange: setAmount,
|
|
2898
|
-
|
|
2988
|
+
onFieldChange: setFieldValue,
|
|
2899
2989
|
onCountryChange: handleCountryChange,
|
|
2900
2990
|
onFindRoute: handleFindRoute,
|
|
2901
2991
|
onSelectQuote: handleSelectQuote,
|
|
2992
|
+
onContactContinue: handleContactContinue,
|
|
2902
2993
|
onOpenKyc: handleOpenKyc,
|
|
2903
2994
|
onCompleteWithdraw: handleCompleteWithdraw,
|
|
2904
2995
|
onRetry: resetToInput,
|
|
@@ -4551,6 +4642,10 @@ function TxHistoryModalTemplate({
|
|
|
4551
4642
|
/* @__PURE__ */ jsxRuntime.jsx(StatusBadge, { status: record.status }),
|
|
4552
4643
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-hist-item-meta", children: [
|
|
4553
4644
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: record.operation }),
|
|
4645
|
+
typeof record.details?.sponsored === "boolean" && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
4646
|
+
"\xB7 ",
|
|
4647
|
+
record.details.sponsored ? "Sponsored" : "Self-paid"
|
|
4648
|
+
] }),
|
|
4554
4649
|
record.feeXlm && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
4555
4650
|
"\xB7 ",
|
|
4556
4651
|
record.feeXlm,
|