diff --git a/src/components/transactions/TxDetails/TxData/DecodedData/SingleTxDecoded/index.test.tsx b/src/components/transactions/TxDetails/TxData/DecodedData/SingleTxDecoded/index.test.tsx new file mode 100644 index 0000000000..1141df3261 --- /dev/null +++ b/src/components/transactions/TxDetails/TxData/DecodedData/SingleTxDecoded/index.test.tsx @@ -0,0 +1,111 @@ +import { render } from '@/tests/test-utils' +import SingleTxDecoded from '.' +import { Operation } from '@safe-global/safe-gateway-typescript-sdk' +import { faker } from '@faker-js/faker' +import { parseUnits } from 'ethers' +import { ERC20__factory } from '@/types/contracts' + +describe('SingleTxDecoded', () => { + it('should show native transfers', () => { + const receiver = faker.finance.ethereumAddress() + const result = render( + , + ) + + expect(result.queryByText('native transfer')).not.toBeNull() + }) + + it('should show unknown contract interactions', () => { + const unknownToken = faker.finance.ethereumAddress() + const spender = faker.finance.ethereumAddress() + const result = render( + , + ) + + expect(result.queryByText('Unknown contract interaction')).not.toBeNull() + }) + + it('should show decoded data ', () => { + const unknownToken = faker.finance.ethereumAddress() + const spender = faker.finance.ethereumAddress() + const result = render( + , + ) + + expect(result.queryAllByText('approve')).not.toHaveLength(0) + }) +}) diff --git a/src/components/transactions/TxDetails/TxData/DecodedData/SingleTxDecoded/index.tsx b/src/components/transactions/TxDetails/TxData/DecodedData/SingleTxDecoded/index.tsx index 0bddda1f97..d04b43ca1f 100644 --- a/src/components/transactions/TxDetails/TxData/DecodedData/SingleTxDecoded/index.tsx +++ b/src/components/transactions/TxDetails/TxData/DecodedData/SingleTxDecoded/index.tsx @@ -35,7 +35,7 @@ export const SingleTxDecoded = ({ onChange, }: SingleTxDecodedProps) => { const chain = useCurrentChain() - const isNativeTransfer = tx.value !== '0' && tx.data && isEmptyHexData(tx.data) + const isNativeTransfer = tx.value !== '0' && (!tx.data || isEmptyHexData(tx.data)) const method = tx.dataDecoded?.method || (isNativeTransfer ? 'native transfer' : 'Unknown contract interaction') const { decimals, symbol } = chain?.nativeCurrency || {} const amount = tx.value ? formatVisualAmount(tx.value, decimals) : 0