network

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: 41 Imported by: 0

Documentation

Index

Constants

View Source
const MinLaunchTimeOffset = time.Second * 30

MinLaunchTimeOffset represents an offset used when minimum launch time is used minimum launch time will be block time + minimum launch time duration param block time when tx is executed is not predicable, therefore we add few seconds to ensure the minimum duration is reached.

Variables

View Source
var ErrObjectNotFound = errors.New("query object not found")

ErrObjectNotFound is returned when the query returns a not found error.

Functions

func FillMetadata

func FillMetadata(metadata []byte) ([]byte, error)

FillMetadata fills the metadata of the chain with the plugin version

func ParseID

func ParseID(id string) (uint64, error)

func ParsePeerAddress

func ParsePeerAddress(addr string) (launchtypes.Peer, error)

func PeerAddress

func PeerAddress(peer launchtypes.Peer) (string, error)

Types

type Chain

type Chain interface {
	ID() (string, error)
	ChainID() (string, error)
	Name() string
	SourceURL() string
	SourceHash() string
	GenesisPath() (string, error)
	GentxsPath() (string, error)
	DefaultGentxPath() (string, error)
	AppTOMLPath() (string, error)
	ConfigTOMLPath() (string, error)
	NodeID(ctx context.Context) (string, error)
	CacheBinary(launchID uint64) error
}

type CosmosClient

type CosmosClient interface {
	Context() client.Context
	BroadcastTx(ctx context.Context, account cosmosaccount.Account, msgs ...sdktypes.Msg) (cosmosclient.Response, error)
	Status(ctx context.Context) (*ctypes.ResultStatus, error)
	ConsensusInfo(ctx context.Context, height int64) (cosmosclient.ConsensusInfo, error)
}

type JoinOption

type JoinOption func(*joinOptions)

func WithAccountRequest

func WithAccountRequest(amount sdk.Coins) JoinOption

WithAccountRequest allows to join the chain by requesting a genesis account with the specified amount of tokens.

func WithPublicAddress

func WithPublicAddress(addr string) JoinOption

WithPublicAddress allows to specify a peer public address for the node.

type Network

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

Network is network builder.

func New

func New(cosmos CosmosClient, account cosmosaccount.Account, options ...Option) Network

New creates a Builder.

func (Network) AccountAddress

func (n Network) AccountAddress() (string, error)

AccountAddress returns the address of the account used by the network builder

func (Network) Balances

func (n Network) Balances(ctx context.Context, address string) (sdk.Coins, error)

Balances returns the all balances by address from SPN.

func (Network) ChainID

func (n Network) ChainID(ctx context.Context) (string, error)

ChainID fetches the network chain id.

func (Network) ChainLaunch

func (n Network) ChainLaunch(ctx context.Context, id uint64) (networktypes.ChainLaunch, error)

ChainLaunch fetches the chain launch from Network by launch id.

func (Network) ChainLaunchesWithReward

func (n Network) ChainLaunchesWithReward(ctx context.Context, pagination *query.PageRequest) ([]networktypes.ChainLaunch, error)

ChainLaunchesWithReward fetches the chain launches with rewards from Network.

func (Network) ChainReward

func (n Network) ChainReward(ctx context.Context, launchID uint64) (rewardtypes.RewardPool, error)

ChainReward fetches the chain reward from SPN by launch id.

func (Network) Coordinator

func (n Network) Coordinator(ctx context.Context, address string) (networktypes.Coordinator, error)

Coordinator returns the Coordinator by address from SPN.

func (Network) CoordinatorIDByAddress

func (n Network) CoordinatorIDByAddress(ctx context.Context, address string) (uint64, error)

CoordinatorIDByAddress returns the CoordinatorByAddress from SPN.

func (Network) CreateClient

func (n Network) CreateClient(
	ctx context.Context,
	launchID uint64,
	unbondingTime int64,
	rewardsInfo networktypes.Reward,
) (string, error)

