@rango-dev/widget-embedded 0.36.1-next.7 → 0.37.0

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.
Files changed (123) hide show
  1. package/dist/QueueManager.d.ts.map +1 -1
  2. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  3. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  4. package/dist/components/Layout/Layout.d.ts.map +1 -1
  5. package/dist/components/Quote/Quote.d.ts.map +1 -1
  6. package/dist/components/Quote/Quote.styles.d.ts +1 -1
  7. package/dist/components/Quote/Quote.types.d.ts +0 -2
  8. package/dist/components/Quote/Quote.types.d.ts.map +1 -1
  9. package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
  10. package/dist/components/Quote/QuoteCostDetails.styles.d.ts.map +1 -1
  11. package/dist/components/RefreshModal/RefreshModal.styles.d.ts +1 -1
  12. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  13. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +1 -1
  14. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
  15. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  16. package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts +1 -2
  17. package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts.map +1 -1
  18. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +1 -1
  19. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
  20. package/dist/constants/quote.d.ts +0 -2
  21. package/dist/constants/quote.d.ts.map +1 -1
  22. package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts.map +1 -1
  23. package/dist/containers/Inputs/Inputs.d.ts.map +1 -1
  24. package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
  25. package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -1
  26. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +2 -2
  27. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -1
  28. package/dist/hooks/useFetchCustomToken.d.ts.map +1 -1
  29. package/dist/hooks/useObserveBalanceChanges/index.d.ts +2 -0
  30. package/dist/hooks/useObserveBalanceChanges/index.d.ts.map +1 -0
  31. package/dist/hooks/useObserveBalanceChanges/useObserveBalanceChanges.d.ts +4 -0
  32. package/dist/hooks/useObserveBalanceChanges/useObserveBalanceChanges.d.ts.map +1 -0
  33. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts +1 -2
  34. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
  35. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +1 -1
  36. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
  37. package/dist/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.d.ts.map +1 -1
  38. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  39. package/dist/hooks/useWalletList.d.ts.map +1 -1
  40. package/dist/hooks/useWalletProviders/useWalletProviders.d.ts +2 -1
  41. package/dist/hooks/useWalletProviders/useWalletProviders.d.ts.map +1 -1
  42. package/dist/index.d.ts +1 -1
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +2 -2
  45. package/dist/index.js.map +4 -4
  46. package/dist/pages/Home.d.ts.map +1 -1
  47. package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
  48. package/dist/store/app.d.ts +4 -2
  49. package/dist/store/app.d.ts.map +1 -1
  50. package/dist/store/slices/config.d.ts.map +1 -1
  51. package/dist/store/slices/data.d.ts.map +1 -1
  52. package/dist/store/wallets.d.ts +66 -0
  53. package/dist/store/wallets.d.ts.map +1 -0
  54. package/dist/types/config.d.ts +3 -6
  55. package/dist/types/config.d.ts.map +1 -1
  56. package/dist/types/wallets.d.ts +2 -3
  57. package/dist/types/wallets.d.ts.map +1 -1
  58. package/dist/utils/providers.d.ts +8 -3
  59. package/dist/utils/providers.d.ts.map +1 -1
  60. package/dist/utils/settings.d.ts +0 -1
  61. package/dist/utils/settings.d.ts.map +1 -1
  62. package/dist/utils/swap.d.ts +1 -1
  63. package/dist/utils/swap.d.ts.map +1 -1
  64. package/dist/utils/wallets.d.ts +14 -12
  65. package/dist/utils/wallets.d.ts.map +1 -1
  66. package/dist/widget-embedded.build.json +1 -1
  67. package/package.json +7 -7
  68. package/src/QueueManager.tsx +7 -12
  69. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +5 -3
  70. package/src/components/ConfirmWalletsModal/WalletList.tsx +7 -10
  71. package/src/components/Layout/Layout.tsx +3 -1
  72. package/src/components/Quote/Quote.tsx +3 -22
  73. package/src/components/Quote/Quote.types.ts +0 -2
  74. package/src/components/Quote/QuoteCostDetails.styles.ts +1 -0
  75. package/src/components/Quote/QuoteCostDetails.tsx +4 -23
  76. package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +1 -1
  77. package/src/components/SwapDetails/SwapDetails.tsx +1 -6
  78. package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +1 -1
  79. package/src/components/TokenList/TokenList.tsx +27 -4
  80. package/src/components/WalletStatefulConnect/DerivationPath.helpers.ts +1 -2
  81. package/src/components/WalletStatefulConnect/Namespaces.tsx +1 -1
  82. package/src/components/WalletStatefulConnect/Namespaces.types.tsx +1 -1
  83. package/src/constants/quote.ts +0 -2
  84. package/src/containers/ExpandedQuotes/ExpandedQuotes.styles.ts +0 -1
  85. package/src/containers/ExpandedQuotes/ExpandedQuotes.tsx +1 -1
  86. package/src/containers/Inputs/Inputs.tsx +7 -20
  87. package/src/containers/Wallets/Wallets.tsx +14 -20
  88. package/src/containers/WidgetInfo/WidgetInfo.tsx +8 -10
  89. package/src/containers/WidgetInfo/WidgetInfo.types.ts +2 -2
  90. package/src/hooks/useFetchCustomToken.ts +0 -5
  91. package/src/hooks/useObserveBalanceChanges/index.ts +1 -0
  92. package/src/hooks/useObserveBalanceChanges/useObserveBalanceChanges.ts +68 -0
  93. package/src/hooks/useStatefulConnect/useStatefulConnect.ts +7 -42
  94. package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +1 -1
  95. package/src/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.ts +6 -7
  96. package/src/hooks/useSwapInput.ts +2 -1
  97. package/src/hooks/useWalletList.ts +3 -1
  98. package/src/hooks/useWalletProviders/useWalletProviders.ts +7 -3
  99. package/src/index.ts +1 -1
  100. package/src/pages/Home.tsx +3 -5
  101. package/src/pages/SelectSwapItemsPage.tsx +2 -1
  102. package/src/store/app.ts +4 -4
  103. package/src/store/slices/config.ts +0 -3
  104. package/src/store/slices/data.ts +2 -3
  105. package/src/store/wallets.ts +268 -0
  106. package/src/types/config.ts +3 -7
  107. package/src/types/wallets.ts +2 -3
  108. package/src/utils/providers.ts +12 -68
  109. package/src/utils/settings.ts +0 -4
  110. package/src/utils/swap.ts +1 -1
  111. package/src/utils/wallets.ts +137 -74
  112. package/dist/store/slices/types.d.ts +0 -6
  113. package/dist/store/slices/types.d.ts.map +0 -1
  114. package/dist/store/slices/wallets.d.ts +0 -58
  115. package/dist/store/slices/wallets.d.ts.map +0 -1
  116. package/dist/store/utils/wallets.d.ts +0 -17
  117. package/dist/store/utils/wallets.d.ts.map +0 -1
  118. package/dist/utils/hub.d.ts +0 -4
  119. package/dist/utils/hub.d.ts.map +0 -1
  120. package/src/store/slices/types.ts +0 -9
  121. package/src/store/slices/wallets.ts +0 -477
  122. package/src/store/utils/wallets.ts +0 -108
  123. package/src/utils/hub.ts +0 -21
