@rango-dev/widget-embedded 0.0.0-experimental-e5c14f42-20260614 → 0.0.0-experimental-e17e4765-20260615

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 (135) hide show
  1. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  2. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  3. package/dist/components/CustomDestination/CustomDestination.d.ts.map +1 -1
  4. package/dist/components/CustomTokenModal/CustomTokenModal.d.ts.map +1 -1
  5. package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
  6. package/dist/components/Slippage/Slippage.d.ts.map +1 -1
  7. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  8. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  9. package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts +1 -1
  10. package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts.map +1 -1
  11. package/dist/components/WalletStatefulConnect/Detached.types.d.ts +1 -1
  12. package/dist/components/WalletStatefulConnect/Detached.types.d.ts.map +1 -1
  13. package/dist/components/WalletStatefulConnect/NamespaceDetachedItem.d.ts.map +1 -1
  14. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +2 -2
  15. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
  16. package/dist/components/WalletStatefulConnect/index.d.ts +0 -1
  17. package/dist/components/WalletStatefulConnect/index.d.ts.map +1 -1
  18. package/dist/constants/wallets.d.ts +1 -2
  19. package/dist/constants/wallets.d.ts.map +1 -1
  20. package/dist/containers/Settings/Lists.d.ts.map +1 -1
  21. package/dist/containers/Wallets/useUpdates.d.ts.map +1 -1
  22. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.d.ts.map +1 -1
  23. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -1
  24. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts +1 -1
  25. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
  26. package/dist/hooks/useStatefulConnect/useStatefulConnect.state.d.ts +1 -1
  27. package/dist/hooks/useStatefulConnect/useStatefulConnect.state.d.ts.map +1 -1
  28. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +1 -1
  29. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
  30. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  31. package/dist/hooks/useSyncNotifications/useSyncNotifications.d.ts.map +1 -1
  32. package/dist/hooks/useWalletList.d.ts.map +1 -1
  33. package/dist/hooks/useWalletProviders/useWalletProviders.d.ts +1 -1
  34. package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts +1 -1
  35. package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts.map +1 -1
  36. package/dist/index.js +2 -2
  37. package/dist/index.js.map +4 -4
  38. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  39. package/dist/pages/Home.d.ts.map +1 -1
  40. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  41. package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
  42. package/dist/pages/SelectSwapItemPage/SelectSwapItemPage.helpers.d.ts +0 -1
  43. package/dist/pages/SelectSwapItemPage/SelectSwapItemPage.helpers.d.ts.map +1 -1
  44. package/dist/pages/SelectSwapItemPage/SelectSwapItemsPage.d.ts.map +1 -1
  45. package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
  46. package/dist/store/slices/config.d.ts +1 -1
  47. package/dist/store/slices/config.d.ts.map +1 -1
  48. package/dist/store/slices/wallets.d.ts +2 -4
  49. package/dist/store/slices/wallets.d.ts.map +1 -1
  50. package/dist/store/utils/wallets.d.ts +2 -2
  51. package/dist/store/utils/wallets.d.ts.map +1 -1
  52. package/dist/test-utils/fixtures.d.ts.map +1 -1
  53. package/dist/types/config.d.ts +1 -1
  54. package/dist/types/config.d.ts.map +1 -1
  55. package/dist/types/event.d.ts +6 -141
  56. package/dist/types/event.d.ts.map +1 -1
  57. package/dist/utils/common.d.ts.map +1 -1
  58. package/dist/utils/events.d.ts +5 -16
  59. package/dist/utils/events.d.ts.map +1 -1
  60. package/dist/utils/meta.d.ts +4 -0
  61. package/dist/utils/meta.d.ts.map +1 -1
  62. package/dist/utils/providers.d.ts +2 -1
  63. package/dist/utils/providers.d.ts.map +1 -1
  64. package/dist/utils/wallets.d.ts +0 -2
  65. package/dist/utils/wallets.d.ts.map +1 -1
  66. package/dist/widget-embedded.build.json +1 -1
  67. package/package.json +11 -8
  68. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +2 -53
  69. package/src/components/ConfirmWalletsModal/WalletList.tsx +16 -166
  70. package/src/components/CustomDestination/CustomDestination.tsx +0 -18
  71. package/src/components/CustomTokenModal/CustomTokenModal.tsx +7 -2
  72. package/src/components/Quote/QuoteCostDetails.tsx +0 -8
  73. package/src/components/Slippage/Slippage.tsx +0 -21
  74. package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +1 -1
  75. package/src/components/SwapDetails/SwapDetails.tsx +0 -6
  76. package/src/components/TokenList/TokenList.tsx +11 -8
  77. package/src/components/WalletStatefulConnect/DerivationPath.helpers.ts +1 -1
  78. package/src/components/WalletStatefulConnect/Detached.tsx +1 -1
  79. package/src/components/WalletStatefulConnect/Detached.types.ts +1 -1
  80. package/src/components/WalletStatefulConnect/NamespaceDetachedItem.tsx +7 -1
  81. package/src/components/WalletStatefulConnect/Namespaces.tsx +1 -1
  82. package/src/components/WalletStatefulConnect/Namespaces.types.tsx +2 -2
  83. package/src/components/WalletStatefulConnect/index.ts +0 -1
  84. package/src/constants/wallets.ts +1 -3
  85. package/src/containers/Settings/Lists.tsx +1 -13
  86. package/src/containers/Wallets/useUpdates.ts +1 -9
  87. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -1
  88. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +45 -3316
  89. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +26 -228
  90. package/src/hooks/useStatefulConnect/useStatefulConnect.state.ts +1 -1
  91. package/src/hooks/useStatefulConnect/useStatefulConnect.ts +1 -1
  92. package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +1 -1
  93. package/src/hooks/useSwapInput.ts +1 -46
  94. package/src/hooks/useSyncNotifications/useSyncNotifications.ts +1 -26
  95. package/src/hooks/useWalletList.ts +6 -63
  96. package/src/hooks/useWalletProviders/useWalletProviders.helpers.ts +1 -1
  97. package/src/pages/ConfirmSwapPage.tsx +1 -12
  98. package/src/pages/Home.tsx +4 -33
  99. package/src/pages/LiquiditySourcePage.tsx +0 -24
  100. package/src/pages/SelectBlockchainPage.tsx +0 -10
  101. package/src/pages/SelectSwapItemPage/SelectSwapItemPage.helpers.ts +0 -13
  102. package/src/pages/SelectSwapItemPage/SelectSwapItemsPage.tsx +0 -27
  103. package/src/pages/SwapDetailsPage.tsx +0 -6
  104. package/src/store/slices/config.ts +1 -1
  105. package/src/store/slices/wallets.ts +4 -12
  106. package/src/store/utils/wallets.ts +2 -2
  107. package/src/test-utils/fixtures.ts +0 -39
  108. package/src/types/config.ts +1 -1
  109. package/src/types/event.ts +10 -182
  110. package/src/utils/common.ts +0 -1
  111. package/src/utils/events.ts +6 -51
  112. package/src/utils/meta.ts +13 -0
  113. package/src/utils/providers.ts +2 -2
  114. package/src/utils/wallets.ts +0 -32
  115. package/dist/components/CustomTokenModal/CustomTokenModal.helpers.d.ts +0 -3
  116. package/dist/components/CustomTokenModal/CustomTokenModal.helpers.d.ts.map +0 -1
  117. package/dist/components/WalletStatefulConnect/ExperimentalChain.d.ts +0 -9
  118. package/dist/components/WalletStatefulConnect/ExperimentalChain.d.ts.map +0 -1
  119. package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.d.ts +0 -4
  120. package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.d.ts.map +0 -1
  121. package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.d.ts +0 -8
  122. package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.d.ts.map +0 -1
  123. package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.types.d.ts +0 -6
  124. package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.types.d.ts.map +0 -1
  125. package/dist/services/walletConnectionSource.d.ts +0 -10
  126. package/dist/services/walletConnectionSource.d.ts.map +0 -1
  127. package/dist/utils/eventPayloads.d.ts +0 -8
  128. package/dist/utils/eventPayloads.d.ts.map +0 -1
  129. package/src/components/CustomTokenModal/CustomTokenModal.helpers.ts +0 -19
  130. package/src/components/WalletStatefulConnect/ExperimentalChain.tsx +0 -39
  131. package/src/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.ts +0 -53
  132. package/src/components/WalletStatefulConnect/ExperimentalChainStatus.tsx +0 -36
  133. package/src/components/WalletStatefulConnect/ExperimentalChainStatus.types.ts +0 -5
  134. package/src/services/walletConnectionSource.ts +0 -41
  135. package/src/utils/eventPayloads.ts +0 -37
