@swype-org/react-sdk 0.1.127 → 0.1.129
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 +25 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1976,7 +1976,8 @@ function createInitialState(config) {
|
|
|
1976
1976
|
oneTapLimit: 100,
|
|
1977
1977
|
mobileFlow: false,
|
|
1978
1978
|
deeplinkUri: null,
|
|
1979
|
-
increasingLimit: false
|
|
1979
|
+
increasingLimit: false,
|
|
1980
|
+
previousStep: null
|
|
1980
1981
|
};
|
|
1981
1982
|
}
|
|
1982
1983
|
function paymentReducer(state, action) {
|
|
@@ -2200,7 +2201,7 @@ function paymentReducer(state, action) {
|
|
|
2200
2201
|
};
|
|
2201
2202
|
// ── Navigation & error ───────────────────────────────────────
|
|
2202
2203
|
case "NAVIGATE":
|
|
2203
|
-
return { ...state, step: action.step, error: null };
|
|
2204
|
+
return { ...state, step: action.step, previousStep: state.step, error: null };
|
|
2204
2205
|
case "SET_ERROR":
|
|
2205
2206
|
return { ...state, error: action.error };
|
|
2206
2207
|
// ── Lifecycle ────────────────────────────────────────────────
|
|
@@ -5622,6 +5623,8 @@ function StepRenderer({
|
|
|
5622
5623
|
handlers
|
|
5623
5624
|
}) {
|
|
5624
5625
|
const { step } = state;
|
|
5626
|
+
const selectedWallet = selectedAccount?.wallets.find((w) => w.id === state.selectedWalletId);
|
|
5627
|
+
const selectedSourceLabel = selectedSource && selectedWallet ? `${selectedSource.token.symbol} on ${selectedWallet.chain.name}` : void 0;
|
|
5625
5628
|
if (!ready) {
|
|
5626
5629
|
return /* @__PURE__ */ jsx(SwypeLoadingScreen, {});
|
|
5627
5630
|
}
|
|
@@ -5737,6 +5740,8 @@ function StepRenderer({
|
|
|
5737
5740
|
onSetupOneTap: handlers.onSetupOneTap,
|
|
5738
5741
|
onBack: () => handlers.onNavigate("deposit"),
|
|
5739
5742
|
onLogout: handlers.onLogout,
|
|
5743
|
+
onAdvanced: handlers.onSelectToken,
|
|
5744
|
+
selectedSourceLabel,
|
|
5740
5745
|
loading: savingOneTapLimit,
|
|
5741
5746
|
error: state.error
|
|
5742
5747
|
}
|
|
@@ -5799,7 +5804,7 @@ function StepRenderer({
|
|
|
5799
5804
|
chains: state.chains,
|
|
5800
5805
|
onSelectAuthorized: handlers.onSelectAuthorizedToken,
|
|
5801
5806
|
onAuthorizeToken: handlers.onAuthorizeToken,
|
|
5802
|
-
onBack: () => handlers.onNavigate("deposit")
|
|
5807
|
+
onBack: () => handlers.onNavigate(state.previousStep === "setup" ? "setup" : "deposit")
|
|
5803
5808
|
}
|
|
5804
5809
|
);
|
|
5805
5810
|
}
|
|
@@ -7153,6 +7158,20 @@ function SwypePaymentInner({
|
|
|
7153
7158
|
return;
|
|
7154
7159
|
}
|
|
7155
7160
|
if (initializedSelectSourceActionRef.current === pendingSelectSourceAction.id) return;
|
|
7161
|
+
const options = pendingSelectSourceAction.metadata?.options ?? [];
|
|
7162
|
+
if (pendingTokenAuthRef.current) {
|
|
7163
|
+
const { tokenAddress, chainId } = pendingTokenAuthRef.current;
|
|
7164
|
+
const chainIdHex = `0x${chainId.toString(16)}`;
|
|
7165
|
+
const match = options.find(
|
|
7166
|
+
(opt) => opt.tokenAddress.toLowerCase() === tokenAddress.toLowerCase() && opt.chainId.toLowerCase() === chainIdHex.toLowerCase()
|
|
7167
|
+
);
|
|
7168
|
+
if (match) {
|
|
7169
|
+
setSelectSourceChainName(match.chainName);
|
|
7170
|
+
setSelectSourceTokenSymbol(match.tokenSymbol);
|
|
7171
|
+
initializedSelectSourceActionRef.current = pendingSelectSourceAction.id;
|
|
7172
|
+
return;
|
|
7173
|
+
}
|
|
7174
|
+
}
|
|
7156
7175
|
const hasRecommended = !!selectSourceRecommended && selectSourceChoices.some(
|
|
7157
7176
|
(chain) => chain.chainName === selectSourceRecommended.chainName && chain.tokens.some((t) => t.tokenSymbol === selectSourceRecommended.tokenSymbol)
|
|
7158
7177
|
);
|
|
@@ -7170,37 +7189,13 @@ function SwypePaymentInner({
|
|
|
7170
7189
|
}, [pendingSelectSourceAction, selectSourceChoices, selectSourceRecommended]);
|
|
7171
7190
|
useEffect(() => {
|
|
7172
7191
|
if (pendingSelectSourceAction && (state.step === "processing" || state.step === "open-wallet" || state.step === "setup-status")) {
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
if (recommended) {
|
|
7176
|
-
authExecutor.resolveSelectSource(recommended);
|
|
7177
|
-
} else {
|
|
7178
|
-
authExecutor.resolveSelectSource({ chainName: "Base", tokenSymbol: "USDC" });
|
|
7179
|
-
}
|
|
7180
|
-
} else {
|
|
7181
|
-
preSelectSourceStepRef.current = state.step;
|
|
7182
|
-
dispatch({ type: "NAVIGATE", step: "select-source" });
|
|
7183
|
-
}
|
|
7192
|
+
preSelectSourceStepRef.current = state.step;
|
|
7193
|
+
dispatch({ type: "NAVIGATE", step: "select-source" });
|
|
7184
7194
|
} else if (!pendingSelectSourceAction && state.step === "select-source") {
|
|
7185
7195
|
dispatch({ type: "NAVIGATE", step: preSelectSourceStepRef.current ?? "processing" });
|
|
7186
7196
|
preSelectSourceStepRef.current = null;
|
|
7187
7197
|
}
|
|
7188
|
-
}, [pendingSelectSourceAction, state.step,
|
|
7189
|
-
useEffect(() => {
|
|
7190
|
-
if (!pendingSelectSourceAction || !pendingTokenAuthRef.current) return;
|
|
7191
|
-
const { tokenAddress, chainId } = pendingTokenAuthRef.current;
|
|
7192
|
-
const chainIdHex = `0x${chainId.toString(16)}`;
|
|
7193
|
-
const options = pendingSelectSourceAction.metadata?.options ?? [];
|
|
7194
|
-
const match = options.find(
|
|
7195
|
-
(opt) => opt.tokenAddress.toLowerCase() === tokenAddress.toLowerCase() && opt.chainId.toLowerCase() === chainIdHex.toLowerCase()
|
|
7196
|
-
);
|
|
7197
|
-
if (match) {
|
|
7198
|
-
authExecutor.resolveSelectSource({
|
|
7199
|
-
chainName: match.chainName,
|
|
7200
|
-
tokenSymbol: match.tokenSymbol
|
|
7201
|
-
});
|
|
7202
|
-
}
|
|
7203
|
-
}, [pendingSelectSourceAction, authExecutor]);
|
|
7198
|
+
}, [pendingSelectSourceAction, state.step, authExecutor]);
|
|
7204
7199
|
const pendingOneTapSetupAction = authExecutor.pendingOneTapSetup;
|
|
7205
7200
|
const preOneTapSetupStepRef = useRef(null);
|
|
7206
7201
|
useEffect(() => {
|