Files

44 lines
1.0 KiB
Go

// (c) 2023, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package predicate
import (
"math/big"
"github.com/luxfi/evm/core/types"
"github.com/luxfi/evm/utils"
"github.com/luxfi/geth/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,
})
}