Skip to content

Commit

Permalink
Make sure EIP-1559 transactions have the right fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin Roberts committed Jul 5, 2021
1 parent 3ed4d3a commit ae0c09d
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions eth/filters/dropped_tx_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,16 @@ type rejectNotification struct {
// newRPCTransaction returns a transaction that will serialize to the RPC
// representation, with the given location metadata set (if available).
func newRPCPendingTransaction(tx *types.Transaction) *ethapi.RPCTransaction {
if tx == nil {
return nil
}
var signer types.Signer = types.FrontierSigner{}
var signer types.Signer
if tx.Protected() {
signer = types.NewEIP155Signer(tx.ChainId())
signer = types.LatestSignerForChainID(tx.ChainId())
} else {
signer = types.HomesteadSigner{}
}
from, _ := types.Sender(signer, tx)
v, r, s := tx.RawSignatureValues()

result := &ethapi.RPCTransaction{
Type: hexutil.Uint64(tx.Type()),
From: from,
Gas: hexutil.Uint64(tx.Gas()),
GasPrice: (*hexutil.Big)(tx.GasPrice()),
Expand All @@ -55,6 +54,20 @@ func newRPCPendingTransaction(tx *types.Transaction) *ethapi.RPCTransaction {
R: (*hexutil.Big)(r),
S: (*hexutil.Big)(s),
}
switch tx.Type() {
case types.AccessListTxType:
al := tx.AccessList()
result.Accesses = &al
result.ChainID = (*hexutil.Big)(tx.ChainId())
case types.DynamicFeeTxType:
al := tx.AccessList()
result.Accesses = &al
result.ChainID = (*hexutil.Big)(tx.ChainId())
result.GasFeeCap = (*hexutil.Big)(tx.GasFeeCap())
result.GasTipCap = (*hexutil.Big)(tx.GasTipCap())
// if the transaction has been mined, compute the effective gas price
result.GasPrice = nil
}
return result
}

Expand Down

0 comments on commit ae0c09d

Please sign in to comment.