CreateClient send create client message to SPN.

func (Network) CreateProject

func (n Network) CreateProject(ctx context.Context, name, metadata string, totalSupply sdk.Coins) (uint64, error)

CreateProject creates a project in Network.

func (Network) GenesisAccount

func (n Network) GenesisAccount(ctx context.Context, launchID uint64, address string) (networktypes.GenesisAccount, error)

func (Network) GenesisAccounts

func (n Network) GenesisAccounts(ctx context.Context, launchID uint64) (genAccs []networktypes.GenesisAccount, err error)

GenesisAccounts returns the list of approved genesis accounts for a launch from SPN.

func (Network) GenesisInformation

func (n Network) GenesisInformation(ctx context.Context, launchID uint64) (gi networktypes.GenesisInformation, err error)

GenesisInformation returns all the information to construct the genesis from a chain ID.

func (Network) GenesisValidator

func (n Network) GenesisValidator(ctx context.Context, launchID uint64, address string) (networktypes.GenesisValidator, error)

func (Network) GenesisValidators

func (n Network) GenesisValidators(ctx context.Context, launchID uint64) (genVals []networktypes.GenesisValidator, err error)

GenesisValidators returns the list of approved genesis validators for a launch from SPN.

func (Network) GetJoinRequestContents

func (n Network) GetJoinRequestContents(
	ctx context.Context,
	c Chain,
	launchID uint64,
	gentxPath string,
	options ...JoinOption,
) (reqs []launchtypes.RequestContent, err error)

GetJoinRequestContents returns the request contents to join a chain as a validator

func (Network) InitializeMainnet

func (n Network) InitializeMainnet(
	ctx context.Context,
	projectID uint64,
	sourceURL,
	sourceHash string,
	mainnetChainID string,
) (uint64, error)

InitializeMainnet Initialize the mainnet of the project.

func (Network) LaunchParams

func (n Network) LaunchParams(ctx context.Context) (launchtypes.Params, error)

LaunchParams fetches the chain launch module params from SPN.

func (Network) MainnetAccount

func (n Network) MainnetAccount(
	ctx context.Context,
	projectID uint64,
	address string,
) (acc networktypes.MainnetAccount, err error)

MainnetAccount returns the project mainnet account for a launch from SPN.

func (Network) MainnetAccounts

func (n Network) MainnetAccounts(ctx context.Context, projectID uint64) (genAccs []networktypes.MainnetAccount, err error)

MainnetAccounts returns the list of project mainnet accounts for a launch from SPN.

func (Network) ParamChanges

func (n Network) ParamChanges(ctx context.Context, launchID uint64) (paramChanges []networktypes.ParamChange, err error)

ParamChanges returns the list of approved param changes for a launch from SPN.

func (Network) Profile

func (n Network) Profile(ctx context.Context, projectID uint64) (networktypes.Profile, error)

Profile returns the address profile info.

func (Network) Project

func (n Network) Project(ctx context.Context, projectID uint64) (networktypes.Project, error)

Project fetches the project from Network.

func (Network) Projects

func (n Network) Projects(ctx context.Context) ([]networktypes.Project, error)

Projects fetches the projects from Network.

func (Network) Publish

func (n Network) Publish(ctx context.Context, c Chain, options ...PublishOption) (launchID, projectID uint64, err error)

Publish submits Genesis to SPN to announce a new network.

func (Network) Request

func (n Network) Request(ctx context.Context, launchID, requestID uint64) (networktypes.Request, error)

Request fetches the chain request from SPN by launch and request id.

func (Network) RequestFromIDs

func (n Network) RequestFromIDs(ctx context.Context, launchID uint64, requestIDs ...uint64) (reqs []networktypes.Request, err error)

RequestFromIDs fetches the chain requested from SPN by launch and provided request IDs TODO: once implemented, use the SPN query from https://github.com/tendermint/spn/issues/420

