@pollar/react 0.12.1-rc.6 → 0.12.1-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -10
- package/dist/index.css +138 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +401 -249
- package/dist/index.d.ts +401 -249
- package/dist/index.js +949 -101
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +950 -104
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
var core = require('@pollar/core');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var reactDom = require('react-dom');
|
|
7
8
|
var browser = require('@simplewebauthn/browser');
|
|
8
9
|
|
|
9
10
|
var __create = Object.create;
|
|
@@ -1205,9 +1206,18 @@ var COMMONS_COPY = {
|
|
|
1205
1206
|
|
|
1206
1207
|
// src/language-context.ts
|
|
1207
1208
|
var ModalLanguageContext = react.createContext(null);
|
|
1208
|
-
function useProviderLanguage(client, dashboard) {
|
|
1209
|
-
const
|
|
1210
|
-
|
|
1209
|
+
function useProviderLanguage(client, dashboard, language) {
|
|
1210
|
+
const subscribe = react.useCallback(
|
|
1211
|
+
(onChange) => typeof client.onLocaleChange === "function" ? client.onLocaleChange(onChange) : () => {
|
|
1212
|
+
},
|
|
1213
|
+
[client]
|
|
1214
|
+
);
|
|
1215
|
+
const getLocale = () => typeof client.getLocale === "function" ? client.getLocale() : void 0;
|
|
1216
|
+
const locale = react.useSyncExternalStore(subscribe, getLocale, getLocale);
|
|
1217
|
+
return react.useMemo(
|
|
1218
|
+
() => core.resolveLanguage({ dashboard, code: [language, locale], device: deviceLanguageTag() }),
|
|
1219
|
+
[dashboard, language, locale]
|
|
1220
|
+
);
|
|
1211
1221
|
}
|
|
1212
1222
|
function useInheritedLanguage(language) {
|
|
1213
1223
|
const inherited = react.useContext(ModalLanguageContext);
|
|
@@ -1272,7 +1282,7 @@ var PollarModalFooter = ({ language: languageProp }) => {
|
|
|
1272
1282
|
/* @__PURE__ */ jsxRuntime.jsx("img", { src: LOGO_POLLAR_WORDMARK_ON_DARK, alt: "Pollar", className: "pollar-footer-logo pollar-logo-on-dark" }),
|
|
1273
1283
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-footer-version", children: [
|
|
1274
1284
|
"v",
|
|
1275
|
-
"0.12.1-rc.
|
|
1285
|
+
"0.12.1-rc.8"
|
|
1276
1286
|
] })
|
|
1277
1287
|
] });
|
|
1278
1288
|
};
|
|
@@ -1436,13 +1446,12 @@ function Toggle({ checked, onChange, disabled = false, busy = false, label }) {
|
|
|
1436
1446
|
);
|
|
1437
1447
|
}
|
|
1438
1448
|
function useModalLanguage(language) {
|
|
1439
|
-
const {
|
|
1440
|
-
const
|
|
1441
|
-
const locale = typeof client.getLocale === "function" ? client.getLocale() : void 0;
|
|
1449
|
+
const { styles } = usePollar();
|
|
1450
|
+
const provider = react.useContext(ModalLanguageContext);
|
|
1442
1451
|
const dashboard = styles?.language;
|
|
1443
1452
|
return react.useMemo(
|
|
1444
|
-
() => core.resolveLanguage({ dashboard, code: [language,
|
|
1445
|
-
[dashboard, language,
|
|
1453
|
+
() => core.resolveLanguage({ dashboard, code: [language, provider], device: deviceLanguageTag() }),
|
|
1454
|
+
[dashboard, language, provider]
|
|
1446
1455
|
);
|
|
1447
1456
|
}
|
|
1448
1457
|
|
|
@@ -1790,6 +1799,20 @@ function DistributionRulesModalTemplate({
|
|
|
1790
1799
|
}
|
|
1791
1800
|
);
|
|
1792
1801
|
}
|
|
1802
|
+
var noSubscription = () => () => {
|
|
1803
|
+
};
|
|
1804
|
+
function PollarOverlay({ style, onClick, children }) {
|
|
1805
|
+
const canPortal = react.useSyncExternalStore(
|
|
1806
|
+
noSubscription,
|
|
1807
|
+
() => true,
|
|
1808
|
+
() => false
|
|
1809
|
+
);
|
|
1810
|
+
if (!canPortal) return null;
|
|
1811
|
+
return reactDom.createPortal(
|
|
1812
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-overlay", "data-react-aria-top-layer": "true", style, onClick, children }),
|
|
1813
|
+
document.body
|
|
1814
|
+
);
|
|
1815
|
+
}
|
|
1793
1816
|
function DistributionRulesModal({ onClose }) {
|
|
1794
1817
|
const { getClient, styles } = usePollar();
|
|
1795
1818
|
const { theme, accentColor, styleOverrides, overlayStyle } = modalChrome(styles);
|
|
@@ -1837,7 +1860,7 @@ function DistributionRulesModal({ onClose }) {
|
|
|
1837
1860
|
},
|
|
1838
1861
|
[getClient, copy]
|
|
1839
1862
|
);
|
|
1840
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1863
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1841
1864
|
DistributionRulesModalTemplate,
|
|
1842
1865
|
{
|
|
1843
1866
|
theme,
|
|
@@ -2335,7 +2358,7 @@ function EnabledAssetsModal({ onClose }) {
|
|
|
2335
2358
|
},
|
|
2336
2359
|
[runAction]
|
|
2337
2360
|
);
|
|
2338
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2361
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: view === "list" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2339
2362
|
EnabledAssetsModalTemplate,
|
|
2340
2363
|
{
|
|
2341
2364
|
theme,
|
|
@@ -2924,7 +2947,7 @@ function KycModal({
|
|
|
2924
2947
|
if (selectedProvider) void handleSelectProvider(selectedProvider);
|
|
2925
2948
|
else setStep("select_provider");
|
|
2926
2949
|
}
|
|
2927
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2950
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2928
2951
|
KycModalTemplate,
|
|
2929
2952
|
{
|
|
2930
2953
|
theme,
|
|
@@ -3083,7 +3106,7 @@ function RequirementFormModal({
|
|
|
3083
3106
|
if (mounted.current) setSubmitting(false);
|
|
3084
3107
|
}
|
|
3085
3108
|
}
|
|
3086
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3109
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3087
3110
|
"div",
|
|
3088
3111
|
{
|
|
3089
3112
|
className: "pollar-modal-card pollar-form-modal",
|
|
@@ -3312,6 +3335,7 @@ var LOGIN_COPY = {
|
|
|
3312
3335
|
genericError: "Something went wrong. Please try again.",
|
|
3313
3336
|
codeLabel: "Enter the 6-digit code sent to",
|
|
3314
3337
|
yourEmail: "your email",
|
|
3338
|
+
codeDigit: (position, total) => `Digit ${position} of ${total}`,
|
|
3315
3339
|
codePlaceholder: "Enter verification code",
|
|
3316
3340
|
verifyCode: "Verify Code",
|
|
3317
3341
|
status: {
|
|
@@ -3349,6 +3373,7 @@ var LOGIN_COPY = {
|
|
|
3349
3373
|
genericError: "Algo sali\xF3 mal. Intenta de nuevo.",
|
|
3350
3374
|
codeLabel: "Ingresa el c\xF3digo de 6 d\xEDgitos que enviamos a",
|
|
3351
3375
|
yourEmail: "tu correo",
|
|
3376
|
+
codeDigit: (position, total) => `D\xEDgito ${position} de ${total}`,
|
|
3352
3377
|
codePlaceholder: "Ingresa el c\xF3digo de verificaci\xF3n",
|
|
3353
3378
|
verifyCode: "Verificar c\xF3digo",
|
|
3354
3379
|
status: {
|
|
@@ -3386,6 +3411,7 @@ var LOGIN_COPY = {
|
|
|
3386
3411
|
genericError: "Algo deu errado. Tente novamente.",
|
|
3387
3412
|
codeLabel: "Digite o c\xF3digo de 6 d\xEDgitos enviado para",
|
|
3388
3413
|
yourEmail: "seu e-mail",
|
|
3414
|
+
codeDigit: (position, total) => `D\xEDgito ${position} de ${total}`,
|
|
3389
3415
|
codePlaceholder: "Digite o c\xF3digo de verifica\xE7\xE3o",
|
|
3390
3416
|
verifyCode: "Verificar c\xF3digo",
|
|
3391
3417
|
status: {
|
|
@@ -3441,7 +3467,7 @@ function EmailCodeInput({ email, onSubmit, language }) {
|
|
|
3441
3467
|
type: "text",
|
|
3442
3468
|
inputMode: "numeric",
|
|
3443
3469
|
autoComplete: i === 0 ? "one-time-code" : "off",
|
|
3444
|
-
"aria-label":
|
|
3470
|
+
"aria-label": copy.codeDigit(i + 1, EMAIL_CODE_LENGTH),
|
|
3445
3471
|
value: digit,
|
|
3446
3472
|
className: "pollar-code-input",
|
|
3447
3473
|
onChange: (e) => apply(applyEmailCodeInput(digits, i, e.target.value, e.target.selectionStart)),
|
|
@@ -4053,7 +4079,7 @@ function LoginModal({ onClose }) {
|
|
|
4053
4079
|
getClient().login({ provider });
|
|
4054
4080
|
}
|
|
4055
4081
|
}
|
|
4056
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4082
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: handleClose, children: configStatus !== "ready" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4057
4083
|
LoginModalStatus,
|
|
4058
4084
|
{
|
|
4059
4085
|
status: configStatus === "error" ? "error" : "loading",
|
|
@@ -4955,11 +4981,11 @@ function RampWidgetTemplate({
|
|
|
4955
4981
|
className: "pollar-ramp-input",
|
|
4956
4982
|
value: country,
|
|
4957
4983
|
onChange: (e) => onCountryChange(e.target.value),
|
|
4958
|
-
children: countries.map((c) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: c.
|
|
4959
|
-
flagEmoji(c.
|
|
4984
|
+
children: countries.map((c) => ({ code: c.country, name: core.countryName(c.country, language) })).sort((a, b) => a.name.localeCompare(b.name, language)).map((c) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: c.code, children: [
|
|
4985
|
+
flagEmoji(c.code),
|
|
4960
4986
|
" ",
|
|
4961
|
-
c.
|
|
4962
|
-
] }, c.
|
|
4987
|
+
c.name
|
|
4988
|
+
] }, c.code))
|
|
4963
4989
|
}
|
|
4964
4990
|
)
|
|
4965
4991
|
] }),
|
|
@@ -5606,7 +5632,7 @@ function RegistryCheckModal({
|
|
|
5606
5632
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-form-label", children: label }),
|
|
5607
5633
|
/* @__PURE__ */ jsxRuntime.jsx("input", { className: "pollar-input", value, readOnly: true, disabled: true })
|
|
5608
5634
|
] });
|
|
5609
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5635
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5610
5636
|
"div",
|
|
5611
5637
|
{
|
|
5612
5638
|
className: "pollar-modal-card pollar-form-modal",
|
|
@@ -5786,7 +5812,7 @@ function ProviderRegistrationModal({
|
|
|
5786
5812
|
}
|
|
5787
5813
|
);
|
|
5788
5814
|
}
|
|
5789
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5815
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5790
5816
|
"div",
|
|
5791
5817
|
{
|
|
5792
5818
|
className: "pollar-modal-card pollar-form-modal",
|
|
@@ -5863,6 +5889,24 @@ function routeKey(quote) {
|
|
|
5863
5889
|
return quote.legs.map((leg) => `${leg.kind}:${node(leg.from)}>${node(leg.to)}`).join("|");
|
|
5864
5890
|
}
|
|
5865
5891
|
var DECIMAL = /^\d+(\.\d+)?$/;
|
|
5892
|
+
function seededSelection(routes, seed) {
|
|
5893
|
+
const countries = core.rampCountries(routes);
|
|
5894
|
+
const wanted = seed.country?.trim().toUpperCase();
|
|
5895
|
+
const country = wanted ? countries.find((c) => c.country === wanted) : countries[0];
|
|
5896
|
+
if (!country) return null;
|
|
5897
|
+
const fiat = country.fiats.find((f) => f.currency === seed.fiat?.trim().toUpperCase()) ?? null;
|
|
5898
|
+
const resolvedFiat = fiat ?? country.fiats[0];
|
|
5899
|
+
const asset = routes.find(
|
|
5900
|
+
(r) => r.fiat.country === country.country && resolvedFiat !== void 0 && fiatKey(r.fiat) === fiatKey(resolvedFiat) && r.asset.code.toUpperCase() === seed.asset?.trim().toUpperCase()
|
|
5901
|
+
)?.asset;
|
|
5902
|
+
const amount = seed.amount?.trim() ?? "";
|
|
5903
|
+
return {
|
|
5904
|
+
country: country.country,
|
|
5905
|
+
fiatChoice: fiat ? fiatKey(fiat) : "",
|
|
5906
|
+
assetChoice: asset ? assetKey3(asset) : "",
|
|
5907
|
+
amount: DECIMAL.test(amount) ? amount : ""
|
|
5908
|
+
};
|
|
5909
|
+
}
|
|
5866
5910
|
async function signLegWithWallet(client, orderId, actionId, copy) {
|
|
5867
5911
|
const lent = [];
|
|
5868
5912
|
const lend = (chain, encoding, handler) => {
|
|
@@ -5897,7 +5941,7 @@ async function signLegWithWallet(client, orderId, actionId, copy) {
|
|
|
5897
5941
|
for (const release of lent) release();
|
|
5898
5942
|
}
|
|
5899
5943
|
}
|
|
5900
|
-
function RampWidget({ onClose, language: languageProp }) {
|
|
5944
|
+
function RampWidget({ onClose, language: languageProp, initial }) {
|
|
5901
5945
|
const {
|
|
5902
5946
|
getClient,
|
|
5903
5947
|
styles,
|
|
@@ -5916,7 +5960,10 @@ function RampWidget({ onClose, language: languageProp }) {
|
|
|
5916
5960
|
const copy = RAMP_COPY[language];
|
|
5917
5961
|
const { theme, accentColor, styleOverrides, overlayStyle } = modalChrome(styles);
|
|
5918
5962
|
const [step, setStep] = react.useState("input");
|
|
5919
|
-
const [direction, setDirection] = react.useState("ONRAMP");
|
|
5963
|
+
const [direction, setDirection] = react.useState(initial?.direction === "sell" ? "OFFRAMP" : "ONRAMP");
|
|
5964
|
+
const seedRef = react.useRef(
|
|
5965
|
+
initial ? { direction: initial.direction === "sell" ? "OFFRAMP" : "ONRAMP", options: initial } : null
|
|
5966
|
+
);
|
|
5920
5967
|
const [routes, setRoutes] = react.useState([]);
|
|
5921
5968
|
const [routesLoading, setRoutesLoading] = react.useState(true);
|
|
5922
5969
|
const [country, setCountry] = react.useState("");
|
|
@@ -5970,6 +6017,16 @@ function RampWidget({ onClose, language: languageProp }) {
|
|
|
5970
6017
|
try {
|
|
5971
6018
|
const { routes: found } = await client.getRampRoutes(next);
|
|
5972
6019
|
setRoutes(found);
|
|
6020
|
+
const seed = seedRef.current?.direction === next ? seedRef.current.options : null;
|
|
6021
|
+
if (seed) seedRef.current = null;
|
|
6022
|
+
const seeded = seed ? seededSelection(found, seed) : null;
|
|
6023
|
+
if (seeded) {
|
|
6024
|
+
setCountry(seeded.country);
|
|
6025
|
+
setFiatChoice(seeded.fiatChoice);
|
|
6026
|
+
setAssetChoice(seeded.assetChoice);
|
|
6027
|
+
setAmount(seeded.amount);
|
|
6028
|
+
return;
|
|
6029
|
+
}
|
|
5973
6030
|
const first = core.rampCountries(found)[0]?.country ?? "";
|
|
5974
6031
|
setCountry((current) => found.some((r) => r.fiat.country === current) ? current : first);
|
|
5975
6032
|
} catch (error) {
|
|
@@ -6054,6 +6111,7 @@ function RampWidget({ onClose, language: languageProp }) {
|
|
|
6054
6111
|
void resumeRoute(awaitingAccount.routeKey);
|
|
6055
6112
|
}, [awaitingAccount, resolvedRequest]);
|
|
6056
6113
|
function handleDirectionChange(next) {
|
|
6114
|
+
seedRef.current = null;
|
|
6057
6115
|
setDirection(next);
|
|
6058
6116
|
setErrorMsg(null);
|
|
6059
6117
|
setAwaitingAccount(null);
|
|
@@ -6233,6 +6291,7 @@ function RampWidget({ onClose, language: languageProp }) {
|
|
|
6233
6291
|
setErrorMsg(null);
|
|
6234
6292
|
try {
|
|
6235
6293
|
const found = await client.getRampOrder(id);
|
|
6294
|
+
seedRef.current = null;
|
|
6236
6295
|
setDirection(found.direction);
|
|
6237
6296
|
setOrder(found);
|
|
6238
6297
|
setStep("status");
|
|
@@ -6375,7 +6434,7 @@ function RampWidget({ onClose, language: languageProp }) {
|
|
|
6375
6434
|
}
|
|
6376
6435
|
);
|
|
6377
6436
|
}
|
|
6378
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6437
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6379
6438
|
RampWidgetTemplate,
|
|
6380
6439
|
{
|
|
6381
6440
|
language,
|
|
@@ -6485,6 +6544,37 @@ function walletNotReadyReason(wallet, chain, language = "en") {
|
|
|
6485
6544
|
}
|
|
6486
6545
|
return null;
|
|
6487
6546
|
}
|
|
6547
|
+
function seededAmount(amount) {
|
|
6548
|
+
const value = amount?.trim() ?? "";
|
|
6549
|
+
return /^\d+(\.\d+)?$/.test(value) ? value : "";
|
|
6550
|
+
}
|
|
6551
|
+
function byCode(options, code) {
|
|
6552
|
+
const wanted = code?.trim().toUpperCase();
|
|
6553
|
+
return wanted ? options.find((o) => o.code.toUpperCase() === wanted) : void 0;
|
|
6554
|
+
}
|
|
6555
|
+
function oneOf(allowed, value) {
|
|
6556
|
+
return value !== void 0 && allowed.includes(value) ? value : void 0;
|
|
6557
|
+
}
|
|
6558
|
+
function useSuccessReport(transaction, active, onSuccess) {
|
|
6559
|
+
const reported = react.useRef(null);
|
|
6560
|
+
const hash = active && transaction.step === "success" ? transaction.hash : null;
|
|
6561
|
+
react.useEffect(() => {
|
|
6562
|
+
if (!hash || reported.current === hash) return;
|
|
6563
|
+
reported.current = hash;
|
|
6564
|
+
onSuccess?.({ hash });
|
|
6565
|
+
}, [hash, onSuccess]);
|
|
6566
|
+
}
|
|
6567
|
+
function useModalOptions() {
|
|
6568
|
+
const [state, setState] = react.useState({ options: void 0, key: 0 });
|
|
6569
|
+
const seeded = react.useRef(false);
|
|
6570
|
+
const open = react.useCallback((options) => {
|
|
6571
|
+
const given = options !== void 0 && Object.keys(options).length > 0;
|
|
6572
|
+
const remount = given || seeded.current;
|
|
6573
|
+
seeded.current = given;
|
|
6574
|
+
setState((current) => ({ options: given ? options : void 0, key: remount ? current.key + 1 : current.key }));
|
|
6575
|
+
}, []);
|
|
6576
|
+
return [state, open];
|
|
6577
|
+
}
|
|
6488
6578
|
|
|
6489
6579
|
// src/lib/qr-code/index.tsx
|
|
6490
6580
|
var import_ErrorCorrectLevel = __toESM(require_ErrorCorrectLevel());
|
|
@@ -6711,7 +6801,7 @@ function ReceiveModalTemplate({
|
|
|
6711
6801
|
}
|
|
6712
6802
|
);
|
|
6713
6803
|
}
|
|
6714
|
-
function ReceiveModal({ onClose }) {
|
|
6804
|
+
function ReceiveModal({ onClose, initial }) {
|
|
6715
6805
|
const { wallet, wallets, styles, recoveryLocked, openRecoveryModal } = usePollar();
|
|
6716
6806
|
const { theme, accentColor, styleOverrides, overlayStyle } = modalChrome(styles);
|
|
6717
6807
|
const language = useModalLanguage();
|
|
@@ -6720,8 +6810,8 @@ function ReceiveModal({ onClose }) {
|
|
|
6720
6810
|
const { chains } = useChains();
|
|
6721
6811
|
const [selectedChain, setSelectedChain] = react.useState(null);
|
|
6722
6812
|
react.useEffect(() => {
|
|
6723
|
-
if (selectedChain === null && chains.length > 0) setSelectedChain(chains[0]);
|
|
6724
|
-
}, [chains, selectedChain]);
|
|
6813
|
+
if (selectedChain === null && chains.length > 0) setSelectedChain(oneOf(chains, initial?.chain) ?? chains[0]);
|
|
6814
|
+
}, [chains, selectedChain, initial?.chain]);
|
|
6725
6815
|
const walletAddress = addressForChain(wallets, selectedChain);
|
|
6726
6816
|
const notReadyReason = walletNotReadyReason(wallet, selectedChain, language);
|
|
6727
6817
|
react.useEffect(
|
|
@@ -6741,7 +6831,7 @@ function ReceiveModal({ onClose }) {
|
|
|
6741
6831
|
}, 2e3);
|
|
6742
6832
|
});
|
|
6743
6833
|
}
|
|
6744
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6834
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6745
6835
|
ReceiveModalTemplate,
|
|
6746
6836
|
{
|
|
6747
6837
|
theme,
|
|
@@ -7968,7 +8058,7 @@ function assetParam(record) {
|
|
|
7968
8058
|
}
|
|
7969
8059
|
return { type: "credit_alphanum12", code: record.code, issuer: record.issuer };
|
|
7970
8060
|
}
|
|
7971
|
-
function SendModal({ onClose }) {
|
|
8061
|
+
function SendModal({ onClose, initial }) {
|
|
7972
8062
|
const {
|
|
7973
8063
|
walletBalance,
|
|
7974
8064
|
refreshWalletBalance,
|
|
@@ -7988,10 +8078,13 @@ function SendModal({ onClose }) {
|
|
|
7988
8078
|
const [step, setStep] = react.useState("form");
|
|
7989
8079
|
const [createsAccount, setCreatesAccount] = react.useState(false);
|
|
7990
8080
|
const [checkingDestination, setCheckingDestination] = react.useState(false);
|
|
7991
|
-
const [amount, setAmount] = react.useState(
|
|
7992
|
-
const [destination, setDestination] = react.useState("");
|
|
7993
|
-
const [memo, setMemo] = react.useState("");
|
|
7994
|
-
const [memoType, setMemoType] = react.useState(
|
|
8081
|
+
const [amount, setAmount] = react.useState(() => seededAmount(initial?.amount));
|
|
8082
|
+
const [destination, setDestination] = react.useState(() => initial?.destination?.trim() ?? "");
|
|
8083
|
+
const [memo, setMemo] = react.useState(() => initial?.memo ?? "");
|
|
8084
|
+
const [memoType, setMemoType] = react.useState(
|
|
8085
|
+
() => oneOf(["text", "id", "hash"], initial?.memoType) ?? "text"
|
|
8086
|
+
);
|
|
8087
|
+
const assetSeed = react.useRef(initial?.asset);
|
|
7995
8088
|
const [selectedAsset, setSelectedAsset] = react.useState(null);
|
|
7996
8089
|
const [showXdr, setShowXdr] = react.useState(false);
|
|
7997
8090
|
const [copied, setCopied] = react.useState(false);
|
|
@@ -8000,8 +8093,8 @@ function SendModal({ onClose }) {
|
|
|
8000
8093
|
const { chains } = useChains();
|
|
8001
8094
|
const [selectedChain, setSelectedChain] = react.useState(null);
|
|
8002
8095
|
react.useEffect(() => {
|
|
8003
|
-
if (selectedChain === null && chains.length > 0) setSelectedChain(chains[0]);
|
|
8004
|
-
}, [chains, selectedChain]);
|
|
8096
|
+
if (selectedChain === null && chains.length > 0) setSelectedChain(oneOf(chains, initial?.chain) ?? chains[0]);
|
|
8097
|
+
}, [chains, selectedChain, initial?.chain]);
|
|
8005
8098
|
const canSendOnChain = selectedChain === "STELLAR" || selectedChain === "SOLANA" || selectedChain === "POLYGON";
|
|
8006
8099
|
const notReadyReason = walletNotReadyReason(wallet, selectedChain, language);
|
|
8007
8100
|
const isBaseUnitChain = selectedChain === "SOLANA" || selectedChain === "POLYGON";
|
|
@@ -8028,9 +8121,13 @@ function SendModal({ onClose }) {
|
|
|
8028
8121
|
setSelectedAsset(sortedAssets[0] ?? null);
|
|
8029
8122
|
return;
|
|
8030
8123
|
}
|
|
8031
|
-
if (!selectedAsset && sortedAssets.length > 0)
|
|
8124
|
+
if (!selectedAsset && sortedAssets.length > 0) {
|
|
8125
|
+
setSelectedAsset(byCode(sortedAssets, assetSeed.current) ?? sortedAssets[0]);
|
|
8126
|
+
assetSeed.current = void 0;
|
|
8127
|
+
}
|
|
8032
8128
|
}, [sortedAssets, selectedAsset, selectedChain]);
|
|
8033
8129
|
const hash = transaction.step === "success" ? transaction.hash : null;
|
|
8130
|
+
useSuccessReport(transaction, step === "tx", initial?.onSuccess);
|
|
8034
8131
|
const buildData = "buildData" in transaction ? transaction.buildData : null;
|
|
8035
8132
|
const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
|
|
8036
8133
|
const explorerUrl = !hash ? null : selectedChain === "SOLANA" ? `https://explorer.solana.com/tx/${hash}${explorerNetwork === "testnet" ? "?cluster=devnet" : ""}` : selectedChain === "POLYGON" ? `https://${explorerNetwork === "testnet" ? "amoy." : ""}polygonscan.com/tx/${hash}` : `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}`;
|
|
@@ -8195,7 +8292,7 @@ function SendModal({ onClose }) {
|
|
|
8195
8292
|
setShowXdr(false);
|
|
8196
8293
|
setCopied(false);
|
|
8197
8294
|
}
|
|
8198
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8295
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: !isInProgress ? onClose : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8199
8296
|
SendModalTemplate,
|
|
8200
8297
|
{
|
|
8201
8298
|
theme,
|
|
@@ -8850,7 +8947,7 @@ function fromBaseUnits3(units, decimals) {
|
|
|
8850
8947
|
function catalogRef(code, issuer) {
|
|
8851
8948
|
return code.length <= 4 ? { type: "credit_alphanum4", code, issuer } : { type: "credit_alphanum12", code, issuer };
|
|
8852
8949
|
}
|
|
8853
|
-
function SwapModal({ onClose }) {
|
|
8950
|
+
function SwapModal({ onClose, initial }) {
|
|
8854
8951
|
const {
|
|
8855
8952
|
getSwapConfig,
|
|
8856
8953
|
getSwapTokens,
|
|
@@ -8871,13 +8968,15 @@ function SwapModal({ onClose }) {
|
|
|
8871
8968
|
const language = useModalLanguage();
|
|
8872
8969
|
const copy = SWAP_COPY[language];
|
|
8873
8970
|
const walletType = wallet?.custody === "external" ? wallet.provider : null;
|
|
8874
|
-
const [chain, setChain] = react.useState("STELLAR");
|
|
8971
|
+
const [chain, setChain] = react.useState(() => oneOf(["STELLAR", "SOLANA"], initial?.chain) ?? "STELLAR");
|
|
8972
|
+
const sellSeed = react.useRef(initial?.sell);
|
|
8973
|
+
const buySeed = react.useRef(initial?.buy);
|
|
8875
8974
|
const smartUnsupported = chain === "STELLAR" && wallet?.custody === "smart";
|
|
8876
8975
|
const { theme, accentColor, styleOverrides, overlayStyle } = modalChrome(styles);
|
|
8877
8976
|
const [step, setStep] = react.useState("form");
|
|
8878
8977
|
const [selectedSell, setSelectedSell] = react.useState(null);
|
|
8879
8978
|
const [selectedBuy, setSelectedBuy] = react.useState(null);
|
|
8880
|
-
const [amount, setAmount] = react.useState(
|
|
8979
|
+
const [amount, setAmount] = react.useState(() => seededAmount(initial?.amount));
|
|
8881
8980
|
const [provider, setProvider] = react.useState("auto");
|
|
8882
8981
|
const [venues, setVenues] = react.useState(null);
|
|
8883
8982
|
const [solanaVenues, setSolanaVenues] = react.useState(null);
|
|
@@ -8992,12 +9091,24 @@ function SwapModal({ onClose }) {
|
|
|
8992
9091
|
);
|
|
8993
9092
|
react.useEffect(() => {
|
|
8994
9093
|
if (sellOptions.length === 0) return;
|
|
9094
|
+
const seeded = byCode(sellOptions, sellSeed.current);
|
|
9095
|
+
if (seeded) {
|
|
9096
|
+
sellSeed.current = void 0;
|
|
9097
|
+
setSelectedSell(seeded);
|
|
9098
|
+
return;
|
|
9099
|
+
}
|
|
8995
9100
|
if (!selectedSell || !sellOptions.some((o) => optKey(o) === optKey(selectedSell))) {
|
|
8996
9101
|
setSelectedSell(sellOptions[0]);
|
|
8997
9102
|
}
|
|
8998
9103
|
}, [sellOptions, selectedSell]);
|
|
8999
9104
|
react.useEffect(() => {
|
|
9000
9105
|
if (buyOptions.length === 0) return;
|
|
9106
|
+
const seeded = byCode(buyOptions, buySeed.current);
|
|
9107
|
+
if (seeded) {
|
|
9108
|
+
buySeed.current = void 0;
|
|
9109
|
+
setSelectedBuy(seeded);
|
|
9110
|
+
return;
|
|
9111
|
+
}
|
|
9001
9112
|
if (!selectedBuy || !buyOptions.some((o) => optKey(o) === optKey(selectedBuy))) {
|
|
9002
9113
|
setSelectedBuy(buyOptions[0]);
|
|
9003
9114
|
}
|
|
@@ -9009,6 +9120,7 @@ function SwapModal({ onClose }) {
|
|
|
9009
9120
|
if (i.length !== 56 || !i.startsWith("G")) return copy.issuerFormat;
|
|
9010
9121
|
const opt = { ref: catalogRef(c, i), code: c, issuer: i, enabledInApp: false };
|
|
9011
9122
|
setCustomTokens((prev) => prev.some((o) => optKey(o) === optKey(opt)) ? prev : [...prev, opt]);
|
|
9123
|
+
buySeed.current = void 0;
|
|
9012
9124
|
setSelectedBuy(opt);
|
|
9013
9125
|
return null;
|
|
9014
9126
|
}
|
|
@@ -9041,6 +9153,8 @@ function SwapModal({ onClose }) {
|
|
|
9041
9153
|
if (chains.length > 0 && !chains.includes(chain)) setChain(chains[0]);
|
|
9042
9154
|
}, [chains, chain]);
|
|
9043
9155
|
function handleChainChange(next) {
|
|
9156
|
+
sellSeed.current = void 0;
|
|
9157
|
+
buySeed.current = void 0;
|
|
9044
9158
|
setChain(next);
|
|
9045
9159
|
setSelectedSell(null);
|
|
9046
9160
|
setSelectedBuy(null);
|
|
@@ -9113,6 +9227,7 @@ function SwapModal({ onClose }) {
|
|
|
9113
9227
|
copy
|
|
9114
9228
|
]);
|
|
9115
9229
|
const hash = transaction.step === "success" ? transaction.hash : null;
|
|
9230
|
+
useSuccessReport(transaction, step === "tx", initial?.onSuccess);
|
|
9116
9231
|
const buildData = "buildData" in transaction ? transaction.buildData : null;
|
|
9117
9232
|
const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
|
|
9118
9233
|
const explorerUrl = !hash ? null : chain === "SOLANA" ? `https://solscan.io/tx/${hash}${network === "testnet" ? "?cluster=devnet" : ""}` : `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}`;
|
|
@@ -9175,6 +9290,8 @@ function SwapModal({ onClose }) {
|
|
|
9175
9290
|
}
|
|
9176
9291
|
function handleReverse() {
|
|
9177
9292
|
if (!selectedSell || !selectedBuy) return;
|
|
9293
|
+
sellSeed.current = void 0;
|
|
9294
|
+
buySeed.current = void 0;
|
|
9178
9295
|
const previousSell = selectedSell;
|
|
9179
9296
|
setSelectedSell(selectedBuy);
|
|
9180
9297
|
setSelectedBuy(previousSell);
|
|
@@ -9195,7 +9312,7 @@ function SwapModal({ onClose }) {
|
|
|
9195
9312
|
setShowXdr(false);
|
|
9196
9313
|
setCopied(false);
|
|
9197
9314
|
}
|
|
9198
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9315
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: !isInProgress ? onClose : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9199
9316
|
SwapModalTemplate,
|
|
9200
9317
|
{
|
|
9201
9318
|
theme,
|
|
@@ -9232,8 +9349,14 @@ function SwapModal({ onClose }) {
|
|
|
9232
9349
|
onClose,
|
|
9233
9350
|
onBack: handleBack,
|
|
9234
9351
|
onRefresh: handleRefresh,
|
|
9235
|
-
onSelectSell:
|
|
9236
|
-
|
|
9352
|
+
onSelectSell: (option) => {
|
|
9353
|
+
sellSeed.current = void 0;
|
|
9354
|
+
setSelectedSell(option);
|
|
9355
|
+
},
|
|
9356
|
+
onSelectBuy: (option) => {
|
|
9357
|
+
buySeed.current = void 0;
|
|
9358
|
+
setSelectedBuy(option);
|
|
9359
|
+
},
|
|
9237
9360
|
onReverse: handleReverse,
|
|
9238
9361
|
onMax: handleMax,
|
|
9239
9362
|
onAddCustomToken: addCustomToken,
|
|
@@ -9249,6 +9372,621 @@ function SwapModal({ onClose }) {
|
|
|
9249
9372
|
) });
|
|
9250
9373
|
}
|
|
9251
9374
|
|
|
9375
|
+
// src/components/bridge-modal/bridge-copy.ts
|
|
9376
|
+
var BRIDGE_COPY = {
|
|
9377
|
+
en: {
|
|
9378
|
+
title: "Move USDC between networks",
|
|
9379
|
+
close: "Close",
|
|
9380
|
+
back: "Back",
|
|
9381
|
+
loading: "Loading\u2026",
|
|
9382
|
+
mainnetOnly: "Moving USDC between networks works on mainnet only.",
|
|
9383
|
+
noDirections: "You need a wallet on at least two networks of this app to move USDC between them.",
|
|
9384
|
+
from: "From",
|
|
9385
|
+
to: "To",
|
|
9386
|
+
amount: "Amount (USDC)",
|
|
9387
|
+
balance: "Balance",
|
|
9388
|
+
max: "Max",
|
|
9389
|
+
youReceive: "You receive",
|
|
9390
|
+
fee: "Fee",
|
|
9391
|
+
noFee: "No fee",
|
|
9392
|
+
eta: "Estimated time",
|
|
9393
|
+
etaValue: "about {minutes} min",
|
|
9394
|
+
signingInternal: "Your wallet sends it right away.",
|
|
9395
|
+
signingCosigned: "You approve it on your device.",
|
|
9396
|
+
signingExternal: "You sign it in your wallet.",
|
|
9397
|
+
quoting: "Getting a quote\u2026",
|
|
9398
|
+
bridgeButton: "Move USDC",
|
|
9399
|
+
starting: "Starting\u2026",
|
|
9400
|
+
invalidAmount: "Enter an amount with up to 6 decimals.",
|
|
9401
|
+
overBalance: "The amount is more than your balance.",
|
|
9402
|
+
statusTitle: {
|
|
9403
|
+
PENDING: "Sending",
|
|
9404
|
+
AWAITING_ACTION: "Your approval is needed",
|
|
9405
|
+
BURNED: "On its way",
|
|
9406
|
+
ATTESTED: "Arriving",
|
|
9407
|
+
COMPLETED: "Done",
|
|
9408
|
+
FAILED: "It did not go through",
|
|
9409
|
+
HELD: "Under review"
|
|
9410
|
+
},
|
|
9411
|
+
statusBody: {
|
|
9412
|
+
PENDING: "Your USDC is leaving your {from} wallet.",
|
|
9413
|
+
AWAITING_ACTION: "Approve the step below to continue.",
|
|
9414
|
+
BURNED: "Circle is confirming the transfer. This takes a few minutes.",
|
|
9415
|
+
ATTESTED: "Your USDC is being delivered to your {to} wallet.",
|
|
9416
|
+
COMPLETED: "{amount} USDC arrived in your {to} wallet.",
|
|
9417
|
+
FAILED: "Nothing left your wallet. You can try again.",
|
|
9418
|
+
HELD: "Your USDC left your {from} wallet but did not arrive yet. Our team is on it; no action is needed from you."
|
|
9419
|
+
},
|
|
9420
|
+
steps: { burn: "Leaves {from}", attest: "Confirmed by Circle", mint: "Arrives on {to}" },
|
|
9421
|
+
authorize: "Authorize",
|
|
9422
|
+
waitingWallet: "Waiting for your wallet\u2026",
|
|
9423
|
+
approveOnDevice: "Approve on your device",
|
|
9424
|
+
viewBurn: "View on {chain}",
|
|
9425
|
+
viewMint: "View on {chain}",
|
|
9426
|
+
done: "Done",
|
|
9427
|
+
newBridge: "Move more",
|
|
9428
|
+
pollTrouble: "We could not refresh the status. Retrying\u2026",
|
|
9429
|
+
errors: {
|
|
9430
|
+
mainnetOnly: "Moving USDC between networks works on mainnet only.",
|
|
9431
|
+
chainNotEnabled: "This app does not use one of these networks.",
|
|
9432
|
+
noGasWallet: "This app cannot pay the network fees for this move right now.",
|
|
9433
|
+
noWallet: (chain) => `You do not have a wallet on ${chain} yet.`,
|
|
9434
|
+
noTrustline: "Your Stellar wallet needs to accept USDC first.",
|
|
9435
|
+
connectSolanaWallet: "Connect the Solana wallet this move leaves from to sign.",
|
|
9436
|
+
unsupportedWallet: "This wallet cannot move USDC between networks.",
|
|
9437
|
+
credits: "This app cannot cover this operation right now.",
|
|
9438
|
+
actionChanged: "The step changed. Review it and authorize again.",
|
|
9439
|
+
connectStellarWallet: "Connect your Stellar wallet to sign.",
|
|
9440
|
+
walletChanged: "The connected wallet changed. Try again.",
|
|
9441
|
+
signingCancelled: "The signature was cancelled.",
|
|
9442
|
+
generic: "Something went wrong. Try again."
|
|
9443
|
+
}
|
|
9444
|
+
},
|
|
9445
|
+
es: {
|
|
9446
|
+
title: "Mover USDC entre redes",
|
|
9447
|
+
close: "Cerrar",
|
|
9448
|
+
back: "Volver",
|
|
9449
|
+
loading: "Cargando\u2026",
|
|
9450
|
+
mainnetOnly: "Mover USDC entre redes solo funciona en mainnet.",
|
|
9451
|
+
noDirections: "Necesitas una wallet en al menos dos redes de esta app para mover USDC entre ellas.",
|
|
9452
|
+
from: "Desde",
|
|
9453
|
+
to: "Hacia",
|
|
9454
|
+
amount: "Monto (USDC)",
|
|
9455
|
+
balance: "Saldo",
|
|
9456
|
+
max: "M\xE1x",
|
|
9457
|
+
youReceive: "Recibes",
|
|
9458
|
+
fee: "Comisi\xF3n",
|
|
9459
|
+
noFee: "Sin comisi\xF3n",
|
|
9460
|
+
eta: "Tiempo estimado",
|
|
9461
|
+
etaValue: "unos {minutes} min",
|
|
9462
|
+
signingInternal: "Tu wallet lo env\xEDa de inmediato.",
|
|
9463
|
+
signingCosigned: "Lo apruebas en tu dispositivo.",
|
|
9464
|
+
signingExternal: "Lo firmas en tu wallet.",
|
|
9465
|
+
quoting: "Cotizando\u2026",
|
|
9466
|
+
bridgeButton: "Mover USDC",
|
|
9467
|
+
starting: "Iniciando\u2026",
|
|
9468
|
+
invalidAmount: "Ingresa un monto con hasta 6 decimales.",
|
|
9469
|
+
overBalance: "El monto es mayor que tu saldo.",
|
|
9470
|
+
statusTitle: {
|
|
9471
|
+
PENDING: "Enviando",
|
|
9472
|
+
AWAITING_ACTION: "Falta tu aprobaci\xF3n",
|
|
9473
|
+
BURNED: "En camino",
|
|
9474
|
+
ATTESTED: "Llegando",
|
|
9475
|
+
COMPLETED: "Listo",
|
|
9476
|
+
FAILED: "No se complet\xF3",
|
|
9477
|
+
HELD: "En revisi\xF3n"
|
|
9478
|
+
},
|
|
9479
|
+
statusBody: {
|
|
9480
|
+
PENDING: "Tu USDC est\xE1 saliendo de tu wallet de {from}.",
|
|
9481
|
+
AWAITING_ACTION: "Aprueba el paso de abajo para continuar.",
|
|
9482
|
+
BURNED: "Circle est\xE1 confirmando la transferencia. Tarda unos minutos.",
|
|
9483
|
+
ATTESTED: "Tu USDC se est\xE1 entregando en tu wallet de {to}.",
|
|
9484
|
+
COMPLETED: "Llegaron {amount} USDC a tu wallet de {to}.",
|
|
9485
|
+
FAILED: "No sali\xF3 nada de tu wallet. Puedes intentarlo de nuevo.",
|
|
9486
|
+
HELD: "Tu USDC sali\xF3 de tu wallet de {from} pero todav\xEDa no lleg\xF3. Nuestro equipo ya lo est\xE1 revisando; no tienes que hacer nada."
|
|
9487
|
+
},
|
|
9488
|
+
steps: { burn: "Sale de {from}", attest: "Confirmado por Circle", mint: "Llega a {to}" },
|
|
9489
|
+
authorize: "Autorizar",
|
|
9490
|
+
waitingWallet: "Esperando a tu wallet\u2026",
|
|
9491
|
+
approveOnDevice: "Aprobar en tu dispositivo",
|
|
9492
|
+
viewBurn: "Ver en {chain}",
|
|
9493
|
+
viewMint: "Ver en {chain}",
|
|
9494
|
+
done: "Listo",
|
|
9495
|
+
newBridge: "Mover m\xE1s",
|
|
9496
|
+
pollTrouble: "No pudimos actualizar el estado. Reintentando\u2026",
|
|
9497
|
+
errors: {
|
|
9498
|
+
mainnetOnly: "Mover USDC entre redes solo funciona en mainnet.",
|
|
9499
|
+
chainNotEnabled: "Esta app no usa una de estas redes.",
|
|
9500
|
+
noGasWallet: "Esta app no puede pagar ahora las comisiones de red de este movimiento.",
|
|
9501
|
+
noWallet: (chain) => `Todav\xEDa no tienes una wallet en ${chain}.`,
|
|
9502
|
+
noTrustline: "Tu wallet de Stellar primero tiene que aceptar USDC.",
|
|
9503
|
+
connectSolanaWallet: "Conecta la wallet de Solana desde la que sale este movimiento para firmar.",
|
|
9504
|
+
unsupportedWallet: "Esta wallet no puede mover USDC entre redes.",
|
|
9505
|
+
credits: "Esta app no puede cubrir esta operaci\xF3n ahora.",
|
|
9506
|
+
actionChanged: "El paso cambi\xF3. Rev\xEDsalo y autoriza de nuevo.",
|
|
9507
|
+
connectStellarWallet: "Conecta tu wallet de Stellar para firmar.",
|
|
9508
|
+
walletChanged: "Cambi\xF3 la wallet conectada. Int\xE9ntalo de nuevo.",
|
|
9509
|
+
signingCancelled: "Se cancel\xF3 la firma.",
|
|
9510
|
+
generic: "Algo sali\xF3 mal. Int\xE9ntalo de nuevo."
|
|
9511
|
+
}
|
|
9512
|
+
},
|
|
9513
|
+
pt: {
|
|
9514
|
+
title: "Mover USDC entre redes",
|
|
9515
|
+
close: "Fechar",
|
|
9516
|
+
back: "Voltar",
|
|
9517
|
+
loading: "Carregando\u2026",
|
|
9518
|
+
mainnetOnly: "Mover USDC entre redes funciona s\xF3 na mainnet.",
|
|
9519
|
+
noDirections: "Voc\xEA precisa de uma carteira em pelo menos duas redes deste app para mover USDC entre elas.",
|
|
9520
|
+
from: "De",
|
|
9521
|
+
to: "Para",
|
|
9522
|
+
amount: "Valor (USDC)",
|
|
9523
|
+
balance: "Saldo",
|
|
9524
|
+
max: "M\xE1x",
|
|
9525
|
+
youReceive: "Voc\xEA recebe",
|
|
9526
|
+
fee: "Taxa",
|
|
9527
|
+
noFee: "Sem taxa",
|
|
9528
|
+
eta: "Tempo estimado",
|
|
9529
|
+
etaValue: "cerca de {minutes} min",
|
|
9530
|
+
signingInternal: "Sua carteira envia na hora.",
|
|
9531
|
+
signingCosigned: "Voc\xEA aprova no seu dispositivo.",
|
|
9532
|
+
signingExternal: "Voc\xEA assina na sua carteira.",
|
|
9533
|
+
quoting: "Cotando\u2026",
|
|
9534
|
+
bridgeButton: "Mover USDC",
|
|
9535
|
+
starting: "Iniciando\u2026",
|
|
9536
|
+
invalidAmount: "Informe um valor com at\xE9 6 casas decimais.",
|
|
9537
|
+
overBalance: "O valor \xE9 maior que o seu saldo.",
|
|
9538
|
+
statusTitle: {
|
|
9539
|
+
PENDING: "Enviando",
|
|
9540
|
+
AWAITING_ACTION: "Falta a sua aprova\xE7\xE3o",
|
|
9541
|
+
BURNED: "A caminho",
|
|
9542
|
+
ATTESTED: "Chegando",
|
|
9543
|
+
COMPLETED: "Pronto",
|
|
9544
|
+
FAILED: "N\xE3o foi conclu\xEDdo",
|
|
9545
|
+
HELD: "Em an\xE1lise"
|
|
9546
|
+
},
|
|
9547
|
+
statusBody: {
|
|
9548
|
+
PENDING: "Seu USDC est\xE1 saindo da sua carteira na {from}.",
|
|
9549
|
+
AWAITING_ACTION: "Aprove o passo abaixo para continuar.",
|
|
9550
|
+
BURNED: "A Circle est\xE1 confirmando a transfer\xEAncia. Leva alguns minutos.",
|
|
9551
|
+
ATTESTED: "Seu USDC est\xE1 sendo entregue na sua carteira na {to}.",
|
|
9552
|
+
COMPLETED: "{amount} USDC chegaram na sua carteira na {to}.",
|
|
9553
|
+
FAILED: "Nada saiu da sua carteira. Voc\xEA pode tentar de novo.",
|
|
9554
|
+
HELD: "Seu USDC saiu da sua carteira na {from} mas ainda n\xE3o chegou. Nossa equipe j\xE1 est\xE1 cuidando disso; voc\xEA n\xE3o precisa fazer nada."
|
|
9555
|
+
},
|
|
9556
|
+
steps: { burn: "Sai da {from}", attest: "Confirmado pela Circle", mint: "Chega na {to}" },
|
|
9557
|
+
authorize: "Autorizar",
|
|
9558
|
+
waitingWallet: "Aguardando sua carteira\u2026",
|
|
9559
|
+
approveOnDevice: "Aprovar no dispositivo",
|
|
9560
|
+
viewBurn: "Ver na {chain}",
|
|
9561
|
+
viewMint: "Ver na {chain}",
|
|
9562
|
+
done: "Pronto",
|
|
9563
|
+
newBridge: "Mover mais",
|
|
9564
|
+
pollTrouble: "N\xE3o conseguimos atualizar o status. Tentando de novo\u2026",
|
|
9565
|
+
errors: {
|
|
9566
|
+
mainnetOnly: "Mover USDC entre redes funciona s\xF3 na mainnet.",
|
|
9567
|
+
chainNotEnabled: "Este app n\xE3o usa uma dessas redes.",
|
|
9568
|
+
noGasWallet: "Este app n\xE3o consegue pagar agora as taxas de rede deste movimento.",
|
|
9569
|
+
noWallet: (chain) => `Voc\xEA ainda n\xE3o tem uma carteira na ${chain}.`,
|
|
9570
|
+
noTrustline: "Sua carteira Stellar precisa aceitar USDC primeiro.",
|
|
9571
|
+
connectSolanaWallet: "Conecte a carteira Solana de onde sai este movimento para assinar.",
|
|
9572
|
+
unsupportedWallet: "Esta carteira n\xE3o pode mover USDC entre redes.",
|
|
9573
|
+
credits: "Este app n\xE3o consegue cobrir esta opera\xE7\xE3o agora.",
|
|
9574
|
+
actionChanged: "O passo mudou. Revise e autorize de novo.",
|
|
9575
|
+
connectStellarWallet: "Conecte sua carteira Stellar para assinar.",
|
|
9576
|
+
walletChanged: "A carteira conectada mudou. Tente de novo.",
|
|
9577
|
+
signingCancelled: "A assinatura foi cancelada.",
|
|
9578
|
+
generic: "Algo deu errado. Tente de novo."
|
|
9579
|
+
}
|
|
9580
|
+
}
|
|
9581
|
+
};
|
|
9582
|
+
var BRIDGE_CHAIN_LABEL = {
|
|
9583
|
+
STELLAR: "Stellar",
|
|
9584
|
+
SOLANA: "Solana",
|
|
9585
|
+
POLYGON: "Polygon"
|
|
9586
|
+
};
|
|
9587
|
+
var EXPLORER = {
|
|
9588
|
+
STELLAR: (hash) => `https://stellar.expert/explorer/public/tx/${hash}`,
|
|
9589
|
+
SOLANA: (hash) => `https://solscan.io/tx/${hash}`,
|
|
9590
|
+
POLYGON: (hash) => `https://polygonscan.com/tx/${hash}`
|
|
9591
|
+
};
|
|
9592
|
+
var fill = (text, values) => text.replace(/\{(\w+)\}/g, (_, key) => values[key] ?? `{${key}}`);
|
|
9593
|
+
function ChainPicker({
|
|
9594
|
+
label,
|
|
9595
|
+
value,
|
|
9596
|
+
options,
|
|
9597
|
+
onChange,
|
|
9598
|
+
disabled
|
|
9599
|
+
}) {
|
|
9600
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "pollar-bridge-field", children: [
|
|
9601
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bridge-label", children: label }),
|
|
9602
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9603
|
+
"select",
|
|
9604
|
+
{
|
|
9605
|
+
className: "pollar-input",
|
|
9606
|
+
value: value ?? "",
|
|
9607
|
+
disabled: disabled || options.length === 0,
|
|
9608
|
+
onChange: (event) => onChange(event.target.value),
|
|
9609
|
+
children: options.map((chain) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: chain, children: BRIDGE_CHAIN_LABEL[chain] }, chain))
|
|
9610
|
+
}
|
|
9611
|
+
)
|
|
9612
|
+
] });
|
|
9613
|
+
}
|
|
9614
|
+
function Progress({ transfer, labels }) {
|
|
9615
|
+
const reached = {
|
|
9616
|
+
burn: !!transfer.burnTxHash,
|
|
9617
|
+
attest: transfer.status === "ATTESTED" || transfer.status === "COMPLETED" || !!transfer.mintTxHash,
|
|
9618
|
+
mint: transfer.status === "COMPLETED"
|
|
9619
|
+
};
|
|
9620
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "pollar-bridge-steps", children: ["burn", "attest", "mint"].map((key) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: reached[key] ? "pollar-bridge-step pollar-bridge-step-done" : "pollar-bridge-step", children: [
|
|
9621
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bridge-step-dot", "aria-hidden": true }),
|
|
9622
|
+
labels[key]
|
|
9623
|
+
] }, key)) });
|
|
9624
|
+
}
|
|
9625
|
+
function BridgeModalTemplate(props) {
|
|
9626
|
+
const language = useInheritedLanguage(props.language);
|
|
9627
|
+
const copy = BRIDGE_COPY[language];
|
|
9628
|
+
const cssVars = buildModalCssVars(props.theme, props.accentColor, props.styleOverrides);
|
|
9629
|
+
const { transfer, quote } = props;
|
|
9630
|
+
const busy = props.submitting || props.quoting;
|
|
9631
|
+
const toName = props.toChain ? BRIDGE_CHAIN_LABEL[props.toChain] : "";
|
|
9632
|
+
const signingNote = quote?.signing === "EXTERNAL" ? copy.signingExternal : quote?.signing === "COSIGNED" || quote?.signing === "SELF_CUSTODY" ? copy.signingCosigned : copy.signingInternal;
|
|
9633
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9634
|
+
"div",
|
|
9635
|
+
{
|
|
9636
|
+
className: "pollar-modal-card pollar-bridge-modal",
|
|
9637
|
+
"data-theme": props.theme,
|
|
9638
|
+
style: cssVars,
|
|
9639
|
+
onClick: (event) => event.stopPropagation(),
|
|
9640
|
+
children: [
|
|
9641
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
|
|
9642
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: copy.title }),
|
|
9643
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-header-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: props.onClose, "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" }) }) }) })
|
|
9644
|
+
] }),
|
|
9645
|
+
props.step === "loading" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: copy.loading }),
|
|
9646
|
+
props.step === "unavailable" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: props.unavailableReason === "mainnet_only" ? copy.mainnetOnly : copy.noDirections }),
|
|
9647
|
+
props.step === "form" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bridge-form", children: [
|
|
9648
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bridge-chains", children: [
|
|
9649
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9650
|
+
ChainPicker,
|
|
9651
|
+
{
|
|
9652
|
+
label: copy.from,
|
|
9653
|
+
value: props.fromChain,
|
|
9654
|
+
options: props.sources,
|
|
9655
|
+
onChange: props.onFromChange,
|
|
9656
|
+
disabled: busy
|
|
9657
|
+
}
|
|
9658
|
+
),
|
|
9659
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bridge-arrow", "aria-hidden": true, children: "\u2192" }),
|
|
9660
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9661
|
+
ChainPicker,
|
|
9662
|
+
{
|
|
9663
|
+
label: copy.to,
|
|
9664
|
+
value: props.toChain,
|
|
9665
|
+
options: props.targets,
|
|
9666
|
+
onChange: props.onToChange,
|
|
9667
|
+
disabled: busy
|
|
9668
|
+
}
|
|
9669
|
+
)
|
|
9670
|
+
] }),
|
|
9671
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { className: "pollar-bridge-field", children: [
|
|
9672
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-bridge-label-row", children: [
|
|
9673
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bridge-label", children: copy.amount }),
|
|
9674
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-bridge-balance", children: [
|
|
9675
|
+
copy.balance,
|
|
9676
|
+
" ",
|
|
9677
|
+
props.balance ?? "\u2014",
|
|
9678
|
+
props.balance !== null && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-bridge-max", onClick: props.onMax, disabled: busy, children: copy.max })
|
|
9679
|
+
] })
|
|
9680
|
+
] }),
|
|
9681
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9682
|
+
"input",
|
|
9683
|
+
{
|
|
9684
|
+
className: "pollar-input",
|
|
9685
|
+
type: "text",
|
|
9686
|
+
inputMode: "decimal",
|
|
9687
|
+
placeholder: "0.00",
|
|
9688
|
+
value: props.amount,
|
|
9689
|
+
disabled: props.submitting,
|
|
9690
|
+
onChange: (event) => props.onAmountChange(event.target.value)
|
|
9691
|
+
}
|
|
9692
|
+
)
|
|
9693
|
+
] }),
|
|
9694
|
+
props.quoting && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-bridge-note", children: copy.quoting }),
|
|
9695
|
+
quote && !props.quoting && /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "pollar-bridge-quote", children: [
|
|
9696
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
9697
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: copy.youReceive }),
|
|
9698
|
+
/* @__PURE__ */ jsxRuntime.jsxs("dd", { children: [
|
|
9699
|
+
quote.amountOut,
|
|
9700
|
+
" USDC \xB7 ",
|
|
9701
|
+
toName
|
|
9702
|
+
] })
|
|
9703
|
+
] }),
|
|
9704
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
9705
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: copy.fee }),
|
|
9706
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { children: quote.fee ? `${quote.fee.amount} USD` : copy.noFee })
|
|
9707
|
+
] }),
|
|
9708
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
9709
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: copy.eta }),
|
|
9710
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { children: fill(copy.etaValue, { minutes: String(Math.max(1, Math.round(quote.etaSeconds / 60))) }) })
|
|
9711
|
+
] }),
|
|
9712
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-bridge-note", children: signingNote })
|
|
9713
|
+
] }),
|
|
9714
|
+
props.formError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: props.formError }),
|
|
9715
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9716
|
+
"button",
|
|
9717
|
+
{
|
|
9718
|
+
type: "button",
|
|
9719
|
+
className: "pollar-btn-primary",
|
|
9720
|
+
disabled: !props.canSubmit || props.submitting,
|
|
9721
|
+
onClick: props.onSubmit,
|
|
9722
|
+
children: props.submitting ? copy.starting : copy.bridgeButton
|
|
9723
|
+
}
|
|
9724
|
+
) })
|
|
9725
|
+
] }),
|
|
9726
|
+
props.step === "transfer" && transfer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bridge-transfer", children: [
|
|
9727
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: `pollar-bridge-status pollar-bridge-status-${transfer.status.toLowerCase()}`, children: [
|
|
9728
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: copy.statusTitle[transfer.status] }),
|
|
9729
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { children: fill(copy.statusBody[transfer.status], {
|
|
9730
|
+
from: BRIDGE_CHAIN_LABEL[transfer.fromChain],
|
|
9731
|
+
to: BRIDGE_CHAIN_LABEL[transfer.toChain],
|
|
9732
|
+
amount: transfer.amountOut ?? transfer.amount
|
|
9733
|
+
}) })
|
|
9734
|
+
] }),
|
|
9735
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9736
|
+
Progress,
|
|
9737
|
+
{
|
|
9738
|
+
transfer,
|
|
9739
|
+
labels: {
|
|
9740
|
+
burn: fill(copy.steps.burn, { from: BRIDGE_CHAIN_LABEL[transfer.fromChain] }),
|
|
9741
|
+
attest: copy.steps.attest,
|
|
9742
|
+
mint: fill(copy.steps.mint, { to: BRIDGE_CHAIN_LABEL[transfer.toChain] })
|
|
9743
|
+
}
|
|
9744
|
+
}
|
|
9745
|
+
),
|
|
9746
|
+
transfer.pendingAction?.kind === "SIGNATURE" && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", disabled: props.signing, onClick: props.onAuthorize, children: props.signing ? copy.waitingWallet : copy.authorize }),
|
|
9747
|
+
transfer.pendingAction?.kind === "COSIGN_APPROVAL" && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: props.onApprove, children: copy.approveOnDevice }),
|
|
9748
|
+
props.actionError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: props.actionError }),
|
|
9749
|
+
props.pollTrouble && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-bridge-note", children: copy.pollTrouble }),
|
|
9750
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bridge-links", children: [
|
|
9751
|
+
transfer.burnTxHash && /* @__PURE__ */ jsxRuntime.jsx("a", { href: EXPLORER[transfer.fromChain](transfer.burnTxHash), target: "_blank", rel: "noopener noreferrer", children: fill(copy.viewBurn, { chain: BRIDGE_CHAIN_LABEL[transfer.fromChain] }) }),
|
|
9752
|
+
transfer.mintTxHash && /* @__PURE__ */ jsxRuntime.jsx("a", { href: EXPLORER[transfer.toChain](transfer.mintTxHash), target: "_blank", rel: "noopener noreferrer", children: fill(copy.viewMint, { chain: BRIDGE_CHAIN_LABEL[transfer.toChain] }) })
|
|
9753
|
+
] }),
|
|
9754
|
+
(transfer.status === "COMPLETED" || transfer.status === "FAILED") && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-actions", children: [
|
|
9755
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: props.onNewBridge, children: copy.newBridge }),
|
|
9756
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: props.onClose, children: copy.done })
|
|
9757
|
+
] })
|
|
9758
|
+
] }),
|
|
9759
|
+
/* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
|
|
9760
|
+
]
|
|
9761
|
+
}
|
|
9762
|
+
);
|
|
9763
|
+
}
|
|
9764
|
+
var AMOUNT = /^(?:0|[1-9]\d{0,11})(?:\.\d{1,6})?$/;
|
|
9765
|
+
var QUOTE_DEBOUNCE_MS2 = 400;
|
|
9766
|
+
function errorText(error, copy) {
|
|
9767
|
+
if (!core.isPollarApiError(error)) return copy.errors.generic;
|
|
9768
|
+
const reason = typeof error.body.reason === "string" ? error.body.reason : null;
|
|
9769
|
+
const chain = typeof error.body.chain === "string" ? BRIDGE_CHAIN_LABEL[error.body.chain] ?? "" : "";
|
|
9770
|
+
switch (error.code) {
|
|
9771
|
+
case "SDK_BRIDGE_UNAVAILABLE":
|
|
9772
|
+
if (reason === "mainnet_only") return copy.errors.mainnetOnly;
|
|
9773
|
+
if (reason === "chain_not_enabled") return copy.errors.chainNotEnabled;
|
|
9774
|
+
return copy.errors.noGasWallet;
|
|
9775
|
+
case "SDK_BRIDGE_WALLET_NOT_READY":
|
|
9776
|
+
if (reason === "no_usdc_trustline") return copy.errors.noTrustline;
|
|
9777
|
+
if (reason === "no_wallet") return copy.errors.noWallet(chain);
|
|
9778
|
+
return copy.errors.unsupportedWallet;
|
|
9779
|
+
case "SDK_CREDITS_INSUFFICIENT":
|
|
9780
|
+
case "SDK_BILLING_OVERDUE":
|
|
9781
|
+
return copy.errors.credits;
|
|
9782
|
+
case "SDK_BRIDGE_ACTION_CHANGED":
|
|
9783
|
+
return copy.errors.actionChanged;
|
|
9784
|
+
default:
|
|
9785
|
+
return copy.errors.generic;
|
|
9786
|
+
}
|
|
9787
|
+
}
|
|
9788
|
+
function solanaBurnSigner(client, copy) {
|
|
9789
|
+
return async (action) => {
|
|
9790
|
+
const payload = JSON.parse(action.payload.value);
|
|
9791
|
+
const solanaWallet = () => client.getWallets().find((w) => w.chain === "SOLANA" && w.custody === "external");
|
|
9792
|
+
const wallet = solanaWallet();
|
|
9793
|
+
if (!wallet || payload.from !== wallet.address || !payload.unsignedTransaction)
|
|
9794
|
+
throw new Error(copy.errors.connectSolanaWallet);
|
|
9795
|
+
const signed = await client.signSolanaTransaction(payload.unsignedTransaction);
|
|
9796
|
+
if (solanaWallet()?.address !== wallet.address) throw new Error(copy.errors.walletChanged);
|
|
9797
|
+
return signed;
|
|
9798
|
+
};
|
|
9799
|
+
}
|
|
9800
|
+
async function signStepWithWallet(client, transferId, actionId, copy) {
|
|
9801
|
+
const lent = [];
|
|
9802
|
+
const lend = (chain, encoding, handler) => {
|
|
9803
|
+
try {
|
|
9804
|
+
lent.push(client.registerRampSigningHandler(chain, encoding, handler));
|
|
9805
|
+
} catch {
|
|
9806
|
+
}
|
|
9807
|
+
};
|
|
9808
|
+
lend("SOLANA", "solana-cctp-json", solanaBurnSigner(client, copy));
|
|
9809
|
+
lend("STELLAR", "xdr", async (action) => {
|
|
9810
|
+
const wallet = client.getWallet();
|
|
9811
|
+
if (!wallet) throw new Error(copy.errors.connectStellarWallet);
|
|
9812
|
+
core.assertRampStellarSigner(action, wallet.address);
|
|
9813
|
+
const outcome = await client.signTx(action.payload.value);
|
|
9814
|
+
if (client.getWallet()?.address !== wallet.address) throw new Error(copy.errors.walletChanged);
|
|
9815
|
+
if (outcome.status === "signed") return outcome.signedXdr;
|
|
9816
|
+
throw new Error(
|
|
9817
|
+
outcome.status === "error" ? outcome.message ?? outcome.details ?? copy.errors.signingCancelled : copy.errors.signingCancelled
|
|
9818
|
+
);
|
|
9819
|
+
});
|
|
9820
|
+
try {
|
|
9821
|
+
return await client.signBridgeStep(transferId, actionId);
|
|
9822
|
+
} finally {
|
|
9823
|
+
for (const release of lent) release();
|
|
9824
|
+
}
|
|
9825
|
+
}
|
|
9826
|
+
function newIntentKey() {
|
|
9827
|
+
return typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
9828
|
+
}
|
|
9829
|
+
function BridgeModal({ onClose, initial }) {
|
|
9830
|
+
const { getClient, styles, walletBalance, refreshWalletBalance, openCosignModal } = usePollar();
|
|
9831
|
+
const language = useModalLanguage();
|
|
9832
|
+
const copy = BRIDGE_COPY[language];
|
|
9833
|
+
const { theme, accentColor, styleOverrides, overlayStyle } = modalChrome(styles);
|
|
9834
|
+
const client = getClient();
|
|
9835
|
+
const [config, setConfig] = react.useState(null);
|
|
9836
|
+
const [configError, setConfigError] = react.useState(null);
|
|
9837
|
+
const [fromChain, setFromChain] = react.useState(null);
|
|
9838
|
+
const [toChain, setToChain] = react.useState(null);
|
|
9839
|
+
const [amount, setAmount] = react.useState(() => seededAmount(initial?.amount));
|
|
9840
|
+
const [quote, setQuote] = react.useState(null);
|
|
9841
|
+
const [quoting, setQuoting] = react.useState(false);
|
|
9842
|
+
const [quoteError, setQuoteError] = react.useState(null);
|
|
9843
|
+
const [submitting, setSubmitting] = react.useState(false);
|
|
9844
|
+
const [transfer, setTransfer] = react.useState(null);
|
|
9845
|
+
const [signing, setSigning] = react.useState(false);
|
|
9846
|
+
const [actionError, setActionError] = react.useState(null);
|
|
9847
|
+
const [pollTrouble, setPollTrouble] = react.useState(false);
|
|
9848
|
+
const intentKey = react.useRef(newIntentKey());
|
|
9849
|
+
react.useEffect(() => {
|
|
9850
|
+
let cancelled = false;
|
|
9851
|
+
client.getBridgeConfig().then((loaded) => {
|
|
9852
|
+
if (cancelled) return;
|
|
9853
|
+
setConfig(loaded);
|
|
9854
|
+
const sources2 = core.bridgeSourceChains(loaded);
|
|
9855
|
+
const from = oneOf(sources2, initial?.fromChain) ?? sources2[0] ?? null;
|
|
9856
|
+
const targets2 = from ? core.bridgeTargetChains(loaded, from) : [];
|
|
9857
|
+
setFromChain(from);
|
|
9858
|
+
setToChain(oneOf(targets2, initial?.toChain) ?? targets2[0] ?? null);
|
|
9859
|
+
}).catch((error) => !cancelled && setConfigError(errorText(error, copy)));
|
|
9860
|
+
return () => {
|
|
9861
|
+
cancelled = true;
|
|
9862
|
+
};
|
|
9863
|
+
}, [client]);
|
|
9864
|
+
const sources = react.useMemo(() => config ? core.bridgeSourceChains(config) : [], [config]);
|
|
9865
|
+
const targets = react.useMemo(() => config && fromChain ? core.bridgeTargetChains(config, fromChain) : [], [config, fromChain]);
|
|
9866
|
+
const balance = react.useMemo(() => {
|
|
9867
|
+
if (walletBalance.step !== "loaded" || !fromChain) return null;
|
|
9868
|
+
const usdc = walletBalance.data.balances.find((b) => (b.chain ?? "STELLAR") === fromChain && b.code === "USDC");
|
|
9869
|
+
return usdc ? usdc.available ?? usdc.balance : "0";
|
|
9870
|
+
}, [walletBalance, fromChain]);
|
|
9871
|
+
const amountValid = AMOUNT.test(amount) && Number(amount) > 0;
|
|
9872
|
+
const overBalance = amountValid && balance !== null && Number(amount) > Number(balance);
|
|
9873
|
+
const formError = configError ?? quoteError ?? (amount && !amountValid ? copy.invalidAmount : null) ?? (overBalance ? copy.overBalance : null);
|
|
9874
|
+
react.useEffect(() => {
|
|
9875
|
+
setQuote(null);
|
|
9876
|
+
setQuoteError(null);
|
|
9877
|
+
if (!fromChain || !toChain || !amountValid) return;
|
|
9878
|
+
let cancelled = false;
|
|
9879
|
+
const timer = setTimeout(() => {
|
|
9880
|
+
setQuoting(true);
|
|
9881
|
+
client.quoteBridge({ fromChain, toChain, amount }).then((next) => !cancelled && setQuote(next)).catch((error) => !cancelled && setQuoteError(errorText(error, copy))).finally(() => !cancelled && setQuoting(false));
|
|
9882
|
+
}, QUOTE_DEBOUNCE_MS2);
|
|
9883
|
+
return () => {
|
|
9884
|
+
cancelled = true;
|
|
9885
|
+
clearTimeout(timer);
|
|
9886
|
+
};
|
|
9887
|
+
}, [client, fromChain, toChain, amount, amountValid]);
|
|
9888
|
+
react.useEffect(() => {
|
|
9889
|
+
if (!transfer || core.isBridgeSettled(transfer)) return;
|
|
9890
|
+
const controller = new AbortController();
|
|
9891
|
+
client.pollBridgeTransfer(transfer.id, {
|
|
9892
|
+
signal: controller.signal,
|
|
9893
|
+
onUpdate: (next) => {
|
|
9894
|
+
setPollTrouble(false);
|
|
9895
|
+
setTransfer(next);
|
|
9896
|
+
},
|
|
9897
|
+
onError: () => setPollTrouble(true),
|
|
9898
|
+
// A co-signed step moves once the device approves: keep reading through it.
|
|
9899
|
+
until: (next) => next.status === "AWAITING_ACTION" && next.pendingAction?.kind === "SIGNATURE"
|
|
9900
|
+
}).then((settled) => {
|
|
9901
|
+
if (settled.status === "COMPLETED") void refreshWalletBalance();
|
|
9902
|
+
}).catch(() => {
|
|
9903
|
+
});
|
|
9904
|
+
return () => controller.abort();
|
|
9905
|
+
}, [client, transfer?.id, transfer?.pendingAction?.actionId]);
|
|
9906
|
+
const reported = react.useRef(null);
|
|
9907
|
+
const onSuccess = initial?.onSuccess;
|
|
9908
|
+
react.useEffect(() => {
|
|
9909
|
+
if (transfer?.status !== "COMPLETED" || reported.current === transfer.id) return;
|
|
9910
|
+
reported.current = transfer.id;
|
|
9911
|
+
onSuccess?.(transfer);
|
|
9912
|
+
}, [transfer, onSuccess]);
|
|
9913
|
+
async function submit() {
|
|
9914
|
+
if (!fromChain || !toChain || !amountValid || overBalance) return;
|
|
9915
|
+
setSubmitting(true);
|
|
9916
|
+
setQuoteError(null);
|
|
9917
|
+
try {
|
|
9918
|
+
const started = await client.bridge({ fromChain, toChain, amount, idempotencyKey: intentKey.current });
|
|
9919
|
+
setTransfer(started);
|
|
9920
|
+
} catch (error) {
|
|
9921
|
+
setQuoteError(errorText(error, copy));
|
|
9922
|
+
} finally {
|
|
9923
|
+
setSubmitting(false);
|
|
9924
|
+
}
|
|
9925
|
+
}
|
|
9926
|
+
async function authorize() {
|
|
9927
|
+
const action = transfer?.pendingAction;
|
|
9928
|
+
if (!transfer || action?.kind !== "SIGNATURE") return;
|
|
9929
|
+
setSigning(true);
|
|
9930
|
+
setActionError(null);
|
|
9931
|
+
try {
|
|
9932
|
+
setTransfer(await signStepWithWallet(client, transfer.id, action.actionId, copy));
|
|
9933
|
+
} catch (error) {
|
|
9934
|
+
setActionError(error instanceof Error && !core.isPollarApiError(error) ? error.message : errorText(error, copy));
|
|
9935
|
+
client.getBridgeTransfer(transfer.id).then(setTransfer).catch(() => {
|
|
9936
|
+
});
|
|
9937
|
+
} finally {
|
|
9938
|
+
setSigning(false);
|
|
9939
|
+
}
|
|
9940
|
+
}
|
|
9941
|
+
function newBridge() {
|
|
9942
|
+
intentKey.current = newIntentKey();
|
|
9943
|
+
setTransfer(null);
|
|
9944
|
+
setAmount("");
|
|
9945
|
+
setActionError(null);
|
|
9946
|
+
void refreshWalletBalance();
|
|
9947
|
+
}
|
|
9948
|
+
const step = transfer ? "transfer" : !config && !configError ? "loading" : config && (!config.available || sources.length === 0) ? "unavailable" : "form";
|
|
9949
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9950
|
+
BridgeModalTemplate,
|
|
9951
|
+
{
|
|
9952
|
+
theme,
|
|
9953
|
+
accentColor,
|
|
9954
|
+
styleOverrides,
|
|
9955
|
+
step,
|
|
9956
|
+
unavailableReason: config?.reason === "mainnet_only" ? "mainnet_only" : config ? "no_directions" : null,
|
|
9957
|
+
sources,
|
|
9958
|
+
targets,
|
|
9959
|
+
fromChain,
|
|
9960
|
+
toChain,
|
|
9961
|
+
onFromChange: (chain) => {
|
|
9962
|
+
setFromChain(chain);
|
|
9963
|
+
const next = config ? core.bridgeTargetChains(config, chain) : [];
|
|
9964
|
+
if (!toChain || !next.includes(toChain)) setToChain(next[0] ?? null);
|
|
9965
|
+
},
|
|
9966
|
+
onToChange: setToChain,
|
|
9967
|
+
amount,
|
|
9968
|
+
onAmountChange: (value) => setAmount(value.replace(",", ".").trim()),
|
|
9969
|
+
balance,
|
|
9970
|
+
onMax: () => balance !== null && setAmount(balance.replace(/(\.\d{6})\d+$/, "$1")),
|
|
9971
|
+
quote,
|
|
9972
|
+
quoting,
|
|
9973
|
+
formError,
|
|
9974
|
+
canSubmit: !!quote && !quoting && amountValid && !overBalance,
|
|
9975
|
+
submitting,
|
|
9976
|
+
onSubmit: () => void submit(),
|
|
9977
|
+
transfer,
|
|
9978
|
+
signing,
|
|
9979
|
+
onAuthorize: () => void authorize(),
|
|
9980
|
+
onApprove: openCosignModal,
|
|
9981
|
+
actionError,
|
|
9982
|
+
pollTrouble,
|
|
9983
|
+
onNewBridge: newBridge,
|
|
9984
|
+
onClose,
|
|
9985
|
+
language
|
|
9986
|
+
}
|
|
9987
|
+
) });
|
|
9988
|
+
}
|
|
9989
|
+
|
|
9252
9990
|
// src/components/earn-modal/earn-copy.ts
|
|
9253
9991
|
var EARN_COPY = {
|
|
9254
9992
|
en: {
|
|
@@ -9374,7 +10112,7 @@ function formatAmount3(value) {
|
|
|
9374
10112
|
const n = parseFloat(value);
|
|
9375
10113
|
return isNaN(n) ? value : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
|
|
9376
10114
|
}
|
|
9377
|
-
function EarnModal({ onClose }) {
|
|
10115
|
+
function EarnModal({ onClose, initial }) {
|
|
9378
10116
|
const {
|
|
9379
10117
|
getEarnProviders,
|
|
9380
10118
|
getEarnOpportunities,
|
|
@@ -9395,13 +10133,15 @@ function EarnModal({ onClose }) {
|
|
|
9395
10133
|
const smartUnsupported = wallet?.custody === "smart";
|
|
9396
10134
|
const { theme, accentColor, styleOverrides, overlayStyle } = modalChrome(styles);
|
|
9397
10135
|
const [step, setStep] = react.useState("form");
|
|
9398
|
-
const [tab, setTab] = react.useState(
|
|
10136
|
+
const [tab, setTab] = react.useState(
|
|
10137
|
+
() => oneOf(["deposit", "withdraw"], initial?.tab) ?? "deposit"
|
|
10138
|
+
);
|
|
9399
10139
|
const [providers, setProviders] = react.useState(null);
|
|
9400
10140
|
const [provider, setProvider] = react.useState(null);
|
|
9401
10141
|
const [opportunities, setOpportunities] = react.useState([]);
|
|
9402
|
-
const [opportunityId, setOpportunityId] = react.useState("");
|
|
10142
|
+
const [opportunityId, setOpportunityId] = react.useState(() => initial?.opportunityId ?? "");
|
|
9403
10143
|
const [position, setPosition] = react.useState(null);
|
|
9404
|
-
const [amount, setAmount] = react.useState(
|
|
10144
|
+
const [amount, setAmount] = react.useState(() => seededAmount(initial?.amount));
|
|
9405
10145
|
const [loadingOpps, setLoadingOpps] = react.useState(false);
|
|
9406
10146
|
const [formError, setFormError] = react.useState("");
|
|
9407
10147
|
const [refreshing, setRefreshing] = react.useState(false);
|
|
@@ -9412,9 +10152,9 @@ function EarnModal({ onClose }) {
|
|
|
9412
10152
|
setProviders(null);
|
|
9413
10153
|
return getEarnProviders().then((ps) => {
|
|
9414
10154
|
setProviders(ps);
|
|
9415
|
-
setProvider((cur) => cur ?? ps[0] ?? null);
|
|
10155
|
+
setProvider((cur) => cur ?? oneOf(ps, initial?.provider) ?? ps[0] ?? null);
|
|
9416
10156
|
}).catch(() => setProviders([]));
|
|
9417
|
-
}, [getEarnProviders]);
|
|
10157
|
+
}, [getEarnProviders, initial?.provider]);
|
|
9418
10158
|
react.useEffect(() => {
|
|
9419
10159
|
void loadProviders();
|
|
9420
10160
|
}, [loadProviders]);
|
|
@@ -9476,6 +10216,7 @@ function EarnModal({ onClose }) {
|
|
|
9476
10216
|
})();
|
|
9477
10217
|
const depositNeedsTrustline = tab === "deposit" && !smartUnsupported && !!selectedOpportunity?.asset.issuer && !depositAssetRecord?.trustlineEstablished;
|
|
9478
10218
|
const hash = transaction.step === "success" ? transaction.hash : null;
|
|
10219
|
+
useSuccessReport(transaction, step === "tx", initial?.onSuccess);
|
|
9479
10220
|
const buildData = "buildData" in transaction ? transaction.buildData : null;
|
|
9480
10221
|
const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
|
|
9481
10222
|
const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
|
|
@@ -9564,7 +10305,7 @@ function EarnModal({ onClose }) {
|
|
|
9564
10305
|
}
|
|
9565
10306
|
}
|
|
9566
10307
|
const title = step === "form" ? copy.title : txTitle;
|
|
9567
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10308
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: !isInProgress ? onClose : void 0, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9568
10309
|
"div",
|
|
9569
10310
|
{
|
|
9570
10311
|
className: "pollar-modal-card pollar-send-modal",
|
|
@@ -9896,7 +10637,15 @@ var CARD_COPY = {
|
|
|
9896
10637
|
chain: (id) => `chain ${id}`,
|
|
9897
10638
|
sendOnly: (tokens, network) => `Send only ${tokens} on ${network}; anything else can be lost.`,
|
|
9898
10639
|
noDeposit: "The provider returned no deposit address.",
|
|
9899
|
-
hideDeposit: "Hide the deposit address"
|
|
10640
|
+
hideDeposit: "Hide the deposit address",
|
|
10641
|
+
fundingProblem: {
|
|
10642
|
+
noGas: "Your wallet does not have enough to pay the network fee.",
|
|
10643
|
+
sponsorNoGas: "The network fee cannot be covered right now. Please try again later.",
|
|
10644
|
+
noBalance: "Your wallet does not have enough USDC for this amount.",
|
|
10645
|
+
notPaid: "The payment was not sent.",
|
|
10646
|
+
failed: "The payment could not be completed. Please try again.",
|
|
10647
|
+
delayed: "Taking longer than usual. We are following up with the card provider."
|
|
10648
|
+
}
|
|
9900
10649
|
},
|
|
9901
10650
|
es: {
|
|
9902
10651
|
funding: {
|
|
@@ -10054,7 +10803,15 @@ var CARD_COPY = {
|
|
|
10054
10803
|
chain: (id) => `cadena ${id}`,
|
|
10055
10804
|
sendOnly: (tokens, network) => `Env\xEDa solo ${tokens} en ${network}; cualquier otra cosa puede perderse.`,
|
|
10056
10805
|
noDeposit: "El proveedor no devolvi\xF3 ninguna direcci\xF3n de dep\xF3sito.",
|
|
10057
|
-
hideDeposit: "Ocultar la direcci\xF3n de dep\xF3sito"
|
|
10806
|
+
hideDeposit: "Ocultar la direcci\xF3n de dep\xF3sito",
|
|
10807
|
+
fundingProblem: {
|
|
10808
|
+
noGas: "Tu wallet no tiene saldo suficiente para pagar la comisi\xF3n de red.",
|
|
10809
|
+
sponsorNoGas: "Ahora no se puede cubrir la comisi\xF3n de red. Intenta de nuevo m\xE1s tarde.",
|
|
10810
|
+
noBalance: "Tu wallet no tiene suficiente USDC para este monto.",
|
|
10811
|
+
notPaid: "El pago no se envi\xF3.",
|
|
10812
|
+
failed: "No se pudo completar el pago. Intenta de nuevo.",
|
|
10813
|
+
delayed: "Est\xE1 tardando m\xE1s de lo normal. Estamos haciendo seguimiento con el emisor de la tarjeta."
|
|
10814
|
+
}
|
|
10058
10815
|
},
|
|
10059
10816
|
pt: {
|
|
10060
10817
|
funding: {
|
|
@@ -10212,9 +10969,28 @@ var CARD_COPY = {
|
|
|
10212
10969
|
chain: (id) => `rede ${id}`,
|
|
10213
10970
|
sendOnly: (tokens, network) => `Envie apenas ${tokens} na ${network}; qualquer outra coisa pode ser perdida.`,
|
|
10214
10971
|
noDeposit: "O provedor n\xE3o retornou nenhum endere\xE7o de dep\xF3sito.",
|
|
10215
|
-
hideDeposit: "Ocultar o endere\xE7o de dep\xF3sito"
|
|
10972
|
+
hideDeposit: "Ocultar o endere\xE7o de dep\xF3sito",
|
|
10973
|
+
fundingProblem: {
|
|
10974
|
+
noGas: "Sua carteira n\xE3o tem saldo suficiente para pagar a taxa de rede.",
|
|
10975
|
+
sponsorNoGas: "A taxa de rede n\xE3o pode ser coberta agora. Tente novamente mais tarde.",
|
|
10976
|
+
noBalance: "Sua carteira n\xE3o tem USDC suficiente para este valor.",
|
|
10977
|
+
notPaid: "O pagamento n\xE3o foi enviado.",
|
|
10978
|
+
failed: "N\xE3o foi poss\xEDvel concluir o pagamento. Tente novamente.",
|
|
10979
|
+
delayed: "Est\xE1 demorando mais que o normal. Estamos acompanhando com o emissor do cart\xE3o."
|
|
10980
|
+
}
|
|
10216
10981
|
}
|
|
10217
10982
|
};
|
|
10983
|
+
var CREDIT_DELAYED = "provider_credit_delayed";
|
|
10984
|
+
function fundingProblemText(error, copy) {
|
|
10985
|
+
const raw = error ?? "";
|
|
10986
|
+
if (/^TX_INSUFFICIENT_BALANCE|needed \(fee/.test(raw)) {
|
|
10987
|
+
if (/sponsor/i.test(raw)) return copy.fundingProblem.sponsorNoGas;
|
|
10988
|
+
return /token balance/i.test(raw) ? copy.fundingProblem.noBalance : copy.fundingProblem.noGas;
|
|
10989
|
+
}
|
|
10990
|
+
if (/insufficient_usdc/.test(raw)) return copy.fundingProblem.noBalance;
|
|
10991
|
+
if (/^(payment_not_received|cosign_rejected|cosign_expired)/.test(raw)) return copy.fundingProblem.notPaid;
|
|
10992
|
+
return copy.fundingProblem.failed;
|
|
10993
|
+
}
|
|
10218
10994
|
|
|
10219
10995
|
// src/components/card-modal/card-kyc.ts
|
|
10220
10996
|
var nonEmpty = (value) => typeof value === "string" && !!value.trim();
|
|
@@ -10299,10 +11075,20 @@ function money(amount, currency, language) {
|
|
|
10299
11075
|
function groupPan(pan) {
|
|
10300
11076
|
return pan.replace(/\s+/g, "").replace(/(.{4})/g, "$1 ").trim();
|
|
10301
11077
|
}
|
|
10302
|
-
function
|
|
11078
|
+
function errorText2(e, fallback, copy) {
|
|
10303
11079
|
if (core.isPollarApiError(e)) {
|
|
10304
11080
|
const known = copy.errors[e.code];
|
|
10305
11081
|
if (known) return known;
|
|
11082
|
+
if (e.code === "SDK_CARDS_FUNDING_WALLET_NOT_READY") {
|
|
11083
|
+
const { reason, code, message: message2 } = e.body;
|
|
11084
|
+
if (reason === "insufficient_usdc") return copy.fundingProblem.noBalance;
|
|
11085
|
+
if (reason === "build_failed" || reason === "payment_rejected") {
|
|
11086
|
+
return fundingProblemText(
|
|
11087
|
+
`${typeof code === "string" ? code : ""}: ${typeof message2 === "string" ? message2 : ""}`,
|
|
11088
|
+
copy
|
|
11089
|
+
);
|
|
11090
|
+
}
|
|
11091
|
+
}
|
|
10306
11092
|
const providerMessage = e.body.providerMessage;
|
|
10307
11093
|
if (typeof providerMessage === "string" && providerMessage) return providerMessage;
|
|
10308
11094
|
const message = e.body.message;
|
|
@@ -10311,7 +11097,7 @@ function errorText(e, fallback, copy) {
|
|
|
10311
11097
|
}
|
|
10312
11098
|
return e instanceof Error && e.message ? e.message : fallback;
|
|
10313
11099
|
}
|
|
10314
|
-
function CardModal({ onClose }) {
|
|
11100
|
+
function CardModal({ onClose, initial }) {
|
|
10315
11101
|
const { getClient, styles, wallet } = usePollar();
|
|
10316
11102
|
const language = useModalLanguage();
|
|
10317
11103
|
const copy = CARD_COPY[language];
|
|
@@ -10327,9 +11113,10 @@ function CardModal({ onClose }) {
|
|
|
10327
11113
|
const [transactions, setTransactions] = react.useState(null);
|
|
10328
11114
|
const [deposit, setDeposit] = react.useState(null);
|
|
10329
11115
|
const [fundings, setFundings] = react.useState(null);
|
|
10330
|
-
const [fundAmount, setFundAmount] = react.useState(
|
|
11116
|
+
const [fundAmount, setFundAmount] = react.useState(() => seededAmount(initial?.amount));
|
|
10331
11117
|
const fundKey = react.useRef(null);
|
|
10332
|
-
const [fundChain, setFundChain] = react.useState(null);
|
|
11118
|
+
const [fundChain, setFundChain] = react.useState(initial?.chain ?? null);
|
|
11119
|
+
const fundPanelSeed = react.useRef(initial?.panel === "fund");
|
|
10333
11120
|
const [showManual, setShowManual] = react.useState(false);
|
|
10334
11121
|
const [occupations, setOccupations] = react.useState([]);
|
|
10335
11122
|
const [kyc, setKyc] = react.useState(emptyKyc);
|
|
@@ -10343,7 +11130,7 @@ function CardModal({ onClose }) {
|
|
|
10343
11130
|
const provider = providers?.[0] ?? null;
|
|
10344
11131
|
const fundingAsset = provider?.fundingAssets[0] ?? "USDC";
|
|
10345
11132
|
const fundChains = useChains().chains.filter(isFundingChain);
|
|
10346
|
-
const selectedFundChain = fundChain ?? fundChains[0] ?? "STELLAR";
|
|
11133
|
+
const selectedFundChain = (fundChain && fundChains.includes(fundChain) ? fundChain : null) ?? fundChains[0] ?? "STELLAR";
|
|
10347
11134
|
const fundAvailable = useWalletAvailable(panel === "fund" ? { chain: selectedFundChain, code: fundingAsset } : null);
|
|
10348
11135
|
const card = cards?.[0] ?? null;
|
|
10349
11136
|
const expiry = card?.expMonth && card.expYear ? `${card.expMonth}/${card.expYear.slice(-2)}` : null;
|
|
@@ -10391,7 +11178,7 @@ function CardModal({ onClose }) {
|
|
|
10391
11178
|
} catch (e) {
|
|
10392
11179
|
if (!cancelled) {
|
|
10393
11180
|
setProviders((cur) => cur ?? []);
|
|
10394
|
-
setError(
|
|
11181
|
+
setError(errorText2(e, copy.failed.load, copy));
|
|
10395
11182
|
}
|
|
10396
11183
|
}
|
|
10397
11184
|
})();
|
|
@@ -10440,7 +11227,7 @@ function CardModal({ onClose }) {
|
|
|
10440
11227
|
} catch (e) {
|
|
10441
11228
|
const step = requiredCardStep(e);
|
|
10442
11229
|
if (step) openStep(step);
|
|
10443
|
-
else setError(
|
|
11230
|
+
else setError(errorText2(e, fallback, copy));
|
|
10444
11231
|
} finally {
|
|
10445
11232
|
setBusy(null);
|
|
10446
11233
|
}
|
|
@@ -10507,6 +11294,11 @@ function CardModal({ onClose }) {
|
|
|
10507
11294
|
},
|
|
10508
11295
|
copy.failed.loadFundings
|
|
10509
11296
|
);
|
|
11297
|
+
react.useEffect(() => {
|
|
11298
|
+
if (!card || !fundPanelSeed.current) return;
|
|
11299
|
+
fundPanelSeed.current = false;
|
|
11300
|
+
void openFund();
|
|
11301
|
+
}, [card]);
|
|
10510
11302
|
const fund = () => run(
|
|
10511
11303
|
"fund-send",
|
|
10512
11304
|
async () => {
|
|
@@ -10529,6 +11321,7 @@ function CardModal({ onClose }) {
|
|
|
10529
11321
|
}
|
|
10530
11322
|
setFundings((cur) => [outcome.funding, ...(cur ?? []).filter((f) => f.id !== outcome.funding.id)]);
|
|
10531
11323
|
setFundAmount("");
|
|
11324
|
+
initial?.onFunded?.(outcome.funding);
|
|
10532
11325
|
},
|
|
10533
11326
|
copy.failed.fund
|
|
10534
11327
|
);
|
|
@@ -10637,7 +11430,7 @@ function CardModal({ onClose }) {
|
|
|
10637
11430
|
const blocked = requirements?.next ? blockedStepMessage(requirements.next, copy.blocked) : null;
|
|
10638
11431
|
const stepsPending = !!requirements?.next;
|
|
10639
11432
|
const title = panel === "fund" ? copy.title.addFunds : card ? card.nickname ?? copy.title.yourCard : copy.title.getCard;
|
|
10640
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11433
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10641
11434
|
"div",
|
|
10642
11435
|
{
|
|
10643
11436
|
className: "pollar-modal-card pollar-card-modal",
|
|
@@ -10945,12 +11738,13 @@ function CardModal({ onClose }) {
|
|
|
10945
11738
|
] }),
|
|
10946
11739
|
inflight && step > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-card-tx-meta", role: "status", children: [
|
|
10947
11740
|
copy.stepOf(step, steps.length),
|
|
10948
|
-
" \xB7
|
|
10949
|
-
|
|
11741
|
+
" \xB7",
|
|
11742
|
+
" ",
|
|
11743
|
+
f.error === CREDIT_DELAYED ? copy.fundingProblem.delayed : state?.hint
|
|
10950
11744
|
] }),
|
|
10951
11745
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-card-tx-meta", children: [
|
|
10952
11746
|
new Date(f.createdAt).toLocaleString(),
|
|
10953
|
-
f.status === "FAILED"
|
|
11747
|
+
f.status === "FAILED" ? ` \xB7 ${fundingProblemText(f.error, copy)}` : ""
|
|
10954
11748
|
] })
|
|
10955
11749
|
] }),
|
|
10956
11750
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-card-tx-amount", "data-direction": f.status === "CREDITED" ? "credit" : void 0, children: money(f.amount, "USD", language) })
|
|
@@ -11312,7 +12106,7 @@ function SessionsModal({ onClose }) {
|
|
|
11312
12106
|
setSigningOutEverywhere(false);
|
|
11313
12107
|
}
|
|
11314
12108
|
}, [getClient, onClose]);
|
|
11315
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12109
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11316
12110
|
SessionsModalTemplate,
|
|
11317
12111
|
{
|
|
11318
12112
|
theme,
|
|
@@ -11391,6 +12185,8 @@ var COSIGN_COPY = {
|
|
|
11391
12185
|
approve: "Approve",
|
|
11392
12186
|
approving: "Approving...",
|
|
11393
12187
|
genericError: "Something went wrong. Please try again.",
|
|
12188
|
+
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.",
|
|
12189
|
+
linkDevice: "Link this device",
|
|
11394
12190
|
transaction: "Transaction",
|
|
11395
12191
|
operations: {
|
|
11396
12192
|
payment: "Send",
|
|
@@ -11430,6 +12226,8 @@ var COSIGN_COPY = {
|
|
|
11430
12226
|
approve: "Aprobar",
|
|
11431
12227
|
approving: "Aprobando...",
|
|
11432
12228
|
genericError: "Algo sali\xF3 mal. Intenta de nuevo.",
|
|
12229
|
+
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.",
|
|
12230
|
+
linkDevice: "Vincular este dispositivo",
|
|
11433
12231
|
transaction: "Transacci\xF3n",
|
|
11434
12232
|
operations: {
|
|
11435
12233
|
payment: "Enviar",
|
|
@@ -11469,6 +12267,8 @@ var COSIGN_COPY = {
|
|
|
11469
12267
|
approve: "Aprovar",
|
|
11470
12268
|
approving: "Aprovando...",
|
|
11471
12269
|
genericError: "Algo deu errado. Tente novamente.",
|
|
12270
|
+
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.",
|
|
12271
|
+
linkDevice: "Vincular este dispositivo",
|
|
11472
12272
|
transaction: "Transa\xE7\xE3o",
|
|
11473
12273
|
operations: {
|
|
11474
12274
|
payment: "Enviar",
|
|
@@ -11514,6 +12314,8 @@ function CosignModalTemplate({
|
|
|
11514
12314
|
busy,
|
|
11515
12315
|
error,
|
|
11516
12316
|
approveBlocked = false,
|
|
12317
|
+
deviceNotLinked = false,
|
|
12318
|
+
onLinkDevice,
|
|
11517
12319
|
lastResolved,
|
|
11518
12320
|
explorerUrl,
|
|
11519
12321
|
closesIn = null,
|
|
@@ -11528,7 +12330,7 @@ function CosignModalTemplate({
|
|
|
11528
12330
|
const language = useInheritedLanguage(languageProp);
|
|
11529
12331
|
const copy = COSIGN_COPY[language];
|
|
11530
12332
|
const cssVars = buildModalCssVars(theme, accentColor, styleOverrides);
|
|
11531
|
-
const verified = verification?.ok === true;
|
|
12333
|
+
const verified = verification?.ok === true && !deviceNotLinked;
|
|
11532
12334
|
const canVote = !!current && verified && !busy && !approveBlocked;
|
|
11533
12335
|
const [verifiedOpenFor, setVerifiedOpenFor] = react.useState(null);
|
|
11534
12336
|
const verifiedOpen = !!current && verifiedOpenFor === current.id;
|
|
@@ -11613,11 +12415,11 @@ function CosignModalTemplate({
|
|
|
11613
12415
|
current && review && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `pollar-cosign-detail${pending.length > 1 ? " pollar-cosign-detail-grouped" : ""}`, children: [
|
|
11614
12416
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-cosign-detail-head", children: [
|
|
11615
12417
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-cosign-detail-title", children: review.title }),
|
|
11616
|
-
!verification && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-cosign-chip", children: [
|
|
12418
|
+
!verification && !deviceNotLinked && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-cosign-chip", children: [
|
|
11617
12419
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-hidden": true }),
|
|
11618
12420
|
copy.checking
|
|
11619
12421
|
] }),
|
|
11620
|
-
|
|
12422
|
+
verified && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11621
12423
|
"button",
|
|
11622
12424
|
{
|
|
11623
12425
|
type: "button",
|
|
@@ -11632,8 +12434,11 @@ function CosignModalTemplate({
|
|
|
11632
12434
|
)
|
|
11633
12435
|
] }),
|
|
11634
12436
|
/* @__PURE__ */ jsxRuntime.jsx(TxReview, { data: review, language }, current.id),
|
|
11635
|
-
|
|
11636
|
-
|
|
12437
|
+
verified && verifiedOpen && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-cosign-verify pollar-cosign-verify-ok", children: copy.checkedAgainstTurnkey }),
|
|
12438
|
+
deviceNotLinked ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-cosign-verify pollar-cosign-verify-bad", children: [
|
|
12439
|
+
copy.deviceNotLinked,
|
|
12440
|
+
onLinkDevice && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-cosign-link", onClick: onLinkDevice, children: copy.linkDevice })
|
|
12441
|
+
] }) : verification && !verification.ok && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-cosign-verify pollar-cosign-verify-bad", children: [
|
|
11637
12442
|
copy.notVerified,
|
|
11638
12443
|
" ",
|
|
11639
12444
|
verification.reason
|
|
@@ -11671,7 +12476,7 @@ var CLOSE_AFTER_SECONDS = 3;
|
|
|
11671
12476
|
var CLOSE_AFTER_SENT_SECONDS = 5;
|
|
11672
12477
|
var NEXT_REQUEST_EVERY_MS = 2e3;
|
|
11673
12478
|
function CosignModal({ nextStep = null, onClose }) {
|
|
11674
|
-
const { getClient, styles, network } = usePollar();
|
|
12479
|
+
const { getClient, styles, network, openRecoveryModal } = usePollar();
|
|
11675
12480
|
const { theme, accentColor, styleOverrides, overlayStyle } = modalChrome(styles);
|
|
11676
12481
|
const { pending, lastResolved, loaded, refresh, approve, reject, verify, inspectQuorum } = useCosign();
|
|
11677
12482
|
const language = useModalLanguage();
|
|
@@ -11681,10 +12486,13 @@ function CosignModal({ nextStep = null, onClose }) {
|
|
|
11681
12486
|
const [error, setError] = react.useState(null);
|
|
11682
12487
|
const [approveFailedFor, setApproveFailedFor] = react.useState(null);
|
|
11683
12488
|
const [quorumFailure, setQuorumFailure] = react.useState(null);
|
|
12489
|
+
const [deviceNotLinked, setDeviceNotLinked] = react.useState(false);
|
|
11684
12490
|
react.useEffect(() => {
|
|
11685
12491
|
let cancelled = false;
|
|
11686
12492
|
inspectQuorum().then((q) => {
|
|
11687
|
-
if (
|
|
12493
|
+
if (cancelled || q.ok) return;
|
|
12494
|
+
if (q.code === "DEVICE_NOT_ENROLLED") setDeviceNotLinked(true);
|
|
12495
|
+
else setQuorumFailure(q.reason);
|
|
11688
12496
|
}).catch(() => void 0);
|
|
11689
12497
|
return () => {
|
|
11690
12498
|
cancelled = true;
|
|
@@ -11754,14 +12562,15 @@ function CosignModal({ nextStep = null, onClose }) {
|
|
|
11754
12562
|
setError(
|
|
11755
12563
|
core.transactionErrorMessage(core.isPollarApiError(err) ? err.code : null, err instanceof Error ? err.message : null, language)
|
|
11756
12564
|
);
|
|
11757
|
-
if (kind === "approving"
|
|
12565
|
+
if (kind === "approving" && !(core.isPollarApiError(err) && err.code === "SDK_COSIGN_GAS_PENDING"))
|
|
12566
|
+
setApproveFailedFor(request.id);
|
|
11758
12567
|
} finally {
|
|
11759
12568
|
setBusy(null);
|
|
11760
12569
|
}
|
|
11761
12570
|
},
|
|
11762
12571
|
[]
|
|
11763
12572
|
);
|
|
11764
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12573
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11765
12574
|
CosignModalTemplate,
|
|
11766
12575
|
{
|
|
11767
12576
|
theme,
|
|
@@ -11773,6 +12582,11 @@ function CosignModal({ nextStep = null, onClose }) {
|
|
|
11773
12582
|
busy,
|
|
11774
12583
|
error,
|
|
11775
12584
|
approveBlocked: !!current && approveFailedFor === current.id,
|
|
12585
|
+
deviceNotLinked,
|
|
12586
|
+
onLinkDevice: () => {
|
|
12587
|
+
onClose();
|
|
12588
|
+
openRecoveryModal();
|
|
12589
|
+
},
|
|
11776
12590
|
...lastResolved ? { lastResolved } : {},
|
|
11777
12591
|
closesIn,
|
|
11778
12592
|
nextStep: awaitingNext ? nextStep : null,
|
|
@@ -11945,7 +12759,7 @@ function CustodyMigrationModal({ state, onMoved, onLater }) {
|
|
|
11945
12759
|
setBusy(false);
|
|
11946
12760
|
}
|
|
11947
12761
|
}
|
|
11948
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12762
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11949
12763
|
CustodyMigrationModalTemplate,
|
|
11950
12764
|
{
|
|
11951
12765
|
theme,
|
|
@@ -12406,7 +13220,7 @@ function RecoveryModalTemplate(p) {
|
|
|
12406
13220
|
}
|
|
12407
13221
|
);
|
|
12408
13222
|
}
|
|
12409
|
-
function
|
|
13223
|
+
function errorText3(err, language) {
|
|
12410
13224
|
return core.cosignRefusalMessage(err, language) ?? core.transactionErrorMessage(core.isPollarApiError(err) ? err.code : null, err instanceof Error ? err.message : null, language);
|
|
12411
13225
|
}
|
|
12412
13226
|
function RecoveryModal({ onClose }) {
|
|
@@ -12439,7 +13253,7 @@ function RecoveryModal({ onClose }) {
|
|
|
12439
13253
|
refreshRecovery();
|
|
12440
13254
|
}, [getClient, refreshRecovery]);
|
|
12441
13255
|
react.useEffect(() => {
|
|
12442
|
-
load().catch((err) => setError(
|
|
13256
|
+
load().catch((err) => setError(errorText3(err, language)));
|
|
12443
13257
|
}, [load]);
|
|
12444
13258
|
const onCloseRef = react.useRef(onClose);
|
|
12445
13259
|
onCloseRef.current = onClose;
|
|
@@ -12460,7 +13274,7 @@ function RecoveryModal({ onClose }) {
|
|
|
12460
13274
|
if (after?.notice) setNotice(after.notice);
|
|
12461
13275
|
if (after?.view) setView(after.view);
|
|
12462
13276
|
} catch (err) {
|
|
12463
|
-
setError(
|
|
13277
|
+
setError(errorText3(err, language));
|
|
12464
13278
|
} finally {
|
|
12465
13279
|
setBusy(null);
|
|
12466
13280
|
}
|
|
@@ -12468,7 +13282,7 @@ function RecoveryModal({ onClose }) {
|
|
|
12468
13282
|
[load]
|
|
12469
13283
|
);
|
|
12470
13284
|
const enrolled = !!thisDeviceKey && !!devices?.devices.some((d) => d.publicKey.toLowerCase() === thisDeviceKey);
|
|
12471
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13285
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12472
13286
|
RecoveryModalTemplate,
|
|
12473
13287
|
{
|
|
12474
13288
|
theme,
|
|
@@ -12614,7 +13428,7 @@ function ConfirmModal({ confirmation }) {
|
|
|
12614
13428
|
if (authState.step === "idle") rejectRef.current();
|
|
12615
13429
|
});
|
|
12616
13430
|
}, [getClient]);
|
|
12617
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13431
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: confirmation.reject, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12618
13432
|
"div",
|
|
12619
13433
|
{
|
|
12620
13434
|
className: "pollar-modal-card pollar-cosign-modal",
|
|
@@ -12744,7 +13558,7 @@ function TransactionModal({ onClose }) {
|
|
|
12744
13558
|
await getClient().signAndSubmitTx(transaction.buildData.unsignedXdr);
|
|
12745
13559
|
}
|
|
12746
13560
|
}
|
|
12747
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13561
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12748
13562
|
TransactionModalTemplate,
|
|
12749
13563
|
{
|
|
12750
13564
|
theme,
|
|
@@ -13101,7 +13915,7 @@ function TxHistoryModalTemplate({
|
|
|
13101
13915
|
);
|
|
13102
13916
|
}
|
|
13103
13917
|
var PAGE_SIZE2 = 10;
|
|
13104
|
-
function TxHistoryModal({ onClose }) {
|
|
13918
|
+
function TxHistoryModal({ onClose, initial }) {
|
|
13105
13919
|
const { getClient, styles, txHistory, wallets } = usePollar();
|
|
13106
13920
|
const { theme, accentColor, styleOverrides, overlayStyle } = modalChrome(styles);
|
|
13107
13921
|
const language = useModalLanguage();
|
|
@@ -13109,8 +13923,8 @@ function TxHistoryModal({ onClose }) {
|
|
|
13109
13923
|
const { chains } = useChains();
|
|
13110
13924
|
const [selectedChain, setSelectedChain] = react.useState(null);
|
|
13111
13925
|
react.useEffect(() => {
|
|
13112
|
-
if (selectedChain === null && chains.length > 0) setSelectedChain(chains[0]);
|
|
13113
|
-
}, [chains, selectedChain]);
|
|
13926
|
+
if (selectedChain === null && chains.length > 0) setSelectedChain(oneOf(chains, initial?.chain) ?? chains[0]);
|
|
13927
|
+
}, [chains, selectedChain, initial?.chain]);
|
|
13114
13928
|
const walletAddress = addressForChain(wallets, selectedChain);
|
|
13115
13929
|
const load = react.useCallback(
|
|
13116
13930
|
(nextOffset, chain) => {
|
|
@@ -13126,7 +13940,7 @@ function TxHistoryModal({ onClose }) {
|
|
|
13126
13940
|
const paged = (nextOffset) => {
|
|
13127
13941
|
if (selectedChain) load(nextOffset, selectedChain);
|
|
13128
13942
|
};
|
|
13129
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13943
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13130
13944
|
TxHistoryModalTemplate,
|
|
13131
13945
|
{
|
|
13132
13946
|
theme,
|
|
@@ -13357,7 +14171,7 @@ function WalletBalanceModal({ onClose }) {
|
|
|
13357
14171
|
react.useEffect(() => {
|
|
13358
14172
|
void refreshWalletBalance();
|
|
13359
14173
|
}, [refreshWalletBalance]);
|
|
13360
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
14174
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PollarOverlay, { style: overlayStyle, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13361
14175
|
WalletBalanceModalTemplate,
|
|
13362
14176
|
{
|
|
13363
14177
|
theme,
|
|
@@ -13488,6 +14302,7 @@ var PollarContext = react.createContext(null);
|
|
|
13488
14302
|
var clientByConfig = /* @__PURE__ */ new WeakMap();
|
|
13489
14303
|
function PollarProvider({
|
|
13490
14304
|
client,
|
|
14305
|
+
language,
|
|
13491
14306
|
appConfig: appConfigProp,
|
|
13492
14307
|
adapters,
|
|
13493
14308
|
onStorageDegrade,
|
|
@@ -13649,6 +14464,13 @@ function PollarProvider({
|
|
|
13649
14464
|
const [kycModalOpen, setKycModalOpen] = react.useState(false);
|
|
13650
14465
|
const [kycModalOptions, setKycModalOptions] = react.useState({});
|
|
13651
14466
|
const [rampModalOpen, setRampModalOpen] = react.useState(false);
|
|
14467
|
+
const [rampSeed, seedRamp] = useModalOptions();
|
|
14468
|
+
const [receiveSeed, seedReceive] = useModalOptions();
|
|
14469
|
+
const [txHistorySeed, seedTxHistory] = useModalOptions();
|
|
14470
|
+
const [sendModalOptions, setSendModalOptions] = react.useState(void 0);
|
|
14471
|
+
const [swapModalOptions, setSwapModalOptions] = react.useState(void 0);
|
|
14472
|
+
const [earnModalOptions, setEarnModalOptions] = react.useState(void 0);
|
|
14473
|
+
const [cardModalOptions, setCardModalOptions] = react.useState(void 0);
|
|
13652
14474
|
const [txHistoryModalOpen, setTxHistoryModalOpen] = react.useState(false);
|
|
13653
14475
|
const [walletBalanceModalOpen, setWalletBalanceModalOpen] = react.useState(false);
|
|
13654
14476
|
const [enabledAssetsModalOpen, setEnabledAssetsModalOpen] = react.useState(false);
|
|
@@ -13657,6 +14479,9 @@ function PollarProvider({
|
|
|
13657
14479
|
const [earnModalOpen, setEarnModalOpen] = react.useState(false);
|
|
13658
14480
|
const [sendModalKey, setSendModalKey] = react.useState(0);
|
|
13659
14481
|
const [swapModalKey, setSwapModalKey] = react.useState(0);
|
|
14482
|
+
const [bridgeModalOpen, setBridgeModalOpen] = react.useState(false);
|
|
14483
|
+
const [bridgeModalKey, setBridgeModalKey] = react.useState(0);
|
|
14484
|
+
const [bridgeModalOptions, setBridgeModalOptions] = react.useState(void 0);
|
|
13660
14485
|
const [earnModalKey, setEarnModalKey] = react.useState(0);
|
|
13661
14486
|
const [cardModalOpen, setCardModalOpen] = react.useState(false);
|
|
13662
14487
|
const [cardModalKey, setCardModalKey] = react.useState(0);
|
|
@@ -13670,6 +14495,7 @@ function PollarProvider({
|
|
|
13670
14495
|
if (cosign.pending.length > cosignPendingCount.current) setCosignModalOpen(true);
|
|
13671
14496
|
cosignPendingCount.current = cosign.pending.length;
|
|
13672
14497
|
}, [cosign.pending.length]);
|
|
14498
|
+
react.useEffect(() => pollarClient.onCosignDeviceNotEnrolled(() => setRecoveryModalOpen(true)), [pollarClient]);
|
|
13673
14499
|
const [distributionRulesModalOpen, setDistributionRulesModalOpen] = react.useState(false);
|
|
13674
14500
|
react.useEffect(
|
|
13675
14501
|
() => pollarClient.onAuthStateChange((authState) => {
|
|
@@ -13682,6 +14508,7 @@ function PollarProvider({
|
|
|
13682
14508
|
setEnabledAssetsModalOpen(false);
|
|
13683
14509
|
setSendModalOpen(false);
|
|
13684
14510
|
setSwapModalOpen(false);
|
|
14511
|
+
setBridgeModalOpen(false);
|
|
13685
14512
|
setEarnModalOpen(false);
|
|
13686
14513
|
setCardModalOpen(false);
|
|
13687
14514
|
setReceiveModalOpen(false);
|
|
@@ -13765,7 +14592,10 @@ function PollarProvider({
|
|
|
13765
14592
|
openTxModal: () => setTransactionModalOpen(true),
|
|
13766
14593
|
// tx history
|
|
13767
14594
|
txHistory,
|
|
13768
|
-
openTxHistoryModal: () =>
|
|
14595
|
+
openTxHistoryModal: (options) => {
|
|
14596
|
+
seedTxHistory(options);
|
|
14597
|
+
setTxHistoryModalOpen(true);
|
|
14598
|
+
},
|
|
13769
14599
|
// wallet balance
|
|
13770
14600
|
walletBalance,
|
|
13771
14601
|
refreshWalletBalance,
|
|
@@ -13776,12 +14606,16 @@ function PollarProvider({
|
|
|
13776
14606
|
setTrustline: (asset, opts) => pollarClient.setTrustline(asset, opts),
|
|
13777
14607
|
openEnabledAssetsModal: () => setEnabledAssetsModalOpen(true),
|
|
13778
14608
|
// send / receive
|
|
13779
|
-
openSendModal: () => {
|
|
14609
|
+
openSendModal: (options) => {
|
|
14610
|
+
setSendModalOptions(options);
|
|
13780
14611
|
pollarClient.resetTransactionState();
|
|
13781
14612
|
setSendModalKey((k) => k + 1);
|
|
13782
14613
|
setSendModalOpen(true);
|
|
13783
14614
|
},
|
|
13784
|
-
openReceiveModal: () =>
|
|
14615
|
+
openReceiveModal: (options) => {
|
|
14616
|
+
seedReceive(options);
|
|
14617
|
+
setReceiveModalOpen(true);
|
|
14618
|
+
},
|
|
13785
14619
|
// swap
|
|
13786
14620
|
getSwapConfig: () => pollarClient.getSwapConfig(),
|
|
13787
14621
|
getSwapTokens: () => pollarClient.getSwapTokens(),
|
|
@@ -13790,24 +14624,32 @@ function PollarProvider({
|
|
|
13790
14624
|
getSolanaSwapConfig: () => pollarClient.getSolanaSwapConfig(),
|
|
13791
14625
|
getSolanaSwapQuote: (params) => pollarClient.getSolanaSwapQuote(params),
|
|
13792
14626
|
swapSolana: (quote, opts) => pollarClient.swapSolana(quote, opts),
|
|
13793
|
-
openSwapModal: () => {
|
|
14627
|
+
openSwapModal: (options) => {
|
|
14628
|
+
setSwapModalOptions(options);
|
|
13794
14629
|
pollarClient.resetTransactionState();
|
|
13795
14630
|
setSwapModalKey((k) => k + 1);
|
|
13796
14631
|
setSwapModalOpen(true);
|
|
13797
14632
|
},
|
|
14633
|
+
openBridgeModal: (options) => {
|
|
14634
|
+
setBridgeModalOptions(options);
|
|
14635
|
+
setBridgeModalKey((k) => k + 1);
|
|
14636
|
+
setBridgeModalOpen(true);
|
|
14637
|
+
},
|
|
13798
14638
|
// earn
|
|
13799
14639
|
getEarnProviders: () => pollarClient.getEarnProviders(),
|
|
13800
14640
|
getEarnOpportunities: (provider) => pollarClient.getEarnOpportunities(provider),
|
|
13801
14641
|
getEarnPosition: (params) => pollarClient.getEarnPosition(params),
|
|
13802
14642
|
earnDeposit: (params) => pollarClient.earnDeposit(params),
|
|
13803
14643
|
earnWithdraw: (params) => pollarClient.earnWithdraw(params),
|
|
13804
|
-
openEarnModal: () => {
|
|
14644
|
+
openEarnModal: (options) => {
|
|
14645
|
+
setEarnModalOptions(options);
|
|
13805
14646
|
pollarClient.resetTransactionState();
|
|
13806
14647
|
setEarnModalKey((k) => k + 1);
|
|
13807
14648
|
setEarnModalOpen(true);
|
|
13808
14649
|
},
|
|
13809
14650
|
// cards
|
|
13810
|
-
openCardModal: () => {
|
|
14651
|
+
openCardModal: (options) => {
|
|
14652
|
+
setCardModalOptions(options);
|
|
13811
14653
|
setCardModalKey((k) => k + 1);
|
|
13812
14654
|
setCardModalOpen(true);
|
|
13813
14655
|
},
|
|
@@ -13836,7 +14678,10 @@ function PollarProvider({
|
|
|
13836
14678
|
setKycModalOpen(true);
|
|
13837
14679
|
},
|
|
13838
14680
|
// ramp
|
|
13839
|
-
openRampModal: () =>
|
|
14681
|
+
openRampModal: (options) => {
|
|
14682
|
+
seedRamp(options);
|
|
14683
|
+
setRampModalOpen(true);
|
|
14684
|
+
},
|
|
13840
14685
|
// config
|
|
13841
14686
|
appConfig: resolvedConfig,
|
|
13842
14687
|
styles,
|
|
@@ -13871,7 +14716,7 @@ function PollarProvider({
|
|
|
13871
14716
|
retryConfig,
|
|
13872
14717
|
adapters
|
|
13873
14718
|
]);
|
|
13874
|
-
const modalLanguage = useProviderLanguage(pollarClient, contextValue.styles?.language);
|
|
14719
|
+
const modalLanguage = useProviderLanguage(pollarClient, contextValue.styles?.language, language);
|
|
13875
14720
|
return /* @__PURE__ */ jsxRuntime.jsx(PollarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(ModalLanguageContext.Provider, { value: modalLanguage, children: [
|
|
13876
14721
|
children,
|
|
13877
14722
|
loginModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setLoginModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(LoginModal, { onClose: () => setLoginModalOpen(false) }) }),
|
|
@@ -13898,16 +14743,17 @@ function PollarProvider({
|
|
|
13898
14743
|
...kycModalOptions.onApproved !== void 0 && { onApproved: kycModalOptions.onApproved }
|
|
13899
14744
|
}
|
|
13900
14745
|
) }),
|
|
13901
|
-
rampModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setRampModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(RampWidget, { onClose: () => setRampModalOpen(false) }) }),
|
|
13902
|
-
txHistoryModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setTxHistoryModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(TxHistoryModal, { onClose: () => setTxHistoryModalOpen(false) }) }),
|
|
14746
|
+
rampModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setRampModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(RampWidget, { onClose: () => setRampModalOpen(false), initial: rampSeed.options }) }, `ramp:${rampSeed.key}`),
|
|
14747
|
+
txHistoryModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setTxHistoryModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(TxHistoryModal, { onClose: () => setTxHistoryModalOpen(false), initial: txHistorySeed.options }) }, `history:${txHistorySeed.key}`),
|
|
13903
14748
|
walletBalanceModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setWalletBalanceModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(WalletBalanceModal, { onClose: () => setWalletBalanceModalOpen(false) }) }),
|
|
13904
14749
|
enabledAssetsModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setEnabledAssetsModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(EnabledAssetsModal, { onClose: () => setEnabledAssetsModalOpen(false) }) }),
|
|
13905
|
-
sendModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSendModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SendModal, { onClose: () => setSendModalOpen(false) }) }, sendModalKey),
|
|
13906
|
-
swapModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSwapModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SwapModal, { onClose: () => setSwapModalOpen(false) }) }, swapModalKey),
|
|
13907
|
-
|
|
14750
|
+
sendModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSendModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SendModal, { onClose: () => setSendModalOpen(false), initial: sendModalOptions }) }, `send:${sendModalKey}`),
|
|
14751
|
+
swapModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSwapModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SwapModal, { onClose: () => setSwapModalOpen(false), initial: swapModalOptions }) }, `swap:${swapModalKey}`),
|
|
14752
|
+
bridgeModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setBridgeModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(BridgeModal, { onClose: () => setBridgeModalOpen(false), initial: bridgeModalOptions }) }, bridgeModalKey),
|
|
14753
|
+
earnModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setEarnModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(EarnModal, { onClose: () => setEarnModalOpen(false), initial: earnModalOptions }) }, `earn:${earnModalKey}`),
|
|
13908
14754
|
cardModalOpen && // Keyed by the wallet too: a different user, or signing in with it open, starts it from scratch.
|
|
13909
|
-
/* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setCardModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(CardModal, { onClose: () => setCardModalOpen(false) }) }, `${cardModalKey}:${walletAddress}`),
|
|
13910
|
-
receiveModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setReceiveModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(ReceiveModal, { onClose: () => setReceiveModalOpen(false) }) }),
|
|
14755
|
+
/* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setCardModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(CardModal, { onClose: () => setCardModalOpen(false), initial: cardModalOptions }) }, `${cardModalKey}:${walletAddress}`),
|
|
14756
|
+
receiveModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setReceiveModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(ReceiveModal, { onClose: () => setReceiveModalOpen(false), initial: receiveSeed.options }) }, `receive:${receiveSeed.key}`),
|
|
13911
14757
|
sessionsModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSessionsModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SessionsModal, { onClose: () => setSessionsModalOpen(false) }) }),
|
|
13912
14758
|
cosignModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setCosignModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(CosignModal, { nextStep: cosignNextStep, onClose: () => setCosignModalOpen(false) }) }),
|
|
13913
14759
|
custodyMigration?.required && !custodyMigrationLater && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: refreshCustodyMigration, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -14721,6 +15567,8 @@ function WalletButton() {
|
|
|
14721
15567
|
);
|
|
14722
15568
|
}
|
|
14723
15569
|
|
|
15570
|
+
exports.BridgeModal = BridgeModal;
|
|
15571
|
+
exports.BridgeModalTemplate = BridgeModalTemplate;
|
|
14724
15572
|
exports.CardModal = CardModal;
|
|
14725
15573
|
exports.ChainSelect = ChainSelect;
|
|
14726
15574
|
exports.CosignModal = CosignModal;
|