cosmosutil

package
v0.0.0-...-7149754 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ChainConfigDir = "config"
)

Variables

View Source
var GentxFilename = "gentx.json"

Functions

func ChangeAddressPrefix

func ChangeAddressPrefix(address, newPrefix string) (string, error)

ChangeAddressPrefix returns the address with another prefix

func CheckGenesisContainsAddress

func CheckGenesisContainsAddress(genesisPath, addr string) (bool, error)

CheckGenesisContainsAddress returns true if the address exist into the genesis file

func GenesisAndHashFromURL

func GenesisAndHashFromURL(ctx context.Context, url string) (genesis []byte, hash string, err error)

GenesisAndHashFromURL fetches the genesis from the given url and returns its content along with the sha256 hash.

func GetAddressPrefix

func GetAddressPrefix(address string) (string, error)

GetAddressPrefix returns the bech 32 prefix used by the address

func ParseCoinsNormalizedWithPercentageRequired

func ParseCoinsNormalizedWithPercentageRequired(coins string) (sdk.Coins, error)

ParseCoinsNormalizedWithPercentageRequired parses coins by requiring percentages. format: 20%foo,50%staking

func SetChainID

func SetChainID(genesisPath, chainID string) error

TODO refactor

func SetGenesisTime

func SetGenesisTime(genesisPath string, genesisTime int64) error

SetGenesisTime sets the genesis time inside a genesis file

func VerifyPeerFormat

func VerifyPeerFormat(peer launchtypes.Peer) bool

VerifyPeerFormat checks if the peer address format is valid

Types

type ChainGenesis

type ChainGenesis struct {
	ChainID  string `json:"chain_id"`
	AppState struct {
		Auth struct {
			Accounts []struct {
				Address string `json:"address"`
			} `json:"accounts"`
		} `json:"auth"`
		Staking struct {
			Params struct {
				BondDenom string `json:"bond_denom"`
			} `json:"params"`
		} `json:"staking"`
	} `json:"app_state"`
}

ChainGenesis represents the stargate genesis file

func ParseChainGenesis

func ParseChainGenesis(genesisFile []byte) (chainGenesis ChainGenesis, err error)

ParseChainGenesis parse ChainGenesis object from a byte slice

type Genesis

type Genesis struct {
	Accounts   []string
	StakeDenom string
}

Genesis represents a more readable version of the stargate genesis file

func ParseGenesis

func ParseGenesis(genesisFile []byte) (Genesis, error)

ParseGenesis parse ChainGenesis object from a byte slice into a Genesis object

func ParseGenesisFromPath

func ParseGenesisFromPath(genesisPath string) (Genesis, error)

ParseGenesisFromPath parse ChainGenesis object from a genesis file

func (Genesis) HasAccount

func (g Genesis) HasAccount(address string) bool

HasAccount check if account exist into the genesis account

type GentxInfo

type GentxInfo struct {
	DelegatorAddress string
	PubKey           ed25519.PubKey
	SelfDelegation   sdk.Coin
	Memo             string
}

GentxInfo represents the basic info about gentx file

func GentxFromPath

func GentxFromPath(path string) (info GentxInfo, gentx []byte, err error)

GentxFromPath returns GentxInfo from the json file

func ParseGentx

func ParseGentx(gentx []byte) (info GentxInfo, file []byte, err error)

ParseGentx returns GentxInfo and the gentx file in bytes TODO refector. no need to return file, it's already given as gentx in the argument.

type StargateGentx

type StargateGentx struct {
	Body struct {
		Messages []struct {
			DelegatorAddress string `json:"delegator_address"`
			ValidatorAddress string `json:"validator_address"`
			PubKey           struct {
				Type string `json:"@type"`
				Key  string `json:"key"`
			} `json:"pubkey"`
			Value struct {
				Denom  string `json:"denom"`
				Amount string `json:"amount"`
			} `json:"value"`
		} `json:"messages"`
		Memo string `json:"memo"`
	} `json:"body"`
}

StargateGentx represents the stargate gentx file

Jump to

Keyboard shortcuts

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