types

package
v0.50.5 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 28 Imported by: 2,595

Documentation

Index

Constants

View Source
const ChainIDFieldName = "chain_id"
View Source
const (
	// MaxChainIDLen is the maximum length of a chain ID.
	MaxChainIDLen = cmttypes.MaxChainIDLen
)
View Source
const ModuleName = "genutil"

ModuleName is genutil

Variables

View Source
var (
	ErrInvalidLengthGenesis        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowGenesis          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
)

Functions

func DefaultMessageValidator added in v0.47.0

func DefaultMessageValidator(msgs []sdk.Msg) error

func GenesisStateFromAppGenesis added in v0.50.0

func GenesisStateFromAppGenesis(genesis *AppGenesis) (genesisState map[string]json.RawMessage, err error)

GenesisStateFromAppGenesis creates the core parameters for genesis initialization for the application.

NOTE: The pubkey input is this machines pubkey.

func ParseChainIDFromGenesis added in v0.50.0

func ParseChainIDFromGenesis(r io.Reader) (string, error)

ParseChainIDFromGenesis parses the `chain_id` from a genesis JSON file, aborting early after finding the `chain_id`. For efficiency, it's recommended to place the `chain_id` field before any large entries in the JSON file. Returns an error if the `chain_id` field is not found.

func SetGenesisStateInAppState

func SetGenesisStateInAppState(
	cdc codec.JSONCodec, appState map[string]json.RawMessage, genesisState *GenesisState,
) map[string]json.RawMessage

SetGenesisStateInAppState sets the genutil genesis state within the expected app state

func ValidateAndGetGenTx added in v0.46.0

func ValidateAndGetGenTx(genTx json.RawMessage, txJSONDecoder sdk.TxDecoder, validator MessageValidator) (sdk.Tx, error)

ValidateAndGetGenTx validates the genesis transaction and returns GenTx if valid it cannot verify the signature as it is stateless validation

func ValidateGenesis

func ValidateGenesis(genesisState *GenesisState, txJSONDecoder sdk.TxDecoder, validator MessageValidator) error

ValidateGenesis validates GenTx transactions

Types

type AccountKeeper

type AccountKeeper interface {
	NewAccount(context.Context, sdk.AccountI) sdk.AccountI
	SetAccount(context.Context, sdk.AccountI)
	IterateAccounts(ctx context.Context, process func(sdk.AccountI) (stop bool))
}

AccountKeeper defines the expected account keeper (noalias)

type AppGenesis added in v0.50.0

type AppGenesis struct {
	AppName       string            `json:"app_name"`
	AppVersion    string            `json:"app_version"`
	GenesisTime   time.Time         `json:"genesis_time"`
	ChainID       string            `json:"chain_id"`
	InitialHeight int64             `json:"initial_height"`
	AppHash       []byte            `json:"app_hash"`
	AppState      json.RawMessage   `json:"app_state,omitempty"`
	Consensus     *ConsensusGenesis `json:"consensus,omitempty"`
}

AppGenesis defines the app's genesis.

func AppGenesisFromFile added in v0.50.0

func AppGenesisFromFile(genFile string) (*AppGenesis, error)

AppGenesisFromFile reads the AppGenesis from the provided file.

func AppGenesisFromReader added in v0.50.0

func AppGenesisFromReader(reader io.Reader) (*AppGenesis, error)

AppGenesisFromReader reads the AppGenesis from the reader.

func GenesisStateFromGenFile

func GenesisStateFromGenFile(genFile string) (genesisState map[string]json.RawMessage, genesis *AppGenesis, err error)

GenesisStateFromGenFile creates the core parameters for genesis initialization for the application.

NOTE: The pubkey input is this machines pubkey.

func NewAppGenesisWithVersion added in v0.50.0

func NewAppGenesisWithVersion(chainID string, appState json.RawMessage) *AppGenesis

NewAppGenesisWithVersion returns a new AppGenesis with the app name and app version already.

func (*AppGenesis) SaveAs added in v0.50.0

func (ag *AppGenesis) SaveAs(file string) error

SaveAs is a utility method for saving AppGenesis as a JSON file.

func (*AppGenesis) ToGenesisDoc added in v0.50.0

func (ag *AppGenesis) ToGenesisDoc() (*cmttypes.GenesisDoc, error)

ToGenesisDoc converts the AppGenesis to a CometBFT GenesisDoc.

func (*AppGenesis) ValidateAndComplete added in v0.50.0

func (ag *AppGenesis) ValidateAndComplete() error

ValidateAndComplete performs validation and completes the AppGenesis.

type AppMap

type AppMap map[string]json.RawMessage

AppMap map modules names with their json raw representation.

type ConsensusGenesis added in v0.50.0

type ConsensusGenesis struct {
	Validators []cmttypes.GenesisValidator `json:"validators,omitempty"`
	Params     *cmttypes.ConsensusParams   `json:"params,omitempty"`
}

ConsensusGenesis defines the consensus layer's genesis. TODO(@julienrbrt) eventually abstract from CometBFT types

func NewConsensusGenesis added in v0.50.0

