factory

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2025 License: Apache-2.0 Imports: 27 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckError

func CheckError(err error, logCheckArgs testutil.LogCheckArgs) error

CheckError is a helper function to check if the error is the expected one.

func GenerateContractCallArgs

func GenerateContractCallArgs(
	callArgs testutiltypes.CallArgs,
) ([]byte, error)

GenerateContractCallArgs generates the txArgs for a contract call.

Types

type IntegrationTxFactory

type IntegrationTxFactory struct {
	basefactory.CoreTxFactory
	// contains filtered or unexported fields
}

IntegrationTxFactory is a helper struct to build and broadcast transactions to the network on integration tests. This is to simulate the behavior of a real user.

func (*IntegrationTxFactory) CallContractAndCheckLogs

CallContractAndCheckLogs is a helper function to call a contract and check the logs using the integration test utilities.

It returns the Cosmos Tx response, the decoded Ethereum Tx response and an error. This error value is nil, if the expected logs are found and the VM error is the expected one, should one be expected.

func (*IntegrationTxFactory) DeployContract

func (tf *IntegrationTxFactory) DeployContract(
	priv cryptotypes.PrivKey,
	txArgs evmtypes.EvmTxArgs,
	deploymentData testutiltypes.ContractDeploymentData,
) (common.Address, error)

DeployContract deploys a contract with the provided private key, compiled contract data and constructor arguments. TxArgs Input and Nonce fields are overwritten.

func (*IntegrationTxFactory) EstimateGasLimit

func (tf *IntegrationTxFactory) EstimateGasLimit(from *common.Address, txArgs *evmtypes.EvmTxArgs) (uint64, error)

EstimateGasLimit estimates the gas limit for a tx with the provided address and txArgs

func (*IntegrationTxFactory) ExecuteContractCall

func (tf *IntegrationTxFactory) ExecuteContractCall(privKey cryptotypes.PrivKey, txArgs evmtypes.EvmTxArgs, callArgs testutiltypes.CallArgs) (abcitypes.ExecTxResult, error)

ExecuteContractCall executes a contract call with the provided private key.

func (*IntegrationTxFactory) ExecuteEthTx

ExecuteEthTx executes an Ethereum transaction - contract call with the provided private key and txArgs It first builds a MsgEthereumTx and then broadcasts it to the network.

func (*IntegrationTxFactory) GenerateDefaultTxTypeArgs

func (tf *IntegrationTxFactory) GenerateDefaultTxTypeArgs(sender common.Address, txType int) (evmtypes.EvmTxArgs, error)

func (*IntegrationTxFactory) GenerateDeployContractArgs

func (tf *IntegrationTxFactory) GenerateDeployContractArgs(
	from common.Address,
	txArgs evmtypes.EvmTxArgs,
	deploymentData testutiltypes.ContractDeploymentData,
) (evmtypes.EvmTxArgs, error)

GenerateDeployContractArgs generates the txArgs for a contract deployment.

func (*IntegrationTxFactory) GenerateGethCoreMsg

func (tf *IntegrationTxFactory) GenerateGethCoreMsg(
	privKey cryptotypes.PrivKey,
	txArgs evmtypes.EvmTxArgs,
) (*core.Message, error)

GenerateGethCoreMsg creates a new GethCoreMsg with the provided arguments.

func (*IntegrationTxFactory) GenerateMsgEthereumTx

func (tf *IntegrationTxFactory) GenerateMsgEthereumTx(
	privKey cryptotypes.PrivKey,
	txArgs evmtypes.EvmTxArgs,
) (evmtypes.MsgEthereumTx, error)

GenerateMsgEthereumTx creates a new MsgEthereumTx with the provided arguments. If any of the arguments are not provided, they will be populated with default values.

func (*IntegrationTxFactory) GenerateSignedEthTx

func (tf *IntegrationTxFactory) GenerateSignedEthTx(privKey cryptotypes.PrivKey, txArgs evmtypes.EvmTxArgs) (signing.Tx, error)

