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

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
  3. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  4. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +1 -1
  5. package/dist/components/HeaderButtons/WalletButton.d.ts.map +1 -1
  6. package/dist/components/Quote/Quote.d.ts.map +1 -1
  7. package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
  8. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
  9. package/dist/hooks/useFetch.d.ts +1 -1
  10. package/dist/hooks/useFetch.d.ts.map +1 -1
  11. package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -1
  12. package/dist/hooks/useWalletList.d.ts +0 -2
  13. package/dist/hooks/useWalletList.d.ts.map +1 -1
  14. package/dist/hooks/useWalletProviders.d.ts.map +1 -1
  15. package/dist/index.js +2 -2
  16. package/dist/index.js.map +3 -3
  17. package/dist/pages/Home.d.ts.map +1 -1
  18. package/dist/pages/WalletsPage.d.ts.map +1 -1
  19. package/dist/utils/providers.d.ts.map +1 -1
  20. package/package.json +8 -8
  21. package/src/components/ConfirmWalletsModal/WalletList.tsx +0 -2
  22. package/src/components/HeaderButtons/WalletButton.tsx +1 -4
  23. package/src/components/Quote/Quote.styles.ts +19 -1
  24. package/src/components/Quote/Quote.tsx +12 -2
  25. package/src/containers/Wallets/Wallets.tsx +1 -1
  26. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +3 -3
  27. package/src/hooks/useFetch.ts +13 -2
  28. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +1 -1
  29. package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +10 -1
  30. package/src/hooks/useWalletList.ts +2 -3
  31. package/src/hooks/useWalletProviders.ts +4 -2
  32. package/src/pages/Home.tsx +1 -2
  33. package/src/pages/WalletsPage.tsx +1 -2
  34. package/src/utils/providers.ts +1 -0
