@pollar/react 0.12.1-rc.23 → 0.12.1-rc.25
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.css +88 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +375 -92
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +376 -93
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1311,7 +1311,7 @@ var PollarModalFooter = ({ language: languageProp }) => {
|
|
|
1311
1311
|
/* @__PURE__ */ jsxRuntime.jsx("img", { src: LOGO_POLLAR_WORDMARK_ON_DARK, alt: "Pollar", className: "pollar-footer-logo pollar-logo-on-dark" }),
|
|
1312
1312
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-footer-version", children: [
|
|
1313
1313
|
"v",
|
|
1314
|
-
"0.12.1-rc.
|
|
1314
|
+
"0.12.1-rc.25"
|
|
1315
1315
|
] })
|
|
1316
1316
|
] });
|
|
1317
1317
|
};
|
|
@@ -5630,6 +5630,21 @@ var RAMP_COPY = {
|
|
|
5630
5630
|
startAnother: "Start another operation",
|
|
5631
5631
|
newQuote: "Get a new quote",
|
|
5632
5632
|
keepsGoing: "This one keeps going; you can resume it later.",
|
|
5633
|
+
screens: {
|
|
5634
|
+
pay: (amount, currency) => `Pay ${amount} ${currency}`,
|
|
5635
|
+
send: (amount, code) => `Send ${amount} ${code}`,
|
|
5636
|
+
delivering: (code) => `Your ${code} is on its way`,
|
|
5637
|
+
payingOut: (currency) => `Your ${currency} is on its way to your account`,
|
|
5638
|
+
done: "Done",
|
|
5639
|
+
toCurrent: "Go to the current step",
|
|
5640
|
+
updatesItself: "This screen updates on its own.",
|
|
5641
|
+
preparing: "Preparing your payment\u2026",
|
|
5642
|
+
received: (amount) => `+${amount}`,
|
|
5643
|
+
arrived: (chain) => `It reached your wallet on ${chain}.`,
|
|
5644
|
+
paidOut: "It was sent to your account.",
|
|
5645
|
+
finish: "Done",
|
|
5646
|
+
details: "Details"
|
|
5647
|
+
},
|
|
5633
5648
|
somethingWrong: "Something went wrong.",
|
|
5634
5649
|
routeSteps: (count) => count === 1 ? "1 step" : `${count} steps`,
|
|
5635
5650
|
feesIncluded: "fees included",
|
|
@@ -5761,6 +5776,21 @@ var RAMP_COPY = {
|
|
|
5761
5776
|
startAnother: "Iniciar otra operaci\xF3n",
|
|
5762
5777
|
newQuote: "Pedir nueva cotizaci\xF3n",
|
|
5763
5778
|
keepsGoing: "Esta sigue en curso; puedes retomarla m\xE1s tarde.",
|
|
5779
|
+
screens: {
|
|
5780
|
+
pay: (amount, currency) => `Paga ${amount} ${currency}`,
|
|
5781
|
+
send: (amount, code) => `Env\xEDa ${amount} ${code}`,
|
|
5782
|
+
delivering: (code) => `Tu ${code} est\xE1 en camino`,
|
|
5783
|
+
payingOut: (currency) => `Tus ${currency} van en camino a tu cuenta`,
|
|
5784
|
+
done: "Hecho",
|
|
5785
|
+
toCurrent: "Ir al paso actual",
|
|
5786
|
+
updatesItself: "Esta pantalla se actualiza sola.",
|
|
5787
|
+
preparing: "Preparando tu pago\u2026",
|
|
5788
|
+
received: (amount) => `+${amount}`,
|
|
5789
|
+
arrived: (chain) => `Lleg\xF3 a tu wallet en ${chain}.`,
|
|
5790
|
+
paidOut: "Se envi\xF3 a tu cuenta.",
|
|
5791
|
+
finish: "Listo",
|
|
5792
|
+
details: "Detalles"
|
|
5793
|
+
},
|
|
5764
5794
|
somethingWrong: "Algo sali\xF3 mal.",
|
|
5765
5795
|
routeSteps: (count) => count === 1 ? "1 paso" : `${count} pasos`,
|
|
5766
5796
|
feesIncluded: "comisiones incluidas",
|
|
@@ -5892,6 +5922,21 @@ var RAMP_COPY = {
|
|
|
5892
5922
|
startAnother: "Iniciar outra opera\xE7\xE3o",
|
|
5893
5923
|
newQuote: "Pedir nova cota\xE7\xE3o",
|
|
5894
5924
|
keepsGoing: "Esta continua em andamento; voc\xEA pode retom\xE1-la depois.",
|
|
5925
|
+
screens: {
|
|
5926
|
+
pay: (amount, currency) => `Pague ${amount} ${currency}`,
|
|
5927
|
+
send: (amount, code) => `Envie ${amount} ${code}`,
|
|
5928
|
+
delivering: (code) => `Seu ${code} est\xE1 a caminho`,
|
|
5929
|
+
payingOut: (currency) => `Seus ${currency} est\xE3o a caminho da sua conta`,
|
|
5930
|
+
done: "Conclu\xEDdo",
|
|
5931
|
+
toCurrent: "Ir para a etapa atual",
|
|
5932
|
+
updatesItself: "Esta tela se atualiza sozinha.",
|
|
5933
|
+
preparing: "Preparando o seu pagamento\u2026",
|
|
5934
|
+
received: (amount) => `+${amount}`,
|
|
5935
|
+
arrived: (chain) => `Chegou \xE0 sua carteira na ${chain}.`,
|
|
5936
|
+
paidOut: "Foi enviado para a sua conta.",
|
|
5937
|
+
finish: "Pronto",
|
|
5938
|
+
details: "Detalhes"
|
|
5939
|
+
},
|
|
5895
5940
|
somethingWrong: "Algo deu errado.",
|
|
5896
5941
|
routeSteps: (count) => count === 1 ? "1 etapa" : `${count} etapas`,
|
|
5897
5942
|
feesIncluded: "taxas inclu\xEDdas",
|
|
@@ -6040,6 +6085,93 @@ function routeKey(quote) {
|
|
|
6040
6085
|
const node = (n) => n.kind === "asset" ? `${n.code}:${n.chain}` : `${n.currency}:${n.rail}`;
|
|
6041
6086
|
return quote.legs.map((leg) => `${leg.kind}:${node(leg.from)}>${node(leg.to)}`).join("|");
|
|
6042
6087
|
}
|
|
6088
|
+
var amountText = (value, language) => {
|
|
6089
|
+
const n = Number(value);
|
|
6090
|
+
return Number.isFinite(n) ? n.toLocaleString(language, { maximumFractionDigits: 7 }) : value;
|
|
6091
|
+
};
|
|
6092
|
+
function rampOrderScreens(order, language) {
|
|
6093
|
+
const copy = RAMP_COPY[language].screens;
|
|
6094
|
+
const parts = [];
|
|
6095
|
+
const waitsOn = (leg) => order.pendingAction?.legIndex === leg.index && order.pendingAction.kind !== "NONE";
|
|
6096
|
+
for (const leg of order.legs) {
|
|
6097
|
+
const legStatus = core.rampLegStatus(leg);
|
|
6098
|
+
const legDone = legStatus === "done";
|
|
6099
|
+
if (leg.steps?.length) {
|
|
6100
|
+
let running = [];
|
|
6101
|
+
const flush = () => {
|
|
6102
|
+
if (!running.length) return;
|
|
6103
|
+
parts.push({
|
|
6104
|
+
key: `${leg.index}:${running[0].kind}`,
|
|
6105
|
+
kind: "wait",
|
|
6106
|
+
leg,
|
|
6107
|
+
steps: running,
|
|
6108
|
+
title: core.rampLegTitle(leg, language),
|
|
6109
|
+
done: legDone || running.every((s) => s.status === "done")
|
|
6110
|
+
});
|
|
6111
|
+
running = [];
|
|
6112
|
+
};
|
|
6113
|
+
for (const step of leg.steps) {
|
|
6114
|
+
if (!step.signs) {
|
|
6115
|
+
running.push(step);
|
|
6116
|
+
continue;
|
|
6117
|
+
}
|
|
6118
|
+
flush();
|
|
6119
|
+
parts.push({
|
|
6120
|
+
key: `${leg.index}:${step.kind}`,
|
|
6121
|
+
kind: "action",
|
|
6122
|
+
leg,
|
|
6123
|
+
steps: [step],
|
|
6124
|
+
title: core.rampStepTitle(step, leg, language),
|
|
6125
|
+
done: legDone || step.status === "done"
|
|
6126
|
+
});
|
|
6127
|
+
}
|
|
6128
|
+
flush();
|
|
6129
|
+
continue;
|
|
6130
|
+
}
|
|
6131
|
+
if (leg.kind === "PROVIDER_ONRAMP" || leg.kind === "PROVIDER_OFFRAMP") {
|
|
6132
|
+
const onramp = leg.kind === "PROVIDER_ONRAMP";
|
|
6133
|
+
const unitIn = leg.from.kind === "fiat" ? leg.from.currency : leg.from.code;
|
|
6134
|
+
const unitOut = leg.to.kind === "fiat" ? leg.to.currency : leg.to.code;
|
|
6135
|
+
const payment = leg.paymentStatus;
|
|
6136
|
+
const paid = payment === void 0 ? legStatus === "active" && !waitsOn(leg) : payment === "received";
|
|
6137
|
+
const amount = amountText(leg.amountInPlanned, language);
|
|
6138
|
+
parts.push({
|
|
6139
|
+
key: `${leg.index}:pay`,
|
|
6140
|
+
kind: "action",
|
|
6141
|
+
leg,
|
|
6142
|
+
steps: [],
|
|
6143
|
+
title: onramp ? copy.pay(amount, unitIn) : copy.send(amount, unitIn),
|
|
6144
|
+
done: legDone || paid,
|
|
6145
|
+
preparing: payment === "not_requested" && !waitsOn(leg)
|
|
6146
|
+
});
|
|
6147
|
+
parts.push({
|
|
6148
|
+
key: `${leg.index}:deliver`,
|
|
6149
|
+
kind: "wait",
|
|
6150
|
+
leg,
|
|
6151
|
+
steps: [],
|
|
6152
|
+
title: onramp ? copy.delivering(unitOut) : copy.payingOut(unitOut),
|
|
6153
|
+
done: legDone
|
|
6154
|
+
});
|
|
6155
|
+
continue;
|
|
6156
|
+
}
|
|
6157
|
+
parts.push({
|
|
6158
|
+
key: `${leg.index}`,
|
|
6159
|
+
kind: leg.signingMode ? "action" : "wait",
|
|
6160
|
+
leg,
|
|
6161
|
+
steps: [],
|
|
6162
|
+
title: core.rampLegTitle(leg, language),
|
|
6163
|
+
done: legDone
|
|
6164
|
+
});
|
|
6165
|
+
}
|
|
6166
|
+
const stopped = ["failed", "refunded"].includes(order.state);
|
|
6167
|
+
let currentFound = false;
|
|
6168
|
+
return parts.map(({ done, ...screen }) => {
|
|
6169
|
+
if (done) return { ...screen, status: "done" };
|
|
6170
|
+
if (currentFound) return { ...screen, status: "upcoming" };
|
|
6171
|
+
currentFound = true;
|
|
6172
|
+
return { ...screen, status: stopped || core.rampLegStatus(screen.leg) === "failed" ? "failed" : "current" };
|
|
6173
|
+
});
|
|
6174
|
+
}
|
|
6043
6175
|
function scannableImageSrc(image) {
|
|
6044
6176
|
return image.encoding === "base64" ? `data:${image.mediaType};base64,${image.data}` : `data:${image.mediaType};charset=utf-8,${encodeURIComponent(image.data)}`;
|
|
6045
6177
|
}
|
|
@@ -6179,6 +6311,8 @@ function RampWidgetTemplate({
|
|
|
6179
6311
|
const onramp = direction === "ONRAMP";
|
|
6180
6312
|
const sendUnit = onramp ? fiat?.currency : asset?.code;
|
|
6181
6313
|
const [detailsOpen, setDetailsOpen] = react.useState(false);
|
|
6314
|
+
const [viewing, setViewing] = react.useState(null);
|
|
6315
|
+
react.useEffect(() => setViewing(null), [order?.id]);
|
|
6182
6316
|
const routeName = (quote) => quote.legs.map((leg) => core.rampLegTitle(leg, language)).join(" \xB7 ");
|
|
6183
6317
|
const rate = (() => {
|
|
6184
6318
|
if (!chosenQuote) return null;
|
|
@@ -6250,7 +6384,6 @@ function RampWidgetTemplate({
|
|
|
6250
6384
|
] : [];
|
|
6251
6385
|
const running = order?.legs.find((leg) => core.rampLegStatus(leg) === "active" && order.pendingAction?.legIndex !== leg.index);
|
|
6252
6386
|
const now = useNowEverySecond(step === "status" && !settled && !!running && running.etaSeconds !== null);
|
|
6253
|
-
const nextApproval = order && !settled ? core.rampNextApproval(order, language) : null;
|
|
6254
6387
|
const stopped = order ? core.rampOrderStopped(order) : false;
|
|
6255
6388
|
const receive = order ? core.rampOrderReceive(order) : null;
|
|
6256
6389
|
const waitsOnRecovery = order?.failure?.resolutionAction === "set_up_recovery";
|
|
@@ -6258,12 +6391,41 @@ function RampWidgetTemplate({
|
|
|
6258
6391
|
const payBy = view?.action?.kind === "FIAT_PAYMENT" && view.expiresAt ? Date.parse(view.expiresAt) : null;
|
|
6259
6392
|
useRenderAt(view?.canSign && view.expiresAt ? Date.parse(view.expiresAt) : null);
|
|
6260
6393
|
const stepsOpen = !!onStepSelect && step !== "status" && !isLoading && startingQuoteId === null && trustingAsset === null && walletBusy === null;
|
|
6394
|
+
const screens = order ? rampOrderScreens(order, language) : [];
|
|
6395
|
+
const completed = order?.state === "completed";
|
|
6396
|
+
const firstOpen = screens.findIndex((s) => s.status !== "done");
|
|
6397
|
+
const currentScreen = completed ? screens.length : firstOpen === -1 ? Math.max(0, screens.length - 1) : firstOpen;
|
|
6398
|
+
const shownScreen = viewing !== null && viewing < currentScreen ? viewing : currentScreen;
|
|
6399
|
+
const shown = screens[shownScreen];
|
|
6400
|
+
const askedInstead = order?.pendingAction?.kind === "KYC" || !!shown?.key.endsWith(":pay") && order?.pendingAction?.legIndex === shown.leg.index && !["FIAT_PAYMENT", "NONE"].includes(order.pendingAction.kind);
|
|
6401
|
+
const firstLeg = order?.legs[0];
|
|
6402
|
+
const orderSummary = firstLeg && receive ? `${amountText(firstLeg.amountInPlanned, language)} ${firstLeg.from.kind === "fiat" ? firstLeg.from.currency : firstLeg.from.code} \u2192 ${receive.estimated ? "~" : ""}${amountText(receive.amount, language)} ${receive.unit}` : null;
|
|
6403
|
+
const lastLeg = order?.legs[order.legs.length - 1];
|
|
6404
|
+
const arrivedText = lastLeg?.to.kind === "asset" ? copy.screens.arrived(CHAIN_NAME[lastLeg.to.chain] ?? lastLeg.to.chain) : copy.screens.paidOut;
|
|
6405
|
+
const finalNote = order?.legs.map((leg) => core.rampLegNote(leg, language)).find((note) => note !== null) ?? null;
|
|
6406
|
+
const screenRows = (screen) => screen.steps.length ? screen.steps.flatMap(
|
|
6407
|
+
(st) => st.hash ? [
|
|
6408
|
+
{
|
|
6409
|
+
label: core.rampStepTitle(st, screen.leg, language),
|
|
6410
|
+
value: shortHash(st.hash),
|
|
6411
|
+
href: explorerTxUrl2(stepChain(st.kind, screen.leg), st.hash, network),
|
|
6412
|
+
copyValue: st.hash
|
|
6413
|
+
}
|
|
6414
|
+
] : []
|
|
6415
|
+
) : screen.leg.onchainTxHash && !screen.key.endsWith(":pay") ? [
|
|
6416
|
+
{
|
|
6417
|
+
label: core.rampLegTitle(screen.leg, language),
|
|
6418
|
+
value: shortHash(screen.leg.onchainTxHash),
|
|
6419
|
+
href: explorerTxUrl2(legChain(screen.leg), screen.leg.onchainTxHash, network),
|
|
6420
|
+
copyValue: screen.leg.onchainTxHash
|
|
6421
|
+
}
|
|
6422
|
+
] : [];
|
|
6261
6423
|
const stepTitle = {
|
|
6262
6424
|
input: onramp ? copy.title.buy : copy.title.sell,
|
|
6263
6425
|
loading_quote: copy.title.finding,
|
|
6264
6426
|
select_route: copy.title.chooseRoute,
|
|
6265
6427
|
contact: copy.title.details,
|
|
6266
|
-
status:
|
|
6428
|
+
status: onramp ? copy.title.purchase : copy.title.sale,
|
|
6267
6429
|
error: copy.title.error
|
|
6268
6430
|
};
|
|
6269
6431
|
const stepSubtitle = {
|
|
@@ -6276,7 +6438,7 @@ function RampWidgetTemplate({
|
|
|
6276
6438
|
copy
|
|
6277
6439
|
)
|
|
6278
6440
|
),
|
|
6279
|
-
status:
|
|
6441
|
+
status: orderSummary ?? copy.subtitle.processing,
|
|
6280
6442
|
error: copy.subtitle.error
|
|
6281
6443
|
};
|
|
6282
6444
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-ramp-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
|
|
@@ -6291,6 +6453,16 @@ function RampWidgetTemplate({
|
|
|
6291
6453
|
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 3 5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
6292
6454
|
}
|
|
6293
6455
|
),
|
|
6456
|
+
step === "status" && shownScreen > 0 && shownScreen <= currentScreen && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6457
|
+
"button",
|
|
6458
|
+
{
|
|
6459
|
+
type: "button",
|
|
6460
|
+
className: "pollar-back-btn pollar-ramp-back",
|
|
6461
|
+
onClick: () => setViewing(shownScreen - 1),
|
|
6462
|
+
"aria-label": copy.back,
|
|
6463
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 3 5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
6464
|
+
}
|
|
6465
|
+
),
|
|
6294
6466
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-header-text", children: [
|
|
6295
6467
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: stepTitle[step] }),
|
|
6296
6468
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-subtitle", children: stepSubtitle[step] })
|
|
@@ -6347,6 +6519,15 @@ function RampWidgetTemplate({
|
|
|
6347
6519
|
}
|
|
6348
6520
|
) }, label)) })
|
|
6349
6521
|
] }),
|
|
6522
|
+
step === "status" && screens.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "pollar-ramp-screens-bar", "aria-label": copy.progress, children: [...screens.map((s) => s.key), "final"].map((key, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6523
|
+
"li",
|
|
6524
|
+
{
|
|
6525
|
+
"data-done": i < currentScreen || completed && i === screens.length || void 0,
|
|
6526
|
+
"data-shown": i === shownScreen || void 0,
|
|
6527
|
+
"data-failed": screens[i]?.status === "failed" || void 0
|
|
6528
|
+
},
|
|
6529
|
+
key
|
|
6530
|
+
)) }),
|
|
6350
6531
|
step === "input" && pendingOrders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "pollar-ramp-payment pollar-ramp-saved", "aria-label": copy.pendingAria, children: [
|
|
6351
6532
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: copy.pendingNote }),
|
|
6352
6533
|
pendingOrders.map((pending) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-saved-row", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6634,37 +6815,62 @@ function RampWidgetTemplate({
|
|
|
6634
6815
|
}
|
|
6635
6816
|
) })
|
|
6636
6817
|
] }),
|
|
6637
|
-
step === "status" && order && view && /* @__PURE__ */ jsxRuntime.
|
|
6638
|
-
/* @__PURE__ */ jsxRuntime.
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
/* @__PURE__ */ jsxRuntime.
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6818
|
+
step === "status" && order && view && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-payment", children: shownScreen === screens.length ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6819
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-final", children: [
|
|
6820
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-final-mark", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "28", height: "28", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6821
|
+
"path",
|
|
6822
|
+
{
|
|
6823
|
+
d: "M3 8.5 6.5 12 13 4.5",
|
|
6824
|
+
stroke: "currentColor",
|
|
6825
|
+
strokeWidth: "2",
|
|
6826
|
+
strokeLinecap: "round",
|
|
6827
|
+
strokeLinejoin: "round"
|
|
6828
|
+
}
|
|
6829
|
+
) }) }),
|
|
6830
|
+
receive && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-final-amount", children: copy.screens.received(`${amountText(receive.amount, language)} ${receive.unit}`) }),
|
|
6831
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: arrivedText }),
|
|
6832
|
+
finalNote && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: finalNote })
|
|
6833
|
+
] }),
|
|
6834
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: onClose, children: copy.screens.finish }),
|
|
6835
|
+
/* @__PURE__ */ jsxRuntime.jsx(TxReview, { data: { title: "", kind: "other", rows: orderRows }, language })
|
|
6836
|
+
] }) : shownScreen < currentScreen ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6837
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "pollar-ramp-screen-title", children: screens[shownScreen].title }),
|
|
6838
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-ramp-screen-state", children: [
|
|
6839
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6840
|
+
"path",
|
|
6841
|
+
{
|
|
6842
|
+
d: "M3 8.5 6.5 12 13 4.5",
|
|
6843
|
+
stroke: "currentColor",
|
|
6844
|
+
strokeWidth: "2",
|
|
6845
|
+
strokeLinecap: "round",
|
|
6846
|
+
strokeLinejoin: "round"
|
|
6847
|
+
}
|
|
6848
|
+
) }),
|
|
6849
|
+
copy.screens.done
|
|
6850
|
+
] }),
|
|
6851
|
+
screenRows(screens[shownScreen]).length > 0 && /* @__PURE__ */ jsxRuntime.jsx(TxReview, { data: { title: "", kind: "other", rows: screenRows(screens[shownScreen]) }, language }),
|
|
6852
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: () => setViewing(null), children: copy.screens.toCurrent })
|
|
6853
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6854
|
+
shown && /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "pollar-ramp-screen-title", "data-status": shown.status, children: askedInstead ? view.title : shown.title }),
|
|
6855
|
+
shown?.status === "failed" && shown.leg.failure && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-field-error", children: core.rampFailureReason(shown.leg.failure, language) }),
|
|
6856
|
+
shown?.preparing && !settled && !order.failure && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-wait", children: [
|
|
6857
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner", "aria-label": copy.inProgress }),
|
|
6858
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: copy.screens.preparing })
|
|
6667
6859
|
] }),
|
|
6860
|
+
shown?.kind === "wait" && !settled && !order.failure && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-wait", children: [
|
|
6861
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner", "aria-label": copy.inProgress }),
|
|
6862
|
+
core.rampLegTimeLeft(shown.leg, now) !== null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-leg-eta", children: copy.timeLeft(core.rampLegTimeLeft(shown.leg, now)) }),
|
|
6863
|
+
core.rampLegNote(shown.leg, language) && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: core.rampLegNote(shown.leg, language) }),
|
|
6864
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: copy.screens.updatesItself })
|
|
6865
|
+
] }),
|
|
6866
|
+
shown && shown.steps.length > 1 && !settled && /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "pollar-ramp-screen-steps", children: shown.steps.map((s) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "pollar-ramp-step", "data-status": s.status, children: [
|
|
6867
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-step-title", children: core.rampStepTitle(s, shown.leg, language) }),
|
|
6868
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-ramp-step-state", children: [
|
|
6869
|
+
s.status === "confirming" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-hidden": true }),
|
|
6870
|
+
core.rampStepStatusText(s, language)
|
|
6871
|
+
] })
|
|
6872
|
+
] }, s.kind)) }),
|
|
6873
|
+
confirmation && /* @__PURE__ */ jsxRuntime.jsx(InlineConfirm, { confirmation, language, network }),
|
|
6668
6874
|
order.failure && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-field", children: [
|
|
6669
6875
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-payment-label", children: copy.whatToDo }),
|
|
6670
6876
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: core.rampOrderResolutionText(order, language) }),
|
|
@@ -6725,7 +6931,14 @@ function RampWidgetTemplate({
|
|
|
6725
6931
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-payment-label", children: view.pasteCode.label }),
|
|
6726
6932
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-payment-value", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
6727
6933
|
/* @__PURE__ */ jsxRuntime.jsx("code", { style: { flex: 1, wordBreak: "break-all" }, children: view.pasteCode.value }),
|
|
6728
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6934
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6935
|
+
CopyButton,
|
|
6936
|
+
{
|
|
6937
|
+
value: view.pasteCode.value,
|
|
6938
|
+
label: copy.copyLabel(view.pasteCode.label),
|
|
6939
|
+
language
|
|
6940
|
+
}
|
|
6941
|
+
)
|
|
6729
6942
|
] }) })
|
|
6730
6943
|
] }),
|
|
6731
6944
|
!settled && view.details.map((d) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-field", children: [
|
|
@@ -6757,11 +6970,8 @@ function RampWidgetTemplate({
|
|
|
6757
6970
|
!settled && order.pendingAction?.kind === "KYC" && !view.link && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: view.note ?? copy.providerReviewing }),
|
|
6758
6971
|
pollTrouble && !settled && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: copy.serverTrouble }),
|
|
6759
6972
|
errorMsg && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-field-error", children: errorMsg }),
|
|
6760
|
-
/* @__PURE__ */ jsxRuntime.
|
|
6761
|
-
|
|
6762
|
-
!stopped && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: copy.keepsGoing })
|
|
6763
|
-
] })
|
|
6764
|
-
] }),
|
|
6973
|
+
!settled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-explore", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onNewOrder, children: copy.startAnother }) })
|
|
6974
|
+
] }) }),
|
|
6765
6975
|
step === "error" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6766
6976
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: errorMsg ?? copy.somethingWrong }),
|
|
6767
6977
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-actions", children: [
|
|
@@ -7926,8 +8136,7 @@ function RampWidget({ onClose, language: languageProp, initial }) {
|
|
|
7926
8136
|
const flowSteps = fields.length || quotes.some((q) => core.rampQuoteFields(q).length) ? [copy.steps.route, copy.steps.details, copy.steps.complete] : [copy.steps.route, copy.steps.complete];
|
|
7927
8137
|
const stepLabel = {
|
|
7928
8138
|
select_route: copy.steps.route,
|
|
7929
|
-
contact: copy.steps.details
|
|
7930
|
-
status: copy.steps.complete
|
|
8139
|
+
contact: copy.steps.details
|
|
7931
8140
|
};
|
|
7932
8141
|
const label = stepLabel[step];
|
|
7933
8142
|
if (verifying) {
|
|
@@ -10332,8 +10541,6 @@ function SwapModal({ onClose, initial }) {
|
|
|
10332
10541
|
void refreshAssets();
|
|
10333
10542
|
}, [refreshWalletBalance, refreshAssets]);
|
|
10334
10543
|
const loadConfig = react.useCallback(() => {
|
|
10335
|
-
setVenues(null);
|
|
10336
|
-
setSolanaVenues(null);
|
|
10337
10544
|
return Promise.all([
|
|
10338
10545
|
getSwapConfig().then(setVenues).catch(() => setVenues([])),
|
|
10339
10546
|
// treat a failed config as "unavailable"
|
|
@@ -10471,10 +10678,12 @@ function SwapModal({ onClose, initial }) {
|
|
|
10471
10678
|
setSelectedBuy(seeded);
|
|
10472
10679
|
return;
|
|
10473
10680
|
}
|
|
10474
|
-
|
|
10475
|
-
|
|
10681
|
+
const sellKey = selectedSell ? optKey(selectedSell) : "";
|
|
10682
|
+
if (!selectedBuy || optKey(selectedBuy) === sellKey || !buyOptions.some((o) => optKey(o) === optKey(selectedBuy))) {
|
|
10683
|
+
const next = buyOptions.find((o) => optKey(o) !== sellKey) ?? null;
|
|
10684
|
+
if (next !== selectedBuy) setSelectedBuy(next);
|
|
10476
10685
|
}
|
|
10477
|
-
}, [buyOptions, selectedBuy, isLoadingData]);
|
|
10686
|
+
}, [buyOptions, selectedBuy, selectedSell, isLoadingData]);
|
|
10478
10687
|
function addCustomToken(code, issuer) {
|
|
10479
10688
|
const c = code.trim().toUpperCase();
|
|
10480
10689
|
const i = issuer.trim();
|
|
@@ -10534,8 +10743,13 @@ function SwapModal({ onClose, initial }) {
|
|
|
10534
10743
|
};
|
|
10535
10744
|
}, [quotedSolana, step]);
|
|
10536
10745
|
react.useEffect(() => {
|
|
10537
|
-
if (
|
|
10538
|
-
|
|
10746
|
+
if (configLoading) return;
|
|
10747
|
+
if (chains.length === 0 || chains.includes(chain)) return;
|
|
10748
|
+
setChain(chains[0]);
|
|
10749
|
+
setProvider("auto");
|
|
10750
|
+
setQuotes([]);
|
|
10751
|
+
setSolanaQuotes([]);
|
|
10752
|
+
}, [chains, chain, configLoading]);
|
|
10539
10753
|
function handleChainChange(next) {
|
|
10540
10754
|
sellSeed.current = void 0;
|
|
10541
10755
|
buySeed.current = void 0;
|
|
@@ -13997,6 +14211,7 @@ var COSIGN_COPY = {
|
|
|
13997
14211
|
approve: "Approve",
|
|
13998
14212
|
approving: "Approving...",
|
|
13999
14213
|
genericError: "Something went wrong. Please try again.",
|
|
14214
|
+
unreachable: "We could not reach Pollar, so nothing was approved. Check your connection and approve again.",
|
|
14000
14215
|
deviceNotLinked: "This device isn't linked to your wallet yet, so it can't approve. Add it with a device that already is, your passkey or your email.",
|
|
14001
14216
|
linkDevice: "Link this device",
|
|
14002
14217
|
transaction: "Transaction",
|
|
@@ -14050,6 +14265,7 @@ var COSIGN_COPY = {
|
|
|
14050
14265
|
approve: "Aprobar",
|
|
14051
14266
|
approving: "Aprobando...",
|
|
14052
14267
|
genericError: "Algo sali\xF3 mal. Intenta de nuevo.",
|
|
14268
|
+
unreachable: "No pudimos conectar con Pollar, as\xED que no se aprob\xF3 nada. Revisa tu conexi\xF3n y aprueba de nuevo.",
|
|
14053
14269
|
deviceNotLinked: "Este dispositivo a\xFAn no est\xE1 vinculado a tu billetera, as\xED que no puede aprobar. Agr\xE9galo con un dispositivo que ya lo est\xE9, tu passkey o tu email.",
|
|
14054
14270
|
linkDevice: "Vincular este dispositivo",
|
|
14055
14271
|
transaction: "Transacci\xF3n",
|
|
@@ -14103,6 +14319,7 @@ var COSIGN_COPY = {
|
|
|
14103
14319
|
approve: "Aprovar",
|
|
14104
14320
|
approving: "Aprovando...",
|
|
14105
14321
|
genericError: "Algo deu errado. Tente novamente.",
|
|
14322
|
+
unreachable: "N\xE3o conseguimos conectar \xE0 Pollar, ent\xE3o nada foi aprovado. Verifique sua conex\xE3o e aprove novamente.",
|
|
14106
14323
|
deviceNotLinked: "Este dispositivo ainda n\xE3o est\xE1 vinculado \xE0 sua carteira, ent\xE3o n\xE3o pode aprovar. Adicione-o com um dispositivo que j\xE1 esteja, sua passkey ou seu email.",
|
|
14107
14324
|
linkDevice: "Vincular este dispositivo",
|
|
14108
14325
|
transaction: "Transa\xE7\xE3o",
|
|
@@ -14456,6 +14673,11 @@ function CosignModal({ nextStep = null, onClose }) {
|
|
|
14456
14673
|
try {
|
|
14457
14674
|
await action(request);
|
|
14458
14675
|
} catch (err) {
|
|
14676
|
+
if (core.isPollarNetworkError(err) || err instanceof TypeError) {
|
|
14677
|
+
setError(COSIGN_COPY[language].unreachable);
|
|
14678
|
+
void refresh().catch(() => void 0);
|
|
14679
|
+
return;
|
|
14680
|
+
}
|
|
14459
14681
|
setError(
|
|
14460
14682
|
core.transactionErrorMessage(core.isPollarApiError(err) ? err.code : null, err instanceof Error ? err.message : null, language)
|
|
14461
14683
|
);
|
|
@@ -14465,7 +14687,7 @@ function CosignModal({ nextStep = null, onClose }) {
|
|
|
14465
14687
|
setBusy(null);
|
|
14466
14688
|
}
|
|
14467
14689
|
},
|
|
14468
|
-
[]
|
|
14690
|
+
[language, refresh]
|
|
14469
14691
|
);
|
|
14470
14692
|
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
14471
14693
|
CosignModalTemplate,
|
|
@@ -14696,6 +14918,9 @@ var RECOVERY_COPY = {
|
|
|
14696
14918
|
acceptRisks: "I understand and accept these risks",
|
|
14697
14919
|
recoverEmailIntro: (address) => `We'll email a code to ${address}. The code goes straight to the wallet provider, encrypted on this device.`,
|
|
14698
14920
|
sendCode: "Send code",
|
|
14921
|
+
sendCodeIn: (seconds) => `Send code in ${seconds}s`,
|
|
14922
|
+
resendCode: "Send a new code",
|
|
14923
|
+
resendCodeIn: (seconds) => `Send a new code in ${seconds}s`,
|
|
14699
14924
|
recover: "Recover",
|
|
14700
14925
|
back: "Back",
|
|
14701
14926
|
emailIntro: "Confirm an email you control. If you lose this device, a code sent there lets you add a new one. Anyone who controls this inbox could do the same, so use one that is well protected.",
|
|
@@ -14748,6 +14973,9 @@ var RECOVERY_COPY = {
|
|
|
14748
14973
|
acceptRisks: "Entiendo y acepto estos riesgos",
|
|
14749
14974
|
recoverEmailIntro: (address) => `Te enviaremos un c\xF3digo a ${address}. El c\xF3digo va directo al proveedor de la billetera, cifrado en este dispositivo.`,
|
|
14750
14975
|
sendCode: "Enviar c\xF3digo",
|
|
14976
|
+
sendCodeIn: (seconds) => `Enviar c\xF3digo en ${seconds} s`,
|
|
14977
|
+
resendCode: "Enviar otro c\xF3digo",
|
|
14978
|
+
resendCodeIn: (seconds) => `Enviar otro c\xF3digo en ${seconds} s`,
|
|
14751
14979
|
recover: "Recuperar",
|
|
14752
14980
|
back: "Atr\xE1s",
|
|
14753
14981
|
emailIntro: "Confirma un correo que controles. Si pierdes este dispositivo, un c\xF3digo enviado ah\xED te permite agregar uno nuevo. Cualquiera que controle esa bandeja de entrada podr\xEDa hacer lo mismo, as\xED que usa una que est\xE9 bien protegida.",
|
|
@@ -14800,6 +15028,9 @@ var RECOVERY_COPY = {
|
|
|
14800
15028
|
acceptRisks: "Entendo e aceito esses riscos",
|
|
14801
15029
|
recoverEmailIntro: (address) => `Vamos enviar um c\xF3digo para ${address}. O c\xF3digo vai direto para o provedor da carteira, criptografado neste dispositivo.`,
|
|
14802
15030
|
sendCode: "Enviar c\xF3digo",
|
|
15031
|
+
sendCodeIn: (seconds) => `Enviar c\xF3digo em ${seconds} s`,
|
|
15032
|
+
resendCode: "Enviar outro c\xF3digo",
|
|
15033
|
+
resendCodeIn: (seconds) => `Enviar outro c\xF3digo em ${seconds} s`,
|
|
14803
15034
|
recover: "Recuperar",
|
|
14804
15035
|
back: "Voltar",
|
|
14805
15036
|
emailIntro: "Confirme um e-mail que voc\xEA controla. Se voc\xEA perder este dispositivo, um c\xF3digo enviado para ele permite adicionar um novo. Qualquer pessoa que controle essa caixa de entrada poderia fazer o mesmo, ent\xE3o use uma que esteja bem protegida.",
|
|
@@ -14955,11 +15186,25 @@ function RecoveryModalTemplate(p) {
|
|
|
14955
15186
|
copy,
|
|
14956
15187
|
busy: p.busy,
|
|
14957
15188
|
id: "recover-send",
|
|
14958
|
-
label: copy.sendCode,
|
|
15189
|
+
label: p.sendWaitSeconds ? copy.sendCodeIn(p.sendWaitSeconds) : copy.sendCode,
|
|
14959
15190
|
kind: "primary",
|
|
14960
|
-
onClick: p.onSendRecoveryCode
|
|
15191
|
+
onClick: p.onSendRecoveryCode,
|
|
15192
|
+
disabled: p.sendWaitSeconds > 0
|
|
14961
15193
|
}
|
|
14962
|
-
) : /* @__PURE__ */ jsxRuntime.
|
|
15194
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
15195
|
+
/* @__PURE__ */ jsxRuntime.jsx(CodeForm, { copy, busy: p.busy, id: "recover-code", label: copy.recover, onSubmit: p.onRecoverWithCode }),
|
|
15196
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
15197
|
+
Button,
|
|
15198
|
+
{
|
|
15199
|
+
copy,
|
|
15200
|
+
busy: p.busy,
|
|
15201
|
+
id: "recover-send",
|
|
15202
|
+
label: p.sendWaitSeconds ? copy.resendCodeIn(p.sendWaitSeconds) : copy.resendCode,
|
|
15203
|
+
onClick: p.onSendRecoveryCode,
|
|
15204
|
+
disabled: p.sendWaitSeconds > 0
|
|
15205
|
+
}
|
|
15206
|
+
)
|
|
15207
|
+
] }),
|
|
14963
15208
|
/* @__PURE__ */ jsxRuntime.jsx(Button, { copy, busy: p.busy, id: "back", label: copy.back, onClick: () => p.onView("overview") })
|
|
14964
15209
|
] });
|
|
14965
15210
|
} else if (p.view === "email") {
|
|
@@ -14971,7 +15216,7 @@ function RecoveryModalTemplate(p) {
|
|
|
14971
15216
|
className: "pollar-recovery-row",
|
|
14972
15217
|
onSubmit: (e) => {
|
|
14973
15218
|
e.preventDefault();
|
|
14974
|
-
p.onSendEmailCode();
|
|
15219
|
+
if (!p.sendWaitSeconds) p.onSendEmailCode();
|
|
14975
15220
|
},
|
|
14976
15221
|
children: [
|
|
14977
15222
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -14991,15 +15236,28 @@ function RecoveryModalTemplate(p) {
|
|
|
14991
15236
|
copy,
|
|
14992
15237
|
busy: p.busy,
|
|
14993
15238
|
id: "email-send",
|
|
14994
|
-
label: copy.sendCode,
|
|
15239
|
+
label: p.sendWaitSeconds ? copy.sendCodeIn(p.sendWaitSeconds) : copy.sendCode,
|
|
14995
15240
|
kind: "primary",
|
|
14996
15241
|
onClick: p.onSendEmailCode,
|
|
14997
|
-
disabled: !p.emailDraft.trim()
|
|
15242
|
+
disabled: !p.emailDraft.trim() || p.sendWaitSeconds > 0
|
|
14998
15243
|
}
|
|
14999
15244
|
)
|
|
15000
15245
|
]
|
|
15001
15246
|
}
|
|
15002
|
-
) : /* @__PURE__ */ jsxRuntime.
|
|
15247
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
15248
|
+
/* @__PURE__ */ jsxRuntime.jsx(CodeForm, { copy, busy: p.busy, id: "email-confirm", label: copy.confirm, onSubmit: p.onConfirmEmail }),
|
|
15249
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
15250
|
+
Button,
|
|
15251
|
+
{
|
|
15252
|
+
copy,
|
|
15253
|
+
busy: p.busy,
|
|
15254
|
+
id: "email-send",
|
|
15255
|
+
label: p.sendWaitSeconds ? copy.resendCodeIn(p.sendWaitSeconds) : copy.resendCode,
|
|
15256
|
+
onClick: p.onSendEmailCode,
|
|
15257
|
+
disabled: p.sendWaitSeconds > 0
|
|
15258
|
+
}
|
|
15259
|
+
)
|
|
15260
|
+
] }),
|
|
15003
15261
|
/* @__PURE__ */ jsxRuntime.jsx(Button, { copy, busy: p.busy, id: "back", label: copy.back, onClick: () => p.onView("overview") })
|
|
15004
15262
|
] });
|
|
15005
15263
|
} else if (p.view === "export") {
|
|
@@ -15142,6 +15400,7 @@ function RecoveryModal({ onClose }) {
|
|
|
15142
15400
|
const [emailDraft, setEmailDraft] = react.useState("");
|
|
15143
15401
|
const [codeSent, setCodeSent] = react.useState(false);
|
|
15144
15402
|
const [phrase, setPhrase] = react.useState(null);
|
|
15403
|
+
const [now, setNow] = react.useState(() => Date.now());
|
|
15145
15404
|
const load = react.useCallback(async () => {
|
|
15146
15405
|
const client = getClient();
|
|
15147
15406
|
const [nextState, nextDevices, key] = await Promise.all([
|
|
@@ -15184,6 +15443,14 @@ function RecoveryModal({ onClose }) {
|
|
|
15184
15443
|
},
|
|
15185
15444
|
[load]
|
|
15186
15445
|
);
|
|
15446
|
+
const codeEmail = view === "recover-email" ? state?.email.address ?? "" : emailDraft.trim();
|
|
15447
|
+
const codeAvailableAt = codeEmail ? recovery.codeAvailableAt(codeEmail) : 0;
|
|
15448
|
+
const sendWaitSeconds = codeAvailableAt > now ? Math.ceil((codeAvailableAt - now) / 1e3) : 0;
|
|
15449
|
+
react.useEffect(() => {
|
|
15450
|
+
if (!codeAvailableAt) return;
|
|
15451
|
+
const timer = setInterval(() => setNow(Date.now()), 1e3);
|
|
15452
|
+
return () => clearInterval(timer);
|
|
15453
|
+
}, [codeAvailableAt]);
|
|
15187
15454
|
const enrolled = !!thisDeviceKey && !!devices?.devices.some((d) => d.publicKey.toLowerCase() === thisDeviceKey);
|
|
15188
15455
|
const [awaitingApproval, setAwaitingApproval] = react.useState(false);
|
|
15189
15456
|
react.useEffect(() => {
|
|
@@ -15218,6 +15485,7 @@ function RecoveryModal({ onClose }) {
|
|
|
15218
15485
|
notice,
|
|
15219
15486
|
emailDraft,
|
|
15220
15487
|
codeSent,
|
|
15488
|
+
sendWaitSeconds,
|
|
15221
15489
|
phrase,
|
|
15222
15490
|
onView: (next) => {
|
|
15223
15491
|
setError(null);
|
|
@@ -15230,8 +15498,12 @@ function RecoveryModal({ onClose }) {
|
|
|
15230
15498
|
onAddPasskey: () => void run("passkey", () => recovery.addPasskey(), { notice: copy.passkeyAdded }),
|
|
15231
15499
|
onRemovePasskey: (id) => void run(`passkey:${id}`, () => recovery.removePasskey(id)),
|
|
15232
15500
|
onSendEmailCode: () => void run("email-send", async () => {
|
|
15233
|
-
|
|
15234
|
-
|
|
15501
|
+
try {
|
|
15502
|
+
await recovery.startEmail(emailDraft.trim());
|
|
15503
|
+
setCodeSent(true);
|
|
15504
|
+
} finally {
|
|
15505
|
+
setNow(Date.now());
|
|
15506
|
+
}
|
|
15235
15507
|
}),
|
|
15236
15508
|
onConfirmEmail: (code) => void run("email-confirm", () => recovery.confirmEmail(code.trim()), { notice: copy.emailConfirmed, view: "overview" }),
|
|
15237
15509
|
onApproveDevice: (id) => void run(`approve:${id}`, () => recovery.approveDevice(id), { notice: copy.deviceAdded }),
|
|
@@ -15248,8 +15520,12 @@ function RecoveryModal({ onClose }) {
|
|
|
15248
15520
|
notice: copy.recovered
|
|
15249
15521
|
}),
|
|
15250
15522
|
onSendRecoveryCode: () => void run("recover-send", async () => {
|
|
15251
|
-
|
|
15252
|
-
|
|
15523
|
+
try {
|
|
15524
|
+
await recovery.startEmailRecovery();
|
|
15525
|
+
setCodeSent(true);
|
|
15526
|
+
} finally {
|
|
15527
|
+
setNow(Date.now());
|
|
15528
|
+
}
|
|
15253
15529
|
}),
|
|
15254
15530
|
onRecoverWithCode: (code) => void run("recover-code", () => recovery.recoverWithEmailCode(code.trim()), {
|
|
15255
15531
|
notice: copy.recovered,
|
|
@@ -16472,31 +16748,58 @@ function PollarProvider({
|
|
|
16472
16748
|
}, [pollarClient, hasSession, walletAddress, custodyMigrationTick]);
|
|
16473
16749
|
const refreshWalletBalance = react.useCallback(() => pollarClient.refreshBalance(), [pollarClient, walletAddress]);
|
|
16474
16750
|
const refreshAssets = react.useCallback(() => pollarClient.refreshAssets(), [pollarClient, walletAddress]);
|
|
16751
|
+
const clientMethods = react.useMemo(
|
|
16752
|
+
() => ({
|
|
16753
|
+
createWallet: (options) => pollarClient.createWallet(options),
|
|
16754
|
+
login: (options) => pollarClient.login(options),
|
|
16755
|
+
logout: () => pollarClient.logout(),
|
|
16756
|
+
buildTx: (operation, params, options) => pollarClient.buildTx(operation, params, options),
|
|
16757
|
+
signAndSubmitTx: (unsignedXdr) => pollarClient.signAndSubmitTx(unsignedXdr),
|
|
16758
|
+
signTx: (unsignedXdr) => pollarClient.signTx(unsignedXdr),
|
|
16759
|
+
submitTx: (signedXdr) => pollarClient.submitTx(signedXdr),
|
|
16760
|
+
buildAndSignAndSubmitTx: (operation, params, options) => pollarClient.buildAndSignAndSubmitTx(operation, params, options),
|
|
16761
|
+
runTx: (operation, params, options) => pollarClient.runTx(operation, params, options),
|
|
16762
|
+
sendPayment: (params) => pollarClient.sendPayment(params),
|
|
16763
|
+
setTrustline: (asset, opts) => pollarClient.setTrustline(asset, opts),
|
|
16764
|
+
getSwapConfig: () => pollarClient.getSwapConfig(),
|
|
16765
|
+
getSwapTokens: () => pollarClient.getSwapTokens(),
|
|
16766
|
+
getSwapQuote: (params) => pollarClient.getSwapQuote(params),
|
|
16767
|
+
swap: (quote, opts) => pollarClient.swap(quote, opts),
|
|
16768
|
+
getSolanaSwapConfig: () => pollarClient.getSolanaSwapConfig(),
|
|
16769
|
+
getSolanaSwapQuote: (params) => pollarClient.getSolanaSwapQuote(params),
|
|
16770
|
+
swapSolana: (quote, opts) => pollarClient.swapSolana(quote, opts),
|
|
16771
|
+
getSolanaSwapOptions: () => pollarClient.getSolanaSwapOptions(),
|
|
16772
|
+
getSwapStatus: (idempotencyKey) => pollarClient.getSwapStatus(idempotencyKey),
|
|
16773
|
+
getEarnProviders: () => pollarClient.getEarnProviders(),
|
|
16774
|
+
getEarnOpportunities: (provider) => pollarClient.getEarnOpportunities(provider).then(remembered),
|
|
16775
|
+
getEarnPosition: (params) => pollarClient.getEarnPosition(params),
|
|
16776
|
+
earnDeposit: (params) => pollarClient.earnDeposit(params),
|
|
16777
|
+
earnWithdraw: (params) => pollarClient.earnWithdraw(params),
|
|
16778
|
+
getSolanaEarnProviders: () => pollarClient.getSolanaEarnProviders(),
|
|
16779
|
+
getSolanaEarnOpportunities: () => pollarClient.getSolanaEarnOpportunities().then(remembered),
|
|
16780
|
+
getSolanaEarnPosition: (opportunity) => pollarClient.getSolanaEarnPosition(opportunity),
|
|
16781
|
+
earnSolanaDeposit: (params) => pollarClient.earnSolanaDeposit(params),
|
|
16782
|
+
earnSolanaWithdraw: (params) => pollarClient.earnSolanaWithdraw(params),
|
|
16783
|
+
setNetwork: (network) => pollarClient.setNetwork(network)
|
|
16784
|
+
}),
|
|
16785
|
+
[pollarClient]
|
|
16786
|
+
);
|
|
16475
16787
|
const contextValue = react.useMemo(() => {
|
|
16476
16788
|
const styles = resolvedConfig.styles ?? {};
|
|
16477
16789
|
return {
|
|
16790
|
+
...clientMethods,
|
|
16478
16791
|
// session
|
|
16479
16792
|
wallet: pollarClient.getWallet(),
|
|
16480
16793
|
wallets: pollarClient.getWallets(),
|
|
16481
16794
|
isAuthenticated: hasSession,
|
|
16482
16795
|
hasWallet: pollarClient.hasWallet(),
|
|
16483
|
-
createWallet: (options) => pollarClient.createWallet(options),
|
|
16484
16796
|
verified,
|
|
16485
16797
|
// client
|
|
16486
16798
|
getClient,
|
|
16487
16799
|
// auth
|
|
16488
|
-
login: (options) => pollarClient.login(options),
|
|
16489
|
-
logout: () => pollarClient.logout(),
|
|
16490
16800
|
openLoginModal: () => setLoginModalOpen(true),
|
|
16491
16801
|
// transactions
|
|
16492
16802
|
tx: transaction,
|
|
16493
|
-
buildTx: (operation, params, options) => pollarClient.buildTx(operation, params, options),
|
|
16494
|
-
signAndSubmitTx: (unsignedXdr) => pollarClient.signAndSubmitTx(unsignedXdr),
|
|
16495
|
-
signTx: (unsignedXdr) => pollarClient.signTx(unsignedXdr),
|
|
16496
|
-
submitTx: (signedXdr) => pollarClient.submitTx(signedXdr),
|
|
16497
|
-
buildAndSignAndSubmitTx: (operation, params, options) => pollarClient.buildAndSignAndSubmitTx(operation, params, options),
|
|
16498
|
-
runTx: (operation, params, options) => pollarClient.runTx(operation, params, options),
|
|
16499
|
-
sendPayment: (params) => pollarClient.sendPayment(params),
|
|
16500
16803
|
openTxModal: () => setTransactionModalOpen(true),
|
|
16501
16804
|
// tx history
|
|
16502
16805
|
txHistory,
|
|
@@ -16511,7 +16814,6 @@ function PollarProvider({
|
|
|
16511
16814
|
// enabled assets
|
|
16512
16815
|
enabledAssets,
|
|
16513
16816
|
refreshAssets,
|
|
16514
|
-
setTrustline: (asset, opts) => pollarClient.setTrustline(asset, opts),
|
|
16515
16817
|
openEnabledAssetsModal: () => setEnabledAssetsModalOpen(true),
|
|
16516
16818
|
// send / receive
|
|
16517
16819
|
openSendModal: (options) => {
|
|
@@ -16525,15 +16827,6 @@ function PollarProvider({
|
|
|
16525
16827
|
setReceiveModalOpen(true);
|
|
16526
16828
|
},
|
|
16527
16829
|
// swap
|
|
16528
|
-
getSwapConfig: () => pollarClient.getSwapConfig(),
|
|
16529
|
-
getSwapTokens: () => pollarClient.getSwapTokens(),
|
|
16530
|
-
getSwapQuote: (params) => pollarClient.getSwapQuote(params),
|
|
16531
|
-
swap: (quote, opts) => pollarClient.swap(quote, opts),
|
|
16532
|
-
getSolanaSwapConfig: () => pollarClient.getSolanaSwapConfig(),
|
|
16533
|
-
getSolanaSwapQuote: (params) => pollarClient.getSolanaSwapQuote(params),
|
|
16534
|
-
swapSolana: (quote, opts) => pollarClient.swapSolana(quote, opts),
|
|
16535
|
-
getSolanaSwapOptions: () => pollarClient.getSolanaSwapOptions(),
|
|
16536
|
-
getSwapStatus: (idempotencyKey) => pollarClient.getSwapStatus(idempotencyKey),
|
|
16537
16830
|
openSwapModal: (options) => {
|
|
16538
16831
|
setSwapModalOptions(options);
|
|
16539
16832
|
pollarClient.resetTransactionState();
|
|
@@ -16546,16 +16839,6 @@ function PollarProvider({
|
|
|
16546
16839
|
setBridgeModalOpen(true);
|
|
16547
16840
|
},
|
|
16548
16841
|
// earn
|
|
16549
|
-
getEarnProviders: () => pollarClient.getEarnProviders(),
|
|
16550
|
-
getEarnOpportunities: (provider) => pollarClient.getEarnOpportunities(provider).then(remembered),
|
|
16551
|
-
getEarnPosition: (params) => pollarClient.getEarnPosition(params),
|
|
16552
|
-
earnDeposit: (params) => pollarClient.earnDeposit(params),
|
|
16553
|
-
earnWithdraw: (params) => pollarClient.earnWithdraw(params),
|
|
16554
|
-
getSolanaEarnProviders: () => pollarClient.getSolanaEarnProviders(),
|
|
16555
|
-
getSolanaEarnOpportunities: () => pollarClient.getSolanaEarnOpportunities().then(remembered),
|
|
16556
|
-
getSolanaEarnPosition: (opportunity) => pollarClient.getSolanaEarnPosition(opportunity),
|
|
16557
|
-
earnSolanaDeposit: (params) => pollarClient.earnSolanaDeposit(params),
|
|
16558
|
-
earnSolanaWithdraw: (params) => pollarClient.earnSolanaWithdraw(params),
|
|
16559
16842
|
openEarnModal: (options) => {
|
|
16560
16843
|
setEarnModalOptions(options);
|
|
16561
16844
|
pollarClient.resetTransactionState();
|
|
@@ -16587,7 +16870,6 @@ function PollarProvider({
|
|
|
16587
16870
|
openDistributionRulesModal: () => setDistributionRulesModalOpen(true),
|
|
16588
16871
|
// network
|
|
16589
16872
|
network: networkState.step === "connected" ? networkState.network : "testnet",
|
|
16590
|
-
setNetwork: (network) => pollarClient.setNetwork(network),
|
|
16591
16873
|
// kyc
|
|
16592
16874
|
openKycModal: (options = {}) => {
|
|
16593
16875
|
setKycModalOptions(options);
|
|
@@ -16606,6 +16888,7 @@ function PollarProvider({
|
|
|
16606
16888
|
adapters
|
|
16607
16889
|
};
|
|
16608
16890
|
}, [
|
|
16891
|
+
clientMethods,
|
|
16609
16892
|
walletAddress,
|
|
16610
16893
|
walletProvisioning,
|
|
16611
16894
|
recovery,
|