@rango-dev/widget-embedded 0.17.1-next.31 → 0.17.1-next.33
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/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +1 -0
- package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +2 -2
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/types/config.d.ts +3 -3
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +14 -8
- package/src/components/TokenList/TokenList.tsx +1 -1
- package/src/components/TokenList/TokenList.types.ts +1 -0
- package/src/pages/SelectSwapItemsPage.tsx +8 -4
- package/src/store/slices/data.ts +10 -6
- package/src/types/config.ts +3 -3
- package/src/utils/wallets.ts +52 -23
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectSwapItemsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SelectSwapItemsPage.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAcxC,UAAU,SAAS;IACjB,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC;CAChC;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"SelectSwapItemsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SelectSwapItemsPage.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAcxC,UAAU,SAAS;IACjB,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC;CAChC;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,qBA+FnD"}
|
|
@@ -5,7 +5,7 @@ type BlockchainOptions = {
|
|
|
5
5
|
type?: 'source' | 'destination';
|
|
6
6
|
};
|
|
7
7
|
type TokenOptions = {
|
|
8
|
-
type
|
|
8
|
+
type: 'source' | 'destination';
|
|
9
9
|
blockchain?: string;
|
|
10
10
|
searchFor?: string;
|
|
11
11
|
};
|
|
@@ -19,7 +19,7 @@ export interface DataSlice {
|
|
|
19
19
|
blockchains: (options?: BlockchainOptions) => BlockchainMeta[];
|
|
20
20
|
tokens: (options?: TokenOptions) => Token[];
|
|
21
21
|
swappers: () => SwapperMeta[];
|
|
22
|
-
isTokenPinned: (token: Token) => boolean;
|
|
22
|
+
isTokenPinned: (token: Token, type: 'source' | 'destination') => boolean;
|
|
23
23
|
fetch: () => Promise<void>;
|
|
24
24
|
}
|
|
25
25
|
export declare const createDataSlice: StateCreator<DataSlice & ConfigSlice, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/store/slices/data.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAO5C,KAAK,iBAAiB,GAAG;IACvB,IAAI,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC;CACjC,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,IAAI,
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/store/slices/data.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAO5C,KAAK,iBAAiB,GAAG;IACvB,IAAI,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC;CACjC,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC;IAE/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC3D,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,OAAO,EAAE,KAAK,EAAE,CAAC;IACjB,cAAc,EAAE,KAAK,EAAE,CAAC;IACxB,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,iBAAiB,KAAK,cAAc,EAAE,CAAC;IAC/D,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,KAAK,EAAE,CAAC;IAC5C,QAAQ,EAAE,MAAM,WAAW,EAAE,CAAC;IAC9B,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,GAAG,aAAa,KAAK,OAAO,CAAC;IAEzE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,eAAO,MAAM,eAAe,EAAE,YAAY,CACxC,SAAS,GAAG,WAAW,EACvB;CAAE,EACF;CAAE,EACF,SAAS,CAyMT,CAAC"}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -78,12 +78,15 @@ export type WidgetAffiliate = {
|
|
|
78
78
|
* blockchains. e.g. ['BSC','ETHEREUM']
|
|
79
79
|
* @property {Asset[]} tokens - The `tokens` property is an optional array of `Asset` objects that
|
|
80
80
|
* you could use that to limit tokens to some limited ones.
|
|
81
|
+
* @property {Asset} pinnedTokens - The `pinnedTokens` property is an optional array of `Asset` objects that
|
|
82
|
+
* you could use to pin tokens of your choice to the top of the token list.
|
|
81
83
|
*/
|
|
82
84
|
export type BlockchainAndTokenConfig = {
|
|
83
85
|
blockchain?: string;
|
|
84
86
|
token?: Asset;
|
|
85
87
|
blockchains?: string[];
|
|
86
88
|
tokens?: Asset[];
|
|
89
|
+
pinnedTokens?: Asset[];
|
|
87
90
|
};
|
|
88
91
|
/**
|
|
89
92
|
* `Features`
|
|
@@ -142,8 +145,6 @@ export type Features = Partial<Record<'theme' | 'language' | 'connectWalletButto
|
|
|
142
145
|
* that defines the various properties of the theme, such as colors, fonts, and others.
|
|
143
146
|
* @property {boolean} externalWallets
|
|
144
147
|
* If `externalWallets` is `true`, you should add `WidgetWallets` to your app.
|
|
145
|
-
* @property {Asset} pinnedTokens - The `pinnedTokens` property is an optional array of `Asset` objects that
|
|
146
|
-
* you could use to pin tokens of your choice to the top of the token list.
|
|
147
148
|
* @property {boolean} enableNewLiquiditySources - The `enableNewLiquiditySources` property is a boolean value that when you
|
|
148
149
|
* set it to true, whenever a new liquidity source is added, it will be added to your list as well.
|
|
149
150
|
* @property {Features} features - An optional object for configuring the visibility or enablement of various features.
|
|
@@ -170,7 +171,6 @@ export type WidgetConfig = {
|
|
|
170
171
|
language?: Language;
|
|
171
172
|
theme?: WidgetTheme;
|
|
172
173
|
externalWallets?: boolean;
|
|
173
|
-
pinnedTokens?: Asset[];
|
|
174
174
|
enableNewLiquiditySources?: boolean;
|
|
175
175
|
features?: Features;
|
|
176
176
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,C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-17,7 +17,7 @@ export declare const getUsdPrice: (blockchain: string, symbol: string, address:
|
|
|
17
17
|
export declare const isExperimentalChain: (blockchains: BlockchainMeta[], wallet: string) => boolean;
|
|
18
18
|
export declare const getKeplrCompatibleConnectedWallets: (selectableWallets: Wallet[]) => WalletType[];
|
|
19
19
|
export declare function formatBalance(balance: Balance | null): Balance | null;
|
|
20
|
-
export declare function
|
|
20
|
+
export declare function sortTokens(tokens: Token[], getBalanceFor: (token: Token) => Balance | null, isTokenPinned: (token: Token) => boolean): Token[];
|
|
21
21
|
export declare function tokensAreEqual(tokenA: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null, tokenB: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null): boolean;
|
|
22
22
|
export declare function sortWalletsBasedOnConnectionState(wallets: ModalWalletInfo[]): ModalWalletInfo[];
|
|
23
23
|
export declare function getConciseAddress(address: string, maxChars?: number, ellipsisLength?: number): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/utils/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EACV,KAAK,EACL,OAAO,EACP,UAAU,EACV,WAAW,EACX,UAAU,EAEX,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,KAAK,EACL,YAAY,EACb,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AAuB5D,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAWvE;AAED,wBAA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EACzB,KAAK,EACL,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,MAAM,GAAG,SAAS,CAMrB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CAEvD;AAED,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,eAAe,EAAE,iBAmCpE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.17.1-next.
|
|
3
|
+
"version": "0.17.1-next.33",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@rango-dev/queue-manager-core": "^0.22.1-next.3",
|
|
26
26
|
"@rango-dev/queue-manager-rango-preset": "^0.22.1-next.12",
|
|
27
27
|
"@rango-dev/queue-manager-react": "^0.22.1-next.3",
|
|
28
|
-
"@rango-dev/ui": "^0.22.1-next.
|
|
28
|
+
"@rango-dev/ui": "^0.22.1-next.19",
|
|
29
29
|
"@rango-dev/wallets-react": "^0.8.1-next.6",
|
|
30
30
|
"@rango-dev/wallets-shared": "^0.21.1-next.6",
|
|
31
31
|
"bignumber.js": "^9.1.1",
|
|
@@ -1,30 +1,36 @@
|
|
|
1
1
|
import type { WalletStateContentProps } from './SwapDetailsModal.types';
|
|
2
2
|
|
|
3
|
-
import { MessageBox, Wallet
|
|
3
|
+
import { MessageBox, Wallet } from '@rango-dev/ui';
|
|
4
4
|
import { useWallets } from '@rango-dev/wallets-react';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { getContainer } from '../../utils/common';
|
|
8
|
+
import { mapStatusToWalletState } from '../../utils/wallets';
|
|
8
9
|
|
|
9
10
|
import { WalletContainer } from './SwapDetailsModal.styles';
|
|
10
11
|
|
|
11
12
|
export const WalletStateContent = (props: WalletStateContentProps) => {
|
|
12
13
|
const { type, title, currentStepWallet, message, showWalletButton } = props;
|
|
13
|
-
const { connect, getWalletInfo, state
|
|
14
|
+
const { connect, getWalletInfo, state } = useWallets();
|
|
14
15
|
const walletType = currentStepWallet?.walletType;
|
|
15
|
-
const
|
|
16
|
-
|
|
16
|
+
const walletState = walletType
|
|
17
|
+
? mapStatusToWalletState(state(walletType))
|
|
18
|
+
: null;
|
|
19
|
+
const walletInfo = walletType ? getWalletInfo(walletType) : null;
|
|
20
|
+
const shouldShowWallet =
|
|
21
|
+
showWalletButton && !!walletType && !!walletState && !!walletInfo;
|
|
17
22
|
return (
|
|
18
23
|
<>
|
|
19
24
|
<MessageBox type={type} title={title} description={message} />
|
|
20
|
-
{
|
|
25
|
+
{shouldShowWallet && (
|
|
21
26
|
<WalletContainer>
|
|
22
27
|
<Wallet
|
|
23
28
|
container={getContainer()}
|
|
24
|
-
title={
|
|
25
|
-
image={
|
|
29
|
+
title={walletInfo.name}
|
|
30
|
+
image={walletInfo.img}
|
|
26
31
|
type={walletType}
|
|
27
|
-
state={
|
|
32
|
+
state={walletState}
|
|
33
|
+
link={walletInfo.installLink}
|
|
28
34
|
onClick={async () => connect(walletType)}
|
|
29
35
|
/>
|
|
30
36
|
</WalletContainer>
|
|
@@ -184,7 +184,7 @@ export function TokenList(props: PropTypes) {
|
|
|
184
184
|
start={
|
|
185
185
|
<ImageSection>
|
|
186
186
|
<Image src={token.image} size={30} />
|
|
187
|
-
{isTokenPinned(token) && (
|
|
187
|
+
{isTokenPinned(token, props.type) && (
|
|
188
188
|
<Pin>
|
|
189
189
|
<PinIcon size={12} color="gray" />
|
|
190
190
|
</Pin>
|
|
@@ -14,7 +14,7 @@ import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
|
14
14
|
import { useAppStore } from '../store/AppStore';
|
|
15
15
|
import { useQuoteStore } from '../store/quote';
|
|
16
16
|
import { useWalletsStore } from '../store/wallets';
|
|
17
|
-
import {
|
|
17
|
+
import { sortTokens } from '../utils/wallets';
|
|
18
18
|
|
|
19
19
|
interface PropTypes {
|
|
20
20
|
type: 'source' | 'destination';
|
|
@@ -34,22 +34,25 @@ export function SelectSwapItemsPage(props: PropTypes) {
|
|
|
34
34
|
} = useQuoteStore();
|
|
35
35
|
const getBalanceFor = useWalletsStore.use.getBalanceFor();
|
|
36
36
|
const [searchedFor, setSearchedFor] = useState<string>('');
|
|
37
|
+
const { isTokenPinned } = useAppStore();
|
|
37
38
|
|
|
38
39
|
const selectedBlockchain = type === 'source' ? fromBlockchain : toBlockchain;
|
|
39
40
|
const selectedBlockchainName = selectedBlockchain?.name ?? '';
|
|
40
41
|
|
|
41
42
|
// Tokens & Blockchains list
|
|
42
43
|
const blockchains = useAppStore().blockchains({
|
|
43
|
-
type
|
|
44
|
+
type,
|
|
44
45
|
});
|
|
45
46
|
const tokens = useAppStore().tokens({
|
|
46
47
|
type,
|
|
47
48
|
blockchain: selectedBlockchainName,
|
|
48
49
|
searchFor: searchedFor,
|
|
49
50
|
});
|
|
50
|
-
const tokensList = sortTokensByBalance(tokens, getBalanceFor);
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
const checkIsTokenPinned = (token: Token) => isTokenPinned(token, type);
|
|
53
|
+
|
|
54
|
+
const tokensList = sortTokens(tokens, getBalanceFor, checkIsTokenPinned);
|
|
55
|
+
|
|
53
56
|
const updateBlockchain = (blockchain: BlockchainMeta) => {
|
|
54
57
|
if (type === 'source') {
|
|
55
58
|
setFromBlockchain(blockchain);
|
|
@@ -96,6 +99,7 @@ export function SelectSwapItemsPage(props: PropTypes) {
|
|
|
96
99
|
list={tokensList}
|
|
97
100
|
selectedBlockchain={selectedBlockchainName}
|
|
98
101
|
searchedFor={searchedFor}
|
|
102
|
+
type={type}
|
|
99
103
|
onChange={(token) => {
|
|
100
104
|
updateToken(token);
|
|
101
105
|
|
package/src/store/slices/data.ts
CHANGED
|
@@ -14,7 +14,7 @@ type BlockchainOptions = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
type TokenOptions = {
|
|
17
|
-
type
|
|
17
|
+
type: 'source' | 'destination';
|
|
18
18
|
// filter by an specific blockchain
|
|
19
19
|
blockchain?: string;
|
|
20
20
|
searchFor?: string;
|
|
@@ -29,7 +29,7 @@ export interface DataSlice {
|
|
|
29
29
|
blockchains: (options?: BlockchainOptions) => BlockchainMeta[];
|
|
30
30
|
tokens: (options?: TokenOptions) => Token[];
|
|
31
31
|
swappers: () => SwapperMeta[];
|
|
32
|
-
isTokenPinned: (token: Token) => boolean;
|
|
32
|
+
isTokenPinned: (token: Token, type: 'source' | 'destination') => boolean;
|
|
33
33
|
|
|
34
34
|
fetch: () => Promise<void>;
|
|
35
35
|
}
|
|
@@ -131,10 +131,10 @@ export const createDataSlice: StateCreator<
|
|
|
131
131
|
})
|
|
132
132
|
.sort((a, b) => {
|
|
133
133
|
// Check pinned tokens
|
|
134
|
-
if (get().isTokenPinned(a)) {
|
|
134
|
+
if (get().isTokenPinned(a, options.type)) {
|
|
135
135
|
return -1;
|
|
136
136
|
}
|
|
137
|
-
if (get().isTokenPinned(b)) {
|
|
137
|
+
if (get().isTokenPinned(b, options.type)) {
|
|
138
138
|
return 1;
|
|
139
139
|
}
|
|
140
140
|
|
|
@@ -159,8 +159,12 @@ export const createDataSlice: StateCreator<
|
|
|
159
159
|
|
|
160
160
|
return list;
|
|
161
161
|
},
|
|
162
|
-
isTokenPinned: (token) => {
|
|
163
|
-
const
|
|
162
|
+
isTokenPinned: (token, type) => {
|
|
163
|
+
const pinnedTokens =
|
|
164
|
+
type === 'source'
|
|
165
|
+
? get().config.from?.pinnedTokens
|
|
166
|
+
: get().config.to?.pinnedTokens;
|
|
167
|
+
const pinned = !!pinnedTokens?.some((pinnedToken) =>
|
|
164
168
|
tokensAreEqual(pinnedToken, token)
|
|
165
169
|
);
|
|
166
170
|
return pinned;
|
package/src/types/config.ts
CHANGED
|
@@ -77,12 +77,15 @@ export type WidgetAffiliate = {
|
|
|
77
77
|
* blockchains. e.g. ['BSC','ETHEREUM']
|
|
78
78
|
* @property {Asset[]} tokens - The `tokens` property is an optional array of `Asset` objects that
|
|
79
79
|
* you could use that to limit tokens to some limited ones.
|
|
80
|
+
* @property {Asset} pinnedTokens - The `pinnedTokens` property is an optional array of `Asset` objects that
|
|
81
|
+
* you could use to pin tokens of your choice to the top of the token list.
|
|
80
82
|
*/
|
|
81
83
|
export type BlockchainAndTokenConfig = {
|
|
82
84
|
blockchain?: string;
|
|
83
85
|
token?: Asset;
|
|
84
86
|
blockchains?: string[];
|
|
85
87
|
tokens?: Asset[];
|
|
88
|
+
pinnedTokens?: Asset[];
|
|
86
89
|
};
|
|
87
90
|
|
|
88
91
|
/**
|
|
@@ -153,8 +156,6 @@ export type Features = Partial<
|
|
|
153
156
|
* that defines the various properties of the theme, such as colors, fonts, and others.
|
|
154
157
|
* @property {boolean} externalWallets
|
|
155
158
|
* If `externalWallets` is `true`, you should add `WidgetWallets` to your app.
|
|
156
|
-
* @property {Asset} pinnedTokens - The `pinnedTokens` property is an optional array of `Asset` objects that
|
|
157
|
-
* you could use to pin tokens of your choice to the top of the token list.
|
|
158
159
|
* @property {boolean} enableNewLiquiditySources - The `enableNewLiquiditySources` property is a boolean value that when you
|
|
159
160
|
* set it to true, whenever a new liquidity source is added, it will be added to your list as well.
|
|
160
161
|
* @property {Features} features - An optional object for configuring the visibility or enablement of various features.
|
|
@@ -182,7 +183,6 @@ export type WidgetConfig = {
|
|
|
182
183
|
language?: Language;
|
|
183
184
|
theme?: WidgetTheme;
|
|
184
185
|
externalWallets?: boolean;
|
|
185
|
-
pinnedTokens?: Asset[];
|
|
186
186
|
enableNewLiquiditySources?: boolean;
|
|
187
187
|
features?: Features;
|
|
188
188
|
};
|
package/src/utils/wallets.ts
CHANGED
|
@@ -380,35 +380,64 @@ export function formatBalance(balance: Balance | null): Balance | null {
|
|
|
380
380
|
return formattedBalance;
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
-
|
|
383
|
+
function sortTokensByBalance(
|
|
384
|
+
token1Balance: Balance | null,
|
|
385
|
+
token2Balance: Balance | null
|
|
386
|
+
): number {
|
|
387
|
+
if (token1Balance?.usdValue && token2Balance?.usdValue) {
|
|
388
|
+
return (
|
|
389
|
+
parseFloat(token2Balance.usdValue) - parseFloat(token1Balance.usdValue)
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (!token1Balance?.usdValue && token2Balance?.usdValue) {
|
|
394
|
+
return 1;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
if (token1Balance?.usdValue && !token2Balance?.usdValue) {
|
|
398
|
+
return -1;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
if (!token1Balance?.usdValue && !token2Balance?.usdValue) {
|
|
402
|
+
return (
|
|
403
|
+
parseFloat(token2Balance?.amount || '0') -
|
|
404
|
+
parseFloat(token1Balance?.amount || '0')
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return 0;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function sortTokensByPinnedToken(
|
|
412
|
+
token1: Token,
|
|
413
|
+
token2: Token,
|
|
414
|
+
isTokenPinned: (token: Token) => boolean
|
|
415
|
+
): number {
|
|
416
|
+
const isToken1Pinned = isTokenPinned(token1);
|
|
417
|
+
const isToken2Pinned = isTokenPinned(token2);
|
|
418
|
+
|
|
419
|
+
if (isToken1Pinned === isToken2Pinned) {
|
|
420
|
+
return 0;
|
|
421
|
+
}
|
|
422
|
+
if (isToken1Pinned) {
|
|
423
|
+
return -1;
|
|
424
|
+
}
|
|
425
|
+
return 1;
|
|
426
|
+
}
|
|
427
|
+
export function sortTokens(
|
|
384
428
|
tokens: Token[],
|
|
385
|
-
getBalanceFor: (token: Token) => Balance | null
|
|
429
|
+
getBalanceFor: (token: Token) => Balance | null,
|
|
430
|
+
isTokenPinned: (token: Token) => boolean
|
|
386
431
|
) {
|
|
387
432
|
tokens.sort((token1, token2) => {
|
|
388
433
|
const token1Balance = getBalanceFor(token1);
|
|
389
434
|
const token2Balance = getBalanceFor(token2);
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
parseFloat(token2Balance.usdValue) - parseFloat(token1Balance.usdValue)
|
|
393
|
-
);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
if (!token1Balance?.usdValue && token2Balance?.usdValue) {
|
|
397
|
-
return 1;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
if (token1Balance?.usdValue && !token2Balance?.usdValue) {
|
|
401
|
-
return -1;
|
|
402
|
-
}
|
|
435
|
+
// Check pinned tokens
|
|
436
|
+
const isTokenPin = sortTokensByPinnedToken(token1, token2, isTokenPinned);
|
|
403
437
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
parseFloat(token1Balance?.amount || '0')
|
|
408
|
-
);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
return 0;
|
|
438
|
+
return isTokenPin !== 0
|
|
439
|
+
? isTokenPin
|
|
440
|
+
: sortTokensByBalance(token1Balance, token2Balance);
|
|
412
441
|
});
|
|
413
442
|
|
|
414
443
|
return tokens;
|