state

package
v0.0.0-...-4e9d6c2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAccountName = "my_celes_key"

Variables

This section is empty.

Functions

func ConstructModule

func ConstructModule(tp node.Type, cfg *Config) fx.Option

ConstructModule provides all components necessary to construct the state service.

func Flags

func Flags() *flag.FlagSet

Flags gives a set of hardcoded State flags.

func KeyringSigner

func KeyringSigner(cfg Config, ks keystore.Keystore, net p2p.Network) (*apptypes.KeyringSigner, error)

KeyringSigner constructs a new keyring signer. NOTE: we construct keyring signer before constructing node for easier UX as having keyring-backend set to `file` prompts user for password.

func ParseFlags

func ParseFlags(cmd *cobra.Command, cfg *Config)

ParseFlags parses State flags from the given cmd and saves them to the passed config.

func WithKeyringSigner

func WithKeyringSigner(signer *types.KeyringSigner) fx.Option

WithKeyringSigner overrides the default keyring signer constructed by the node.

Types

type API

type API struct {
	Internal struct {
		AccountAddress    func(ctx context.Context) (state.Address, error)                      `perm:"read"`
		IsStopped         func(ctx context.Context) bool                                        `perm:"public"`
		Balance           func(ctx context.Context) (*state.Balance, error)                     `perm:"read"`
		BalanceForAddress func(ctx context.Context, addr state.Address) (*state.Balance, error) `perm:"public"`
		Transfer          func(
			ctx context.Context,
			to state.AccAddress,
			amount,
			fee state.Int,
			gasLimit uint64,
		) (*state.TxResponse, error) `perm:"write"`
		SubmitTx         func(ctx context.Context, tx state.Tx) (*state.TxResponse, error) `perm:"write"`
		SubmitPayForBlob func(
			ctx context.Context,
			nID namespace.ID,
			data []byte,
			fee state.Int,
			gasLim uint64,
		) (*state.TxResponse, error) `perm:"write"`
		CancelUnbondingDelegation func(
			ctx context.Context,
			valAddr state.ValAddress,
			amount,
			height,
			fee state.Int,
			gasLim uint64,
		) (*state.TxResponse, error) `perm:"write"`
		BeginRedelegate func(
			ctx context.Context,
			srcValAddr,
			dstValAddr state.ValAddress,
			amount,
			fee state.Int,
			gasLim uint64,
		) (*state.TxResponse, error) `perm:"write"`
		Undelegate func(
			ctx context.Context,
			delAddr state.ValAddress,
			amount,
			fee state.Int,
			gasLim uint64,
		) (*state.TxResponse, error) `perm:"write"`
		Delegate func(
			ctx context.Context,
			delAddr state.ValAddress,
			amount,
			fee state.Int,
			gasLim uint64,
		) (*state.TxResponse, error) `perm:"write"`
		QueryDelegation func(
			ctx context.Context,
			valAddr state.ValAddress,
		) (*types.QueryDelegationResponse, error) `perm:"public"`
		QueryUnbonding func(
			ctx context.Context,
			valAddr state.ValAddress,
		) (*types.QueryUnbondingDelegationResponse, error) `perm:"public"`
		QueryRedelegations func(
			ctx context.Context,
			srcValAddr,
			dstValAddr state.ValAddress,
		) (*types.QueryRedelegationsResponse, error) `perm:"public"`
	}
}

API is a wrapper around Module for the RPC. TODO(@distractedm1nd): These structs need to be autogenerated.

func (*API) AccountAddress

func (api *API) AccountAddress(ctx context.Context) (state.Address, error)

func (*API) Balance

func (api *API) Balance(ctx context.Context) (*state.Balance, error)

func (*API) BalanceForAddress

func (api *API) BalanceForAddress(ctx context.Context, addr state.Address) (*state.Balance, error)

func (*API) BeginRedelegate

func (api *API) BeginRedelegate(
	ctx context.Context,
	srcValAddr, dstValAddr state.ValAddress,
	amount,
	fee state.Int,
	gasLim uint64,
) (*state.TxResponse, error)

func (*API) CancelUnbondingDelegation

func (api *API) CancelUnbondingDelegation(
	ctx context.Context,
	valAddr state.ValAddress,
	amount,
	height,
	fee state.Int,
	gasLim uint64,
) (*state.TxResponse, error)

func (*API) Delegate

func (api *API) Delegate(
	ctx context.Context,
	delAddr state.ValAddress,
	amount,
	fee state.Int,
	gasLim uint64,
) (*state.TxResponse, error)

func (*API) IsStopped

func (api *API) IsStopped(ctx context.Context) bool

func (*API) QueryDelegation

func (api *API) QueryDelegation(ctx context.Context, valAddr state.ValAddress) (*types.QueryDelegationResponse, error)

func (*API) QueryRedelegations

