@swype-org/react-sdk 0.1.33 → 0.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +354 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +354 -44
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1727,7 +1727,7 @@ var circleStyle = (bg, size) => ({
|
|
|
1727
1727
|
function OtpInput({ value, onChange, length = 6, disabled }) {
|
|
1728
1728
|
const { tokens } = useSwypeConfig();
|
|
1729
1729
|
const inputsRef = react.useRef([]);
|
|
1730
|
-
const digits = value.padEnd(length
|
|
1730
|
+
const digits = value.padEnd(length).split("").slice(0, length);
|
|
1731
1731
|
const focusInput = react.useCallback((index) => {
|
|
1732
1732
|
const clamped = Math.max(0, Math.min(index, length - 1));
|
|
1733
1733
|
inputsRef.current[clamped]?.focus();
|
|
@@ -3011,8 +3011,7 @@ function DepositScreen({
|
|
|
3011
3011
|
onLogout
|
|
3012
3012
|
}) {
|
|
3013
3013
|
const { tokens } = useSwypeConfig();
|
|
3014
|
-
const
|
|
3015
|
-
const sliderMax = Math.min(remainingLimit, availableBalance, 500);
|
|
3014
|
+
const amount = initialAmount;
|
|
3016
3015
|
const isLowBalance = availableBalance < MIN_DEPOSIT;
|
|
3017
3016
|
const canDeposit = amount >= MIN_DEPOSIT && amount <= remainingLimit && !isLowBalance && !processing;
|
|
3018
3017
|
const headerTitle = merchantName ? `Deposit to ${merchantName}` : "Deposit";
|
|
@@ -3124,17 +3123,6 @@ function DepositScreen({
|
|
|
3124
3123
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: chevronStyle2, children: ">" })
|
|
3125
3124
|
] })
|
|
3126
3125
|
] }),
|
|
3127
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3128
|
-
LimitSlider,
|
|
3129
|
-
{
|
|
3130
|
-
value: amount,
|
|
3131
|
-
min: MIN_DEPOSIT,
|
|
3132
|
-
max: sliderMax > MIN_DEPOSIT ? sliderMax : 20,
|
|
3133
|
-
step: 0.5,
|
|
3134
|
-
ticks: [MIN_DEPOSIT, 1, 5, 10, 20].filter((t) => t <= sliderMax || t <= 20),
|
|
3135
|
-
onChange: setAmount
|
|
3136
|
-
}
|
|
3137
|
-
),
|
|
3138
3126
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: detailsStyle, children: [
|
|
3139
3127
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: detailRowStyle(tokens.textMuted), children: [
|
|
3140
3128
|
"Remaining limit: ",
|
|
@@ -3259,14 +3247,45 @@ function SuccessScreen({
|
|
|
3259
3247
|
onDone,
|
|
3260
3248
|
onLogout,
|
|
3261
3249
|
onIncreaseLimits,
|
|
3262
|
-
onManageAccount
|
|
3250
|
+
onManageAccount,
|
|
3251
|
+
autoCloseSeconds
|
|
3263
3252
|
}) {
|
|
3264
3253
|
const { tokens } = useSwypeConfig();
|
|
3254
|
+
const [countdown, setCountdown] = react.useState(autoCloseSeconds ?? 0);
|
|
3255
|
+
const doneCalledRef = react.useRef(false);
|
|
3256
|
+
const handleDone = react.useCallback(() => {
|
|
3257
|
+
if (doneCalledRef.current) return;
|
|
3258
|
+
doneCalledRef.current = true;
|
|
3259
|
+
onDone();
|
|
3260
|
+
}, [onDone]);
|
|
3261
|
+
react.useEffect(() => {
|
|
3262
|
+
if (!autoCloseSeconds || autoCloseSeconds <= 0) return;
|
|
3263
|
+
const intervalId = window.setInterval(() => {
|
|
3264
|
+
setCountdown((prev) => {
|
|
3265
|
+
if (prev <= 1) {
|
|
3266
|
+
window.clearInterval(intervalId);
|
|
3267
|
+
return 0;
|
|
3268
|
+
}
|
|
3269
|
+
return prev - 1;
|
|
3270
|
+
});
|
|
3271
|
+
}, 1e3);
|
|
3272
|
+
return () => window.clearInterval(intervalId);
|
|
3273
|
+
}, [autoCloseSeconds]);
|
|
3274
|
+
react.useEffect(() => {
|
|
3275
|
+
if (autoCloseSeconds && countdown === 0) {
|
|
3276
|
+
handleDone();
|
|
3277
|
+
}
|
|
3278
|
+
}, [autoCloseSeconds, countdown, handleDone]);
|
|
3265
3279
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3266
3280
|
ScreenLayout,
|
|
3267
3281
|
{
|
|
3268
3282
|
footer: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3269
|
-
/* @__PURE__ */ jsxRuntime.jsx(PrimaryButton, { onClick:
|
|
3283
|
+
/* @__PURE__ */ jsxRuntime.jsx(PrimaryButton, { onClick: handleDone, children: "Done" }),
|
|
3284
|
+
autoCloseSeconds != null && autoCloseSeconds > 0 && /* @__PURE__ */ jsxRuntime.jsxs("p", { style: countdownStyle(tokens.textMuted), children: [
|
|
3285
|
+
"Returning to app in ",
|
|
3286
|
+
countdown,
|
|
3287
|
+
"s\u2026"
|
|
3288
|
+
] }),
|
|
3270
3289
|
onManageAccount && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onManageAccount, style: manageStyle(tokens.textMuted), children: "Manage Swype account \u2192" }),
|
|
3271
3290
|
/* @__PURE__ */ jsxRuntime.jsx(PoweredByFooter, {})
|
|
3272
3291
|
] }),
|
|
@@ -3390,6 +3409,12 @@ var upsellLinkStyle = (color) => ({
|
|
|
3390
3409
|
fontFamily: "inherit",
|
|
3391
3410
|
padding: 0
|
|
3392
3411
|
});
|
|
3412
|
+
var countdownStyle = (color) => ({
|
|
3413
|
+
fontSize: "0.82rem",
|
|
3414
|
+
color,
|
|
3415
|
+
margin: "10px 0 0",
|
|
3416
|
+
textAlign: "center"
|
|
3417
|
+
});
|
|
3393
3418
|
var manageStyle = (color) => ({
|
|
3394
3419
|
background: "transparent",
|
|
3395
3420
|
border: "none",
|
|
@@ -3403,6 +3428,233 @@ var manageStyle = (color) => ({
|
|
|
3403
3428
|
textAlign: "center",
|
|
3404
3429
|
padding: "12px 0 0"
|
|
3405
3430
|
});
|
|
3431
|
+
function SelectSourceScreen({
|
|
3432
|
+
choices,
|
|
3433
|
+
selectedChainName,
|
|
3434
|
+
selectedTokenSymbol,
|
|
3435
|
+
recommended,
|
|
3436
|
+
onChainChange,
|
|
3437
|
+
onTokenChange,
|
|
3438
|
+
onConfirm,
|
|
3439
|
+
onLogout
|
|
3440
|
+
}) {
|
|
3441
|
+
const { tokens } = useSwypeConfig();
|
|
3442
|
+
const selectedChain = choices.find((c) => c.chainName === selectedChainName) ?? choices[0];
|
|
3443
|
+
const tokenChoices = selectedChain?.tokens ?? [];
|
|
3444
|
+
const canConfirm = !!selectedChainName && !!selectedTokenSymbol;
|
|
3445
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3446
|
+
ScreenLayout,
|
|
3447
|
+
{
|
|
3448
|
+
footer: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3449
|
+
/* @__PURE__ */ jsxRuntime.jsx(PrimaryButton, { onClick: onConfirm, disabled: !canConfirm, children: "Confirm source" }),
|
|
3450
|
+
/* @__PURE__ */ jsxRuntime.jsx(PoweredByFooter, {})
|
|
3451
|
+
] }),
|
|
3452
|
+
children: [
|
|
3453
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3454
|
+
ScreenHeader,
|
|
3455
|
+
{
|
|
3456
|
+
title: "Select Source",
|
|
3457
|
+
right: /* @__PURE__ */ jsxRuntime.jsx(SettingsMenu, { onLogout })
|
|
3458
|
+
}
|
|
3459
|
+
),
|
|
3460
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: subtitleStyle7(tokens.textMuted), children: "Choose which chain and token to pay from." }),
|
|
3461
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: labelStyle2(tokens.textSecondary), children: "Chain" }),
|
|
3462
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: optionListStyle, children: choices.map((chain) => {
|
|
3463
|
+
const isSelected = chain.chainName === selectedChainName;
|
|
3464
|
+
const isRecommended = chain.chainName === recommended?.chainName;
|
|
3465
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3466
|
+
"button",
|
|
3467
|
+
{
|
|
3468
|
+
type: "button",
|
|
3469
|
+
onClick: () => onChainChange(chain.chainName),
|
|
3470
|
+
style: optionButtonStyle(tokens, isSelected),
|
|
3471
|
+
children: [
|
|
3472
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: optionContentStyle, children: [
|
|
3473
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: optionNameStyle(tokens.text), children: [
|
|
3474
|
+
chain.chainName,
|
|
3475
|
+
isRecommended && /* @__PURE__ */ jsxRuntime.jsx("span", { style: recommendedBadgeStyle(tokens.accent), children: " recommended" })
|
|
3476
|
+
] }),
|
|
3477
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: optionBalanceStyle(tokens.textMuted), children: [
|
|
3478
|
+
"$",
|
|
3479
|
+
chain.balance.toFixed(2)
|
|
3480
|
+
] })
|
|
3481
|
+
] }),
|
|
3482
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: radioStyle(tokens, isSelected), children: isSelected && /* @__PURE__ */ jsxRuntime.jsx("div", { style: radioDotStyle(tokens.accent) }) })
|
|
3483
|
+
]
|
|
3484
|
+
},
|
|
3485
|
+
chain.chainName
|
|
3486
|
+
);
|
|
3487
|
+
}) }),
|
|
3488
|
+
tokenChoices.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3489
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: labelStyle2(tokens.textSecondary), children: "Token" }),
|
|
3490
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: optionListStyle, children: tokenChoices.map((token) => {
|
|
3491
|
+
const isSelected = token.tokenSymbol === selectedTokenSymbol;
|
|
3492
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3493
|
+
"button",
|
|
3494
|
+
{
|
|
3495
|
+
type: "button",
|
|
3496
|
+
onClick: () => onTokenChange(token.tokenSymbol),
|
|
3497
|
+
style: optionButtonStyle(tokens, isSelected),
|
|
3498
|
+
children: [
|
|
3499
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: optionContentStyle, children: [
|
|
3500
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: optionNameStyle(tokens.text), children: token.tokenSymbol }),
|
|
3501
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: optionBalanceStyle(tokens.textMuted), children: [
|
|
3502
|
+
"$",
|
|
3503
|
+
token.balance.toFixed(2)
|
|
3504
|
+
] })
|
|
3505
|
+
] }),
|
|
3506
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: radioStyle(tokens, isSelected), children: isSelected && /* @__PURE__ */ jsxRuntime.jsx("div", { style: radioDotStyle(tokens.accent) }) })
|
|
3507
|
+
]
|
|
3508
|
+
},
|
|
3509
|
+
token.tokenSymbol
|
|
3510
|
+
);
|
|
3511
|
+
}) })
|
|
3512
|
+
] })
|
|
3513
|
+
]
|
|
3514
|
+
}
|
|
3515
|
+
);
|
|
3516
|
+
}
|
|
3517
|
+
var subtitleStyle7 = (color) => ({
|
|
3518
|
+
fontSize: "0.85rem",
|
|
3519
|
+
color,
|
|
3520
|
+
margin: "0 0 20px",
|
|
3521
|
+
lineHeight: 1.5
|
|
3522
|
+
});
|
|
3523
|
+
var labelStyle2 = (color) => ({
|
|
3524
|
+
display: "block",
|
|
3525
|
+
fontSize: "0.75rem",
|
|
3526
|
+
fontWeight: 600,
|
|
3527
|
+
color,
|
|
3528
|
+
textTransform: "uppercase",
|
|
3529
|
+
letterSpacing: "0.05em",
|
|
3530
|
+
marginBottom: 8
|
|
3531
|
+
});
|
|
3532
|
+
var optionListStyle = {
|
|
3533
|
+
display: "flex",
|
|
3534
|
+
flexDirection: "column",
|
|
3535
|
+
gap: 8,
|
|
3536
|
+
marginBottom: 20
|
|
3537
|
+
};
|
|
3538
|
+
var optionButtonStyle = (tokens, selected) => ({
|
|
3539
|
+
display: "flex",
|
|
3540
|
+
alignItems: "center",
|
|
3541
|
+
justifyContent: "space-between",
|
|
3542
|
+
padding: "14px 16px",
|
|
3543
|
+
background: tokens.bgInput,
|
|
3544
|
+
border: `1.5px solid ${selected ? tokens.accent : tokens.border}`,
|
|
3545
|
+
borderRadius: 14,
|
|
3546
|
+
cursor: "pointer",
|
|
3547
|
+
fontFamily: "inherit",
|
|
3548
|
+
textAlign: "left",
|
|
3549
|
+
transition: "border-color 0.15s ease"
|
|
3550
|
+
});
|
|
3551
|
+
var optionContentStyle = {
|
|
3552
|
+
display: "flex",
|
|
3553
|
+
flexDirection: "column",
|
|
3554
|
+
gap: 2
|
|
3555
|
+
};
|
|
3556
|
+
var optionNameStyle = (color) => ({
|
|
3557
|
+
fontSize: "0.9rem",
|
|
3558
|
+
fontWeight: 600,
|
|
3559
|
+
color
|
|
3560
|
+
});
|
|
3561
|
+
var recommendedBadgeStyle = (color) => ({
|
|
3562
|
+
fontSize: "0.7rem",
|
|
3563
|
+
fontWeight: 500,
|
|
3564
|
+
color,
|
|
3565
|
+
marginLeft: 6
|
|
3566
|
+
});
|
|
3567
|
+
var optionBalanceStyle = (color) => ({
|
|
3568
|
+
fontSize: "0.78rem",
|
|
3569
|
+
color
|
|
3570
|
+
});
|
|
3571
|
+
var radioStyle = (tokens, selected) => ({
|
|
3572
|
+
width: 20,
|
|
3573
|
+
height: 20,
|
|
3574
|
+
borderRadius: "50%",
|
|
3575
|
+
border: `2px solid ${selected ? tokens.accent : tokens.border}`,
|
|
3576
|
+
display: "flex",
|
|
3577
|
+
alignItems: "center",
|
|
3578
|
+
justifyContent: "center",
|
|
3579
|
+
flexShrink: 0
|
|
3580
|
+
});
|
|
3581
|
+
var radioDotStyle = (color) => ({
|
|
3582
|
+
width: 10,
|
|
3583
|
+
height: 10,
|
|
3584
|
+
borderRadius: "50%",
|
|
3585
|
+
background: color
|
|
3586
|
+
});
|
|
3587
|
+
var STEP_LABELS = ["Creating transfer", "Verifying", "Sent", "Done"];
|
|
3588
|
+
var PHASE_ACTIVE_INDEX = {
|
|
3589
|
+
creating: 0,
|
|
3590
|
+
verifying: 1,
|
|
3591
|
+
sent: 2,
|
|
3592
|
+
done: 4
|
|
3593
|
+
};
|
|
3594
|
+
function buildSteps(phase) {
|
|
3595
|
+
const activeIdx = PHASE_ACTIVE_INDEX[phase];
|
|
3596
|
+
return STEP_LABELS.map((label, i) => ({
|
|
3597
|
+
label,
|
|
3598
|
+
status: i < activeIdx ? "complete" : i === activeIdx ? "active" : "pending"
|
|
3599
|
+
}));
|
|
3600
|
+
}
|
|
3601
|
+
function TransferStatusScreen({
|
|
3602
|
+
phase,
|
|
3603
|
+
error,
|
|
3604
|
+
onLogout
|
|
3605
|
+
}) {
|
|
3606
|
+
const { tokens } = useSwypeConfig();
|
|
3607
|
+
const steps = buildSteps(phase);
|
|
3608
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ScreenLayout, { children: [
|
|
3609
|
+
/* @__PURE__ */ jsxRuntime.jsx(ScreenHeader, { right: /* @__PURE__ */ jsxRuntime.jsx(SettingsMenu, { onLogout }) }),
|
|
3610
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: contentStyle6, children: [
|
|
3611
|
+
/* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: 48 }),
|
|
3612
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle8(tokens.text), children: "Processing Transfer..." }),
|
|
3613
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: errorBannerStyle6(tokens), children: error }),
|
|
3614
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: stepsWrapStyle2, children: /* @__PURE__ */ jsxRuntime.jsx(StepList, { steps }) }),
|
|
3615
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: waitHintStyle2(tokens.textMuted), children: "Usually takes a few seconds" })
|
|
3616
|
+
] })
|
|
3617
|
+
] });
|
|
3618
|
+
}
|
|
3619
|
+
var contentStyle6 = {
|
|
3620
|
+
flex: 1,
|
|
3621
|
+
display: "flex",
|
|
3622
|
+
flexDirection: "column",
|
|
3623
|
+
alignItems: "center",
|
|
3624
|
+
justifyContent: "center",
|
|
3625
|
+
textAlign: "center",
|
|
3626
|
+
padding: "0 24px"
|
|
3627
|
+
};
|
|
3628
|
+
var headingStyle8 = (color) => ({
|
|
3629
|
+
fontSize: "1.45rem",
|
|
3630
|
+
fontWeight: 700,
|
|
3631
|
+
letterSpacing: "-0.02em",
|
|
3632
|
+
color,
|
|
3633
|
+
margin: "20px 0 16px"
|
|
3634
|
+
});
|
|
3635
|
+
var errorBannerStyle6 = (tokens) => ({
|
|
3636
|
+
background: tokens.errorBg,
|
|
3637
|
+
border: `1px solid ${tokens.error}66`,
|
|
3638
|
+
borderRadius: 16,
|
|
3639
|
+
padding: "11px 14px",
|
|
3640
|
+
color: tokens.error,
|
|
3641
|
+
fontSize: "0.84rem",
|
|
3642
|
+
marginBottom: 14,
|
|
3643
|
+
lineHeight: 1.5,
|
|
3644
|
+
width: "100%",
|
|
3645
|
+
textAlign: "left"
|
|
3646
|
+
});
|
|
3647
|
+
var stepsWrapStyle2 = {
|
|
3648
|
+
width: "100%",
|
|
3649
|
+
maxWidth: 280,
|
|
3650
|
+
textAlign: "left",
|
|
3651
|
+
marginBottom: 16
|
|
3652
|
+
};
|
|
3653
|
+
var waitHintStyle2 = (color) => ({
|
|
3654
|
+
fontSize: "0.82rem",
|
|
3655
|
+
color,
|
|
3656
|
+
margin: 0
|
|
3657
|
+
});
|
|
3406
3658
|
var ACTIVE_CREDENTIAL_STORAGE_KEY = "swype_active_credential_id";
|
|
3407
3659
|
var MIN_SEND_AMOUNT_USD = 0.25;
|
|
3408
3660
|
function computeSmartDefaults(accts, transferAmount) {
|
|
@@ -3481,7 +3733,9 @@ function SwypePayment({
|
|
|
3481
3733
|
idempotencyKey,
|
|
3482
3734
|
merchantAuthorization,
|
|
3483
3735
|
merchantName,
|
|
3484
|
-
onBack
|
|
3736
|
+
onBack,
|
|
3737
|
+
onDismiss,
|
|
3738
|
+
autoCloseSeconds
|
|
3485
3739
|
}) {
|
|
3486
3740
|
const { apiBaseUrl, tokens, depositAmount } = useSwypeConfig();
|
|
3487
3741
|
const { ready, authenticated, user, logout, getAccessToken } = reactAuth.usePrivy();
|
|
@@ -3529,6 +3783,7 @@ function SwypePayment({
|
|
|
3529
3783
|
const [selectSourceChainName, setSelectSourceChainName] = react.useState("");
|
|
3530
3784
|
const [selectSourceTokenSymbol, setSelectSourceTokenSymbol] = react.useState("");
|
|
3531
3785
|
const initializedSelectSourceActionRef = react.useRef(null);
|
|
3786
|
+
const preSelectSourceStepRef = react.useRef(null);
|
|
3532
3787
|
const authExecutor = useAuthorizationExecutor();
|
|
3533
3788
|
const polling = useTransferPolling();
|
|
3534
3789
|
const transferSigning = useTransferSigning();
|
|
@@ -3544,7 +3799,7 @@ function SwypePayment({
|
|
|
3544
3799
|
setVerificationTarget(null);
|
|
3545
3800
|
setOtpCode("");
|
|
3546
3801
|
}, []);
|
|
3547
|
-
|
|
3802
|
+
react.useCallback(async (provider) => {
|
|
3548
3803
|
setError(null);
|
|
3549
3804
|
try {
|
|
3550
3805
|
await initOAuth({ provider });
|
|
@@ -3807,6 +4062,44 @@ function SwypePayment({
|
|
|
3807
4062
|
}
|
|
3808
4063
|
initializedSelectSourceActionRef.current = pendingSelectSourceAction.id;
|
|
3809
4064
|
}, [pendingSelectSourceAction, selectSourceChoices, selectSourceRecommended]);
|
|
4065
|
+
react.useEffect(() => {
|
|
4066
|
+
if (pendingSelectSourceAction && (step === "processing" || step === "setup-status")) {
|
|
4067
|
+
preSelectSourceStepRef.current = step;
|
|
4068
|
+
setStep("select-source");
|
|
4069
|
+
} else if (!pendingSelectSourceAction && step === "select-source") {
|
|
4070
|
+
setStep(preSelectSourceStepRef.current ?? "processing");
|
|
4071
|
+
preSelectSourceStepRef.current = null;
|
|
4072
|
+
}
|
|
4073
|
+
}, [pendingSelectSourceAction, step]);
|
|
4074
|
+
const SETUP_ACTION_LABELS = react.useMemo(() => ({
|
|
4075
|
+
OPEN_PROVIDER: "Connecting wallet",
|
|
4076
|
+
SELECT_SOURCE: "Selecting source",
|
|
4077
|
+
SWITCH_CHAIN: "Switching network",
|
|
4078
|
+
APPROVE_PERMIT2: "Approving tokens",
|
|
4079
|
+
SIGN_PERMIT2: "Signing permit",
|
|
4080
|
+
DEPLOY_SMART_ACCOUNT: "Setting up account",
|
|
4081
|
+
CREATE_SMART_ACCOUNT: "Creating account"
|
|
4082
|
+
}), []);
|
|
4083
|
+
react.useEffect(() => {
|
|
4084
|
+
if (step !== "setup-status") return;
|
|
4085
|
+
const actionType = authExecutor.currentAction?.type;
|
|
4086
|
+
if (!actionType) return;
|
|
4087
|
+
const label = SETUP_ACTION_LABELS[actionType];
|
|
4088
|
+
if (label) setSetupStepLabel(label);
|
|
4089
|
+
}, [step, authExecutor.currentAction, SETUP_ACTION_LABELS]);
|
|
4090
|
+
const handleSelectSourceChainChange = react.useCallback(
|
|
4091
|
+
(chainName) => {
|
|
4092
|
+
setSelectSourceChainName(chainName);
|
|
4093
|
+
const chain = selectSourceChoices.find((c) => c.chainName === chainName);
|
|
4094
|
+
if (!chain || chain.tokens.length === 0) return;
|
|
4095
|
+
const recommendedToken = selectSourceRecommended?.chainName === chainName ? selectSourceRecommended.tokenSymbol : null;
|
|
4096
|
+
const hasRecommended = !!recommendedToken && chain.tokens.some((t) => t.tokenSymbol === recommendedToken);
|
|
4097
|
+
setSelectSourceTokenSymbol(
|
|
4098
|
+
hasRecommended ? recommendedToken : chain.tokens[0].tokenSymbol
|
|
4099
|
+
);
|
|
4100
|
+
},
|
|
4101
|
+
[selectSourceChoices, selectSourceRecommended]
|
|
4102
|
+
);
|
|
3810
4103
|
const selectedAccount = accounts.find((a) => a.id === selectedAccountId);
|
|
3811
4104
|
const selectedWallet = selectedAccount?.wallets.find((w) => w.id === selectedWalletId);
|
|
3812
4105
|
const sourceName = selectedAccount?.name ?? selectedWallet?.chain.name ?? "Wallet";
|
|
@@ -3972,7 +4265,7 @@ function SwypePayment({
|
|
|
3972
4265
|
setOneTapLimit(limit);
|
|
3973
4266
|
setStep("setup-status");
|
|
3974
4267
|
setSetupComplete(false);
|
|
3975
|
-
setSetupStepLabel("
|
|
4268
|
+
setSetupStepLabel("Preparing");
|
|
3976
4269
|
setError(null);
|
|
3977
4270
|
try {
|
|
3978
4271
|
const token = await getAccessToken();
|
|
@@ -4083,8 +4376,7 @@ function SwypePayment({
|
|
|
4083
4376
|
sending: activeOtpStatus === "sending-code",
|
|
4084
4377
|
error,
|
|
4085
4378
|
onBack,
|
|
4086
|
-
merchantInitials: merchantName ? merchantName.slice(0, 2).toUpperCase() : void 0
|
|
4087
|
-
onSocialLogin: handleSocialLogin
|
|
4379
|
+
merchantInitials: merchantName ? merchantName.slice(0, 2).toUpperCase() : void 0
|
|
4088
4380
|
}
|
|
4089
4381
|
);
|
|
4090
4382
|
}
|
|
@@ -4111,6 +4403,9 @@ function SwypePayment({
|
|
|
4111
4403
|
}
|
|
4112
4404
|
);
|
|
4113
4405
|
}
|
|
4406
|
+
if ((step === "login" || step === "otp-verify") && authenticated) {
|
|
4407
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ScreenLayout, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", padding: "48px 0", flex: 1, display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { label: "Verifying your passkey..." }) }) });
|
|
4408
|
+
}
|
|
4114
4409
|
if (step === "create-passkey") {
|
|
4115
4410
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4116
4411
|
CreatePasskeyScreen,
|
|
@@ -4176,7 +4471,7 @@ function SwypePayment({
|
|
|
4176
4471
|
sourceAddress,
|
|
4177
4472
|
sourceVerified,
|
|
4178
4473
|
availableBalance: maxSourceBalance,
|
|
4179
|
-
remainingLimit: oneTapLimit,
|
|
4474
|
+
remainingLimit: selectedAccount?.remainingAllowance ?? oneTapLimit,
|
|
4180
4475
|
tokenCount,
|
|
4181
4476
|
initialAmount: parsedAmt,
|
|
4182
4477
|
processing: creatingTransfer,
|
|
@@ -4190,25 +4485,36 @@ function SwypePayment({
|
|
|
4190
4485
|
);
|
|
4191
4486
|
}
|
|
4192
4487
|
if (step === "processing") {
|
|
4193
|
-
const currentActionType = authExecutor.currentAction?.type;
|
|
4194
4488
|
const polledStatus = polling.transfer?.status;
|
|
4195
|
-
const
|
|
4196
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4489
|
+
const transferPhase = creatingTransfer ? "creating" : mobileFlow || authExecutor.executing || transferSigning.signing ? "verifying" : polledStatus === "SENDING" || polledStatus === "SENT" || polling.isPolling ? "sent" : "creating";
|
|
4490
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4491
|
+
TransferStatusScreen,
|
|
4492
|
+
{
|
|
4493
|
+
phase: transferPhase,
|
|
4494
|
+
error: error || authExecutor.error || transferSigning.error || polling.error,
|
|
4495
|
+
onLogout: handleLogout
|
|
4496
|
+
}
|
|
4497
|
+
);
|
|
4498
|
+
}
|
|
4499
|
+
if (step === "select-source") {
|
|
4500
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4501
|
+
SelectSourceScreen,
|
|
4502
|
+
{
|
|
4503
|
+
choices: selectSourceChoices,
|
|
4504
|
+
selectedChainName: selectSourceChainName,
|
|
4505
|
+
selectedTokenSymbol: selectSourceTokenSymbol,
|
|
4506
|
+
recommended: selectSourceRecommended,
|
|
4507
|
+
onChainChange: handleSelectSourceChainChange,
|
|
4508
|
+
onTokenChange: setSelectSourceTokenSymbol,
|
|
4509
|
+
onConfirm: () => {
|
|
4510
|
+
authExecutor.resolveSelectSource({
|
|
4511
|
+
chainName: selectSourceChainName,
|
|
4512
|
+
tokenSymbol: selectSourceTokenSymbol
|
|
4513
|
+
});
|
|
4514
|
+
},
|
|
4515
|
+
onLogout: handleLogout
|
|
4516
|
+
}
|
|
4517
|
+
);
|
|
4212
4518
|
}
|
|
4213
4519
|
if (step === "success") {
|
|
4214
4520
|
transfer?.status === "COMPLETED";
|
|
@@ -4221,9 +4527,13 @@ function SwypePayment({
|
|
|
4221
4527
|
currency: displayCurrency,
|
|
4222
4528
|
merchantName,
|
|
4223
4529
|
sourceName,
|
|
4224
|
-
remainingLimit:
|
|
4225
|
-
|
|
4226
|
-
|
|
4530
|
+
remainingLimit: (() => {
|
|
4531
|
+
const limit = selectedAccount?.remainingAllowance ?? oneTapLimit;
|
|
4532
|
+
return limit > displayAmount ? limit - displayAmount : 0;
|
|
4533
|
+
})(),
|
|
4534
|
+
onDone: onDismiss ?? handleNewPayment,
|
|
4535
|
+
onLogout: handleLogout,
|
|
4536
|
+
autoCloseSeconds
|
|
4227
4537
|
}
|
|
4228
4538
|
);
|
|
4229
4539
|
}
|
|
@@ -4236,7 +4546,7 @@ function SwypePayment({
|
|
|
4236
4546
|
sourceAddress,
|
|
4237
4547
|
sourceVerified,
|
|
4238
4548
|
availableBalance: 0,
|
|
4239
|
-
remainingLimit: oneTapLimit,
|
|
4549
|
+
remainingLimit: selectedAccount?.remainingAllowance ?? oneTapLimit,
|
|
4240
4550
|
tokenCount,
|
|
4241
4551
|
initialAmount: depositAmount ?? 5,
|
|
4242
4552
|
processing: false,
|