func (Network) Requests

func (n Network) Requests(ctx context.Context, launchID uint64) ([]networktypes.Request, error)

Requests fetches all the chain requests from SPN by launch id.

func (Network) RevertLaunch

func (n Network) RevertLaunch(ctx context.Context, launchID uint64, _ Chain) error

RevertLaunch reverts a launched chain as a coordinator.

func (Network) RewardIBCInfo

func (n Network) RewardIBCInfo(ctx context.Context, launchID uint64) (networktypes.RewardIBCInfo, error)

RewardIBCInfo returns IBC info to relay packets for a chain to claim rewards.

func (Network) RewardsInfo

func (n Network) RewardsInfo(
	ctx context.Context,
	launchID uint64,
	height int64,
) (
	rewardsInfo networktypes.Reward,
	lastRewardHeight int64,
	unboundingTime int64,
	err error,
)

RewardsInfo Fetches the consensus state with the validator set, the unbounding time, and the last block height from chain rewards.

func (Network) SendRequest

func (n Network) SendRequest(
	ctx context.Context,
	launchID uint64,
	content launchtypes.RequestContent,
) error

SendRequest creates and sends the Request message to SPN.

func (Network) SendRequests

func (n Network) SendRequests(
	ctx context.Context,
	launchID uint64,
	contents []launchtypes.RequestContent,
) error

SendRequests creates and sends the Request message to SPN

func (Network) SetCoordinatorDescription

func (n Network) SetCoordinatorDescription(ctx context.Context, description profiletypes.CoordinatorDescription) error

SetCoordinatorDescription set the description of a coordinator or creates the coordinator if it doesn't exist yet for the sender address.

func (Network) SetReward

func (n Network) SetReward(ctx context.Context, launchID uint64, lastRewardHeight int64, coins sdk.Coins) error

SetReward set a chain reward.

func (Network) SetValidatorDescription

func (n Network) SetValidatorDescription(ctx context.Context, validator profiletypes.Validator) error

SetValidatorDescription set a validator profile.

func (Network) SubmitRequestReviewals

func (n Network) SubmitRequestReviewals(ctx context.Context, launchID uint64, reviewal ...Reviewal) error

SubmitRequestReviewals submits reviewals for proposals in batch for chain.

func (Network) TriggerLaunch

func (n Network) TriggerLaunch(ctx context.Context, launchID uint64, launchTime time.Time) error

TriggerLaunch launches a chain as a coordinator.

func (Network) UpdateProject

func (n Network) UpdateProject(
	ctx context.Context,
	id uint64,
	props ...Prop,
) error

UpdateProject updates the project name or metadata.

func (Network) Validator

func (n Network) Validator(ctx context.Context, address string) (networktypes.Validator, error)

Validator returns the Validator by address from SPN.

func (Network) VestingAccount

func (n Network) VestingAccount(ctx context.Context, launchID uint64, address string) (networktypes.VestingAccount, error)

func (Network) VestingAccounts

func (n Network) VestingAccounts(ctx context.Context, launchID uint64) (vestingAccs []networktypes.VestingAccount, err error)

VestingAccounts returns the list of approved genesis vesting accounts for a launch from SPN.

type Node

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

Node is node builder.

func NewNode

func NewNode(cosmos CosmosClient) Node

NewNode creates a new client for node API.

func (Node) RewardIBCInfo

func (n Node) RewardIBCInfo(ctx context.Context) (networktypes.RewardIBCInfo, error)

RewardIBCInfo returns IBC info to relay packets to claim rewards for the chain.

func (Node) RewardsInfo

func (n Node) RewardsInfo(ctx context.Context) (
	reward networktypes.Reward,
	chainID string,
	unbondingTimeSeconds int64,
	err error,
)

RewardsInfo Fetches the consensus state with the validator set and the unbounding time.

type Option

type Option func(*Network)

