@swype-org/react-sdk 0.1.132 → 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 +75 -26
- 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 +75 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -767,9 +767,10 @@ interface SelectSourceScreenProps {
|
|
|
767
767
|
onChainChange: (chainName: string) => void;
|
|
768
768
|
onTokenChange: (tokenSymbol: string) => void;
|
|
769
769
|
onConfirm: () => void;
|
|
770
|
+
onBack?: () => void;
|
|
770
771
|
onLogout: () => void;
|
|
771
772
|
}
|
|
772
|
-
declare function SelectSourceScreen({ choices, selectedChainName, selectedTokenSymbol, recommended, onChainChange, onTokenChange, onConfirm, onLogout, }: SelectSourceScreenProps): react_jsx_runtime.JSX.Element;
|
|
773
|
+
declare function SelectSourceScreen({ choices, selectedChainName, selectedTokenSymbol, recommended, onChainChange, onTokenChange, onConfirm, onBack, onLogout, }: SelectSourceScreenProps): react_jsx_runtime.JSX.Element;
|
|
773
774
|
|
|
774
775
|
interface ChainChoice {
|
|
775
776
|
chainName: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -767,9 +767,10 @@ interface SelectSourceScreenProps {
|
|
|
767
767
|
onChainChange: (chainName: string) => void;
|
|
768
768
|
onTokenChange: (tokenSymbol: string) => void;
|
|
769
769
|
onConfirm: () => void;
|
|
770
|
+
onBack?: () => void;
|
|
770
771
|
onLogout: () => void;
|
|
771
772
|
}
|
|
772
|
-
declare function SelectSourceScreen({ choices, selectedChainName, selectedTokenSymbol, recommended, onChainChange, onTokenChange, onConfirm, onLogout, }: SelectSourceScreenProps): react_jsx_runtime.JSX.Element;
|
|
773
|
+
declare function SelectSourceScreen({ choices, selectedChainName, selectedTokenSymbol, recommended, onChainChange, onTokenChange, onConfirm, onBack, onLogout, }: SelectSourceScreenProps): react_jsx_runtime.JSX.Element;
|
|
773
774
|
|
|
774
775
|
interface ChainChoice {
|
|
775
776
|
chainName: string;
|
package/dist/index.js
CHANGED
|
@@ -4248,7 +4248,9 @@ function DepositScreen({
|
|
|
4248
4248
|
onSelectAccount,
|
|
4249
4249
|
onAuthorizeAccount,
|
|
4250
4250
|
onAddProvider,
|
|
4251
|
-
onSelectToken
|
|
4251
|
+
onSelectToken,
|
|
4252
|
+
pendingSetup,
|
|
4253
|
+
onStartSetup
|
|
4252
4254
|
}) {
|
|
4253
4255
|
const { tokens } = useSwypeConfig();
|
|
4254
4256
|
const amount = initialAmount;
|
|
@@ -4256,6 +4258,29 @@ function DepositScreen({
|
|
|
4256
4258
|
const exceedsLimit = amount > remainingLimit && !isLowBalance;
|
|
4257
4259
|
const canDeposit = amount >= MIN_DEPOSIT && !exceedsLimit && !isLowBalance && !processing;
|
|
4258
4260
|
const headerTitle = merchantName ? `Deposit to ${merchantName}` : "Deposit";
|
|
4261
|
+
if (pendingSetup) {
|
|
4262
|
+
return /* @__PURE__ */ jsxs(
|
|
4263
|
+
ScreenLayout,
|
|
4264
|
+
{
|
|
4265
|
+
footer: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4266
|
+
/* @__PURE__ */ jsx(PrimaryButton, { onClick: onStartSetup, children: "Set up One-Tap" }),
|
|
4267
|
+
/* @__PURE__ */ jsx("p", { style: setupHintStyle(tokens.textSecondary), children: "Choose your source and set your One-Tap limit to deposit instantly." }),
|
|
4268
|
+
/* @__PURE__ */ jsx(PoweredByFooter, {})
|
|
4269
|
+
] }),
|
|
4270
|
+
children: [
|
|
4271
|
+
/* @__PURE__ */ jsx(ScreenHeader, { title: headerTitle, right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout }) }),
|
|
4272
|
+
/* @__PURE__ */ jsxs("div", { style: setupContentStyle, children: [
|
|
4273
|
+
/* @__PURE__ */ jsx("div", { style: amountDisplayStyle, children: /* @__PURE__ */ jsxs("span", { style: amountStyle(tokens), children: [
|
|
4274
|
+
"$",
|
|
4275
|
+
amount.toFixed(2)
|
|
4276
|
+
] }) }),
|
|
4277
|
+
/* @__PURE__ */ jsx("p", { style: setupDescStyle(tokens.textSecondary), children: "Set up your payment source to deposit with One-Tap \u2014 no approvals needed after setup." })
|
|
4278
|
+
] }),
|
|
4279
|
+
error && /* @__PURE__ */ jsx("div", { style: errorBannerStyle5(tokens), children: error })
|
|
4280
|
+
]
|
|
4281
|
+
}
|
|
4282
|
+
);
|
|
4283
|
+
}
|
|
4259
4284
|
if (isLowBalance) {
|
|
4260
4285
|
return /* @__PURE__ */ jsxs(
|
|
4261
4286
|
ScreenLayout,
|
|
@@ -4518,6 +4543,29 @@ var switchHintStyle = (color) => ({
|
|
|
4518
4543
|
var outlineBtnWrapStyle = {
|
|
4519
4544
|
marginBottom: 8
|
|
4520
4545
|
};
|
|
4546
|
+
var setupContentStyle = {
|
|
4547
|
+
flex: 1,
|
|
4548
|
+
display: "flex",
|
|
4549
|
+
flexDirection: "column",
|
|
4550
|
+
alignItems: "center",
|
|
4551
|
+
justifyContent: "center",
|
|
4552
|
+
textAlign: "center",
|
|
4553
|
+
padding: "0 24px"
|
|
4554
|
+
};
|
|
4555
|
+
var setupDescStyle = (color) => ({
|
|
4556
|
+
fontSize: "0.88rem",
|
|
4557
|
+
color,
|
|
4558
|
+
margin: "8px 0 0",
|
|
4559
|
+
lineHeight: 1.6,
|
|
4560
|
+
maxWidth: 300
|
|
4561
|
+
});
|
|
4562
|
+
var setupHintStyle = (color) => ({
|
|
4563
|
+
textAlign: "center",
|
|
4564
|
+
fontSize: "0.78rem",
|
|
4565
|
+
color,
|
|
4566
|
+
margin: "12px 0 2px",
|
|
4567
|
+
lineHeight: 1.5
|
|
4568
|
+
});
|
|
4521
4569
|
function SuccessScreen({
|
|
4522
4570
|
amount,
|
|
4523
4571
|
currency,
|
|
@@ -4725,6 +4773,7 @@ function SelectSourceScreen({
|
|
|
4725
4773
|
onChainChange,
|
|
4726
4774
|
onTokenChange,
|
|
4727
4775
|
onConfirm,
|
|
4776
|
+
onBack,
|
|
4728
4777
|
onLogout
|
|
4729
4778
|
}) {
|
|
4730
4779
|
const { tokens } = useSwypeConfig();
|
|
@@ -4743,6 +4792,7 @@ function SelectSourceScreen({
|
|
|
4743
4792
|
ScreenHeader,
|
|
4744
4793
|
{
|
|
4745
4794
|
title: "Select Source",
|
|
4795
|
+
onBack,
|
|
4746
4796
|
right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout })
|
|
4747
4797
|
}
|
|
4748
4798
|
),
|
|
@@ -5615,6 +5665,7 @@ function StepRenderer({
|
|
|
5615
5665
|
selectSourceChainName,
|
|
5616
5666
|
selectSourceTokenSymbol,
|
|
5617
5667
|
savingOneTapLimit,
|
|
5668
|
+
pendingSetup,
|
|
5618
5669
|
merchantName,
|
|
5619
5670
|
onBack,
|
|
5620
5671
|
onDismiss,
|
|
@@ -5731,6 +5782,8 @@ function StepRenderer({
|
|
|
5731
5782
|
);
|
|
5732
5783
|
}
|
|
5733
5784
|
if (step === "setup") {
|
|
5785
|
+
const hasPendingSelectSource = selectSourceChoices.length > 0;
|
|
5786
|
+
const setupSourceLabel = hasPendingSelectSource && selectSourceChainName && selectSourceTokenSymbol ? `${selectSourceTokenSymbol} on ${selectSourceChainName}` : selectedSourceLabel;
|
|
5734
5787
|
return /* @__PURE__ */ jsx(
|
|
5735
5788
|
SetupScreen,
|
|
5736
5789
|
{
|
|
@@ -5740,8 +5793,8 @@ function StepRenderer({
|
|
|
5740
5793
|
onSetupOneTap: handlers.onSetupOneTap,
|
|
5741
5794
|
onBack: () => handlers.onNavigate("deposit"),
|
|
5742
5795
|
onLogout: handlers.onLogout,
|
|
5743
|
-
onAdvanced: handlers.onSelectToken,
|
|
5744
|
-
selectedSourceLabel,
|
|
5796
|
+
onAdvanced: hasPendingSelectSource ? () => handlers.onNavigate("select-source") : handlers.onSelectToken,
|
|
5797
|
+
selectedSourceLabel: setupSourceLabel,
|
|
5745
5798
|
loading: savingOneTapLimit,
|
|
5746
5799
|
error: state.error
|
|
5747
5800
|
}
|
|
@@ -5789,7 +5842,9 @@ function StepRenderer({
|
|
|
5789
5842
|
onSelectAccount: handlers.onSelectAccount,
|
|
5790
5843
|
onAuthorizeAccount: handlers.onContinueConnection,
|
|
5791
5844
|
onAddProvider: () => handlers.onNavigate("wallet-picker"),
|
|
5792
|
-
onSelectToken: handlers.onSelectToken
|
|
5845
|
+
onSelectToken: handlers.onSelectToken,
|
|
5846
|
+
pendingSetup,
|
|
5847
|
+
onStartSetup: () => handlers.onNavigate("setup")
|
|
5793
5848
|
}
|
|
5794
5849
|
);
|
|
5795
5850
|
}
|
|
@@ -5821,6 +5876,7 @@ function StepRenderer({
|
|
|
5821
5876
|
);
|
|
5822
5877
|
}
|
|
5823
5878
|
if (step === "select-source") {
|
|
5879
|
+
const enteredFromSetup = state.previousStep === "setup";
|
|
5824
5880
|
return /* @__PURE__ */ jsx(
|
|
5825
5881
|
SelectSourceScreen,
|
|
5826
5882
|
{
|
|
@@ -5830,7 +5886,8 @@ function StepRenderer({
|
|
|
5830
5886
|
recommended: selectSourceRecommended,
|
|
5831
5887
|
onChainChange: handlers.onSelectSourceChainChange,
|
|
5832
5888
|
onTokenChange: handlers.onSetSelectSourceTokenSymbol,
|
|
5833
|
-
onConfirm: handlers.onConfirmSelectSource,
|
|
5889
|
+
onConfirm: enteredFromSetup ? () => handlers.onNavigate("setup") : handlers.onConfirmSelectSource,
|
|
5890
|
+
onBack: enteredFromSetup ? () => handlers.onNavigate("setup") : void 0,
|
|
5834
5891
|
onLogout: handlers.onLogout
|
|
5835
5892
|
}
|
|
5836
5893
|
);
|
|
@@ -6660,7 +6717,13 @@ function SwypePaymentInner({
|
|
|
6660
6717
|
const token = await getAccessToken();
|
|
6661
6718
|
if (!token) throw new Error("Not authenticated");
|
|
6662
6719
|
await updateUserConfig(apiBaseUrl, token, { defaultAllowance: limit });
|
|
6663
|
-
if (authExecutor.
|
|
6720
|
+
if (authExecutor.pendingSelectSource) {
|
|
6721
|
+
authExecutor.resolveSelectSource({
|
|
6722
|
+
chainName: selectSourceChainName,
|
|
6723
|
+
tokenSymbol: selectSourceTokenSymbol
|
|
6724
|
+
});
|
|
6725
|
+
dispatch({ type: "NAVIGATE", step: "setup-status" });
|
|
6726
|
+
} else if (authExecutor.pendingOneTapSetup) {
|
|
6664
6727
|
authExecutor.resolveOneTapSetup();
|
|
6665
6728
|
} else if (pendingTokenAuthSessionRef.current) {
|
|
6666
6729
|
const pending = pendingTokenAuthSessionRef.current;
|
|
@@ -6700,7 +6763,7 @@ function SwypePaymentInner({
|
|
|
6700
6763
|
} finally {
|
|
6701
6764
|
setSavingOneTapLimit(false);
|
|
6702
6765
|
}
|
|
6703
|
-
}, [getAccessToken, apiBaseUrl, authExecutor, reloadAccounts, onError]);
|
|
6766
|
+
}, [getAccessToken, apiBaseUrl, authExecutor, reloadAccounts, onError, selectSourceChainName, selectSourceTokenSymbol]);
|
|
6704
6767
|
const handleNewPayment = useCallback(() => {
|
|
6705
6768
|
clearMobileFlowState();
|
|
6706
6769
|
processingStartedAtRef.current = null;
|
|
@@ -7231,24 +7294,9 @@ function SwypePaymentInner({
|
|
|
7231
7294
|
userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
|
|
7232
7295
|
});
|
|
7233
7296
|
if (isDesktop && state.step === "setup-status") {
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
let tokenSymbol;
|
|
7238
|
-
if (pendingTokenAuthRef.current) {
|
|
7239
|
-
const { tokenAddress, chainId } = pendingTokenAuthRef.current;
|
|
7240
|
-
const chainIdHex = `0x${chainId.toString(16)}`;
|
|
7241
|
-
const match = options.find(
|
|
7242
|
-
(opt) => opt.tokenAddress.toLowerCase() === tokenAddress.toLowerCase() && opt.chainId.toLowerCase() === chainIdHex.toLowerCase()
|
|
7243
|
-
);
|
|
7244
|
-
chainName = match?.chainName ?? recommended?.chainName ?? "Base";
|
|
7245
|
-
tokenSymbol = match?.tokenSymbol ?? recommended?.tokenSymbol ?? "USDC";
|
|
7246
|
-
} else {
|
|
7247
|
-
const choices = buildSelectSourceChoices(options);
|
|
7248
|
-
chainName = recommended?.chainName ?? choices[0]?.chainName ?? "Base";
|
|
7249
|
-
tokenSymbol = recommended?.tokenSymbol ?? choices[0]?.tokens[0]?.tokenSymbol ?? "USDC";
|
|
7250
|
-
}
|
|
7251
|
-
authExecutor.resolveSelectSource({ chainName, tokenSymbol });
|
|
7297
|
+
reloadAccounts().then(() => {
|
|
7298
|
+
dispatch({ type: "NAVIGATE", step: "deposit" });
|
|
7299
|
+
});
|
|
7252
7300
|
return;
|
|
7253
7301
|
}
|
|
7254
7302
|
preSelectSourceStepRef.current = state.step;
|
|
@@ -7257,7 +7305,7 @@ function SwypePaymentInner({
|
|
|
7257
7305
|
dispatch({ type: "NAVIGATE", step: preSelectSourceStepRef.current ?? "processing" });
|
|
7258
7306
|
preSelectSourceStepRef.current = null;
|
|
7259
7307
|
}
|
|
7260
|
-
}, [pendingSelectSourceAction, state.step, authExecutor, useWalletConnectorProp]);
|
|
7308
|
+
}, [pendingSelectSourceAction, state.step, authExecutor, useWalletConnectorProp, reloadAccounts]);
|
|
7261
7309
|
const pendingOneTapSetupAction = authExecutor.pendingOneTapSetup;
|
|
7262
7310
|
const preOneTapSetupStepRef = useRef(null);
|
|
7263
7311
|
useEffect(() => {
|
|
@@ -7355,6 +7403,7 @@ function SwypePaymentInner({
|
|
|
7355
7403
|
selectSourceChainName,
|
|
7356
7404
|
selectSourceTokenSymbol,
|
|
7357
7405
|
savingOneTapLimit,
|
|
7406
|
+
pendingSetup: !!pendingSelectSourceAction || !!pendingOneTapSetupAction,
|
|
7358
7407
|
merchantName,
|
|
7359
7408
|
onBack,
|
|
7360
7409
|
onDismiss,
|