mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01: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:
parent
be8d832426
commit
578f73b2ea
@ -50,6 +50,16 @@ const GasDetailsItem = ({ userAcknowledgedGasMissing = false }) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const maxPriorityFeePerGasToRender = (
|
||||||
|
maxPriorityFeePerGas ??
|
||||||
|
hexWEIToDecGWEI(transactionData.txParams?.maxPriorityFeePerGas ?? '0x0')
|
||||||
|
).toString();
|
||||||
|
|
||||||
|
const maxFeePerGasToRender = (
|
||||||
|
maxFeePerGas ??
|
||||||
|
hexWEIToDecGWEI(transactionData.txParams?.maxFeePerGas ?? '0x0')
|
||||||
|
).toString();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TransactionDetailItem
|
<TransactionDetailItem
|
||||||
key="gas-details-item"
|
key="gas-details-item"
|
||||||
@ -113,14 +123,8 @@ const GasDetailsItem = ({ userAcknowledgedGasMissing = false }) => {
|
|||||||
}
|
}
|
||||||
subTitle={
|
subTitle={
|
||||||
<GasTiming
|
<GasTiming
|
||||||
maxPriorityFeePerGas={(
|
maxPriorityFeePerGas={maxPriorityFeePerGasToRender}
|
||||||
maxPriorityFeePerGas ||
|
maxFeePerGas={maxFeePerGasToRender}
|
||||||
hexWEIToDecGWEI(transactionData.txParams.maxPriorityFeePerGas)
|
|
||||||
).toString()}
|
|
||||||
maxFeePerGas={(
|
|
||||||
maxFeePerGas ||
|
|
||||||
hexWEIToDecGWEI(transactionData.txParams.maxFeePerGas)
|
|
||||||
).toString()}
|
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -110,4 +110,43 @@ describe('GasDetailsItem', () => {
|
|||||||
expect(screen.queryAllByText('ETH').length).toBeGreaterThan(0);
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user