@swype-org/react-sdk 0.1.237 → 0.1.241
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 +113 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +113 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2004,14 +2004,29 @@ function isTransferInFlight(transfer) {
|
|
|
2004
2004
|
if (!transfer) return false;
|
|
2005
2005
|
return ["CREATED", "SENDING", "SENT"].includes(transfer.status);
|
|
2006
2006
|
}
|
|
2007
|
+
function isGuestPreauthCompletedTransferPinPhase(phase) {
|
|
2008
|
+
switch (phase.step) {
|
|
2009
|
+
case "completed":
|
|
2010
|
+
case "select-source":
|
|
2011
|
+
case "one-tap-setup":
|
|
2012
|
+
case "token-picker":
|
|
2013
|
+
case "login":
|
|
2014
|
+
case "otp-verify":
|
|
2015
|
+
case "passkey-create":
|
|
2016
|
+
case "passkey-verify":
|
|
2017
|
+
case "data-loading":
|
|
2018
|
+
return true;
|
|
2019
|
+
case "wallet-setup":
|
|
2020
|
+
return phase.mobile == null;
|
|
2021
|
+
default:
|
|
2022
|
+
return false;
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2007
2025
|
function resolvePhase(state) {
|
|
2008
2026
|
const p = state.phase;
|
|
2009
|
-
if (
|
|
2027
|
+
if (state.transfer?.status === "COMPLETED" && state.guestPreauthorizing && isGuestPreauthCompletedTransferPinPhase(p)) {
|
|
2010
2028
|
return p;
|
|
2011
2029
|
}
|
|
2012
|
-
if (state.transfer?.status === "COMPLETED" && state.guestPreauthorizing) {
|
|
2013
|
-
return { step: "processing", transfer: state.transfer };
|
|
2014
|
-
}
|
|
2015
2030
|
if (state.transfer?.status === "COMPLETED") {
|
|
2016
2031
|
return { step: "completed", transfer: state.transfer };
|
|
2017
2032
|
}
|
|
@@ -2021,7 +2036,7 @@ function resolvePhase(state) {
|
|
|
2021
2036
|
if (state.creatingTransfer || isTransferInFlight(state.transfer)) {
|
|
2022
2037
|
return { step: "processing", transfer: state.transfer };
|
|
2023
2038
|
}
|
|
2024
|
-
if (p.step === "token-picker" || p.step === "one-tap-setup" || p.step === "select-source" || p.step === "confirm-sign" || p.step === "guest-token-picker") {
|
|
2039
|
+
if (!state.loginRequested && (p.step === "token-picker" || p.step === "one-tap-setup" || p.step === "select-source" || p.step === "confirm-sign" || p.step === "guest-token-picker")) {
|
|
2025
2040
|
return p;
|
|
2026
2041
|
}
|
|
2027
2042
|
if (state.mobileFlow && state.deeplinkUri) {
|
|
@@ -6045,7 +6060,8 @@ function StepRendererContent({
|
|
|
6045
6060
|
pollingError,
|
|
6046
6061
|
authExecutorError,
|
|
6047
6062
|
transferSigningSigning,
|
|
6048
|
-
transferSigningError
|
|
6063
|
+
transferSigningError,
|
|
6064
|
+
pendingSelectSource
|
|
6049
6065
|
} = remote;
|
|
6050
6066
|
const {
|
|
6051
6067
|
pendingConnections,
|
|
@@ -6245,6 +6261,26 @@ function StepRendererContent({
|
|
|
6245
6261
|
}
|
|
6246
6262
|
case "token-picker": {
|
|
6247
6263
|
if (!selectedAccount) {
|
|
6264
|
+
if (pendingSelectSource && selectSourceChoices.length > 0) {
|
|
6265
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6266
|
+
SelectSourceScreen,
|
|
6267
|
+
{
|
|
6268
|
+
choices: selectSourceChoices,
|
|
6269
|
+
selectedChainName: selectSourceChainName,
|
|
6270
|
+
selectedTokenSymbol: selectSourceTokenSymbol,
|
|
6271
|
+
recommended: selectSourceRecommended,
|
|
6272
|
+
onChainChange: handlers.onSelectSourceChainChange,
|
|
6273
|
+
onTokenChange: handlers.onSetSelectSourceTokenSymbol,
|
|
6274
|
+
onConfirm: handlers.onConfirmSelectSource,
|
|
6275
|
+
onBack: () => handlers.onSetPhase({
|
|
6276
|
+
step: "select-source",
|
|
6277
|
+
action: pendingSelectSource,
|
|
6278
|
+
isDesktop
|
|
6279
|
+
}),
|
|
6280
|
+
onLogout: handlers.onLogout
|
|
6281
|
+
}
|
|
6282
|
+
);
|
|
6283
|
+
}
|
|
6248
6284
|
return /* @__PURE__ */ jsxRuntime.jsx(BlinkLoadingScreen, {});
|
|
6249
6285
|
}
|
|
6250
6286
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6842,15 +6878,15 @@ function useTransferHandlers(deps) {
|
|
|
6842
6878
|
pollingTransferIdRef
|
|
6843
6879
|
};
|
|
6844
6880
|
}
|
|
6845
|
-
function useSourceSelectionHandlers(dispatch, authExecutor) {
|
|
6881
|
+
function useSourceSelectionHandlers(dispatch, authExecutor, options) {
|
|
6846
6882
|
const [selectSourceChainName, setSelectSourceChainName] = react.useState("");
|
|
6847
6883
|
const [selectSourceTokenSymbol, setSelectSourceTokenSymbol] = react.useState("");
|
|
6848
6884
|
const initializedSelectSourceActionRef = react.useRef(null);
|
|
6849
6885
|
const pendingSelectSourceAction = authExecutor.pendingSelectSource;
|
|
6850
6886
|
const selectSourceChoices = react.useMemo(() => {
|
|
6851
6887
|
if (!pendingSelectSourceAction) return [];
|
|
6852
|
-
const
|
|
6853
|
-
return buildSelectSourceChoices(
|
|
6888
|
+
const options2 = pendingSelectSourceAction.metadata?.options ?? [];
|
|
6889
|
+
return buildSelectSourceChoices(options2);
|
|
6854
6890
|
}, [pendingSelectSourceAction]);
|
|
6855
6891
|
const selectSourceRecommended = react.useMemo(() => {
|
|
6856
6892
|
if (!pendingSelectSourceAction) return null;
|
|
@@ -6858,16 +6894,16 @@ function useSourceSelectionHandlers(dispatch, authExecutor) {
|
|
|
6858
6894
|
}, [pendingSelectSourceAction]);
|
|
6859
6895
|
const selectSourceAvailableBalance = react.useMemo(() => {
|
|
6860
6896
|
if (!pendingSelectSourceAction) return 0;
|
|
6861
|
-
const
|
|
6897
|
+
const options2 = pendingSelectSourceAction.metadata?.options ?? [];
|
|
6862
6898
|
const recommended = selectSourceRecommended;
|
|
6863
6899
|
if (recommended) {
|
|
6864
|
-
const match =
|
|
6900
|
+
const match = options2.find(
|
|
6865
6901
|
(opt) => opt.chainName === recommended.chainName && opt.tokenSymbol === recommended.tokenSymbol
|
|
6866
6902
|
);
|
|
6867
6903
|
if (match) return Number(match.rawBalance) / Math.pow(10, match.decimals);
|
|
6868
6904
|
}
|
|
6869
6905
|
let max = 0;
|
|
6870
|
-
for (const opt of
|
|
6906
|
+
for (const opt of options2) {
|
|
6871
6907
|
const bal = Number(opt.rawBalance) / Math.pow(10, opt.decimals);
|
|
6872
6908
|
if (bal > max) max = bal;
|
|
6873
6909
|
}
|
|
@@ -6891,7 +6927,17 @@ function useSourceSelectionHandlers(dispatch, authExecutor) {
|
|
|
6891
6927
|
chainName: selectSourceChainName,
|
|
6892
6928
|
tokenSymbol: selectSourceTokenSymbol
|
|
6893
6929
|
});
|
|
6894
|
-
|
|
6930
|
+
if (options?.guestPreauthorizing && options?.isDesktop) {
|
|
6931
|
+
dispatch({ type: "REQUEST_LOGIN" });
|
|
6932
|
+
}
|
|
6933
|
+
}, [
|
|
6934
|
+
authExecutor,
|
|
6935
|
+
dispatch,
|
|
6936
|
+
options?.guestPreauthorizing,
|
|
6937
|
+
options?.isDesktop,
|
|
6938
|
+
selectSourceChainName,
|
|
6939
|
+
selectSourceTokenSymbol
|
|
6940
|
+
]);
|
|
6895
6941
|
return {
|
|
6896
6942
|
selectSourceChainName,
|
|
6897
6943
|
selectSourceTokenSymbol,
|
|
@@ -8618,6 +8664,9 @@ function useGuestPreauthPhaseSyncEffect(deps) {
|
|
|
8618
8664
|
if (!state.guestPreauthorizing || !isDesktop) return;
|
|
8619
8665
|
const pending = authExecutor.pendingSelectSource;
|
|
8620
8666
|
if (pending) {
|
|
8667
|
+
if (state.phase.step === "token-picker") {
|
|
8668
|
+
return;
|
|
8669
|
+
}
|
|
8621
8670
|
const intent = {
|
|
8622
8671
|
step: "select-source",
|
|
8623
8672
|
action: pending,
|
|
@@ -8631,6 +8680,10 @@ function useGuestPreauthPhaseSyncEffect(deps) {
|
|
|
8631
8680
|
}
|
|
8632
8681
|
if (state.phase.step === "select-source") {
|
|
8633
8682
|
dispatch({ type: "SET_USER_INTENT", intent: { step: "one-tap-setup", action: null } });
|
|
8683
|
+
return;
|
|
8684
|
+
}
|
|
8685
|
+
if (state.phase.step === "token-picker") {
|
|
8686
|
+
dispatch({ type: "SET_USER_INTENT", intent: { step: "one-tap-setup", action: null } });
|
|
8634
8687
|
}
|
|
8635
8688
|
}, [
|
|
8636
8689
|
state.guestPreauthorizing,
|
|
@@ -8640,6 +8693,42 @@ function useGuestPreauthPhaseSyncEffect(deps) {
|
|
|
8640
8693
|
dispatch
|
|
8641
8694
|
]);
|
|
8642
8695
|
}
|
|
8696
|
+
function useGuestPreauthWalletSetupEffect(deps) {
|
|
8697
|
+
const { state, dispatch, authExecutor, isDesktop, privyAuthenticated } = deps;
|
|
8698
|
+
react.useEffect(() => {
|
|
8699
|
+
if (!isDesktop || !state.guestPreauthorizing || !state.guestPreauthSessionId) return;
|
|
8700
|
+
if (!authExecutor.executing || authExecutor.pendingSelectSource) return;
|
|
8701
|
+
if (!privyAuthenticated || !state.activeCredentialId) return;
|
|
8702
|
+
if (state.verificationTarget) return;
|
|
8703
|
+
if (state.loginRequested) return;
|
|
8704
|
+
const p = state.phase;
|
|
8705
|
+
if (p.step === "wallet-setup" && p.mobile == null) {
|
|
8706
|
+
const id = state.guestPreauthAccountId;
|
|
8707
|
+
if (id != null && p.accountId === id) return;
|
|
8708
|
+
}
|
|
8709
|
+
dispatch({
|
|
8710
|
+
type: "SET_USER_INTENT",
|
|
8711
|
+
intent: {
|
|
8712
|
+
step: "wallet-setup",
|
|
8713
|
+
mobile: null,
|
|
8714
|
+
accountId: state.guestPreauthAccountId
|
|
8715
|
+
}
|
|
8716
|
+
});
|
|
8717
|
+
}, [
|
|
8718
|
+
isDesktop,
|
|
8719
|
+
state.guestPreauthorizing,
|
|
8720
|
+
state.guestPreauthSessionId,
|
|
8721
|
+
state.guestPreauthAccountId,
|
|
8722
|
+
state.activeCredentialId,
|
|
8723
|
+
state.verificationTarget,
|
|
8724
|
+
state.loginRequested,
|
|
8725
|
+
state.phase,
|
|
8726
|
+
authExecutor.executing,
|
|
8727
|
+
authExecutor.pendingSelectSource,
|
|
8728
|
+
dispatch,
|
|
8729
|
+
privyAuthenticated
|
|
8730
|
+
]);
|
|
8731
|
+
}
|
|
8643
8732
|
function BlinkPayment(props) {
|
|
8644
8733
|
const resetKey = react.useRef(0);
|
|
8645
8734
|
const handleBoundaryReset = react.useCallback(() => {
|
|
@@ -8724,7 +8813,10 @@ function BlinkPaymentInner({
|
|
|
8724
8813
|
mobileFlowRefs,
|
|
8725
8814
|
onComplete
|
|
8726
8815
|
);
|
|
8727
|
-
const sourceSelection = useSourceSelectionHandlers(dispatch, authExecutor
|
|
8816
|
+
const sourceSelection = useSourceSelectionHandlers(dispatch, authExecutor, {
|
|
8817
|
+
guestPreauthorizing: state.guestPreauthorizing,
|
|
8818
|
+
isDesktop
|
|
8819
|
+
});
|
|
8728
8820
|
const provider = useProviderHandlers({
|
|
8729
8821
|
dispatch,
|
|
8730
8822
|
getAccessToken,
|
|
@@ -8897,6 +8989,13 @@ function BlinkPaymentInner({
|
|
|
8897
8989
|
dispatch,
|
|
8898
8990
|
desktopGuestPreauth: isDesktop
|
|
8899
8991
|
});
|
|
8992
|
+
useGuestPreauthWalletSetupEffect({
|
|
8993
|
+
state,
|
|
8994
|
+
dispatch,
|
|
8995
|
+
authExecutor,
|
|
8996
|
+
isDesktop,
|
|
8997
|
+
privyAuthenticated: authenticated
|
|
8998
|
+
});
|
|
8900
8999
|
const handlers = react.useMemo(() => ({
|
|
8901
9000
|
onSendLoginCode: auth.handleSendLoginCode,
|
|
8902
9001
|
onVerifyLoginCode: auth.handleVerifyLoginCode,
|