Files
explore/ui/userOp/UserOpSubHeading.tsx
enochleeandGitHub 4c78f91771 display copy button for tx hashes in relevant components (#3031)
* default TxEntity.noCopy to false
remove redundant noCopy=false
restore noCopy for tx hashes in this components

This commit has no essential change, order than defaulting noCopy for TxEntity to false, and reversing the use of the prop

* To reflect new default of TxEntity and UserOpEntity

Updated tests to with-no-copy from with-copy
remove outdated screenshots
Regenerate screenshot for new default

* display copy button for tx hash

In the following pages:
/txs, /internal-txs
/token-transfers
/address/txs, /address/token-transfers(tab)
/deposits, /withdrawals
/batches[id]/txs(tab)
/advanced-filter

* update snapshots

* update snapshots
2025-10-21 17:28:01 +02:00

87 lines
3.2 KiB
TypeScript

import { Flex } from '@chakra-ui/react';
// import type { UseQueryResult } from '@tanstack/react-query';
import React from 'react';
// import type { UserOp } from 'types/api/userOps';
import config from 'configs/app';
// import type { ResourceError } from 'lib/api/resources';
import useApiQuery from 'lib/api/useApiQuery';
import { useMultichainContext } from 'lib/contexts/multichain';
import { TX_INTERPRETATION } from 'stubs/txInterpretation';
import { Link } from 'toolkit/chakra/link';
import { TX_ACTIONS_BLOCK_ID } from 'ui/shared/DetailedInfo/DetailedInfoActionsWrapper';
import UserOpEntity from 'ui/shared/entities/userOp/UserOpEntity';
import TxInterpretation from 'ui/shared/tx/interpretation/TxInterpretation';
type Props = {
hash: string;
// userOpQuery: UseQueryResult<UserOp, ResourceError<unknown>>;
};
const UserOpSubHeading = ({ hash }: Props) => {
const multichainContext = useMultichainContext();
const hasInterpretationFeature = config.features.txInterpretation.isEnabled;
const txInterpretationQuery = useApiQuery('general:user_op_interpretation', {
pathParams: { hash },
queryOptions: {
enabled: Boolean(hash) && hasInterpretationFeature,
placeholderData: TX_INTERPRETATION,
},
});
const hasInterpretation = hasInterpretationFeature &&
(txInterpretationQuery.isPlaceholderData || Boolean(txInterpretationQuery.data?.data.summaries.length));
const hasViewAllInterpretationsLink =
!txInterpretationQuery.isPlaceholderData && txInterpretationQuery.data?.data.summaries && txInterpretationQuery.data?.data.summaries.length > 1;
if (hasInterpretation) {
return (
<Flex mr={{ base: 0, lg: 6 }} flexWrap="wrap" alignItems="center">
<TxInterpretation
summary={ txInterpretationQuery.data?.data.summaries[0] }
isLoading={ txInterpretationQuery.isPlaceholderData }
fontSize="lg"
mr={ hasViewAllInterpretationsLink ? 3 : 0 }
chainData={ multichainContext?.chain }
/>
{ hasViewAllInterpretationsLink &&
<Link href={ `#${ TX_ACTIONS_BLOCK_ID }` }>View all</Link> }
</Flex>
);
// fallback will be added later
// } else if (hasInterpretationFeature && userOpQuery.data?.decoded_call_data.method_call && userOpQuery.data?.sender && userOpQuery.data?.to) {
// return (
// <TxInterpretation
// summary={{
// summary_template: `{sender_hash} called {method} on {receiver_hash}`,
// summary_template_variables: {
// sender_hash: {
// type: 'address',
// value: txQuery.data.from,
// },
// method: {
// type: 'method',
// value: txQuery.data.method,
// },
// receiver_hash: {
// type: 'address',
// value: txQuery.data.to,
// },
// },
// }}
// isLoading={ txQuery.isPlaceholderData }
// fontSize="lg"
// />
// );
} else {
return <UserOpEntity hash={ hash } noLink variant="subheading" chain={ multichainContext?.chain }/>;
}
};
export default UserOpSubHeading;