GenerateSignedEthTx generates an Ethereum tx with the provided private key and txArgs but does not broadcast it.

func (*IntegrationTxFactory) GenerateSignedEthTxWithChainID

func (tf *IntegrationTxFactory) GenerateSignedEthTxWithChainID(privKey cryptotypes.PrivKey, txArgs evmtypes.EvmTxArgs, eip155ChainID *big.Int) (signing.Tx, error)

GenerateSignedEthTxWithChainID generates an Ethereum tx with the provided private key, txArgs, and Chain ID, but does not broadcast it.

func (*IntegrationTxFactory) GenerateSignedMsgEthereumTx

func (tf *IntegrationTxFactory) GenerateSignedMsgEthereumTx(privKey cryptotypes.PrivKey, txArgs evmtypes.EvmTxArgs) (evmtypes.MsgEthereumTx, error)

GenerateSignedMsgEthereumTx generates an MsgEthereumTx signed with the provided private key and txArgs.

func (*IntegrationTxFactory) GenerateSignedMsgEthereumTxWithChainID

func (tf *IntegrationTxFactory) GenerateSignedMsgEthereumTxWithChainID(privKey cryptotypes.PrivKey, txArgs evmtypes.EvmTxArgs, eip155ChainID *big.Int) (evmtypes.MsgEthereumTx, error)

GenerateSignedMsgEthereumTxWithChainID generates an MsgEthereumTx signed with the provided private key, txArgs, and Chain ID.

func (*IntegrationTxFactory) GetEvmTransactionResponseFromTxResult

func (tf *IntegrationTxFactory) GetEvmTransactionResponseFromTxResult(
	txResult abcitypes.ExecTxResult,
) (*evmtypes.MsgEthereumTxResponse, error)

GetEvmTransactionResponseFromTxResult returns the MsgEthereumTxResponse from the provided txResult.

func (*IntegrationTxFactory) SignMsgEthereumTx

func (tf *IntegrationTxFactory) SignMsgEthereumTx(privKey cryptotypes.PrivKey, msgEthereumTx evmtypes.MsgEthereumTx) (evmtypes.MsgEthereumTx, error)

SignMsgEthereumTx signs a MsgEthereumTx with the provided private key and uses the chain's ID for convenience.

func (*IntegrationTxFactory) SignMsgEthereumTxWithChainID

func (tf *IntegrationTxFactory) SignMsgEthereumTxWithChainID(privKey cryptotypes.PrivKey, msgEthereumTx evmtypes.MsgEthereumTx, eip155ChainID *big.Int) (evmtypes.MsgEthereumTx, error)

SignMsgEthereumTxWithChainID signs a MsgEthereumTx with the provided private key and chainID.

type TxFactory

