Skip to content

Commit

Permalink
fix(extension): resolve sanchonet pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vetalcore committed Feb 26, 2024
1 parent 8a7a878 commit 2b585b2
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 41 deletions.
5 changes: 3 additions & 2 deletions apps/browser-extension-wallet/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Exclude<EnvironmentTypes, 'Sanchonet'>, string>;
CEXPLORER_BASE_URL: Record<EnvironmentTypes, string>;
CEXPLORER_URL_PATHS: CExplorerUrlPaths;
SAVED_PRICE_DURATION: number;
};
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -96,7 +97,7 @@ export const ConfirmTransaction = (): React.ReactElement => {
pageClassname={styles.spaceBetween}
title={!confirmTransactionError && txType && t(`core.${txType}.title`)}
>
{req && txType && <ConfirmTransactionContent txType={txType} onError={onError} />}
{req && txType ? <ConfirmTransactionContent txType={txType} onError={onError} /> : <Skeleton loading />}
{!confirmTransactionError && (
<div className={styles.actions}>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ interface Props {
onError?: () => void;
}

ConfirmDRepRetirementContainer;

export const ConfirmTransactionContent = ({ txType, onError }: Props): React.ReactElement => {
const containerPerTypeMap: Record<
Wallet.Cip30TxType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const DappTransactionContainer = withAddressBookContext(({ errorMessage }
walletInfo
});

// TODO: merge with the upper skeleton check
if (!txSummary) {
return <Skeleton />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const VotingProceduresContainer = (): React.ReactElement => {
actionId: {
index: vote.actionId.actionIndex,
txHash: vote.actionId.id.toString(),
...(explorerBaseUrl && { txHashUrl: `${explorerBaseUrl}/${vote.actionId.id}` })
txHashUrl: `${explorerBaseUrl}/${vote.actionId.id}`
},
votingProcedure: {
vote: t(`core.VotingProcedures.votes.${getVote(vote.votingProcedure.vote)}`),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,7 @@ export const useCexplorerBaseUrl = (): string => {
const { CEXPLORER_BASE_URL, CEXPLORER_URL_PATHS } = config();

useEffect(() => {
const newUrl =
environmentName === 'Sanchonet' ? '' : `${CEXPLORER_BASE_URL[environmentName]}/${CEXPLORER_URL_PATHS.Tx}`;
const newUrl = `${CEXPLORER_BASE_URL[environmentName]}/${CEXPLORER_URL_PATHS.Tx}`;
if (newUrl !== explorerBaseUrl) {
setExplorerBaseUrl(newUrl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const HardForkInitiationActionContainer = ({
anchor: {
url: anchor.url,
hash: anchor.dataHash,
...(explorerBaseUrl && { txHashUrl: `${explorerBaseUrl}/${anchor.dataHash}` })
txHashUrl: `${explorerBaseUrl}/${anchor.dataHash}`
}
},
protocolVersion: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const InfoActionContainer = ({ dappInfo, anchor, errorMessage }: Props):
anchor: {
url: anchor.url,
hash: anchor.dataHash,
...(explorerBaseUrl && { txHashUrl: `${explorerBaseUrl}/${anchor.dataHash}` })
txHashUrl: `${explorerBaseUrl}/${anchor.dataHash}`
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const NewConstitutionActionContainer = ({
anchor: {
url: anchor.url,
hash: anchor.dataHash,
...(explorerBaseUrl && { txHashUrl: `${explorerBaseUrl}/${anchor.dataHash}` })
txHashUrl: `${explorerBaseUrl}/${anchor.dataHash}`
}
},
...(governanceActionId && {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const NoConfidenceActionContainer = ({
anchor: {
url: anchor.url,
hash: anchor.dataHash,
...(explorerBaseUrl && { txHashUrl: `${explorerBaseUrl}/${anchor.dataHash}` })
txHashUrl: `${explorerBaseUrl}/${anchor.dataHash}`
}
},
...(governanceActionId && {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export const ParameterChangeActionContainer = ({
anchor: {
url: anchor.url,
hash: anchor.dataHash,
...(explorerBaseUrl && { txHashUrl: `${explorerBaseUrl}/${anchor.dataHash}` })
txHashUrl: `${explorerBaseUrl}/${anchor.dataHash}`
},
protocolParamUpdate: {
maxTxExUnits: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const TreasuryWithdrawalsActionContainer = ({
anchor: {
url: anchor.url,
hash: anchor.dataHash,
...(explorerBaseUrl && { txHashUrl: `${explorerBaseUrl}/${anchor.dataHash}` })
txHashUrl: `${explorerBaseUrl}/${anchor.dataHash}`
}
},
withdrawals: [...withdrawals].map((withdrawal) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const UpdateCommitteeActionContainer = ({
anchor: {
url: anchor.url,
hash: anchor.dataHash,
...(explorerBaseUrl && { txHashUrl: `${explorerBaseUrl}/${anchor.dataHash}` })
txHashUrl: `${explorerBaseUrl}/${anchor.dataHash}`
}
},
...(governanceActionId && {
Expand All @@ -94,12 +94,12 @@ export const UpdateCommitteeActionContainer = ({
}),
membersToBeAdded: [...membersToBeAdded].map(({ coldCredential: { hash }, epoch }) => ({
coldCredential: {
hash: drepIDasBech32FromHash(hash)
hash: hash.toString()
},
epoch: epoch.toString()
})),
membersToBeRemoved: [...membersToBeRemoved].map(({ hash }) => ({
hash: drepIDasBech32FromHash(hash)
hash: hash.toString()
}))
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ export const TransactionDetailsProxy = withAddressBookContext(
const { list: addressList } = useAddressBookContext();

const { CEXPLORER_BASE_URL, CEXPLORER_URL_PATHS } = config();
// TODO, remove if sanchonet gets an explorer
const explorerBaseUrl = useMemo(() => {
if (environmentName === 'Sanchonet') return;
// eslint-disable-next-line consistent-return
return `${CEXPLORER_BASE_URL[environmentName]}/${CEXPLORER_URL_PATHS.Tx}`;
}, [CEXPLORER_BASE_URL, CEXPLORER_URL_PATHS.Tx, environmentName]);
const explorerBaseUrl = useMemo(
() => `${CEXPLORER_BASE_URL[environmentName]}/${CEXPLORER_URL_PATHS.Tx}`,
[CEXPLORER_BASE_URL, CEXPLORER_URL_PATHS.Tx, environmentName]
);
const getHeaderDescription = () => {
if (activityInfo.type === DelegationActivityType.delegation) return '1 token';
return ` (${activityInfo?.assetAmount})`;
Expand Down Expand Up @@ -78,10 +76,6 @@ export const TransactionDetailsProxy = withAddressBookContext(
[addressList]
);

const environmentSpecificProps = {
...(explorerBaseUrl && { openExternalLink: handleOpenExternalLink })
};

return (
// eslint-disable-next-line react/jsx-pascal-case
<TransactionDetails
Expand All @@ -108,7 +102,7 @@ export const TransactionDetailsProxy = withAddressBookContext(
proposalProcedures={proposalProcedures}
votingProcedures={votingProcedures}
certificates={certificates}
{...environmentSpecificProps}
openExternalLink={handleOpenExternalLink}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import dayjs from 'dayjs';
import isEmpty from 'lodash/isEmpty';
import { PriceResult } from '@hooks';
import { formatPercentages } from '@lace/common';
import { depositPaidWithSymbol } from '@src/features/dapp/components/confirm-transaction/utils';

const { util, GovernanceActionType, PlutusLanguageVersion, CertificateType } = Wallet.Cardano;

Expand Down Expand Up @@ -664,11 +665,11 @@ export const governanceProposalsTransformer = ({
},
{
title: 'govActionDeposit',
details: [`${governanceActionDeposit?.toString()} ${cardanoCoin.symbol}`]
details: [depositPaidWithSymbol(BigInt(governanceActionDeposit), cardanoCoin)]
},
{
title: 'drepDeposit',
details: [`${dRepDeposit?.toString()} ${cardanoCoin.symbol}`]
details: [depositPaidWithSymbol(BigInt(dRepDeposit), cardanoCoin)]
},
{
title: 'drepActivity',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ export const AssetDetails = ({
const { environmentName } = useWalletStore();
const openExternalLink = useExternalLinkOpener();

const explorerBaseUrl = useMemo(() => {
if (environmentName === 'Sanchonet') return '';
// eslint-disable-next-line consistent-return
return CEXPLORER_BASE_URL[environmentName];
}, [environmentName]);
const explorerBaseUrl = useMemo(() => CEXPLORER_BASE_URL[environmentName], [environmentName]);
const isTxListLoading = activityListStatus === StateStatus.IDLE || activityListStatus === StateStatus.LOADING;

return (
Expand Down Expand Up @@ -115,17 +111,13 @@ export const AssetDetails = ({
name: t('browserView.assetDetails.fingerprint'),
value: fingerprint,
showCopyIcon: true,
...(explorerBaseUrl && {
onClick: () => openExternalLink(`${explorerBaseUrl}/${CEXPLORER_URL_PATHS.Asset}/${fingerprint}`)
})
onClick: () => openExternalLink(`${explorerBaseUrl}/${CEXPLORER_URL_PATHS.Asset}/${fingerprint}`)
},
{
name: t('browserView.assetDetails.policyId'),
value: policyId,
showCopyIcon: true,
...(explorerBaseUrl && {
onClick: () => openExternalLink(`${explorerBaseUrl}/${CEXPLORER_URL_PATHS.Policy}/${policyId}`)
})
onClick: () => openExternalLink(`${explorerBaseUrl}/${CEXPLORER_URL_PATHS.Policy}/${policyId}`)
}
]}
/>
Expand Down

0 comments on commit 2b585b2

Please sign in to comment.