@rango-dev/widget-embedded 0.17.1-next.25 → 0.17.1-next.27
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/ConfirmWallets.styles.d.ts +3 -3
- package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +1 -1
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.helpers.d.ts +2 -2
- package/dist/components/TokenList/TokenList.helpers.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +3 -9
- package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
- package/dist/components/TokenList/index.d.ts +0 -1
- package/dist/components/TokenList/index.d.ts.map +1 -1
- package/dist/containers/App/App.d.ts.map +1 -1
- package/dist/hooks/useLanguage.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts +1 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/ThemePage.d.ts.map +1 -1
- package/dist/store/AppStore.d.ts +37 -1
- package/dist/store/AppStore.d.ts.map +1 -1
- package/dist/store/app.d.ts +39 -2
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/quote.d.ts +4 -5
- package/dist/store/quote.d.ts.map +1 -1
- package/dist/store/slices/settings.d.ts +39 -0
- package/dist/store/slices/settings.d.ts.map +1 -0
- package/dist/store/wallets.d.ts +5 -2
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +28 -9
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +15 -1
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/settings.d.ts +4 -1
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +6 -8
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/HeaderButtons/HomeButtons.tsx +28 -18
- package/src/components/Layout/Layout.tsx +11 -1
- package/src/components/NoResult/NoResult.tsx +2 -5
- package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +2 -2
- package/src/components/Slippage/Slippage.tsx +3 -5
- package/src/components/TokenList/TokenList.helpers.ts +2 -2
- package/src/components/TokenList/TokenList.tsx +10 -12
- package/src/components/TokenList/TokenList.types.ts +3 -10
- package/src/components/TokenList/index.ts +0 -1
- package/src/containers/App/App.tsx +0 -2
- package/src/containers/Wallets/Wallets.tsx +3 -3
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +4 -4
- package/src/hooks/useLanguage.ts +2 -3
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.ts +2 -2
- package/src/hooks/useSwapInput.ts +4 -4
- package/src/hooks/useSyncStoresWithConfig.ts +1 -2
- package/src/hooks/useTheme.ts +4 -5
- package/src/pages/ConfirmSwapPage.tsx +2 -3
- package/src/pages/Home.tsx +9 -33
- package/src/pages/LiquiditySourcePage.tsx +3 -3
- package/src/pages/SelectSwapItemsPage.tsx +3 -6
- package/src/pages/SettingsPage.tsx +22 -11
- package/src/pages/ThemePage.tsx +2 -3
- package/src/store/AppStore.tsx +7 -1
- package/src/store/app.ts +31 -5
- package/src/store/quote.ts +2 -3
- package/src/store/slices/settings.ts +168 -0
- package/src/store/wallets.ts +56 -29
- package/src/types/config.ts +38 -8
- package/src/types/wallets.ts +18 -1
- package/src/utils/settings.ts +11 -5
- package/src/utils/wallets.ts +80 -134
- package/dist/store/settings.d.ts +0 -83
- package/dist/store/settings.d.ts.map +0 -1
- package/src/store/settings.ts +0 -161
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { ConfigSlice } from './config';
|
|
2
|
+
import type { WidgetConfig } from '../../types';
|
|
3
|
+
import type { SwapperMeta } from 'rango-sdk';
|
|
4
|
+
import type { StateCreator } from 'zustand';
|
|
5
|
+
|
|
6
|
+
import { type Language } from '@rango-dev/ui';
|
|
7
|
+
|
|
8
|
+
import { BLOCKCHAIN_LIST_SIZE } from '../../constants/configs';
|
|
9
|
+
import { DEFAULT_LANGUAGE } from '../../constants/languages';
|
|
10
|
+
import { DEFAULT_SLIPPAGE } from '../../constants/swapSettings';
|
|
11
|
+
import { removeDuplicateFrom } from '../../utils/common';
|
|
12
|
+
import { isFeatureHidden } from '../../utils/settings';
|
|
13
|
+
|
|
14
|
+
export type ThemeMode = 'auto' | 'dark' | 'light';
|
|
15
|
+
|
|
16
|
+
export interface SettingsSlice {
|
|
17
|
+
theme: ThemeMode;
|
|
18
|
+
language: Language;
|
|
19
|
+
disabledLiquiditySources: string[];
|
|
20
|
+
/** Keeping a history of blockchains that user has selected (in Swap process) */
|
|
21
|
+
preferredBlockchains: string[];
|
|
22
|
+
slippage: number;
|
|
23
|
+
customSlippage: number | null;
|
|
24
|
+
infiniteApprove: boolean;
|
|
25
|
+
affiliateRef: string | null;
|
|
26
|
+
affiliatePercent: number | null;
|
|
27
|
+
affiliateWallets: { [key: string]: string } | null;
|
|
28
|
+
|
|
29
|
+
setSlippage: (slippage: number) => void;
|
|
30
|
+
setCustomSlippage: (customSlippage: number | null) => void;
|
|
31
|
+
toggleInfiniteApprove: () => void;
|
|
32
|
+
toggleLiquiditySource: (name: string) => void;
|
|
33
|
+
setTheme: (theme: ThemeMode) => void;
|
|
34
|
+
setLanguage: (language: Language) => void;
|
|
35
|
+
toggleAllLiquiditySources: (
|
|
36
|
+
swappers: SwapperMeta[],
|
|
37
|
+
shouldReset?: boolean
|
|
38
|
+
) => void;
|
|
39
|
+
setAffiliateRef: (affiliateRef: string | null) => void;
|
|
40
|
+
setAffiliatePercent: (affiliatePercent: number | null) => void;
|
|
41
|
+
setAffiliateWallets: (
|
|
42
|
+
affiliateWallets: { [key: string]: string } | null
|
|
43
|
+
) => void;
|
|
44
|
+
addPreferredBlockchain: (blockchain: string) => void;
|
|
45
|
+
updateSettings: (config: WidgetConfig) => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const createSettingsSlice: StateCreator<
|
|
49
|
+
SettingsSlice & ConfigSlice,
|
|
50
|
+
[],
|
|
51
|
+
[],
|
|
52
|
+
SettingsSlice
|
|
53
|
+
> = (set, get) => ({
|
|
54
|
+
disabledLiquiditySources: [],
|
|
55
|
+
theme: 'auto',
|
|
56
|
+
language: DEFAULT_LANGUAGE,
|
|
57
|
+
preferredBlockchains: [],
|
|
58
|
+
slippage: DEFAULT_SLIPPAGE,
|
|
59
|
+
customSlippage: null,
|
|
60
|
+
infiniteApprove: false,
|
|
61
|
+
affiliateRef: null,
|
|
62
|
+
affiliatePercent: null,
|
|
63
|
+
affiliateWallets: null,
|
|
64
|
+
|
|
65
|
+
addPreferredBlockchain: (blockchain) => {
|
|
66
|
+
const currentPreferredBlockchains = get().preferredBlockchains;
|
|
67
|
+
|
|
68
|
+
const noNeedToDoAnything = currentPreferredBlockchains.find(
|
|
69
|
+
(preferredBlockchain, index) => {
|
|
70
|
+
const isSameBlockchain = preferredBlockchain === blockchain;
|
|
71
|
+
const isInVisibleList = index <= BLOCKCHAIN_LIST_SIZE - 1;
|
|
72
|
+
|
|
73
|
+
return isSameBlockchain && isInVisibleList;
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
if (noNeedToDoAnything) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const nextPreferredBlockchains: string[] =
|
|
82
|
+
currentPreferredBlockchains.filter((preferredBlockchain) => {
|
|
83
|
+
const isSameBlockchain = preferredBlockchain === blockchain;
|
|
84
|
+
|
|
85
|
+
return !isSameBlockchain;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
set(() => ({
|
|
89
|
+
preferredBlockchains: [blockchain, ...nextPreferredBlockchains],
|
|
90
|
+
}));
|
|
91
|
+
},
|
|
92
|
+
setSlippage: (slippage) =>
|
|
93
|
+
set(() => ({
|
|
94
|
+
slippage: slippage,
|
|
95
|
+
})),
|
|
96
|
+
setCustomSlippage: (customSlippage) =>
|
|
97
|
+
set(() => ({
|
|
98
|
+
customSlippage: customSlippage,
|
|
99
|
+
})),
|
|
100
|
+
setAffiliateRef: (affiliateRef) =>
|
|
101
|
+
set(() => ({
|
|
102
|
+
affiliateRef,
|
|
103
|
+
})),
|
|
104
|
+
setAffiliatePercent: (affiliatePercent) =>
|
|
105
|
+
set(() => ({
|
|
106
|
+
affiliatePercent,
|
|
107
|
+
})),
|
|
108
|
+
|
|
109
|
+
setAffiliateWallets: (affiliateWallets) =>
|
|
110
|
+
set(() => ({
|
|
111
|
+
affiliateWallets,
|
|
112
|
+
})),
|
|
113
|
+
toggleAllLiquiditySources: (swappers, shouldReset) =>
|
|
114
|
+
set((state) => {
|
|
115
|
+
if (shouldReset) {
|
|
116
|
+
return { disabledLiquiditySources: [] };
|
|
117
|
+
}
|
|
118
|
+
const swappersGroup = removeDuplicateFrom(
|
|
119
|
+
swappers.map((swapper) => swapper.swapperGroup)
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
if (swappersGroup.length === state.disabledLiquiditySources.length) {
|
|
123
|
+
return { disabledLiquiditySources: [] };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
disabledLiquiditySources: swappersGroup,
|
|
128
|
+
};
|
|
129
|
+
}),
|
|
130
|
+
toggleInfiniteApprove: () =>
|
|
131
|
+
set((state) => ({
|
|
132
|
+
infiniteApprove: !state.infiniteApprove,
|
|
133
|
+
})),
|
|
134
|
+
toggleLiquiditySource: (name) =>
|
|
135
|
+
set((state) => {
|
|
136
|
+
if (state.disabledLiquiditySources.includes(name)) {
|
|
137
|
+
return {
|
|
138
|
+
disabledLiquiditySources: state.disabledLiquiditySources.filter(
|
|
139
|
+
(liquiditySource) => liquiditySource != name
|
|
140
|
+
),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
disabledLiquiditySources: state.disabledLiquiditySources.concat(name),
|
|
145
|
+
};
|
|
146
|
+
}),
|
|
147
|
+
setTheme: (theme) =>
|
|
148
|
+
set(() => ({
|
|
149
|
+
theme,
|
|
150
|
+
})),
|
|
151
|
+
setLanguage: (language) =>
|
|
152
|
+
set(() => ({
|
|
153
|
+
language,
|
|
154
|
+
})),
|
|
155
|
+
updateSettings: (nextConfig: WidgetConfig) => {
|
|
156
|
+
const { features } = nextConfig;
|
|
157
|
+
|
|
158
|
+
const isThemeHidden = isFeatureHidden('theme', features);
|
|
159
|
+
const isLanguageHidden = isFeatureHidden('language', features);
|
|
160
|
+
const isLiquidityHidden = isFeatureHidden('liquiditySource', features);
|
|
161
|
+
|
|
162
|
+
set({
|
|
163
|
+
...(isThemeHidden && { theme: 'auto' }),
|
|
164
|
+
...(isLanguageHidden && { language: DEFAULT_LANGUAGE }),
|
|
165
|
+
...(isLiquidityHidden && { disabledLiquiditySources: [] }),
|
|
166
|
+
});
|
|
167
|
+
},
|
|
168
|
+
});
|
package/src/store/wallets.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Wallet } from '../types';
|
|
1
|
+
import type { Balance, TokensBalance, Wallet } from '../types';
|
|
2
2
|
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
3
3
|
import type { Token } from 'rango-sdk';
|
|
4
4
|
|
|
@@ -7,8 +7,10 @@ import { subscribeWithSelector } from 'zustand/middleware';
|
|
|
7
7
|
|
|
8
8
|
import { httpService } from '../services/httpService';
|
|
9
9
|
import {
|
|
10
|
+
createTokenHash,
|
|
10
11
|
isAccountAndWalletMatched,
|
|
11
12
|
makeBalanceFor,
|
|
13
|
+
makeTokensBalance,
|
|
12
14
|
resetConnectedWalletState,
|
|
13
15
|
} from '../utils/wallets';
|
|
14
16
|
|
|
@@ -33,9 +35,9 @@ export interface ConnectedWallet extends Wallet {
|
|
|
33
35
|
loading: boolean;
|
|
34
36
|
error: boolean;
|
|
35
37
|
}
|
|
36
|
-
|
|
37
38
|
interface WalletsStore {
|
|
38
39
|
connectedWallets: ConnectedWallet[];
|
|
40
|
+
balances: TokensBalance;
|
|
39
41
|
customDestination: string;
|
|
40
42
|
loading: boolean;
|
|
41
43
|
connectWallet: (accounts: Wallet[], tokens: Token[]) => void;
|
|
@@ -47,12 +49,14 @@ interface WalletsStore {
|
|
|
47
49
|
tokens: Token[],
|
|
48
50
|
shouldRetry?: boolean
|
|
49
51
|
) => void;
|
|
52
|
+
getBalanceFor: (token: Token) => Balance | null;
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
export const useWalletsStore = createSelectors(
|
|
53
56
|
create<WalletsStore>()(
|
|
54
57
|
subscribeWithSelector((set, get) => ({
|
|
55
58
|
connectedWallets: [],
|
|
59
|
+
balances: {},
|
|
56
60
|
customDestination: '',
|
|
57
61
|
loading: false,
|
|
58
62
|
connectWallet: (accounts, tokens) => {
|
|
@@ -92,21 +96,27 @@ export const useWalletsStore = createSelectors(
|
|
|
92
96
|
connectedWallet.walletType !== walletType
|
|
93
97
|
)
|
|
94
98
|
.map((selectedWallet) => selectedWallet.chain);
|
|
99
|
+
|
|
100
|
+
const connectedWallets = state.connectedWallets
|
|
101
|
+
.filter(
|
|
102
|
+
(connectedWallet) => connectedWallet.walletType !== walletType
|
|
103
|
+
)
|
|
104
|
+
.map((connectedWallet) => {
|
|
105
|
+
const anyWalletSelectedForBlockchain = selectedWallets.includes(
|
|
106
|
+
connectedWallet.chain
|
|
107
|
+
);
|
|
108
|
+
if (anyWalletSelectedForBlockchain) {
|
|
109
|
+
return connectedWallet;
|
|
110
|
+
}
|
|
111
|
+
selectedWallets.push(connectedWallet.chain);
|
|
112
|
+
return { ...connectedWallet, selected: true };
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const balances = makeTokensBalance(connectedWallets);
|
|
116
|
+
|
|
95
117
|
return {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
(connectedWallet) => connectedWallet.walletType !== walletType
|
|
99
|
-
)
|
|
100
|
-
.map((connectedWallet) => {
|
|
101
|
-
const anyWalletSelectedForBlockchain = selectedWallets.includes(
|
|
102
|
-
connectedWallet.chain
|
|
103
|
-
);
|
|
104
|
-
if (anyWalletSelectedForBlockchain) {
|
|
105
|
-
return connectedWallet;
|
|
106
|
-
}
|
|
107
|
-
selectedWallets.push(connectedWallet.chain);
|
|
108
|
-
return { ...connectedWallet, selected: true };
|
|
109
|
-
}),
|
|
118
|
+
balances,
|
|
119
|
+
connectedWallets,
|
|
110
120
|
};
|
|
111
121
|
});
|
|
112
122
|
},
|
|
@@ -159,9 +169,8 @@ export const useWalletsStore = createSelectors(
|
|
|
159
169
|
const response = await httpService().getWalletsDetails(data);
|
|
160
170
|
const retrievedBalance = response.wallets;
|
|
161
171
|
if (retrievedBalance) {
|
|
162
|
-
set((state) =>
|
|
163
|
-
|
|
164
|
-
connectedWallets: state.connectedWallets.map(
|
|
172
|
+
set((state) => {
|
|
173
|
+
const connectedWallets = state.connectedWallets.map(
|
|
165
174
|
(connectedWallet) => {
|
|
166
175
|
const matchedAccount = accounts.find((account) =>
|
|
167
176
|
isAccountAndWalletMatched(account, connectedWallet)
|
|
@@ -190,27 +199,45 @@ export const useWalletsStore = createSelectors(
|
|
|
190
199
|
}
|
|
191
200
|
: connectedWallet;
|
|
192
201
|
}
|
|
193
|
-
)
|
|
194
|
-
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
const balances = makeTokensBalance(connectedWallets);
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
loading: false,
|
|
208
|
+
balances,
|
|
209
|
+
connectedWallets,
|
|
210
|
+
};
|
|
211
|
+
});
|
|
195
212
|
} else {
|
|
196
213
|
throw new Error('Wallet not found');
|
|
197
214
|
}
|
|
198
215
|
} catch (error) {
|
|
199
|
-
set((state) =>
|
|
200
|
-
|
|
201
|
-
connectedWallets: state.connectedWallets.map((balance) => {
|
|
216
|
+
set((state) => {
|
|
217
|
+
const connectedWallets = state.connectedWallets.map((balance) => {
|
|
202
218
|
return accounts.find((account) =>
|
|
203
219
|
isAccountAndWalletMatched(account, balance)
|
|
204
220
|
)
|
|
205
221
|
? resetConnectedWalletState(balance)
|
|
206
222
|
: balance;
|
|
207
|
-
})
|
|
208
|
-
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
const balances = makeTokensBalance(connectedWallets);
|
|
226
|
+
|
|
227
|
+
return {
|
|
228
|
+
loading: false,
|
|
229
|
+
balances,
|
|
230
|
+
connectedWallets,
|
|
231
|
+
};
|
|
232
|
+
});
|
|
209
233
|
}
|
|
210
234
|
},
|
|
235
|
+
getBalanceFor: (token) => {
|
|
236
|
+
const { balances } = get();
|
|
237
|
+
const tokenHash = createTokenHash(token);
|
|
238
|
+
const balance = balances[tokenHash];
|
|
239
|
+
return balance ?? null;
|
|
240
|
+
},
|
|
211
241
|
}))
|
|
212
242
|
)
|
|
213
243
|
);
|
|
214
|
-
|
|
215
|
-
export const fetchingBalanceSelector = (state: WalletsStore) =>
|
|
216
|
-
!!state.connectedWallets.find((wallet) => wallet.loading);
|
package/src/types/config.ts
CHANGED
|
@@ -86,14 +86,37 @@ export type BlockchainAndTokenConfig = {
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
* `
|
|
89
|
+
* `Features`
|
|
90
90
|
*
|
|
91
|
-
* @property {
|
|
92
|
-
|
|
91
|
+
* @property {'visible' | 'hidden'} [theme]
|
|
92
|
+
* - The visibility state for the theme feature. Optional property.
|
|
93
|
+
*
|
|
94
|
+
* @property {'visible' | 'hidden'} [language]
|
|
95
|
+
* - The visibility state for the language feature. Optional property.
|
|
96
|
+
*
|
|
97
|
+
* @property {'disabled' | 'enabled'} [experimentalRoute]
|
|
98
|
+
* - The enablement state for the experimental route feature. Optional property.
|
|
99
|
+
*
|
|
100
|
+
* @property {'visible' | 'hidden'} [connectWalletButton]
|
|
101
|
+
* - The visibility state for the connect wallet button feature. Optional property.
|
|
102
|
+
*
|
|
103
|
+
* @property {'visible' | 'hidden'} [notification]
|
|
104
|
+
* - The visibility state for the notification feature. Optional property.
|
|
105
|
+
*
|
|
106
|
+
* @property {'visible' | 'hidden'} [liquiditySource]
|
|
107
|
+
* - The visibility state for the liquiditySource feature. Optional property.
|
|
93
108
|
*/
|
|
94
|
-
type
|
|
95
|
-
|
|
96
|
-
|
|
109
|
+
export type Features = Partial<
|
|
110
|
+
Record<
|
|
111
|
+
| 'theme'
|
|
112
|
+
| 'language'
|
|
113
|
+
| 'connectWalletButton'
|
|
114
|
+
| 'notification'
|
|
115
|
+
| 'liquiditySource',
|
|
116
|
+
'visible' | 'hidden'
|
|
117
|
+
>
|
|
118
|
+
> &
|
|
119
|
+
Partial<Record<'experimentalRoute', 'disabled' | 'enabled'>>;
|
|
97
120
|
|
|
98
121
|
/**
|
|
99
122
|
* The type WidgetConfig defines the configuration options for a widget, including API key, affiliate
|
|
@@ -134,7 +157,14 @@ type ExperimentalFeatures = {
|
|
|
134
157
|
* you could use to pin tokens of your choice to the top of the token list.
|
|
135
158
|
* @property {boolean} enableNewLiquiditySources - The `enableNewLiquiditySources` property is a boolean value that when you
|
|
136
159
|
* set it to true, whenever a new liquidity source is added, it will be added to your list as well.
|
|
137
|
-
* @property {
|
|
160
|
+
* @property {Features} features - An optional object for configuring the visibility or enablement of various features.
|
|
161
|
+
* Keys include:
|
|
162
|
+
* - 'notification': Visibility state for the notification icon.
|
|
163
|
+
* - 'theme': Visibility state for the theme.
|
|
164
|
+
* - 'liquiditySource': Visibility state for liquidity source.
|
|
165
|
+
* - 'connectWalletButton': Visibility state for the wallet connect icon.
|
|
166
|
+
* - 'language': Visibility state for the language.
|
|
167
|
+
* - 'experimentalRoute': Enablement state for the experimental route.
|
|
138
168
|
*/
|
|
139
169
|
|
|
140
170
|
export type WidgetConfig = {
|
|
@@ -154,5 +184,5 @@ export type WidgetConfig = {
|
|
|
154
184
|
externalWallets?: boolean;
|
|
155
185
|
pinnedTokens?: Asset[];
|
|
156
186
|
enableNewLiquiditySources?: boolean;
|
|
157
|
-
|
|
187
|
+
features?: Features;
|
|
158
188
|
};
|
package/src/types/wallets.ts
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
import { WalletType } from '@rango-dev/wallets-shared';
|
|
1
|
+
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
2
2
|
|
|
3
3
|
export interface Wallet {
|
|
4
4
|
chain: string;
|
|
5
5
|
address: string;
|
|
6
6
|
walletType: WalletType;
|
|
7
7
|
}
|
|
8
|
+
|
|
9
|
+
export type Balance = {
|
|
10
|
+
amount: string;
|
|
11
|
+
decimals: number;
|
|
12
|
+
usdValue: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type Blockchain = string;
|
|
16
|
+
type TokenSymbol = string;
|
|
17
|
+
type Address = string;
|
|
18
|
+
|
|
19
|
+
/** `blockchain-symbol-Address` */
|
|
20
|
+
export type TokenHash = `${Blockchain}-${TokenSymbol}-${Address}`;
|
|
21
|
+
|
|
22
|
+
export type TokensBalance = {
|
|
23
|
+
[key: TokenHash]: Balance;
|
|
24
|
+
};
|
package/src/utils/settings.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import type { Features } from '../types';
|
|
1
2
|
import type { SwapperMeta } from 'rango-sdk';
|
|
2
3
|
|
|
3
|
-
import { useSettingsStore } from '../store/settings';
|
|
4
|
-
|
|
5
4
|
import { removeDuplicateFrom } from './common';
|
|
6
5
|
|
|
7
6
|
export type LiquiditySourceType = 'BRIDGE' | 'AGGREGATOR' | 'DEX';
|
|
@@ -15,10 +14,9 @@ export type UniqueSwappersGroupType = {
|
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
export function getUniqueSwappersGroups(
|
|
18
|
-
swappers: SwapperMeta[]
|
|
17
|
+
swappers: SwapperMeta[],
|
|
18
|
+
disabledLiquiditySources: string[]
|
|
19
19
|
): UniqueSwappersGroupType[] {
|
|
20
|
-
const disabledLiquiditySources =
|
|
21
|
-
useSettingsStore.use.disabledLiquiditySources();
|
|
22
20
|
const supportedSwappers = swappers.map((swapper) => swapper.swapperGroup);
|
|
23
21
|
|
|
24
22
|
const uniqueSupportedSwappersGroups: Array<UniqueSwappersGroupType> = [];
|
|
@@ -71,3 +69,11 @@ export function sortLiquiditySourcesByGroupTitle(
|
|
|
71
69
|
|
|
72
70
|
return 0;
|
|
73
71
|
}
|
|
72
|
+
|
|
73
|
+
export function isFeatureHidden(feature: keyof Features, features?: Features) {
|
|
74
|
+
return features?.[feature] === 'hidden';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function isFeatureEnabled(feature: keyof Features, features?: Features) {
|
|
78
|
+
return features?.[feature] === 'enabled';
|
|
79
|
+
}
|