@rango-dev/widget-embedded 0.17.1-next.3 → 0.17.1-next.5

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 (104) hide show
  1. package/dist/QueueManager.d.ts +2 -1
  2. package/dist/QueueManager.d.ts.map +1 -1
  3. package/dist/Wallets.d.ts +1 -0
  4. package/dist/Wallets.d.ts.map +1 -1
  5. package/dist/Widget.d.ts +1 -1
  6. package/dist/Widget.d.ts.map +1 -1
  7. package/dist/components/AppRouter.d.ts +0 -2
  8. package/dist/components/AppRouter.d.ts.map +1 -1
  9. package/dist/components/AppRoutes.d.ts +1 -6
  10. package/dist/components/AppRoutes.d.ts.map +1 -1
  11. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
  12. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  13. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +0 -2
  14. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
  15. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  16. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +1 -4
  17. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
  18. package/dist/components/NoResult/NoResult.d.ts.map +1 -1
  19. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  20. package/dist/components/Quote/Quote.d.ts.map +1 -1
  21. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  22. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  23. package/dist/components/UpdateUrl.d.ts +1 -6
  24. package/dist/components/UpdateUrl.d.ts.map +1 -1
  25. package/dist/components/WidgetEvents.d.ts.map +1 -1
  26. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  27. package/dist/hooks/useSyncStoresWithConfig.d.ts +1 -2
  28. package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
  29. package/dist/hooks/useWalletList.d.ts.map +1 -1
  30. package/dist/index.js +1 -1
  31. package/dist/index.js.map +4 -4
  32. package/dist/pages/ConfirmSwapPage.d.ts +1 -6
  33. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  34. package/dist/pages/LiquiditySourcePage.d.ts +1 -2
  35. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  36. package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
  37. package/dist/pages/SettingsPage.d.ts +1 -6
  38. package/dist/pages/SettingsPage.d.ts.map +1 -1
  39. package/dist/pages/WalletsPage.d.ts +1 -8
  40. package/dist/pages/WalletsPage.d.ts.map +1 -1
  41. package/dist/store/AppStore.d.ts +59 -0
  42. package/dist/store/AppStore.d.ts.map +1 -0
  43. package/dist/store/app.d.ts +12 -6
  44. package/dist/store/app.d.ts.map +1 -1
  45. package/dist/store/quote.d.ts +14 -7
  46. package/dist/store/quote.d.ts.map +1 -1
  47. package/dist/store/settings.d.ts +3 -2
  48. package/dist/store/settings.d.ts.map +1 -1
  49. package/dist/store/slices/config.d.ts +3 -2
  50. package/dist/store/slices/config.d.ts.map +1 -1
  51. package/dist/store/slices/data.d.ts +3 -0
  52. package/dist/store/slices/data.d.ts.map +1 -1
  53. package/dist/store/wallets.d.ts +5 -4
  54. package/dist/store/wallets.d.ts.map +1 -1
  55. package/dist/types/config.d.ts +5 -5
  56. package/dist/types/config.d.ts.map +1 -1
  57. package/dist/utils/settings.d.ts +3 -2
  58. package/dist/utils/settings.d.ts.map +1 -1
  59. package/dist/utils/swap.d.ts +4 -3
  60. package/dist/utils/swap.d.ts.map +1 -1
  61. package/package.json +3 -3
  62. package/src/QueueManager.tsx +14 -14
  63. package/src/Wallets.tsx +30 -5
  64. package/src/Widget.tsx +11 -25
  65. package/src/components/AppRouter.tsx +3 -5
  66. package/src/components/AppRoutes.tsx +6 -39
  67. package/src/components/BlockchainList/BlockchainList.tsx +4 -4
  68. package/src/components/BlockchainsSection/BlockchainsSection.tsx +4 -4
  69. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +5 -14
  70. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +0 -2
  71. package/src/components/ConfirmWalletsModal/WalletList.tsx +6 -5
  72. package/src/components/ConfirmWalletsModal/WalletList.type.ts +1 -4
  73. package/src/components/NoResult/NoResult.tsx +4 -1
  74. package/src/components/NotificationContent/NotificationContent.tsx +3 -2
  75. package/src/components/Quote/Quote.tsx +2 -4
  76. package/src/components/SwapDetails/SwapDetails.tsx +5 -6
  77. package/src/components/TokenList/TokenList.tsx +6 -7
  78. package/src/components/UpdateUrl.tsx +20 -14
  79. package/src/components/WidgetEvents.tsx +4 -2
  80. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +5 -5
  81. package/src/hooks/useSwapInput.ts +6 -4
  82. package/src/hooks/useSyncStoresWithConfig.ts +20 -17
  83. package/src/hooks/useWalletList.ts +3 -5
  84. package/src/pages/ConfirmSwapPage.tsx +1 -9
  85. package/src/pages/Home.tsx +7 -7
  86. package/src/pages/LiquiditySourcePage.tsx +22 -31
  87. package/src/pages/SelectBlockchainPage.tsx +4 -5
  88. package/src/pages/SelectSwapItemsPage.tsx +5 -5
  89. package/src/pages/SettingsPage.tsx +8 -12
  90. package/src/pages/SwapDetailsPage.tsx +3 -3
  91. package/src/pages/WalletsPage.tsx +4 -11
  92. package/src/store/AppStore.tsx +35 -0
  93. package/src/store/app.ts +20 -5
  94. package/src/store/quote.ts +26 -22
  95. package/src/store/settings.ts +7 -4
  96. package/src/store/slices/config.ts +25 -15
  97. package/src/store/slices/data.ts +64 -29
  98. package/src/store/wallets.ts +11 -8
  99. package/src/types/config.ts +5 -5
  100. package/src/utils/settings.ts +8 -7
  101. package/src/utils/swap.ts +14 -16
  102. package/dist/store/meta.d.ts +0 -23
  103. package/dist/store/meta.d.ts.map +0 -1
  104. package/src/store/meta.ts +0 -39
