diff --git a/packages/suite/src/components/wallet/TransactionItem/components/Target/index.tsx b/packages/suite/src/components/wallet/TransactionItem/components/Target/index.tsx index 79120295b286..af9c07bd9f13 100644 --- a/packages/suite/src/components/wallet/TransactionItem/components/Target/index.tsx +++ b/packages/suite/src/components/wallet/TransactionItem/components/Target/index.tsx @@ -12,7 +12,7 @@ import TokenTransferAddressLabel from '../TokenTransferAddressLabel'; import TargetAddressLabel from '../TargetAddressLabel'; import BaseTargetLayout from '../BaseTargetLayout'; import { copyToClipboard } from '@suite-utils/dom'; -import { AccountMetadata } from '@suite-types/metadata'; +import { AccountMetadata, MetadataAddPayload } from '@suite-types/metadata'; import { ExtendedMessageDescriptor } from '@suite-types'; const StyledHiddenPlaceholder = styled(props => )` @@ -23,7 +23,11 @@ const StyledHiddenPlaceholder = styled(props => text-overflow: ellipsis; `; -interface TokenTransferProps { +interface MetadataProps { + isMetadataDisabled: boolean; + metadataPayload: MetadataAddPayload; +} +interface TokenTransferProps extends MetadataProps { transfer: ArrayElement; transaction: WalletAccountTransaction; singleRowLayout?: boolean; @@ -34,14 +38,47 @@ interface TokenTransferProps { export const TokenTransfer = ({ transfer, transaction, - + metadataPayload, + isMetadataDisabled, ...baseLayoutProps }: TokenTransferProps) => { + console.log('transfer', transfer); + console.log('transaction', transaction); + const operation = getTxOperation(transfer); return ( } + addressLabel={ + + } + // todo: items in dropdown? + // dropdownOptions={[ + // { + // callback: () => { + // if (!target?.addresses) { + // // probably should not happen? + // return addNotification({ + // type: 'error', + // error: 'There is nothing to copy', + // }); + // } + // const result = copyToClipboard(target.addresses.join(), null); + // if (typeof result === 'string') { + // return addNotification({ type: 'error', error: result }); + // } + // return addNotification({ type: 'copy-to-clipboard' }); + // }, + // label: , + // key: 'copy-address', + // }, + // ]} + payload={metadataPayload} + /> + } amount={ !baseLayoutProps.singleRowLayout && ( @@ -54,7 +91,7 @@ export const TokenTransfer = ({ ); }; -interface TargetProps { +interface TargetProps extends MetadataProps { target: ArrayElement; transaction: WalletAccountTransaction; singleRowLayout?: boolean; @@ -69,21 +106,20 @@ export const Target = ({ target, transaction, accountMetadata, - accountKey, - isActionDisabled, + metadataPayload, + isMetadataDisabled, ...baseLayoutProps }: TargetProps) => { const targetAmount = getTargetAmount(target, transaction); const operation = getTxOperation(transaction); const { addNotification } = useActions({ addNotification: notificationActions.addToast }); - const targetMetadata = accountMetadata?.outputLabels?.[transaction.txid]?.[target.n]; return ( } amount={ diff --git a/packages/suite/src/components/wallet/TransactionItem/index.tsx b/packages/suite/src/components/wallet/TransactionItem/index.tsx index 131e8dc59088..c7739f2b777b 100644 --- a/packages/suite/src/components/wallet/TransactionItem/index.tsx +++ b/packages/suite/src/components/wallet/TransactionItem/index.tsx @@ -281,7 +281,17 @@ const TransactionItem = React.memo( } // if list of targets is expanded we won't get last item here accountMetadata={accountMetadata} accountKey={accountKey} - isActionDisabled={isActionDisabled} + isMetadataDisabled={!!isActionDisabled} + metadataPayload={{ + type: 'outputLabel', + accountKey, + txid: transaction.txid, + outputIndex: t.payload.n, + defaultValue: `${transaction.txid}-${t.payload.n}`, + value: accountMetadata?.outputLabels?.[ + transaction.txid + ]?.[t.payload.n], + }} /> ) : ( )}