Documentation
¶
Index ¶
- Variables
- func BroadcastTxBytes(app *app.XOSD, txEncoder sdk.TxEncoder, tx sdk.Tx) (abci.ExecTxResult, error)
- func CheckEthTx(exampleApp *app.XOSD, priv cryptotypes.PrivKey, msgs ...sdk.Msg) (abci.ResponseCheckTx, error)
- func CheckEthTxResponse(r abci.ExecTxResult, cdc codec.Codec) ([]*evmtypes.MsgEthereumTxResponse, error)
- func CheckTx(ctx sdk.Context, exampleApp *app.XOSD, priv cryptotypes.PrivKey, ...) (abci.ResponseCheckTx, error)
- func Commit(ctx sdk.Context, app *app.XOSD, t time.Duration, vs *cmttypes.ValidatorSet) (sdk.Context, error)
- func CommitAndCreateNewCtx(ctx sdk.Context, app *app.XOSD, t time.Duration, vs *cmttypes.ValidatorSet) (sdk.Context, error)
- func Delegate(ctx sdk.Context, appEvmos *exampleapp.XOSD, priv *ethsecp256k1.PrivKey, ...) (abci.ExecTxResult, error)
- func DeliverEthTx(exampleApp *app.XOSD, priv cryptotypes.PrivKey, msgs ...sdk.Msg) (abci.ExecTxResult, error)
- func DeliverEthTxWithoutCheck(exampleApp *app.XOSD, priv cryptotypes.PrivKey, msgs ...sdk.Msg) (abci.ExecTxResult, error)
- func DeliverTx(ctx sdk.Context, exampleApp *app.XOSD, priv cryptotypes.PrivKey, ...) (abci.ExecTxResult, error)
- func DeployContract(ctx sdk.Context, app *exampleapp.XOSD, priv cryptotypes.PrivKey, ...) (common.Address, error)
- func DeployContractWithFactory(ctx sdk.Context, exampleApp *exampleapp.XOSD, priv cryptotypes.PrivKey, ...) (common.Address, abci.ExecTxResult, error)
- func EthSetup(isCheckTx bool, chainID string, ...) *exampleapp.XOSD
- func EthSetupWithDB(isCheckTx bool, chainID string, ...) *exampleapp.XOSD
- func FundAccount(ctx sdk.Context, bankKeeper bankkeeper.Keeper, addr sdk.AccAddress, ...) error
- func FundAccountWithBaseDenom(ctx sdk.Context, bankKeeper bankkeeper.Keeper, addr sdk.AccAddress, ...) error
- func FundModuleAccount(ctx sdk.Context, bankKeeper bankkeeper.Keeper, recipientMod string, ...) error
- func NewTestGenesisState(app *exampleapp.XOSD) cosmosevmtypes.GenesisState
- func SubmitProposal(ctx sdk.Context, appEvmos *exampleapp.XOSD, pk *ethsecp256k1.PrivKey, ...) (id uint64, err error)
- func Vote(ctx sdk.Context, appEvmos *exampleapp.XOSD, priv *ethsecp256k1.PrivKey, ...) (abci.ExecTxResult, error)
- type ContractArgs
- type ContractCallArgs
Constants ¶
This section is empty.
Variables ¶
var ( // ExampleMinGasPrices defines 20B related to atto units as the minimum gas price value on the fee market module. // See https://commonwealth.im/evmos/discussion/5073-global-min-gas-price-value-for-cosmos-sdk-and-evm-transaction-choosing-a-value for reference ExampleMinGasPrices = math.LegacyNewDec(20_000_000_000) // ExampleMinGasMultiplier defines the min gas multiplier value on the fee market module. // 50% of the leftover gas will be refunded ExampleMinGasMultiplier = math.LegacyNewDecWithPrec(5, 1) )
var DefaultConsensusParams = &tmproto.ConsensusParams{ Block: &tmproto.BlockParams{ MaxBytes: 200000, MaxGas: -1, }, Evidence: &tmproto.EvidenceParams{ MaxAgeNumBlocks: 302400, MaxAgeDuration: 504 * time.Hour, MaxBytes: 10000, }, Validator: &tmproto.ValidatorParams{ PubKeyTypes: []string{ cmtypes.ABCIPubKeyTypeEd25519, }, }, }
DefaultConsensusParams defines the default Tendermint consensus params used in Cosmos EVM testing.
var EthDefaultConsensusParams = &cmtypes.ConsensusParams{ Block: cmtypes.BlockParams{ MaxBytes: 200000, MaxGas: -1, }, Evidence: cmtypes.EvidenceParams{ MaxAgeNumBlocks: 302400, MaxAgeDuration: 504 * time.Hour, MaxBytes: 10000, }, Validator: cmtypes.ValidatorParams{ PubKeyTypes: []string{ cmtypes.ABCIPubKeyTypeEd25519, }, }, }
EthDefaultConsensusParams defines the default Tendermint consensus params used in Cosmos EVM app testing.
TODO: currently not used
Functions ¶
func BroadcastTxBytes ¶
BroadcastTxBytes encodes a transaction and calls DeliverTx on the app.
func CheckEthTx ¶
func CheckEthTx( exampleApp *app.XOSD, priv cryptotypes.PrivKey, msgs ...sdk.Msg, ) (abci.ResponseCheckTx, error)
CheckEthTx checks a Ethereum tx for a given set of msgs
func CheckEthTxResponse ¶
func CheckEthTxResponse(r abci.ExecTxResult, cdc codec.Codec) ([]*evmtypes.MsgEthereumTxResponse, error)
CheckEthTxResponse checks that the transaction was executed successfully
func CheckTx ¶
func CheckTx( ctx sdk.Context, exampleApp *app.XOSD, priv cryptotypes.PrivKey, gasPrice *sdkmath.Int, msgs ...sdk.Msg, ) (abci.ResponseCheckTx, error)
CheckTx checks a cosmos tx for a given set of msgs
func Commit ¶
func Commit(ctx sdk.Context, app *app.XOSD, t time.Duration, vs *cmttypes.ValidatorSet) (sdk.Context, error)
Commit commits a block at a given time. Reminder: At the end of each Tendermint Consensus round the following methods are run
- BeginBlock
- DeliverTx
- EndBlock
- Commit
func CommitAndCreateNewCtx ¶
func CommitAndCreateNewCtx(ctx sdk.Context, app *app.XOSD, t time.Duration, vs *cmttypes.ValidatorSet) (sdk.Context, error)
CommitAndCreateNewCtx commits a block at a given time creating a ctx with the current settings This is useful to keep test settings that could be affected by EndBlockers, e.g. setting a baseFee == 0 and expecting this condition to continue after commit
func Delegate ¶
func Delegate( ctx sdk.Context, appEvmos *exampleapp.XOSD, priv *ethsecp256k1.PrivKey, delegateAmount sdk.Coin, validator stakingtypes.Validator, ) (abci.ExecTxResult, error)
Delegate delivers a delegate tx
func DeliverEthTx ¶
func DeliverEthTx( exampleApp *app.XOSD, priv cryptotypes.PrivKey, msgs ...sdk.Msg, ) (abci.ExecTxResult, error)
DeliverEthTx generates and broadcasts a Cosmos Tx populated with MsgEthereumTx messages. If a private key is provided, it will attempt to sign all messages with the given private key, otherwise, it will assume the messages have already been signed.
func DeliverEthTxWithoutCheck ¶
func DeliverEthTxWithoutCheck( exampleApp *app.XOSD, priv cryptotypes.PrivKey, msgs ...sdk.Msg, ) (abci.ExecTxResult, error)
DeliverEthTxWithoutCheck generates and broadcasts a Cosmos Tx populated with MsgEthereumTx messages. If a private key is provided, it will attempt to sign all messages with the given private key, otherwise, it will assume the messages have already been signed. It does not check if the Eth tx is successful or not.
func DeliverTx ¶
func DeliverTx( ctx sdk.Context, exampleApp *app.XOSD, priv cryptotypes.PrivKey, gasPrice *sdkmath.Int, msgs ...sdk.Msg, ) (abci.ExecTxResult, error)
DeliverTx delivers a cosmos tx for a given set of msgs
func DeployContract ¶
func DeployContract( ctx sdk.Context, app *exampleapp.XOSD, priv cryptotypes.PrivKey, queryClientEvm evmtypes.QueryClient, contract evmtypes.CompiledContract, constructorArgs ...interface{}, ) (common.Address, error)
DeployContract deploys a contract with the provided private key, compiled contract data and constructor arguments
func DeployContractWithFactory ¶
func DeployContractWithFactory( ctx sdk.Context, exampleApp *exampleapp.XOSD, priv cryptotypes.PrivKey, factoryAddress common.Address, ) (common.Address, abci.ExecTxResult, error)
DeployContractWithFactory deploys a contract using a contract factory with the provided factoryAddress
func EthSetup ¶
func EthSetup(isCheckTx bool, chainID string, patchGenesis func(*exampleapp.XOSD, cosmosevmtypes.GenesisState) cosmosevmtypes.GenesisState) *exampleapp.XOSD
EthSetup initializes a new Cosmos EVM application. A Nop logger is set in XOSD.
func EthSetupWithDB ¶
func EthSetupWithDB(isCheckTx bool, chainID string, patchGenesis func(*exampleapp.XOSD, cosmosevmtypes.GenesisState) cosmosevmtypes.GenesisState, db dbm.DB) *exampleapp.XOSD
EthSetupWithDB initializes a new XOSD. A Nop logger is set in XOSD.
func FundAccount ¶
func FundAccount(ctx sdk.Context, bankKeeper bankkeeper.Keeper, addr sdk.AccAddress, amounts sdk.Coins) error
FundAccount is a utility function that funds an account by minting and sending the coins to the address.
func FundAccountWithBaseDenom ¶
func FundAccountWithBaseDenom(ctx sdk.Context, bankKeeper bankkeeper.Keeper, addr sdk.AccAddress, amount int64) error
FundAccountWithBaseDenom is a utility function that uses the FundAccount function to fund an account with the default denomination.
TODO: as per Freddy these methods should be replaced with a bank transfer from a main account, not by minting in the process
func FundModuleAccount ¶
func FundModuleAccount(ctx sdk.Context, bankKeeper bankkeeper.Keeper, recipientMod string, amounts sdk.Coins) error
FundModuleAccount is a utility function that funds a module account by minting and sending the coins to the address.
func NewTestGenesisState ¶
func NewTestGenesisState(app *exampleapp.XOSD) cosmosevmtypes.GenesisState
NewTestGenesisState generate genesis state with single validator
It is also setting up the EVM parameters to use sensible defaults.
TODO: are these different genesis functions necessary or can they all be refactored into one? there's also other genesis state functions; some like app.DefaultGenesis() or others in test helpers only.
func SubmitProposal ¶
func SubmitProposal( ctx sdk.Context, appEvmos *exampleapp.XOSD, pk *ethsecp256k1.PrivKey, content govv1beta1.Content, eventNum int, ) (id uint64, err error)
SubmitProposal delivers a submit proposal tx for a given gov content. Depending on the content type, the eventNum needs to specify submit_proposal event.
func Vote ¶
func Vote( ctx sdk.Context, appEvmos *exampleapp.XOSD, priv *ethsecp256k1.PrivKey, proposalID uint64, voteOption govv1beta1.VoteOption, ) (abci.ExecTxResult, error)
Vote delivers a vote tx with the VoteOption "yes"
Types ¶
type ContractArgs ¶
type ContractArgs struct { // Addr is the address of the contract to call. Addr common.Address // ABI is the ABI of the contract to call. ABI abi.ABI // MethodName is the name of the method to call. MethodName string // Args are the arguments to pass to the method. Args []interface{} }
ContractArgs are the params used for calling a smart contract.
type ContractCallArgs ¶
type ContractCallArgs struct { // Contract are the contract-specific arguments required for the contract call. Contract ContractArgs // Nonce is the nonce to use for the transaction. Nonce *big.Int // Amount is the amount of the native denomination to send in the transaction. Amount *big.Int // GasLimit to use for the transaction GasLimit uint64 // PrivKey is the private key to be used for the transaction. PrivKey cryptotypes.PrivKey }
ContractCallArgs is the arguments for calling a smart contract.