network

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrObjectNotFound is returned when the query returns a not found error.
	ErrObjectNotFound = errors.New("query object not found")
)

Functions

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
	ResetGenesisTime() error
}

type CosmosClient

type CosmosClient interface {
	Account(accountName string) (cosmosaccount.Account, error)
	Address(accountName string) (sdktypes.AccAddress, error)
	Context() client.Context
	BroadcastTx(accountName string, msgs ...sdktypes.Msg) (cosmosclient.Response, error)
	BroadcastTxWithProvision(accountName string, msgs ...sdktypes.Msg) (gas uint64, broadcast func() (cosmosclient.Response, error), err error)
	Status(ctx context.Context) (*ctypes.ResultStatus, error)
	ConsensusInfo(ctx context.Context, height int64) (cosmosclient.ConsensusInfo, error)
}

type IBCInfo

type IBCInfo struct {
	ConsensusState spntypes.ConsensusState
	ValidatorSet   spntypes.ValidatorSet
	UnbondingTime  int64
	Height         uint64
}

IBCInfo is node client info.

type JoinOption

type JoinOption func(*joinOptions)

func WithAccountRequest

func WithAccountRequest(amount sdk.Coins) JoinOption

func WithCustomGentxPath

func WithCustomGentxPath(path string) JoinOption

TODO accept struct not file path

func WithPublicAddress

func WithPublicAddress(addr string) JoinOption

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) Campaign

func (n Network) Campaign(ctx context.Context, campaignID uint64) (networktypes.Campaign, error)

Campaign fetches the campaign from Network

func (Network) Campaigns

func (n Network) Campaigns(ctx context.Context) ([]networktypes.Campaign, error)

Campaigns fetches the campaigns from Network

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) ([]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) CreateCampaign

func (n Network) CreateCampaign(name, metadata string, totalSupply sdk.Coins) (uint64, error)

CreateCampaign creates a campaign in Network

func (Network) CreateClient

func (n Network) CreateClient(
	launchID uint64,
	ibcInfo IBCInfo,
) (string, 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) 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) InitializeMainnet

func (n Network) InitializeMainnet(
	campaignID uint64,
	sourceURL,
	sourceHash string,
	mainnetChainID string,
) (uint64, error)

InitializeMainnet Initialize the mainnet of the campaign.

func (Network) Join

func (n Network) Join(
	ctx context.Context,
	c Chain,
	launchID uint64,
	options ...JoinOption,
) error

Join to the network.

func (Network) LaunchParams

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

LaunchParams fetches the chain launch module params from SPN

func (Network) MainnetAccounts

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

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

func (Network) MainnetVestingAccounts

func (n Network) MainnetVestingAccounts(ctx context.Context, campaignID uint64) (genAccs []networktypes.MainnetVestingAccount, err error)

MainnetVestingAccounts returns the list of campaign mainnet vesting accounts for a launch from SPN

func (Network) Publish

func (n Network) Publish(ctx context.Context, c Chain, options ...PublishOption) (launchID, campaignID, mainnetID 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(launchID uint64, chain Chain) error

RevertLaunch reverts a launched chain as a coordinator

func (Network) SetReward

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

SetReward set a chain reward

func (Network) SubmitRequest

func (n Network) SubmitRequest(launchID uint64, reviewal ...Reviewal) error

SubmitRequest submits reviewals for proposals in batch for chain.

func (Network) TriggerLaunch

func (n Network) TriggerLaunch(ctx context.Context, launchID uint64, remainingTime time.Duration) error

TriggerLaunch launches a chain as a coordinator

func (Network) UpdateCampaign

func (n Network) UpdateCampaign(
	id uint64,
	props ...Prop,
) error

UpdateCampaign updates the campaign name or metadata

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 NewNodeClient

func NewNodeClient(cosmos CosmosClient) (Node, error)

func (Node) IBCInfo

func (n Node) IBCInfo(ctx context.Context) (IBCInfo, error)

IBCInfo Fetches the consensus state, validator set and the staking parameters

func (Node) StakingParams

func (n Node) StakingParams(ctx context.Context) (stakingtypes.Params, error)

StakingParams fetches the staking module params

type Option

type Option func(*Network)

func CollectEvents

func CollectEvents(ev events.Bus) Option

CollectEvents collects events from the network builder.

func WithCampaignQueryClient

func WithCampaignQueryClient(client campaigntypes.QueryClient) Option

func WithLaunchQueryClient

func WithLaunchQueryClient(client launchtypes.QueryClient) Option

func WithProfileQueryClient

func WithProfileQueryClient(client profiletypes.QueryClient) Option

func WithRewardQueryClient

func WithRewardQueryClient(client rewardtypes.QueryClient) Option

type Prop

type Prop func(*updateProp)

Prop update campaign proposal

func WithCampaignMetadata

func WithCampaignMetadata(metadata string) Prop

WithCampaignMetadata provides a meta data proposal to update the campaign.

func WithCampaignName

func WithCampaignName(name string) Prop

WithCampaignName provides a name proposal to update the campaign.

func WithCampaignTotalSupply

func WithCampaignTotalSupply(totalSupply sdk.Coins) Prop

WithCampaignTotalSupply provides a total supply proposal to update the campaign.

type PublishOption

type PublishOption func(*publishOptions)

PublishOption configures chain creation.

func Mainnet

func Mainnet() PublishOption

Mainnet initialize a published chain into the mainnet

func WithCampaign

func WithCampaign(id uint64) PublishOption

WithCampaign add a campaign id.

func WithChainID

func WithChainID(chainID string) PublishOption

WithChainID use a custom chain id.

func WithCustomGenesis

func WithCustomGenesis(url string) PublishOption

WithCustomGenesis enables using a custom genesis during publish.

func WithMetadata

func WithMetadata(metadata string) PublishOption

WithMetadata provides a meta data proposal to update the campaign.

func WithNoCheck

func WithNoCheck() PublishOption

WithNoCheck disables checking integrity of the chain.

func WithShares

func WithShares(shares campaigntypes.Shares) PublishOption

WithShares enables minting vouchers for shares.

func WithTotalSupply

func WithTotalSupply(totalSupply sdk.Coins) PublishOption

WithTotalSupply provides a total supply proposal to update the campaign.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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