cosmos

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Bech32MainPrefix defines the main Bech32 prefix
	Bech32MainPrefix = "mesgtest"

	// CoinType is the mesg registered coin type from https://github.com/satoshilabs/slips/blob/master/slip-0044.md.
	CoinType = 470

	// BIP44Prefix is the parts of the BIP44 HD path that are fixed by
	// what we used during the fundraiser.
	FullFundraiserPath = "44'/470'/0'/0/0"

	// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
	Bech32PrefixAccAddr = Bech32MainPrefix
	// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key
	Bech32PrefixAccPub = Bech32MainPrefix + sdktypes.PrefixPublic
	// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address
	Bech32PrefixValAddr = Bech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixOperator
	// Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key
	Bech32PrefixValPub = Bech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixOperator + sdktypes.PrefixPublic
	// Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address
	Bech32PrefixConsAddr = Bech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixConsensus
	// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
	Bech32PrefixConsPub = Bech32MainPrefix + sdktypes.PrefixValidator + sdktypes.PrefixConsensus + sdktypes.PrefixPublic
)

See github.com/cosmos/cosmos-sdk/types/address.go

View Source
const (
	CodeInternal   types.CodeType = 1000
	CodeValidation types.CodeType = 2000
)

Base mesg codes.

View Source
const (
	AttributeKeyHash = "hash"
)

common attribute keys.

View Source
const (
	// CodespaceMesg is a cosmos codespace for all mesg errors.
	CodespaceMesg types.CodespaceType = "mesg"
)

Variables

EventHashType is a message with resource hash

Functions

func CustomizeConfig added in v0.18.1

func CustomizeConfig()

CustomizeConfig customizes the cosmos application like addresses prefixes and coin type

func EventActionQuery added in v0.17.0

func EventActionQuery(msgType string) string

EventActionQuery returns tendermint query which matches given message type.

func EventModuleQuery added in v0.17.0

func EventModuleQuery(module string) string

EventModuleQuery returns tendermint query which matches given module.

func GenGenesis added in v0.16.0

func GenGenesis(kb *Keybase, defaultGenesisŚtate map[string]json.RawMessage, chainID, initialBalances, genesisFile string, validators []GenesisValidator) (*tmtypes.GenesisDoc, error)

GenGenesis generates a new genesis and save it.

func GenesisExist added in v0.16.0

func GenesisExist(genesisFile string) bool

GenesisExist returns true if the genesis file already exists.

func LoadGenesis added in v0.16.0

func LoadGenesis(genesisFile string) (*tmtypes.GenesisDoc, error)

LoadGenesis loads a genesis from a file.

func NewMesgErrorf added in v0.18.0

func NewMesgErrorf(ct types.CodeType, format string, a ...interface{}) types.Error

NewMesgErrorf creates error with given code type and mesg codespace.

func NewMesgWrapError added in v0.18.0

func NewMesgWrapError(ct types.CodeType, err error) types.Error

NewMesgWrapError creates error with given code type and mesg codespace.

func NewNode

func NewNode(app *App, cfg *tmconfig.Config, genesis *types.GenesisDoc) (*node.Node, error)

NewNode creates a new Tendermint node from an App.

Types

type App

type App struct {
	*baseapp.BaseApp
	// contains filtered or unexported fields
}

App is a loaded Cosmos application that inherit from BaseApp.

func NewApp

func NewApp(factory *AppFactory) (*App, error)

NewApp initializes a new App.

func (*App) BasicManager added in v0.18.1

func (a *App) BasicManager() module.BasicManager

BasicManager returns app basic manager.

func (*App) DefaultGenesis

func (a *App) DefaultGenesis() map[string]json.RawMessage

DefaultGenesis returns the default genesis from the basic manager.

type AppFactory

type AppFactory struct {
	// contains filtered or unexported fields
}

AppFactory is a Cosmos application factory.

func NewAppFactory

func NewAppFactory(logger log.Logger, db dbm.DB, minGasPrices string) *AppFactory

NewAppFactory returns a new AppFactory.

func (*AppFactory) DeliverTx

DeliverTx implement baseApp.DeliverTx

func (*AppFactory) RegisterModule

