utils

package
v0.0.0-...-d14323f Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TokenToMint = 1e18
)

Variables

This section is empty.

Functions

func ApproveProposal

func ApproveProposal(tf factory.TxFactory, network network.Network, proposerPriv cryptotypes.PrivKey, proposalID uint64) error

ApproveProposal is a helper function to vote 'yes' for it and wait till it passes.

func CheckBalances

func CheckBalances(ctx context.Context, client banktypes.QueryClient, balances []banktypes.Balance) error

CheckBalances checks that the given accounts have the expected balances and returns an error if that is not the case.

func CheckTxTopics

func CheckTxTopics(res abcitypes.ExecTxResult, expectedTopics []string) error

CheckTxTopics checks if all expected topics are present in the transaction response

func ContainsEventType

func ContainsEventType(events []abcitypes.Event, eventType string) bool

ContainsEventType returns true if the given events contain the given eventType.

func CreateGenesisWithTokenPairs

func CreateGenesisWithTokenPairs(keyring testkeyring.Keyring, denoms ...string) network.CustomGenesisState

CreateGenesisWithTokenPairs creates a genesis that includes the WEVMOS and the provided denoms. If no denoms provided, creates only one dynamic precompile with the 'xmpl' denom.

func DecodeContractCallResponse

func DecodeContractCallResponse(response interface{}, callArgs factory.CallArgs, res abcitypes.ExecTxResult) error

DecodeContractCallResponse decodes the response of a contract call query

func FundAccountWithBaseDenom

func FundAccountWithBaseDenom(tf cmnfactory.CoreTxFactory, nw cmnnet.Network, sender keyring.Key, receiver sdk.AccAddress, amount math.Int) error

FundAccountWithBaseDenom funds the given account with the given amount of the network's base denomination.

func GetERC20Balance

func GetERC20Balance(nw network.Network, tokenAddress, accountAddress common.Address) (*big.Int, error)

GetERC20Balance returns the token balance of a given account address for an ERC-20 token at the given contract address.

func GetEventAttributeValue

func GetEventAttributeValue(event abcitypes.Event, attrKey string) string

GetEventAttributeValue returns the value for the required attribute key

func GetEventType

func GetEventType(events []abcitypes.Event, eventType string) *abcitypes.Event

GetEventType returns the given events if found Otherwise returns nil

func GetFeesFromEvents

func GetFeesFromEvents(events []abcitypes.Event) (sdktypes.DecCoins, error)

GetFeesFromEvents returns the fees value for the specified events

func RegisterERC20

func RegisterERC20(tf factory.TxFactory, network network.Network, data ERC20RegistrationData) (res []erc20types.TokenPair, err error)

RegisterERC20 is a helper function to register ERC20 token through submitting a governance proposal and having it pass. It returns the registered token pair.

func RegisterEvmosERC20Coins

func RegisterEvmosERC20Coins(
	network network.UnitTestNetwork,
	tokenReceiver sdk.AccAddress,
) (erc20types.TokenPair, error)

RegisterEvmosERC20Coins uses the UnitNetwork to register the evmos token as an ERC20 token. The function performs all the required steps for the registration like registering the denom trace in the transfer keeper and minting the token with the bank. Returns the TokenPair or an error.

func RegisterIBCERC20Coins

func RegisterIBCERC20Coins(
	network *network.UnitTestNetwork,
	tokenReceiver sdk.AccAddress,
	denomTrace transfertypes.DenomTrace,
) (erc20types.TokenPair, error)

RegisterIBCERC20Coins uses the UnitNetwork to register the denomTrace as an ERC20 token. The function performs all the required steps for the registration like registering the denom trace in the transfer keeper and minting the token with the bank. Returns the TokenPair or an error.

TODO: why is this not yet used

func SubmitLegacyProposal

func SubmitLegacyProposal(tf factory.TxFactory, network network.Network, proposerPriv cryptotypes.PrivKey, proposal govv1beta1.Content) (uint64, error)

SubmitLegacyProposal is a helper function to submit a governance proposal and return the proposal ID.

func SubmitProposal

func SubmitProposal(tf factory.TxFactory, network network.Network, proposerPriv cryptotypes.PrivKey, title string, msgs ...sdk.Msg) (uint64, error)

SubmitProposal is a helper function to submit a governance proposal and return the proposal ID.

func ToggleTokenConversion

func ToggleTokenConversion(tf factory.TxFactory, network network.Network, privKey cryptotypes.PrivKey, token string) error

ToggleTokenConversion is a helper function to toggle an ERC20 token pair conversion through submitting a governance proposal and having it pass.

func UpdateERC20Params

func UpdateERC20Params(input UpdateParamsInput) error

UpdateERC20Params helper function to update the erc20 module parameters It submits an update params proposal, votes for it, and waits till it passes

func UpdateEvmParams

func UpdateEvmParams(input UpdateParamsInput) error

UpdateEvmParams helper function to update the EVM module parameters It submits an update params proposal, votes for it, and waits till it passes

func UpdateFeeMarketParams

func UpdateFeeMarketParams(input UpdateParamsInput) error

UpdateFeeMarketParams helper function to update the feemarket module parameters It submits an update params proposal, votes for it, and waits till it passes

func UpdateGovParams

func UpdateGovParams(input UpdateParamsInput) error

UpdateGovParams helper function to update the governance module parameters It submits an update params proposal, votes for it, and waits till it passes

func ValidatorConsAddressToHex

func ValidatorConsAddressToHex(valAddress string) common.Address

func VoteOnProposal

func VoteOnProposal(tf factory.TxFactory, voterPriv cryptotypes.PrivKey, proposalID uint64, option govv1.VoteOption) (abcitypes.ExecTxResult, error)

VoteOnProposal is a helper function to vote on a governance proposal given the private key of the voter and the option to vote.

func WaitToAccrueCommission

func WaitToAccrueCommission(n network.Network, gh grpc.Handler, validatorAddr string, expCommission sdk.DecCoins) (sdk.DecCoins, error)

WaitToAccrueCommission is a helper function that waits for commission to accumulate up to a specified expected amount

func WaitToAccrueRewards

func WaitToAccrueRewards(n network.Network, gh grpc.Handler, delegatorAddr string, expRewards sdk.DecCoins) (sdk.DecCoins, error)

WaitToAccrueRewards is a helper function that waits for rewards to accumulate up to a specified expected amount

Types

type ERC20RegistrationData

type ERC20RegistrationData struct {
	// Addresses are the addresses of the ERC20 tokens.
	Addresses []string
	// ProposerPriv is the private key used to sign the proposal and voting transactions.
	ProposerPriv cryptotypes.PrivKey
}

ERC20RegistrationData is the necessary data to provide in order to register an ERC20 token.

func (ERC20RegistrationData) ValidateBasic

func (ed ERC20RegistrationData) ValidateBasic() error

ValidateBasic does stateless validation of the data for the ERC20 registration.

type UpdateParamsInput

type UpdateParamsInput struct {
	Tf      factory.TxFactory
	Network network.Network
	Pk      cryptotypes.PrivKey
	Params  interface{}
}

Jump to

Keyboard shortcuts

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