package/src/utils/swap.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-magic-numbers */
2
- import type { LoadingStatus } from '../store/meta';
2
+ import type { FetchStatus } from '../store/slices/data';
3
3
  import type { ConnectedWallet } from '../store/wallets';
4
4
  import type {
5
5
  ConvertedToken,
@@ -35,7 +35,6 @@ import {
35
35
  TOKEN_AMOUNT_MAX_DECIMALS,
36
36
  TOKEN_AMOUNT_MIN_DECIMALS,
37
37
  } from '../constants/routing';
38
- import { useMetaStore } from '../store/meta';
39
38
  import { ButtonState } from '../types';
40
39
 
41
40
  import { removeDuplicateFrom } from './common';
@@ -181,7 +180,7 @@ export function getLimitErrorMessage(quote: BestRouteResponse): {
181
180
  }
182
181
 
183
182
  export function getSwapButtonState(
184
- loadingMetaStatus: LoadingStatus,
183
+ loadingMetaStatus: FetchStatus,
185
184
  connectedWallets: ConnectedWallet[],
186
185
  loading: boolean,
187
186
  quote: BestRouteResponse | null,
@@ -441,6 +440,8 @@ export function createQuoteRequestBody(params: {
441
440
  inputAmount: string;
442
441
  wallets?: Wallet[];
443
442
  selectedWallets?: Wallet[];
443
+ liquiditySources?: string[];
444
+ excludeLiquiditySources?: boolean;
444
445
  disabledLiquiditySources: string[];
445
446
  slippage: number;
446
447
  affiliateRef: string | null;
@@ -456,6 +457,8 @@ export function createQuoteRequestBody(params: {
456
457
  wallets,
457
458
  selectedWallets,
458
459
  disabledLiquiditySources,
460
+ liquiditySources,
461
+ excludeLiquiditySources,
459
462
  slippage,
460
463
  affiliateRef,
461
464
  affiliatePercent,
@@ -531,13 +534,18 @@ export function createQuoteRequestBody(params: {
531
534
  selectedWallets: selectedWalletsMap ?? {},
532
535
  slippage: slippage.toString(),
533
536
  ...(destination && { destination: destination }),
534
- ...(disabledLiquiditySources.length > 0 && {
535
- swapperGroups: disabledLiquiditySources,
537
+ ...(excludeLiquiditySources && {
538
+ swapperGroups: disabledLiquiditySources.concat(liquiditySources ?? []),
536
539
  swappersGroupsExclude: true,
537
540
  }),
541
+ ...(!excludeLiquiditySources && {
542
+ swapperGroups: liquiditySources?.filter(
543
+ (liquiditySource) => !disabledLiquiditySources.includes(liquiditySource)
544
+ ),
545
+ swappersGroupsExclude: false,
546
+ }),
538
547
  ...(checkPrerequisites && { blockchains: filteredBlockchains }),
539
548
  };
540
-
541
549
  return requestBody;
542
550
  }
543
551
 
@@ -744,16 +752,6 @@ export function shouldRetrySwap(pendingSwap: PendingSwap) {
744
752
  new Date().getTime() - parseInt(pendingSwap.finishTime) < 4 * 3600 * 1000
745
753
  );
746
754
  }
747
- export function isValidCustomDestination(
748
- blockchain: string,
749
- address: string
750
- ): boolean {
751
- const blockchains = useMetaStore.getState().meta.blockchains;
752
- const regex =
753
- blockchains.find((chain) => chain.name === blockchain)?.addressPatterns ||
754
- [];
755
- return regex.filter((r) => new RegExp(r).test(address)).length > 0;
756
- }
757
755
 
758
756
  export function confirmSwapDisabled(
759
757
  fetching: boolean,
@@ -1,23 +0,0 @@
1
- import type { TokenWithBalance } from '../components/TokenList';
2
- import type { MetaResponse } from 'rango-sdk';
3
- export type LoadingStatus = 'loading' | 'success' | 'failed';
4
- export interface MetaState {
5
- meta: MetaResponse & {
6
- tokens: TokenWithBalance[];
7
- };
8
- loadingStatus: LoadingStatus;
9
- fetchMeta: () => Promise<void>;
10
- }
11
- export declare const useMetaStore: {
12
- (): MetaState;
13
- <U>(selector: (state: MetaState) => U, equals?: ((a: U, b: U) => boolean) | undefined): U;
14
- } & import("zustand").StoreApi<MetaState> & {
15
- use: {
16
- meta: () => MetaResponse & {
17
- tokens: TokenWithBalance[];
18
- };
19
- loadingStatus: () => LoadingStatus;
20
- fetchMeta: () => () => Promise<void>;
21
- };
22
- };
23
- //# sourceMappingURL=meta.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/store/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAO9C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE7D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,YAAY,GAAG;QAAE,MAAM,EAAE,gBAAgB,EAAE,CAAA;KAAE,CAAC;IACpD,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED,eAAO,MAAM,YAAY;;;;;;oBALQ,gBAAgB,EAAE;;;+BAEhC,QAAQ,IAAI,CAAC;;CAyB/B,CAAC"}
package/src/store/meta.ts DELETED
@@ -1,39 +0,0 @@
1
- import type { TokenWithBalance } from '../components/TokenList';
2
- import type { MetaResponse } from 'rango-sdk';
3
-
4
- import { create } from 'zustand';
5
-
6
- import { useAppStore } from './app';
7
- import createSelectors from './selectors';
8
-
9
- export type LoadingStatus = 'loading' | 'success' | 'failed';
10
-
11
- export interface MetaState {
12
- meta: MetaResponse & { tokens: TokenWithBalance[] };
13
- loadingStatus: LoadingStatus;
14
- fetchMeta: () => Promise<void>;
15
- }
16
-
17
- export const useMetaStore = createSelectors(
18
- create<MetaState>()((set) => ({
19
- meta: { blockchains: [], popularTokens: [], swappers: [], tokens: [] },
20
- loadingStatus: 'loading',
21
- fetchMeta: async () => {
22
- try {
23
- await useAppStore.getState().fetch();
24
-
25
- const state = useAppStore.getState();
26
- const response: MetaResponse = {
27
- blockchains: state.blockchains(),
28
- tokens: state.tokens(),
29
- popularTokens: state._popularTokens,
30
- swappers: state._swappers,
31
- };
32
-
33
- set({ meta: response, loadingStatus: 'success' });
34
- } catch (error) {
35
- set({ loadingStatus: 'failed' });
36
- }
37
- },
38
- }))
39
- );