@rango-dev/widget-embedded 0.29.1-next.1 → 0.29.1-next.10
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/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.d.ts +0 -2
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +4 -2
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +3 -1
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +2 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -1
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.helpers.d.ts +2 -2
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.helpers.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/notification.d.ts.map +1 -1
- package/dist/store/quote.d.ts +9 -3
- package/dist/store/quote.d.ts.map +1 -1
- package/dist/store/selectors.d.ts +1 -1
- package/dist/store/selectors.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +5 -3
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/slices/settings.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +5 -4
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/test-utils/fixtures.d.ts +1 -1
- package/dist/test-utils/fixtures.d.ts.map +1 -1
- package/dist/types/config.d.ts +3 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/common.d.ts +2 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +3 -1
- package/dist/utils/meta.d.ts.map +1 -1
- package/dist/utils/quote.d.ts +4 -8
- package/dist/utils/quote.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +3 -4
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +4 -5
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +7 -7
- package/src/components/NotificationContent/NotificationContent.tsx +13 -119
- package/src/components/Quote/Quote.tsx +3 -3
- package/src/components/Quotes/Quotes.tsx +2 -2
- package/src/components/SwapDetails/SwapDetails.tsx +8 -3
- package/src/components/WalletNamespacesModal/WalletNamespacesModal.tsx +2 -10
- package/src/containers/Wallets/Wallets.tsx +3 -3
- package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +12 -3
- package/src/containers/WidgetInfo/WidgetInfo.tsx +7 -2
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +3 -1
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +4 -2
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +3 -1
- package/src/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.ts +3 -3
- package/src/hooks/useSwapInput.ts +2 -2
- package/src/hooks/useSyncStoresWithConfig.ts +6 -7
- package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.helpers.ts +12 -26
- package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +19 -12
- package/src/hooks/useWalletList.ts +2 -4
- package/src/pages/WalletsPage.tsx +23 -16
- package/src/store/notification.ts +3 -1
- package/src/store/quote.ts +12 -7
- package/src/store/selectors.ts +6 -4
- package/src/store/slices/data.test.ts +9 -5
- package/src/store/slices/data.ts +26 -7
- package/src/store/slices/settings.ts +3 -0
- package/src/store/wallets.ts +9 -8
- package/src/test-utils/fixtures.ts +9 -2
- package/src/types/config.ts +5 -0
- package/src/utils/common.ts +12 -1
- package/src/utils/meta.ts +13 -6
- package/src/utils/quote.ts +12 -20
- package/src/utils/swap.ts +5 -25
- package/src/utils/wallets.ts +4 -28
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts +0 -1559
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +0 -1
- package/dist/components/NotificationContent/NotificationNotFound.d.ts +0 -3
- package/dist/components/NotificationContent/NotificationNotFound.d.ts.map +0 -1
- package/src/components/NotificationContent/NotificationContent.styles.ts +0 -63
- package/src/components/NotificationContent/NotificationNotFound.tsx +0 -17
package/src/utils/wallets.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
import type { FindToken } from '../store/slices/data';
|
|
1
2
|
import type { ConnectedWallet, TokenBalance } from '../store/wallets';
|
|
2
3
|
import type {
|
|
3
4
|
Balance,
|
|
4
5
|
SelectedQuote,
|
|
5
|
-
TokenHash,
|
|
6
6
|
TokensBalance,
|
|
7
7
|
Wallet,
|
|
8
8
|
WalletInfoWithNamespaces,
|
|
9
9
|
} from '../types';
|
|
10
10
|
import type { WalletInfo as ModalWalletInfo } from '@rango-dev/ui';
|
|
11
11
|
import type {
|
|
12
|
-
Asset,
|
|
13
12
|
Network,
|
|
14
13
|
WalletInfo,
|
|
15
14
|
WalletState,
|
|
@@ -48,6 +47,7 @@ import {
|
|
|
48
47
|
import { EXCLUDED_WALLETS } from '../constants/wallets';
|
|
49
48
|
|
|
50
49
|
import { isBlockchainTypeInCategory, removeDuplicateFrom } from './common';
|
|
50
|
+
import { createTokenHash } from './meta';
|
|
51
51
|
import { numberToString } from './numbers';
|
|
52
52
|
|
|
53
53
|
export function mapStatusToWalletState(state: WalletState): WalletStatus {
|
|
@@ -278,7 +278,7 @@ export function isAccountAndWalletMatched(
|
|
|
278
278
|
|
|
279
279
|
export function makeBalanceFor(
|
|
280
280
|
retrievedBalance: WalletDetail,
|
|
281
|
-
|
|
281
|
+
findToken: FindToken
|
|
282
282
|
): TokenBalance[] {
|
|
283
283
|
const { blockChain: chain, balances = [] } = retrievedBalance;
|
|
284
284
|
return (
|
|
@@ -293,13 +293,7 @@ export function makeBalanceFor(
|
|
|
293
293
|
.shiftedBy(-tokenBalance.amount.decimals)
|
|
294
294
|
.toFixed(),
|
|
295
295
|
logo: '',
|
|
296
|
-
usdPrice:
|
|
297
|
-
getUsdPrice(
|
|
298
|
-
chain,
|
|
299
|
-
tokenBalance.asset.symbol,
|
|
300
|
-
tokenBalance.asset.address,
|
|
301
|
-
tokens
|
|
302
|
-
) || null,
|
|
296
|
+
usdPrice: findToken(tokenBalance.asset)?.usdPrice || null,
|
|
303
297
|
})) || []
|
|
304
298
|
);
|
|
305
299
|
}
|
|
@@ -358,20 +352,6 @@ function numberWithThousandSeparator(number: string | number): string {
|
|
|
358
352
|
return parts.join('.');
|
|
359
353
|
}
|
|
360
354
|
|
|
361
|
-
export const getUsdPrice = (
|
|
362
|
-
blockchain: string,
|
|
363
|
-
symbol: string,
|
|
364
|
-
address: string | null,
|
|
365
|
-
allTokens: Token[]
|
|
366
|
-
): number | null => {
|
|
367
|
-
const token = allTokens?.find(
|
|
368
|
-
(t) =>
|
|
369
|
-
t.blockchain === blockchain &&
|
|
370
|
-
t.symbol?.toUpperCase() === symbol?.toUpperCase() &&
|
|
371
|
-
t.address === address
|
|
372
|
-
);
|
|
373
|
-
return token?.usdPrice || null;
|
|
374
|
-
};
|
|
375
355
|
export const isExperimentalChain = (
|
|
376
356
|
blockchains: BlockchainMeta[],
|
|
377
357
|
wallet: string
|
|
@@ -502,10 +482,6 @@ export function getAddress({
|
|
|
502
482
|
)?.address;
|
|
503
483
|
}
|
|
504
484
|
|
|
505
|
-
export function createTokenHash(token: Asset): TokenHash {
|
|
506
|
-
return `${token.blockchain}-${token.symbol}-${token.address ?? ''}`;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
485
|
export function makeTokensBalance(connectedWallets: ConnectedWallet[]) {
|
|
510
486
|
return connectedWallets
|
|
511
487
|
.flatMap((wallet) => wallet.balances)
|