@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.js
CHANGED
|
@@ -2001,14 +2001,29 @@ function isTransferInFlight(transfer) {
|
|
|
2001
2001
|
if (!transfer) return false;
|
|
2002
2002
|
return ["CREATED", "SENDING", "SENT"].includes(transfer.status);
|
|
2003
2003
|
}
|
|
2004
|
+
function isGuestPreauthCompletedTransferPinPhase(phase) {
|
|
2005
|
+
switch (phase.step) {
|
|
2006
|
+
case "completed":
|
|
2007
|
+
case "select-source":
|
|
2008
|
+
case "one-tap-setup":
|
|
2009
|
+
case "token-picker":
|
|
2010
|
+
case "login":
|
|
2011
|
+
case "otp-verify":
|
|
2012
|
+
case "passkey-create":
|
|
2013
|
+
case "passkey-verify":
|
|
2014
|
+
case "data-loading":
|
|
2015
|
+
return true;
|
|
2016
|
+
case "wallet-setup":
|
|
2017
|
+
return phase.mobile == null;
|
|
2018
|
+
default:
|
|
2019
|
+
return false;
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2004
2022
|
function resolvePhase(state) {
|
|
2005
2023
|
const p = state.phase;
|
|
2006
|
-
if (
|
|
2024
|
+
if (state.transfer?.status === "COMPLETED" && state.guestPreauthorizing && isGuestPreauthCompletedTransferPinPhase(p)) {
|
|
2007
2025
|
return p;
|
|
2008
2026
|
}
|
|
2009
|
-
if (state.transfer?.status === "COMPLETED" && state.guestPreauthorizing) {
|
|
2010
|
-
return { step: "processing", transfer: state.transfer };
|
|
2011
|
-
}
|
|
2012
2027
|
if (state.transfer?.status === "COMPLETED") {
|
|
2013
2028
|
return { step: "completed", transfer: state.transfer };
|
|
2014
2029
|
}
|
|
@@ -2018,7 +2033,7 @@ function resolvePhase(state) {
|
|
|
2018
2033
|
if (state.creatingTransfer || isTransferInFlight(state.transfer)) {
|
|
2019
2034
|
return { step: "processing", transfer: state.transfer };
|
|
2020
2035
|
}
|
|
2021
|
-
if (p.step === "token-picker" || p.step === "one-tap-setup" || p.step === "select-source" || p.step === "confirm-sign" || p.step === "guest-token-picker") {
|
|
2036
|
+
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")) {
|
|
2022
2037
|
return p;
|
|
2023
2038
|
}
|
|
2024
2039
|
if (state.mobileFlow && state.deeplinkUri) {
|
|
@@ -6042,7 +6057,8 @@ function StepRendererContent({
|
|
|
6042
6057
|
pollingError,
|
|
6043
6058
|
authExecutorError,
|
|
6044
6059
|
transferSigningSigning,
|
|
6045
|
-
transferSigningError
|
|
6060
|
+
transferSigningError,
|
|
6061
|
+
pendingSelectSource
|
|
6046
6062
|
} = remote;
|
|
6047
6063
|
const {
|
|
6048
6064
|
pendingConnections,
|
|
@@ -6242,6 +6258,26 @@ function StepRendererContent({
|
|
|
6242
6258
|
}
|
|
6243
6259
|
case "token-picker": {
|
|
6244
6260
|
if (!selectedAccount) {
|
|
6261
|
+
if (pendingSelectSource && selectSourceChoices.length > 0) {
|
|
6262
|
+
return /* @__PURE__ */ jsx(
|
|
6263
|
+
SelectSourceScreen,
|
|
6264
|
+
{
|
|
6265
|
+
choices: selectSourceChoices,
|
|
6266
|
+
selectedChainName: selectSourceChainName,
|
|
6267
|
+
selectedTokenSymbol: selectSourceTokenSymbol,
|
|
6268
|
+
recommended: selectSourceRecommended,
|
|
6269
|
+
onChainChange: handlers.onSelectSourceChainChange,
|
|
6270
|
+
onTokenChange: handlers.onSetSelectSourceTokenSymbol,
|
|
6271
|
+
onConfirm: handlers.onConfirmSelectSource,
|
|
6272
|
+
onBack: () => handlers.onSetPhase({
|
|
6273
|
+
step: "select-source",
|
|
6274
|
+
action: pendingSelectSource,
|
|
6275
|
+
isDesktop
|
|
6276
|
+
}),
|
|
6277
|
+
onLogout: handlers.onLogout
|
|
6278
|
+
}
|
|
6279
|
+
);
|
|
6280
|
+
}
|
|
6245
6281
|
return /* @__PURE__ */ jsx(BlinkLoadingScreen, {});
|
|
6246
6282
|
}
|
|
6247
6283
|
return /* @__PURE__ */ jsx(
|
|
@@ -6839,15 +6875,15 @@ function useTransferHandlers(deps) {
|
|
|
6839
6875
|
pollingTransferIdRef
|
|
6840
6876
|
};
|
|
6841
6877
|
}
|
|
6842
|
-
function useSourceSelectionHandlers(dispatch, authExecutor) {
|
|
6878
|
+
function useSourceSelectionHandlers(dispatch, authExecutor, options) {
|
|
6843
6879
|
const [selectSourceChainName, setSelectSourceChainName] = useState("");
|
|
6844
6880
|
const [selectSourceTokenSymbol, setSelectSourceTokenSymbol] = useState("");
|
|
6845
6881
|
const initializedSelectSourceActionRef = useRef(null);
|
|
6846
6882
|
const pendingSelectSourceAction = authExecutor.pendingSelectSource;
|
|
6847
6883
|
const selectSourceChoices = useMemo(() => {
|
|
6848
6884
|
if (!pendingSelectSourceAction) return [];
|
|
6849
|
-
const
|
|
6850
|
-
return buildSelectSourceChoices(
|
|
6885
|
+
const options2 = pendingSelectSourceAction.metadata?.options ?? [];
|
|
6886
|
+
return buildSelectSourceChoices(options2);
|
|
6851
6887
|
}, [pendingSelectSourceAction]);
|
|
6852
6888
|
const selectSourceRecommended = useMemo(() => {
|
|
6853
6889
|
if (!pendingSelectSourceAction) return null;
|
|
@@ -6855,16 +6891,16 @@ function useSourceSelectionHandlers(dispatch, authExecutor) {
|
|
|
6855
6891
|
}, [pendingSelectSourceAction]);
|
|
6856
6892
|
const selectSourceAvailableBalance = useMemo(() => {
|
|
6857
6893
|
if (!pendingSelectSourceAction) return 0;
|
|
6858
|
-
const
|
|
6894
|
+
const options2 = pendingSelectSourceAction.metadata?.options ?? [];
|
|
6859
6895
|
const recommended = selectSourceRecommended;
|
|
6860
6896
|
if (recommended) {
|
|
6861
|
-
const match =
|
|
6897
|
+
const match = options2.find(
|
|
6862
6898
|
(opt) => opt.chainName === recommended.chainName && opt.tokenSymbol === recommended.tokenSymbol
|
|
6863
6899
|
);
|
|
6864
6900
|
if (match) return Number(match.rawBalance) / Math.pow(10, match.decimals);
|
|
6865
6901
|
}
|
|
6866
6902
|
let max = 0;
|
|
6867
|
-
for (const opt of
|
|
6903
|
+
for (const opt of options2) {
|
|
6868
6904
|
const bal = Number(opt.rawBalance) / Math.pow(10, opt.decimals);
|
|
6869
6905
|
if (bal > max) max = bal;
|
|
6870
6906
|
}
|
|
@@ -6888,7 +6924,17 @@ function useSourceSelectionHandlers(dispatch, authExecutor) {
|
|
|
6888
6924
|
chainName: selectSourceChainName,
|
|
6889
6925
|
tokenSymbol: selectSourceTokenSymbol
|
|
6890
6926
|
});
|
|
6891
|
-
|
|
6927
|
+
if (options?.guestPreauthorizing && options?.isDesktop) {
|
|
6928
|
+
dispatch({ type: "REQUEST_LOGIN" });
|
|
6929
|
+
}
|
|
6930
|
+
}, [
|
|
6931
|
+
authExecutor,
|
|
6932
|
+
dispatch,
|
|
6933
|
+
options?.guestPreauthorizing,
|
|
6934
|
+
options?.isDesktop,
|
|
6935
|
+
selectSourceChainName,
|
|
6936
|
+
selectSourceTokenSymbol
|
|
6937
|
+
]);
|
|
6892
6938
|
return {
|
|
6893
6939
|
selectSourceChainName,
|
|
6894
6940
|
selectSourceTokenSymbol,
|
|
@@ -8615,6 +8661,9 @@ function useGuestPreauthPhaseSyncEffect(deps) {
|
|
|
8615
8661
|
if (!state.guestPreauthorizing || !isDesktop) return;
|
|
8616
8662
|
const pending = authExecutor.pendingSelectSource;
|
|
8617
8663
|
if (pending) {
|
|
8664
|
+
if (state.phase.step === "token-picker") {
|
|
8665
|
+
return;
|
|
8666
|
+
}
|
|
8618
8667
|
const intent = {
|
|
8619
8668
|
step: "select-source",
|
|
8620
8669
|
action: pending,
|
|
@@ -8628,6 +8677,10 @@ function useGuestPreauthPhaseSyncEffect(deps) {
|
|
|
8628
8677
|
}
|
|
8629
8678
|
if (state.phase.step === "select-source") {
|
|
8630
8679
|
dispatch({ type: "SET_USER_INTENT", intent: { step: "one-tap-setup", action: null } });
|
|
8680
|
+
return;
|
|
8681
|
+
}
|
|
8682
|
+
if (state.phase.step === "token-picker") {
|
|
8683
|
+
dispatch({ type: "SET_USER_INTENT", intent: { step: "one-tap-setup", action: null } });
|
|
8631
8684
|
}
|
|
8632
8685
|
}, [
|
|
8633
8686
|
state.guestPreauthorizing,
|
|
@@ -8637,6 +8690,42 @@ function useGuestPreauthPhaseSyncEffect(deps) {
|
|
|
8637
8690
|
dispatch
|
|
8638
8691
|
]);
|
|
8639
8692
|
}
|
|
8693
|
+
function useGuestPreauthWalletSetupEffect(deps) {
|
|
8694
|
+
const { state, dispatch, authExecutor, isDesktop, privyAuthenticated } = deps;
|
|
8695
|
+
useEffect(() => {
|
|
8696
|
+
if (!isDesktop || !state.guestPreauthorizing || !state.guestPreauthSessionId) return;
|
|
8697
|
+
if (!authExecutor.executing || authExecutor.pendingSelectSource) return;
|
|
8698
|
+
if (!privyAuthenticated || !state.activeCredentialId) return;
|
|
8699
|
+
if (state.verificationTarget) return;
|
|
8700
|
+
if (state.loginRequested) return;
|
|
8701
|
+
const p = state.phase;
|
|
8702
|
+
if (p.step === "wallet-setup" && p.mobile == null) {
|
|
8703
|
+
const id = state.guestPreauthAccountId;
|
|
8704
|
+
if (id != null && p.accountId === id) return;
|
|
8705
|
+
}
|
|
8706
|
+
dispatch({
|
|
8707
|
+
type: "SET_USER_INTENT",
|
|
8708
|
+
intent: {
|
|
8709
|
+
step: "wallet-setup",
|
|
8710
|
+
mobile: null,
|
|
8711
|
+
accountId: state.guestPreauthAccountId
|
|
8712
|
+
}
|
|
8713
|
+
});
|
|
8714
|
+
}, [
|
|
8715
|
+
isDesktop,
|
|
8716
|
+
state.guestPreauthorizing,
|
|
8717
|
+
state.guestPreauthSessionId,
|
|
8718
|
+
state.guestPreauthAccountId,
|
|
8719
|
+
state.activeCredentialId,
|
|
8720
|
+
state.verificationTarget,
|
|
8721
|
+
state.loginRequested,
|
|
8722
|
+
state.phase,
|
|
8723
|
+
authExecutor.executing,
|
|
8724
|
+
authExecutor.pendingSelectSource,
|
|
8725
|
+
dispatch,
|
|
8726
|
+
privyAuthenticated
|
|
8727
|
+
]);
|
|
8728
|
+
}
|
|
8640
8729
|
function BlinkPayment(props) {
|
|
8641
8730
|
const resetKey = useRef(0);
|
|
8642
8731
|
const handleBoundaryReset = useCallback(() => {
|
|
@@ -8721,7 +8810,10 @@ function BlinkPaymentInner({
|
|
|
8721
8810
|
mobileFlowRefs,
|
|
8722
8811
|
onComplete
|
|
8723
8812
|
);
|
|
8724
|
-
const sourceSelection = useSourceSelectionHandlers(dispatch, authExecutor
|
|
8813
|
+
const sourceSelection = useSourceSelectionHandlers(dispatch, authExecutor, {
|
|
8814
|
+
guestPreauthorizing: state.guestPreauthorizing,
|
|
8815
|
+
isDesktop
|
|
8816
|
+
});
|
|
8725
8817
|
const provider = useProviderHandlers({
|
|
8726
8818
|
dispatch,
|
|
8727
8819
|
getAccessToken,
|
|
@@ -8894,6 +8986,13 @@ function BlinkPaymentInner({
|
|
|
8894
8986
|
dispatch,
|
|
8895
8987
|
desktopGuestPreauth: isDesktop
|
|
8896
8988
|
});
|
|
8989
|
+
useGuestPreauthWalletSetupEffect({
|
|
8990
|
+
state,
|
|
8991
|
+
dispatch,
|
|
8992
|
+
authExecutor,
|
|
8993
|
+
isDesktop,
|
|
8994
|
+
privyAuthenticated: authenticated
|
|
8995
|
+
});
|
|
8897
8996
|
const handlers = useMemo(() => ({
|
|
8898
8997
|
onSendLoginCode: auth.handleSendLoginCode,
|
|
8899
8998
|
onVerifyLoginCode: auth.handleVerifyLoginCode,
|