Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: decoding txs without parameters #1938

Merged
merged 1 commit into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions src/components/tx/DecodedTx/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ describe('DecodedTx', () => {
return Promise.resolve()
})

result.debug()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I left it there.


expect(result.queryByText('transfer')).toBeInTheDocument()
expect(result.queryByText('to(address):')).toBeInTheDocument()
expect(result.queryByText('0x474e...78C8')).toBeInTheDocument()
Expand Down Expand Up @@ -187,4 +185,42 @@ describe('DecodedTx', () => {
expect(result.queryByText('Action 1')).toBeInTheDocument()
expect(result.queryByText('Action 2')).toBeInTheDocument()
})

it('should render a function call without parameters', async () => {
// Wrapped token deposit function
jest.spyOn(gatewayMethods, 'getDecodedData').mockReturnValue(
Promise.resolve({
method: 'deposit',
parameters: [],
}),
)

const result = render(
<DecodedTx
tx={
{
data: {
to: '0xe91d153e0b41518a2ce8dd3d7944fa863463a97d',
value: '5000000000000',
data: '0xd0e30db0',
operation: 0,
baseGas: 0,
gasPrice: 0,
gasToken: '0x0000000000000000000000000000000000000000',
refundReceiver: '0x0000000000000000000000000000000000000000',
nonce: 58,
safeTxGas: 0,
},
} as SafeTransaction
}
/>,
)

await act(() => {
fireEvent.click(result.getByText('Transaction details'))
return Promise.resolve()
})

expect(result.queryByText('deposit')).toBeInTheDocument()
})
})
2 changes: 1 addition & 1 deletion src/components/tx/DecodedTx/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const DecodedTx = ({ tx, txId }: DecodedTxProps): ReactElement | null => {
return getDecodedData(chainId, encodedData)
}, [chainId, encodedData, isEmptyData])

const isMultisend = !!decodedData?.parameters?.[0].valueDecoded
const isMultisend = !!decodedData?.parameters?.[0]?.valueDecoded

const [txDetails, txDetailsError, txDetailsLoading] = useAsync<TransactionDetails>(() => {
if (!txId) return
Expand Down