factory

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GasAdjustment = float64(1.7)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseTxFactory

type BaseTxFactory interface {
	// BuildCosmosTx builds a Cosmos tx with the provided private key and txArgs
	BuildCosmosTx(privKey cryptotypes.PrivKey, txArgs CosmosTxArgs) (authsigning.Tx, error)
	// SignCosmosTx signs a Cosmos transaction with the provided
	// private key and tx builder
	SignCosmosTx(privKey cryptotypes.PrivKey, txBuilder client.TxBuilder) error
	// ExecuteCosmosTx builds, signs and broadcasts a Cosmos tx with the provided private key and txArgs
	ExecuteCosmosTx(privKey cryptotypes.PrivKey, txArgs CosmosTxArgs) (abcitypes.ExecTxResult, error)
	// EncodeTx encodes the provided transaction
	EncodeTx(tx sdktypes.Tx) ([]byte, error)
	// CommitCosmosTx creates, signs and commits a cosmos tx
	// (produces a block with the specified transaction)
	CommitCosmosTx(privKey cryptotypes.PrivKey, txArgs CosmosTxArgs) (abcitypes.ExecTxResult, error)
}

BaseTxFactory is the interface that wraps the common methods to build and broadcast transactions within cosmos chains

type CoreTxFactory

CoreTxFactory is the interface that wraps the methods to build and broadcast cosmos transactions, and also includes module-specific transactions

func New

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

New creates a new IntegrationTxFactory instance

type CosmosTxArgs

type CosmosTxArgs struct {
	// ChainID is the chain's id in cosmos format, e.g. 'evmos_9000-1'
	ChainID string
	// Gas to be used on the tx
	Gas *uint64
	// GasPrice to use on tx
	GasPrice *sdkmath.Int
	// Fees is the fee to be used on the tx (amount and denom)
	Fees sdktypes.Coins
	// FeeGranter is the account address of the fee granter
	FeeGranter sdktypes.AccAddress
	// Msgs slice of messages to include on the tx
	Msgs []sdktypes.Msg
}

CosmosTxArgs contains the params to create a cosmos tx

type DistributionTxFactory

type DistributionTxFactory interface {
	// SetWithdrawAddress is a method to create and broadcast a MsgSetWithdrawAddress
	SetWithdrawAddress(delegatorPriv cryptotypes.PrivKey, withdrawerAddr sdk.AccAddress) error
	// WithdrawDelegationRewards is a method to create and broadcast a MsgWithdrawDelegationRewards
	WithdrawDelegationRewards(delegatorPriv cryptotypes.PrivKey, validatorAddr string) error
	// WithdrawValidatorCommission is a method to create and broadcast a MsgWithdrawValidatorCommission
	WithdrawValidatorCommission(validatorPriv cryptotypes.PrivKey) error
}

type FundTxFactory

type FundTxFactory interface {
	// FundAccount funds the given account with the given amount.
	FundAccount(sender keyring.Key, receiver sdktypes.AccAddress, amount sdktypes.Coins) error
}

FundTxFactory is the interface that wraps the common methods to fund accounts via a bank send transaction

type IntegrationTxFactory

type IntegrationTxFactory struct {
	BaseTxFactory
	DistributionTxFactory
	StakingTxFactory
	FundTxFactory
}

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.

type StakingTxFactory

type StakingTxFactory interface {
	// Delegate is a method to create and execute a MsgDelegate paying always the same fee amount
	// The tx is included in a block and committed in the chain state
	Delegate(delegatorPriv cryptotypes.PrivKey, validatorAddr string, amount sdk.Coin) error
	// CreateValidator is a method to create and broadcast a MsgCreateValidator
	CreateValidator(operatorPriv cryptotypes.PrivKey, pubKey cryptotypes.PubKey, selfDelegation sdk.Coin, description stakingtypes.Description, commission stakingtypes.CommissionRates, minSelfDelegation math.Int) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