type TxFactory interface {
	basefactory.CoreTxFactory

	// GenerateDefaultTxTypeArgs generates a default ETH tx args for the desired tx type
	GenerateDefaultTxTypeArgs(sender common.Address, txType int) (evmtypes.EvmTxArgs, error)
	// GenerateSignedEthTx generates an Ethereum tx with the provided private key and txArgs but does not broadcast it.
	GenerateSignedEthTx(privKey cryptotypes.PrivKey, txArgs evmtypes.EvmTxArgs) (signing.Tx, error)
	// GenerateSignedEthTxWithChainID generates an Ethereum tx with the provided private key, txArgs, and Chain ID, but does not broadcast it.
	GenerateSignedEthTxWithChainID(privKey cryptotypes.PrivKey, txArgs evmtypes.EvmTxArgs, eip155ChainID *big.Int) (signing.Tx, error)
	// GenerateSignedMsgEthereumTx generates an MsgEthereumTx signed with the provided private key and txArgs.
	GenerateSignedMsgEthereumTx(privKey cryptotypes.PrivKey, txArgs evmtypes.EvmTxArgs) (evmtypes.MsgEthereumTx, error)
	// GenerateSignedMsgEthereumTxWithChainID generates an MsgEthereumTx signed with the provided private key, txArgs, and Chain ID.
	GenerateSignedMsgEthereumTxWithChainID(privKey cryptotypes.PrivKey, txArgs evmtypes.EvmTxArgs, eip155ChainID *big.Int) (evmtypes.MsgEthereumTx, error)

	// SignMsgEthereumTx signs a MsgEthereumTx with the provided private key and uses the chain's ID for convenience.
	SignMsgEthereumTx(privKey cryptotypes.PrivKey, msgEthereumTx evmtypes.MsgEthereumTx) (evmtypes.MsgEthereumTx, error)
	// SignMsgEthereumTxWithChainID signs a MsgEthereumTx with the provided private key and chainID.
	SignMsgEthereumTxWithChainID(privKey cryptotypes.PrivKey, msgEthereumTx evmtypes.MsgEthereumTx, eip155ChainID *big.Int) (evmtypes.MsgEthereumTx, error)

	// ExecuteEthTx builds, signs and broadcasts an Ethereum tx with the provided private key and txArgs.
	// If the txArgs are not provided, they will be populated with default values or gas estimations.
	ExecuteEthTx(privKey cryptotypes.PrivKey, txArgs evmtypes.EvmTxArgs) (abcitypes.ExecTxResult, error)
	// ExecuteContractCall executes a contract call with the provided private key
	ExecuteContractCall(privKey cryptotypes.PrivKey, txArgs evmtypes.EvmTxArgs, callArgs types.CallArgs) (abcitypes.ExecTxResult, error)
	// DeployContract deploys a contract with the provided private key,
	// compiled contract data and constructor arguments
	DeployContract(privKey cryptotypes.PrivKey, txArgs evmtypes.EvmTxArgs, deploymentData types.ContractDeploymentData) (common.Address, error)
	// CallContractAndCheckLogs is a helper function to call a contract and check the logs using
	// the integration test utilities.
	//
	// It returns the Cosmos Tx response, the decoded Ethereum Tx response and an error. This error value
	// is nil, if the expected logs are found and the VM error is the expected one, should one be expected.
	CallContractAndCheckLogs(privKey cryptotypes.PrivKey, txArgs evmtypes.EvmTxArgs, callArgs types.CallArgs, logCheckArgs testutil.LogCheckArgs) (abcitypes.ExecTxResult, *evmtypes.MsgEthereumTxResponse, error)
	// GenerateDeployContractArgs generates the txArgs for a contract deployment.
	GenerateDeployContractArgs(from common.Address, txArgs evmtypes.EvmTxArgs, deploymentData types.ContractDeploymentData) (evmtypes.EvmTxArgs, error)
	// GenerateMsgEthereumTx creates a new MsgEthereumTx with the provided arguments.
	GenerateMsgEthereumTx(privKey cryptotypes.PrivKey, txArgs evmtypes.EvmTxArgs) (evmtypes.MsgEthereumTx, error)
	// GenerateGethCoreMsg creates a new GethCoreMsg with the provided arguments.
	GenerateGethCoreMsg(privKey cryptotypes.PrivKey, txArgs evmtypes.EvmTxArgs) (*core.Message, error)
	// EstimateGasLimit estimates the gas limit for a tx with the provided address and txArgs
	EstimateGasLimit(from *common.Address, txArgs *evmtypes.EvmTxArgs) (uint64, error)
	// GetEvmTransactionResponseFromTxResult returns the MsgEthereumTxResponse from the provided txResult
	GetEvmTransactionResponseFromTxResult(txResult abcitypes.ExecTxResult) (*evmtypes.MsgEthereumTxResponse, error)
}

TxFactory defines a struct that can build and broadcast transactions for the Cosmos EVM network. Methods are organized by build sign and broadcast type methods.

func New

func New(
	network network.Network,
	grpcHandler grpc.Handler,
) TxFactory

New creates a new IntegrationTxFactory instance

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL