Skip to content

Commit

Permalink
Merge pull request #2512 from novasamatech/fix/tbaut-descriptions
Browse files Browse the repository at this point in the history
fix: remove multisig descriptions
  • Loading branch information
Tbaut authored Oct 21, 2024
2 parents 0a3e32d + 295fabc commit edf1aee
Show file tree
Hide file tree
Showing 28 changed files with 24 additions and 694 deletions.
2 changes: 0 additions & 2 deletions src/renderer/entities/multisig/lib/multisigTx/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ export const buildMultisigTx = (
multisigTx: Transaction,
params: ExtrinsicResultParams,
account: MultisigAccount,
description?: string,
): MultisigTxResult => {
const transaction: MultisigTransaction = {
transaction: tx,
Expand All @@ -168,7 +167,6 @@ export const buildMultisigTx = (
blockCreated: params.timepoint.height,
indexCreated: params.timepoint.index,
dateCreated: Date.now(),
description,
};

const event: MultisigEvent = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ import { type PropsWithChildren } from 'react';
import { type DecodedTransaction, type Transaction } from '@/shared/core';
import { useI18n } from '@/shared/i18n';
import { cnTw } from '@/shared/lib/utils';
import { BodyText, FootnoteText, Icon } from '@/shared/ui';
import { BodyText, Icon } from '@/shared/ui';
import { getIconName } from '@/entities/transaction/lib/transactionIcon';
import { getTransactionTitle } from '../../lib';

type Props = {
tx?: Transaction | DecodedTransaction;
description?: string;
className?: string;
};

export const TransactionTitle = ({ tx, description, className, children }: PropsWithChildren<Props>) => {
export const TransactionTitle = ({ tx, className, children }: PropsWithChildren<Props>) => {
const { t } = useI18n();

const title = getTransactionTitle(t, tx);
Expand All @@ -28,7 +27,6 @@ export const TransactionTitle = ({ tx, description, className, children }: Props
<BodyText className={cnTw('whitespace-nowrap', !children && 'truncate')}>{t(title)}</BodyText>
{children}
</div>
{description && <FootnoteText className="truncate text-text-tertiary">{description} </FootnoteText>}
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,17 @@ type SaveMultisigParams = {
multisigAccount: MultisigAccount;
params: ExtrinsicResultParams;
hooks: Callbacks;
description?: string;
};

type SaveMultisigResult = {
transactions: MultisigTransaction[];
events: MultisigEvent[];
};
const saveMultisigTxFx = createEffect(
({
transactions,
multisigTxs,
multisigAccount,
params,
hooks,
description,
}: SaveMultisigParams): SaveMultisigResult => {
({ transactions, multisigTxs, multisigAccount, params, hooks }: SaveMultisigParams): SaveMultisigResult => {
const { txs, events } = transactions.reduce<{ txs: MultisigTransaction[]; events: MultisigEvent[] }>(
(acc, transaction, index) => {
const multisigData = buildMultisigTx(transaction, multisigTxs[index], params, multisigAccount, description);
const multisigData = buildMultisigTx(transaction, multisigTxs[index], params, multisigAccount);

hooks.addEventWithQueue(multisigData.event);
hooks.addMultisigTx(multisigData.transaction);
Expand Down Expand Up @@ -225,7 +217,6 @@ sample({
transactions: submitStore!.coreTxs,
multisigTxs: submitStore!.multisigTxs,
multisigAccount: submitStore!.account as MultisigAccount,
description: submitStore!.description,
}),
target: saveMultisigTxFx,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useEffect, useState } from 'react';
import { type Account, type MultisigAccount, type MultisigTransaction, type Transaction } from '@/shared/core';
import { useI18n } from '@/shared/i18n';
import { getAssetById } from '@/shared/lib/utils';
import { DetailRow, FootnoteText, Icon } from '@/shared/ui';
import { DetailRow, Icon } from '@/shared/ui';
import { getTransactionFromMultisigTx } from '@/entities/multisig';
import { type ExtendedChain } from '@/entities/network';
import { SignButton } from '@/entities/operations';
Expand Down Expand Up @@ -53,12 +53,6 @@ export const Confirmation = ({ tx, account, connection, signatory, feeTx, onSign
<Icon className="text-icon-default" name={getIconName(tx.transaction)} size={60} />

{tx.transaction && <TransactionAmount tx={tx.transaction} />}

{tx.description && (
<FootnoteText className="ml-3 rounded bg-block-background px-3 py-2 text-text-secondary">
{tx.description}
</FootnoteText>
)}
</div>

<Details tx={tx} account={account} extendedChain={connection} signatory={signatory} />
Expand Down
14 changes: 1 addition & 13 deletions src/renderer/pages/Operations/components/ActionSteps/Submit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,11 @@ type Props = {
multisigTx?: MultisigTransaction;
txPayload: Uint8Array;
signature: HexString;
rejectReason?: string;
isReject?: boolean;
onClose: () => void;
};

export const Submit = ({
api,
tx,
multisigTx,
account,
txPayload,
signature,
rejectReason,
isReject,
onClose,
}: Props) => {
export const Submit = ({ api, tx, multisigTx, account, txPayload, signature, isReject, onClose }: Props) => {
const { t } = useI18n();

const { addTask } = useMultisigChainContext();
Expand Down Expand Up @@ -73,7 +62,6 @@ export const Submit = ({

if (isReject) {
updatedTx.status = MultisigTxFinalStatus.CANCELLED;
updatedTx.cancelDescription = rejectReason;
}

await updateMultisigTx(updatedTx);
Expand Down
14 changes: 1 addition & 13 deletions src/renderer/pages/Operations/components/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
isXcmTransaction,
} from '@/entities/transaction';
import { AddressWithExplorers, ExplorersPopover, WalletCardSm, WalletIcon, walletModel } from '@/entities/wallet';
import { AddressStyle, DescriptionBlockStyle, InteractionStyle } from '../common/constants';
import { AddressStyle, InteractionStyle } from '../common/constants';
import {
getDelegate,
getDelegationTarget,
Expand Down Expand Up @@ -109,7 +109,6 @@ export const Details = ({ tx, account, extendedChain, signatory }: Props) => {

const [isValidatorsOpen, toggleValidators] = useToggle();

const cancelDescription = tx.cancelDescription;
const allValidators = Object.values(validatorsMap);

const transaction = getTransactionFromMultisigTx(tx);
Expand Down Expand Up @@ -158,17 +157,6 @@ export const Details = ({ tx, account, extendedChain, signatory }: Props) => {

return (
<dl className="flex w-full flex-col gap-y-4">
{cancelDescription && (
<div className={DescriptionBlockStyle}>
<FootnoteText as="dt" className="text-text-tertiary">
{t('operation.details.rejectReason')}
</FootnoteText>
<FootnoteText as="dd" className="break-words">
{cancelDescription}
</FootnoteText>
</div>
)}

{proxied && (
<>
<DetailRow label={t('operation.details.senderProxiedWallet')}>
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/pages/Operations/components/LogModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const LogModal = ({ isOpen, onClose, tx, account, connection, contacts }: Props)
const filteredAccountMap = getFilteredAccountsMap(filteredWalletsMap);
const events = getLiveTxEvents(tx.accountId, tx.chainId, tx.callHash, tx.blockCreated, tx.indexCreated);

const { transaction, description, status } = tx;
const { transaction, status } = tx;
const approvals = events.filter((e) => e.status === 'SIGNED');

const asset =
Expand Down Expand Up @@ -111,7 +111,7 @@ const LogModal = ({ isOpen, onClose, tx, account, connection, contacts }: Props)
onClose={onClose}
>
<div className="flex items-center justify-between gap-2 px-4 py-3">
<TransactionTitle className="overflow-hidden" tx={transaction} description={description}>
<TransactionTitle className="overflow-hidden" tx={transaction}>
{asset && amount && <AssetBalance value={amount} asset={asset} className="truncate" />}
</TransactionTitle>

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/pages/Operations/components/Operation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Operation = ({ tx, account }: Props) => {
</FootnoteText>
</div>

<TransactionTitle className="flex-1 overflow-hidden" tx={tx.transaction} description={tx.description} />
<TransactionTitle className="flex-1 overflow-hidden" tx={tx.transaction} />

{asset && amount && (
<div className="w-[160px]">
Expand Down
25 changes: 2 additions & 23 deletions src/renderer/pages/Operations/components/OperationCardDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
isXcmTransaction,
} from '@/entities/transaction';
import { AddressWithExplorers, ExplorersPopover, WalletCardSm, walletModel } from '@/entities/wallet';
import { AddressStyle, DescriptionBlockStyle, InteractionStyle } from '../common/constants';
import { AddressStyle, InteractionStyle } from '../common/constants';
import {
getDelegate,
getDelegationTarget,
Expand Down Expand Up @@ -104,7 +104,7 @@ export const OperationCardDetails = ({ tx, account, extendedChain }: Props) => {
const [isAdvancedShown, toggleAdvanced] = useToggle();
const [isValidatorsOpen, toggleValidators] = useToggle();

const { indexCreated, blockCreated, deposit, depositor, callHash, callData, description, cancelDescription } = tx;
const { indexCreated, blockCreated, deposit, depositor, callHash, callData } = tx;

const transaction = getTransactionFromMultisigTx(tx);
const validatorsMap = useValidatorsMap(api, connection && networkUtils.isLightClientConnection(connection));
Expand Down Expand Up @@ -133,27 +133,6 @@ export const OperationCardDetails = ({ tx, account, extendedChain }: Props) => {

return (
<dl className="flex w-full flex-col gap-y-1">
{description && (
<div className={DescriptionBlockStyle}>
<FootnoteText as="dt" className="text-text-tertiary">
{t('operation.details.description')}
</FootnoteText>
<FootnoteText as="dd" className={cnTw('break-words', valueClass)}>
{description}
</FootnoteText>
</div>
)}
{cancelDescription && (
<div className={DescriptionBlockStyle}>
<FootnoteText as="dt" className="text-text-tertiary">
{t('operation.details.rejectReason')}
</FootnoteText>
<FootnoteText as="dd" className={cnTw('break-words', valueClass)}>
{cancelDescription}
</FootnoteText>
</div>
)}

{account && activeWallet && (
<DetailRow label={t('operation.details.multisigWallet')} className={valueClass}>
<div className="-mr-2">
Expand Down

This file was deleted.

16 changes: 2 additions & 14 deletions src/renderer/pages/Operations/components/modals/RejectTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ import { SigningSwitch } from '@/features/operations';
import { Confirmation } from '../ActionSteps/Confirmation';
import { Submit } from '../ActionSteps/Submit';

import RejectReasonModal from './RejectReasonModal';

type Props = {
tx: MultisigTransactionDS;
account: MultisigAccount;
Expand All @@ -56,15 +54,13 @@ const RejectTx = ({ tx, account, connection }: Props) => {
const apis = useUnit(networkModel.$apis);

const [isModalOpen, setIsModalOpen] = useState(false);
const [isRejectReasonModalOpen, toggleRejectReasonModal] = useToggle();
const [isFeeModalOpen, toggleFeeModal] = useToggle();

const [activeStep, setActiveStep] = useState(Step.CONFIRMATION);

const [rejectTx, setRejectTx] = useState<Transaction>();
const [txPayload, setTxPayload] = useState<Uint8Array>();

const [rejectReason, setRejectReason] = useState('');
const [signature, setSignature] = useState<HexString>();

const transactionTitle = getMultisigSignOperationTitle(
Expand Down Expand Up @@ -172,11 +168,10 @@ const RejectTx = ({ tx, account, connection }: Props) => {
return null;
}

const handleRejectReason = async (reason: string) => {
const handleConfirm = async () => {
const isValid = await validateBalanceForFee(signAccount);

if (isValid) {
setRejectReason(reason);
setActiveStep(Step.SIGNING);
} else {
toggleFeeModal();
Expand Down Expand Up @@ -209,7 +204,7 @@ const RejectTx = ({ tx, account, connection }: Props) => {
connection={connection}
feeTx={rejectTx}
signatory={signAccount}
onSign={toggleRejectReasonModal}
onSign={handleConfirm}
/>
)}
{activeStep === Step.SIGNING && rejectTx && connection.api && signAccount && (
Expand All @@ -230,12 +225,6 @@ const RejectTx = ({ tx, account, connection }: Props) => {
/>
)}

<RejectReasonModal
isOpen={isRejectReasonModalOpen}
onClose={toggleRejectReasonModal}
onSubmit={handleRejectReason}
/>

<OperationResult
isOpen={isFeeModalOpen}
variant="error"
Expand All @@ -256,7 +245,6 @@ const RejectTx = ({ tx, account, connection }: Props) => {
account={signAccount}
txPayload={txPayload}
signature={signature}
rejectReason={rejectReason}
onClose={handleClose}
/>
)}
Expand Down
Loading

0 comments on commit edf1aee

Please sign in to comment.