network

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: Apache-2.0 Imports: 31 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)

func RewardsInfo added in v0.22.0

func RewardsInfo(ctx context.Context, client CosmosClient, height int64) (networktypes.Reward, error)

RewardsInfo Fetches the consensus state with the validator set

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 added in v0.21.0

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 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) ChainID added in v0.22.0

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) ([]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 added in v0.21.1

func (n Network) CreateClient(
	launchID uint64,
	unbondingTime int64,
	rewardsInfo networktypes.Reward,
) (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 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) RewardsInfo added in v0.22.0

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) SendAccountRequestForCoordinator added in v0.22.0

func (n Network) SendAccountRequestForCoordinator(launchID uint64, amount sdk.Coins) error

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 added in v0.21.1

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

Node is node builder.

func NewNodeClient added in v0.21.1

func NewNodeClient(cosmos CosmosClient) (Node, error)

func (Node) RewardsInfo added in v0.22.0

func (n Node) RewardsInfo(ctx context.Context) (networktypes.Reward, int64, error)

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

func (Node) StakingParams added in v0.21.1

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 added in v0.21.0

func WithCampaignQueryClient(client campaigntypes.QueryClient) Option

func WithLaunchQueryClient added in v0.21.0

func WithLaunchQueryClient(client launchtypes.QueryClient) Option

func WithProfileQueryClient added in v0.21.0

func WithProfileQueryClient(client profiletypes.QueryClient) Option

func WithRewardQueryClient added in v0.21.0

func WithRewardQueryClient(client rewardtypes.QueryClient) Option

func WithStakingQueryClient added in v0.22.0

func WithStakingQueryClient(client stakingtypes.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 WithPercentageShares added in v0.22.0

func WithPercentageShares(sharePercentages []SharePercent) PublishOption

WithPercentageShares 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.

type SharePercent added in v0.22.0

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

SharePercent represent percent of total share

func NewSharePercent added in v0.22.0

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

NewSharePercent creates new share percent representation

func SharePercentFromString added in v0.22.0

func SharePercentFromString(str string) (SharePercent, error)

SharePercentFromString parses share percent from string format: 11.87%foo

func (SharePercent) Share added in v0.22.0

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

Share returns coin share of total according to underlying percent

type SharePercents added in v0.22.0

type SharePercents []SharePercent

func ParseSharePercents added in v0.22.0

func ParseSharePercents(percents string) (SharePercents, error)

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

func (SharePercents) Empty added in v0.22.0

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