@swype-org/react-sdk 0.1.131 → 0.1.133
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 +112 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +112 -34
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4251,7 +4251,9 @@ function DepositScreen({
|
|
|
4251
4251
|
onSelectAccount,
|
|
4252
4252
|
onAuthorizeAccount,
|
|
4253
4253
|
onAddProvider,
|
|
4254
|
-
onSelectToken
|
|
4254
|
+
onSelectToken,
|
|
4255
|
+
pendingSetup,
|
|
4256
|
+
onStartSetup
|
|
4255
4257
|
}) {
|
|
4256
4258
|
const { tokens } = useSwypeConfig();
|
|
4257
4259
|
const amount = initialAmount;
|
|
@@ -4259,6 +4261,29 @@ function DepositScreen({
|
|
|
4259
4261
|
const exceedsLimit = amount > remainingLimit && !isLowBalance;
|
|
4260
4262
|
const canDeposit = amount >= MIN_DEPOSIT && !exceedsLimit && !isLowBalance && !processing;
|
|
4261
4263
|
const headerTitle = merchantName ? `Deposit to ${merchantName}` : "Deposit";
|
|
4264
|
+
if (pendingSetup) {
|
|
4265
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4266
|
+
ScreenLayout,
|
|
4267
|
+
{
|
|
4268
|
+
footer: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4269
|
+
/* @__PURE__ */ jsxRuntime.jsx(PrimaryButton, { onClick: onStartSetup, children: "Set up One-Tap" }),
|
|
4270
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: setupHintStyle(tokens.textSecondary), children: "Choose your source and set your One-Tap limit to deposit instantly." }),
|
|
4271
|
+
/* @__PURE__ */ jsxRuntime.jsx(PoweredByFooter, {})
|
|
4272
|
+
] }),
|
|
4273
|
+
children: [
|
|
4274
|
+
/* @__PURE__ */ jsxRuntime.jsx(ScreenHeader, { title: headerTitle, right: /* @__PURE__ */ jsxRuntime.jsx(SettingsMenu, { onLogout }) }),
|
|
4275
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: setupContentStyle, children: [
|
|
4276
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: amountDisplayStyle, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { style: amountStyle(tokens), children: [
|
|
4277
|
+
"$",
|
|
4278
|
+
amount.toFixed(2)
|
|
4279
|
+
] }) }),
|
|
4280
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: setupDescStyle(tokens.textSecondary), children: "Set up your payment source to deposit with One-Tap \u2014 no approvals needed after setup." })
|
|
4281
|
+
] }),
|
|
4282
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: errorBannerStyle5(tokens), children: error })
|
|
4283
|
+
]
|
|
4284
|
+
}
|
|
4285
|
+
);
|
|
4286
|
+
}
|
|
4262
4287
|
if (isLowBalance) {
|
|
4263
4288
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4264
4289
|
ScreenLayout,
|
|
@@ -4521,6 +4546,29 @@ var switchHintStyle = (color) => ({
|
|
|
4521
4546
|
var outlineBtnWrapStyle = {
|
|
4522
4547
|
marginBottom: 8
|
|
4523
4548
|
};
|
|
4549
|
+
var setupContentStyle = {
|
|
4550
|
+
flex: 1,
|
|
4551
|
+
display: "flex",
|
|
4552
|
+
flexDirection: "column",
|
|
4553
|
+
alignItems: "center",
|
|
4554
|
+
justifyContent: "center",
|
|
4555
|
+
textAlign: "center",
|
|
4556
|
+
padding: "0 24px"
|
|
4557
|
+
};
|
|
4558
|
+
var setupDescStyle = (color) => ({
|
|
4559
|
+
fontSize: "0.88rem",
|
|
4560
|
+
color,
|
|
4561
|
+
margin: "8px 0 0",
|
|
4562
|
+
lineHeight: 1.6,
|
|
4563
|
+
maxWidth: 300
|
|
4564
|
+
});
|
|
4565
|
+
var setupHintStyle = (color) => ({
|
|
4566
|
+
textAlign: "center",
|
|
4567
|
+
fontSize: "0.78rem",
|
|
4568
|
+
color,
|
|
4569
|
+
margin: "12px 0 2px",
|
|
4570
|
+
lineHeight: 1.5
|
|
4571
|
+
});
|
|
4524
4572
|
function SuccessScreen({
|
|
4525
4573
|
amount,
|
|
4526
4574
|
currency,
|
|
@@ -4728,6 +4776,7 @@ function SelectSourceScreen({
|
|
|
4728
4776
|
onChainChange,
|
|
4729
4777
|
onTokenChange,
|
|
4730
4778
|
onConfirm,
|
|
4779
|
+
onBack,
|
|
4731
4780
|
onLogout
|
|
4732
4781
|
}) {
|
|
4733
4782
|
const { tokens } = useSwypeConfig();
|
|
@@ -4746,6 +4795,7 @@ function SelectSourceScreen({
|
|
|
4746
4795
|
ScreenHeader,
|
|
4747
4796
|
{
|
|
4748
4797
|
title: "Select Source",
|
|
4798
|
+
onBack,
|
|
4749
4799
|
right: /* @__PURE__ */ jsxRuntime.jsx(SettingsMenu, { onLogout })
|
|
4750
4800
|
}
|
|
4751
4801
|
),
|
|
@@ -5618,6 +5668,7 @@ function StepRenderer({
|
|
|
5618
5668
|
selectSourceChainName,
|
|
5619
5669
|
selectSourceTokenSymbol,
|
|
5620
5670
|
savingOneTapLimit,
|
|
5671
|
+
pendingSetup,
|
|
5621
5672
|
merchantName,
|
|
5622
5673
|
onBack,
|
|
5623
5674
|
onDismiss,
|
|
@@ -5734,6 +5785,8 @@ function StepRenderer({
|
|
|
5734
5785
|
);
|
|
5735
5786
|
}
|
|
5736
5787
|
if (step === "setup") {
|
|
5788
|
+
const hasPendingSelectSource = selectSourceChoices.length > 0;
|
|
5789
|
+
const setupSourceLabel = hasPendingSelectSource && selectSourceChainName && selectSourceTokenSymbol ? `${selectSourceTokenSymbol} on ${selectSourceChainName}` : selectedSourceLabel;
|
|
5737
5790
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5738
5791
|
SetupScreen,
|
|
5739
5792
|
{
|
|
@@ -5743,8 +5796,8 @@ function StepRenderer({
|
|
|
5743
5796
|
onSetupOneTap: handlers.onSetupOneTap,
|
|
5744
5797
|
onBack: () => handlers.onNavigate("deposit"),
|
|
5745
5798
|
onLogout: handlers.onLogout,
|
|
5746
|
-
onAdvanced: handlers.onSelectToken,
|
|
5747
|
-
selectedSourceLabel,
|
|
5799
|
+
onAdvanced: hasPendingSelectSource ? () => handlers.onNavigate("select-source") : handlers.onSelectToken,
|
|
5800
|
+
selectedSourceLabel: setupSourceLabel,
|
|
5748
5801
|
loading: savingOneTapLimit,
|
|
5749
5802
|
error: state.error
|
|
5750
5803
|
}
|
|
@@ -5792,7 +5845,9 @@ function StepRenderer({
|
|
|
5792
5845
|
onSelectAccount: handlers.onSelectAccount,
|
|
5793
5846
|
onAuthorizeAccount: handlers.onContinueConnection,
|
|
5794
5847
|
onAddProvider: () => handlers.onNavigate("wallet-picker"),
|
|
5795
|
-
onSelectToken: handlers.onSelectToken
|
|
5848
|
+
onSelectToken: handlers.onSelectToken,
|
|
5849
|
+
pendingSetup,
|
|
5850
|
+
onStartSetup: () => handlers.onNavigate("setup")
|
|
5796
5851
|
}
|
|
5797
5852
|
);
|
|
5798
5853
|
}
|
|
@@ -5824,6 +5879,7 @@ function StepRenderer({
|
|
|
5824
5879
|
);
|
|
5825
5880
|
}
|
|
5826
5881
|
if (step === "select-source") {
|
|
5882
|
+
const enteredFromSetup = state.previousStep === "setup";
|
|
5827
5883
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5828
5884
|
SelectSourceScreen,
|
|
5829
5885
|
{
|
|
@@ -5833,7 +5889,8 @@ function StepRenderer({
|
|
|
5833
5889
|
recommended: selectSourceRecommended,
|
|
5834
5890
|
onChainChange: handlers.onSelectSourceChainChange,
|
|
5835
5891
|
onTokenChange: handlers.onSetSelectSourceTokenSymbol,
|
|
5836
|
-
onConfirm: handlers.onConfirmSelectSource,
|
|
5892
|
+
onConfirm: enteredFromSetup ? () => handlers.onNavigate("setup") : handlers.onConfirmSelectSource,
|
|
5893
|
+
onBack: enteredFromSetup ? () => handlers.onNavigate("setup") : void 0,
|
|
5837
5894
|
onLogout: handlers.onLogout
|
|
5838
5895
|
}
|
|
5839
5896
|
);
|
|
@@ -6008,6 +6065,7 @@ function SwypePaymentInner({
|
|
|
6008
6065
|
const preSelectSourceStepRef = react.useRef(null);
|
|
6009
6066
|
const pendingTokenAuthRef = react.useRef(null);
|
|
6010
6067
|
const pendingTokenSelectionRef = react.useRef(null);
|
|
6068
|
+
const pendingTokenAuthSessionRef = react.useRef(null);
|
|
6011
6069
|
const reauthSessionIdRef = react.useRef(null);
|
|
6012
6070
|
const reauthTokenRef = react.useRef(null);
|
|
6013
6071
|
const checkingPasskeyRef = react.useRef(false);
|
|
@@ -6506,10 +6564,14 @@ function SwypePaymentInner({
|
|
|
6506
6564
|
dispatch({ type: "MOBILE_DEEPLINK_READY", deeplinkUri: session.uri });
|
|
6507
6565
|
triggerDeeplink(session.uri);
|
|
6508
6566
|
} else {
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6567
|
+
pendingTokenAuthSessionRef.current = {
|
|
6568
|
+
sessionId: session.id,
|
|
6569
|
+
walletId: _walletId,
|
|
6570
|
+
tokenSymbol,
|
|
6571
|
+
tokenAddress,
|
|
6572
|
+
chainId
|
|
6573
|
+
};
|
|
6574
|
+
dispatch({ type: "SELECT_TOKEN", walletId: _walletId, tokenSymbol });
|
|
6513
6575
|
dispatch({ type: "NAVIGATE", step: "setup" });
|
|
6514
6576
|
}
|
|
6515
6577
|
} catch (err) {
|
|
@@ -6658,12 +6720,40 @@ function SwypePaymentInner({
|
|
|
6658
6720
|
const token = await getAccessToken();
|
|
6659
6721
|
if (!token) throw new Error("Not authenticated");
|
|
6660
6722
|
await updateUserConfig(apiBaseUrl, token, { defaultAllowance: limit });
|
|
6661
|
-
if (authExecutor.
|
|
6723
|
+
if (authExecutor.pendingSelectSource) {
|
|
6724
|
+
authExecutor.resolveSelectSource({
|
|
6725
|
+
chainName: selectSourceChainName,
|
|
6726
|
+
tokenSymbol: selectSourceTokenSymbol
|
|
6727
|
+
});
|
|
6728
|
+
dispatch({ type: "NAVIGATE", step: "setup-status" });
|
|
6729
|
+
} else if (authExecutor.pendingOneTapSetup) {
|
|
6662
6730
|
authExecutor.resolveOneTapSetup();
|
|
6663
|
-
} else if (
|
|
6664
|
-
const
|
|
6665
|
-
|
|
6666
|
-
|
|
6731
|
+
} else if (pendingTokenAuthSessionRef.current) {
|
|
6732
|
+
const pending = pendingTokenAuthSessionRef.current;
|
|
6733
|
+
pendingTokenAuthSessionRef.current = null;
|
|
6734
|
+
pendingTokenAuthRef.current = {
|
|
6735
|
+
tokenAddress: pending.tokenAddress,
|
|
6736
|
+
chainId: pending.chainId,
|
|
6737
|
+
tokenSymbol: pending.tokenSymbol,
|
|
6738
|
+
walletId: pending.walletId
|
|
6739
|
+
};
|
|
6740
|
+
dispatch({ type: "SET_INCREASING_LIMIT", value: true });
|
|
6741
|
+
dispatch({ type: "NAVIGATE", step: "setup-status" });
|
|
6742
|
+
try {
|
|
6743
|
+
await authExecutor.executeSessionById(pending.sessionId);
|
|
6744
|
+
await reloadAccounts();
|
|
6745
|
+
dispatch({ type: "SELECT_TOKEN", walletId: pending.walletId, tokenSymbol: pending.tokenSymbol });
|
|
6746
|
+
} catch (authErr) {
|
|
6747
|
+
captureException(authErr);
|
|
6748
|
+
dispatch({
|
|
6749
|
+
type: "SET_ERROR",
|
|
6750
|
+
error: authErr instanceof Error ? authErr.message : "Failed to authorize token"
|
|
6751
|
+
});
|
|
6752
|
+
dispatch({ type: "NAVIGATE", step: "deposit" });
|
|
6753
|
+
} finally {
|
|
6754
|
+
pendingTokenAuthRef.current = null;
|
|
6755
|
+
dispatch({ type: "SET_INCREASING_LIMIT", value: false });
|
|
6756
|
+
}
|
|
6667
6757
|
} else {
|
|
6668
6758
|
dispatch({ type: "NAVIGATE", step: "deposit" });
|
|
6669
6759
|
}
|
|
@@ -6676,13 +6766,14 @@ function SwypePaymentInner({
|
|
|
6676
6766
|
} finally {
|
|
6677
6767
|
setSavingOneTapLimit(false);
|
|
6678
6768
|
}
|
|
6679
|
-
}, [getAccessToken, apiBaseUrl, authExecutor]);
|
|
6769
|
+
}, [getAccessToken, apiBaseUrl, authExecutor, reloadAccounts, onError, selectSourceChainName, selectSourceTokenSymbol]);
|
|
6680
6770
|
const handleNewPayment = react.useCallback(() => {
|
|
6681
6771
|
clearMobileFlowState();
|
|
6682
6772
|
processingStartedAtRef.current = null;
|
|
6683
6773
|
pollingTransferIdRef.current = null;
|
|
6684
6774
|
preSelectSourceStepRef.current = null;
|
|
6685
6775
|
pendingTokenSelectionRef.current = null;
|
|
6776
|
+
pendingTokenAuthSessionRef.current = null;
|
|
6686
6777
|
dispatch({
|
|
6687
6778
|
type: "NEW_PAYMENT",
|
|
6688
6779
|
depositAmount,
|
|
@@ -6701,6 +6792,7 @@ function SwypePaymentInner({
|
|
|
6701
6792
|
polling.stopPolling();
|
|
6702
6793
|
preSelectSourceStepRef.current = null;
|
|
6703
6794
|
pendingTokenSelectionRef.current = null;
|
|
6795
|
+
pendingTokenAuthSessionRef.current = null;
|
|
6704
6796
|
checkingPasskeyRef.current = false;
|
|
6705
6797
|
setAuthInput("");
|
|
6706
6798
|
setOtpCode("");
|
|
@@ -7205,24 +7297,9 @@ function SwypePaymentInner({
|
|
|
7205
7297
|
userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
|
|
7206
7298
|
});
|
|
7207
7299
|
if (isDesktop && state.step === "setup-status") {
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
let tokenSymbol;
|
|
7212
|
-
if (pendingTokenAuthRef.current) {
|
|
7213
|
-
const { tokenAddress, chainId } = pendingTokenAuthRef.current;
|
|
7214
|
-
const chainIdHex = `0x${chainId.toString(16)}`;
|
|
7215
|
-
const match = options.find(
|
|
7216
|
-
(opt) => opt.tokenAddress.toLowerCase() === tokenAddress.toLowerCase() && opt.chainId.toLowerCase() === chainIdHex.toLowerCase()
|
|
7217
|
-
);
|
|
7218
|
-
chainName = match?.chainName ?? recommended?.chainName ?? "Base";
|
|
7219
|
-
tokenSymbol = match?.tokenSymbol ?? recommended?.tokenSymbol ?? "USDC";
|
|
7220
|
-
} else {
|
|
7221
|
-
const choices = buildSelectSourceChoices(options);
|
|
7222
|
-
chainName = recommended?.chainName ?? choices[0]?.chainName ?? "Base";
|
|
7223
|
-
tokenSymbol = recommended?.tokenSymbol ?? choices[0]?.tokens[0]?.tokenSymbol ?? "USDC";
|
|
7224
|
-
}
|
|
7225
|
-
authExecutor.resolveSelectSource({ chainName, tokenSymbol });
|
|
7300
|
+
reloadAccounts().then(() => {
|
|
7301
|
+
dispatch({ type: "NAVIGATE", step: "deposit" });
|
|
7302
|
+
});
|
|
7226
7303
|
return;
|
|
7227
7304
|
}
|
|
7228
7305
|
preSelectSourceStepRef.current = state.step;
|
|
@@ -7231,7 +7308,7 @@ function SwypePaymentInner({
|
|
|
7231
7308
|
dispatch({ type: "NAVIGATE", step: preSelectSourceStepRef.current ?? "processing" });
|
|
7232
7309
|
preSelectSourceStepRef.current = null;
|
|
7233
7310
|
}
|
|
7234
|
-
}, [pendingSelectSourceAction, state.step, authExecutor, useWalletConnectorProp]);
|
|
7311
|
+
}, [pendingSelectSourceAction, state.step, authExecutor, useWalletConnectorProp, reloadAccounts]);
|
|
7235
7312
|
const pendingOneTapSetupAction = authExecutor.pendingOneTapSetup;
|
|
7236
7313
|
const preOneTapSetupStepRef = react.useRef(null);
|
|
7237
7314
|
react.useEffect(() => {
|
|
@@ -7329,6 +7406,7 @@ function SwypePaymentInner({
|
|
|
7329
7406
|
selectSourceChainName,
|
|
7330
7407
|
selectSourceTokenSymbol,
|
|
7331
7408
|
savingOneTapLimit,
|
|
7409
|
+
pendingSetup: !!pendingSelectSourceAction || !!pendingOneTapSetupAction,
|
|
7332
7410
|
merchantName,
|
|
7333
7411
|
onBack,
|
|
7334
7412
|
onDismiss,
|