func CollectEvents

func CollectEvents(ev events.Bus) Option

CollectEvents collects events from the network builder.

func WithBankQueryClient

func WithBankQueryClient(client banktypes.QueryClient) Option

func WithCustomClock

func WithCustomClock(clock xtime.Clock) Option

func WithLaunchQueryClient

func WithLaunchQueryClient(client launchtypes.QueryClient) Option

func WithMonitoringConsumerQueryClient

func WithMonitoringConsumerQueryClient(client monitoringctypes.QueryClient) Option

func WithProfileQueryClient

func WithProfileQueryClient(client profiletypes.QueryClient) Option

func WithProjectQueryClient

func WithProjectQueryClient(client projecttypes.QueryClient) Option

func WithRewardQueryClient

func WithRewardQueryClient(client rewardtypes.QueryClient) Option

func WithStakingQueryClient

func WithStakingQueryClient(client stakingtypes.QueryClient) Option

type Prop

type Prop func(*updateProp)

Prop updates project proposal.

func WithProjectMetadata

func WithProjectMetadata(metadata string) Prop

WithProjectMetadata provides a meta data proposal to update the project.

func WithProjectName

func WithProjectName(name string) Prop

WithProjectName provides a name proposal to update the project.

func WithProjectTotalSupply

func WithProjectTotalSupply(totalSupply sdk.Coins) Prop

WithProjectTotalSupply provides a total supply proposal to update the project.

type PublishOption

type PublishOption func(*publishOptions)

PublishOption configures chain creation.

func Mainnet

func Mainnet() PublishOption

Mainnet initialize a published chain into the mainnet.

func WithAccountBalance

func WithAccountBalance(accountBalance sdk.Coins) PublishOption

WithAccountBalance set a balance used for all genesis account of the chain.

func WithChainID

func WithChainID(chainID string) PublishOption

WithChainID use a custom chain id.

func WithCustomGenesisConfig

func WithCustomGenesisConfig(configFile string) PublishOption

WithCustomGenesisConfig enables using a custom genesis during publish.

func WithCustomGenesisURL

func WithCustomGenesisURL(url string) PublishOption

WithCustomGenesisURL enables using a custom genesis during publish.

func WithMetadata

func WithMetadata(metadata string) PublishOption

WithMetadata provides a meta data proposal to update the project.

func WithPercentageShares

func WithPercentageShares(sharePercentages []SharePercent) PublishOption

WithPercentageShares enables minting vouchers for shares.

func WithProject

func WithProject(id uint64) PublishOption

WithProject add a project id.

func WithTotalSupply

func WithTotalSupply(totalSupply sdk.Coins) PublishOption

WithTotalSupply provides a total supply proposal to update the project.

type Reviewal

type Reviewal struct {
	RequestID  uint64
	IsApproved bool
}

Reviewal keeps a request's reviewal.

func ApproveRequest

func ApproveRequest(requestID uint64) Reviewal

ApproveRequest returns approval for a request with id.

func RejectRequest

func RejectRequest(requestID uint64) Reviewal

RejectRequest returns rejection for a request with id.

type SharePercent

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

SharePercent represent percent of total share.

func NewSharePercent

func NewSharePercent(denom string, nominator, denominator uint64) (SharePercent, error)

NewSharePercent creates new share percent representation.

func SharePercentFromString

func SharePercentFromString(str string) (SharePercent, error)

SharePercentFromString parses share percent from string format: 11.87%foo

func (SharePercent) Share

func (p SharePercent) Share(total uint64) (sdk.Coin, error)

Share returns coin share of total according to underlying percent.

type SharePercents

type SharePercents []SharePercent

func ParseSharePercents

func ParseSharePercents(percents string) (SharePercents, error)

ParseSharePercents parses SharePercentage list from string format: 12.4%foo,10%bar,0.133%baz

func (SharePercents) Empty

func (sp SharePercents) Empty() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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