@rango-dev/widget-embedded 0.29.1-next.15 → 0.29.1-next.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.29.1-next.15",
3
+ "version": "0.29.1-next.17",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -30,7 +30,7 @@
30
30
  "@rango-dev/queue-manager-rango-preset": "^0.34.1-next.6",
31
31
  "@rango-dev/queue-manager-react": "^0.26.0",
32
32
  "@rango-dev/signer-solana": "^0.29.1-next.1",
33
- "@rango-dev/ui": "^0.35.1-next.6",
33
+ "@rango-dev/ui": "^0.35.1-next.7",
34
34
  "@rango-dev/wallets-react": "^0.20.1-next.4",
35
35
  "@rango-dev/wallets-shared": "^0.34.1-next.4",
36
36
  "bignumber.js": "^9.1.1",
@@ -53,4 +53,4 @@
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  }
56
- }
56
+ }
@@ -18,7 +18,13 @@ import {
18
18
  Typography,
19
19
  WalletIcon,
20
20
  } from '@rango-dev/ui';
21
- import React, { useCallback, useEffect, useRef, useState } from 'react';
21
+ import React, {
22
+ useCallback,
23
+ useEffect,
24
+ useMemo,
25
+ useRef,
26
+ useState,
27
+ } from 'react';
22
28
  import { useNavigate } from 'react-router-dom';
23
29
 
24
30
  import { WIDGET_UI_ID } from '../../constants';
@@ -87,10 +93,14 @@ export function ConfirmWalletsModal(props: PropTypes) {
87
93
 
88
94
  const isFirefox = navigator?.userAgent.includes('Firefox');
89
95
 
90
- const quoteWallets = getQuoteWallets({
91
- filter: 'all',
92
- quote: selectedQuote,
93
- });
96
+ const quoteWallets = useMemo(
97
+ () =>
98
+ getQuoteWallets({
99
+ filter: 'all',
100
+ quote: selectedQuote,
101
+ }),
102
+ [selectedQuote]
103
+ );
94
104
 
95
105
  const requiredWallets = getQuoteWallets({
96
106
  filter: 'required',
@@ -113,7 +123,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
113
123
  quoteWallets.includes(connectedWallet.chain)
114
124
  );
115
125
  }),
116
- [connectedWallets.length, quoteWallets.length]
126
+ [connectedWallets, quoteWallets]
117
127
  );
118
128
 
119
129
  const [selectableWallets, setSelectableWallets] = useState<ConnectedWallet[]>(
@@ -333,7 +343,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
333
343
  );
334
344
  return nextState;
335
345
  });
336
- }, [connectedWallets.length, quoteWallets.length]);
346
+ }, [connectedWallets, quoteWallets]);
337
347
 
338
348
  useEffect(() => {
339
349
  const nextState: typeof nextSelectedWallets = [];
@@ -353,7 +363,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
353
363
  });
354
364
  setNextSelectedWallets(nextState);
355
365
  }
356
- }, [connectedWallets.length, nextSelectedWallets.length]);
366
+ }, [connectedWallets, nextSelectedWallets]);
357
367
 
358
368
  const modalContainer = document.getElementById(
359
369
  WIDGET_UI_ID.SWAP_BOX_ID
@@ -110,7 +110,7 @@ export function TokenList(props: PropTypes) {
110
110
 
111
111
  useEffect(() => {
112
112
  setTokens(list.slice(0, PAGE_SIZE));
113
- }, [list.length]);
113
+ }, [list.length, selectedBlockchain]);
114
114
 
115
115
  const renderList = () => {
116
116
  if (!tokens.length && !!searchedFor) {
@@ -46,9 +46,8 @@ export function useSubscribeToWidgetEvents() {
46
46
  setNotification(event, route);
47
47
  };
48
48
  eventEmitter.on(WidgetEvents.StepEvent, handleStepEvent);
49
-
50
49
  return () => eventEmitter.off(WidgetEvents.StepEvent, handleStepEvent);
51
- }, [eventEmitter, connectedWallets.length]);
50
+ }, [eventEmitter, connectedWallets]);
52
51
 
53
52
  useEffect(() => {
54
53
  const handleRouteEvent = (widgetEvent: RouteEventData) => {
@@ -64,5 +63,5 @@ export function useSubscribeToWidgetEvents() {
64
63
  eventEmitter.on(WidgetEvents.RouteEvent, handleRouteEvent);
65
64
 
66
65
  return () => eventEmitter.off(WidgetEvents.RouteEvent, handleRouteEvent);
67
- }, [eventEmitter, connectedWallets.length]);
66
+ }, [eventEmitter]);
68
67
  }
@@ -0,0 +1 @@
1
+ export { useWalletProviders } from './useWalletProviders';
@@ -0,0 +1,14 @@
1
+ import type { ProviderInterface } from '@rango-dev/wallets-react';
2
+
3
+ export function hashProviders(
4
+ providers: (string | ProviderInterface)[]
5
+ ): string {
6
+ return providers
7
+ .map((provider) => {
8
+ if (typeof provider === 'string') {
9
+ return provider;
10
+ }
11
+ return provider.config.type;
12
+ })
13
+ .join('-');
14
+ }
@@ -1,11 +1,13 @@
1
- import type { WidgetConfig } from '../types';
2
- import type { ProvidersOptions } from '../utils/providers';
1
+ import type { WidgetConfig } from '../../types';
2
+ import type { ProvidersOptions } from '../../utils/providers';
3
3
  import type { ProviderInterface } from '@rango-dev/wallets-react';
4
4
 
5
5
  import { useEffect } from 'react';
6
6
 
7
- import { useWalletsStore } from '../store/wallets';
8
- import { matchAndGenerateProviders } from '../utils/providers';
7
+ import { useWalletsStore } from '../../store/wallets';
8
+ import { matchAndGenerateProviders } from '../../utils/providers';
9
+
10
+ import { hashProviders } from './useWalletProviders.helpers';
9
11
 
10
12
  export function useWalletProviders(
11
13
  providers: WidgetConfig['wallets'],
@@ -20,7 +22,11 @@ export function useWalletProviders(
20
22
  useEffect(() => {
21
23
  clearConnectedWallet();
22
24
  generateProviders = matchAndGenerateProviders(providers, options);
23
- }, [providers?.length]);
25
+ }, [
26
+ hashProviders(providers ?? []),
27
+ options?.walletConnectProjectId,
28
+ options?.walletConnectListedDesktopWalletLink,
29
+ ]);
24
30
 
25
31
  return {
26
32
  providers: generateProviders,
@@ -1 +0,0 @@
1
- {"version":3,"file":"useWalletProviders.d.ts","sourceRoot":"","sources":["../../src/hooks/useWalletProviders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAOlE,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,EAClC,OAAO,CAAC,EAAE,gBAAgB;;EAgB3B"}