func (api *API) QueryRedelegations(
	ctx context.Context,
	srcValAddr, dstValAddr state.ValAddress,
) (*types.QueryRedelegationsResponse, error)

func (*API) QueryUnbonding

func (api *API) QueryUnbonding(
	ctx context.Context,
	valAddr state.ValAddress,
) (*types.QueryUnbondingDelegationResponse, error)

func (*API) SubmitPayForBlob

func (api *API) SubmitPayForBlob(
	ctx context.Context,
	nID namespace.ID,
	data []byte,
	fee state.Int,
	gasLim uint64,
) (*state.TxResponse, error)

func (*API) SubmitTx

func (api *API) SubmitTx(ctx context.Context, tx state.Tx) (*state.TxResponse, error)

func (*API) Transfer

func (api *API) Transfer(
	ctx context.Context,
	to state.AccAddress,
	amount,
	fee state.Int,
	gasLimit uint64,
) (*state.TxResponse, error)

func (*API) Undelegate

func (api *API) Undelegate(
	ctx context.Context,
	delAddr state.ValAddress,
	amount,
	fee state.Int,
	gasLim uint64,
) (*state.TxResponse, error)

type Config

type Config struct {
	KeyringAccName string
	KeyringBackend string
}

Config contains configuration parameters for constructing the node's keyring signer.

func DefaultConfig

func DefaultConfig() Config

func (*Config) Validate

func (cfg *Config) Validate() error

Validate performs basic validation of the config.

type Module

type Module interface {
	// IsStopped checks if the Module's context has been stopped
	IsStopped(ctx context.Context) bool

	// AccountAddress retrieves the address of the node's account/signer
	AccountAddress(ctx context.Context) (state.Address, error)
	// Balance retrieves the Elysium coin balance for the node's account/signer
	// and verifies it against the corresponding block's AppHash.
	Balance(ctx context.Context) (*state.Balance, error)
	// BalanceForAddress retrieves the Elysium coin balance for the given address and verifies
	// the returned balance against the corresponding block's AppHash.
	//
	// NOTE: the balance returned is the balance reported by the block right before
	// the node's current head (head-1). This is due to the fact that for block N, the block's
	// `AppHash` is the result of applying the previous block's transaction list.
	BalanceForAddress(ctx context.Context, addr state.Address) (*state.Balance, error)

	// Transfer sends the given amount of coins from default wallet of the node to the given account
	// address.
	Transfer(ctx context.Context, to state.AccAddress, amount, fee state.Int, gasLimit uint64) (*state.TxResponse, error)
	// SubmitTx submits the given transaction/message to the
	// Elysium network and blocks until the tx is included in
	// a block.
	SubmitTx(ctx context.Context, tx state.Tx) (*state.TxResponse, error)
	// SubmitPayForBlob builds, signs and submits a PayForBlob transaction.
	SubmitPayForBlob(
		ctx context.Context,
		nID namespace.ID,
		data []byte,
		fee state.Int,
		gasLim uint64,
	) (*state.TxResponse, error)

	// CancelUnbondingDelegation cancels a user's pending undelegation from a validator.
	CancelUnbondingDelegation(
		ctx context.Context,
		valAddr state.ValAddress,
		amount,
		height,
		fee state.Int,
		gasLim uint64,
	) (*state.TxResponse, error)
	// BeginRedelegate sends a user's delegated tokens to a new validator for redelegation.
	BeginRedelegate(
		ctx context.Context,
		srcValAddr,
		dstValAddr state.ValAddress,
		amount,
		fee state.Int,
		gasLim uint64,
	) (*state.TxResponse, error)
	// Undelegate undelegates a user's delegated tokens, unbonding them from the current validator.
	Undelegate(
		ctx context.Context,
		delAddr state.ValAddress,
		amount, fee state.Int,
		gasLim uint64,
	) (*state.TxResponse, error)
	// Delegate sends a user's liquid tokens to a validator for delegation.
	Delegate(
		ctx context.Context,
		delAddr state.ValAddress,
		amount, fee state.Int,
		gasLim uint64,
	) (*state.TxResponse, error)

	// QueryDelegation retrieves the delegation information between a delegator and a validator.
	QueryDelegation(ctx context.Context, valAddr state.ValAddress) (*types.QueryDelegationResponse, error)
	// QueryUnbonding retrieves the unbonding status between a delegator and a validator.
	QueryUnbonding(ctx context.Context, valAddr state.ValAddress) (*types.QueryUnbondingDelegationResponse, error)
	// QueryRedelegations retrieves the status of the redelegations between a delegator and a validator.
	QueryRedelegations(
		ctx context.Context,
		srcValAddr,
		dstValAddr state.ValAddress,
	) (*types.QueryRedelegationsResponse, error)
}

Module represents the behaviors necessary for a user to query for state-related information and submit transactions/ messages to the Elysium network.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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