@@ -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"}
@@ -1 +1 @@
1
- {"version":3,"file":"WalletsPage.d.ts","sourceRoot":"","sources":["../../src/pages/WalletsPage.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAsBxC,eAAO,MAAM,mBAAmB,OAAQ,CAAC;AACzC,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,wBAAgB,WAAW,sBA0E1B"}
1
+ {"version":3,"file":"WalletsPage.d.ts","sourceRoot":"","sources":["../../src/pages/WalletsPage.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAsBxC,eAAO,MAAM,mBAAmB,OAAQ,CAAC;AACzC,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,wBAAgB,WAAW,sBAyE1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/utils/providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,MAAM,WAAW,gBAAgB;IAC/B,sBAAsB,CAAC,EAAE,YAAY,CAAC,wBAAwB,CAAC,CAAC;CACjE;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,EAClC,OAAO,CAAC,EAAE,gBAAgB,GACzB,iBAAiB,EAAE,CAoCrB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,EAC/B,OAAO,CAAC,EAAE,gBAAgB,GACzB,MAAM,EAAE,CAMV"}
1
+ {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/utils/providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,MAAM,WAAW,gBAAgB;IAC/B,sBAAsB,CAAC,EAAE,YAAY,CAAC,wBAAwB,CAAC,CAAC;CACjE;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,EAClC,OAAO,CAAC,EAAE,gBAAgB,GACzB,iBAAiB,EAAE,CAqCrB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,EAC/B,OAAO,CAAC,EAAE,gBAAgB,GACzB,MAAM,EAAE,CAMV"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.27.3",
3
+ "version": "0.27.4-next.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -24,14 +24,14 @@
24
24
  "dependencies": {
25
25
  "@lingui/core": "4.2.1",
26
26
  "@lingui/react": "4.2.1",
27
- "@rango-dev/logging-core": "^0.2.0",
28
- "@rango-dev/provider-all": "^0.32.1",
27
+ "@rango-dev/logging-core": "^0.2.1-next.1",
28
+ "@rango-dev/provider-all": "^0.32.2-next.2",
29
29
  "@rango-dev/queue-manager-core": "^0.26.0",
30
- "@rango-dev/queue-manager-rango-preset": "^0.32.0",
30
+ "@rango-dev/queue-manager-rango-preset": "^0.32.1-next.0",
31
31
  "@rango-dev/queue-manager-react": "^0.26.0",
32
- "@rango-dev/ui": "^0.33.0",
33
- "@rango-dev/wallets-react": "^0.18.0",
34
- "@rango-dev/wallets-shared": "^0.32.0",
32
+ "@rango-dev/ui": "^0.33.1-next.2",
33
+ "@rango-dev/wallets-react": "^0.18.1-next.0",
34
+ "@rango-dev/wallets-shared": "^0.32.1-next.0",
35
35
  "bignumber.js": "^9.1.1",
36
36
  "copy-to-clipboard": "^3.3.3",
37
37
  "dayjs": "^1.11.7",
@@ -52,4 +52,4 @@
52
52
  "publishConfig": {
53
53
  "access": "public"
54
54
  }
55
- }
55
+ }
@@ -44,7 +44,6 @@ import {
44
44
  const ACCOUNT_ADDRESS_MAX_CHARACTERS = 7;
45
45
  export function WalletList(props: PropTypes) {
46
46
  const { chain, isSelected, selectWallet, limit, onShowMore } = props;
47
- const { config } = useAppStore();
48
47
  const isActiveTab = useUiStore.use.isActiveTab();
49
48
 
50
49
  const connectedWallets = useWalletsStore.use.connectedWallets();
@@ -61,7 +60,6 @@ export function WalletList(props: PropTypes) {
61
60
  let modalTimerId: ReturnType<typeof setTimeout> | null = null;
62
61
  const { list, error, handleClick, disconnectConnectingWallets } =
63
62
  useWalletList({
64
- config,
65
63
  chain,
66
64
  onBeforeConnect: (type) => {
67
65
  modalTimerId = setTimeout(() => {
@@ -5,7 +5,6 @@ import { Image, Tooltip, WalletIcon } from '@rango-dev/ui';
5
5
  import React from 'react';
6
6
 
7
7
  import { useWalletList } from '../../hooks/useWalletList';
8
- import { useAppStore } from '../../store/AppStore';
9
8
 
10
9
  import {
11
10
  ConnectedIcon,
@@ -15,9 +14,7 @@ import {
15
14
  } from './HeaderButtons.styles';
16
15
 
17
16
  function WalletButton(props: PropTypes) {
18
- const { config } = useAppStore();
19
-
20
- const { list } = useWalletList({ config });
17
+ const { list } = useWalletList({});
21
18
  const connectedWallets = list.filter(
22
19
  (wallet) => wallet.state === 'connected'
23
20
  );
@@ -63,7 +63,25 @@ export const stepsDetailsStyles = css({
63
63
  });
64
64
  export const AllRoutesButton = styled(Button, {
65
65
  backgroundColor: 'transparent',
66
- border: '1px solid $secondary',
66
+ border: '1px solid $secondary600',
67
+ [`.${darkTheme} &`]: {
68
+ border: '1px solid $secondary',
69
+ },
70
+ transition: 'background-color 0.3s ease',
71
+ '&:hover': {
72
+ backgroundColor: '$secondary600',
73
+ [`.${darkTheme} &`]: {
74
+ backgroundColor: '$secondary',
75
+ },
76
+ '.allRoutesLabel': {
77
+ $$color: '$colors$background',
78
+ [`.${darkTheme} &`]: {
79
+ $$color: '$colors$foreground',
80
+ },
81
+ color: '$$color',
82
+ transition: 'color 0.3s ease',
83
+ },
84
+ },
67
85
  });
68
86
  export const SummaryContainer = styled('div', {
69
87
  borderRadius: '$xm',
@@ -381,8 +381,18 @@ export function Quote(props: QuoteProps) {
381
381
  }}
382
382
  size="xxsmall"
383
383
  type="secondary"
384
- variant="default">
385
- <Typography color="secondary" variant="label" size="medium">
384
+ variant="default"
385
+ css={{
386
+ paddingLeft: '$10',
387
+ paddingRight: '$10',
388
+ paddingTop: '$5',
389
+ paddingBottom: '$5',
390
+ }}>
391
+ <Typography
392
+ color="secondary"
393
+ variant="body"
394
+ size="xsmall"
395
+ className="allRoutesLabel">
386
396
  {i18n.t('See All Routes')}
387
397
  </Typography>
388
398
  </AllRoutesButton>
@@ -39,7 +39,7 @@ function Main(props: PropsWithChildren<PropTypes>) {
39
39
  const walletOptions: ProvidersOptions = {
40
40
  walletConnectProjectId: props.config?.walletConnectProjectId,
41
41
  };
42
- const { providers } = useWalletProviders(props.config.wallets, walletOptions);
42
+ const { providers } = useWalletProviders(config.wallets, walletOptions);
43
43
  const { connectWallet, disconnectWallet } = useWalletsStore();
44
44
  const onConnectWalletHandler = useRef<OnWalletConnectionChange>();
45
45
  const onDisconnectWalletHandler = useRef<OnWalletConnectionChange>();
@@ -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);
@@ -271,7 +271,7 @@ describe('usePrepareBlockchainList', () => {
271
271
  ]);
272
272
  });
273
273
 
274
- it.only('Last item of the main list should be moved to front if it selected again.', () => {
274
+ it('Last item of the main list should be moved to front if it selected again.', () => {
275
275
  const listLimit = 10;
276
276
  const preferredBlockchains = ['AVAX_CCHAIN', 'BTC'];
277
277
  const expected = [
@@ -38,6 +38,13 @@ export function useSyncUrlAndStore() {
38
38
  const liquiditySourcesParamsRef = useRef<string>();
39
39
 
40
40
  const getUrlSearchParams = () => {
41
+ const utmQueryParams: Record<string, string> = {};
42
+
43
+ for (const [key, value] of searchParams.entries()) {
44
+ if (key.startsWith('utm_')) {
45
+ utmQueryParams[key] = value;
46
+ }
47
+ }
41
48
  const fromAmount = searchParams.get(SearchParams.FROM_AMOUNT);
42
49
  const fromBlockchain = searchParams.get(SearchParams.FROM_BLOCKCHAIN);
43
50
  const fromToken = searchParams.get(SearchParams.FROM_TOKEN);
@@ -56,6 +63,7 @@ export function useSyncUrlAndStore() {
56
63
  autoConnect,
57
64
  clientUrl,
58
65
  liquiditySources,
66
+ utmQueryParams,
59
67
  };
60
68
  };
61
69
 
@@ -71,7 +79,7 @@ export function useSyncUrlAndStore() {
71
79
  };
72
80
 
73
81
  useEffect(() => {
74
- const { autoConnect, clientUrl } = getUrlSearchParams();
82
+ const { autoConnect, clientUrl, utmQueryParams } = getUrlSearchParams();
75
83
  if (isInRouterContext && fetchMetaStatus === 'success') {
76
84
  updateUrlSearchParams({
77
85
  [SearchParams.FROM_BLOCKCHAIN]: fromBlockchain?.name,
@@ -84,6 +92,7 @@ export function useSyncUrlAndStore() {
84
92
  [SearchParams.LIQUIDITY_SOURCES]: campaignMode
85
93
  ? liquiditySourcesParamsRef.current
86
94
  : undefined,
95
+ ...utmQueryParams,
87
96
  });
88
97
  }
89
98
  }, [
@@ -1,4 +1,3 @@
1
- import type { WidgetConfig } from '../types';
2
1
  import type { WalletInfo } from '@rango-dev/ui';
3
2
  import type { BlockchainMeta } from 'rango-sdk';
4
3
 
@@ -25,7 +24,6 @@ import {
25
24
  const ALL_SUPPORTED_WALLETS = Object.values(WalletTypes);
26
25
 
27
26
  interface Params {
28
- config?: WidgetConfig;
29
27
  chain?: string;
30
28
  onBeforeConnect?: (walletType: string) => void;
31
29
  onConnect?: (walletType: string) => void;
@@ -37,7 +35,8 @@ interface Params {
37
35
  * you can use this list whenever you need to show the list of wallets and needed callbacks
38
36
  */
39
37
  export function useWalletList(params: Params) {
40
- const { config, chain, onBeforeConnect, onConnect } = params;
38
+ const { chain, onBeforeConnect, onConnect } = params;
39
+ const { config } = useAppStore();
41
40
  const { state, disconnect, getWalletInfo, connect } = useWallets();
42
41
  const { connectedWallets } = useWalletsStore();
43
42
  const blockchains = useAppStore().blockchains();
@@ -13,8 +13,10 @@ export function useWalletProviders(
13
13
  ) {
14
14
  const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
15
15
  let generateProviders: ProviderInterface[] = matchAndGenerateProviders(
16
- undefined,
17
- options
16
+ providers,
17
+ {
18
+ walletConnectProjectId: options?.walletConnectProjectId,
19
+ }
18
20
  );
19
21
 
20
22
  useEffect(() => {
@@ -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': {
@@ -28,7 +28,7 @@ export const TIME_TO_CLOSE_MODAL = 3_000;
28
28
  export const TIME_TO_IGNORE_MODAL = 300;
29
29
 
30
30
  export function WalletsPage() {
31
- const { config, fetchStatus: fetchMetaStatus } = useAppStore();
31
+ const { fetchStatus: fetchMetaStatus } = useAppStore();
32
32
  const [openModal, setOpenModal] = useState(false);
33
33
  const [selectedWalletType, setSelectedWalletType] = useState<WalletType>('');
34
34
  let modalTimerId: ReturnType<typeof setTimeout> | null = null;
@@ -36,7 +36,6 @@ export function WalletsPage() {
36
36
 
37
37
  const { list, handleClick, error, disconnectConnectingWallets } =
38
38
  useWalletList({
39
- config,
40
39
  onBeforeConnect: (type) => {
41
40
  modalTimerId = setTimeout(() => {
42
41
  setOpenModal(true);
@@ -21,6 +21,7 @@ export function matchAndGenerateProviders(
21
21
  walletconnect2: {
22
22
  WC_PROJECT_ID: options?.walletConnectProjectId || '',
23
23
  },
24
+ selectedProviders: providers,
24
25
  });
25
26
 
26
27
  if (providers) {