@rango-dev/widget-embedded 0.27.4-next.2 → 0.27.4-next.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAuD,MAAM,OAAO,CAAC;AA6C5E,wBAAgB,eAAe,sBA8P9B"}
1
+ {"version":3,"file":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAuD,MAAM,OAAO,CAAC;AA6C5E,wBAAgB,eAAe,sBA6P9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"Routes.d.ts","sourceRoot":"","sources":["../../src/pages/Routes.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,wBAAgB,UAAU,sBAqDzB"}
1
+ {"version":3,"file":"Routes.d.ts","sourceRoot":"","sources":["../../src/pages/Routes.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,wBAAgB,UAAU,sBAwDzB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.27.4-next.2",
3
+ "version": "0.27.4-next.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -52,4 +52,4 @@
52
52
  "publishConfig": {
53
53
  "access": "public"
54
54
  }
55
- }
55
+ }
@@ -1,6 +1,6 @@
1
1
  import type { Token } from 'rango-sdk';
2
2
 
3
- import { useCallback, useEffect, useState } from 'react';
3
+ import { useCallback, useEffect, useRef, useState } from 'react';
4
4
 
5
5
  import { useAppStore } from '../store/AppStore';
6
6
  import { useQuoteStore } from '../store/quote';
@@ -80,6 +80,7 @@ export function useSwapInput({
80
80
  const excludeLiquiditySources = useAppStore().excludeLiquiditySources();
81
81
 
82
82
  const [loading, setLoading] = useState(true);
83
+ const prevInputAmount = useRef(inputAmount);
83
84
  const userSlippage = customSlippage ?? slippage;
84
85
  const tokensValueInvalid = !fromToken || !toToken;
85
86
  const shouldSkipRequest =
@@ -174,9 +175,7 @@ export function useSwapInput({
174
175
 
175
176
  const debouncedFetch = useCallback(
176
177
  debounce((params: FetchQuoteParams) => {
177
- if (!shouldSkipRequest) {
178
- fetch(params);
179
- }
178
+ fetch(params);
180
179
  }, DEBOUNCE_DELAY),
181
180
  [shouldSkipRequest]
182
181
  );
@@ -204,7 +203,14 @@ export function useSwapInput({
204
203
 
205
204
  resetQuote();
206
205
  resetState(true);
207
- debouncedFetch({
206
+
207
+ let fetchQuotes = fetch;
208
+ if (prevInputAmount.current && prevInputAmount.current != inputAmount) {
209
+ fetchQuotes = debouncedFetch;
210
+ }
211
+ prevInputAmount.current = inputAmount;
212
+
213
+ fetchQuotes({
208
214
  inputAmount,
209
215
  fromToken,
210
216
  toToken,
@@ -16,6 +16,7 @@ export function useSyncStoresWithConfig() {
16
16
  setToToken,
17
17
  setToBlockchain,
18
18
  setFromBlockchain,
19
+ resetQuote,
19
20
  setFromToken,
20
21
  fromToken,
21
22
  toToken,
@@ -46,6 +47,7 @@ export function useSyncStoresWithConfig() {
46
47
 
47
48
  useEffect(() => {
48
49
  if (fetchMetaStatus === 'success') {
50
+ resetQuote();
49
51
  const chain = blockchains.find(
50
52
  (chain) => chain.name === config?.from?.blockchain
51
53
  );
@@ -95,6 +97,7 @@ export function useSyncStoresWithConfig() {
95
97
 
96
98
  useEffect(() => {
97
99
  if (fetchMetaStatus === 'success') {
100
+ resetQuote();
98
101
  const chain = blockchains.find(
99
102
  (chain) => chain.name === config?.to?.blockchain
100
103
  );
@@ -17,7 +17,7 @@ import {
17
17
  WalletIcon,
18
18
  } from '@rango-dev/ui';
19
19
  import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
20
- import { useLocation, useNavigate } from 'react-router-dom';
20
+ import { useNavigate } from 'react-router-dom';
21
21
 
22
22
  import { ConfirmWalletsModal } from '../components/ConfirmWalletsModal/ConfirmWalletsModal';
23
23
  import { RefreshButton } from '../components/HeaderButtons/RefreshButton';
@@ -72,7 +72,6 @@ export function ConfirmSwapPage() {
72
72
  quoteWarningsConfirmed,
73
73
  } = useQuoteStore();
74
74
  const navigate = useNavigate();
75
- const location = useLocation();
76
75
  const [dbErrorMessage, setDbErrorMessage] = useState<string>('');
77
76
 
78
77
  const showWalletsOnInit = !quoteWalletsConfirmed;
@@ -185,10 +184,10 @@ export function ConfirmSwapPage() {
185
184
  }, []);
186
185
 
187
186
  useLayoutEffect(() => {
188
- if (!selectedQuote) {
187
+ if (!selectedQuote?.requestId) {
189
188
  navigate(`../${location.search}`);
190
189
  }
191
- }, []);
190
+ }, [selectedQuote?.requestId]);
192
191
 
193
192
  const quoteWarning = confirmSwapResult.warnings?.quote ?? null;
194
193
  const quoteError = confirmSwapResult.error;
@@ -15,7 +15,6 @@ import { useQuoteStore } from '../store/quote';
15
15
  export function RoutesPage() {
16
16
  const navigate = useNavigate();
17
17
  const navigateBack = useNavigateBack();
18
-
19
18
  const {
20
19
  selectedQuote,
21
20
  refetchQuote,
@@ -41,6 +40,7 @@ export function RoutesPage() {
41
40
  header={{
42
41
  onWallet: () => {
43
42
  navigate(wallets_url);
43
+ updateQuotePartialState('refetchQuote', true);
44
44
  },
45
45
  onBack: () => {
46
46
  updateQuotePartialState('refetchQuote', false);
@@ -52,7 +52,10 @@ export function RoutesPage() {
52
52
  !!selectedQuote || quoteError ? fetchQuote : undefined
53
53
  }
54
54
  hidden={['notifications', 'history']}
55
- onClickSettings={() => navigate(settings_url)}
55
+ onClickSettings={() => {
56
+ navigate(settings_url);
57
+ updateQuotePartialState('refetchQuote', true);
58
+ }}
56
59
  />
57
60
  ),
58
61
  }}>