@swype-org/react-sdk 0.1.114 → 0.1.115

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.d.cts CHANGED
@@ -30,6 +30,8 @@ interface WalletSource {
30
30
  address: string;
31
31
  token: WalletToken;
32
32
  balance: TokenBalance;
33
+ /** Remaining One-Tap allowance in USD for this token on this chain, or null when not configured. */
34
+ remainingAllowance?: number | null;
33
35
  }
34
36
  /** Full wallet with chain, balance, and token sources */
35
37
  interface Wallet {
package/dist/index.d.ts CHANGED
@@ -30,6 +30,8 @@ interface WalletSource {
30
30
  address: string;
31
31
  token: WalletToken;
32
32
  balance: TokenBalance;
33
+ /** Remaining One-Tap allowance in USD for this token on this chain, or null when not configured. */
34
+ remainingAllowance?: number | null;
33
35
  }
34
36
  /** Full wallet with chain, balance, and token sources */
35
37
  interface Wallet {
package/dist/index.js CHANGED
@@ -5573,6 +5573,7 @@ function StepRenderer({
5573
5573
  maxSourceBalance,
5574
5574
  tokenCount,
5575
5575
  selectedAccount,
5576
+ selectedSource,
5576
5577
  selectSourceChoices,
5577
5578
  selectSourceRecommended,
5578
5579
  authInput,
@@ -5682,7 +5683,7 @@ function StepRenderer({
5682
5683
  return /* @__PURE__ */ jsx(
5683
5684
  SetupScreen,
5684
5685
  {
5685
- availableBalance: selectedAccount ? selectedAccount.wallets.reduce((sum, w) => sum + w.balance.available.amount, 0) : maxSourceBalance,
5686
+ availableBalance: selectedSource ? selectedSource.balance.available.amount : selectedAccount ? selectedAccount.wallets.reduce((sum, w) => sum + w.balance.available.amount, 0) : maxSourceBalance,
5686
5687
  tokenCount,
5687
5688
  sourceName,
5688
5689
  onSetupOneTap: handlers.onSetupOneTap,
@@ -5718,8 +5719,8 @@ function StepRenderer({
5718
5719
  sourceName,
5719
5720
  sourceAddress,
5720
5721
  sourceVerified,
5721
- availableBalance: selectedAccount ? selectedAccount.wallets.reduce((sum, w) => sum + w.balance.available.amount, 0) : maxSourceBalance,
5722
- remainingLimit: selectedAccount?.remainingAllowance ?? state.oneTapLimit,
5722
+ availableBalance: selectedSource ? selectedSource.balance.available.amount : selectedAccount ? selectedAccount.wallets.reduce((sum, w) => sum + w.balance.available.amount, 0) : maxSourceBalance,
5723
+ remainingLimit: selectedSource?.remainingAllowance ?? selectedAccount?.remainingAllowance ?? state.oneTapLimit,
5723
5724
  tokenCount,
5724
5725
  initialAmount: parsedAmt,
5725
5726
  processing: state.creatingTransfer,
@@ -5795,7 +5796,7 @@ function StepRenderer({
5795
5796
  merchantName,
5796
5797
  sourceName,
5797
5798
  remainingLimit: succeeded ? (() => {
5798
- const limit = selectedAccount?.remainingAllowance ?? state.oneTapLimit;
5799
+ const limit = selectedSource?.remainingAllowance ?? selectedAccount?.remainingAllowance ?? state.oneTapLimit;
5799
5800
  return limit > displayAmount ? limit - displayAmount : 0;
5800
5801
  })() : void 0,
5801
5802
  onDone: onDismiss ?? handlers.onNewPayment,
@@ -5813,7 +5814,7 @@ function StepRenderer({
5813
5814
  sourceAddress,
5814
5815
  sourceVerified,
5815
5816
  availableBalance: 0,
5816
- remainingLimit: selectedAccount?.remainingAllowance ?? state.oneTapLimit,
5817
+ remainingLimit: selectedSource?.remainingAllowance ?? selectedAccount?.remainingAllowance ?? state.oneTapLimit,
5817
5818
  tokenCount,
5818
5819
  initialAmount: depositAmount ?? 5,
5819
5820
  processing: false,
@@ -5972,6 +5973,15 @@ function SwypePaymentInner({
5972
5973
  const selectedWallet = selectedAccount?.wallets.find(
5973
5974
  (w) => w.id === state.selectedWalletId
5974
5975
  );
5976
+ const selectedSource = useMemo(() => {
5977
+ if (!selectedWallet) return null;
5978
+ if (state.selectedTokenSymbol) {
5979
+ return selectedWallet.sources.find(
5980
+ (s) => s.token.symbol === state.selectedTokenSymbol
5981
+ ) ?? null;
5982
+ }
5983
+ return selectedWallet.sources.find((s) => s.token.status === "AUTHORIZED") ?? selectedWallet.sources[0] ?? null;
5984
+ }, [selectedWallet, state.selectedTokenSymbol]);
5975
5985
  const sourceName = selectedAccount?.name ?? selectedWallet?.chain.name ?? "Wallet";
5976
5986
  const sourceAddress = selectedWallet ? `${selectedWallet.name.slice(0, 6)}...${selectedWallet.name.slice(-4)}` : void 0;
5977
5987
  const sourceVerified = selectedWallet?.status === "ACTIVE";
@@ -7135,6 +7145,7 @@ function SwypePaymentInner({
7135
7145
  maxSourceBalance,
7136
7146
  tokenCount,
7137
7147
  selectedAccount,
7148
+ selectedSource,
7138
7149
  selectSourceChoices,
7139
7150
  selectSourceRecommended,
7140
7151
  authInput,