Add max fee per gas/max priority fee per gas

This commit is contained in:
Willian Mitsuda 2021-07-26 20:47:25 -03:00
parent bc8bf0cf93
commit e967abf61e
4 changed files with 60 additions and 0 deletions

View File

@ -92,7 +92,10 @@ const Transaction: React.FC = () => {
value: _response.value, value: _response.value,
tokenTransfers, tokenTransfers,
tokenMetas, tokenMetas,
type: _response.type ?? 0,
fee: _response.gasPrice!.mul(_receipt.gasUsed), fee: _response.gasPrice!.mul(_receipt.gasUsed),
maxFeePerGas: _response.maxFeePerGas,
maxPriorityFeePerGas: _response.maxPriorityFeePerGas,
gasPrice: _response.gasPrice!, gasPrice: _response.gasPrice!,
gasLimit: _response.gasLimit, gasLimit: _response.gasLimit,
gasUsed: _receipt.gasUsed, gasUsed: _receipt.gasUsed,

View File

@ -0,0 +1,30 @@
import React from "react";
type TransactionTypeProps = {
type: number;
};
const TransactionType: React.FC<TransactionTypeProps> = ({ type }) => {
let description: string;
switch (type) {
case 0:
description = "legacy";
break;
case 1:
description = "EIP-2930";
break;
case 2:
description = "EIP-1559";
break;
default:
description = "unknown";
}
return (
<span>
{type} <span className="font-bold">({description})</span>
</span>
);
};
export default React.memo(TransactionType);

View File

@ -15,6 +15,7 @@ import Copy from "../components/Copy";
import Timestamp from "../components/Timestamp"; import Timestamp from "../components/Timestamp";
import InternalTransactionOperation from "../components/InternalTransactionOperation"; import InternalTransactionOperation from "../components/InternalTransactionOperation";
import MethodName from "../components/MethodName"; import MethodName from "../components/MethodName";
import TransactionType from "../components/TransactionType";
import GasValue from "../components/GasValue"; import GasValue from "../components/GasValue";
import FormattedBalance from "../components/FormattedBalance"; import FormattedBalance from "../components/FormattedBalance";
import TokenTransferItem from "../TokenTransferItem"; import TokenTransferItem from "../TokenTransferItem";
@ -130,6 +131,29 @@ const Details: React.FC<DetailsProps> = ({
{ethers.utils.formatEther(txData.value)} Ether {ethers.utils.formatEther(txData.value)} Ether
</span> </span>
</InfoRow> </InfoRow>
<InfoRow title="Type (EIP-2718)">
<TransactionType type={txData.type} />
</InfoRow>
{txData.type === 2 && (
<>
<InfoRow title="Max Fee Per Gas">
<span>
<FormattedBalance value={txData.maxFeePerGas!} /> Ether (
<FormattedBalance value={txData.maxFeePerGas!} decimals={9} /> Gwei)
</span>
</InfoRow>
<InfoRow title="Max Priority Fee Per Gas">
<span>
<FormattedBalance value={txData.maxPriorityFeePerGas!} /> Ether (
<FormattedBalance
value={txData.maxPriorityFeePerGas!}
decimals={9}
/>{" "}
Gwei)
</span>
</InfoRow>
</>
)}
<InfoRow title="Transaction Fee"> <InfoRow title="Transaction Fee">
<FormattedBalance value={txData.fee} /> Ether <FormattedBalance value={txData.fee} /> Ether
</InfoRow> </InfoRow>

View File

@ -49,6 +49,9 @@ export type TransactionData = {
value: BigNumber; value: BigNumber;
tokenTransfers: TokenTransfer[]; tokenTransfers: TokenTransfer[];
tokenMetas: TokenMetas; tokenMetas: TokenMetas;
type: number;
maxFeePerGas?: BigNumber | undefined;
maxPriorityFeePerGas?: BigNumber | undefined;
fee: BigNumber; fee: BigNumber;
gasPrice: BigNumber; gasPrice: BigNumber;
gasLimit: BigNumber; gasLimit: BigNumber;