@silentswap/react 0.0.83 → 0.0.85

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.
@@ -8,17 +8,12 @@ import { getAssociatedTokenAddress } from '@solana/spl-token';
8
8
  import { PublicKey } from '@solana/web3.js';
9
9
  import { useAssetsContext } from './AssetsContext.js';
10
10
  import { usePrices } from '../hooks/usePrices.js';
11
- import { isSolanaAsset, parseSolanaCaip19, isSolanaNativeToken, isSplToken, isEvmNativeToken, isBitcoinAsset, isBitcoinMainnetAsset, SB58_CHAIN_ID_SOLANA_MAINNET, A_VIEM_CHAINS, BITCOIN_CHAIN_ID, } from '@silentswap/sdk';
11
+ import { isSolanaAsset, parseSolanaCaip19, isSolanaNativeToken, isSplToken, isEvmNativeToken, isBitcoinAsset, isBitcoinMainnetAsset, SB58_CHAIN_ID_SOLANA_MAINNET, A_VIEM_CHAINS, BITCOIN_CHAIN_ID, H_RPCS, } from '@silentswap/sdk';
12
12
  const BalancesContext = createContext(undefined);
13
- // Custom RPC endpoints from 0xrpc.io (fast, free, private public RPC)
14
- // Reference: https://0xrpc.io
15
- const CUSTOM_RPC_ENDPOINTS = {
16
- 1: 'https://red-old-fog.quiknode.pro/7a0bdad6750af42fb7fb312cabd90f196594e700/', // Ethereum Mainnet
17
- 10: 'https://cold-white-mountain.optimism.quiknode.pro/dd00719b96a7c719aa6065c476ef928e465c6799/', // Optimism L2 Mainnet
18
- };
19
13
  // Utility: Create viem client with custom RPC endpoints where available
14
+ // Uses H_RPCS from @silentswap/sdk (rpc.ts) as the single source of truth
20
15
  const createViemClient = (chain) => {
21
- const customRpc = CUSTOM_RPC_ENDPOINTS[chain.id];
16
+ const customRpc = H_RPCS[chain.id];
22
17
  const chainWithCustomRpc = customRpc
23
18
  ? {
24
19
  ...chain,
@@ -32,10 +32,6 @@ export function SwapFormEstimatesProvider({ children, tokenIn, fetchEstimates, s
32
32
  const rafScheduledRef = useRef(false);
33
33
  const pendingUpdateRef = useRef(null);
34
34
  const isManualDestinationChangeRef = useRef(false);
35
- // Update fetchEstimates ref
36
- React.useEffect(() => {
37
- fetchEstimatesRef.current = fetchEstimates;
38
- }, [fetchEstimates]);
39
35
  // Debounced fetch estimates
40
36
  const scheduleFetchEstimates = useCallback((immediate = false, direction) => {
41
37
  if (isDraggingSlider) {
@@ -74,6 +70,19 @@ export function SwapFormEstimatesProvider({ children, tokenIn, fetchEstimates, s
74
70
  isFetchingEstimatesRef.current = false;
75
71
  });
76
72
  }, [isDraggingSlider]);
73
+ // Update fetchEstimates ref and re-trigger fetch when the function identity
74
+ // changes (e.g. wallet reconnects → address changes → getQuote recreated →
75
+ // fetchEstimates recreated). We can't just reset lastFetchedKeyRef because
76
+ // ref mutations don't cause the initial-fetch effect to re-run.
77
+ React.useEffect(() => {
78
+ const prev = fetchEstimatesRef.current;
79
+ fetchEstimatesRef.current = fetchEstimates;
80
+ // When fetchEstimates changes and we had already fetched, re-trigger
81
+ if (prev !== fetchEstimates && lastFetchedKeyRef.current) {
82
+ lastFetchedKeyRef.current = null;
83
+ scheduleFetchEstimates(true);
84
+ }
85
+ }, [fetchEstimates, scheduleFetchEstimates]);
77
86
  // Recalculate splits from destination amounts
78
87
  const recalculateSplitsFromAmounts = useCallback(() => {
79
88
  if (!tokenIn)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@silentswap/react",
3
3
  "type": "module",
4
- "version": "0.0.83",
4
+ "version": "0.0.85",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -24,8 +24,8 @@
24
24
  "dependencies": {
25
25
  "@bigmi/core": "^0.6.5",
26
26
  "@ensdomains/ensjs": "^4.2.0",
27
- "@silentswap/sdk": "0.0.83",
28
- "@silentswap/ui-kit": "0.0.83",
27
+ "@silentswap/sdk": "0.0.85",
28
+ "@silentswap/ui-kit": "0.0.85",
29
29
  "@solana/codecs-strings": "^5.1.0",
30
30
  "@solana/kit": "^5.1.0",
31
31
  "@solana/rpc": "^5.1.0",