func (a *AppFactory) RegisterModule(module module.AppModule)

RegisterModule registers a module to the app.

func (*AppFactory) RegisterOrderBeginBlocks

func (a *AppFactory) RegisterOrderBeginBlocks(beginBlockers ...string)

RegisterOrderBeginBlocks sets the order of the modules when they are called on the begin block event.

func (*AppFactory) RegisterOrderEndBlocks

func (a *AppFactory) RegisterOrderEndBlocks(endBlockers ...string)

RegisterOrderEndBlocks sets the order of the modules when they are called on the end block event.

func (*AppFactory) RegisterOrderInitGenesis

func (a *AppFactory) RegisterOrderInitGenesis(moduleNames ...string)

RegisterOrderInitGenesis sets the order of the modules when they are called to initialize the genesis.

func (*AppFactory) RegisterStoreKey

func (a *AppFactory) RegisterStoreKey(storeKey *sdk.KVStoreKey)

RegisterStoreKey registers a store key to the app.

func (*AppFactory) RegisterTransientStoreKey

func (a *AppFactory) RegisterTransientStoreKey(transientStoreKey *sdk.TransientStoreKey)

RegisterTransientStoreKey registers a transient store key to the app.

func (*AppFactory) SetAnteHandler

func (a *AppFactory) SetAnteHandler(anteHandler sdk.AnteHandler)

SetAnteHandler registers the authentication handler to the app.

type AppModule

type AppModule struct {
	AppModuleBasic
	// contains filtered or unexported fields
}

AppModule is a main element of an cosmos app.

func NewAppModule

func NewAppModule(moduleBasic AppModuleBasic, handler Handler, querier Querier) AppModule

NewAppModule inits an AppModule using an AppModuleBasic, Handler and Querier.

func (AppModule) BeginBlock

func (m AppModule) BeginBlock(_ cosmostypes.Request, _ abci.RequestBeginBlock)

BeginBlock is called at the beginning of the process of a new block.

func (AppModule) EndBlock

EndBlock is called at the end of the process of a new block.

func (AppModule) ExportGenesis

func (m AppModule) ExportGenesis(request cosmostypes.Request) json.RawMessage

ExportGenesis exports the current state of the app.

func (AppModule) InitGenesis

func (m AppModule) InitGenesis(request cosmostypes.Request, data json.RawMessage) []abci.ValidatorUpdate

InitGenesis initializes the genesis from a request and data.

func (AppModule) NewHandler

func (m AppModule) NewHandler() cosmostypes.Handler

NewHandler returns the handler used to apply transactions.

func (AppModule) NewQuerierHandler

func (m AppModule) NewQuerierHandler() cosmostypes.Querier

NewQuerierHandler returns the handler used to reply ABCI query.

func (AppModule) QuerierRoute

func (m AppModule) QuerierRoute() string

QuerierRoute the route prefix for query of the module.

func (AppModule) RegisterInvariants

func (m AppModule) RegisterInvariants(ir cosmostypes.InvariantRegistry)

RegisterInvariants registers invariants to the registry.

func (AppModule) Route

func (m AppModule) Route() string

Route returns the route prefix for transaction of the module.

type AppModuleBasic

type AppModuleBasic struct {
	// contains filtered or unexported fields
}

AppModuleBasic is a basic element of an cosmos app.

func NewAppModuleBasic

func NewAppModuleBasic(name string) AppModuleBasic

NewAppModuleBasic inits an AppModuleBasic using a name.

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis() json.RawMessage

DefaultGenesis returns the default genesis of the module.

func (AppModuleBasic) GetQueryCmd

func (AppModuleBasic) GetQueryCmd(cdc *cosmoscodec.Codec) *cobra.Command

GetQueryCmd returns the root query command of this module

func (AppModuleBasic) GetTxCmd

func (AppModuleBasic) GetTxCmd(cdc *cosmoscodec.Codec) *cobra.Command

GetTxCmd returns the root tx command of this module

func (AppModuleBasic) Name

func (m AppModuleBasic) Name() string

Name returns the name of the module.

func (AppModuleBasic) RegisterCodec

