Skip to content

Commit

Permalink
fix: goerli support for Cancun
Browse files Browse the repository at this point in the history
  • Loading branch information
Wodann committed Feb 12, 2024
1 parent 015e31f commit 191062d
Showing 1 changed file with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
TracingMessage,
SuccessReason,
IntervalRange,
Eip4844SignedTransaction,
} from "@ignored/edr";
import { fromBigIntLike, toHex } from "../../../util/bigint";
import { HardforkName, hardforkGte } from "../../../util/hardforks";
Expand Down Expand Up @@ -672,10 +673,33 @@ export function edrSignedTransactionToEthereumJSTypedTransaction(
transaction:
| LegacySignedTransaction
| Eip2930SignedTransaction
| Eip1559SignedTransaction,
| Eip1559SignedTransaction
| Eip4844SignedTransaction,
caller: Address
): TypedTransaction {
if (isEip1559SignedTransaction(transaction)) {
if (isEip4844SignedTransaction(transaction)) {
// TODO: https://github.com/NomicFoundation/edr/issues/289
// Add proper support for EIP-4844
const fakeTransaction = new FakeSenderEIP1559Transaction(caller, {
maxPriorityFeePerGas: transaction.maxPriorityFeePerGas,
maxFeePerGas: transaction.maxFeePerGas,
chainId: transaction.chainId,
accessList: transaction.accessList.map((value, _index, _array) => {
return [value.address, value.storageKeys];
}),
nonce: transaction.nonce,
gasLimit: transaction.gasLimit,
to: transaction.to,
value: transaction.value,
data: transaction.input,
v: BigInt(transaction.oddYParity),
r: transaction.r,
s: transaction.s,
type: 3,
});

return fakeTransaction;
} else if (isEip1559SignedTransaction(transaction)) {
return new FakeSenderEIP1559Transaction(caller, {
maxPriorityFeePerGas: transaction.maxPriorityFeePerGas,
maxFeePerGas: transaction.maxFeePerGas,
Expand Down Expand Up @@ -730,6 +754,7 @@ function isLegacySignedTransaction(
| LegacySignedTransaction
| Eip2930SignedTransaction
| Eip1559SignedTransaction
| Eip4844SignedTransaction
): transaction is LegacySignedTransaction {
// Only need to check for one unique field
return "signature" in transaction;
Expand All @@ -740,23 +765,38 @@ function isEip1559SignedTransaction(
| LegacySignedTransaction
| Eip2930SignedTransaction
| Eip1559SignedTransaction
| Eip4844SignedTransaction
): transaction is Eip1559SignedTransaction {
// Only need to check for one unique field
return "maxPriorityFeePerGas" in transaction;
return (
!isEip4844SignedTransaction(transaction) &&
"maxPriorityFeePerGas" in transaction
);
}

function isEip2930SignedTransaction(
transaction:
| LegacySignedTransaction
| Eip2930SignedTransaction
| Eip1559SignedTransaction
| Eip4844SignedTransaction
): transaction is Eip2930SignedTransaction {
// Only need to check for one unique field
return (
!isEip1559SignedTransaction(transaction) && "oddYParity" in transaction
);
}

function isEip4844SignedTransaction(
transaction:
| LegacySignedTransaction
| Eip2930SignedTransaction
| Eip1559SignedTransaction
| Eip4844SignedTransaction
): transaction is Eip4844SignedTransaction {
return "maxfeePerBlobGas" in transaction;
}

export function edrRpcDebugTraceToHardhat(
rpcDebugTrace: DebugTraceResult
): RpcDebugTraceOutput {
Expand Down

0 comments on commit 191062d

Please sign in to comment.