1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +02:00

Ensure the GasDetailsItem component can handle a tx with a maxPriorityFee of 0 (#19102)

* Ensure the GasDetailsItem component can handle a tx with a maxPriorityFee of 0

* Clean up code

* Update ui/components/app/gas-details-item/gas-details-item.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

---------

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
This commit is contained in:
Dan J Miller 2023-05-12 12:31:15 -02:30 committed by GitHub
parent be8d832426
commit 578f73b2ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 8 deletions

View File

@ -50,6 +50,16 @@ const GasDetailsItem = ({ userAcknowledgedGasMissing = false }) => {
return null;
}
const maxPriorityFeePerGasToRender = (
maxPriorityFeePerGas ??
hexWEIToDecGWEI(transactionData.txParams?.maxPriorityFeePerGas ?? '0x0')
).toString();
const maxFeePerGasToRender = (
maxFeePerGas ??
hexWEIToDecGWEI(transactionData.txParams?.maxFeePerGas ?? '0x0')
).toString();
return (
<TransactionDetailItem
key="gas-details-item"
@ -113,14 +123,8 @@ const GasDetailsItem = ({ userAcknowledgedGasMissing = false }) => {
}
subTitle={
<GasTiming
maxPriorityFeePerGas={(
maxPriorityFeePerGas ||
hexWEIToDecGWEI(transactionData.txParams.maxPriorityFeePerGas)
).toString()}
maxFeePerGas={(
maxFeePerGas ||
hexWEIToDecGWEI(transactionData.txParams.maxFeePerGas)
).toString()}
maxPriorityFeePerGas={maxPriorityFeePerGasToRender}
maxFeePerGas={maxFeePerGasToRender}
/>
}
/>

View File

@ -110,4 +110,43 @@ describe('GasDetailsItem', () => {
expect(screen.queryAllByText('ETH').length).toBeGreaterThan(0);
});
});
it('should render gas fee details if maxPriorityFeePerGas is 0', async () => {
render({
contextProps: {
transaction: {
txParams: {
gas: '0x5208',
maxFeePerGas: '0x59682f10',
maxPriorityFeePerGas: '0',
},
simulationFails: false,
userFeeLevel: 'low',
},
},
});
await waitFor(() => {
expect(screen.queryAllByTitle('0.0000315 ETH').length).toBeGreaterThan(0);
expect(screen.queryAllByText('ETH').length).toBeGreaterThan(0);
});
});
it('should render gas fee details if maxPriorityFeePerGas is undefined', async () => {
render({
contextProps: {
transaction: {
txParams: {
gas: '0x5208',
maxFeePerGas: '0x59682f10',
},
simulationFails: false,
userFeeLevel: 'low',
},
},
});
await waitFor(() => {
expect(screen.queryAllByTitle('0.0000315 ETH').length).toBeGreaterThan(0);
expect(screen.queryAllByText('ETH').length).toBeGreaterThan(0);
});
});
});