@@ -21,8 +21,6 @@ import {
21
21
  NotFoundContainer,
22
22
  } from '../components/SettingsContainer';
23
23
  import { useAppStore } from '../store/AppStore';
24
- import { UiEventTypes } from '../types';
25
- import { emitUiEvent } from '../utils/events';
26
24
  import { containsText } from '../utils/numbers';
27
25
  import { replaceSpacesWithDash } from '../utils/sanitizers';
28
26
  import { getUniqueSwappersGroups } from '../utils/settings';
@@ -59,18 +57,6 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
59
57
  liquiditySources.filter((sourceItem) => sourceItem.selected).length;
60
58
 
61
59
  const toggleAllSources = () => {
62
- emitUiEvent({
63
- type: UiEventTypes.SETTINGS_CHANGED,
64
- payload: {
65
- settingName: 'bridge_exclusion',
66
- previousValue: `${sourceType}:${
67
- hasSelectAll ? 'all_enabled' : 'some_disabled'
68
- }`,
69
- newValue: `${sourceType}:${
70
- hasSelectAll ? 'all_disabled' : 'all_enabled'
71
- }`,
72
- },
73
- });
74
60
  liquiditySources.forEach((sourceItem) => {
75
61
  if (hasSelectAll) {
76
62
  toggleLiquiditySource(sourceItem.groupTitle);
@@ -93,16 +79,6 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
93
79
  start: <Image src={logo} size={22} type="circular" />,
94
80
  onClick: () => {
95
81
  if (!campaignMode) {
96
- emitUiEvent({
97
- type: UiEventTypes.SETTINGS_CHANGED,
98
- payload: {
99
- settingName: 'bridge_exclusion',
100
- previousValue: `${groupTitle}:${
101
- selected ? 'enabled' : 'disabled'
102
- }`,
103
- newValue: `${groupTitle}:${selected ? 'disabled' : 'enabled'}`,
104
- },
105
- });
106
82
  toggleLiquiditySource(groupTitle);
107
83
  }
108
84
  },
@@ -16,9 +16,7 @@ import { useNavigateBack } from '../hooks/useNavigateBack';
16
16
  import { useSwapMode } from '../hooks/useSwapMode';
17
17
  import { useAppStore } from '../store/AppStore';
18
18
  import { useQuoteStore } from '../store/quote';
19
- import { UiEventTypes } from '../types';
20
19
  import { filterBlockchainsWithAtLeastOneToken } from '../utils/common';
21
- import { emitUiEvent } from '../utils/events';
22
20
 
23
21
  interface PropTypes {
24
22
  type: 'source' | 'destination' | 'custom-token';
@@ -53,14 +51,6 @@ export function SelectBlockchainPage(props: PropTypes) {
53
51
  if (type === 'custom-token') {
54
52
  navigate(`..?blockchain=${blockchain.name}`, { replace: true });
55
53
  } else {
56
- emitUiEvent({
57
- type: UiEventTypes.CHAIN_FILTER_APPLIED,
58
- payload: {
59
- side: type === 'source' ? 'from' : 'to',
60
- chain: blockchain.name,
61
- filterSource: 'expanded',
62
- },
63
- });
64
54
  if (type === 'source') {
65
55
  setFromBlockchain(blockchain);
66
56
  } else {
@@ -7,19 +7,6 @@ import {
7
7
  MIN_SEARCH_LENGTH,
8
8
  } from './SelectSwapItemPage.constants';
9
9
 
10
- export function getTokenSelectionMethod(
11
- searchedFor: string,
12
- isPopular: boolean | undefined
13
- ): 'search' | 'popular' | 'recent' {
14
- if (searchedFor.trim()) {
15
- return 'search';
16
- }
17
- if (isPopular) {
18
- return 'popular';
19
- }
20
- return 'recent';
21
- }
22
-
23
10
  export function shouldSearchForCustomTokens(
24
11
  metaSearchResultTokens: Token[],
25
12
  query: string,
@@ -14,11 +14,8 @@ import { useNavigateBack } from '../../hooks/useNavigateBack';
14
14
  import { useSearchCustomTokens } from '../../hooks/useSearchCustomTokens';
15
15
  import { useAppStore } from '../../store/AppStore';
16
16
  import { useQuoteStore } from '../../store/quote';
17
- import { UiEventTypes } from '../../types';
18
- import { emitUiEvent } from '../../utils/events';
19
17
 
20
18
  import {
21
- getTokenSelectionMethod,
22
19
  prepareTokensList,
23
20
  shouldSearchForCustomTokens,
24
21
  } from './SelectSwapItemPage.helpers';
@@ -114,14 +111,6 @@ export function SelectSwapItemsPage(props: PropTypes) {
114
111
  blockchain={type === 'source' ? fromBlockchain : toBlockchain}
115
112
  onMoreClick={() => navigate(navigationRoutes.blockchains)}
116
113
  onChange={(blockchain) => {
117
- emitUiEvent({
118
- type: UiEventTypes.CHAIN_FILTER_APPLIED,
119
- payload: {
120
- side: type === 'source' ? 'from' : 'to',
121
- chain: blockchain.name,
122
- filterSource: 'featured',
123
- },
124
- });
125
114
  updateBlockchain(blockchain);
126
115
  }}
127
116
  />
@@ -153,22 +142,6 @@ export function SelectSwapItemsPage(props: PropTypes) {
153
142
  searchedFor={searchedFor}
154
143
  type={type}
155
144
  onChange={(token) => {
156
- emitUiEvent({
157
- type: UiEventTypes.TOKEN_SELECTED,
158
- payload: {
159
- side: type === 'source' ? 'from' : 'to',
160
- tokenName: token.name,
161
- tokenSymbol: token.symbol,
162
- tokenAddress: token.address,
163
- chain: token.blockchain,
164
- selectionMethod: getTokenSelectionMethod(
165
- searchedFor,
166
- token.isPopular
167
- ),
168
- activeChainFilter: selectedBlockchainName || 'all',
169
- },
170
- });
171
-
172
145
  updateToken(token);
173
146
 
174
147
  const tokenBlockchain = blockchains.find(
@@ -9,8 +9,6 @@ import { SwapDetails } from '../components/SwapDetails';
9
9
  import { SwapDetailsPlaceholder } from '../components/SwapDetails/SwapDetails.Placeholder';
10
10
  import { useNavigateBack } from '../hooks/useNavigateBack';
11
11
  import { useAppStore } from '../store/AppStore';
12
- import { UiEventTypes } from '../types';
13
- import { emitUiEvent } from '../utils/events';
14
12
  import { getPendingSwaps } from '../utils/queue';
15
13
 
16
14
  export function SwapDetailsPage() {
@@ -43,10 +41,6 @@ export function SwapDetailsPage() {
43
41
  if (selectedSwap?.id) {
44
42
  const swap = manager?.get(selectedSwap.id);
45
43
  if (swap) {
46
- emitUiEvent({
47
- type: UiEventTypes.SWAP_CANCELLED,
48
- payload: { routeId: requestId },
49
- });
50
44
  cancelSwap(swap);
51
45
  }
52
46
  }
@@ -2,9 +2,9 @@ import type { DataSlice } from './data';
2
2
  import type { SettingsSlice } from './settings';
3
3
  import type { WidgetConfig } from '../../types';
4
4
  import type { StateCreatorWithInitialData } from '../app';
5
+ import type { VersionedProviders } from '@hub3js/core/utils';
5
6
 
6
7
  import { allProviders as getAllProviders } from '@rango-dev/provider-all';
7
- import { type VersionedProviders } from '@rango-dev/wallets-core';
8
8
 
9
9
  import { cacheService } from '../../services/cacheService';
10
10
  import {
@@ -1,5 +1,5 @@
1
1
  import type { AppStoreState } from './types';
2
- import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
2
+ import type { Namespace } from '@hub3js/namespaces';
3
3
  import type { Asset, Token, WalletDetail } from 'rango-sdk';
4
4
 
5
5
  import BigNumber from 'bignumber.js';
@@ -8,7 +8,6 @@ import { ZERO } from '../../constants/numbers';
8
8
  import { BALANCE_SEPARATOR } from '../../constants/wallets';
9
9
  import { eventEmitter } from '../../services/eventEmitter';
10
10
  import { httpService } from '../../services/httpService';
11
- import { getWalletConnectionSource } from '../../services/walletConnectionSource';
12
11
  import {
13
12
  type Balance,
14
13
  type Wallet,
@@ -115,8 +114,7 @@ export interface WalletsSlice {
115
114
  newWalletConnected: (
116
115
  accounts: Wallet[],
117
116
  namespace?: Namespace,
118
- derivationPath?: string,
119
- meta?: { walletName?: string }
117
+ derivationPath?: string
120
118
  ) => Promise<void>;
121
119
  disconnectNamespaces: (walletType: string, namespaces: Namespace[]) => void;
122
120
  /**
@@ -445,20 +443,14 @@ export const createWalletsSlice = keepLastUpdated<AppStoreState, WalletsSlice>(
445
443
  connectedWallets: nextConnectedWalletsWithUpdatedSelectedStatus,
446
444
  });
447
445
  },
448
- newWalletConnected: async (accounts, namespace, derivationPath, meta) => {
446
+ newWalletConnected: async (accounts, namespace, derivationPath) => {
449
447
  const newAccount = accounts[0];
450
448
  if (!newAccount) {
451
449
  return;
452
450
  }
453
451
  eventEmitter.emit(WidgetEvents.WalletEvent, {
454
452
  type: WalletEventTypes.CONNECT,
455
- payload: {
456
- walletType: newAccount.walletType,
457
- accounts,
458
- chain: newAccount.chain ?? null,
459
- walletName: meta?.walletName ?? newAccount.walletType,
460
- source: getWalletConnectionSource(newAccount.walletType),
461
- },
453
+ payload: { walletType: newAccount.walletType, accounts },
462
454
  });
463
455
 
464
456
  get().addConnectedWallet(accounts, namespace, derivationPath);
@@ -8,7 +8,7 @@ import type {
8
8
  BalanceState,
9
9
  ConnectedWallet,
10
10
  } from '../slices/wallets';
11
- import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
11
+ import type { Namespace } from '@hub3js/namespaces';
12
12
  import type { Asset, WalletDetail } from 'rango-types';
13
13
 
14
14
  import BigNumber from 'bignumber.js';
@@ -17,7 +17,7 @@ import { ZERO } from '../../constants/numbers';
17
17
  import { BALANCE_SEPARATOR } from '../../constants/wallets';
18
18
 
19
19
  /**
20
- * Note: We need to use `symbol` as well since native coins and cosmos blockchains don't have `address`
20
+ * Note: We need to use `symbol` as well since native coins don't have `address`
21
21
  * output format: BlockchainId${BALANCE_SEPARATOR}TokenAddress${BALANCE_SEPARATOR}TokenSymbol
22
22
  */
23
23
  export function createAssetKey(asset: Asset): AssetKey {
@@ -25,12 +25,7 @@ const listBlockchains = [
25
25
  'TRON',
26
26
  'BTC',
27
27
  'SCROLL',
28
- 'COSMOS',
29
- 'OSMOSIS',
30
28
  'METIS',
31
- 'NEUTRON',
32
- 'NOBLE',
33
- 'DYDX',
34
29
  'SOLANA',
35
30
  'CRONOS',
36
31
  'BNB',
@@ -47,43 +42,12 @@ const listBlockchains = [
47
42
  'LTC',
48
43
  'BCH',
49
44
  'HARMONY',
50
- 'EVMOS',
51
45
  'HECO',
52
- 'SIF',
53
46
  'BRISE',
54
- 'STARGAZE',
55
47
  'FUSE',
56
- 'CRYPTO_ORG',
57
- 'CHIHUAHUA',
58
- 'BANDCHAIN',
59
- 'COMDEX',
60
- 'REGEN',
61
- 'IRIS',
62
- 'EMONEY',
63
48
  'GNOSIS',
64
- 'JUNO',
65
- 'AXELAR',
66
- 'STRIDE',
67
49
  'KCC',
68
- 'MARS',
69
- 'TERRA',
70
50
  'TELOS',
71
- 'BITSONG',
72
- 'AKASH',
73
- 'KI',
74
- 'PERSISTENCE',
75
- 'MEDIBLOC',
76
- 'KUJIRA',
77
- 'SENTINEL',
78
- 'INJECTIVE',
79
- 'SECRET',
80
- 'KONSTELLATION',
81
- 'STARNAME',
82
- 'BITCANNA',
83
- 'UMEE',
84
- 'DESMOS',
85
- 'LUMNETWORK',
86
- 'TERRA_CLASSIC',
87
51
  'DASH',
88
52
  'DOGE',
89
53
  ];
@@ -105,13 +69,10 @@ const listTokens = [
105
69
  'FIL',
106
70
  'ETC',
107
71
  'DAI',
108
- 'ATOM',
109
72
  'IMX',
110
73
  'OP',
111
74
  'HBAR',
112
- 'INJ',
113
75
  'XLM',
114
- 'CRO',
115
76
  'RNDR',
116
77
  'GRT',
117
78
  'OKB',
@@ -1,5 +1,5 @@
1
+ import type { Provider } from '@hub3js/core';
1
2
  import type { Language, theme } from '@rango-dev/ui';
2
- import type { Provider } from '@rango-dev/wallets-core';
3
3
  import type { LegacyProviderInterface } from '@rango-dev/wallets-core/legacy';
4
4
  import type { WalletType } from '@rango-dev/wallets-shared';
5
5
  import type { Asset } from 'rango-sdk';
@@ -5,6 +5,8 @@ import type {
5
5
  StepEventData,
6
6
  } from '@rango-dev/queue-manager-rango-preset';
7
7
 
8
+ import { WidgetEvents as QueueManagerEvents } from '@rango-dev/queue-manager-rango-preset';
9
+
8
10
  type EventData<
9
11
  T extends QuoteEventTypes | WalletEventTypes | UiEventTypes,
10
12
  U extends Record<string, unknown> | null
@@ -21,48 +23,19 @@ type Account = Wallet;
21
23
  export enum QuoteEventTypes {
22
24
  QUOTE_INPUT_UPDATE = 'quoteInputUpdate',
23
25
  QUOTE_OUTPUT_UPDATE = 'quoteOutputUpdate',
24
- /** A route/quote request was made with a valid source, destination and amount. */
25
- ROUTE_REQUESTED = 'routeRequested',
26
- /** The route API returned zero results for the requested pair. */
27
- ROUTE_NOT_FOUND = 'routeNotFound',
28
- /** The route API returned a 4xx/5xx error. */
29
- ROUTE_FETCH_FAILED = 'routeFetchFailed',
30
- /** The user overrode the auto-selected route. */
31
- ROUTE_CHANGED = 'routeChanged',
32
26
  }
33
27
 
34
28
  export enum WalletEventTypes {
35
29
  CONNECT = 'connect',
36
30
  DISCONNECT = 'disconnect',
37
- /** The user opened the wallet connection modal/flow. */
38
- CONNECT_INITIATED = 'connectInitiated',
39
- /** A wallet provider was detected on app load (one per detected wallet). */
40
- DETECTED = 'detected',
41
31
  }
42
32
 
43
- /** Where in the UI a wallet connection was triggered. */
44
- export type WalletConnectionSource = 'nav' | 'swap_button' | 'confirm_modal';
45
-
46
33
  /**
47
34
  * We use a prefix for interaction type and a name for defining the event name: INTERACTION_EVENT_NAME
48
35
  * e.g. CLICK_X_BUTTON or NAVIGATE_WALLET_PAGE
49
36
  */
50
37
  export enum UiEventTypes {
51
38
  CLICK_CONNECT_WALLET = 'clickConnectWallet',
52
- TOKEN_SELECTED = 'tokenSelected',
53
- CHAIN_FILTER_APPLIED = 'chainFilterApplied',
54
- SETTINGS_CHANGED = 'settingsChanged',
55
- ROUTE_FEE_VIEWED = 'routeFeeViewed',
56
- DESTINATION_ADDRESS_SET = 'destinationAddressSet',
57
- GAS_WARNING_SHOWN = 'gasWarningShown',
58
- GAS_WARNING_BYPASSED = 'gasWarningBypassed',
59
- SWAP_INITIATED = 'swapInitiated',
60
- SWAP_WALLETS_MODAL_SHOWN = 'swapWalletsModalShown',
61
- SWAP_WALLETS_CONFIRMED = 'swapWalletsConfirmed',
62
- SWAP_STARTED = 'swapStarted',
63
- SWAP_RESUMED = 'swapResumed',
64
- SWAP_RETRIED = 'swapRetried',
65
- SWAP_CANCELLED = 'swapCancelled',
66
39
  }
67
40
 
68
41
  export type QuoteInputUpdateEventPayload = {
@@ -81,175 +54,30 @@ export type QuoteUpdateEventPayload = Pick<
81
54
  export type ConnectWalletEventPayload = {
82
55
  walletType: string;
83
56
  accounts: Account[];
84
- /** Blockchain of the first connected account. */
85
- chain: string | null;
86
- /** wallet type (e.g. "metamask"). */
87
- walletName: string;
88
- /** Where in the UI the connection was triggered, when known. */
89
- source: WalletConnectionSource | null;
90
57
  };
91
58
 
92
59
  export type DisconnectWalletEventPayload = {
93
60
  walletType: string;
94
61
  };
95
62
 
96
- export type ConnectInitiatedWalletEventPayload = {
97
- /** Where in the UI the connection flow was opened, when known. */
98
- source: WalletConnectionSource | null;
99
- };
100
-
101
- export type WalletDetectedEventPayload = {
102
- walletType: string;
103
- walletName: string;
104
- };
105
-
106
63
  export type ClickConnectWalletPayload = PreventableEventPayload;
107
64
 
108
- /** Shared shape describing a route/quote, used by several swap events. */
109
- export type SwapEstimateEventPayload = {
110
- sourceChain: string;
111
- destinationChain: string;
112
- sourceToken: string;
113
- destinationToken: string;
114
- inputAmountUsd: number | null;
115
- outputAmountUsd: number | null;
116
- sourceTokenAmount: number | null;
117
- destinationTokenAmount: number | null;
118
- routeId: string;
119
- };
120
-
121
- export type RouteRequestedEventPayload = SwapEstimateEventPayload & {
122
- routeCount: number;
123
- };
124
-
125
- export type RouteNotFoundEventPayload = {
126
- sourceChain: string;
127
- destinationChain: string;
128
- sourceToken: string;
129
- destinationToken: string;
130
- inputAmountUsd: number | null;
131
- };
132
-
133
- export type RouteFetchFailedEventPayload = {
134
- sourceChain: string;
135
- destinationChain: string;
136
- /** HTTP status code returned by the route API, as a string. */
137
- errorCode: string;
138
- };
139
-
140
- export type RouteChangedEventPayload = {
141
- sourceChain: string;
142
- destinationChain: string;
143
- fromRouteId: string;
144
- toRouteId: string;
145
- };
146
-
147
- export type TokenSelectedEventPayload = {
148
- side: 'from' | 'to';
149
- tokenName: string | null;
150
- tokenSymbol: string;
151
- tokenAddress: string | null;
152
- chain: string;
153
- selectionMethod: 'search' | 'popular' | 'recent';
154
- /** `all` when no chain filter is active, otherwise the filtered chain name. */
155
- activeChainFilter: string;
156
- };
157
-
158
- export type ChainFilterAppliedEventPayload = {
159
- side: 'from' | 'to';
160
- chain: string;
161
- filterSource: 'featured' | 'expanded';
162
- };
163
-
164
- export type SettingsChangedEventPayload = {
165
- settingName: 'slippage' | 'bridge_exclusion' | 'infinite_approval';
166
- previousValue: string;
167
- newValue: string;
168
- };
169
-
170
- export type RouteFeeViewedEventPayload = { routeId: string };
171
-
172
- export type DestinationAddressSetEventPayload = { destinationChain: string };
173
-
174
- export type GasWarningEventPayload = { routeId: string };
175
-
176
- export type SwapInitiatedEventPayload = SwapEstimateEventPayload & {
177
- walletConnected: boolean;
178
- };
179
-
180
- export type SwapStartedEventPayload = SwapEstimateEventPayload & {
181
- stepCount: number;
182
- };
183
-
184
- export type SwapWalletsModalShownEventPayload = {
185
- chainsRequired: number;
186
- chainsPending: number;
187
- };
188
-
189
- export type SwapWalletsConfirmedEventPayload = { routeId: string };
190
-
191
- export type SwapResumedEventPayload = {
192
- routeId: string;
193
- stepCount: number;
194
- stepNumber: number;
195
- };
196
-
197
- export type SwapRetriedEventPayload = { routeId: string };
198
-
199
- export type SwapCancelledEventPayload = { routeId: string };
200
-
201
65
  export type QuoteEventData =
202
66
  | EventData<QuoteEventTypes.QUOTE_INPUT_UPDATE, QuoteInputUpdateEventPayload>
203
- | EventData<QuoteEventTypes.QUOTE_OUTPUT_UPDATE, QuoteUpdateEventPayload>
204
- | EventData<QuoteEventTypes.ROUTE_REQUESTED, RouteRequestedEventPayload>
205
- | EventData<QuoteEventTypes.ROUTE_NOT_FOUND, RouteNotFoundEventPayload>
206
- | EventData<QuoteEventTypes.ROUTE_FETCH_FAILED, RouteFetchFailedEventPayload>
207
- | EventData<QuoteEventTypes.ROUTE_CHANGED, RouteChangedEventPayload>;
67
+ | EventData<QuoteEventTypes.QUOTE_OUTPUT_UPDATE, QuoteUpdateEventPayload>;
208
68
 
209
69
  export type WalletEventData =
210
70
  | EventData<WalletEventTypes.CONNECT, ConnectWalletEventPayload>
211
- | EventData<WalletEventTypes.DISCONNECT, DisconnectWalletEventPayload>
212
- | EventData<
213
- WalletEventTypes.CONNECT_INITIATED,
214
- ConnectInitiatedWalletEventPayload
215
- >
216
- | EventData<WalletEventTypes.DETECTED, WalletDetectedEventPayload>;
71
+ | EventData<WalletEventTypes.DISCONNECT, DisconnectWalletEventPayload>;
217
72
 
218
- export type UiEventData =
219
- | EventData<UiEventTypes.CLICK_CONNECT_WALLET, ClickConnectWalletPayload>
220
- | EventData<UiEventTypes.TOKEN_SELECTED, TokenSelectedEventPayload>
221
- | EventData<UiEventTypes.CHAIN_FILTER_APPLIED, ChainFilterAppliedEventPayload>
222
- | EventData<UiEventTypes.SETTINGS_CHANGED, SettingsChangedEventPayload>
223
- | EventData<UiEventTypes.ROUTE_FEE_VIEWED, RouteFeeViewedEventPayload>
224
- | EventData<
225
- UiEventTypes.DESTINATION_ADDRESS_SET,
226
- DestinationAddressSetEventPayload
227
- >
228
- | EventData<UiEventTypes.GAS_WARNING_SHOWN, GasWarningEventPayload>
229
- | EventData<UiEventTypes.GAS_WARNING_BYPASSED, GasWarningEventPayload>
230
- | EventData<UiEventTypes.SWAP_INITIATED, SwapInitiatedEventPayload>
231
- | EventData<
232
- UiEventTypes.SWAP_WALLETS_MODAL_SHOWN,
233
- SwapWalletsModalShownEventPayload
234
- >
235
- | EventData<
236
- UiEventTypes.SWAP_WALLETS_CONFIRMED,
237
- SwapWalletsConfirmedEventPayload
238
- >
239
- | EventData<UiEventTypes.SWAP_STARTED, SwapStartedEventPayload>
240
- | EventData<UiEventTypes.SWAP_RESUMED, SwapResumedEventPayload>
241
- | EventData<UiEventTypes.SWAP_RETRIED, SwapRetriedEventPayload>
242
- | EventData<UiEventTypes.SWAP_CANCELLED, SwapCancelledEventPayload>;
73
+ export type UiEventData = EventData<
74
+ UiEventTypes.CLICK_CONNECT_WALLET,
75
+ ClickConnectWalletPayload
76
+ >;
243
77
 
244
- /**
245
- * RouteEvent/StepEvent must match the queue-manager's `WidgetEvents` string
246
- * values (`QueueManagerEvents`) so events route correctly. They're inlined as
247
- * literals rather than referencing the other enum to keep this a pure string
248
- * enum (a cross-enum reference makes `no-mixed-enums` read them as numeric).
249
- */
250
78
  export enum WidgetEvents {
251
- RouteEvent = 'routeEvent',
252
- StepEvent = 'stepEvent',
79
+ RouteEvent = QueueManagerEvents.RouteEvent,
80
+ StepEvent = QueueManagerEvents.StepEvent,
253
81
  QuoteEvent = 'quoteEvent',
254
82
  WalletEvent = 'walletEvent',
255
83
  UiEvent = 'uiEvent',
@@ -237,7 +237,6 @@ export const isBlockchainTypeInCategory = (
237
237
  case BlockchainCategories.OTHER:
238
238
  return (
239
239
  blockchainType !== TransactionType.TRANSFER &&
240
- blockchainType !== TransactionType.COSMOS &&
241
240
  blockchainType !== TransactionType.EVM
242
241
  );
243
242
  default:
@@ -1,32 +1,19 @@
1
1
  import { eventEmitter } from '../services/eventEmitter';
2
- import { setPendingWalletConnectionSource } from '../services/walletConnectionSource';
3
- import {
4
- type ClickConnectWalletPayload,
5
- type QuoteEventData,
6
- type UiEventData,
7
- type UiEventTypes,
8
- type WalletConnectionSource,
9
- type WalletDetectedEventPayload,
10
- WalletEventTypes,
11
- WidgetEvents,
12
- } from '../types';
2
+ import { type UiEventData, WidgetEvents } from '../types';
13
3
 
14
- type PreventableUiEvent = {
15
- type: UiEventTypes.CLICK_CONNECT_WALLET;
16
- payload?: Omit<ClickConnectWalletPayload, 'preventDefault'>;
4
+ type UiEvent = {
5
+ type: UiEventData['type'];
6
+ payload?: Omit<UiEventData['payload'], 'preventDefault'>;
17
7
  };
18
8
 
19
- export function emitPreventableEvent(
20
- event: PreventableUiEvent,
21
- action: () => void
22
- ): void {
9
+ export function emitPreventableEvent(event: UiEvent, action: () => void): void {
23
10
  let defaultPrevented = false;
24
11
 
25
12
  const extendedPayload = {
26
- ...event.payload,
27
13
  preventDefault() {
28
14
  defaultPrevented = true;
29
15
  },
16
+ ...(event.payload === undefined && { payload: event.payload }),
30
17
  };
31
18
 
32
19
  eventEmitter.emit(WidgetEvents.UiEvent, {
@@ -38,35 +25,3 @@ export function emitPreventableEvent(
38
25
  action();
39
26
  }
40
27
  }
41
-
42
- export function emitUiEvent(
43
- event: Exclude<UiEventData, { type: UiEventTypes.CLICK_CONNECT_WALLET }>
44
- ): void {
45
- eventEmitter.emit(WidgetEvents.UiEvent, event);
46
- }
47
-
48
- /**
49
- * Records the source of the wallet connection the user is about to start and
50
- * emits a `connectInitiated` wallet event. The recorded source is later read
51
- * when the wallet finishes connecting to enrich the `connect` event.
52
- */
53
- export function emitWalletConnectInitiated(
54
- source: WalletConnectionSource | null
55
- ): void {
56
- setPendingWalletConnectionSource(source);
57
- eventEmitter.emit(WidgetEvents.WalletEvent, {
58
- type: WalletEventTypes.CONNECT_INITIATED,
59
- payload: { source },
60
- });
61
- }
62
-
63
- export function emitQuoteEvent(event: QuoteEventData): void {
64
- eventEmitter.emit(WidgetEvents.QuoteEvent, event);
65
- }
66
-
67
- export function emitWalletDetected(payload: WalletDetectedEventPayload): void {
68
- eventEmitter.emit(WidgetEvents.WalletEvent, {
69
- type: WalletEventTypes.DETECTED,
70
- payload,
71
- });
72
- }
package/src/utils/meta.ts CHANGED
@@ -70,3 +70,16 @@ export function isValidTokenAddress(
70
70
  const valid = regex.filter((r) => new RegExp(r).test(address)).length > 0;
71
71
  return valid;
72
72
  }
73
+
74
+ export function createTokenExplorerUrl(params: {
75
+ contractAddress: string;
76
+ blockchainMeta: BlockchainMeta;
77
+ }): string | undefined {
78
+ const { contractAddress, blockchainMeta } = params;
79
+
80
+ if (blockchainMeta.info?.tokenUrl) {
81
+ return blockchainMeta.info.tokenUrl.replace('{address}', contractAddress);
82
+ }
83
+
84
+ return blockchainMeta.info?.addressUrl.replace('{wallet}', contractAddress);
85
+ }
@@ -1,12 +1,12 @@
1
1
  import type { WidgetConfig } from '../types';
2
2
  import type { LegacyProviderInterface } from '@rango-dev/wallets-core/legacy';
3
3
 
4
+ import { Provider } from '@hub3js/core';
4
5
  import {
5
6
  defineVersions,
6
7
  pickVersion,
7
- Provider,
8
8
  type VersionedProviders,
9
- } from '@rango-dev/wallets-core';
9
+ } from '@hub3js/core/utils';
10
10
 
11
11
  export interface ProvidersOptions {
12
12
  walletConnectProjectId?: WidgetConfig['walletConnectProjectId'];