@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
@@ -23,13 +23,10 @@ import {
23
23
  import { legacyReadAccountAddress as readAccountAddress } from '@rango-dev/wallets-core/legacy';
24
24
  import {
25
25
  detectInstallLink,
26
- getCosmosExperimentalChainInfo,
27
26
  isEvmAddress,
28
- KEPLR_COMPATIBLE_WALLETS,
29
27
  Networks,
30
28
  } from '@rango-dev/wallets-shared';
31
29
  import BigNumber from 'bignumber.js';
32
- import { isCosmosBlockchain } from 'rango-types';
33
30
 
34
31
  import { ZERO } from '../constants/numbers';
35
32
  import {
@@ -314,35 +311,6 @@ function numberWithThousandSeparator(number: string | number): string {
314
311
  return parts.join('.');
315
312
  }
316
313
 
317
- export const isExperimentalChain = (
318
- blockchains: BlockchainMeta[],
319
- wallet: string
320
- ): boolean => {
321
- const cosmosExperimentalChainInfo = getCosmosExperimentalChainInfo(
322
- Object.entries(blockchains)
323
- .map(([, blockchainMeta]) => blockchainMeta)
324
- .filter(isCosmosBlockchain)
325
- );
326
- return (
327
- cosmosExperimentalChainInfo &&
328
- !!cosmosExperimentalChainInfo[wallet]?.experimental
329
- );
330
- };
331
-
332
- export const getKeplrCompatibleConnectedWallets = (
333
- selectableWallets: Wallet[]
334
- ): WalletType[] => {
335
- const connectedWalletTypes = new Set(
336
- selectableWallets.map((wallet) => {
337
- return wallet.walletType;
338
- })
339
- );
340
-
341
- return KEPLR_COMPATIBLE_WALLETS.filter((compatibleWallet) =>
342
- connectedWalletTypes.has(compatibleWallet)
343
- );
344
- };
345
-
346
314
  function representAmountInNumber(amount: string, decimals: number): string {
347
315
  return new BigNumber(amount).shiftedBy(-decimals).toFixed();
348
316
  }
@@ -1,3 +0,0 @@
1
- import type { BlockchainMeta } from 'rango-types';
2
- export declare function generateExplorerLink(address: string | null, blockchain: BlockchainMeta): string;
3
- //# sourceMappingURL=CustomTokenModal.helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CustomTokenModal.helpers.d.ts","sourceRoot":"","sources":["../../../src/components/CustomTokenModal/CustomTokenModal.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,UAAU,EAAE,cAAc,GACzB,MAAM,CAaR"}
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- interface PropTypes {
3
- displayName?: string;
4
- onConfirm: () => void;
5
- id: string;
6
- }
7
- export declare function ExperimentalChain(props: PropTypes): React.JSX.Element;
8
- export {};
9
- //# sourceMappingURL=ExperimentalChain.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExperimentalChain.d.ts","sourceRoot":"","sources":["../../../src/components/WalletStatefulConnect/ExperimentalChain.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,UAAU,SAAS;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,qBA4BjD"}
@@ -1,4 +0,0 @@
1
- import type { PropTypes } from './ExperimentalChainStatus.types';
2
- import React from 'react';
3
- export declare function ExperimentalChainStatus(props: PropTypes): React.JSX.Element;
4
- //# sourceMappingURL=ExperimentalChainStatus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExperimentalChainStatus.d.ts","sourceRoot":"","sources":["../../../src/components/WalletStatefulConnect/ExperimentalChainStatus.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,SAAS,qBAsBvD"}
@@ -1,8 +0,0 @@
1
- import type { PropTypes } from './ExperimentalChainStatus.types';
2
- import type { MessageType } from '@rango-dev/ui';
3
- export declare function generateMessageByStatus(status: PropTypes['status'], blockchainDisplayName: string | undefined): {
4
- type: MessageType;
5
- title: string;
6
- description: string;
7
- };
8
- //# sourceMappingURL=ExperimentalChainStatus.helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExperimentalChainStatus.helpers.d.ts","sourceRoot":"","sources":["../../../src/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAIjD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,EAC3B,qBAAqB,EAAE,MAAM,GAAG,SAAS,GACxC;IACD,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAwCA"}
@@ -1,6 +0,0 @@
1
- export interface PropTypes {
2
- displayName?: string;
3
- status: 'in-progress' | 'completed' | 'rejected';
4
- image: string;
5
- }
6
- //# sourceMappingURL=ExperimentalChainStatus.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExperimentalChainStatus.types.d.ts","sourceRoot":"","sources":["../../../src/components/WalletStatefulConnect/ExperimentalChainStatus.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,aAAa,GAAG,WAAW,GAAG,UAAU,CAAC;IACjD,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -1,10 +0,0 @@
1
- import type { WalletConnectionSource } from '../types';
2
- export declare function setPendingWalletConnectionSource(source: WalletConnectionSource | null): void;
3
- /**
4
- * Snapshots the current pending source for a wallet as it starts connecting.
5
- * Called on the wallet's `connecting` event.
6
- */
7
- export declare function markWalletConnecting(walletType: string): void;
8
- /** Reads the source captured for a wallet when it began connecting. */
9
- export declare function getWalletConnectionSource(walletType: string): WalletConnectionSource | null;
10
- //# sourceMappingURL=walletConnectionSource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"walletConnectionSource.d.ts","sourceRoot":"","sources":["../../src/services/walletConnectionSource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAqBvD,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,sBAAsB,GAAG,IAAI,GACpC,IAAI,CAEN;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAE7D;AAED,uEAAuE;AACvE,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,MAAM,GACjB,sBAAsB,GAAG,IAAI,CAE/B"}
@@ -1,8 +0,0 @@
1
- import type { SelectedQuote, SwapEstimateEventPayload } from '../types';
2
- /**
3
- * Derives the shared route/quote descriptor used by several swap
4
- * events (swapInitiated, swapStarted, routeRequested, ...) from a quote.
5
- * Amounts are estimates taken from the quote, not on-chain actuals.
6
- */
7
- export declare function buildSwapEstimatePayload(quote: SelectedQuote): SwapEstimateEventPayload;
8
- //# sourceMappingURL=eventPayloads.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"eventPayloads.d.ts","sourceRoot":"","sources":["../../src/utils/eventPayloads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAYxE;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,aAAa,GACnB,wBAAwB,CAiB1B"}
@@ -1,19 +0,0 @@
1
- import type { BlockchainMeta } from 'rango-types';
2
-
3
- export function generateExplorerLink(
4
- address: string | null,
5
- blockchain: BlockchainMeta
6
- ): string {
7
- // We don't have Cosmos explorer url in API.
8
- if (blockchain.type === 'COSMOS') {
9
- return '';
10
- }
11
-
12
- const explorerLinkPattern = blockchain.info?.addressUrl;
13
-
14
- if (!explorerLinkPattern || !address) {
15
- return '';
16
- }
17
-
18
- return explorerLinkPattern.replace('{wallet}', address);
19
- }
@@ -1,39 +0,0 @@
1
- import { i18n } from '@lingui/core';
2
- import { Button, Divider, MessageBox } from '@rango-dev/ui';
3
- import React from 'react';
4
-
5
- interface PropTypes {
6
- displayName?: string;
7
- onConfirm: () => void;
8
- id: string;
9
- }
10
-
11
- export function ExperimentalChain(props: PropTypes) {
12
- const { displayName, onConfirm, id } = props;
13
-
14
- return (
15
- <MessageBox
16
- id={id}
17
- title={i18n.t({
18
- id: 'Add {blockchainDisplayName} Chain',
19
- values: { blockchainDisplayName: displayName },
20
- })}
21
- type="warning"
22
- description={i18n.t({
23
- id: 'Would you like to add the {blockchainDisplayName} experimental chain to your wallet?',
24
- values: { blockchainDisplayName: displayName },
25
- })}>
26
- <Divider size={18} />
27
- <Divider size={32} />
28
- <Button
29
- id="widget-experimental-chain-confirm-btn"
30
- onClick={onConfirm}
31
- variant="outlined"
32
- type="primary"
33
- fullWidth
34
- size="large">
35
- {i18n.t('Confirm')}
36
- </Button>
37
- </MessageBox>
38
- );
39
- }
@@ -1,53 +0,0 @@
1
- import type { PropTypes } from './ExperimentalChainStatus.types';
2
- import type { MessageType } from '@rango-dev/ui';
3
-
4
- import { i18n } from '@lingui/core';
5
-
6
- export function generateMessageByStatus(
7
- status: PropTypes['status'],
8
- blockchainDisplayName: string | undefined
9
- ): {
10
- type: MessageType;
11
- title: string;
12
- description: string;
13
- } {
14
- switch (status) {
15
- case 'in-progress':
16
- return {
17
- type: 'loading',
18
- title: i18n.t({
19
- id: 'Add {blockchainDisplayName} Chain',
20
- values: { blockchainDisplayName },
21
- }),
22
- description: i18n.t({
23
- id: 'Please approve the experimental chain pop-up in your wallet.',
24
- values: { blockchainDisplayName },
25
- }),
26
- };
27
- case 'completed':
28
- return {
29
- type: 'success',
30
- title: i18n.t({
31
- id: '{blockchainDisplayName} Chain Added',
32
- values: { blockchainDisplayName },
33
- }),
34
- description: i18n.t({
35
- id: 'The {blockchainDisplayName} chain has been successfully added to your wallet.',
36
- values: { blockchainDisplayName },
37
- }),
38
- };
39
- case 'rejected':
40
- return {
41
- type: 'error',
42
- title: i18n.t('Request Rejected'),
43
- description: i18n.t({
44
- id: "You've rejected adding {blockchainDisplayName} chain to your wallet.",
45
- values: { blockchainDisplayName },
46
- }),
47
- };
48
- default:
49
- throw new Error(
50
- `Showing information about an experimentation chain status needs to be defined first. status: ${status}`
51
- );
52
- }
53
- }
@@ -1,36 +0,0 @@
1
- import type { PropTypes } from './ExperimentalChainStatus.types';
2
-
3
- import { Image, MessageBox } from '@rango-dev/ui';
4
- import React from 'react';
5
-
6
- import {
7
- LogoContainer,
8
- Spinner,
9
- WalletImageContainer,
10
- } from '../ConfirmWalletsModal/WalletList.styles';
11
-
12
- import { generateMessageByStatus } from './ExperimentalChainStatus.helpers';
13
-
14
- export function ExperimentalChainStatus(props: PropTypes) {
15
- const { status, displayName, image } = props;
16
- const data = generateMessageByStatus(status, displayName);
17
- const hasImage = status == 'in-progress';
18
-
19
- return (
20
- <MessageBox
21
- type={data.type}
22
- title={data.title}
23
- description={data.description}
24
- icon={
25
- hasImage ? (
26
- <LogoContainer>
27
- <WalletImageContainer>
28
- <Image src={image} size={45} />
29
- </WalletImageContainer>
30
- <Spinner />
31
- </LogoContainer>
32
- ) : undefined
33
- }
34
- />
35
- );
36
- }
@@ -1,5 +0,0 @@
1
- export interface PropTypes {
2
- displayName?: string;
3
- status: 'in-progress' | 'completed' | 'rejected';
4
- image: string;
5
- }
@@ -1,41 +0,0 @@
1
- import type { WalletConnectionSource } from '../types';
2
-
3
- /**
4
- * Source of the connection the user is about to start, recorded when an
5
- * in-widget connection flow is initiated (e.g. the nav or swap button). This is
6
- * only "pending" until a specific wallet actually starts connecting — see
7
- * `markWalletConnecting`.
8
- */
9
- let pendingSource: WalletConnectionSource | null = null;
10
-
11
- /**
12
- * Source captured per wallet type at the moment that wallet began connecting.
13
- * Keying by wallet type (rather than a single global value) means interleaved
14
- * or abandoned connection attempts can't misattribute each other: e.g.
15
- * initiating from the nav, leaving the wallet popup, then connecting a
16
- * different wallet from the swap button no longer overwrites the first wallet's
17
- * source. The connection completes asynchronously, far from the click site, so
18
- * the source has to be remembered until `walletConnected` is emitted.
19
- */
20
- const sourceByWallet = new Map<string, WalletConnectionSource | null>();
21
-
22
- export function setPendingWalletConnectionSource(
23
- source: WalletConnectionSource | null
24
- ): void {
25
- pendingSource = source;
26
- }
27
-
28
- /**
29
- * Snapshots the current pending source for a wallet as it starts connecting.
30
- * Called on the wallet's `connecting` event.
31
- */
32
- export function markWalletConnecting(walletType: string): void {
33
- sourceByWallet.set(walletType, pendingSource);
34
- }
35
-
36
- /** Reads the source captured for a wallet when it began connecting. */
37
- export function getWalletConnectionSource(
38
- walletType: string
39
- ): WalletConnectionSource | null {
40
- return sourceByWallet.get(walletType) ?? null;
41
- }
@@ -1,37 +0,0 @@
1
- import type { SelectedQuote, SwapEstimateEventPayload } from '../types';
2
-
3
- import { getUsdInputFrom, getUsdOutputFrom } from './swap';
4
-
5
- function toNumberOrNull(value: string | null | undefined): number | null {
6
- if (value === null || value === undefined || value === '') {
7
- return null;
8
- }
9
- const parsed = Number(value);
10
- return Number.isFinite(parsed) ? parsed : null;
11
- }
12
-
13
- /**
14
- * Derives the shared route/quote descriptor used by several swap
15
- * events (swapInitiated, swapStarted, routeRequested, ...) from a quote.
16
- * Amounts are estimates taken from the quote, not on-chain actuals.
17
- */
18
- export function buildSwapEstimatePayload(
19
- quote: SelectedQuote
20
- ): SwapEstimateEventPayload {
21
- const firstSwap = quote.swaps[0];
22
- const lastSwap = quote.swaps[quote.swaps.length - 1];
23
- const inputUsd = getUsdInputFrom(quote);
24
- const outputUsd = getUsdOutputFrom(quote);
25
-
26
- return {
27
- routeId: quote.requestId,
28
- sourceChain: firstSwap?.from.blockchain ?? '',
29
- destinationChain: lastSwap?.to.blockchain ?? '',
30
- sourceToken: firstSwap?.from.symbol ?? '',
31
- destinationToken: lastSwap?.to.symbol ?? '',
32
- sourceTokenAmount: toNumberOrNull(quote.requestAmount),
33
- destinationTokenAmount: toNumberOrNull(quote.outputAmount),
34
- inputAmountUsd: inputUsd ? inputUsd.toNumber() : null,
35
- outputAmountUsd: outputUsd ? outputUsd.toNumber() : null,
36
- };
37
- }