@rango-dev/widget-embedded 0.27.3-next.0 → 0.27.3-next.2

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":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA8B,MAAM,OAAO,CAAC;AA4BnD,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAEjD,wBAAgB,IAAI,sBA0MnB"}
1
+ {"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA8B,MAAM,OAAO,CAAC;AA2BnD,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAEjD,wBAAgB,IAAI,sBA0MnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.27.3-next.0",
3
+ "version": "0.27.3-next.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -1,4 +1,4 @@
1
- import type { ConfirmSwap, Params } from './useConfirmSwap.types';
1
+ import type { ConfirmSwap } from './useConfirmSwap.types';
2
2
  import type { PendingSwapSettings, SelectedQuote } from '../../types';
3
3
  import type { ConfirmRouteRequest } from 'rango-sdk';
4
4
 
@@ -39,7 +39,7 @@ export function useConfirmSwap(): ConfirmSwap {
39
39
 
40
40
  useEffect(() => cancelFetch, []);
41
41
 
42
- const fetch: ConfirmSwap['fetch'] = async (params: Params) => {
42
+ const fetch: ConfirmSwap['fetch'] = async (params) => {
43
43
  const selectedWallets = params.selectedWallets;
44
44
  const customDestination =
45
45
  params?.customDestination ?? customDestinationFromStore;
@@ -67,7 +67,7 @@ export function useConfirmSwap(): ConfirmSwap {
67
67
  };
68
68
 
69
69
  try {
70
- return await fetchQuote(requestBody).then((response) => {
70
+ return await fetchQuote(requestBody, true).then((response) => {
71
71
  const { result } = response;
72
72
 
73
73
  throwErrorIfResponseIsNotValid({
@@ -9,11 +9,13 @@ type UseFetchOptions<TRequest, TResponse> = {
9
9
  ) => Promise<TResponse>;
10
10
  };
11
11
  export type UseFetchResult<TRequest, TResponse> = {
12
- fetch: (requestBody: TRequest) => Promise<TResponse>;
12
+ fetch: (requestBody: TRequest, retryOnFail?: boolean) => Promise<TResponse>;
13
13
  cancelFetch: () => void;
14
14
  loading: boolean;
15
15
  };
16
16
 
17
+ const RETRY_DELAY = 2_000;
18
+
17
19
  export function useFetch<TRequest, TResponse>({
18
20
  request,
19
21
  }: UseFetchOptions<TRequest, TResponse>): UseFetchResult<TRequest, TResponse> {
@@ -22,8 +24,14 @@ export function useFetch<TRequest, TResponse>({
22
24
 
23
25
  const cancelFetch = () => abortController.current?.abort();
24
26
 
27
+ const retryFetch = async (requestBody: TRequest) => {
28
+ await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY));
29
+ return await fetch(requestBody, false);
30
+ };
31
+
25
32
  const fetch: UseFetchResult<TRequest, TResponse>['fetch'] = async (
26
- requestBody
33
+ requestBody,
34
+ retryOnFail = false
27
35
  ) => {
28
36
  cancelFetch();
29
37
  abortController.current = new AbortController();
@@ -38,6 +46,9 @@ export function useFetch<TRequest, TResponse>({
38
46
  return res;
39
47
  // eslint-disable-next-line no-useless-catch
40
48
  } catch (error) {
49
+ if (retryOnFail) {
50
+ return await retryFetch(requestBody);
51
+ }
41
52
  throw error;
42
53
  } finally {
43
54
  setLoading(false);
@@ -23,8 +23,7 @@ import { isVariantExpandable } from '../utils/configs';
23
23
  import { getSwapButtonState, isTokensIdentical } from '../utils/swap';
24
24
 
25
25
  const MainContainer = styled('div', {
26
- display: 'grid',
27
- gridTemplateColumns: 'auto auto',
26
+ display: 'flex',
28
27
  alignItems: 'flex-start',
29
28
  maxHeight: 700,
30
29
  '& .footer__alert': {