@rango-dev/widget-embedded 0.30.1-next.2 → 0.30.1-next.4

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 (35) hide show
  1. package/dist/components/Quote/Quote.styles.d.ts +1 -1
  2. package/dist/components/RefreshModal/RefreshModal.styles.d.ts +1 -1
  3. package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
  4. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +2 -2
  5. package/dist/index.js +2 -2
  6. package/dist/index.js.map +4 -4
  7. package/dist/services/cacheService.d.ts +21 -0
  8. package/dist/services/cacheService.d.ts.map +1 -0
  9. package/dist/store/slices/config.d.ts +2 -1
  10. package/dist/store/slices/config.d.ts.map +1 -1
  11. package/dist/store/slices/data.d.ts +2 -1
  12. package/dist/store/slices/data.d.ts.map +1 -1
  13. package/dist/store/utils/data.d.ts +20 -0
  14. package/dist/store/utils/data.d.ts.map +1 -0
  15. package/dist/store/utils/data.test.d.ts +2 -0
  16. package/dist/store/utils/data.test.d.ts.map +1 -0
  17. package/dist/store/utils/index.d.ts +2 -0
  18. package/dist/store/utils/index.d.ts.map +1 -0
  19. package/dist/test-utils/fixtures.d.ts +1 -0
  20. package/dist/test-utils/fixtures.d.ts.map +1 -1
  21. package/dist/types/wallets.d.ts +1 -1
  22. package/dist/types/wallets.d.ts.map +1 -1
  23. package/dist/utils/settings.d.ts +1 -1
  24. package/dist/widget-embedded.build.json +1 -1
  25. package/package.json +2 -2
  26. package/src/containers/Wallets/Wallets.tsx +7 -2
  27. package/src/services/cacheService.ts +35 -0
  28. package/src/store/slices/config.ts +39 -1
  29. package/src/store/slices/data.test.ts +84 -0
  30. package/src/store/slices/data.ts +44 -24
  31. package/src/store/utils/data.test.ts +175 -0
  32. package/src/store/utils/data.ts +117 -0
  33. package/src/store/utils/index.ts +1 -0
  34. package/src/test-utils/fixtures.ts +14 -7
  35. package/src/types/wallets.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  import type { AppStoreState } from '../store/app';
2
- import type { TokenHash, WidgetConfig } from '../types';
2
+ import type { Blockchain, TokenHash, WidgetConfig } from '../types';
3
3
  import type { BlockchainMeta, EvmBlockchainMeta, Token } from 'rango-sdk';
4
4
 
5
5
  import { faker } from '@faker-js/faker';
@@ -231,13 +231,20 @@ export function createInitialAppStore() {
231
231
  blockchains: blockchains.map((b) => b.name),
232
232
  });
233
233
 
234
+ const tokensMapByTokenHash: Map<TokenHash, Token> = new Map();
235
+ const tokensMapByBlockchainName: Record<Blockchain, TokenHash[]> = {};
236
+ tokens.forEach((token) => {
237
+ const tokenHash = createTokenHash(token);
238
+ if (!tokensMapByBlockchainName[token.blockchain]) {
239
+ tokensMapByBlockchainName[token.blockchain] = [];
240
+ }
241
+ tokensMapByTokenHash.set(tokenHash, token);
242
+ tokensMapByBlockchainName[token.blockchain].push(tokenHash);
243
+ });
244
+
234
245
  return {
235
- _tokensMapByTokenHash: new Map<TokenHash, Token>(
236
- tokens.map((token) => {
237
- const tokenHash = createTokenHash(token);
238
- return [tokenHash, token];
239
- })
240
- ),
246
+ _tokensMapByTokenHash: tokensMapByTokenHash,
247
+ _tokensMapByBlockchainName: tokensMapByBlockchainName,
241
248
  _blockchainsMapByName: new Map<string, BlockchainMeta>(
242
249
  blockchains.map((meta) => [meta.name, meta])
243
250
  ),
@@ -13,7 +13,7 @@ export type Balance = {
13
13
  usdValue: string;
14
14
  };
15
15
 
16
- type Blockchain = string;
16
+ export type Blockchain = string;
17
17
  type TokenSymbol = string;
18
18
  type Address = string;
19
19