spn

package
v0.14.1-0...-8b31b97 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientCtx

func NewClientCtx(kr keyring.Keyring, c *rpchttp.HTTP, out io.Writer) client.Context

func NewFactory

func NewFactory(clientCtx client.Context) tx.Factory

NewFactory creates a new Factory.

Types

type Account

type Account struct {
	Name     string
	Address  string
	Mnemonic string
}

Account represents an account on SPN.

type Chain

type Chain struct {
	ChainID   string
	Creator   string
	URL       string
	Hash      string
	CreatedAt time.Time
}

Chain represents a chain in Genesis module of SPN.

type ChainListOption

type ChainListOption func(*chainListOptions)

ChainListOption configures chain listing options.

func PaginateChainListing

func PaginateChainListing(key []byte, limit uint64) ChainListOption

PaginateChainListing sets pagination for chain listing.

func PrefixChainListing

func PrefixChainListing(prefix string) ChainListOption

PrefixChainListing sets the prefix for the chain to search for.

type Client

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

Client is client to interact with SPN.

func New

func New(nodeAddress, apiAddress, faucetAddress string, option ...Option) (*Client, error)

New creates a new SPN Client with nodeAddress of a full SPN node. by default, OS is used as keyring backend.

func (*Client) AccountCreate

func (c *Client) AccountCreate(accountName, mnemonic string) (Account, error)

AccountCreate creates an account by name and mnemonic (optional) in the keyring.

func (*Client) AccountExport

func (c *Client) AccountExport(accountName, password string) (privateKey string, err error)

AccountExport exports an account in the keyring by name and an encryption password into privateKey. password later can be used to decrypt the privateKey.

func (*Client) AccountGet

func (c *Client) AccountGet(accountName string) (Account, error)

AccountGet retrieves an account by name from the keyring.

func (*Client) AccountImport

func (c *Client) AccountImport(accountName, privateKey, password string) error

AccountImport imports an account to the keyring by account name, privateKey and decryption password.

func (*Client) AccountList

func (c *Client) AccountList() ([]Account, error)

AccountList returns a list of accounts.

func (*Client) ChainCreate

func (c *Client) ChainCreate(ctx context.Context, accountName, chainID string, sourceURL, sourceHash string) error

ChainCreate creates a new chain.

func (*Client) ChainList

func (c *Client) ChainList(ctx context.Context, accountName string, options ...ChainListOption) (chains []Chain, nextPageKey []byte, err error)

ChainList lists chain summaries

func (*Client) LaunchInformation

func (c *Client) LaunchInformation(ctx context.Context, accountName, chainID string) (LaunchInformation, error)

LaunchInformation retrieves chain's launch information.

func (*Client) ProposalGet

func (c *Client) ProposalGet(ctx context.Context, accountName, chainID string, id int) (Proposal, error)

func (*Client) ProposalList

func (c *Client) ProposalList(ctx context.Context, acccountName, chainID string, options ...ProposalListOption) ([]Proposal, error)

ProposalList lists proposals on a chain by status.

func (*Client) Propose

func (c *Client) Propose(ctx context.Context, accountName, chainID string, proposals ...ProposalOption) error

Propose proposes given proposals in batch for chainID by using SPN accountName.

func (*Client) ShowChain

func (c *Client) ShowChain(ctx context.Context, accountName, chainID string) (Chain, error)

ShowChain shows chain info.

func (*Client) SimulatedLaunchInformation

func (c *Client) SimulatedLaunchInformation(ctx context.Context, accountName, chainID string, proposalIDs []int) (LaunchInformation, error)

SimulatedLaunchInformation retrieves chain's simulated launch information.

func (*Client) SubmitReviewals

func (c *Client) SubmitReviewals(ctx context.Context, accountName, chainID string, reviewals ...Reviewal) (gas uint64, broadcast func() error, err error)

SubmitReviewals submits reviewals for proposals in batch for chainID by using SPN accountName.

type GenesisAccount

type GenesisAccount struct {
	Address types.AccAddress
	Coins   types.Coins
}

GenesisAccount represents a genesis account inside a chain with its allocated coins.

type LaunchInformation

type LaunchInformation struct {
	GenesisAccounts []GenesisAccount
	GenTxs          []jsondoc.Doc
	Peers           []string
}

LaunchInformation keeps the chain's launch information.

type Option

type Option func(*options)

Option configures Client options.

func Keyring

func Keyring(keyring string) Option

Keyring uses given keyring type as storage.

type Proposal

type Proposal struct {
	ID        int                   `yaml:",omitempty"`
	Status    ProposalStatus        `yaml:",omitempty"`
	Account   *ProposalAddAccount   `yaml:",omitempty"`
	Validator *ProposalAddValidator `yaml:",omitempty"`
}

Proposal represents a proposal.

type ProposalAddAccount

type ProposalAddAccount struct {
	Address string
	Coins   types.Coins
}

ProposalAddAccount used to propose adding an account.

type ProposalAddValidator

type ProposalAddValidator struct {
	Gentx            jsondoc.Doc
	ValidatorAddress string
	SelfDelegation   types.Coin
	P2PAddress       string
}

ProposalAddValidator used to propose adding a validator.

type ProposalListOption

type ProposalListOption func(*proposalListOptions)

ProposalListOption configures proposal listing options.

func ProposalListStatus

func ProposalListStatus(status ProposalStatus) ProposalListOption

ProposalListStatus sets proposal status filter for proposal listing.

func ProposalListType

func ProposalListType(typ ProposalType) ProposalListOption

ProposalListType sets proposal type filter for proposal listing.

type ProposalOption

type ProposalOption func(*Proposal)

ProposalOption configures Proposal to set a spesific type of proposal.

func AddAccountProposal

func AddAccountProposal(address string, coins types.Coins) ProposalOption

AddAccountProposal creates an add account proposal option.

func AddValidatorProposal

func AddValidatorProposal(gentx jsondoc.Doc, validatorAddress string, selfDelegation types.Coin, p2pAddress string) ProposalOption

AddValidatorProposal creates an add validator proposal option.

type ProposalStatus

type ProposalStatus string

ProposalStatus represents the status of the proposal

const (
	ProposalStatusAll      ProposalStatus = ""
	ProposalStatusPending  ProposalStatus = "pending"
	ProposalStatusApproved ProposalStatus = "approved"
	ProposalStatusRejected ProposalStatus = "rejected"
)

type ProposalType

type ProposalType string

ProposalType represents the type of the proposal

const (
	ProposalTypeAll          ProposalType = ""
	ProposalTypeAddAccount   ProposalType = "add-account"
	ProposalTypeAddValidator ProposalType = "add-validator"
)

type Reviewal

type Reviewal func(*reviewal)

Reviewal configures reviewal to create a review for a proposal.

func ApproveProposal

func ApproveProposal(id int) Reviewal

ApproveProposal returns approval for a proposal with id.

func RejectProposal

func RejectProposal(id int) Reviewal

RejectProposal returns rejection for a proposals with id.

Jump to

Keyboard shortcuts

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