func (AppModuleBasic) RegisterCodec(cdc *cosmoscodec.Codec)

RegisterCodec registers the module's structs in the codec.

func (AppModuleBasic) RegisterRESTRoutes

func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router)

RegisterRESTRoutes registers rest routes

func (AppModuleBasic) ValidateGenesis

func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error

ValidateGenesis checks a Genesis.

type Client

type Client struct {
	*rpcclient.Local
	// contains filtered or unexported fields
}

Client is a tendermint client with helper functions.

func NewClient

func NewClient(node *node.Node, kb keys.Keybase, chainID, accName, accPassword, minGasPrices string) *Client

NewClient returns a rpc tendermint client.

func (*Client) BuildAndBroadcastMsg

func (c *Client) BuildAndBroadcastMsg(msg sdktypes.Msg) (*abci.ResponseDeliverTx, error)

BuildAndBroadcastMsg builds and signs message and broadcast it to node.

func (*Client) GetAccount added in v0.18.0

func (c *Client) GetAccount() (auth.Account, error)

GetAccount returns the local account.

func (*Client) Query added in v0.15.0

func (c *Client) Query(path string, qdata, ptr interface{}) error

Query is abci.query wrapper with errors check and decode data.

func (*Client) QueryWithData

func (c *Client) QueryWithData(path string, data []byte) ([]byte, int64, error)

QueryWithData performs a query to a Tendermint node with the provided path and a data payload. It returns the result and height of the query upon success or an error if the query fails.

func (*Client) Stream added in v0.17.0

func (c *Client) Stream(ctx context.Context, query string) (chan hash.Hash, chan error, error)

Stream subscribes to the provided query and returns the hash of the matching ressources.

type GenesisValidator added in v0.16.0

type GenesisValidator struct {
	Name      string
	Password  string
	ValPubKey crypto.PubKey
	NodeID    p2p.ID
}

GenesisValidator holds the info of a specific validator to use to generate a genesis.

func NewGenesisValidator added in v0.16.0

func NewGenesisValidator(kb *Keybase, name, password, privValidatorKeyFile, privValidatorStateFile, nodeKeyFile string) (GenesisValidator, error)

NewGenesisValidator creates a new validator with an cosmos account, validator and node identity.

type Handler added in v0.17.0

type Handler func(request cosmostypes.Request, msg cosmostypes.Msg) (hash.Hash, error)

Handler defines the core of the state transition function of an application.

type Keybase

type Keybase struct {
	// contains filtered or unexported fields
}

Keybase is a standard cosmos keybase.

func NewKeybase

func NewKeybase(dir string) (*Keybase, error)

NewKeybase initializes a filesystem keybase at a particular dir.

func (*Keybase) CloseDB added in v0.18.0

func (kb *Keybase) CloseDB()

CloseDB is a lock protected version of keys.CloseDB

func (*Keybase) CreateAccount added in v0.18.0

func (kb *Keybase) CreateAccount(name, mnemonic, bip39Passwd, encryptPasswd string, account, index uint32) (keys.Info, error)

CreateAccount is a lock protected version of keys.CreateAccount

func (*Keybase) CreateLedger added in v0.18.0

func (kb *Keybase) CreateLedger(name string, algo keys.SigningAlgo, hrp string, account, index uint32) (keys.Info, error)

CreateLedger is a lock protected version of keys.CreateLedger

func (*Keybase) CreateMnemonic added in v0.18.0

func (kb *Keybase) CreateMnemonic(name string, language keys.Language, passwd string, algo keys.SigningAlgo) (keys.Info, string, error)

CreateMnemonic is a lock protected version of keys.CreateMnemonic

func (*Keybase) CreateMulti added in v0.18.0

func (kb *Keybase) CreateMulti(name string, pubkey crypto.PubKey) (keys.Info, error)

CreateMulti is a lock protected version of keys.CreateMulti

func (*Keybase) CreateOffline added in v0.18.0

func (kb *Keybase) CreateOffline(name string, pubkey crypto.PubKey) (keys.Info, error)

CreateOffline is a lock protected version of keys.CreateOffline

func (*Keybase) Delete added in v0.18.0

func (kb *Keybase) Delete(name, passphrase string, skipPass bool) error

