@rango-dev/widget-embedded 0.29.1-next.14 → 0.29.1-next.16
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/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.d.ts.map +1 -1
- package/dist/hooks/useWalletProviders/index.d.ts +2 -0
- package/dist/hooks/useWalletProviders/index.d.ts.map +1 -0
- package/dist/hooks/{useWalletProviders.d.ts → useWalletProviders/useWalletProviders.d.ts} +2 -2
- package/dist/hooks/useWalletProviders/useWalletProviders.d.ts.map +1 -0
- package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts +3 -0
- package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/store/slices/settings.d.ts.map +1 -1
- package/dist/types/config.d.ts +0 -2
- package/dist/types/config.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +1 -1
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +18 -8
- package/src/components/TokenList/TokenList.tsx +1 -1
- package/src/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.ts +2 -3
- package/src/hooks/useWalletProviders/index.ts +1 -0
- package/src/hooks/useWalletProviders/useWalletProviders.helpers.ts +14 -0
- package/src/hooks/{useWalletProviders.ts → useWalletProviders/useWalletProviders.ts} +11 -5
- package/src/store/slices/settings.ts +4 -1
- package/src/types/config.ts +0 -4
- package/dist/hooks/useWalletProviders.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -18,7 +18,13 @@ import {
|
|
|
18
18
|
Typography,
|
|
19
19
|
WalletIcon,
|
|
20
20
|
} from '@rango-dev/ui';
|
|
21
|
-
import 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 =
|
|
91
|
-
|
|
92
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 '
|
|
2
|
-
import type { ProvidersOptions } from '
|
|
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 '
|
|
8
|
-
import { matchAndGenerateProviders } from '
|
|
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
|
-
}, [
|
|
25
|
+
}, [
|
|
26
|
+
hashProviders(providers ?? []),
|
|
27
|
+
options?.walletConnectProjectId,
|
|
28
|
+
options?.walletConnectListedDesktopWalletLink,
|
|
29
|
+
]);
|
|
24
30
|
|
|
25
31
|
return {
|
|
26
32
|
providers: generateProviders,
|
|
@@ -159,6 +159,8 @@ export const createSettingsSlice: StateCreator<
|
|
|
159
159
|
const isLanguageHidden = isFeatureHidden('language', features);
|
|
160
160
|
const isLiquidityHidden = isFeatureHidden('liquiditySource', features);
|
|
161
161
|
const singleTheme = theme?.singleTheme;
|
|
162
|
+
const autoUpdateSettings =
|
|
163
|
+
nextConfig?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;
|
|
162
164
|
|
|
163
165
|
set({
|
|
164
166
|
...(isThemeHidden && { theme: nextConfig.theme?.mode || 'auto' }),
|
|
@@ -169,7 +171,8 @@ export const createSettingsSlice: StateCreator<
|
|
|
169
171
|
...(isLiquidityHidden && {
|
|
170
172
|
disabledLiquiditySources: nextConfig.liquiditySources || [],
|
|
171
173
|
}),
|
|
172
|
-
...(
|
|
174
|
+
...(autoUpdateSettings && {
|
|
175
|
+
// For the time being, we have added the language; if more are needed later, we can add other parameters.
|
|
173
176
|
language: nextConfig.language || DEFAULT_LANGUAGE,
|
|
174
177
|
}),
|
|
175
178
|
});
|
package/src/types/config.ts
CHANGED
|
@@ -223,10 +223,6 @@ export type WidgetConfig = {
|
|
|
223
223
|
// These are likely to change or remove at anytime. Please use with a caution.
|
|
224
224
|
__UNSTABLE_OR_INTERNAL__?: {
|
|
225
225
|
walletConnectListedDesktopWalletLink?: string;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
// Internal configuration options. Not intended for public use or modification.
|
|
229
|
-
_INTERNAL_SETTINGS_?: {
|
|
230
226
|
autoUpdateSettings?: boolean; // If true, settings will be updated automatically based on the configuration.
|
|
231
227
|
};
|
|
232
228
|
};
|
|
@@ -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"}
|