@rango-dev/widget-embedded 0.23.1-next.21 → 0.23.1-next.23
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/constants/languages.d.ts.map +1 -1
- package/dist/constants/searchFor.d.ts +7 -0
- package/dist/constants/searchFor.d.ts.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/LanguagePage.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/store/AppStore.d.ts +2 -2
- package/dist/store/app.d.ts +2 -2
- package/dist/store/slices/data.d.ts +3 -1
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/utils/common.d.ts +4 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +1 -0
- package/dist/utils/meta.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/constants/languages.ts +27 -1
- package/src/constants/searchFor.ts +6 -0
- package/src/pages/LanguagePage.tsx +8 -0
- package/src/pages/SelectSwapItemsPage.tsx +2 -7
- package/src/store/slices/data.ts +74 -29
- package/src/utils/common.ts +181 -0
- package/src/utils/meta.ts +21 -0
- package/src/utils/wallets.ts +5 -47
package/src/utils/meta.ts
CHANGED
|
@@ -31,3 +31,24 @@ export function findToken(t: Asset, tokens: Token[]) {
|
|
|
31
31
|
export function findBlockchain(name: string, blockchains: BlockchainMeta[]) {
|
|
32
32
|
return blockchains.find((blockchain) => blockchain.name === name) ?? null;
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
export function isTokenNative(
|
|
36
|
+
token: Token,
|
|
37
|
+
blockchain: BlockchainMeta | undefined
|
|
38
|
+
) {
|
|
39
|
+
if (!blockchain || !token) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
for (const feeAsset of blockchain.feeAssets) {
|
|
44
|
+
if (
|
|
45
|
+
token?.blockchain === feeAsset?.blockchain &&
|
|
46
|
+
token?.symbol === feeAsset?.symbol &&
|
|
47
|
+
token?.address === feeAsset?.address
|
|
48
|
+
) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return false;
|
|
54
|
+
}
|
package/src/utils/wallets.ts
CHANGED
|
@@ -381,25 +381,18 @@ export function formatBalance(balance: Balance | null): Balance | null {
|
|
|
381
381
|
return formattedBalance;
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
-
function
|
|
384
|
+
export function compareTokenBalance(
|
|
385
385
|
token1Balance: Balance | null,
|
|
386
386
|
token2Balance: Balance | null
|
|
387
387
|
): number {
|
|
388
|
-
if (token1Balance?.usdValue
|
|
388
|
+
if (token1Balance?.usdValue || token2Balance?.usdValue) {
|
|
389
389
|
return (
|
|
390
|
-
parseFloat(token2Balance
|
|
390
|
+
parseFloat(token2Balance?.usdValue || '0') -
|
|
391
|
+
parseFloat(token1Balance?.usdValue || '0')
|
|
391
392
|
);
|
|
392
393
|
}
|
|
393
394
|
|
|
394
|
-
if (
|
|
395
|
-
return 1;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
if (token1Balance?.usdValue && !token2Balance?.usdValue) {
|
|
399
|
-
return -1;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
if (!token1Balance?.usdValue && !token2Balance?.usdValue) {
|
|
395
|
+
if (token1Balance?.amount || token2Balance?.amount) {
|
|
403
396
|
return (
|
|
404
397
|
parseFloat(token2Balance?.amount || '0') -
|
|
405
398
|
parseFloat(token1Balance?.amount || '0')
|
|
@@ -409,41 +402,6 @@ function sortTokensByBalance(
|
|
|
409
402
|
return 0;
|
|
410
403
|
}
|
|
411
404
|
|
|
412
|
-
function sortTokensByPinnedToken(
|
|
413
|
-
token1: Token,
|
|
414
|
-
token2: Token,
|
|
415
|
-
isTokenPinned: (token: Token) => boolean
|
|
416
|
-
): number {
|
|
417
|
-
const isToken1Pinned = isTokenPinned(token1);
|
|
418
|
-
const isToken2Pinned = isTokenPinned(token2);
|
|
419
|
-
|
|
420
|
-
if (isToken1Pinned === isToken2Pinned) {
|
|
421
|
-
return 0;
|
|
422
|
-
}
|
|
423
|
-
if (isToken1Pinned) {
|
|
424
|
-
return -1;
|
|
425
|
-
}
|
|
426
|
-
return 1;
|
|
427
|
-
}
|
|
428
|
-
export function sortTokens(
|
|
429
|
-
tokens: Token[],
|
|
430
|
-
getBalanceFor: (token: Token) => Balance | null,
|
|
431
|
-
isTokenPinned: (token: Token) => boolean
|
|
432
|
-
) {
|
|
433
|
-
tokens.sort((token1, token2) => {
|
|
434
|
-
const token1Balance = getBalanceFor(token1);
|
|
435
|
-
const token2Balance = getBalanceFor(token2);
|
|
436
|
-
// Check pinned tokens
|
|
437
|
-
const isTokenPin = sortTokensByPinnedToken(token1, token2, isTokenPinned);
|
|
438
|
-
|
|
439
|
-
return isTokenPin !== 0
|
|
440
|
-
? isTokenPin
|
|
441
|
-
: sortTokensByBalance(token1Balance, token2Balance);
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
return tokens;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
405
|
export function areTokensEqual(
|
|
448
406
|
tokenA: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null,
|
|
449
407
|
tokenB: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null
|