func NewConsensusGenesis(params cmtproto.ConsensusParams, validators []cmttypes.GenesisValidator) *ConsensusGenesis

NewConsensusGenesis returns a ConsensusGenesis with given values. It takes a proto consensus params so it can called from server export command.

func (*ConsensusGenesis) MarshalJSON added in v0.50.0

func (cs *ConsensusGenesis) MarshalJSON() ([]byte, error)

func (*ConsensusGenesis) UnmarshalJSON added in v0.50.0

func (cs *ConsensusGenesis) UnmarshalJSON(b []byte) error

func (*ConsensusGenesis) ValidateAndComplete added in v0.50.0

func (cs *ConsensusGenesis) ValidateAndComplete() error

type GenesisAccountsIterator

type GenesisAccountsIterator interface {
	IterateGenesisAccounts(
		cdc *codec.LegacyAmino,
		appGenesis map[string]json.RawMessage,
		cb func(sdk.AccountI) (stop bool),
	)
}

GenesisAccountsIterator defines the expected iterating genesis accounts object (noalias)

type GenesisBalancesIterator

type GenesisBalancesIterator interface {
	IterateGenesisBalances(
		cdc codec.JSONCodec,
		appGenesis map[string]json.RawMessage,
		cb func(bankexported.GenesisBalance) (stop bool),
	)
}

GenesisAccountsIterator defines the expected iterating genesis accounts object (noalias)

type GenesisState

type GenesisState struct {
	// gen_txs defines the genesis transactions.
	GenTxs []encoding_json.RawMessage `protobuf:"bytes,1,rep,name=gen_txs,json=genTxs,proto3,casttype=encoding/json.RawMessage" json:"gentxs"`
}

GenesisState defines the raw genesis transaction in JSON.

func DefaultGenesisState

func DefaultGenesisState() *GenesisState

DefaultGenesisState returns the genutil module's default genesis state.

func GetGenesisStateFromAppState

func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.RawMessage) *GenesisState

GetGenesisStateFromAppState gets the genutil genesis state from the expected app state

func NewGenesisState

func NewGenesisState(genTxs []json.RawMessage) *GenesisState

NewGenesisState creates a new GenesisState object

func NewGenesisStateFromTx added in v0.40.0

func NewGenesisStateFromTx(txJSONEncoder sdk.TxEncoder, genTxs []sdk.Tx) *GenesisState

NewGenesisStateFromTx creates a new GenesisState object from auth transactions

func (*GenesisState) Descriptor added in v0.40.0

func (*GenesisState) Descriptor() ([]byte, []int)

func (*GenesisState) GetGenTxs added in v0.40.0

func (m *GenesisState) GetGenTxs() []encoding_json.RawMessage

func (*GenesisState) Marshal added in v0.40.0

func (m *GenesisState) Marshal() (dAtA []byte, err error)

func (*GenesisState) MarshalTo added in v0.40.0

func (m *GenesisState) MarshalTo(dAtA []byte) (int, error)

func (*GenesisState) MarshalToSizedBuffer added in v0.40.0

func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GenesisState) ProtoMessage added in v0.40.0

func (*GenesisState) ProtoMessage()

func (*GenesisState) Reset added in v0.40.0

func (m *GenesisState) Reset()

func (*GenesisState) Size added in v0.40.0

func (m *GenesisState) Size() (n int)

func (*GenesisState) String added in v0.40.0

func (m *GenesisState) String() string

func (*GenesisState) Unmarshal added in v0.40.0

func (m *GenesisState) Unmarshal(dAtA []byte) error

func (*GenesisState) XXX_DiscardUnknown added in v0.40.0

func (m *GenesisState) XXX_DiscardUnknown()

func (*GenesisState) XXX_Marshal added in v0.40.0

func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GenesisState) XXX_Merge added in v0.40.0

func (m *GenesisState) XXX_Merge(src proto.Message)

func (*GenesisState) XXX_Size added in v0.40.0

func (m *GenesisState) XXX_Size() int

func (*GenesisState) XXX_Unmarshal added in v0.40.0

func (m *GenesisState) XXX_Unmarshal(b []byte) error

type InitConfig

type InitConfig struct {
	ChainID   string
	GenTxsDir string
	NodeID    string
	ValPubKey cryptotypes.PubKey
}

InitConfig common config options for init

func NewInitConfig

func NewInitConfig(chainID, genTxsDir, nodeID string, valPubKey cryptotypes.PubKey) InitConfig

NewInitConfig creates a new InitConfig object

type MessageValidator added in v0.47.0

type MessageValidator func([]sdk.Msg) error

type MigrationCallback

type MigrationCallback func(AppMap, client.Context) (AppMap, error)

MigrationCallback converts a genesis map from the previous version to the targeted one.

type MigrationMap

type MigrationMap map[string]MigrationCallback

MigrationMap defines a mapping from a version to a MigrationCallback.

type StakingKeeper

type StakingKeeper interface {
	ApplyAndReturnValidatorSetUpdates(context.Context) (updates []abci.ValidatorUpdate, err error)
}

StakingKeeper defines the expected staking keeper (noalias)

Jump to

Keyboard shortcuts

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