diff --git a/apps/browser-extension-wallet/src/config.ts b/apps/browser-extension-wallet/src/config.ts index 4180e7af3a..3e6ad690f9 100644 --- a/apps/browser-extension-wallet/src/config.ts +++ b/apps/browser-extension-wallet/src/config.ts @@ -22,7 +22,7 @@ export type Config = { ADA_PRICE_CHECK_INTERVAL: number; TOKEN_PRICE_CHECK_INTERVAL: number; AVAILABLE_CHAINS: Wallet.ChainName[]; - CEXPLORER_BASE_URL: Record, string>; + CEXPLORER_BASE_URL: Record; CEXPLORER_URL_PATHS: CExplorerUrlPaths; SAVED_PRICE_DURATION: number; }; @@ -84,7 +84,8 @@ export const config = (): Config => { CEXPLORER_BASE_URL: { Mainnet: `${process.env.CEXPLORER_URL_MAINNET}`, Preprod: `${process.env.CEXPLORER_URL_PREPROD}`, - Preview: `${process.env.CEXPLORER_URL_PREVIEW}` + Preview: `${process.env.CEXPLORER_URL_PREVIEW}`, + Sanchonet: `${process.env.CEXPLORER_URL_SANCHONET}` }, CEXPLORER_URL_PATHS: { Tx: 'tx', diff --git a/apps/browser-extension-wallet/src/features/dapp/components/DappError.tsx b/apps/browser-extension-wallet/src/features/dapp/components/DappError.tsx index 9c5c85e8d6..042c74a5ab 100644 --- a/apps/browser-extension-wallet/src/features/dapp/components/DappError.tsx +++ b/apps/browser-extension-wallet/src/features/dapp/components/DappError.tsx @@ -1,4 +1,4 @@ -import React, { ReactNode, useCallback, useEffect } from 'react'; +import React, { ReactNode, useCallback } from 'react'; import { Image } from 'antd'; import { useTranslation } from 'react-i18next'; import Empty from '../../../assets/icons/empty.svg'; @@ -10,7 +10,6 @@ type DappErrorProps = { description: ReactNode; closeButtonLabel?: string; onCloseClick?: () => void; - onMount?: () => void; containerTestId: string; imageTestId: string; titleTestId: string; @@ -22,7 +21,6 @@ export const DappError = ({ description, closeButtonLabel, onCloseClick, - onMount, containerTestId, imageTestId, titleTestId, @@ -32,14 +30,8 @@ export const DappError = ({ const { t } = useTranslation(); const handleClose = useCallback(() => { onCloseClick?.(); - window.close(); }, [onCloseClick]); - useEffect(() => { - onMount?.(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - return (
diff --git a/apps/browser-extension-wallet/src/features/dapp/components/collateral/CreateCollateral.tsx b/apps/browser-extension-wallet/src/features/dapp/components/collateral/CreateCollateral.tsx index 7fe3a76c7d..a979c6a80c 100644 --- a/apps/browser-extension-wallet/src/features/dapp/components/collateral/CreateCollateral.tsx +++ b/apps/browser-extension-wallet/src/features/dapp/components/collateral/CreateCollateral.tsx @@ -129,7 +129,10 @@ export const CreateCollateral = ({ })}
{renderAmountInfo( - `${Wallet.util.lovelacesToAdaString(collateralTx.fee.toString())} ${cardanoCoin.symbol}`, + Wallet.util.getFormattedAmount({ + amount: collateralTx.fee.toString(), + cardanoCoin + }), `${Wallet.util.convertAdaToFiat({ ada: Wallet.util.lovelacesToAdaString(collateralTx.fee.toString()), fiat: priceResult?.cardano?.price || 0 diff --git a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmDRepRegistrationContainer.tsx b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmDRepRegistrationContainer.tsx index cfd8e7241b..7cba19e559 100644 --- a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmDRepRegistrationContainer.tsx +++ b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmDRepRegistrationContainer.tsx @@ -9,11 +9,7 @@ import { Skeleton } from 'antd'; const { CertificateType } = Wallet.Cardano; -interface Props { - errorMessage?: string; -} - -export const ConfirmDRepRegistrationContainer = ({ errorMessage }: Props): React.ReactElement => { +export const ConfirmDRepRegistrationContainer = (): React.ReactElement => { const { t } = useTranslation(); const { walletUI: { cardanoCoin } @@ -42,6 +38,7 @@ export const ConfirmDRepRegistrationContainer = ({ errorMessage }: Props): React const depositPaidWithCardanoSymbol = depositPaidWithSymbol(certificate.deposit, cardanoCoin); + // TODO: might be changed in scope of https://input-output.atlassian.net/browse/LW-9034 return ( ); }; diff --git a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmDRepRetirementContainer.tsx b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmDRepRetirementContainer.tsx index 5779328c15..05b835ba91 100644 --- a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmDRepRetirementContainer.tsx +++ b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmDRepRetirementContainer.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { ConfirmDRepRetirement } from '@lace/core'; import { certificateInspectorFactory, depositPaidWithSymbol, disallowSignTx, drepIDasBech32FromHash } from './utils'; @@ -12,11 +12,10 @@ import { useViewsFlowContext } from '@providers'; const { CertificateType } = Wallet.Cardano; interface Props { - errorMessage?: string; onError: () => void; } -export const ConfirmDRepRetirementContainer = ({ onError, errorMessage }: Props): React.ReactElement => { +export const ConfirmDRepRetirementContainer = ({ onError }: Props): React.ReactElement => { const { t } = useTranslation(); const { walletUI: { cardanoCoin } @@ -41,23 +40,31 @@ export const ConfirmDRepRetirementContainer = ({ onError, errorMessage }: Props) getCertificateData(); }, [request]); + const depositPaidWithCardanoSymbol = depositPaidWithSymbol(certificate.deposit, cardanoCoin); + const isNotOwnDRepKey = certificate.dRepCredential.hash !== ownPubDRepKeyHash; + + useEffect(() => { + if (ownPubDRepKeyHash && isNotOwnDRepKey) { + disallowSignTx(request, true); + onError(); + } + }, [ownPubDRepKeyHash, isNotOwnDRepKey, onError, request]); + + const onCloseClick = useCallback(() => { + window.close(); + }, []); + if (!certificate || loadingOwnPubDRepKeyHash) { return ; } - const depositPaidWithCardanoSymbol = depositPaidWithSymbol(certificate.deposit, cardanoCoin); - const isNotOwnDRepKey = certificate.dRepCredential.hash !== ownPubDRepKeyHash; - if (isNotOwnDRepKey) { return ( { - disallowSignTx(request, false); - onError(); - }} containerTestId="drep-id-mismatch-container" + onCloseClick={onCloseClick} imageTestId="drep-id-mismatch-image" titleTestId="drep-id-mismatch-heading" descriptionTestId="drep-id-mismatch-description" @@ -80,7 +87,6 @@ export const ConfirmDRepRetirementContainer = ({ onError, errorMessage }: Props) drepId: t('core.DRepRetirement.drepId') } }} - errorMessage={errorMessage} /> ); }; diff --git a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmDRepUpdateContainer.tsx b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmDRepUpdateContainer.tsx index e82a6e03b1..691529f971 100644 --- a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmDRepUpdateContainer.tsx +++ b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmDRepUpdateContainer.tsx @@ -8,11 +8,7 @@ import { Skeleton } from 'antd'; const { CertificateType } = Wallet.Cardano; -interface Props { - errorMessage?: string; -} - -export const ConfirmDRepUpdateContainer = ({ errorMessage }: Props): React.ReactElement => { +export const ConfirmDRepUpdateContainer = (): React.ReactElement => { const { t } = useTranslation(); const { signTxRequest: { request }, @@ -51,7 +47,6 @@ export const ConfirmDRepUpdateContainer = ({ errorMessage }: Props): React.React url: t('core.DRepUpdate.url') } }} - errorMessage={errorMessage} /> ); }; diff --git a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmStakeRegistrationDelegationContainer.tsx b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmStakeRegistrationDelegationContainer.tsx index 068bc8f585..0d991fbf1b 100644 --- a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmStakeRegistrationDelegationContainer.tsx +++ b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmStakeRegistrationDelegationContainer.tsx @@ -9,11 +9,7 @@ import { Skeleton } from 'antd'; const { CertificateType, RewardAddress } = Wallet.Cardano; -interface Props { - errorMessage?: string; -} - -export const ConfirmStakeRegistrationDelegationContainer = ({ errorMessage }: Props): React.ReactElement => { +export const ConfirmStakeRegistrationDelegationContainer = (): React.ReactElement => { const { walletUI: { cardanoCoin }, currentChain @@ -58,7 +54,6 @@ export const ConfirmStakeRegistrationDelegationContainer = ({ errorMessage }: Pr depositPaid: t('core.StakeRegistrationDelegation.depositPaid') } }} - errorMessage={errorMessage} /> ); }; diff --git a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmStakeVoteDelegationContainer.tsx b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmStakeVoteDelegationContainer.tsx index 2f5438b0b1..df1b8eca72 100644 --- a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmStakeVoteDelegationContainer.tsx +++ b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmStakeVoteDelegationContainer.tsx @@ -9,11 +9,7 @@ import { Skeleton } from 'antd'; const { CertificateType, RewardAddress } = Wallet.Cardano; -interface Props { - errorMessage?: string; -} - -export const ConfirmStakeVoteDelegationContainer = ({ errorMessage }: Props): React.ReactElement => { +export const ConfirmStakeVoteDelegationContainer = (): React.ReactElement => { const { t } = useTranslation(); const { currentChain } = useWalletStore(); const { @@ -62,7 +58,6 @@ export const ConfirmStakeVoteDelegationContainer = ({ errorMessage }: Props): Re alwaysNoConfidence: t('core.StakeVoteDelegation.alwaysNoConfidence') } }} - errorMessage={errorMessage} /> ); }; diff --git a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmStakeVoteRegistrationDelegationContainer.tsx b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmStakeVoteRegistrationDelegationContainer.tsx index 8049b55186..55fcd66395 100644 --- a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmStakeVoteRegistrationDelegationContainer.tsx +++ b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmStakeVoteRegistrationDelegationContainer.tsx @@ -9,11 +9,7 @@ import { Skeleton } from 'antd'; const { CertificateType, RewardAddress } = Wallet.Cardano; -interface Props { - errorMessage?: string; -} - -export const ConfirmStakeVoteRegistrationDelegationContainer = ({ errorMessage }: Props): React.ReactElement => { +export const ConfirmStakeVoteRegistrationDelegationContainer = (): React.ReactElement => { const { t } = useTranslation(); const { walletUI: { cardanoCoin }, @@ -69,7 +65,6 @@ export const ConfirmStakeVoteRegistrationDelegationContainer = ({ errorMessage } depositPaid: t('core.StakeVoteDelegationRegistration.depositPaid') } }} - errorMessage={errorMessage} /> ); }; diff --git a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmTransaction.tsx b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmTransaction.tsx index 1507fc50e5..e38ee78ba6 100644 --- a/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmTransaction.tsx +++ b/apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/ConfirmTransaction.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import cn from 'classnames'; import { Button, PostHogAction } from '@lace/common'; import { useTranslation } from 'react-i18next'; @@ -8,7 +8,7 @@ import styles from './ConfirmTransaction.module.scss'; import { Wallet } from '@lace/cardano'; import { useWalletStore } from '@stores'; import { useDisallowSignTx, useSignWithHardwareWallet, useOnBeforeUnload } from './hooks'; -import { getTitleKey, getTxType } from './utils'; +import { getTxType } from './utils'; import { ConfirmTransactionContent } from './ConfirmTransactionContent'; import { TX_CREATION_TYPE_KEY, TxCreationType } from '@providers/AnalyticsProvider/analyticsTracker'; import { txSubmitted$ } from '@providers/AnalyticsProvider/onChain'; @@ -20,6 +20,7 @@ import { UserPromptService } from '@lib/scripts/background/services'; import { DAPP_CHANNELS } from '@src/utils/constants'; import { of, take } from 'rxjs'; import { runtime } from 'webextension-polyfill'; +import { Skeleton } from 'antd'; export const ConfirmTransaction = (): React.ReactElement => { const { t } = useTranslation(); @@ -45,7 +46,6 @@ export const ConfirmTransaction = (): React.ReactElement => { fetchTxType(); }, [req]); - const title = txType ? t(getTitleKey(txType)) : ''; const onConfirm = () => { analytics.sendEventToPostHog(PostHogAction.SendTransactionSummaryConfirmClick, { [TX_CREATION_TYPE_KEY]: TxCreationType.External @@ -87,13 +87,17 @@ export const ConfirmTransaction = (): React.ReactElement => { useOnBeforeUnload(disallowSignTx); + const onError = useCallback(() => { + setConfirmTransactionError(true); + }, []); + return ( - {req && txType && setConfirmTransactionError(true)} />} + {req && txType ? : } {!confirmTransactionError && (