@pollar/react 0.12.1-rc.23 → 0.12.1-rc.26
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 +175 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +621 -97
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +622 -98
- 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.26"
|
|
1315
1315
|
] })
|
|
1316
1316
|
] });
|
|
1317
1317
|
};
|
|
@@ -5513,6 +5513,7 @@ var RAMP_COPY = {
|
|
|
5513
5513
|
SDK_RAMPS_QUOTE_EXPIRED: "This quote expired. Find a route again.",
|
|
5514
5514
|
SDK_RAMPS_QUOTE_NOT_FOUND: "This quote is no longer available. Find a route again.",
|
|
5515
5515
|
SDK_RAMPS_ACTION_STALE: "This step changed. It was refreshed; try again.",
|
|
5516
|
+
SDK_RAMPS_ORDER_NOT_CANCELLABLE: "This order can no longer be cancelled: its funds are already moving.",
|
|
5516
5517
|
SDK_RAMPS_TX_NOT_FOUND: "This operation was not found.",
|
|
5517
5518
|
SDK_RAMPS_WALLET_NOT_READY: "Approve the new wallet account on your device, then try again."
|
|
5518
5519
|
},
|
|
@@ -5533,6 +5534,7 @@ var RAMP_COPY = {
|
|
|
5533
5534
|
resumeOrderFailed: "Could not resume the operation.",
|
|
5534
5535
|
checkPaymentFailed: "Could not check the payment. Please try again.",
|
|
5535
5536
|
retryOrderFailed: "Could not try again. Please try again.",
|
|
5537
|
+
cancelOrderFailed: "Could not cancel the order. Please try again.",
|
|
5536
5538
|
refreshFailed: "Could not refresh.",
|
|
5537
5539
|
copyFailed: "Could not copy.",
|
|
5538
5540
|
awaitingAccount: "Approve the new account on your device. The order starts once it is approved.",
|
|
@@ -5630,6 +5632,39 @@ var RAMP_COPY = {
|
|
|
5630
5632
|
startAnother: "Start another operation",
|
|
5631
5633
|
newQuote: "Get a new quote",
|
|
5632
5634
|
keepsGoing: "This one keeps going; you can resume it later.",
|
|
5635
|
+
leave: {
|
|
5636
|
+
title: "Leave this purchase?",
|
|
5637
|
+
note: "Your order keeps going. You can come back to it from Buy.",
|
|
5638
|
+
stay: "Stay here",
|
|
5639
|
+
exit: "Leave, keep the order",
|
|
5640
|
+
cancel: "Cancel the order",
|
|
5641
|
+
cancelling: "Cancelling\u2026"
|
|
5642
|
+
},
|
|
5643
|
+
screens: {
|
|
5644
|
+
pay: (amount, currency) => `Pay ${amount} ${currency}`,
|
|
5645
|
+
send: (amount, code) => `Send ${amount} ${code}`,
|
|
5646
|
+
delivering: (code) => `Your ${code} is on its way`,
|
|
5647
|
+
payingOut: (currency) => `Your ${currency} is on its way to your account`,
|
|
5648
|
+
next: "Next step",
|
|
5649
|
+
paidDone: (amount, currency) => `You paid ${amount} ${currency}.`,
|
|
5650
|
+
sentDone: (amount, code) => `You sent ${amount} ${code}.`,
|
|
5651
|
+
receivedDone: (amount, code, chain) => `You received ${amount} ${code} on ${chain}.`,
|
|
5652
|
+
payoutDone: (amount, currency) => `${amount} ${currency} were sent to your account.`,
|
|
5653
|
+
signedDone: "You approved this step.",
|
|
5654
|
+
ranDone: "This step is complete.",
|
|
5655
|
+
updatesItself: "This screen updates on its own.",
|
|
5656
|
+
preparing: "Preparing your payment\u2026",
|
|
5657
|
+
saveQr: "Save QR",
|
|
5658
|
+
savingQr: "Saving\u2026",
|
|
5659
|
+
savedQr: "QR saved",
|
|
5660
|
+
saveQrFailed: "Could not save the QR",
|
|
5661
|
+
qrFile: "payment",
|
|
5662
|
+
received: (amount) => `+${amount}`,
|
|
5663
|
+
arrived: (chain) => `It reached your wallet on ${chain}.`,
|
|
5664
|
+
paidOut: "It was sent to your account.",
|
|
5665
|
+
finish: "Done",
|
|
5666
|
+
details: "Details"
|
|
5667
|
+
},
|
|
5633
5668
|
somethingWrong: "Something went wrong.",
|
|
5634
5669
|
routeSteps: (count) => count === 1 ? "1 step" : `${count} steps`,
|
|
5635
5670
|
feesIncluded: "fees included",
|
|
@@ -5644,6 +5679,7 @@ var RAMP_COPY = {
|
|
|
5644
5679
|
SDK_RAMPS_QUOTE_EXPIRED: "Esta cotizaci\xF3n venci\xF3. Busca una ruta de nuevo.",
|
|
5645
5680
|
SDK_RAMPS_QUOTE_NOT_FOUND: "Esta cotizaci\xF3n ya no est\xE1 disponible. Busca una ruta de nuevo.",
|
|
5646
5681
|
SDK_RAMPS_ACTION_STALE: "Este paso cambi\xF3 y se actualiz\xF3. Intenta de nuevo.",
|
|
5682
|
+
SDK_RAMPS_ORDER_NOT_CANCELLABLE: "Esta orden ya no se puede cancelar: sus fondos ya est\xE1n en movimiento.",
|
|
5647
5683
|
SDK_RAMPS_TX_NOT_FOUND: "No se encontr\xF3 esta operaci\xF3n.",
|
|
5648
5684
|
SDK_RAMPS_WALLET_NOT_READY: "Aprueba la nueva cuenta de la billetera en tu dispositivo e intenta de nuevo."
|
|
5649
5685
|
},
|
|
@@ -5664,6 +5700,7 @@ var RAMP_COPY = {
|
|
|
5664
5700
|
resumeOrderFailed: "No se pudo retomar la operaci\xF3n.",
|
|
5665
5701
|
checkPaymentFailed: "No se pudo verificar el pago. Intenta de nuevo.",
|
|
5666
5702
|
retryOrderFailed: "No se pudo reintentar. Intenta de nuevo.",
|
|
5703
|
+
cancelOrderFailed: "No se pudo cancelar la orden. Intenta de nuevo.",
|
|
5667
5704
|
refreshFailed: "No se pudo actualizar.",
|
|
5668
5705
|
copyFailed: "No se pudo copiar.",
|
|
5669
5706
|
awaitingAccount: "Aprueba la nueva cuenta en tu dispositivo. La orden comienza cuando la apruebes.",
|
|
@@ -5761,6 +5798,39 @@ var RAMP_COPY = {
|
|
|
5761
5798
|
startAnother: "Iniciar otra operaci\xF3n",
|
|
5762
5799
|
newQuote: "Pedir nueva cotizaci\xF3n",
|
|
5763
5800
|
keepsGoing: "Esta sigue en curso; puedes retomarla m\xE1s tarde.",
|
|
5801
|
+
leave: {
|
|
5802
|
+
title: "\xBFSalir de esta compra?",
|
|
5803
|
+
note: "Tu orden sigue activa. Puedes retomarla desde Comprar.",
|
|
5804
|
+
stay: "Seguir aqu\xED",
|
|
5805
|
+
exit: "Salir, la orden sigue",
|
|
5806
|
+
cancel: "Cancelar la orden",
|
|
5807
|
+
cancelling: "Cancelando\u2026"
|
|
5808
|
+
},
|
|
5809
|
+
screens: {
|
|
5810
|
+
pay: (amount, currency) => `Paga ${amount} ${currency}`,
|
|
5811
|
+
send: (amount, code) => `Env\xEDa ${amount} ${code}`,
|
|
5812
|
+
delivering: (code) => `Tu ${code} est\xE1 en camino`,
|
|
5813
|
+
payingOut: (currency) => `Tus ${currency} van en camino a tu cuenta`,
|
|
5814
|
+
next: "Paso siguiente",
|
|
5815
|
+
paidDone: (amount, currency) => `Pagaste ${amount} ${currency}.`,
|
|
5816
|
+
sentDone: (amount, code) => `Enviaste ${amount} ${code}.`,
|
|
5817
|
+
receivedDone: (amount, code, chain) => `Recibiste ${amount} ${code} en ${chain}.`,
|
|
5818
|
+
payoutDone: (amount, currency) => `Se enviaron ${amount} ${currency} a tu cuenta.`,
|
|
5819
|
+
signedDone: "Aprobaste este paso.",
|
|
5820
|
+
ranDone: "Este paso est\xE1 completo.",
|
|
5821
|
+
updatesItself: "Esta pantalla se actualiza sola.",
|
|
5822
|
+
preparing: "Preparando tu pago\u2026",
|
|
5823
|
+
saveQr: "Guardar QR",
|
|
5824
|
+
savingQr: "Guardando\u2026",
|
|
5825
|
+
savedQr: "QR guardado",
|
|
5826
|
+
saveQrFailed: "No se pudo guardar el QR",
|
|
5827
|
+
qrFile: "pago",
|
|
5828
|
+
received: (amount) => `+${amount}`,
|
|
5829
|
+
arrived: (chain) => `Lleg\xF3 a tu wallet en ${chain}.`,
|
|
5830
|
+
paidOut: "Se envi\xF3 a tu cuenta.",
|
|
5831
|
+
finish: "Listo",
|
|
5832
|
+
details: "Detalles"
|
|
5833
|
+
},
|
|
5764
5834
|
somethingWrong: "Algo sali\xF3 mal.",
|
|
5765
5835
|
routeSteps: (count) => count === 1 ? "1 paso" : `${count} pasos`,
|
|
5766
5836
|
feesIncluded: "comisiones incluidas",
|
|
@@ -5775,6 +5845,7 @@ var RAMP_COPY = {
|
|
|
5775
5845
|
SDK_RAMPS_QUOTE_EXPIRED: "Esta cota\xE7\xE3o expirou. Busque uma rota de novo.",
|
|
5776
5846
|
SDK_RAMPS_QUOTE_NOT_FOUND: "Esta cota\xE7\xE3o n\xE3o est\xE1 mais dispon\xEDvel. Busque uma rota de novo.",
|
|
5777
5847
|
SDK_RAMPS_ACTION_STALE: "Esta etapa mudou e foi atualizada. Tente de novo.",
|
|
5848
|
+
SDK_RAMPS_ORDER_NOT_CANCELLABLE: "Esta ordem n\xE3o pode mais ser cancelada: os fundos j\xE1 est\xE3o em movimento.",
|
|
5778
5849
|
SDK_RAMPS_TX_NOT_FOUND: "Esta opera\xE7\xE3o n\xE3o foi encontrada.",
|
|
5779
5850
|
SDK_RAMPS_WALLET_NOT_READY: "Aprove a nova conta da carteira no seu dispositivo e tente de novo."
|
|
5780
5851
|
},
|
|
@@ -5795,6 +5866,7 @@ var RAMP_COPY = {
|
|
|
5795
5866
|
resumeOrderFailed: "N\xE3o foi poss\xEDvel retomar a opera\xE7\xE3o.",
|
|
5796
5867
|
checkPaymentFailed: "N\xE3o foi poss\xEDvel verificar o pagamento. Tente de novo.",
|
|
5797
5868
|
retryOrderFailed: "N\xE3o foi poss\xEDvel tentar de novo. Tente de novo.",
|
|
5869
|
+
cancelOrderFailed: "N\xE3o foi poss\xEDvel cancelar a ordem. Tente de novo.",
|
|
5798
5870
|
refreshFailed: "N\xE3o foi poss\xEDvel atualizar.",
|
|
5799
5871
|
copyFailed: "N\xE3o foi poss\xEDvel copiar.",
|
|
5800
5872
|
awaitingAccount: "Aprove a nova conta no seu dispositivo. A ordem come\xE7a assim que voc\xEA aprovar.",
|
|
@@ -5892,6 +5964,39 @@ var RAMP_COPY = {
|
|
|
5892
5964
|
startAnother: "Iniciar outra opera\xE7\xE3o",
|
|
5893
5965
|
newQuote: "Pedir nova cota\xE7\xE3o",
|
|
5894
5966
|
keepsGoing: "Esta continua em andamento; voc\xEA pode retom\xE1-la depois.",
|
|
5967
|
+
leave: {
|
|
5968
|
+
title: "Sair desta compra?",
|
|
5969
|
+
note: "Sua ordem continua ativa. Voc\xEA pode retom\xE1-la em Comprar.",
|
|
5970
|
+
stay: "Ficar aqui",
|
|
5971
|
+
exit: "Sair, manter a ordem",
|
|
5972
|
+
cancel: "Cancelar a ordem",
|
|
5973
|
+
cancelling: "Cancelando\u2026"
|
|
5974
|
+
},
|
|
5975
|
+
screens: {
|
|
5976
|
+
pay: (amount, currency) => `Pague ${amount} ${currency}`,
|
|
5977
|
+
send: (amount, code) => `Envie ${amount} ${code}`,
|
|
5978
|
+
delivering: (code) => `Seu ${code} est\xE1 a caminho`,
|
|
5979
|
+
payingOut: (currency) => `Seus ${currency} est\xE3o a caminho da sua conta`,
|
|
5980
|
+
next: "Pr\xF3xima etapa",
|
|
5981
|
+
paidDone: (amount, currency) => `Voc\xEA pagou ${amount} ${currency}.`,
|
|
5982
|
+
sentDone: (amount, code) => `Voc\xEA enviou ${amount} ${code}.`,
|
|
5983
|
+
receivedDone: (amount, code, chain) => `Voc\xEA recebeu ${amount} ${code} na ${chain}.`,
|
|
5984
|
+
payoutDone: (amount, currency) => `${amount} ${currency} foram enviados para a sua conta.`,
|
|
5985
|
+
signedDone: "Voc\xEA aprovou esta etapa.",
|
|
5986
|
+
ranDone: "Esta etapa est\xE1 conclu\xEDda.",
|
|
5987
|
+
updatesItself: "Esta tela se atualiza sozinha.",
|
|
5988
|
+
preparing: "Preparando o seu pagamento\u2026",
|
|
5989
|
+
saveQr: "Salvar QR",
|
|
5990
|
+
savingQr: "Salvando\u2026",
|
|
5991
|
+
savedQr: "QR salvo",
|
|
5992
|
+
saveQrFailed: "N\xE3o foi poss\xEDvel salvar o QR",
|
|
5993
|
+
qrFile: "pagamento",
|
|
5994
|
+
received: (amount) => `+${amount}`,
|
|
5995
|
+
arrived: (chain) => `Chegou \xE0 sua carteira na ${chain}.`,
|
|
5996
|
+
paidOut: "Foi enviado para a sua conta.",
|
|
5997
|
+
finish: "Pronto",
|
|
5998
|
+
details: "Detalhes"
|
|
5999
|
+
},
|
|
5895
6000
|
somethingWrong: "Algo deu errado.",
|
|
5896
6001
|
routeSteps: (count) => count === 1 ? "1 etapa" : `${count} etapas`,
|
|
5897
6002
|
feesIncluded: "taxas inclu\xEDdas",
|
|
@@ -6040,6 +6145,184 @@ function routeKey(quote) {
|
|
|
6040
6145
|
const node = (n) => n.kind === "asset" ? `${n.code}:${n.chain}` : `${n.currency}:${n.rail}`;
|
|
6041
6146
|
return quote.legs.map((leg) => `${leg.kind}:${node(leg.from)}>${node(leg.to)}`).join("|");
|
|
6042
6147
|
}
|
|
6148
|
+
var amountText = (value, language) => {
|
|
6149
|
+
const n = Number(value);
|
|
6150
|
+
return Number.isFinite(n) ? n.toLocaleString(language, { maximumFractionDigits: 7 }) : value;
|
|
6151
|
+
};
|
|
6152
|
+
function rampOrderScreens(order, language) {
|
|
6153
|
+
const copy = RAMP_COPY[language].screens;
|
|
6154
|
+
const parts = [];
|
|
6155
|
+
const waitsOn = (leg) => order.pendingAction?.legIndex === leg.index && order.pendingAction.kind !== "NONE";
|
|
6156
|
+
for (const leg of order.legs) {
|
|
6157
|
+
const legStatus = core.rampLegStatus(leg);
|
|
6158
|
+
const legDone = legStatus === "done";
|
|
6159
|
+
if (leg.steps?.length) {
|
|
6160
|
+
let running = [];
|
|
6161
|
+
const flush = () => {
|
|
6162
|
+
if (!running.length) return;
|
|
6163
|
+
parts.push({
|
|
6164
|
+
key: `${leg.index}:${running[0].kind}`,
|
|
6165
|
+
kind: "wait",
|
|
6166
|
+
leg,
|
|
6167
|
+
steps: running,
|
|
6168
|
+
title: core.rampLegTitle(leg, language),
|
|
6169
|
+
done: legDone || running.every((s) => s.status === "done")
|
|
6170
|
+
});
|
|
6171
|
+
running = [];
|
|
6172
|
+
};
|
|
6173
|
+
for (const step of leg.steps) {
|
|
6174
|
+
if (!step.signs) {
|
|
6175
|
+
running.push(step);
|
|
6176
|
+
continue;
|
|
6177
|
+
}
|
|
6178
|
+
flush();
|
|
6179
|
+
parts.push({
|
|
6180
|
+
key: `${leg.index}:${step.kind}`,
|
|
6181
|
+
kind: "action",
|
|
6182
|
+
leg,
|
|
6183
|
+
steps: [step],
|
|
6184
|
+
title: core.rampStepTitle(step, leg, language),
|
|
6185
|
+
done: legDone || step.status === "done"
|
|
6186
|
+
});
|
|
6187
|
+
}
|
|
6188
|
+
flush();
|
|
6189
|
+
continue;
|
|
6190
|
+
}
|
|
6191
|
+
if (leg.kind === "PROVIDER_ONRAMP" || leg.kind === "PROVIDER_OFFRAMP") {
|
|
6192
|
+
const onramp = leg.kind === "PROVIDER_ONRAMP";
|
|
6193
|
+
const unitIn = leg.from.kind === "fiat" ? leg.from.currency : leg.from.code;
|
|
6194
|
+
const unitOut = leg.to.kind === "fiat" ? leg.to.currency : leg.to.code;
|
|
6195
|
+
const payment = leg.paymentStatus;
|
|
6196
|
+
const paid = payment === void 0 ? legStatus === "active" && !waitsOn(leg) : payment === "received";
|
|
6197
|
+
const amount = amountText(leg.amountInPlanned, language);
|
|
6198
|
+
parts.push({
|
|
6199
|
+
key: `${leg.index}:pay`,
|
|
6200
|
+
kind: "action",
|
|
6201
|
+
leg,
|
|
6202
|
+
steps: [],
|
|
6203
|
+
title: onramp ? copy.pay(amount, unitIn) : copy.send(amount, unitIn),
|
|
6204
|
+
done: legDone || paid,
|
|
6205
|
+
preparing: payment === "not_requested" && !waitsOn(leg)
|
|
6206
|
+
});
|
|
6207
|
+
parts.push({
|
|
6208
|
+
key: `${leg.index}:deliver`,
|
|
6209
|
+
kind: "wait",
|
|
6210
|
+
leg,
|
|
6211
|
+
steps: [],
|
|
6212
|
+
title: onramp ? copy.delivering(unitOut) : copy.payingOut(unitOut),
|
|
6213
|
+
done: legDone
|
|
6214
|
+
});
|
|
6215
|
+
continue;
|
|
6216
|
+
}
|
|
6217
|
+
parts.push({
|
|
6218
|
+
key: `${leg.index}`,
|
|
6219
|
+
kind: leg.signingMode ? "action" : "wait",
|
|
6220
|
+
leg,
|
|
6221
|
+
steps: [],
|
|
6222
|
+
title: core.rampLegTitle(leg, language),
|
|
6223
|
+
done: legDone
|
|
6224
|
+
});
|
|
6225
|
+
}
|
|
6226
|
+
const stopped = ["failed", "refunded"].includes(order.state);
|
|
6227
|
+
let currentFound = false;
|
|
6228
|
+
return parts.map(({ done, ...screen }) => {
|
|
6229
|
+
if (done) return { ...screen, status: "done" };
|
|
6230
|
+
if (currentFound) return { ...screen, status: "upcoming" };
|
|
6231
|
+
currentFound = true;
|
|
6232
|
+
return { ...screen, status: stopped || core.rampLegStatus(screen.leg) === "failed" ? "failed" : "current" };
|
|
6233
|
+
});
|
|
6234
|
+
}
|
|
6235
|
+
var SVG_SIDE = 1024;
|
|
6236
|
+
function imageSrc(image) {
|
|
6237
|
+
return image.encoding === "base64" ? `data:${image.mediaType};base64,${image.data}` : `data:${image.mediaType};charset=utf-8,${encodeURIComponent(image.data)}`;
|
|
6238
|
+
}
|
|
6239
|
+
function base64Blob(data, type) {
|
|
6240
|
+
const bytes = Uint8Array.from(atob(data), (c) => c.charCodeAt(0));
|
|
6241
|
+
return new Blob([bytes], { type });
|
|
6242
|
+
}
|
|
6243
|
+
async function scannableFile(image) {
|
|
6244
|
+
if (image.encoding === "base64" && (image.mediaType === "image/png" || image.mediaType === "image/jpeg"))
|
|
6245
|
+
return base64Blob(image.data, image.mediaType);
|
|
6246
|
+
const element = new Image();
|
|
6247
|
+
element.decoding = "async";
|
|
6248
|
+
element.src = imageSrc(image);
|
|
6249
|
+
await element.decode();
|
|
6250
|
+
const svg = image.mediaType === "image/svg+xml";
|
|
6251
|
+
const width = svg ? SVG_SIDE : element.naturalWidth;
|
|
6252
|
+
const height = svg ? Math.round(SVG_SIDE * (element.naturalHeight || 1) / (element.naturalWidth || 1)) : element.naturalHeight;
|
|
6253
|
+
const canvas = document.createElement("canvas");
|
|
6254
|
+
canvas.width = width;
|
|
6255
|
+
canvas.height = height;
|
|
6256
|
+
const context = canvas.getContext("2d");
|
|
6257
|
+
if (!context) throw new Error("canvas unavailable");
|
|
6258
|
+
context.fillStyle = "#ffffff";
|
|
6259
|
+
context.fillRect(0, 0, width, height);
|
|
6260
|
+
context.drawImage(element, 0, 0, width, height);
|
|
6261
|
+
return new Promise(
|
|
6262
|
+
(resolve, reject) => canvas.toBlob((blob) => blob ? resolve(blob) : reject(new Error("png encoding failed")), "image/png")
|
|
6263
|
+
);
|
|
6264
|
+
}
|
|
6265
|
+
async function saveFile(blob, name) {
|
|
6266
|
+
const file = new File([blob], name, { type: blob.type });
|
|
6267
|
+
const touch = typeof window.matchMedia === "function" && window.matchMedia("(pointer: coarse)").matches;
|
|
6268
|
+
if (touch && navigator.canShare?.({ files: [file] })) {
|
|
6269
|
+
try {
|
|
6270
|
+
await navigator.share({ files: [file] });
|
|
6271
|
+
return "saved";
|
|
6272
|
+
} catch (error) {
|
|
6273
|
+
if (error.name === "AbortError") return "dismissed";
|
|
6274
|
+
}
|
|
6275
|
+
}
|
|
6276
|
+
const url = URL.createObjectURL(blob);
|
|
6277
|
+
const link = document.createElement("a");
|
|
6278
|
+
link.href = url;
|
|
6279
|
+
link.download = name;
|
|
6280
|
+
document.body.appendChild(link);
|
|
6281
|
+
link.click();
|
|
6282
|
+
link.remove();
|
|
6283
|
+
setTimeout(() => URL.revokeObjectURL(url), 1e4);
|
|
6284
|
+
return "saved";
|
|
6285
|
+
}
|
|
6286
|
+
function SaveQrButton({
|
|
6287
|
+
image,
|
|
6288
|
+
fileName,
|
|
6289
|
+
labels
|
|
6290
|
+
}) {
|
|
6291
|
+
const [state, setState] = react.useState("idle");
|
|
6292
|
+
const timer = react.useRef(null);
|
|
6293
|
+
react.useEffect(
|
|
6294
|
+
() => () => {
|
|
6295
|
+
if (timer.current) clearTimeout(timer.current);
|
|
6296
|
+
},
|
|
6297
|
+
[]
|
|
6298
|
+
);
|
|
6299
|
+
async function save() {
|
|
6300
|
+
setState("saving");
|
|
6301
|
+
try {
|
|
6302
|
+
const blob = await scannableFile(image);
|
|
6303
|
+
const extension = blob.type === "image/jpeg" ? "jpg" : "png";
|
|
6304
|
+
const outcome = await saveFile(blob, `${fileName}.${extension}`);
|
|
6305
|
+
setState(outcome === "saved" ? "saved" : "idle");
|
|
6306
|
+
} catch {
|
|
6307
|
+
setState("failed");
|
|
6308
|
+
}
|
|
6309
|
+
if (timer.current) clearTimeout(timer.current);
|
|
6310
|
+
timer.current = setTimeout(() => setState("idle"), 2500);
|
|
6311
|
+
}
|
|
6312
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-btn-secondary pollar-ramp-save-qr", disabled: state === "saving", onClick: save, children: [
|
|
6313
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6314
|
+
"path",
|
|
6315
|
+
{
|
|
6316
|
+
d: "M8 2v8m0 0 3-3m-3 3L5 7M3 12.5h10",
|
|
6317
|
+
stroke: "currentColor",
|
|
6318
|
+
strokeWidth: "1.6",
|
|
6319
|
+
strokeLinecap: "round",
|
|
6320
|
+
strokeLinejoin: "round"
|
|
6321
|
+
}
|
|
6322
|
+
) }),
|
|
6323
|
+
state === "saving" ? labels.saving : state === "saved" ? labels.saved : state === "failed" ? labels.failed : labels.save
|
|
6324
|
+
] });
|
|
6325
|
+
}
|
|
6043
6326
|
function scannableImageSrc(image) {
|
|
6044
6327
|
return image.encoding === "base64" ? `data:${image.mediaType};base64,${image.data}` : `data:${image.mediaType};charset=utf-8,${encodeURIComponent(image.data)}`;
|
|
6045
6328
|
}
|
|
@@ -6171,7 +6454,10 @@ function RampWidgetTemplate({
|
|
|
6171
6454
|
onRefresh,
|
|
6172
6455
|
onClose,
|
|
6173
6456
|
language: languageProp,
|
|
6174
|
-
confirmation = null
|
|
6457
|
+
confirmation = null,
|
|
6458
|
+
onCancelOrder,
|
|
6459
|
+
cancelling = false,
|
|
6460
|
+
cancelError = null
|
|
6175
6461
|
}) {
|
|
6176
6462
|
const language = useInheritedLanguage(languageProp);
|
|
6177
6463
|
const cssVars = buildModalCssVars(theme, accentColor, styleOverrides, "hero");
|
|
@@ -6179,6 +6465,12 @@ function RampWidgetTemplate({
|
|
|
6179
6465
|
const onramp = direction === "ONRAMP";
|
|
6180
6466
|
const sendUnit = onramp ? fiat?.currency : asset?.code;
|
|
6181
6467
|
const [detailsOpen, setDetailsOpen] = react.useState(false);
|
|
6468
|
+
const [viewing, setViewing] = react.useState(null);
|
|
6469
|
+
const [leaving, setLeaving] = react.useState(false);
|
|
6470
|
+
react.useEffect(() => {
|
|
6471
|
+
setViewing(null);
|
|
6472
|
+
setLeaving(false);
|
|
6473
|
+
}, [order?.id]);
|
|
6182
6474
|
const routeName = (quote) => quote.legs.map((leg) => core.rampLegTitle(leg, language)).join(" \xB7 ");
|
|
6183
6475
|
const rate = (() => {
|
|
6184
6476
|
if (!chosenQuote) return null;
|
|
@@ -6250,7 +6542,6 @@ function RampWidgetTemplate({
|
|
|
6250
6542
|
] : [];
|
|
6251
6543
|
const running = order?.legs.find((leg) => core.rampLegStatus(leg) === "active" && order.pendingAction?.legIndex !== leg.index);
|
|
6252
6544
|
const now = useNowEverySecond(step === "status" && !settled && !!running && running.etaSeconds !== null);
|
|
6253
|
-
const nextApproval = order && !settled ? core.rampNextApproval(order, language) : null;
|
|
6254
6545
|
const stopped = order ? core.rampOrderStopped(order) : false;
|
|
6255
6546
|
const receive = order ? core.rampOrderReceive(order) : null;
|
|
6256
6547
|
const waitsOnRecovery = order?.failure?.resolutionAction === "set_up_recovery";
|
|
@@ -6258,12 +6549,56 @@ function RampWidgetTemplate({
|
|
|
6258
6549
|
const payBy = view?.action?.kind === "FIAT_PAYMENT" && view.expiresAt ? Date.parse(view.expiresAt) : null;
|
|
6259
6550
|
useRenderAt(view?.canSign && view.expiresAt ? Date.parse(view.expiresAt) : null);
|
|
6260
6551
|
const stepsOpen = !!onStepSelect && step !== "status" && !isLoading && startingQuoteId === null && trustingAsset === null && walletBusy === null;
|
|
6552
|
+
const screens = order ? rampOrderScreens(order, language) : [];
|
|
6553
|
+
const completed = order?.state === "completed";
|
|
6554
|
+
const firstOpen = screens.findIndex((s) => s.status !== "done");
|
|
6555
|
+
const currentScreen = completed ? screens.length : firstOpen === -1 ? Math.max(0, screens.length - 1) : firstOpen;
|
|
6556
|
+
const shownScreen = viewing !== null && viewing < currentScreen ? viewing : currentScreen;
|
|
6557
|
+
const shown = screens[shownScreen];
|
|
6558
|
+
const askedInstead = order?.pendingAction?.kind === "KYC" || !!shown?.key.endsWith(":pay") && order?.pendingAction?.legIndex === shown.leg.index && !["FIAT_PAYMENT", "NONE"].includes(order.pendingAction.kind);
|
|
6559
|
+
const firstLeg = order?.legs[0];
|
|
6560
|
+
const payment = order?.pendingAction?.kind === "FIAT_PAYMENT" ? order.pendingAction.instructions : null;
|
|
6561
|
+
const qrFileName = [copy.screens.qrFile, payment?.amount, payment?.currency, order?.id.slice(-8)].filter(Boolean).join("-");
|
|
6562
|
+
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;
|
|
6563
|
+
const lastLeg = order?.legs[order.legs.length - 1];
|
|
6564
|
+
const arrivedText = lastLeg?.to.kind === "asset" ? copy.screens.arrived(CHAIN_NAME[lastLeg.to.chain] ?? lastLeg.to.chain) : copy.screens.paidOut;
|
|
6565
|
+
const requestClose = () => step === "status" && order && !settled ? setLeaving(true) : onClose();
|
|
6566
|
+
const cancellable = !!order && !settled && order.pendingAction?.kind !== "COSIGN_APPROVAL" && order.legs.every((leg) => leg.status !== "COMPLETED" && leg.status !== "HELD" && leg.paymentStatus !== "received");
|
|
6567
|
+
const doneText = (screen) => {
|
|
6568
|
+
const leg = screen.leg;
|
|
6569
|
+
const unit = (node) => node.kind === "fiat" ? node.currency : node.code;
|
|
6570
|
+
const inAmount = amountText(leg.amountInActual ?? leg.amountInPlanned, language);
|
|
6571
|
+
const outAmount = amountText(leg.amountOutActual ?? leg.amountOutPlanned, language);
|
|
6572
|
+
if (screen.key.endsWith(":pay"))
|
|
6573
|
+
return leg.kind === "PROVIDER_ONRAMP" ? copy.screens.paidDone(inAmount, unit(leg.from)) : copy.screens.sentDone(inAmount, unit(leg.from));
|
|
6574
|
+
if (screen.key.endsWith(":deliver"))
|
|
6575
|
+
return leg.to.kind === "asset" ? copy.screens.receivedDone(outAmount, leg.to.code, CHAIN_NAME[leg.to.chain] ?? leg.to.chain) : copy.screens.payoutDone(outAmount, leg.to.currency);
|
|
6576
|
+
return screen.kind === "action" ? copy.screens.signedDone : copy.screens.ranDone;
|
|
6577
|
+
};
|
|
6578
|
+
const finalNote = order?.legs.map((leg) => core.rampLegNote(leg, language)).find((note) => note !== null) ?? null;
|
|
6579
|
+
const screenRows = (screen) => screen.steps.length ? screen.steps.flatMap(
|
|
6580
|
+
(st) => st.hash ? [
|
|
6581
|
+
{
|
|
6582
|
+
label: core.rampStepTitle(st, screen.leg, language),
|
|
6583
|
+
value: shortHash(st.hash),
|
|
6584
|
+
href: explorerTxUrl2(stepChain(st.kind, screen.leg), st.hash, network),
|
|
6585
|
+
copyValue: st.hash
|
|
6586
|
+
}
|
|
6587
|
+
] : []
|
|
6588
|
+
) : screen.leg.onchainTxHash && !screen.key.endsWith(":pay") ? [
|
|
6589
|
+
{
|
|
6590
|
+
label: core.rampLegTitle(screen.leg, language),
|
|
6591
|
+
value: shortHash(screen.leg.onchainTxHash),
|
|
6592
|
+
href: explorerTxUrl2(legChain(screen.leg), screen.leg.onchainTxHash, network),
|
|
6593
|
+
copyValue: screen.leg.onchainTxHash
|
|
6594
|
+
}
|
|
6595
|
+
] : [];
|
|
6261
6596
|
const stepTitle = {
|
|
6262
6597
|
input: onramp ? copy.title.buy : copy.title.sell,
|
|
6263
6598
|
loading_quote: copy.title.finding,
|
|
6264
6599
|
select_route: copy.title.chooseRoute,
|
|
6265
6600
|
contact: copy.title.details,
|
|
6266
|
-
status:
|
|
6601
|
+
status: onramp ? copy.title.purchase : copy.title.sale,
|
|
6267
6602
|
error: copy.title.error
|
|
6268
6603
|
};
|
|
6269
6604
|
const stepSubtitle = {
|
|
@@ -6276,7 +6611,7 @@ function RampWidgetTemplate({
|
|
|
6276
6611
|
copy
|
|
6277
6612
|
)
|
|
6278
6613
|
),
|
|
6279
|
-
status:
|
|
6614
|
+
status: orderSummary ?? copy.subtitle.processing,
|
|
6280
6615
|
error: copy.subtitle.error
|
|
6281
6616
|
};
|
|
6282
6617
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-ramp-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
|
|
@@ -6327,7 +6662,7 @@ function RampWidgetTemplate({
|
|
|
6327
6662
|
)
|
|
6328
6663
|
}
|
|
6329
6664
|
),
|
|
6330
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick:
|
|
6665
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: requestClose, "aria-label": copy.close, 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: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
6331
6666
|
] })
|
|
6332
6667
|
] }),
|
|
6333
6668
|
flowStepIndex >= 0 && flowSteps.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-steps", children: [
|
|
@@ -6347,6 +6682,41 @@ function RampWidgetTemplate({
|
|
|
6347
6682
|
}
|
|
6348
6683
|
) }, label)) })
|
|
6349
6684
|
] }),
|
|
6685
|
+
step === "status" && screens.length > 0 && !(leaving && !settled) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-screens-nav", children: [
|
|
6686
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6687
|
+
"button",
|
|
6688
|
+
{
|
|
6689
|
+
type: "button",
|
|
6690
|
+
className: "pollar-ramp-screens-arrow",
|
|
6691
|
+
"data-hidden": shownScreen === 0 || void 0,
|
|
6692
|
+
disabled: shownScreen === 0,
|
|
6693
|
+
onClick: () => setViewing(shownScreen - 1),
|
|
6694
|
+
"aria-label": copy.back,
|
|
6695
|
+
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" }) })
|
|
6696
|
+
}
|
|
6697
|
+
),
|
|
6698
|
+
/* @__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(
|
|
6699
|
+
"li",
|
|
6700
|
+
{
|
|
6701
|
+
"data-done": i < currentScreen || completed && i === screens.length || void 0,
|
|
6702
|
+
"data-shown": i === shownScreen || void 0,
|
|
6703
|
+
"data-failed": screens[i]?.status === "failed" || void 0
|
|
6704
|
+
},
|
|
6705
|
+
key
|
|
6706
|
+
)) }),
|
|
6707
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6708
|
+
"button",
|
|
6709
|
+
{
|
|
6710
|
+
type: "button",
|
|
6711
|
+
className: "pollar-ramp-screens-arrow",
|
|
6712
|
+
"data-hidden": shownScreen >= currentScreen || void 0,
|
|
6713
|
+
disabled: shownScreen >= currentScreen,
|
|
6714
|
+
onClick: () => setViewing(shownScreen + 1 >= currentScreen ? null : shownScreen + 1),
|
|
6715
|
+
"aria-label": copy.screens.next,
|
|
6716
|
+
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: "m6 3 5 5-5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
6717
|
+
}
|
|
6718
|
+
)
|
|
6719
|
+
] }),
|
|
6350
6720
|
step === "input" && pendingOrders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "pollar-ramp-payment pollar-ramp-saved", "aria-label": copy.pendingAria, children: [
|
|
6351
6721
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: copy.pendingNote }),
|
|
6352
6722
|
pendingOrders.map((pending) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-saved-row", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6634,37 +7004,84 @@ function RampWidgetTemplate({
|
|
|
6634
7004
|
}
|
|
6635
7005
|
) })
|
|
6636
7006
|
] }),
|
|
6637
|
-
step === "status" && order && view && /* @__PURE__ */ jsxRuntime.
|
|
6638
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
7007
|
+
step === "status" && order && view && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-payment", children: leaving && !settled ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-leave", children: [
|
|
7008
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "pollar-ramp-screen-title", children: copy.leave.title }),
|
|
7009
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: copy.leave.note }),
|
|
7010
|
+
cancelError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-field-error", children: cancelError }),
|
|
7011
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: () => setLeaving(false), children: copy.leave.stay }),
|
|
7012
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onClose, children: copy.leave.exit }),
|
|
7013
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7014
|
+
"button",
|
|
7015
|
+
{
|
|
7016
|
+
type: "button",
|
|
7017
|
+
className: "pollar-ramp-leave-link",
|
|
7018
|
+
onClick: () => {
|
|
7019
|
+
setLeaving(false);
|
|
7020
|
+
onNewOrder();
|
|
7021
|
+
},
|
|
7022
|
+
children: copy.startAnother
|
|
7023
|
+
}
|
|
7024
|
+
),
|
|
7025
|
+
onCancelOrder && cancellable && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-ramp-leave-cancel", disabled: cancelling, onClick: onCancelOrder, children: cancelling ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7026
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
|
|
7027
|
+
" ",
|
|
7028
|
+
copy.leave.cancelling
|
|
7029
|
+
] }) : copy.leave.cancel })
|
|
7030
|
+
] }) : shownScreen === screens.length ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7031
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-final", children: [
|
|
7032
|
+
/* @__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(
|
|
7033
|
+
"path",
|
|
7034
|
+
{
|
|
7035
|
+
d: "M3 8.5 6.5 12 13 4.5",
|
|
7036
|
+
stroke: "currentColor",
|
|
7037
|
+
strokeWidth: "2",
|
|
7038
|
+
strokeLinecap: "round",
|
|
7039
|
+
strokeLinejoin: "round"
|
|
7040
|
+
}
|
|
7041
|
+
) }) }),
|
|
7042
|
+
receive && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-final-amount", children: copy.screens.received(`${amountText(receive.amount, language)} ${receive.unit}`) }),
|
|
7043
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: arrivedText }),
|
|
7044
|
+
finalNote && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: finalNote })
|
|
6667
7045
|
] }),
|
|
7046
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: onClose, children: copy.screens.finish }),
|
|
7047
|
+
/* @__PURE__ */ jsxRuntime.jsx(TxReview, { data: { title: "", kind: "other", rows: orderRows }, language })
|
|
7048
|
+
] }) : shownScreen < currentScreen ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7049
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-done", children: [
|
|
7050
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-done-mark", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "30", height: "30", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7051
|
+
"path",
|
|
7052
|
+
{
|
|
7053
|
+
d: "M3 8.5 6.5 12 13 4.5",
|
|
7054
|
+
stroke: "currentColor",
|
|
7055
|
+
strokeWidth: "2",
|
|
7056
|
+
strokeLinecap: "round",
|
|
7057
|
+
strokeLinejoin: "round"
|
|
7058
|
+
}
|
|
7059
|
+
) }) }),
|
|
7060
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "pollar-ramp-done-title", children: screens[shownScreen].title }),
|
|
7061
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: doneText(screens[shownScreen]) })
|
|
7062
|
+
] }),
|
|
7063
|
+
screenRows(screens[shownScreen]).length > 0 && /* @__PURE__ */ jsxRuntime.jsx(TxReview, { data: { title: "", kind: "other", rows: screenRows(screens[shownScreen]) }, language })
|
|
7064
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7065
|
+
shown && /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "pollar-ramp-screen-title", "data-status": shown.status, children: askedInstead ? view.title : shown.title }),
|
|
7066
|
+
shown?.status === "failed" && shown.leg.failure && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-field-error", children: core.rampFailureReason(shown.leg.failure, language) }),
|
|
7067
|
+
shown?.preparing && !settled && !order.failure && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-wait", children: [
|
|
7068
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner", "aria-label": copy.inProgress }),
|
|
7069
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: copy.screens.preparing })
|
|
7070
|
+
] }),
|
|
7071
|
+
shown?.kind === "wait" && !settled && !order.failure && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-wait", children: [
|
|
7072
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner", "aria-label": copy.inProgress }),
|
|
7073
|
+
core.rampLegTimeLeft(shown.leg, now) !== null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-leg-eta", children: copy.timeLeft(core.rampLegTimeLeft(shown.leg, now)) }),
|
|
7074
|
+
core.rampLegNote(shown.leg, language) && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: core.rampLegNote(shown.leg, language) }),
|
|
7075
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: copy.screens.updatesItself })
|
|
7076
|
+
] }),
|
|
7077
|
+
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: [
|
|
7078
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-step-title", children: core.rampStepTitle(s, shown.leg, language) }),
|
|
7079
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-ramp-step-state", children: [
|
|
7080
|
+
s.status === "confirming" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-hidden": true }),
|
|
7081
|
+
core.rampStepStatusText(s, language)
|
|
7082
|
+
] })
|
|
7083
|
+
] }, s.kind)) }),
|
|
7084
|
+
confirmation && /* @__PURE__ */ jsxRuntime.jsx(InlineConfirm, { confirmation, language, network }),
|
|
6668
7085
|
order.failure && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-field", children: [
|
|
6669
7086
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-payment-label", children: copy.whatToDo }),
|
|
6670
7087
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: core.rampOrderResolutionText(order, language) }),
|
|
@@ -6704,7 +7121,20 @@ function RampWidgetTemplate({
|
|
|
6704
7121
|
alt: copy.paymentQr,
|
|
6705
7122
|
style: { width: "100%", maxWidth: 220, height: "auto", display: "block", margin: "0 auto" }
|
|
6706
7123
|
}
|
|
6707
|
-
) })
|
|
7124
|
+
) }),
|
|
7125
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7126
|
+
SaveQrButton,
|
|
7127
|
+
{
|
|
7128
|
+
image: view.scannable.image,
|
|
7129
|
+
fileName: qrFileName,
|
|
7130
|
+
labels: {
|
|
7131
|
+
save: copy.screens.saveQr,
|
|
7132
|
+
saving: copy.screens.savingQr,
|
|
7133
|
+
saved: copy.screens.savedQr,
|
|
7134
|
+
failed: copy.screens.saveQrFailed
|
|
7135
|
+
}
|
|
7136
|
+
}
|
|
7137
|
+
)
|
|
6708
7138
|
] }),
|
|
6709
7139
|
!settled && view.codeMissing && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", style: { color: "var(--pollar-error-text)" }, children: copy.codeMissing }),
|
|
6710
7140
|
!settled && view.scannable?.payload && view.scannable.payloadLabel && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-field", children: [
|
|
@@ -6725,7 +7155,14 @@ function RampWidgetTemplate({
|
|
|
6725
7155
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-payment-label", children: view.pasteCode.label }),
|
|
6726
7156
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-payment-value", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
6727
7157
|
/* @__PURE__ */ jsxRuntime.jsx("code", { style: { flex: 1, wordBreak: "break-all" }, children: view.pasteCode.value }),
|
|
6728
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7158
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7159
|
+
CopyButton,
|
|
7160
|
+
{
|
|
7161
|
+
value: view.pasteCode.value,
|
|
7162
|
+
label: copy.copyLabel(view.pasteCode.label),
|
|
7163
|
+
language
|
|
7164
|
+
}
|
|
7165
|
+
)
|
|
6729
7166
|
] }) })
|
|
6730
7167
|
] }),
|
|
6731
7168
|
!settled && view.details.map((d) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-field", children: [
|
|
@@ -6756,12 +7193,8 @@ function RampWidgetTemplate({
|
|
|
6756
7193
|
),
|
|
6757
7194
|
!settled && order.pendingAction?.kind === "KYC" && !view.link && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: view.note ?? copy.providerReviewing }),
|
|
6758
7195
|
pollTrouble && !settled && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: copy.serverTrouble }),
|
|
6759
|
-
errorMsg && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-field-error", children: errorMsg })
|
|
6760
|
-
|
|
6761
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onNewOrder, children: copy.startAnother }),
|
|
6762
|
-
!stopped && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-payment-note", children: copy.keepsGoing })
|
|
6763
|
-
] })
|
|
6764
|
-
] }),
|
|
7196
|
+
errorMsg && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-field-error", children: errorMsg })
|
|
7197
|
+
] }) }),
|
|
6765
7198
|
step === "error" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6766
7199
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: errorMsg ?? copy.somethingWrong }),
|
|
6767
7200
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-actions", children: [
|
|
@@ -7483,6 +7916,8 @@ function RampWidget({ onClose, language: languageProp, initial }) {
|
|
|
7483
7916
|
const [trustingAsset, setTrustingAsset] = react.useState(null);
|
|
7484
7917
|
const [walletBusy, setWalletBusy] = react.useState(null);
|
|
7485
7918
|
const [retrying, setRetrying] = react.useState(false);
|
|
7919
|
+
const [cancelling, setCancelling] = react.useState(false);
|
|
7920
|
+
const [cancelError, setCancelError] = react.useState(null);
|
|
7486
7921
|
const [awaitingAccount, setAwaitingAccount] = react.useState(null);
|
|
7487
7922
|
const [pollTrouble, setPollTrouble] = react.useState(false);
|
|
7488
7923
|
const [pollKey, setPollKey] = react.useState(0);
|
|
@@ -7894,6 +8329,19 @@ function RampWidget({ onClose, language: languageProp, initial }) {
|
|
|
7894
8329
|
setRetrying(false);
|
|
7895
8330
|
}
|
|
7896
8331
|
}
|
|
8332
|
+
async function handleCancelOrder() {
|
|
8333
|
+
if (!order || cancelling) return;
|
|
8334
|
+
setCancelling(true);
|
|
8335
|
+
setCancelError(null);
|
|
8336
|
+
try {
|
|
8337
|
+
setOrder(await client.cancelRampOrder(order.id));
|
|
8338
|
+
void loadPendingOrders();
|
|
8339
|
+
} catch (error) {
|
|
8340
|
+
setCancelError(rampErrorMessage(error, copy.cancelOrderFailed, copy, language));
|
|
8341
|
+
} finally {
|
|
8342
|
+
setCancelling(false);
|
|
8343
|
+
}
|
|
8344
|
+
}
|
|
7897
8345
|
async function handleRequote() {
|
|
7898
8346
|
setOrder(null);
|
|
7899
8347
|
await handleFindRoute();
|
|
@@ -7926,8 +8374,7 @@ function RampWidget({ onClose, language: languageProp, initial }) {
|
|
|
7926
8374
|
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
8375
|
const stepLabel = {
|
|
7928
8376
|
select_route: copy.steps.route,
|
|
7929
|
-
contact: copy.steps.details
|
|
7930
|
-
status: copy.steps.complete
|
|
8377
|
+
contact: copy.steps.details
|
|
7931
8378
|
};
|
|
7932
8379
|
const label = stepLabel[step];
|
|
7933
8380
|
if (verifying) {
|
|
@@ -8065,7 +8512,10 @@ function RampWidget({ onClose, language: languageProp, initial }) {
|
|
|
8065
8512
|
},
|
|
8066
8513
|
onRefresh: () => void handleRefresh(),
|
|
8067
8514
|
onClose,
|
|
8068
|
-
confirmation
|
|
8515
|
+
confirmation,
|
|
8516
|
+
onCancelOrder: () => void handleCancelOrder(),
|
|
8517
|
+
cancelling,
|
|
8518
|
+
cancelError
|
|
8069
8519
|
}
|
|
8070
8520
|
) });
|
|
8071
8521
|
}
|
|
@@ -10332,8 +10782,6 @@ function SwapModal({ onClose, initial }) {
|
|
|
10332
10782
|
void refreshAssets();
|
|
10333
10783
|
}, [refreshWalletBalance, refreshAssets]);
|
|
10334
10784
|
const loadConfig = react.useCallback(() => {
|
|
10335
|
-
setVenues(null);
|
|
10336
|
-
setSolanaVenues(null);
|
|
10337
10785
|
return Promise.all([
|
|
10338
10786
|
getSwapConfig().then(setVenues).catch(() => setVenues([])),
|
|
10339
10787
|
// treat a failed config as "unavailable"
|
|
@@ -10471,10 +10919,12 @@ function SwapModal({ onClose, initial }) {
|
|
|
10471
10919
|
setSelectedBuy(seeded);
|
|
10472
10920
|
return;
|
|
10473
10921
|
}
|
|
10474
|
-
|
|
10475
|
-
|
|
10922
|
+
const sellKey = selectedSell ? optKey(selectedSell) : "";
|
|
10923
|
+
if (!selectedBuy || optKey(selectedBuy) === sellKey || !buyOptions.some((o) => optKey(o) === optKey(selectedBuy))) {
|
|
10924
|
+
const next = buyOptions.find((o) => optKey(o) !== sellKey) ?? null;
|
|
10925
|
+
if (next !== selectedBuy) setSelectedBuy(next);
|
|
10476
10926
|
}
|
|
10477
|
-
}, [buyOptions, selectedBuy, isLoadingData]);
|
|
10927
|
+
}, [buyOptions, selectedBuy, selectedSell, isLoadingData]);
|
|
10478
10928
|
function addCustomToken(code, issuer) {
|
|
10479
10929
|
const c = code.trim().toUpperCase();
|
|
10480
10930
|
const i = issuer.trim();
|
|
@@ -10534,8 +10984,13 @@ function SwapModal({ onClose, initial }) {
|
|
|
10534
10984
|
};
|
|
10535
10985
|
}, [quotedSolana, step]);
|
|
10536
10986
|
react.useEffect(() => {
|
|
10537
|
-
if (
|
|
10538
|
-
|
|
10987
|
+
if (configLoading) return;
|
|
10988
|
+
if (chains.length === 0 || chains.includes(chain)) return;
|
|
10989
|
+
setChain(chains[0]);
|
|
10990
|
+
setProvider("auto");
|
|
10991
|
+
setQuotes([]);
|
|
10992
|
+
setSolanaQuotes([]);
|
|
10993
|
+
}, [chains, chain, configLoading]);
|
|
10539
10994
|
function handleChainChange(next) {
|
|
10540
10995
|
sellSeed.current = void 0;
|
|
10541
10996
|
buySeed.current = void 0;
|
|
@@ -13997,6 +14452,7 @@ var COSIGN_COPY = {
|
|
|
13997
14452
|
approve: "Approve",
|
|
13998
14453
|
approving: "Approving...",
|
|
13999
14454
|
genericError: "Something went wrong. Please try again.",
|
|
14455
|
+
unreachable: "We could not reach Pollar, so nothing was approved. Check your connection and approve again.",
|
|
14000
14456
|
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
14457
|
linkDevice: "Link this device",
|
|
14002
14458
|
transaction: "Transaction",
|
|
@@ -14050,6 +14506,7 @@ var COSIGN_COPY = {
|
|
|
14050
14506
|
approve: "Aprobar",
|
|
14051
14507
|
approving: "Aprobando...",
|
|
14052
14508
|
genericError: "Algo sali\xF3 mal. Intenta de nuevo.",
|
|
14509
|
+
unreachable: "No pudimos conectar con Pollar, as\xED que no se aprob\xF3 nada. Revisa tu conexi\xF3n y aprueba de nuevo.",
|
|
14053
14510
|
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
14511
|
linkDevice: "Vincular este dispositivo",
|
|
14055
14512
|
transaction: "Transacci\xF3n",
|
|
@@ -14103,6 +14560,7 @@ var COSIGN_COPY = {
|
|
|
14103
14560
|
approve: "Aprovar",
|
|
14104
14561
|
approving: "Aprovando...",
|
|
14105
14562
|
genericError: "Algo deu errado. Tente novamente.",
|
|
14563
|
+
unreachable: "N\xE3o conseguimos conectar \xE0 Pollar, ent\xE3o nada foi aprovado. Verifique sua conex\xE3o e aprove novamente.",
|
|
14106
14564
|
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
14565
|
linkDevice: "Vincular este dispositivo",
|
|
14108
14566
|
transaction: "Transa\xE7\xE3o",
|
|
@@ -14456,6 +14914,11 @@ function CosignModal({ nextStep = null, onClose }) {
|
|
|
14456
14914
|
try {
|
|
14457
14915
|
await action(request);
|
|
14458
14916
|
} catch (err) {
|
|
14917
|
+
if (core.isPollarNetworkError(err) || err instanceof TypeError) {
|
|
14918
|
+
setError(COSIGN_COPY[language].unreachable);
|
|
14919
|
+
void refresh().catch(() => void 0);
|
|
14920
|
+
return;
|
|
14921
|
+
}
|
|
14459
14922
|
setError(
|
|
14460
14923
|
core.transactionErrorMessage(core.isPollarApiError(err) ? err.code : null, err instanceof Error ? err.message : null, language)
|
|
14461
14924
|
);
|
|
@@ -14465,7 +14928,7 @@ function CosignModal({ nextStep = null, onClose }) {
|
|
|
14465
14928
|
setBusy(null);
|
|
14466
14929
|
}
|
|
14467
14930
|
},
|
|
14468
|
-
[]
|
|
14931
|
+
[language, refresh]
|
|
14469
14932
|
);
|
|
14470
14933
|
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
14471
14934
|
CosignModalTemplate,
|
|
@@ -14696,6 +15159,9 @@ var RECOVERY_COPY = {
|
|
|
14696
15159
|
acceptRisks: "I understand and accept these risks",
|
|
14697
15160
|
recoverEmailIntro: (address) => `We'll email a code to ${address}. The code goes straight to the wallet provider, encrypted on this device.`,
|
|
14698
15161
|
sendCode: "Send code",
|
|
15162
|
+
sendCodeIn: (seconds) => `Send code in ${seconds}s`,
|
|
15163
|
+
resendCode: "Send a new code",
|
|
15164
|
+
resendCodeIn: (seconds) => `Send a new code in ${seconds}s`,
|
|
14699
15165
|
recover: "Recover",
|
|
14700
15166
|
back: "Back",
|
|
14701
15167
|
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 +15214,9 @@ var RECOVERY_COPY = {
|
|
|
14748
15214
|
acceptRisks: "Entiendo y acepto estos riesgos",
|
|
14749
15215
|
recoverEmailIntro: (address) => `Te enviaremos un c\xF3digo a ${address}. El c\xF3digo va directo al proveedor de la billetera, cifrado en este dispositivo.`,
|
|
14750
15216
|
sendCode: "Enviar c\xF3digo",
|
|
15217
|
+
sendCodeIn: (seconds) => `Enviar c\xF3digo en ${seconds} s`,
|
|
15218
|
+
resendCode: "Enviar otro c\xF3digo",
|
|
15219
|
+
resendCodeIn: (seconds) => `Enviar otro c\xF3digo en ${seconds} s`,
|
|
14751
15220
|
recover: "Recuperar",
|
|
14752
15221
|
back: "Atr\xE1s",
|
|
14753
15222
|
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 +15269,9 @@ var RECOVERY_COPY = {
|
|
|
14800
15269
|
acceptRisks: "Entendo e aceito esses riscos",
|
|
14801
15270
|
recoverEmailIntro: (address) => `Vamos enviar um c\xF3digo para ${address}. O c\xF3digo vai direto para o provedor da carteira, criptografado neste dispositivo.`,
|
|
14802
15271
|
sendCode: "Enviar c\xF3digo",
|
|
15272
|
+
sendCodeIn: (seconds) => `Enviar c\xF3digo em ${seconds} s`,
|
|
15273
|
+
resendCode: "Enviar outro c\xF3digo",
|
|
15274
|
+
resendCodeIn: (seconds) => `Enviar outro c\xF3digo em ${seconds} s`,
|
|
14803
15275
|
recover: "Recuperar",
|
|
14804
15276
|
back: "Voltar",
|
|
14805
15277
|
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 +15427,25 @@ function RecoveryModalTemplate(p) {
|
|
|
14955
15427
|
copy,
|
|
14956
15428
|
busy: p.busy,
|
|
14957
15429
|
id: "recover-send",
|
|
14958
|
-
label: copy.sendCode,
|
|
15430
|
+
label: p.sendWaitSeconds ? copy.sendCodeIn(p.sendWaitSeconds) : copy.sendCode,
|
|
14959
15431
|
kind: "primary",
|
|
14960
|
-
onClick: p.onSendRecoveryCode
|
|
15432
|
+
onClick: p.onSendRecoveryCode,
|
|
15433
|
+
disabled: p.sendWaitSeconds > 0
|
|
14961
15434
|
}
|
|
14962
|
-
) : /* @__PURE__ */ jsxRuntime.
|
|
15435
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
15436
|
+
/* @__PURE__ */ jsxRuntime.jsx(CodeForm, { copy, busy: p.busy, id: "recover-code", label: copy.recover, onSubmit: p.onRecoverWithCode }),
|
|
15437
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
15438
|
+
Button,
|
|
15439
|
+
{
|
|
15440
|
+
copy,
|
|
15441
|
+
busy: p.busy,
|
|
15442
|
+
id: "recover-send",
|
|
15443
|
+
label: p.sendWaitSeconds ? copy.resendCodeIn(p.sendWaitSeconds) : copy.resendCode,
|
|
15444
|
+
onClick: p.onSendRecoveryCode,
|
|
15445
|
+
disabled: p.sendWaitSeconds > 0
|
|
15446
|
+
}
|
|
15447
|
+
)
|
|
15448
|
+
] }),
|
|
14963
15449
|
/* @__PURE__ */ jsxRuntime.jsx(Button, { copy, busy: p.busy, id: "back", label: copy.back, onClick: () => p.onView("overview") })
|
|
14964
15450
|
] });
|
|
14965
15451
|
} else if (p.view === "email") {
|
|
@@ -14971,7 +15457,7 @@ function RecoveryModalTemplate(p) {
|
|
|
14971
15457
|
className: "pollar-recovery-row",
|
|
14972
15458
|
onSubmit: (e) => {
|
|
14973
15459
|
e.preventDefault();
|
|
14974
|
-
p.onSendEmailCode();
|
|
15460
|
+
if (!p.sendWaitSeconds) p.onSendEmailCode();
|
|
14975
15461
|
},
|
|
14976
15462
|
children: [
|
|
14977
15463
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -14991,15 +15477,28 @@ function RecoveryModalTemplate(p) {
|
|
|
14991
15477
|
copy,
|
|
14992
15478
|
busy: p.busy,
|
|
14993
15479
|
id: "email-send",
|
|
14994
|
-
label: copy.sendCode,
|
|
15480
|
+
label: p.sendWaitSeconds ? copy.sendCodeIn(p.sendWaitSeconds) : copy.sendCode,
|
|
14995
15481
|
kind: "primary",
|
|
14996
15482
|
onClick: p.onSendEmailCode,
|
|
14997
|
-
disabled: !p.emailDraft.trim()
|
|
15483
|
+
disabled: !p.emailDraft.trim() || p.sendWaitSeconds > 0
|
|
14998
15484
|
}
|
|
14999
15485
|
)
|
|
15000
15486
|
]
|
|
15001
15487
|
}
|
|
15002
|
-
) : /* @__PURE__ */ jsxRuntime.
|
|
15488
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
15489
|
+
/* @__PURE__ */ jsxRuntime.jsx(CodeForm, { copy, busy: p.busy, id: "email-confirm", label: copy.confirm, onSubmit: p.onConfirmEmail }),
|
|
15490
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
15491
|
+
Button,
|
|
15492
|
+
{
|
|
15493
|
+
copy,
|
|
15494
|
+
busy: p.busy,
|
|
15495
|
+
id: "email-send",
|
|
15496
|
+
label: p.sendWaitSeconds ? copy.resendCodeIn(p.sendWaitSeconds) : copy.resendCode,
|
|
15497
|
+
onClick: p.onSendEmailCode,
|
|
15498
|
+
disabled: p.sendWaitSeconds > 0
|
|
15499
|
+
}
|
|
15500
|
+
)
|
|
15501
|
+
] }),
|
|
15003
15502
|
/* @__PURE__ */ jsxRuntime.jsx(Button, { copy, busy: p.busy, id: "back", label: copy.back, onClick: () => p.onView("overview") })
|
|
15004
15503
|
] });
|
|
15005
15504
|
} else if (p.view === "export") {
|
|
@@ -15142,6 +15641,7 @@ function RecoveryModal({ onClose }) {
|
|
|
15142
15641
|
const [emailDraft, setEmailDraft] = react.useState("");
|
|
15143
15642
|
const [codeSent, setCodeSent] = react.useState(false);
|
|
15144
15643
|
const [phrase, setPhrase] = react.useState(null);
|
|
15644
|
+
const [now, setNow] = react.useState(() => Date.now());
|
|
15145
15645
|
const load = react.useCallback(async () => {
|
|
15146
15646
|
const client = getClient();
|
|
15147
15647
|
const [nextState, nextDevices, key] = await Promise.all([
|
|
@@ -15184,6 +15684,14 @@ function RecoveryModal({ onClose }) {
|
|
|
15184
15684
|
},
|
|
15185
15685
|
[load]
|
|
15186
15686
|
);
|
|
15687
|
+
const codeEmail = view === "recover-email" ? state?.email.address ?? "" : emailDraft.trim();
|
|
15688
|
+
const codeAvailableAt = codeEmail ? recovery.codeAvailableAt(codeEmail) : 0;
|
|
15689
|
+
const sendWaitSeconds = codeAvailableAt > now ? Math.ceil((codeAvailableAt - now) / 1e3) : 0;
|
|
15690
|
+
react.useEffect(() => {
|
|
15691
|
+
if (!codeAvailableAt) return;
|
|
15692
|
+
const timer = setInterval(() => setNow(Date.now()), 1e3);
|
|
15693
|
+
return () => clearInterval(timer);
|
|
15694
|
+
}, [codeAvailableAt]);
|
|
15187
15695
|
const enrolled = !!thisDeviceKey && !!devices?.devices.some((d) => d.publicKey.toLowerCase() === thisDeviceKey);
|
|
15188
15696
|
const [awaitingApproval, setAwaitingApproval] = react.useState(false);
|
|
15189
15697
|
react.useEffect(() => {
|
|
@@ -15218,6 +15726,7 @@ function RecoveryModal({ onClose }) {
|
|
|
15218
15726
|
notice,
|
|
15219
15727
|
emailDraft,
|
|
15220
15728
|
codeSent,
|
|
15729
|
+
sendWaitSeconds,
|
|
15221
15730
|
phrase,
|
|
15222
15731
|
onView: (next) => {
|
|
15223
15732
|
setError(null);
|
|
@@ -15230,8 +15739,12 @@ function RecoveryModal({ onClose }) {
|
|
|
15230
15739
|
onAddPasskey: () => void run("passkey", () => recovery.addPasskey(), { notice: copy.passkeyAdded }),
|
|
15231
15740
|
onRemovePasskey: (id) => void run(`passkey:${id}`, () => recovery.removePasskey(id)),
|
|
15232
15741
|
onSendEmailCode: () => void run("email-send", async () => {
|
|
15233
|
-
|
|
15234
|
-
|
|
15742
|
+
try {
|
|
15743
|
+
await recovery.startEmail(emailDraft.trim());
|
|
15744
|
+
setCodeSent(true);
|
|
15745
|
+
} finally {
|
|
15746
|
+
setNow(Date.now());
|
|
15747
|
+
}
|
|
15235
15748
|
}),
|
|
15236
15749
|
onConfirmEmail: (code) => void run("email-confirm", () => recovery.confirmEmail(code.trim()), { notice: copy.emailConfirmed, view: "overview" }),
|
|
15237
15750
|
onApproveDevice: (id) => void run(`approve:${id}`, () => recovery.approveDevice(id), { notice: copy.deviceAdded }),
|
|
@@ -15248,8 +15761,12 @@ function RecoveryModal({ onClose }) {
|
|
|
15248
15761
|
notice: copy.recovered
|
|
15249
15762
|
}),
|
|
15250
15763
|
onSendRecoveryCode: () => void run("recover-send", async () => {
|
|
15251
|
-
|
|
15252
|
-
|
|
15764
|
+
try {
|
|
15765
|
+
await recovery.startEmailRecovery();
|
|
15766
|
+
setCodeSent(true);
|
|
15767
|
+
} finally {
|
|
15768
|
+
setNow(Date.now());
|
|
15769
|
+
}
|
|
15253
15770
|
}),
|
|
15254
15771
|
onRecoverWithCode: (code) => void run("recover-code", () => recovery.recoverWithEmailCode(code.trim()), {
|
|
15255
15772
|
notice: copy.recovered,
|
|
@@ -16472,31 +16989,58 @@ function PollarProvider({
|
|
|
16472
16989
|
}, [pollarClient, hasSession, walletAddress, custodyMigrationTick]);
|
|
16473
16990
|
const refreshWalletBalance = react.useCallback(() => pollarClient.refreshBalance(), [pollarClient, walletAddress]);
|
|
16474
16991
|
const refreshAssets = react.useCallback(() => pollarClient.refreshAssets(), [pollarClient, walletAddress]);
|
|
16992
|
+
const clientMethods = react.useMemo(
|
|
16993
|
+
() => ({
|
|
16994
|
+
createWallet: (options) => pollarClient.createWallet(options),
|
|
16995
|
+
login: (options) => pollarClient.login(options),
|
|
16996
|
+
logout: () => pollarClient.logout(),
|
|
16997
|
+
buildTx: (operation, params, options) => pollarClient.buildTx(operation, params, options),
|
|
16998
|
+
signAndSubmitTx: (unsignedXdr) => pollarClient.signAndSubmitTx(unsignedXdr),
|
|
16999
|
+
signTx: (unsignedXdr) => pollarClient.signTx(unsignedXdr),
|
|
17000
|
+
submitTx: (signedXdr) => pollarClient.submitTx(signedXdr),
|
|
17001
|
+
buildAndSignAndSubmitTx: (operation, params, options) => pollarClient.buildAndSignAndSubmitTx(operation, params, options),
|
|
17002
|
+
runTx: (operation, params, options) => pollarClient.runTx(operation, params, options),
|
|
17003
|
+
sendPayment: (params) => pollarClient.sendPayment(params),
|
|
17004
|
+
setTrustline: (asset, opts) => pollarClient.setTrustline(asset, opts),
|
|
17005
|
+
getSwapConfig: () => pollarClient.getSwapConfig(),
|
|
17006
|
+
getSwapTokens: () => pollarClient.getSwapTokens(),
|
|
17007
|
+
getSwapQuote: (params) => pollarClient.getSwapQuote(params),
|
|
17008
|
+
swap: (quote, opts) => pollarClient.swap(quote, opts),
|
|
17009
|
+
getSolanaSwapConfig: () => pollarClient.getSolanaSwapConfig(),
|
|
17010
|
+
getSolanaSwapQuote: (params) => pollarClient.getSolanaSwapQuote(params),
|
|
17011
|
+
swapSolana: (quote, opts) => pollarClient.swapSolana(quote, opts),
|
|
17012
|
+
getSolanaSwapOptions: () => pollarClient.getSolanaSwapOptions(),
|
|
17013
|
+
getSwapStatus: (idempotencyKey) => pollarClient.getSwapStatus(idempotencyKey),
|
|
17014
|
+
getEarnProviders: () => pollarClient.getEarnProviders(),
|
|
17015
|
+
getEarnOpportunities: (provider) => pollarClient.getEarnOpportunities(provider).then(remembered),
|
|
17016
|
+
getEarnPosition: (params) => pollarClient.getEarnPosition(params),
|
|
17017
|
+
earnDeposit: (params) => pollarClient.earnDeposit(params),
|
|
17018
|
+
earnWithdraw: (params) => pollarClient.earnWithdraw(params),
|
|
17019
|
+
getSolanaEarnProviders: () => pollarClient.getSolanaEarnProviders(),
|
|
17020
|
+
getSolanaEarnOpportunities: () => pollarClient.getSolanaEarnOpportunities().then(remembered),
|
|
17021
|
+
getSolanaEarnPosition: (opportunity) => pollarClient.getSolanaEarnPosition(opportunity),
|
|
17022
|
+
earnSolanaDeposit: (params) => pollarClient.earnSolanaDeposit(params),
|
|
17023
|
+
earnSolanaWithdraw: (params) => pollarClient.earnSolanaWithdraw(params),
|
|
17024
|
+
setNetwork: (network) => pollarClient.setNetwork(network)
|
|
17025
|
+
}),
|
|
17026
|
+
[pollarClient]
|
|
17027
|
+
);
|
|
16475
17028
|
const contextValue = react.useMemo(() => {
|
|
16476
17029
|
const styles = resolvedConfig.styles ?? {};
|
|
16477
17030
|
return {
|
|
17031
|
+
...clientMethods,
|
|
16478
17032
|
// session
|
|
16479
17033
|
wallet: pollarClient.getWallet(),
|
|
16480
17034
|
wallets: pollarClient.getWallets(),
|
|
16481
17035
|
isAuthenticated: hasSession,
|
|
16482
17036
|
hasWallet: pollarClient.hasWallet(),
|
|
16483
|
-
createWallet: (options) => pollarClient.createWallet(options),
|
|
16484
17037
|
verified,
|
|
16485
17038
|
// client
|
|
16486
17039
|
getClient,
|
|
16487
17040
|
// auth
|
|
16488
|
-
login: (options) => pollarClient.login(options),
|
|
16489
|
-
logout: () => pollarClient.logout(),
|
|
16490
17041
|
openLoginModal: () => setLoginModalOpen(true),
|
|
16491
17042
|
// transactions
|
|
16492
17043
|
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
17044
|
openTxModal: () => setTransactionModalOpen(true),
|
|
16501
17045
|
// tx history
|
|
16502
17046
|
txHistory,
|
|
@@ -16511,7 +17055,6 @@ function PollarProvider({
|
|
|
16511
17055
|
// enabled assets
|
|
16512
17056
|
enabledAssets,
|
|
16513
17057
|
refreshAssets,
|
|
16514
|
-
setTrustline: (asset, opts) => pollarClient.setTrustline(asset, opts),
|
|
16515
17058
|
openEnabledAssetsModal: () => setEnabledAssetsModalOpen(true),
|
|
16516
17059
|
// send / receive
|
|
16517
17060
|
openSendModal: (options) => {
|
|
@@ -16525,15 +17068,6 @@ function PollarProvider({
|
|
|
16525
17068
|
setReceiveModalOpen(true);
|
|
16526
17069
|
},
|
|
16527
17070
|
// 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
17071
|
openSwapModal: (options) => {
|
|
16538
17072
|
setSwapModalOptions(options);
|
|
16539
17073
|
pollarClient.resetTransactionState();
|
|
@@ -16546,16 +17080,6 @@ function PollarProvider({
|
|
|
16546
17080
|
setBridgeModalOpen(true);
|
|
16547
17081
|
},
|
|
16548
17082
|
// 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
17083
|
openEarnModal: (options) => {
|
|
16560
17084
|
setEarnModalOptions(options);
|
|
16561
17085
|
pollarClient.resetTransactionState();
|
|
@@ -16587,7 +17111,6 @@ function PollarProvider({
|
|
|
16587
17111
|
openDistributionRulesModal: () => setDistributionRulesModalOpen(true),
|
|
16588
17112
|
// network
|
|
16589
17113
|
network: networkState.step === "connected" ? networkState.network : "testnet",
|
|
16590
|
-
setNetwork: (network) => pollarClient.setNetwork(network),
|
|
16591
17114
|
// kyc
|
|
16592
17115
|
openKycModal: (options = {}) => {
|
|
16593
17116
|
setKycModalOptions(options);
|
|
@@ -16606,6 +17129,7 @@ function PollarProvider({
|
|
|
16606
17129
|
adapters
|
|
16607
17130
|
};
|
|
16608
17131
|
}, [
|
|
17132
|
+
clientMethods,
|
|
16609
17133
|
walletAddress,
|
|
16610
17134
|
walletProvisioning,
|
|
16611
17135
|
recovery,
|