networktypes

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SPNChainID name used as SPN chain id.
	SPNChainID = "spn-1"

	// SPN name used as an address prefix and as a home dir for chains to publish.
	SPN = "spn"

	// SPNDenom is the denom used for the spn chain native token.
	SPNDenom = "uspn"

	// SPNVersion is the spn ibc version used for the relayer connection.
	SPNVersion = "monitoring-1"

	// SPNPortID is the spn ibc port id used for the relayer connection.
	SPNPortID = "monitoringc"

	// ChainPortID is the chain ibc port id used for the relayer connection.
	ChainPortID = "monitoringp"

	// DefaultFee is the default fee to use when sending transactions.
	DefaultFee = "500uspn"
)
View Source
const (
	RequestActionAddAccount        = "add account to the network"
	RequestActionAddValidator      = "join the network as a validator"
	RequestActionAddVestingAccount = "add vesting account to the network"
	RequestActionRemoveAccount     = "remove account from the network"
	RequestActionRemoveValidator   = "remove validator from the network"
	RequestActionChangeParams      = "change param on the network"

	RequestActionResultAddAccount        = "account added to the network"
	RequestActionResultAddValidator      = "Validator added to the network"
	RequestActionResultAddVestingAccount = "vesting account added to the network"
	RequestActionResultRemoveAccount     = "account removed from network"
	RequestActionResultRemoveValidator   = "validator removed from network"
	RequestActionResultChangeParams      = "param changed on network"

	RequestActionUnrecognized = "<unrecognized request>"
)

Request action descriptions

View Source
const Version = "1"

Version current version of the network plugin

Variables

This section is empty.

Functions

func NewWrappedErrInvalidRequest

func NewWrappedErrInvalidRequest(requestID uint64, message string) error

NewWrappedErrInvalidRequest returns a wrapped ErrInvalidRequest.

func RequestActionDescriptionFromContent

func RequestActionDescriptionFromContent(content launchtypes.RequestContent) string

RequestActionDescriptionFromContent describes the action of the request from its content

func RequestActionResultDescriptionFromContent

func RequestActionResultDescriptionFromContent(content launchtypes.RequestContent) string

RequestActionResultDescriptionFromContent describe the result of the action of the request from its content

func VerifyAddValidatorRequest

func VerifyAddValidatorRequest(req *launchtypes.RequestContent_GenesisValidator) error

VerifyAddValidatorRequest verifies the validator request parameters.

func VerifyPeerFormat

func VerifyPeerFormat(peer launchtypes.Peer) bool

VerifyPeerFormat checks if the peer address format is valid

func VerifyRequest

func VerifyRequest(request Request) error

VerifyRequest verifies the validity of the request from its content (static check).

Types

type ChainLaunch

type ChainLaunch struct {
	ID                     uint64      `json:"ID"`
	ConsumerRevisionHeight int64       `json:"ConsumerRevisionHeight"`
	ChainID                string      `json:"ChainID"`
	SourceURL              string      `json:"SourceURL"`
	SourceHash             string      `json:"SourceHash"`
	GenesisURL             string      `json:"GenesisURL"`
	GenesisHash            string      `json:"GenesisHash"`
	GenesisConfig          string      `json:"GenesisConfig"`
	LaunchTime             time.Time   `json:"LaunchTime"`
	ProjectID              uint64      `json:"ProjectID"`
	LaunchTriggered        bool        `json:"LaunchTriggered"`
	Network                NetworkType `json:"Network"`
	Reward                 string      `json:"Reward,omitempty"`
	AccountBalance         sdk.Coins   `json:"AccountBalance"`
	Metadata               Metadata    `json:"Metadata"`
}

ChainLaunch represents the launch of a chain on SPN.

func ToChainLaunch

func ToChainLaunch(chain launchtypes.Chain) ChainLaunch

ToChainLaunch converts a chain launch data from SPN and returns a ChainLaunch object.

type ChainShare

type ChainShare struct {
	LaunchID uint64    `json:"LaunchID"`
	Shares   sdk.Coins `json:"Shares"`
}

ChainShare represents the share of a chain on SPN.

type Cli

type Cli struct {
	Version string `json:"version"`
}

Cli holds information about the CLI used to interact with the chain

type Coordinator

type Coordinator struct {
	CoordinatorID uint64 `json:"ID"`
	Address       string `json:"Address"`
	Active        bool   `json:"Active"`
	Identity      string `json:"Identity"`
	Website       string `json:"Website"`
	Details       string `json:"Details"`
}

Coordinator represents the Coordinator profile on SPN.

func ToCoordinator

func ToCoordinator(coord profiletypes.Coordinator) Coordinator

ToCoordinator converts a Coordinator data from SPN and returns a Coordinator object.

func (Coordinator) ToProfile

func (c Coordinator) ToProfile(
	projectID uint64,
	vouchers sdk.Coins,
	shares projecttypes.Shares,
) Profile

type ErrInvalidRequest

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

