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