Delete is a lock protected version of keys.Delete

func (*Keybase) Derive added in v0.18.0

func (kb *Keybase) Derive(name, mnemonic, bip39Passwd, encryptPasswd string, params hd.BIP44Params) (keys.Info, error)

Derive is a lock protected version of keys.Derive

func (*Keybase) Exist added in v0.17.0

func (kb *Keybase) Exist(name string) (bool, error)

Exist checks if the account exists.

func (*Keybase) Export added in v0.18.0

func (kb *Keybase) Export(name string) (armor string, err error)

Export is a lock protected version of keys.Export

func (*Keybase) ExportPrivKey added in v0.18.0

func (kb *Keybase) ExportPrivKey(name, decryptPassphrase, encryptPassphrase string) (armor string, err error)

ExportPrivKey is a lock protected version of keys.ExportPrivKey

func (*Keybase) ExportPrivateKeyObject added in v0.18.0

func (kb *Keybase) ExportPrivateKeyObject(name string, passphrase string) (crypto.PrivKey, error)

ExportPrivateKeyObject is a lock protected version of keys.ExportPrivateKeyObject

func (*Keybase) ExportPubKey added in v0.18.0

func (kb *Keybase) ExportPubKey(name string) (armor string, err error)

ExportPubKey is a lock protected version of keys.ExportPubKey

func (*Keybase) Get added in v0.18.0

func (kb *Keybase) Get(name string) (keys.Info, error)

Get is a lock protected version of keys.Get

func (*Keybase) GetByAddress added in v0.18.0

func (kb *Keybase) GetByAddress(address types.AccAddress) (keys.Info, error)

GetByAddress is a lock protected version of keys.GetByAddress

func (*Keybase) Import added in v0.18.0

func (kb *Keybase) Import(name, armor string) error

Import is a lock protected version of keys.Import

func (*Keybase) ImportPrivKey added in v0.18.0

func (kb *Keybase) ImportPrivKey(name, armor, passphrase string) error

ImportPrivKey is a lock protected version of keys.ImportPrivKey

func (*Keybase) ImportPubKey added in v0.18.0

func (kb *Keybase) ImportPubKey(name, armor string) (err error)

ImportPubKey is a lock protected version of keys.ImportPubKey

func (*Keybase) List added in v0.18.0

func (kb *Keybase) List() ([]keys.Info, error)

List is a lock protected version of keys.List

func (*Keybase) NewMnemonic added in v0.15.0

func (kb *Keybase) NewMnemonic() (string, error)

NewMnemonic returns a new mnemonic phrase.

func (*Keybase) Sign added in v0.18.0

func (kb *Keybase) Sign(name, passphrase string, msg []byte) ([]byte, crypto.PubKey, error)

Sign is a lock protected version of keys.Sign

func (*Keybase) Update added in v0.18.0

func (kb *Keybase) Update(name, oldpass string, getNewpass func() (string, error)) error

Update is a lock protected version of keys.Update

type Querier

type Querier func(request cosmostypes.Request, path []string, req abci.RequestQuery) (res interface{}, err error)

Querier is responsible to answer to ABCI queries.

type TxBuilder

type TxBuilder struct {
	authtypes.TxBuilder
}

TxBuilder implements a transaction context created in SDK modules.

func NewTxBuilder

func NewTxBuilder(accNumber, accSeq uint64, kb keys.Keybase, chainID string, minGasPrices sdktypes.DecCoins) TxBuilder

NewTxBuilder returns a new initialized TxBuilder.

func (TxBuilder) BuildAndSignStdTx

func (b TxBuilder) BuildAndSignStdTx(msg sdktypes.Msg, accountName, accountPassword string) (authtypes.StdTx, error)

BuildAndSignStdTx a signed transaction from a message.

func (TxBuilder) Encode

func (b TxBuilder) Encode(tx sdktypes.Tx) (types.Tx, error)

Encode a transaction.

func (TxBuilder) WithGas added in v0.18.1

func (b TxBuilder) WithGas(gas uint64) TxBuilder

WithGas returns a copy of the context with an updated gas.

Jump to

Keyboard shortcuts

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