cosmosutil

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 13 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 SetGenesisTime

func SetGenesisTime(genesisPath string, genesisTime int64) error

SetGenesisTime sets the genesis time inside a genesis file

Types

type ChainGenesis

type ChainGenesis struct {
	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

type Genesis

type Genesis struct {
	Accounts   []string
	StakeDenom string
}

Genesis represents a more readable version of the stargate genesis file

func ParseGenesis

func ParseGenesis(genesisPath string) (Genesis, error)

ParseGenesis 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           PubKey
	SelfDelegation   sdk.Coin
}

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

type PubKey

type PubKey []byte

PubKey represents the public key in bytes array

func (PubKey) Equal

func (pb PubKey) Equal(key []byte) bool

Equal returns true if the public keys are equal

type StargateGentx

type StargateGentx struct {
	Body struct {
		Messages []struct {
			DelegatorAddress string `json:"delegator_address"`
			ValidatorAddress string `json:"validator_address"`
			PubKey           struct {
				Key string `json:"key"`
			} `json:"pubkey"`
			Value struct {
				Denom  string `json:"denom"`
				Amount string `json:"amount"`
			} `json:"value"`
		} `json:"messages"`
	} `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