ErrInvalidRequest is an error returned in methods manipulating requests when they are invalid.

func (ErrInvalidRequest) Error

func (err ErrInvalidRequest) Error() string

Error implements error.

type GenesisAccount

type GenesisAccount struct {
	Address string    `json:"Address,omitempty"`
	Coins   sdk.Coins `json:"Coins,omitempty"`
}

GenesisAccount represents an account with initial coin allocation for the chain for the chain genesis.

func ToGenesisAccount

func ToGenesisAccount(acc launchtypes.GenesisAccount) GenesisAccount

ToGenesisAccount converts genesis account from SPN.

type GenesisInformation

type GenesisInformation struct {
	GenesisAccounts   []GenesisAccount
	VestingAccounts   []VestingAccount
	GenesisValidators []GenesisValidator
	ParamChanges      []ParamChange
}

GenesisInformation represents all information for a chain to construct the genesis. This structure indexes accounts and validators by their address for better performance.

func NewGenesisInformation

func NewGenesisInformation(
	genAccs []GenesisAccount,
	vestingAccs []VestingAccount,
	genVals []GenesisValidator,
	paramChanges []ParamChange,
) (gi GenesisInformation)

NewGenesisInformation initializes new GenesisInformation.

func (*GenesisInformation) AddGenesisAccount

func (gi *GenesisInformation) AddGenesisAccount(acc GenesisAccount)

func (*GenesisInformation) AddGenesisValidator

func (gi *GenesisInformation) AddGenesisValidator(val GenesisValidator)

func (*GenesisInformation) AddParamChange

func (gi *GenesisInformation) AddParamChange(pc ParamChange)

AddParamChange adds a ParamChange to the GenesisInformation. Appends if entry does not exist. Updates if it already exists.

func (*GenesisInformation) AddVestingAccount

func (gi *GenesisInformation) AddVestingAccount(acc VestingAccount)

func (GenesisInformation) ApplyRequest

func (gi GenesisInformation) ApplyRequest(request Request) (GenesisInformation, error)

ApplyRequest applies to the genesisInformation the changes implied by the approval of a request.

func (GenesisInformation) ContainsGenesisAccount

func (gi GenesisInformation) ContainsGenesisAccount(address string) (bool, int)

ContainsGenesisAccount returns true if GenesisInformation contains given address. Returns index if true, -1 if false.

func (GenesisInformation) ContainsGenesisValidator

func (gi GenesisInformation) ContainsGenesisValidator(address string) (bool, int)

ContainsGenesisValidator returns true if GenesisInformation contains given address. Returns index if true, -1 if false.

func (GenesisInformation) ContainsParamChange

func (gi GenesisInformation) ContainsParamChange(module, param string) (bool, int)

ContainsParamChange returns true if GenesisInformation contains given module-param pair. Returns index if true, -1 if false.

func (GenesisInformation) ContainsVestingAccount

func (gi GenesisInformation) ContainsVestingAccount(address string) (bool, int)

ContainsVestingAccount returns true if GenesisInformation contains given address. Returns index if true, -1 if false.

func (*GenesisInformation) RemoveGenesisAccount

func (gi *GenesisInformation) RemoveGenesisAccount(address string)

func (*GenesisInformation) RemoveGenesisValidator

func (gi *GenesisInformation) RemoveGenesisValidator(address string)

func (*GenesisInformation) RemoveVestingAccount

func (gi *GenesisInformation) RemoveVestingAccount(address string)

type GenesisValidator

type GenesisValidator struct {
	Address        string           `json:"Address,omitempty"`
	Gentx          []byte           `json:"Gentx,omitempty"`
	Peer           launchtypes.Peer `json:"Peer,omitempty"`
	SelfDelegation sdk.Coin         `json:"SelfDelegation,omitempty"`
}

GenesisValidator represents a genesis validator associated with a gentx in the chain genesis.

func ToGenesisValidator

func ToGenesisValidator(val launchtypes.GenesisValidator) GenesisValidator

ToGenesisValidator converts genesis validator from SPN.

type MainnetAccount

type MainnetAccount struct {
	Address string              `json:"Address"`
	Shares  projecttypes.Shares `json:"Shares"`
}

MainnetAccount represents the project mainnet account of a chain on SPN.

func ToMainnetAccount

func ToMainnetAccount(acc projecttypes.MainnetAccount) MainnetAccount

ToMainnetAccount converts a mainnet account data from SPN and returns a MainnetAccount object.

type Metadata

type Metadata struct {
	Cli Cli `json:"cli"`
}

Metadata is an object that contains the metadata of a chain the metadata represents generic data set by the coordinator these information can be formatted and interpreted by the CLI for specific purposes

func (Metadata) IsCurrentVersion

func (m Metadata) IsCurrentVersion() bool

IsCurrentVersion checks if the version of the CLI is equal to the current version

type NetworkType

type NetworkType string
const (
	NetworkTypeMainnet NetworkType = "mainnet"
	NetworkTypeTestnet NetworkType = "testnet"
)

