forked from MariusVanDerWijden/tx-fuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tx1559.go
31 lines (28 loc) · 681 Bytes
/
tx1559.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package txfuzz
import (
"math/big"
"github.com/ethereum/go-ethereum/core/types"
)
// To1559Tx turns a normal transaction to a DynamicFeeTx.
func To1559Tx(tx *types.Transaction, chainID, tip, feeCap, gasPrice *big.Int, al *types.AccessList) *types.Transaction {
v, r, s := tx.RawSignatureValues()
list := tx.AccessList()
if al != nil {
list = *al
}
newTx := types.DynamicFeeTx{
ChainID: chainID,
Nonce: tx.Nonce(),
GasTipCap: tip,
GasFeeCap: feeCap,
Gas: tx.Gas(),
To: tx.To(),
Value: tx.Value(),
Data: tx.Data(),
AccessList: list,
V: v,
R: r,
S: s,
}
return types.NewTx(&newTx)
}