Files
evm/predicate/predicate_tx.go
2024-01-03 09:44:09 +01:00

45 lines
1.1 KiB
Go

// (c) 2023-2024, Lux Partners Limited. All rights reserved.
// See the file LICENSE for licensing terms.
package predicate
import (
"math/big"
"github.com/luxdefi/evm/core/types"
"github.com/luxdefi/evm/utils"
"github.com/ethereum/go-ethereum/common"
)
// NewPredicateTx returns a transaction with the predicateAddress/predicateBytes tuple
// packed and added to the access list of the transaction.
func NewPredicateTx(
chainID *big.Int,
nonce uint64,
to *common.Address,
gas uint64,
gasFeeCap *big.Int,
gasTipCap *big.Int,
value *big.Int,
data []byte,
accessList types.AccessList,
predicateAddress common.Address,
predicateBytes []byte,
) *types.Transaction {
accessList = append(accessList, types.AccessTuple{
Address: predicateAddress,
StorageKeys: utils.BytesToHashSlice(PackPredicate(predicateBytes)),
})
return types.NewTx(&types.DynamicFeeTx{
ChainID: chainID,
Nonce: nonce,
To: to,
Gas: gas,
GasFeeCap: gasFeeCap,
GasTipCap: gasTipCap,
Value: value,
Data: data,
AccessList: accessList,
})
}