func (NetworkType) String

func (n NetworkType) String() string

type ParamChange

type ParamChange struct {
	Module string `json:"Module,omitempty"`
	Param  string `json:"Param,omitempty"`
	Value  []byte `json:"Value,omitempty"`
}

ParamChange represents a parameter change to be applied to the chain genesis.

func ToParamChange

func ToParamChange(pc launchtypes.ParamChange) ParamChange

ToParamChange converts param change from SPN.

type Profile

type Profile struct {
	Address         string              `json:"Address"`
	ProjectID       uint64              `json:"ProjectID,omitempty"`
	Identity        string              `json:"Identity,omitempty"`
	Website         string              `json:"Website,omitempty"`
	Details         string              `json:"Details,omitempty"`
	Moniker         string              `json:"Moniker,omitempty"`
	SecurityContact string              `json:"SecurityContact,omitempty"`
	Vouchers        sdk.Coins           `json:"Vouchers,omitempty"`
	Shares          projecttypes.Shares `json:"Shares,omitempty"`
}

Profile represents the address profile on SPN.

type ProfileAcc

type ProfileAcc interface {
	ToProfile(
		projectID uint64,
		vouchers sdk.Coins,
		shares projecttypes.Shares,
	) Profile
}

ProfileAcc represents the address profile method interface.

type Project

type Project struct {
	ID                 uint64    `json:"ID"`
	Name               string    `json:"Name"`
	CoordinatorID      uint64    `json:"CoordinatorID"`
	MainnetID          uint64    `json:"MainnetID"`
	MainnetInitialized bool      `json:"MainnetInitialized"`
	TotalSupply        sdk.Coins `json:"TotalSupply"`
	AllocatedShares    string    `json:"AllocatedShares"`
	Metadata           string    `json:"Metadata"`
}

Project represents the project of a chain on SPN.

func ToProject

func ToProject(project projecttypes.Project) Project

ToProject converts a project data from SPN and returns a Project object.

type ProjectChains

type ProjectChains struct {
	ProjectID uint64   `json:"ProjectID"`
	Chains    []uint64 `json:"Chains"`
}

ProjectChains represents the chains of a project on SPN.

func ToProjectChains

func ToProjectChains(c projecttypes.ProjectChains) ProjectChains

ToProjectChains converts a project chains data from SPN and returns a ProjectChains object.

type Request

type Request struct {
	LaunchID  uint64                     `json:"LaunchID"`
	RequestID uint64                     `json:"RequestID"`
	Creator   string                     `json:"Creator"`
	CreatedAt string                     `json:"CreatedAt"`
	Content   launchtypes.RequestContent `json:"Content"`
	Status    string                     `json:"Status"`
}

Request represents the launch Request of a chain on SPN.

func RequestsFromRequestContents

func RequestsFromRequestContents(launchID uint64, contents []launchtypes.RequestContent) []Request

RequestsFromRequestContents creates a list of requests from a list request contents to simulate requests that have not been sent to request pool yet The request ID is set to 0 for the first request and incremented for each request, other values are not set

func ToRequest

func ToRequest(request launchtypes.Request) Request

ToRequest converts a request data from SPN and returns a Request object.

type Reward

type Reward struct {
	ConsensusState spntypes.ConsensusState
	ValidatorSet   spntypes.ValidatorSet
	RevisionHeight uint64
}

Reward is node reward info.

type RewardIBCInfo

type RewardIBCInfo struct {
	ChainID      string
	ClientID     string
	ConnectionID string
	ChannelID    string
}

RewardIBCInfo holds IBC info to relay packets to claim rewards.

type Validator

type Validator struct {
	Address           string   `json:"Address"`
	OperatorAddresses []string `json:"OperatorAddresses"`
	Identity          string   `json:"Identity"`
	Website           string   `json:"Website"`
	Details           string   `json:"Details"`
	Moniker           string   `json:"Moniker"`
	SecurityContact   string   `json:"SecurityContact"`
}

Validator represents the Validator profile on SPN.

func ToValidator

func ToValidator(val profiletypes.Validator) Validator

ToValidator converts a Validator data from SPN and returns a Validator object.

func (Validator) ToProfile

func (v Validator) ToProfile(
	projectID uint64,
	vouchers sdk.Coins,
	shares projecttypes.Shares,
) Profile

type VestingAccount

type VestingAccount struct {
	Address      string    `json:"Address,omitempty"`
	TotalBalance sdk.Coins `json:"TotalBalance,omitempty"`
	Vesting      sdk.Coins `json:"Vesting,omitempty"`
	EndTime      int64     `json:"EndTime,omitempty"`
}

VestingAccount represents a vesting account with initial coin allocation and vesting option for the chain genesis. VestingAccount supports currently only delayed vesting option.

func ToVestingAccount

func ToVestingAccount(acc launchtypes.VestingAccount) (VestingAccount, error)

ToVestingAccount converts vesting account from SPN.

Jump to

Keyboard shortcuts

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