@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.
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/CustomDestination/CustomDestination.d.ts.map +1 -1
- package/dist/components/CustomTokenModal/CustomTokenModal.d.ts.map +1 -1
- package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts +1 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Detached.types.d.ts +1 -1
- package/dist/components/WalletStatefulConnect/Detached.types.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/NamespaceDetachedItem.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +2 -2
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/index.d.ts +0 -1
- package/dist/components/WalletStatefulConnect/index.d.ts.map +1 -1
- package/dist/constants/wallets.d.ts +1 -2
- package/dist/constants/wallets.d.ts.map +1 -1
- package/dist/containers/Settings/Lists.d.ts.map +1 -1
- package/dist/containers/Wallets/useUpdates.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.state.d.ts +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.state.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncNotifications/useSyncNotifications.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/hooks/useWalletProviders/useWalletProviders.d.ts +1 -1
- package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts +1 -1
- package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemPage/SelectSwapItemPage.helpers.d.ts +0 -1
- package/dist/pages/SelectSwapItemPage/SelectSwapItemPage.helpers.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemPage/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +1 -1
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/wallets.d.ts +2 -4
- package/dist/store/slices/wallets.d.ts.map +1 -1
- package/dist/store/utils/wallets.d.ts +2 -2
- package/dist/store/utils/wallets.d.ts.map +1 -1
- package/dist/test-utils/fixtures.d.ts.map +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/event.d.ts +6 -141
- package/dist/types/event.d.ts.map +1 -1
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/events.d.ts +5 -16
- package/dist/utils/events.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +4 -0
- package/dist/utils/meta.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +2 -1
- package/dist/utils/providers.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +0 -2
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +11 -8
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +2 -53
- package/src/components/ConfirmWalletsModal/WalletList.tsx +16 -166
- package/src/components/CustomDestination/CustomDestination.tsx +0 -18
- package/src/components/CustomTokenModal/CustomTokenModal.tsx +7 -2
- package/src/components/Quote/QuoteCostDetails.tsx +0 -8
- package/src/components/Slippage/Slippage.tsx +0 -21
- package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.tsx +0 -6
- package/src/components/TokenList/TokenList.tsx +11 -8
- package/src/components/WalletStatefulConnect/DerivationPath.helpers.ts +1 -1
- package/src/components/WalletStatefulConnect/Detached.tsx +1 -1
- package/src/components/WalletStatefulConnect/Detached.types.ts +1 -1
- package/src/components/WalletStatefulConnect/NamespaceDetachedItem.tsx +7 -1
- package/src/components/WalletStatefulConnect/Namespaces.tsx +1 -1
- package/src/components/WalletStatefulConnect/Namespaces.types.tsx +2 -2
- package/src/components/WalletStatefulConnect/index.ts +0 -1
- package/src/constants/wallets.ts +1 -3
- package/src/containers/Settings/Lists.tsx +1 -13
- package/src/containers/Wallets/useUpdates.ts +1 -9
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -1
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +45 -3316
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +26 -228
- package/src/hooks/useStatefulConnect/useStatefulConnect.state.ts +1 -1
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +1 -1
- package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +1 -1
- package/src/hooks/useSwapInput.ts +1 -46
- package/src/hooks/useSyncNotifications/useSyncNotifications.ts +1 -26
- package/src/hooks/useWalletList.ts +6 -63
- package/src/hooks/useWalletProviders/useWalletProviders.helpers.ts +1 -1
- package/src/pages/ConfirmSwapPage.tsx +1 -12
- package/src/pages/Home.tsx +4 -33
- package/src/pages/LiquiditySourcePage.tsx +0 -24
- package/src/pages/SelectBlockchainPage.tsx +0 -10
- package/src/pages/SelectSwapItemPage/SelectSwapItemPage.helpers.ts +0 -13
- package/src/pages/SelectSwapItemPage/SelectSwapItemsPage.tsx +0 -27
- package/src/pages/SwapDetailsPage.tsx +0 -6
- package/src/store/slices/config.ts +1 -1
- package/src/store/slices/wallets.ts +4 -12
- package/src/store/utils/wallets.ts +2 -2
- package/src/test-utils/fixtures.ts +0 -39
- package/src/types/config.ts +1 -1
- package/src/types/event.ts +10 -182
- package/src/utils/common.ts +0 -1
- package/src/utils/events.ts +6 -51
- package/src/utils/meta.ts +13 -0
- package/src/utils/providers.ts +2 -2
- package/src/utils/wallets.ts +0 -32
- package/dist/components/CustomTokenModal/CustomTokenModal.helpers.d.ts +0 -3
- package/dist/components/CustomTokenModal/CustomTokenModal.helpers.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ExperimentalChain.d.ts +0 -9
- package/dist/components/WalletStatefulConnect/ExperimentalChain.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.d.ts +0 -4
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.d.ts +0 -8
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.types.d.ts +0 -6
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.types.d.ts.map +0 -1
- package/dist/services/walletConnectionSource.d.ts +0 -10
- package/dist/services/walletConnectionSource.d.ts.map +0 -1
- package/dist/utils/eventPayloads.d.ts +0 -8
- package/dist/utils/eventPayloads.d.ts.map +0 -1
- package/src/components/CustomTokenModal/CustomTokenModal.helpers.ts +0 -19
- package/src/components/WalletStatefulConnect/ExperimentalChain.tsx +0 -39
- package/src/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.ts +0 -53
- package/src/components/WalletStatefulConnect/ExperimentalChainStatus.tsx +0 -36
- package/src/components/WalletStatefulConnect/ExperimentalChainStatus.types.ts +0 -5
- package/src/services/walletConnectionSource.ts +0 -41
- package/src/utils/eventPayloads.ts +0 -37
package/src/utils/wallets.ts
CHANGED
|
@@ -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 +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 +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 +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 +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,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
|
-
}
|