@swype-org/react-sdk 0.1.34 → 0.1.36
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 +241 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +93 -1
- package/dist/index.d.ts +93 -1
- package/dist/index.js +232 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@ var react = require('react');
|
|
|
4
4
|
var reactAuth = require('@privy-io/react-auth');
|
|
5
5
|
var wagmi = require('wagmi');
|
|
6
6
|
var chains = require('wagmi/chains');
|
|
7
|
+
var connectors = require('wagmi/connectors');
|
|
7
8
|
var reactQuery = require('@tanstack/react-query');
|
|
8
9
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
10
|
var viem = require('viem');
|
|
@@ -77,6 +78,7 @@ function getTheme(mode) {
|
|
|
77
78
|
var SWYPE_PRIVY_APP_ID = "cmlil87uv004n0ck0blwumwek";
|
|
78
79
|
var wagmiConfig = wagmi.createConfig({
|
|
79
80
|
chains: [chains.mainnet, chains.arbitrum, chains.base],
|
|
81
|
+
connectors: [connectors.injected()],
|
|
80
82
|
transports: {
|
|
81
83
|
[chains.mainnet.id]: wagmi.http(),
|
|
82
84
|
[chains.arbitrum.id]: wagmi.http(),
|
|
@@ -2563,13 +2565,20 @@ var WALLET_EMOJIS = {
|
|
|
2563
2565
|
ora: "\u2666\uFE0F",
|
|
2564
2566
|
phantom: "\u{1F47B}"
|
|
2565
2567
|
};
|
|
2568
|
+
function truncateAddress(address) {
|
|
2569
|
+
if (address.length <= 10) return address;
|
|
2570
|
+
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
2571
|
+
}
|
|
2566
2572
|
function WalletPickerScreen({
|
|
2567
2573
|
providers,
|
|
2574
|
+
pendingConnections,
|
|
2568
2575
|
onSelectProvider,
|
|
2576
|
+
onContinueConnection,
|
|
2569
2577
|
onBack
|
|
2570
2578
|
}) {
|
|
2571
2579
|
const { tokens } = useSwypeConfig();
|
|
2572
2580
|
const [hoveredId, setHoveredId] = react.useState(null);
|
|
2581
|
+
const hasPending = pendingConnections != null && pendingConnections.length > 0;
|
|
2573
2582
|
const displayProviders = providers.length > 0 ? providers : [
|
|
2574
2583
|
{ id: "metamask", name: "MetaMask" },
|
|
2575
2584
|
{ id: "rabby", name: "Rabby" },
|
|
@@ -2585,8 +2594,44 @@ function WalletPickerScreen({
|
|
|
2585
2594
|
] }),
|
|
2586
2595
|
children: [
|
|
2587
2596
|
/* @__PURE__ */ jsxRuntime.jsx(ScreenHeader, { title: "Set up Swype", onBack }),
|
|
2588
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2589
|
-
|
|
2597
|
+
hasPending && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2598
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle4(tokens.text), children: "Continue where you left off" }),
|
|
2599
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: subtitleStyle4(tokens.textSecondary), children: "You have a wallet that still needs setup" }),
|
|
2600
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: pendingListStyle, children: pendingConnections.map((acct) => {
|
|
2601
|
+
const wallet = acct.wallets[0];
|
|
2602
|
+
const address = wallet ? truncateAddress(wallet.name) : void 0;
|
|
2603
|
+
const isHovered = hoveredId === `pending-${acct.id}`;
|
|
2604
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2605
|
+
"button",
|
|
2606
|
+
{
|
|
2607
|
+
onClick: () => onContinueConnection?.(acct.id),
|
|
2608
|
+
onMouseEnter: () => setHoveredId(`pending-${acct.id}`),
|
|
2609
|
+
onMouseLeave: () => setHoveredId(null),
|
|
2610
|
+
style: pendingCardStyle(tokens, isHovered),
|
|
2611
|
+
children: [
|
|
2612
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: pendingCardContentStyle, children: [
|
|
2613
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: pendingIconStyle, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: emojiStyle, children: WALLET_EMOJIS[acct.name.toLowerCase()] ?? acct.name.charAt(0) }) }),
|
|
2614
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: pendingInfoStyle, children: [
|
|
2615
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: pendingNameStyle(tokens.text), children: acct.name }),
|
|
2616
|
+
address && /* @__PURE__ */ jsxRuntime.jsx("span", { style: pendingAddressStyle(tokens.textMuted), children: address })
|
|
2617
|
+
] }),
|
|
2618
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: pendingBadgeStyle(tokens), children: "Setup incomplete" })
|
|
2619
|
+
] }),
|
|
2620
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: continueRowStyle(tokens), children: [
|
|
2621
|
+
"Continue setup",
|
|
2622
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z", fill: "currentColor" }) })
|
|
2623
|
+
] })
|
|
2624
|
+
]
|
|
2625
|
+
},
|
|
2626
|
+
acct.id
|
|
2627
|
+
);
|
|
2628
|
+
}) }),
|
|
2629
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: dividerStyle2(tokens.border), children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: dividerTextStyle(tokens.textMuted), children: "Or connect a new wallet" }) })
|
|
2630
|
+
] }),
|
|
2631
|
+
!hasPending && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2632
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle4(tokens.text), children: "Where are your stablecoins?" }),
|
|
2633
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: subtitleStyle4(tokens.textSecondary), children: "Select the wallet you want to deposit from" })
|
|
2634
|
+
] }),
|
|
2590
2635
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: gridStyle, children: [
|
|
2591
2636
|
displayProviders.map((p) => {
|
|
2592
2637
|
const emoji = WALLET_EMOJIS[p.name.toLowerCase()] ?? p.name.charAt(0);
|
|
@@ -2690,6 +2735,86 @@ var hintStyle2 = (color) => ({
|
|
|
2690
2735
|
color,
|
|
2691
2736
|
margin: "0 0 4px"
|
|
2692
2737
|
});
|
|
2738
|
+
var pendingListStyle = {
|
|
2739
|
+
display: "flex",
|
|
2740
|
+
flexDirection: "column",
|
|
2741
|
+
gap: 10,
|
|
2742
|
+
marginBottom: 20
|
|
2743
|
+
};
|
|
2744
|
+
var pendingCardStyle = (tokens, hovered) => ({
|
|
2745
|
+
display: "flex",
|
|
2746
|
+
flexDirection: "column",
|
|
2747
|
+
gap: 0,
|
|
2748
|
+
padding: 0,
|
|
2749
|
+
background: hovered ? tokens.bgHover : tokens.bgInput,
|
|
2750
|
+
border: `1.5px solid ${tokens.warning}44`,
|
|
2751
|
+
borderRadius: 16,
|
|
2752
|
+
cursor: "pointer",
|
|
2753
|
+
fontFamily: "inherit",
|
|
2754
|
+
transition: "background 0.15s ease",
|
|
2755
|
+
outline: "none",
|
|
2756
|
+
overflow: "hidden",
|
|
2757
|
+
textAlign: "left"
|
|
2758
|
+
});
|
|
2759
|
+
var pendingCardContentStyle = {
|
|
2760
|
+
display: "flex",
|
|
2761
|
+
alignItems: "center",
|
|
2762
|
+
gap: 12,
|
|
2763
|
+
padding: "14px 16px"
|
|
2764
|
+
};
|
|
2765
|
+
var pendingIconStyle = {
|
|
2766
|
+
flexShrink: 0
|
|
2767
|
+
};
|
|
2768
|
+
var pendingInfoStyle = {
|
|
2769
|
+
display: "flex",
|
|
2770
|
+
flexDirection: "column",
|
|
2771
|
+
gap: 2,
|
|
2772
|
+
flex: 1,
|
|
2773
|
+
minWidth: 0
|
|
2774
|
+
};
|
|
2775
|
+
var pendingNameStyle = (color) => ({
|
|
2776
|
+
fontSize: "0.92rem",
|
|
2777
|
+
fontWeight: 600,
|
|
2778
|
+
color
|
|
2779
|
+
});
|
|
2780
|
+
var pendingAddressStyle = (color) => ({
|
|
2781
|
+
fontSize: "0.78rem",
|
|
2782
|
+
color,
|
|
2783
|
+
fontFamily: "monospace"
|
|
2784
|
+
});
|
|
2785
|
+
var pendingBadgeStyle = (tokens) => ({
|
|
2786
|
+
fontSize: "0.72rem",
|
|
2787
|
+
fontWeight: 600,
|
|
2788
|
+
color: tokens.warningText ?? tokens.warning,
|
|
2789
|
+
background: tokens.warningBg ?? `${tokens.warning}1a`,
|
|
2790
|
+
padding: "3px 8px",
|
|
2791
|
+
borderRadius: 6,
|
|
2792
|
+
whiteSpace: "nowrap",
|
|
2793
|
+
flexShrink: 0
|
|
2794
|
+
});
|
|
2795
|
+
var continueRowStyle = (tokens) => ({
|
|
2796
|
+
display: "flex",
|
|
2797
|
+
alignItems: "center",
|
|
2798
|
+
justifyContent: "center",
|
|
2799
|
+
gap: 4,
|
|
2800
|
+
padding: "10px 16px",
|
|
2801
|
+
fontSize: "0.84rem",
|
|
2802
|
+
fontWeight: 600,
|
|
2803
|
+
color: tokens.accent,
|
|
2804
|
+
background: `${tokens.accent}0d`,
|
|
2805
|
+
borderTop: `1px solid ${tokens.accent}22`
|
|
2806
|
+
});
|
|
2807
|
+
var dividerStyle2 = (borderColor) => ({
|
|
2808
|
+
display: "flex",
|
|
2809
|
+
alignItems: "center",
|
|
2810
|
+
gap: 12,
|
|
2811
|
+
margin: "4px 0 16px"
|
|
2812
|
+
});
|
|
2813
|
+
var dividerTextStyle = (color) => ({
|
|
2814
|
+
fontSize: "0.82rem",
|
|
2815
|
+
color,
|
|
2816
|
+
whiteSpace: "nowrap"
|
|
2817
|
+
});
|
|
2693
2818
|
var DEFAULT_MAX = 500;
|
|
2694
2819
|
var ABSOLUTE_MIN = 1;
|
|
2695
2820
|
function buildTicks(min, max) {
|
|
@@ -3777,17 +3902,36 @@ function SwypePayment({
|
|
|
3777
3902
|
const [setupComplete, setSetupComplete] = react.useState(false);
|
|
3778
3903
|
const [setupStepLabel, setSetupStepLabel] = react.useState(void 0);
|
|
3779
3904
|
const [mobileFlow, setMobileFlow] = react.useState(false);
|
|
3905
|
+
const [mobileSetupFlow, setMobileSetupFlow] = react.useState(false);
|
|
3780
3906
|
const pollingTransferIdRef = react.useRef(null);
|
|
3781
3907
|
const mobileSigningTransferIdRef = react.useRef(null);
|
|
3782
3908
|
const processingStartedAtRef = react.useRef(null);
|
|
3783
3909
|
const [selectSourceChainName, setSelectSourceChainName] = react.useState("");
|
|
3784
3910
|
const [selectSourceTokenSymbol, setSelectSourceTokenSymbol] = react.useState("");
|
|
3785
3911
|
const initializedSelectSourceActionRef = react.useRef(null);
|
|
3912
|
+
const preSelectSourceStepRef = react.useRef(null);
|
|
3786
3913
|
const authExecutor = useAuthorizationExecutor();
|
|
3787
3914
|
const polling = useTransferPolling();
|
|
3788
3915
|
const transferSigning = useTransferSigning();
|
|
3789
3916
|
const sourceType = connectingNewAccount ? "providerId" : selectedWalletId ? "walletId" : selectedAccountId ? "accountId" : "providerId";
|
|
3790
3917
|
const sourceId = connectingNewAccount ? selectedProviderId ?? "" : selectedWalletId ? selectedWalletId : selectedAccountId ? selectedAccountId : selectedProviderId ?? "";
|
|
3918
|
+
const reloadAccounts = react.useCallback(async () => {
|
|
3919
|
+
const token = await getAccessToken();
|
|
3920
|
+
if (!token || !activeCredentialId) return;
|
|
3921
|
+
const [accts, prov] = await Promise.all([
|
|
3922
|
+
fetchAccounts(apiBaseUrl, token, activeCredentialId),
|
|
3923
|
+
fetchProviders(apiBaseUrl, token)
|
|
3924
|
+
]);
|
|
3925
|
+
setAccounts(accts);
|
|
3926
|
+
setProviders(prov);
|
|
3927
|
+
const parsedAmt = depositAmount != null ? depositAmount : 0;
|
|
3928
|
+
const defaults = computeSmartDefaults(accts, parsedAmt);
|
|
3929
|
+
if (defaults) {
|
|
3930
|
+
setSelectedAccountId(defaults.accountId);
|
|
3931
|
+
setSelectedWalletId(defaults.walletId);
|
|
3932
|
+
setConnectingNewAccount(false);
|
|
3933
|
+
}
|
|
3934
|
+
}, [getAccessToken, activeCredentialId, apiBaseUrl, depositAmount]);
|
|
3791
3935
|
react.useEffect(() => {
|
|
3792
3936
|
if (depositAmount != null) {
|
|
3793
3937
|
setAmount(depositAmount.toString());
|
|
@@ -3798,7 +3942,7 @@ function SwypePayment({
|
|
|
3798
3942
|
setVerificationTarget(null);
|
|
3799
3943
|
setOtpCode("");
|
|
3800
3944
|
}, []);
|
|
3801
|
-
|
|
3945
|
+
react.useCallback(async (provider) => {
|
|
3802
3946
|
setError(null);
|
|
3803
3947
|
try {
|
|
3804
3948
|
await initOAuth({ provider });
|
|
@@ -3937,7 +4081,10 @@ function SwypePayment({
|
|
|
3937
4081
|
} else if (prov.length > 0) {
|
|
3938
4082
|
setSelectedProviderId(prov[0].id);
|
|
3939
4083
|
}
|
|
3940
|
-
|
|
4084
|
+
const hasActiveWallet = accts.some(
|
|
4085
|
+
(a) => a.wallets.some((w) => w.status === "ACTIVE")
|
|
4086
|
+
);
|
|
4087
|
+
if ((accts.length === 0 || !hasActiveWallet) && step === "deposit") {
|
|
3941
4088
|
setStep("wallet-picker");
|
|
3942
4089
|
}
|
|
3943
4090
|
} catch (err) {
|
|
@@ -3996,7 +4143,24 @@ function SwypePayment({
|
|
|
3996
4143
|
return () => window.clearTimeout(timeoutId);
|
|
3997
4144
|
}, [step, polling.transfer, transfer, polling.stopPolling, onError]);
|
|
3998
4145
|
react.useEffect(() => {
|
|
3999
|
-
if (!
|
|
4146
|
+
if (!mobileSetupFlow) return;
|
|
4147
|
+
const polledTransfer = polling.transfer;
|
|
4148
|
+
if (!polledTransfer) return;
|
|
4149
|
+
if (polledTransfer.status !== "AUTHORIZED" && polledTransfer.status !== "COMPLETED") return;
|
|
4150
|
+
polling.stopPolling();
|
|
4151
|
+
setMobileFlow(false);
|
|
4152
|
+
setMobileSetupFlow(false);
|
|
4153
|
+
const finishSetup = async () => {
|
|
4154
|
+
try {
|
|
4155
|
+
await reloadAccounts();
|
|
4156
|
+
} catch {
|
|
4157
|
+
}
|
|
4158
|
+
setStep("deposit");
|
|
4159
|
+
};
|
|
4160
|
+
void finishSetup();
|
|
4161
|
+
}, [mobileSetupFlow, polling, reloadAccounts]);
|
|
4162
|
+
react.useEffect(() => {
|
|
4163
|
+
if (!mobileFlow || mobileSetupFlow) return;
|
|
4000
4164
|
const polledTransfer = polling.transfer;
|
|
4001
4165
|
if (!polledTransfer || polledTransfer.status !== "AUTHORIZED") return;
|
|
4002
4166
|
if (transferSigning.signing) return;
|
|
@@ -4014,7 +4178,7 @@ function SwypePayment({
|
|
|
4014
4178
|
}
|
|
4015
4179
|
};
|
|
4016
4180
|
void sign();
|
|
4017
|
-
}, [mobileFlow, polling.transfer, transferSigning, onError]);
|
|
4181
|
+
}, [mobileFlow, mobileSetupFlow, polling.transfer, transferSigning, onError]);
|
|
4018
4182
|
react.useEffect(() => {
|
|
4019
4183
|
if (!mobileFlow) return;
|
|
4020
4184
|
const transferIdToResume = pollingTransferIdRef.current ?? transfer?.id;
|
|
@@ -4062,12 +4226,30 @@ function SwypePayment({
|
|
|
4062
4226
|
initializedSelectSourceActionRef.current = pendingSelectSourceAction.id;
|
|
4063
4227
|
}, [pendingSelectSourceAction, selectSourceChoices, selectSourceRecommended]);
|
|
4064
4228
|
react.useEffect(() => {
|
|
4065
|
-
if (pendingSelectSourceAction && step === "processing") {
|
|
4229
|
+
if (pendingSelectSourceAction && (step === "processing" || step === "setup-status")) {
|
|
4230
|
+
preSelectSourceStepRef.current = step;
|
|
4066
4231
|
setStep("select-source");
|
|
4067
4232
|
} else if (!pendingSelectSourceAction && step === "select-source") {
|
|
4068
|
-
setStep("processing");
|
|
4233
|
+
setStep(preSelectSourceStepRef.current ?? "processing");
|
|
4234
|
+
preSelectSourceStepRef.current = null;
|
|
4069
4235
|
}
|
|
4070
4236
|
}, [pendingSelectSourceAction, step]);
|
|
4237
|
+
const SETUP_ACTION_LABELS = react.useMemo(() => ({
|
|
4238
|
+
OPEN_PROVIDER: "Connecting wallet",
|
|
4239
|
+
SELECT_SOURCE: "Selecting source",
|
|
4240
|
+
SWITCH_CHAIN: "Switching network",
|
|
4241
|
+
APPROVE_PERMIT2: "Approving tokens",
|
|
4242
|
+
SIGN_PERMIT2: "Signing permit",
|
|
4243
|
+
DEPLOY_SMART_ACCOUNT: "Setting up account",
|
|
4244
|
+
CREATE_SMART_ACCOUNT: "Creating account"
|
|
4245
|
+
}), []);
|
|
4246
|
+
react.useEffect(() => {
|
|
4247
|
+
if (step !== "setup-status") return;
|
|
4248
|
+
const actionType = authExecutor.currentAction?.type;
|
|
4249
|
+
if (!actionType) return;
|
|
4250
|
+
const label = SETUP_ACTION_LABELS[actionType];
|
|
4251
|
+
if (label) setSetupStepLabel(label);
|
|
4252
|
+
}, [step, authExecutor.currentAction, SETUP_ACTION_LABELS]);
|
|
4071
4253
|
const handleSelectSourceChainChange = react.useCallback(
|
|
4072
4254
|
(chainName) => {
|
|
4073
4255
|
setSelectSourceChainName(chainName);
|
|
@@ -4081,6 +4263,12 @@ function SwypePayment({
|
|
|
4081
4263
|
},
|
|
4082
4264
|
[selectSourceChoices, selectSourceRecommended]
|
|
4083
4265
|
);
|
|
4266
|
+
const pendingConnections = react.useMemo(
|
|
4267
|
+
() => accounts.filter(
|
|
4268
|
+
(a) => a.wallets.length > 0 && !a.wallets.some((w) => w.status === "ACTIVE")
|
|
4269
|
+
),
|
|
4270
|
+
[accounts]
|
|
4271
|
+
);
|
|
4084
4272
|
const selectedAccount = accounts.find((a) => a.id === selectedAccountId);
|
|
4085
4273
|
const selectedWallet = selectedAccount?.wallets.find((w) => w.id === selectedWalletId);
|
|
4086
4274
|
const sourceName = selectedAccount?.name ?? selectedWallet?.chain.name ?? "Wallet";
|
|
@@ -4224,7 +4412,10 @@ function SwypePayment({
|
|
|
4224
4412
|
await registerPasskey(apiBaseUrl, token, credentialId, publicKey);
|
|
4225
4413
|
setActiveCredentialId(credentialId);
|
|
4226
4414
|
window.localStorage.setItem(ACTIVE_CREDENTIAL_STORAGE_KEY, credentialId);
|
|
4227
|
-
|
|
4415
|
+
const hasActiveWallet = accounts.some(
|
|
4416
|
+
(a) => a.wallets.some((w) => w.status === "ACTIVE")
|
|
4417
|
+
);
|
|
4418
|
+
if (accounts.length === 0 || !hasActiveWallet) {
|
|
4228
4419
|
setStep("wallet-picker");
|
|
4229
4420
|
} else {
|
|
4230
4421
|
setStep("deposit");
|
|
@@ -4234,19 +4425,22 @@ function SwypePayment({
|
|
|
4234
4425
|
} finally {
|
|
4235
4426
|
setRegisteringPasskey(false);
|
|
4236
4427
|
}
|
|
4237
|
-
}, [getAccessToken, user, apiBaseUrl, accounts
|
|
4428
|
+
}, [getAccessToken, user, apiBaseUrl, accounts]);
|
|
4238
4429
|
const handleSkipPasskey = react.useCallback(() => {
|
|
4239
|
-
|
|
4430
|
+
const hasActiveWallet = accounts.some(
|
|
4431
|
+
(a) => a.wallets.some((w) => w.status === "ACTIVE")
|
|
4432
|
+
);
|
|
4433
|
+
if (accounts.length === 0 || !hasActiveWallet) {
|
|
4240
4434
|
setStep("wallet-picker");
|
|
4241
4435
|
} else {
|
|
4242
4436
|
setStep("deposit");
|
|
4243
4437
|
}
|
|
4244
|
-
}, [accounts
|
|
4438
|
+
}, [accounts]);
|
|
4245
4439
|
const handleSetupOneTap = react.useCallback(async (limit) => {
|
|
4246
4440
|
setOneTapLimit(limit);
|
|
4247
4441
|
setStep("setup-status");
|
|
4248
4442
|
setSetupComplete(false);
|
|
4249
|
-
setSetupStepLabel("
|
|
4443
|
+
setSetupStepLabel("Preparing");
|
|
4250
4444
|
setError(null);
|
|
4251
4445
|
try {
|
|
4252
4446
|
const token = await getAccessToken();
|
|
@@ -4254,6 +4448,7 @@ function SwypePayment({
|
|
|
4254
4448
|
if (!sourceId) {
|
|
4255
4449
|
throw new Error("No wallet selected for setup.");
|
|
4256
4450
|
}
|
|
4451
|
+
await updateUserConfig(apiBaseUrl, token, { defaultAllowance: limit });
|
|
4257
4452
|
const setupAmount = depositAmount ?? MIN_SEND_AMOUNT_USD;
|
|
4258
4453
|
const t = await createTransfer(apiBaseUrl, token, {
|
|
4259
4454
|
id: idempotencyKey,
|
|
@@ -4271,11 +4466,16 @@ function SwypePayment({
|
|
|
4271
4466
|
});
|
|
4272
4467
|
if (!shouldUseConnector) {
|
|
4273
4468
|
setMobileFlow(true);
|
|
4469
|
+
setMobileSetupFlow(true);
|
|
4470
|
+
pollingTransferIdRef.current = t.id;
|
|
4471
|
+
polling.startPolling(t.id);
|
|
4274
4472
|
window.location.href = t.authorizationSessions[0].uri;
|
|
4473
|
+
return;
|
|
4275
4474
|
} else {
|
|
4276
4475
|
await authExecutor.executeSession(t);
|
|
4277
4476
|
}
|
|
4278
4477
|
}
|
|
4478
|
+
await reloadAccounts();
|
|
4279
4479
|
setSetupStepLabel(void 0);
|
|
4280
4480
|
setSetupComplete(true);
|
|
4281
4481
|
} catch (err) {
|
|
@@ -4294,8 +4494,10 @@ function SwypePayment({
|
|
|
4294
4494
|
merchantAuthorization,
|
|
4295
4495
|
useWalletConnector,
|
|
4296
4496
|
authExecutor,
|
|
4497
|
+
polling,
|
|
4297
4498
|
onError,
|
|
4298
|
-
depositAmount
|
|
4499
|
+
depositAmount,
|
|
4500
|
+
reloadAccounts
|
|
4299
4501
|
]);
|
|
4300
4502
|
const handleSelectProvider = react.useCallback((providerId) => {
|
|
4301
4503
|
setSelectedProviderId(providerId);
|
|
@@ -4303,12 +4505,23 @@ function SwypePayment({
|
|
|
4303
4505
|
setConnectingNewAccount(true);
|
|
4304
4506
|
setStep("setup");
|
|
4305
4507
|
}, []);
|
|
4508
|
+
const handleContinueConnection = react.useCallback(
|
|
4509
|
+
(accountId) => {
|
|
4510
|
+
const acct = accounts.find((a) => a.id === accountId);
|
|
4511
|
+
setSelectedAccountId(accountId);
|
|
4512
|
+
setSelectedWalletId(acct?.wallets[0]?.id ?? null);
|
|
4513
|
+
setConnectingNewAccount(false);
|
|
4514
|
+
setStep("setup");
|
|
4515
|
+
},
|
|
4516
|
+
[accounts]
|
|
4517
|
+
);
|
|
4306
4518
|
const handleNewPayment = react.useCallback(() => {
|
|
4307
4519
|
setStep("deposit");
|
|
4308
4520
|
setTransfer(null);
|
|
4309
4521
|
setError(null);
|
|
4310
4522
|
setAmount(depositAmount != null ? depositAmount.toString() : "");
|
|
4311
4523
|
setMobileFlow(false);
|
|
4524
|
+
setMobileSetupFlow(false);
|
|
4312
4525
|
processingStartedAtRef.current = null;
|
|
4313
4526
|
pollingTransferIdRef.current = null;
|
|
4314
4527
|
mobileSigningTransferIdRef.current = null;
|
|
@@ -4341,6 +4554,7 @@ function SwypePayment({
|
|
|
4341
4554
|
setConnectingNewAccount(false);
|
|
4342
4555
|
setAmount(depositAmount != null ? depositAmount.toString() : "");
|
|
4343
4556
|
setMobileFlow(false);
|
|
4557
|
+
setMobileSetupFlow(false);
|
|
4344
4558
|
setSetupComplete(false);
|
|
4345
4559
|
resetHeadlessLogin();
|
|
4346
4560
|
}, [logout, polling, depositAmount, resetHeadlessLogin]);
|
|
@@ -4357,8 +4571,7 @@ function SwypePayment({
|
|
|
4357
4571
|
sending: activeOtpStatus === "sending-code",
|
|
4358
4572
|
error,
|
|
4359
4573
|
onBack,
|
|
4360
|
-
merchantInitials: merchantName ? merchantName.slice(0, 2).toUpperCase() : void 0
|
|
4361
|
-
onSocialLogin: handleSocialLogin
|
|
4574
|
+
merchantInitials: merchantName ? merchantName.slice(0, 2).toUpperCase() : void 0
|
|
4362
4575
|
}
|
|
4363
4576
|
);
|
|
4364
4577
|
}
|
|
@@ -4405,7 +4618,9 @@ function SwypePayment({
|
|
|
4405
4618
|
WalletPickerScreen,
|
|
4406
4619
|
{
|
|
4407
4620
|
providers,
|
|
4621
|
+
pendingConnections,
|
|
4408
4622
|
onSelectProvider: handleSelectProvider,
|
|
4623
|
+
onContinueConnection: handleContinueConnection,
|
|
4409
4624
|
onBack: () => setStep("create-passkey")
|
|
4410
4625
|
}
|
|
4411
4626
|
);
|
|
@@ -4544,6 +4759,16 @@ function SwypePayment({
|
|
|
4544
4759
|
return null;
|
|
4545
4760
|
}
|
|
4546
4761
|
|
|
4762
|
+
exports.IconCircle = IconCircle;
|
|
4763
|
+
exports.OutlineButton = OutlineButton;
|
|
4764
|
+
exports.PoweredByFooter = PoweredByFooter;
|
|
4765
|
+
exports.PrimaryButton = PrimaryButton;
|
|
4766
|
+
exports.ScreenHeader = ScreenHeader;
|
|
4767
|
+
exports.ScreenLayout = ScreenLayout;
|
|
4768
|
+
exports.SelectSourceScreen = SelectSourceScreen;
|
|
4769
|
+
exports.SettingsMenu = SettingsMenu;
|
|
4770
|
+
exports.Spinner = Spinner;
|
|
4771
|
+
exports.StepList = StepList;
|
|
4547
4772
|
exports.SwypePayment = SwypePayment;
|
|
4548
4773
|
exports.SwypeProvider = SwypeProvider;
|
|
4549
4774
|
exports.createPasskeyCredential = createPasskeyCredential;
|