@@ -1,18 +1,26 @@
1
- import type { BalanceState, ConnectedWallet } from '../store/slices/wallets';
1
+ import type { FindToken } from '../store/slices/data';
2
+ import type { ConnectedWallet, TokenBalance } from '../store/wallets';
2
3
  import type {
3
4
  Balance,
4
5
  SelectedQuote,
6
+ TokensBalance,
5
7
  Wallet,
6
8
  WalletInfoWithExtra,
7
9
  } from '../types';
8
- import type { ExtendedWalletInfo } from '@rango-dev/wallets-react';
10
+ import type { WalletInfo as ModalWalletInfo } from '@rango-dev/ui';
9
11
  import type {
10
12
  Network,
13
+ WalletInfo,
11
14
  WalletState,
12
15
  WalletType,
13
16
  WalletTypes,
14
17
  } from '@rango-dev/wallets-shared';
15
- import type { BlockchainMeta, Token, TransactionType } from 'rango-sdk';
18
+ import type {
19
+ BlockchainMeta,
20
+ Token,
21
+ TransactionType,
22
+ WalletDetail,
23
+ } from 'rango-sdk';
16
24
 
17
25
  import {
18
26
  BlockchainCategories,
@@ -39,11 +47,9 @@ import {
39
47
  import { EXCLUDED_WALLETS } from '../constants/wallets';
40
48
 
41
49
  import { isBlockchainTypeInCategory, removeDuplicateFrom } from './common';
50
+ import { createTokenHash } from './meta';
42
51
  import { numberToString } from './numbers';
43
52
 
44
- export type ExtendedModalWalletInfo = WalletInfoWithExtra &
45
- Pick<ExtendedWalletInfo, 'properties' | 'isHub'>;
46
-
47
53
  export function mapStatusToWalletState(state: WalletState): WalletStatus {
48
54
  switch (true) {
49
55
  case state.connected:
@@ -59,10 +65,10 @@ export function mapStatusToWalletState(state: WalletState): WalletStatus {
59
65
 
60
66
  export function mapWalletTypesToWalletInfo(
61
67
  getState: (type: WalletType) => WalletState,
62
- getWalletInfo: (type: WalletType) => ExtendedWalletInfo,
68
+ getWalletInfo: (type: WalletType) => WalletInfo,
63
69
  list: WalletType[],
64
70
  chain?: string
65
- ): ExtendedModalWalletInfo[] {
71
+ ): WalletInfoWithExtra[] {
66
72
  return list
67
73
  .filter((wallet) => !EXCLUDED_WALLETS.includes(wallet as WalletTypes))
68
74
  .filter((wallet) => {
@@ -91,8 +97,6 @@ export function mapWalletTypesToWalletInfo(
91
97
  singleNamespace,
92
98
  supportedChains,
93
99
  needsDerivationPath,
94
- properties,
95
- isHub,
96
100
  } = getWalletInfo(type);
97
101
  const blockchainTypes = removeDuplicateFrom(
98
102
  supportedChains.map((item) => item.type)
@@ -110,8 +114,6 @@ export function mapWalletTypesToWalletInfo(
110
114
  singleNamespace,
111
115
  blockchainTypes,
112
116
  needsDerivationPath,
113
- properties,
114
- isHub,
115
117
  };
116
118
  });
117
119
  }
@@ -263,6 +265,8 @@ export function getQuoteWallets(params: {
263
265
  return Array.from(wallets);
264
266
  }
265
267
 
268
+ type Blockchain = { name: string; accounts: ConnectedWallet[] };
269
+
266
270
  export function isAccountAndWalletMatched(
267
271
  account: Wallet,
268
272
  connectedWallet: ConnectedWallet
@@ -274,18 +278,74 @@ export function isAccountAndWalletMatched(
274
278
  );
275
279
  }
276
280
 
281
+ export function makeBalanceFor(
282
+ retrievedBalance: WalletDetail,
283
+ findToken: FindToken
284
+ ): TokenBalance[] {
285
+ const { blockChain: chain, balances = [] } = retrievedBalance;
286
+ return (
287
+ balances?.map((tokenBalance) => ({
288
+ chain,
289
+ symbol: tokenBalance.asset.symbol,
290
+ ticker: tokenBalance.asset.symbol,
291
+ address: tokenBalance.asset.address || null,
292
+ rawAmount: tokenBalance.amount.amount,
293
+ decimal: tokenBalance.amount.decimals,
294
+ amount: new BigNumber(tokenBalance.amount.amount)
295
+ .shiftedBy(-tokenBalance.amount.decimals)
296
+ .toFixed(),
297
+ logo: '',
298
+ usdPrice: findToken(tokenBalance.asset)?.usdPrice || null,
299
+ })) || []
300
+ );
301
+ }
302
+
277
303
  export function resetConnectedWalletState(
278
304
  connectedWallet: ConnectedWallet
279
305
  ): ConnectedWallet {
280
306
  return { ...connectedWallet, loading: false, error: true };
281
307
  }
282
308
 
283
- export const calculateWalletUsdValue = (balances: BalanceState) => {
284
- const total = Object.values(balances).reduce((prev, balance) => {
285
- return balance.usdValue ? prev.plus(balance.usdValue) : prev;
286
- }, new BigNumber(ZERO));
309
+ export const calculateWalletUsdValue = (connectedWallet: ConnectedWallet[]) => {
310
+ const uniqueAccountAddresses = new Set<string | null>();
311
+ const uniqueBalance: ConnectedWallet[] = connectedWallet?.reduce(
312
+ (acc: ConnectedWallet[], current: ConnectedWallet) => {
313
+ return acc.findIndex(
314
+ (i) => i.address === current.address && i.chain === current.chain
315
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
316
+ ) === -1
317
+ ? [...acc, current]
318
+ : acc;
319
+ },
320
+ []
321
+ );
287
322
 
288
- return numberWithThousandSeparator(total.toString());
323
+ const modifiedWalletBlockchains = uniqueBalance?.map((chain) => {
324
+ const modifiedWalletBlockchain: Blockchain = {
325
+ name: chain.chain,
326
+ accounts: [],
327
+ };
328
+ if (!uniqueAccountAddresses.has(chain.address)) {
329
+ uniqueAccountAddresses.add(chain.address);
330
+ }
331
+ uniqueAccountAddresses.forEach((accountAddress) => {
332
+ if (chain.address === accountAddress) {
333
+ modifiedWalletBlockchain.accounts.push(chain);
334
+ }
335
+ });
336
+ return modifiedWalletBlockchain;
337
+ });
338
+ const total = numberToString(
339
+ modifiedWalletBlockchains
340
+ ?.flatMap((b) => b.accounts)
341
+ ?.flatMap((a) => a?.balances)
342
+ ?.map((b) =>
343
+ new BigNumber(b?.amount || ZERO).multipliedBy(b?.usdPrice || 0)
344
+ )
345
+ ?.reduce((a, b) => a.plus(b), ZERO) || ZERO
346
+ ).toString();
347
+
348
+ return numberWithThousandSeparator(total);
289
349
  };
290
350
 
291
351
  function numberWithThousandSeparator(number: string | number): string {
@@ -324,31 +384,19 @@ export const getKeplrCompatibleConnectedWallets = (
324
384
  };
325
385
 
326
386
  export function formatBalance(balance: Balance | null): Balance | null {
327
- if (!balance) {
328
- return null;
329
- }
330
-
331
- const amount = new BigNumber(balance.amount)
332
- .shiftedBy(-balance.decimals)
333
- .toFixed();
334
- const usdValue = balance.usdValue
335
- ? new BigNumber(balance.usdValue).shiftedBy(-balance.decimals).toFixed()
336
- : null;
337
- const formattedAmount = numberToString(
338
- amount,
339
- BALANCE_MIN_DECIMALS,
340
- BALANCE_MAX_DECIMALS
341
- );
342
- // null is using for detecing uknown prices
343
- const formattedUsdValue = usdValue
344
- ? numberToString(usdValue, USD_VALUE_MIN_DECIMALS, USD_VALUE_MAX_DECIMALS)
345
- : null;
346
-
347
387
  const formattedBalance: Balance | null = balance
348
388
  ? {
349
389
  ...balance,
350
- amount: formattedAmount,
351
- usdValue: formattedUsdValue,
390
+ amount: numberToString(
391
+ balance.amount,
392
+ BALANCE_MIN_DECIMALS,
393
+ BALANCE_MAX_DECIMALS
394
+ ),
395
+ usdValue: numberToString(
396
+ balance.usdValue,
397
+ USD_VALUE_MIN_DECIMALS,
398
+ USD_VALUE_MAX_DECIMALS
399
+ ),
352
400
  }
353
401
  : null;
354
402
 
@@ -360,39 +408,17 @@ export function compareTokenBalance(
360
408
  token2Balance: Balance | null
361
409
  ): number {
362
410
  if (token1Balance?.usdValue || token2Balance?.usdValue) {
363
- const token1UsdValue =
364
- !!token1Balance && !!token1Balance.usdValue
365
- ? new BigNumber(token1Balance.usdValue).shiftedBy(
366
- -token1Balance.decimals
367
- )
368
- : ZERO;
369
- const token2UsdValue =
370
- !!token2Balance && !!token2Balance.usdValue
371
- ? new BigNumber(token2Balance.usdValue).shiftedBy(
372
- -token2Balance.decimals
373
- )
374
- : ZERO;
375
-
376
- if (token1UsdValue.isEqualTo(token2UsdValue)) {
377
- return 0;
378
- }
379
- return token1UsdValue.isGreaterThan(token2UsdValue) ? -1 : 1;
411
+ return (
412
+ parseFloat(token2Balance?.usdValue || '0') -
413
+ parseFloat(token1Balance?.usdValue || '0')
414
+ );
380
415
  }
381
416
 
382
417
  if (token1Balance?.amount || token2Balance?.amount) {
383
- const token1Amount =
384
- !!token1Balance && !!token1Balance.amount
385
- ? new BigNumber(token1Balance.amount).shiftedBy(-token1Balance.decimals)
386
- : ZERO;
387
- const token2Amount =
388
- !!token2Balance && !!token2Balance.amount
389
- ? new BigNumber(token2Balance.amount).shiftedBy(-token2Balance.decimals)
390
- : ZERO;
391
-
392
- if (token1Amount.isEqualTo(token2Amount)) {
393
- return 0;
394
- }
395
- return token1Amount.isGreaterThan(token2Amount) ? -1 : 1;
418
+ return (
419
+ parseFloat(token2Balance?.amount || '0') -
420
+ parseFloat(token1Balance?.amount || '0')
421
+ );
396
422
  }
397
423
 
398
424
  return 0;
@@ -410,8 +436,8 @@ export function areTokensEqual(
410
436
  }
411
437
 
412
438
  export function sortWalletsBasedOnConnectionState(
413
- wallets: ExtendedModalWalletInfo[]
414
- ): ExtendedModalWalletInfo[] {
439
+ wallets: WalletInfoWithExtra[]
440
+ ): WalletInfoWithExtra[] {
415
441
  return wallets.sort(
416
442
  (a, b) =>
417
443
  Number(b.state === WalletStatus.CONNECTED) -
@@ -458,6 +484,43 @@ export function getAddress({
458
484
  )?.address;
459
485
  }
460
486
 
487
+ export function makeTokensBalance(connectedWallets: ConnectedWallet[]) {
488
+ return connectedWallets
489
+ .flatMap((wallet) => wallet.balances)
490
+ .reduce((balances: TokensBalance, balance) => {
491
+ const currentBalance = {
492
+ amount: balance?.amount ?? '',
493
+ decimals: balance?.decimal ?? 0,
494
+ usdValue: balance?.usdPrice
495
+ ? new BigNumber(balance?.usdPrice ?? ZERO)
496
+ .multipliedBy(balance?.amount)
497
+ .toString()
498
+ : '',
499
+ };
500
+
501
+ const tokenHash = balance
502
+ ? createTokenHash({
503
+ symbol: balance.symbol,
504
+ blockchain: balance.chain,
505
+ address: balance.address,
506
+ })
507
+ : null;
508
+
509
+ const prevBalance = tokenHash ? balances[tokenHash] : null;
510
+
511
+ const shouldUpdateBalance =
512
+ tokenHash &&
513
+ (!prevBalance ||
514
+ (prevBalance && prevBalance.amount < currentBalance.amount));
515
+
516
+ if (shouldUpdateBalance) {
517
+ balances[tokenHash] = currentBalance;
518
+ }
519
+
520
+ return balances;
521
+ }, {});
522
+ }
523
+
461
524
  export const isFetchingBalance = (
462
525
  connectedWallets: ConnectedWallet[],
463
526
  blockchain: string
@@ -466,12 +529,12 @@ export const isFetchingBalance = (
466
529
  (wallet) => wallet.chain === blockchain && wallet.loading
467
530
  );
468
531
 
469
- export function hashWalletsState(walletsInfo: WalletInfoWithExtra[]) {
532
+ export function hashWalletsState(walletsInfo: ModalWalletInfo[]) {
470
533
  return walletsInfo.map((w) => w.state).join('-');
471
534
  }
472
535
 
473
536
  export function filterBlockchainsByWalletTypes(
474
- wallets: WalletInfoWithExtra[],
537
+ wallets: ModalWalletInfo[],
475
538
  blockchains: BlockchainMeta[]
476
539
  ) {
477
540
  const uniqueBlockchainTypes = new Set<TransactionType>();
@@ -488,7 +551,7 @@ export function filterBlockchainsByWalletTypes(
488
551
  }
489
552
 
490
553
  export function filterWalletsByCategory(
491
- wallets: ExtendedModalWalletInfo[],
554
+ wallets: WalletInfoWithExtra[],
492
555
  category: string
493
556
  ) {
494
557
  if (category === BlockchainCategories.ALL) {
@@ -1,6 +0,0 @@
1
- import type { ConfigSlice } from './config';
2
- import type { DataSlice } from './data';
3
- import type { SettingsSlice } from './settings';
4
- import type { WalletsSlice } from './wallets';
5
- export type AppStoreState = DataSlice & ConfigSlice & SettingsSlice & WalletsSlice;
6
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/store/slices/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG,SAAS,GACnC,WAAW,GACX,aAAa,GACb,YAAY,CAAC"}
@@ -1,58 +0,0 @@
1
- import type { AppStoreState } from './types';
2
- import type { Token } from 'rango-sdk';
3
- import type { StateCreator } from 'zustand';
4
- import { type Balance, type Wallet } from '../../types';
5
- type WalletAddress = string;
6
- type TokenAddress = string;
7
- type TokenSymbol = string;
8
- type BlockchainId = string;
9
- /** format: `BlockchainId-TokenAddress-TokenSymbol` */
10
- export type AssetKey = `${BlockchainId}-${TokenAddress}-${TokenSymbol}`;
11
- /** format: `BlockchainId-TokenAddress-TokenSymbol-WalletAddress` */
12
- export type BalanceKey = `${BlockchainId}-${TokenAddress}-${TokenSymbol}-${WalletAddress}`;
13
- export type BalanceState = {
14
- [key: BalanceKey]: Balance;
15
- };
16
- export type AggregatedBalanceState = {
17
- [key: AssetKey]: BalanceKey[];
18
- };
19
- export interface ConnectedWallet extends Wallet {
20
- explorerUrl: string | null;
21
- selected: boolean;
22
- loading: boolean;
23
- error: boolean;
24
- }
25
- export interface WalletsSlice {
26
- _balances: BalanceState;
27
- _aggregatedBalances: AggregatedBalanceState;
28
- connectedWallets: ConnectedWallet[];
29
- fetchingWallets: boolean;
30
- setConnectedWalletAsRefetching: (walletType: string) => void;
31
- setConnectedWalletHasError: (walletType: string) => void;
32
- setConnectedWalletRetrievedData: (walletType: string) => void;
33
- removeBalancesForWallet: (walletType: string) => void;
34
- addConnectedWallet: (accounts: Wallet[]) => void;
35
- setWalletsAsSelected: (wallets: {
36
- walletType: string;
37
- chain: string;
38
- }[]) => void;
39
- /**
40
- * Add new accounts to store and fetch balances for them.
41
- */
42
- newWalletConnected: (accounts: Wallet[]) => Promise<void>;
43
- /**
44
- * Disconnect a wallet and clean up balances after that.
45
- */
46
- disconnectWallet: (walletType: string) => void;
47
- clearConnectedWallet: () => void;
48
- fetchBalances: (accounts: Wallet[], options?: {
49
- retryOnFailedBalances?: boolean;
50
- }) => Promise<void>;
51
- getBalanceFor: (token: Token) => Balance | null;
52
- getBalances: () => BalanceState;
53
- }
54
- export declare const createWalletsSlice: StateCreator<AppStoreState, [
55
- ], [
56
- ], WalletsSlice>;
57
- export {};
58
- //# sourceMappingURL=wallets.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../../src/store/slices/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAM5C,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,MAAM,EAGZ,MAAM,aAAa,CAAC;AAWrB,KAAK,aAAa,GAAG,MAAM,CAAC;AAC5B,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,WAAW,GAAG,MAAM,CAAC;AAC1B,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,sDAAsD;AACtD,MAAM,MAAM,QAAQ,GAAG,GAAG,YAAY,IAAI,YAAY,IAAI,WAAW,EAAE,CAAC;AACxE,oEAAoE;AACpE,MAAM,MAAM,UAAU,GACpB,GAAG,YAAY,IAAI,YAAY,IAAI,WAAW,IAAI,aAAa,EAAE,CAAC;AAEpE,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG;IACnC,CAAC,GAAG,EAAE,QAAQ,GAAG,UAAU,EAAE,CAAC;CAC/B,CAAC;AAEF,MAAM,WAAW,eAAgB,SAAQ,MAAM;IAC7C,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,YAAY,CAAC;IACxB,mBAAmB,EAAE,sBAAsB,CAAC;IAC5C,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,eAAe,EAAE,OAAO,CAAC;IAEzB,8BAA8B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7D,0BAA0B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,+BAA+B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9D,uBAAuB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACjD,oBAAoB,EAAE,CACpB,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,KAC7C,IAAI,CAAC;IACV;;OAEG;IACH,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D;;OAEG;IACH,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,aAAa,EAAE,CACb,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,CAAC,EAAE;QAAE,qBAAqB,CAAC,EAAE,OAAO,CAAA;KAAE,KAC1C,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,GAAG,IAAI,CAAC;IAChD,WAAW,EAAE,MAAM,YAAY,CAAC;CACjC;AAED,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAC3C,aAAa,EACb;CAAE,EACF;CAAE,EACF,YAAY,CAyYZ,CAAC"}
@@ -1,17 +0,0 @@
1
- import type { AppStoreState } from '../app';
2
- import type { AggregatedBalanceState, AssetKey, BalanceKey, BalanceState } from '../slices/wallets';
3
- import type { Asset, WalletDetail } from 'rango-types';
4
- /**
5
- * Note: We need to use `symbol` as well since native coins and cosmos blockchains don't have `address`
6
- * output format: BlockchainId-TokenAddress-TokenSymbol
7
- */
8
- export declare function createAssetKey(asset: Asset): AssetKey;
9
- /**
10
- * output format: BlockchainId-TokenAddress-TokenSymbol-WalletAddress
11
- */
12
- export declare function createBalanceKey(accountAddress: string, asset: Asset): BalanceKey;
13
- export declare function extractAssetFromBalanceKey(key: BalanceKey): Asset;
14
- export declare function createBalanceStateForNewAccount(account: WalletDetail, store: () => AppStoreState): BalanceState;
15
- export declare function updateAggregatedBalanceStateForNewAccount(aggregatedBalances: AggregatedBalanceState, balanceState: BalanceState): AggregatedBalanceState;
16
- export declare function removeBalanceFromAggregatedBalance(aggregatedBalances: AggregatedBalanceState, balanceKey: BalanceKey): AggregatedBalanceState;
17
- //# sourceMappingURL=wallets.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../../src/store/utils/wallets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EACV,sBAAsB,EACtB,QAAQ,EACR,UAAU,EACV,YAAY,EACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAMvD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,QAAQ,CAErD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,KAAK,GACX,UAAU,CAGZ;AAED,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,UAAU,GAAG,KAAK,CAOjE;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,MAAM,aAAa,GACzB,YAAY,CAuBd;AAED,wBAAgB,yCAAyC,CACvD,kBAAkB,EAAE,sBAAsB,EAC1C,YAAY,EAAE,YAAY,0BAmB3B;AAED,wBAAgB,kCAAkC,CAChD,kBAAkB,EAAE,sBAAsB,EAC1C,UAAU,EAAE,UAAU,0BAYvB"}
@@ -1,4 +0,0 @@
1
- import type { CommonNamespaceKeys } from '@rango-dev/wallets-core';
2
- import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
3
- export declare function convertCommonNamespacesKeysToLegacyNamespace(namespaces: CommonNamespaceKeys[]): Namespace[];
4
- //# sourceMappingURL=hub.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hub.d.ts","sourceRoot":"","sources":["../../src/utils/hub.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAE3E,wBAAgB,4CAA4C,CAC1D,UAAU,EAAE,mBAAmB,EAAE,GAChC,SAAS,EAAE,CAeb"}
@@ -1,9 +0,0 @@
1
- import type { ConfigSlice } from './config';
2
- import type { DataSlice } from './data';
3
- import type { SettingsSlice } from './settings';
4
- import type { WalletsSlice } from './wallets';
5
-
6
- export type AppStoreState = DataSlice &
7
- ConfigSlice &
8
- SettingsSlice &
9
- WalletsSlice;