modules

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 55 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusCodeServerErr             = "server_err"
	StatusCodeInvalidPass           = "invalid_passphrase"
	StatusCodeAddressRequire        = "addr_required"
	StatusCodeAccountNotFound       = "account_not_found"
	StatusCodeInvalidParam          = "invalid_param"
	StatusCodeInvalidProposerPubKey = "invalid_proposer_pub_key"
	StatusCodeMempoolAddFail        = "err_mempool"
	StatusCodePushKeyNotFound       = "push_key_not_found"
	StatusCodeRepoNotFound          = "repo_not_found"
	StatusCodePathNotFound          = "path_not_found"
	StatusCodePathNotAFile          = "path_not_file"
	StatusCodeReferenceNotFound     = "reference_not_found"
	StatusCodeBranchNotFound        = "branch_not_found"
	StatusCodeCommitNotFound        = "commit_not_found"
	StatusCodeTxNotFound            = "tx_not_found"
)

Variables

This section is empty.

Functions

func Select

func Select(json string, selectors ...string) (map[string]interface{}, error)

Select selects fields and their value from the given JSON string using dot notation.

Types

type ClientContext

type ClientContext struct {
	Client  types2.Client
	Objects map[string]interface{}
}

type ConsoleUtilModule

type ConsoleUtilModule struct {
	types.ModuleCommon
	// contains filtered or unexported fields
}

ConsoleUtilModule provides access to various console utility functions.

func NewConsoleUtilModule

func NewConsoleUtilModule(stdout io.Writer) *ConsoleUtilModule

NewConsoleUtilModule creates an instance of ConsoleUtilModule

func (*ConsoleUtilModule) ConfigureVM

func (m *ConsoleUtilModule) ConfigureVM(vm *otto.Otto) prompt.Completer

ConfigureVM configures the JS context and return any number of console prompt suggestions

func (*ConsoleUtilModule) Diff

func (m *ConsoleUtilModule) Diff(a, b interface{})

Diff returns a human-readable report of the differences between two values. It returns an empty string if and only if Equal returns true for the same input values and options.

func (*ConsoleUtilModule) Dump

func (m *ConsoleUtilModule) Dump(objs ...interface{})

Dump displays the passed parameters to standard out.

func (*ConsoleUtilModule) Eval

func (m *ConsoleUtilModule) Eval(src interface{}) otto.Value

Eval executes the given JavaScript source and returns the output

func (*ConsoleUtilModule) EvalFile

func (m *ConsoleUtilModule) EvalFile(file string) otto.Value

EvalFile executes given JavaScript script file and returns the output

func (*ConsoleUtilModule) GenKey

func (m *ConsoleUtilModule) GenKey(seed ...int64) util.Map

GenKey generates an Ed25519 key. seed: Specify an optional seed

func (*ConsoleUtilModule) PrettyPrint

func (m *ConsoleUtilModule) PrettyPrint(values ...interface{})

PrettyPrint pretty prints any object. Useful for debugging.

func (*ConsoleUtilModule) ReadFile

func (m *ConsoleUtilModule) ReadFile(filename string) []byte

ReadFile returns the content of the given file

func (*ConsoleUtilModule) ReadTextFile

func (m *ConsoleUtilModule) ReadTextFile(filename string) string

ReadTextFile is like ReadTextFile but casts the content to string type.

func (*ConsoleUtilModule) TreasuryAddress

func (m *ConsoleUtilModule) TreasuryAddress() string

TreasuryAddress returns the treasury address

type DHTModule

type DHTModule struct {
	modulestypes.ModuleCommon
	// contains filtered or unexported fields
}

DHTModule provides access to the DHT service

func NewAttachableDHTModule

func NewAttachableDHTModule(cfg *config.AppConfig, client types2.Client) *DHTModule

NewAttachableDHTModule creates an instance of DHTModule suitable in attach mode

func NewDHTModule

func NewDHTModule(cfg *config.AppConfig, dht dht2.DHT) *DHTModule

NewDHTModule creates an instance of DHTModule

func (*DHTModule) Announce

func (m *DHTModule) Announce(key string)

announce announces to the network that the node can provide value for a given key

func (*DHTModule) ConfigureVM

func (m *DHTModule) ConfigureVM(vm *otto.Otto) prompt.Completer

ConfigureVM configures the JS context and return any number of console prompt suggestions

func (*DHTModule) GetPeers

func (m *DHTModule) GetPeers() (peers []string)

GetPeers getPeers returns a list of DHT peer IDs

func (*DHTModule) GetProviders

func (m *DHTModule) GetProviders(key string) (res []util.Map)

GetProviders returns the providers for a given key

ARGS: hash: The data key

RETURNS: resp <[]map[string]interface{}> - resp.id <string>: The peer ID of the provider - resp.addresses: <[]string>: A list of p2p multiaddrs of the provider

func (*DHTModule) GetRepoObjectProviders

func (m *DHTModule) GetRepoObjectProviders(hash string) (res []util.Map)

GetRepoObjectProviders returns the providers for a given repo object

ARGS: hash: The repo object's hash or DHT object hex-encoded key

RETURNS: resp <[]map[string]interface{}> - resp.id <string>: The peer ID of the provider - resp.addresses: <[]string>: A list of p2p multiaddrs of the provider

func (*DHTModule) Lookup

func (m *DHTModule) Lookup(key string) string

Lookup lookup finds a value for a given key

RETURNS <base64 string>: The data stored on the key

func (*DHTModule) Store

func (m *DHTModule) Store(key string, val string)

Store store stores a value corresponding to the given key

type DevModule

type DevModule struct {
	types.ModuleCommon
	// contains filtered or unexported fields
}

DevModule provides access to various development utility functions.

func NewDevModule

func NewDevModule() *DevModule

NewDevModule creates an instance of DevModule

func (*DevModule) ConfigureVM

func (m *DevModule) ConfigureVM(vm *otto.Otto) prompt.Completer

ConfigureVM configures the JS context and return any number of console prompt suggestions

func (*DevModule) GetDevUserAccountKey

func (m *DevModule) GetDevUserAccountKey() string

GetDevUserAccountKey returns the development account key

func (*DevModule) GetDevUserAddress

func (m *DevModule) GetDevUserAddress() string

GetDevUserAddress returns the development account address

type Module

type Module struct {
	Modules *modulestypes.Modules
	// contains filtered or unexported fields
}

Module implements ModulesHub. It is a hub for other modules.

func New

func New(cfg *config.AppConfig, acctmgr *keystore.Keystore, service services.Service, logic core.Logic,
	mempoolReactor *mempool.Reactor, ticketmgr types2.TicketManager, dht dht2.DHT,
	extMgr *extensions.Manager, remoteSvr core.RemoteServer) *Module

New creates an instance of Module

func NewAttachable

func NewAttachable(cfg *config.AppConfig, client types3.Client, ks *keystore.Keystore) *Module

NewAttachable creates an instance of Module configured for attach mode.

func (*Module) ConfigureVM

func (m *Module) ConfigureVM(vm *otto.Otto) (sugs []prompt.Completer)

ConfigureVM instructs VM-accessible modules accessible to configure the VM

func (*Module) GetModules

func (m *Module) GetModules() *modulestypes.Modules

GetModules returns all sub-modules

type NamespaceModule

type NamespaceModule struct {
	types.ModuleCommon
	// contains filtered or unexported fields
}

NamespaceModule provides namespace management functionalities

func NewAttachableNamespaceModule

func NewAttachableNamespaceModule(client types2.Client) *NamespaceModule

NewAttachableNamespaceModule creates an instance of NamespaceModule suitable in attach mode

func NewNamespaceModule

func NewNamespaceModule(service services.Service, remoteSrv core.RemoteServer, logic core.Logic) *NamespaceModule

NewNamespaceModule creates an instance of NamespaceModule

func (*NamespaceModule) ConfigureVM

func (m *NamespaceModule) ConfigureVM(vm *otto.Otto) prompt.Completer

ConfigureVM configures the JS context and return any number of console prompt suggestions

func (*NamespaceModule) GetTarget

func (m *NamespaceModule) GetTarget(uri string, height ...uint64) string

ARGS: uri: The full namespace URI to look up. [height]: The block height to query

RETURNS: <string>: A domain's target

func (*NamespaceModule) Lookup

func (m *NamespaceModule) Lookup(name string, height ...uint64) util.Map

Lookup finds a namespace

ARGS: name: The name of the namespace height: Optional max block height to limit the search to.

RETURNS: resp <map|nil> resp.name <string>: The name of the namespace resp.expired <bool>: Indicates whether the namespace is expired resp.grace <bool>: Indicates whether the namespace is currently within the grace period

func (*NamespaceModule) Register

func (m *NamespaceModule) Register(params map[string]interface{}, options ...interface{}) util.Map

Register a new namespace

ARGS: params <map> - params.name <string>: The name of the namespace - params.value <string>: The cost of the namespace. - [params.to] <string>: Set the account or repository that will take ownership - [params.domains] <map[string]string>:The initial domain->target mapping - params.nonce <number|string>: The senders next account nonce - params.fee <number|string>: The transaction fee to pay - params.timestamp <number>: The unix timestamp

options <[]interface{}> - options[0] key <string>: The signer's private key - options[1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURNS object <map> - hash <string>: The transaction hash

func (*NamespaceModule) UpdateDomain

func (m *NamespaceModule) UpdateDomain(params map[string]interface{}, options ...interface{}) util.Map

UpdateDomain updates one or more domains of a namespace

ARGS: params <map> params.name <string>: The name of the namespace params.domains <map[string]string>: The domain->target mapping params.nonce <number|string>: The senders next account nonce params.fee <number|string>: The transaction fee to pay params.timestamp <number>: The unix timestamp

options <[]interface{}> options[0] key <string>: The signer's private key options[1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURNS object <map> object.hash <string>: The transaction hash

type NodeModule

type NodeModule struct {
	types.ModuleCommon
	// contains filtered or unexported fields
}

NodeModule provides access to chain information

func NewAttachableChainModule

func NewAttachableChainModule(client types2.Client) *NodeModule

NewAttachableChainModule creates an instance of NodeModule suitable in attach mode

func NewChainModule

func NewChainModule(service services.Service, keepers core.Keepers) *NodeModule

NewChainModule creates an instance of NodeModule

func (*NodeModule) ConfigureVM

func (m *NodeModule) ConfigureVM(vm *otto.Otto) prompt.Completer

ConfigureVM configures the JS context and return any number of console prompt suggestions

func (*NodeModule) GetBlock

func (m *NodeModule) GetBlock(height string) util.Map

GetBlock fetches a block at the given height

func (*NodeModule) GetBlockInfo

func (m *NodeModule) GetBlockInfo(height string) util.Map

GetBlockInfo Get summarized block information at a given height

func (*NodeModule) GetCurHeight added in v0.0.29

func (m *NodeModule) GetCurHeight() string

GetHeight returns the current block height

func (*NodeModule) GetCurrentEpoch added in v0.0.29

func (m *NodeModule) GetCurrentEpoch() string

GetCurrentEpoch returns the current epoch

func (*NodeModule) GetEpoch added in v0.0.29

func (m *NodeModule) GetEpoch(height int64) string

GetEpoch returns the epoch of a block height

func (*NodeModule) GetValidators

func (m *NodeModule) GetValidators(height string) (res []util.Map)

GetValidators returns validators of a given block

  • height: The target block height

RETURNS res []map

  • publicKey <string>: The base58 public key of validator
  • address <string>: The bech32 address of the validator
  • tmAddr <string>: The tendermint address and the validator
  • ticketId <string>: The id of the validator ticket

func (*NodeModule) IsSyncing

func (m *NodeModule) IsSyncing() bool

IsSyncing checks whether the node is synchronizing with peers

type PoolModule

type PoolModule struct {
	modulestypes.ModuleCommon
	// contains filtered or unexported fields
}

PoolModule provides access to the transaction pool

func NewAttachablePoolModule

func NewAttachablePoolModule(client types2.Client) *PoolModule

NewAttachablePoolModule creates an instance of PoolModule suitable in attach mode

func NewPoolModule

func NewPoolModule(reactor core.MempoolReactor, pushPool types.PushPool) *PoolModule

NewPoolModule creates an instance of PoolModule

func (*PoolModule) ConfigureVM

func (m *PoolModule) ConfigureVM(vm *otto.Otto) prompt.Completer

ConfigureVM configures the JS context and return any number of console prompt suggestions

func (*PoolModule) GetPushPoolSize

func (m *PoolModule) GetPushPoolSize() int

getPushPoolSize returns the size of the push pool

func (*PoolModule) GetSize

func (m *PoolModule) GetSize() util.Map

getSize returns the size of the pool

func (*PoolModule) GetTop

func (m *PoolModule) GetTop(n int) []util.Map

getTop returns all the transactions in the pool

type PushKeyModule

type PushKeyModule struct {
	modulestypes.ModuleCommon
	// contains filtered or unexported fields
}

PushKeyModule manages and provides access to push keys.

func NewAttachablePushKeyModule

func NewAttachablePushKeyModule(cfg *config.AppConfig, client types2.Client) *PushKeyModule

NewAttachablePushKeyModule creates an instance of PushKeyModule suitable in attach mode

func NewPushKeyModule

func NewPushKeyModule(cfg *config.AppConfig, service services.Service, logic core.Logic) *PushKeyModule

NewPushKeyModule creates an instance of PushKeyModule

func (*PushKeyModule) ConfigureVM

func (m *PushKeyModule) ConfigureVM(vm *otto.Otto) prompt.Completer

ConfigureVM configures the JS context and return any number of console prompt suggestions

func (*PushKeyModule) Find

func (m *PushKeyModule) Find(address string, height ...uint64) util.Map

Find finds and returns a push key

ARGS: address: The push key address [height]: The target block height to query (default: latest)

RETURNS state.PushKey

func (*PushKeyModule) GetAccountOfOwner

func (m *PushKeyModule) GetAccountOfOwner(address string, height ...uint64) util.Map

GetAccountOfOwner returns the account of the key owner

ARGS: address: The push key address [height]: The target block height to query (default: latest)

RETURNS state.Account

func (*PushKeyModule) GetByAddress

func (m *PushKeyModule) GetByAddress(address string) []string

GetByAddress returns a list of push key addresses owned by the given user address

ARGS: address: An address of an account

RETURNS: List of push key ids

func (*PushKeyModule) Register

func (m *PushKeyModule) Register(params map[string]interface{}, options ...interface{}) util.Map

Register registers a push key with the network.

ARGS: params <map> - params.nonce <number|string>: he senders next account nonce - params.fee <number|string>: The transaction fee to pay - params.timestamp <number>: The unix timestamp - params.pubKey <string>:The public key - params.scopes <string|[]string>: A list of repo or namespace where the key can be used. - params.feeCap <number|string>: The max. amount of fee the key can spend

options <[]interface{}> - options[0] key <string>: The signer's private key - options[1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURNS object <map>: - hash <string>: The transaction hash - address <string>: The push key address

func (*PushKeyModule) Unregister

func (m *PushKeyModule) Unregister(params map[string]interface{}, options ...interface{}) util.Map

Unregister removes a push key from the network

ARGS: - params <map> - params.nonce <number|string>: The senders next account nonce - params.fee <number|string>: The transaction fee to pay - params.timestamp <number>: The unix timestamp - params.id <string>: The target push key ID

options <[]interface{}> - options[0] key <string>: The signer's private key - options[1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURNS object <map>: - hash <string>: The transaction hash

func (*PushKeyModule) Update

func (m *PushKeyModule) Update(params map[string]interface{}, options ...interface{}) util.Map

Update updates a push key

ARGS: params <map> - params.nonce <number|string>: The senders next account nonce - params.fee <number|string>: The transaction fee to pay - params.timestamp <number>: The unix timestamp - params.id <string>: The target push key ID - params.addScopes <string|[]string>: Provide repo names or namespaces where the key can be used. - params.removeScopes <int|[]int>: Select indices of existing scopes to be deleted. - params.feeCap <number|string>: The max. amount of fee the key can spend

options <[]interface{}> - options[0] key <string>: The signer's private key - options[1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURNS object <map>: - hash <string>: The transaction hash

type RPCModule

type RPCModule struct {
	types.ModuleCommon

	ClientContextMaker func(client types2.Client) *ClientContext
	// contains filtered or unexported fields
}

RPCModule provides RPCClient functionalities

func NewRPCModule

func NewRPCModule(cfg *config.AppConfig) *RPCModule

NewRPCModule creates an instance of RPCModule

func (*RPCModule) ConfigureVM

func (m *RPCModule) ConfigureVM(vm *otto.Otto) prompt.Completer

ConfigureVM configures the JS context and return any number of console prompt suggestions

func (*RPCModule) ConnectLocal

func (m *RPCModule) ConnectLocal() util.Map

ConnectLocal returns an RPC client connected to the local RPC server

type RepoModule

type RepoModule struct {
	modtypes.ModuleCommon
	// contains filtered or unexported fields
}

RepoModule provides repository functionalities to JS environment

func NewAttachableRepoModule

func NewAttachableRepoModule(client rpctypes.Client) *RepoModule

NewAttachableRepoModule creates an instance of RepoModule suitable in attach mode

func NewRepoModule

func NewRepoModule(service services.Service, repoSrv core.RemoteServer, logic core.Logic) *RepoModule

NewRepoModule creates an instance of RepoModule

func (*RepoModule) AddContributor

func (m *RepoModule) AddContributor(params map[string]interface{}, options ...interface{}) util.Map

AddContributor creates a proposal to register one or more push keys

params <map>

  • name <string>: The name of the repository
  • id <string>: A unique proposal ID
  • ids <string|[]string>: A list or comma separated list of push key IDs to add
  • policies <[]map[string]interface{}>: A list of policies
  • sub <string>: The policy's subject
  • obj <string>: The policy's object
  • act <string>: The policy's action
  • value <string|number>: The proposal fee to pay
  • nonce <number|string>: The senders next account nonce
  • fee <number|string>: The transaction fee to pay
  • timestamp <number>: The unix timestamp
  • namespace <string>: A namespace to also register the key to
  • namespaceOnly <string>: Like namespace but key will not be registered to the repo.

options <[]interface{}>

  • [0] key <string>: The signer's private key
  • [1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURN object <map>

  • hash <string>: The transaction hash

func (*RepoModule) ConfigureVM

func (m *RepoModule) ConfigureVM(vm *otto.Otto) prompt.Completer

ConfigureVM configures the JS context and return any number of console prompt suggestions

func (*RepoModule) CountCommits added in v0.0.30

func (m *RepoModule) CountCommits(name, ref string) int

CountCommits returns the number commits in a branch/reference.

  • name: The name of the target repository.
  • ref: The target branch or reference.

func (*RepoModule) Create

func (m *RepoModule) Create(params map[string]interface{}, options ...interface{}) util.Map

Create registers a git repository on the network

params <map>

  • name <string>: The name of the namespace
  • value <string>: The amount to pay for initial resources
  • nonce <number|string>: The senders next account nonce
  • fee <number|string>: The transaction fee to pay
  • timestamp <number>: The unix timestamp
  • config <object>: The repo configuration
  • sig <String>: The transaction signature

options <[]interface{}>

  • [0] key <string>: The signer's private key
  • [1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURN object <map>

  • hash <string>: The transaction hash
  • address <string: The address of the repository

func (*RepoModule) DepositProposalFee

func (m *RepoModule) DepositProposalFee(params map[string]interface{}, options ...interface{}) util.Map

DepositProposalFee creates a transaction to deposit a fee to a proposal

params <map>

  • params.name <string>: The name of the repository
  • params.id <string>: A unique proposal ID
  • params.value <string|number>: The amount to add
  • params.nonce <number|string>: The senders next account nonce
  • params.fee <number|string>: The transaction fee to pay
  • params.timestamp <number>: The unix timestamp

options <[]interface{}>

  • [0] key <string>: The signer's private key
  • [1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURN object <map>

  • hash <string>: The transaction hash

func (*RepoModule) Get

func (m *RepoModule) Get(name string, opts ...modtypes.GetOptions) util.Map

Get finds and returns a repository.

name: The name of the repository

opts <map>: fetch options

  • opts.height: Query a specific block
  • opts.select: Provide a list of dot-notated fields to be returned.

RETURN <state.Repository>

func (*RepoModule) GetBranches

func (m *RepoModule) GetBranches(name string) []string

GetBranches returns the list of branches

  • name: The name of the target repository.

func (*RepoModule) GetCommit added in v0.0.30

func (m *RepoModule) GetCommit(name, hash string) util.Map

GetCommit gets a commit.

  • name: The name of the repository
  • hash: The commit hash.

func (*RepoModule) GetCommitAncestors

func (m *RepoModule) GetCommitAncestors(name, commitHash string, limit ...int) []util.Map

GetCommitAncestors returns ancestors of a commit with the given hash.

  • commitHash: The hash of the commit.
  • limit: The number of commit to return. 0 means all.

func (*RepoModule) GetCommits

func (m *RepoModule) GetCommits(name, branch string, limit ...int) []util.Map

GetCommits returns commits in a branch.

  • name: The name of the repository.
  • branch: The target branch.
  • limit: The number of commit to return. 0 means all.

func (*RepoModule) GetLatestBranchCommit

func (m *RepoModule) GetLatestBranchCommit(name, branch string) util.Map

GetLatestBranchCommit returns the latest commit of a branch in a repository.

  • name: The name of the target repository.
  • branch: The name of the branch.

func (*RepoModule) GetParentsAndCommitDiff added in v0.0.30

func (m *RepoModule) GetParentsAndCommitDiff(name string, commitHash string) util.Map

GetParentsAndCommitDiff gets the diff output between a commit and its parent(s).

  • name: The name of the target repository.
  • commitHash: The hash of the commit.

func (*RepoModule) GetReposCreatedByAddress added in v0.0.30

func (m *RepoModule) GetReposCreatedByAddress(address string) []string

GetReposCreatedByAddress returns names of repos created by an address

func (*RepoModule) GetTracked

func (m *RepoModule) GetTracked() util.Map

GetTracked returns the tracked repositories

func (*RepoModule) ListPath

func (m *RepoModule) ListPath(name, path string, revision ...string) []util.Map

ListPath returns a list of entries in a repository's path

  • name: The name of the target repository.
  • path: The file or directory path to list
  • revision: The revision that will be queried (default: HEAD).

func (*RepoModule) ReadFile added in v0.0.30

func (m *RepoModule) ReadFile(name, filePath string, revision ...string) string

ReadFile returns the string content of a file in a repository.

  • name: The name of the target repository.
  • filePath: The file path.
  • revision: The revision that will be queried (default: HEAD).

func (*RepoModule) ReadFileLines added in v0.0.30

func (m *RepoModule) ReadFileLines(name, filePath string, revision ...string) []string

ReadFileLines returns the lines of a file in a repository.

  • name: The name of the target repository.
  • filePath: The file path.
  • revision: The revision that will be queried (default: HEAD).

func (*RepoModule) Track

func (m *RepoModule) Track(names string, height ...uint64)

Track adds a repository to the track list.

  • names: A comma-separated list of repository or namespace names.

func (*RepoModule) UnTrack

func (m *RepoModule) UnTrack(names string)

UnTrack removes a repository from the track list.

  • names: A comma-separated list of repository or namespace names.

func (*RepoModule) Update

func (m *RepoModule) Update(params map[string]interface{}, options ...interface{}) util.Map

Update creates a proposal to update a repository

params <map>

  • name <string>: The name of the repository
  • id <string>: A unique proposal ID
  • value <string|number>: The proposal fee
  • config <map[string]string>: The updated repository config
  • nonce <number|string>: The senders next account nonce
  • fee <number|string>: The transaction fee to pay
  • timestamp <number>: The unix timestamp

options <[]interface{}>

  • [0] key <string>: The signer's private key
  • [1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURN object <map>

  • hash <string>: The transaction hash

func (*RepoModule) UpsertOwner

func (m *RepoModule) UpsertOwner(params map[string]interface{}, options ...interface{}) util.Map

UpsertOwner creates a proposal to add or update a repository owner

params <map>

  • id <string>: A unique proposal id
  • addresses <string>: A comma separated list of addresses
  • veto <bool>: The senders next account nonce
  • fee <number|string>: The transaction fee to pay
  • timestamp <number>: The unix timestamp

options <[]interface{}>

  • [0] key <string>: The signer's private key
  • [1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURN <map>: When payloadOnly is false

  • hash <string>: The transaction hash

func (*RepoModule) Vote

func (m *RepoModule) Vote(params map[string]interface{}, options ...interface{}) util.Map

Vote sends a TxTypeRepoCreate transaction to create a git repository

params <map>

  • id <string>: The proposal ID to vote on
  • name <string>: The name of the repository
  • vote <uint>: The vote choice (1) yes (0) no (2) vote no with veto (3) abstain
  • nonce <number|string>: The senders next account nonce
  • fee <number|string>: The transaction fee to pay
  • timestamp <number>: The unix timestamp

options <[]interface{}>

  • [0] key <string>: The signer's private key
  • [1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURN object <map>

  • hash <string>: The transaction hash

type TicketModule

type TicketModule struct {
	types.ModuleCommon
	// contains filtered or unexported fields
}

TicketModule provides access to various utility functions

func NewAttachableTicketModule

func NewAttachableTicketModule(client types2.Client) *TicketModule

NewAttachableTicketModule creates an instance of TicketModule suitable in attach mode

func NewTicketModule

func NewTicketModule(service services.Service, logic core.Logic, ticketmgr tickettypes.TicketManager) *TicketModule

NewTicketModule creates an instance of TicketModule

func (*TicketModule) BuyHostTicket

func (m *TicketModule) BuyHostTicket(params map[string]interface{}, options ...interface{}) util.Map

BuyHostTicket creates a transaction to acquire a host ticket

params <map>

  • value <number|string>: The amount to pay for the ticket
  • delegate <string>: A base58 public key of an active delegate
  • nonce <number|string>: The senders next account nonce
  • fee <number|string>: The transaction fee to pay
  • timestamp <number>: The unix timestamp

options <[]interface{}>

  • [0] key <string>: The signer's private key
  • [1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURNS object <map>

  • hash <string>: The transaction hash

func (*TicketModule) BuyValidatorTicket

func (m *TicketModule) BuyValidatorTicket(params map[string]interface{}, options ...interface{}) util.Map

BuyValidatorTicket creates a transaction to acquire a validator ticket

params <map>

  • value <number|string>: The amount to pay for the ticket
  • delegate <string>: A base58 public key of an active delegate
  • nonce <number|string>: The senders next account nonce
  • fee <number|string>: The transaction fee to pay
  • timestamp <number>: The unix timestamp

options <[]interface{}>

  • [0] key <string>: The signer's private key
  • [1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURNS object <map>

  • hash <string>: The transaction hash

func (*TicketModule) ConfigureVM

func (m *TicketModule) ConfigureVM(vm *otto.Otto) prompt.Completer

ConfigureVM configures the JS context and return any number of console prompt suggestions

func (*TicketModule) GetAll

func (m *TicketModule) GetAll(limit ...int) []util.Map

ListAll returns all tickets, sorted by the most recently added.

[limit] <int>: Set the number of result to return (default: 0 = no limit)

RETURNS <[]types.Ticket>

func (*TicketModule) GetHostTicketsByProposer

func (m *TicketModule) GetHostTicketsByProposer(proposerPubKey string, queryOpts ...util.Map) []util.Map

GetHostTicketsByProposer finds host tickets where the given public key is the proposer.

proposerPubKey: The public key of the target proposer

[queryOpts] <map>

  • immature <bool> Return immature tickets
  • mature <bool> Return mature tickets
  • expired <bool> Return expired tickets
  • unexpired <bool> Return expired tickets

RETURNS <[]types.Ticket>

func (*TicketModule) GetStats

func (m *TicketModule) GetStats(proPubKey ...string) (result util.Map)

TicketStats returns various statistics about tickets. If proposerPubKey is provided, stats will be personalized to the given proposer public key.

[proPubKey] <string>: Public key of a proposer

RETURNS result <map>

  • nonDelegated <number>: The total value of non-delegated tickets owned by the proposer
  • delegated <number>: The total value of tickets delegated to the proposer
  • power <number>: The total value of staked coins assigned to the proposer
  • all <number>: The total value of all tickets

func (*TicketModule) GetTopHosts

func (m *TicketModule) GetTopHosts(limit ...int) []util.Map

ListTopHosts returns top host tickets

[limit] <int>: Set the number of result to return (default: 0 = no limit)

RETURNS <[]types.Ticket>

func (*TicketModule) GetTopValidators

func (m *TicketModule) GetTopValidators(limit ...int) []util.Map

ListTopValidators returns top validator tickets

[limit] <int>: Set the number of result to return (default: 0 = no limit)

RETURNS <[]types.Ticket>

func (*TicketModule) GetValidatorTicketsByProposer

func (m *TicketModule) GetValidatorTicketsByProposer(proposerPubKey string, queryOpts ...util.Map) []util.Map

GetValidatorTicketsByProposer finds active validator tickets where the given public key is the proposer

proposerPubKey: The public key of the target proposer

[queryOpts] <map>

  • expired <bool> Forces only expired tickets to be returned

RETURNS <[]types.Ticket>

func (*TicketModule) UnbondHostTicket

func (m *TicketModule) UnbondHostTicket(params map[string]interface{}, options ...interface{}) util.Map

unbondHostTicket unbonds a host ticket

params <map>

  • hash <string>: A hash of the host ticket
  • nonce <number|string>: The senders next account nonce
  • fee <number|string>: The transaction fee to pay
  • timestamp <number>: The unix timestamp

options <[]interface{}>

  • [0] key <string>: The signer's private key
  • [1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURNS object <map>

  • hash <string>: The transaction hash

type TxModule

type TxModule struct {
	modulestypes.ModuleCommon
	// contains filtered or unexported fields
}

TxModule provides transaction functionalities to JS environment

func NewAttachableTxModule

func NewAttachableTxModule(client types2.Client) *TxModule

NewAttachableTxModule creates an instance of TxModule suitable in attach mode

func NewTxModule

func NewTxModule(service services.Service, logic core.Logic) *TxModule

NewTxModule creates an instance of TxModule

func (*TxModule) ConfigureVM

func (m *TxModule) ConfigureVM(vm *otto.Otto) prompt.Completer

ConfigureVM configures the JS context and return any number of console prompt suggestions

func (*TxModule) Get

func (m *TxModule) Get(hash string) util.Map

Get returns a tx by hash

ARGS:

  • hash: The transaction hash

RETURNS object <map>

  • object.status <string>: The status of the transaction (in_block, in_mempool or in_pushpool).
  • object.data <object>: The transaction object.

func (*TxModule) SendPayload

func (m *TxModule) SendPayload(params map[string]interface{}) util.Map

SendPayload sends an already signed transaction object to the network

ARGS:

  • params: The transaction data

RETURNS object <map>

  • object.hash <string>: The transaction hash

type UserModule

type UserModule struct {
	types.ModuleCommon
	// contains filtered or unexported fields
}

UserModule provides account management functionalities that are accessed through the JavaScript console environment

func NewAttachableUserModule

func NewAttachableUserModule(cfg *config.AppConfig, client types2.Client, ks *keystore.Keystore) *UserModule

NewAttachableUserModule creates an instance of UserModule suitable in attach mode

func NewUserModule

func NewUserModule(
	cfg *config.AppConfig,
	keystore kstypes.Keystore,
	service services.Service,
	logic core.Logic) *UserModule

NewUserModule creates an instance of UserModule

func (*UserModule) ConfigureVM

func (m *UserModule) ConfigureVM(vm *otto.Otto) prompt.Completer

ConfigureVM configures the JS context and return any number of console prompt suggestions

func (*UserModule) GetAccount

func (m *UserModule) GetAccount(address string, height ...uint64) util.Map

GetAccount returns the account of the given address.

  • address: The address corresponding the account
  • [height]: The target block height to query (default: latest)

func (*UserModule) GetAvailableBalance

func (m *UserModule) GetAvailableBalance(address string, height ...uint64) string

GetAvailableBalance returns the spendable balance of an account.

  • address: The address corresponding the account
  • [height]: The target block height to query (default: latest)

func (*UserModule) GetKeys

func (m *UserModule) GetKeys() []string

GetKeys returns a list of address of keys on the keystore

func (*UserModule) GetNonce

func (m *UserModule) GetNonce(address string, height ...uint64) string

GetNonce returns the current nonce of a network account

  • address: The address corresponding the account
  • [passphrase]: The target block height to query (default: latest)
  • [height]: The target block height to query (default: latest)

func (*UserModule) GetPrivKey

func (m *UserModule) GetPrivKey(address string, passphrase ...string) string

GetPrivKey returns the private key of an account.

The passphrase argument is used to unlock the account. If passphrase is not set, an interactive prompt will be started to collect the passphrase without revealing it in the terminal.

  • address: The address corresponding the the local key
  • [passphrase]: The passphrase of the local key

func (*UserModule) GetPublicKey

func (m *UserModule) GetPublicKey(address string, passphrase ...string) string

getPublicKey returns the public key of a key.

The passphrase argument is used to unlock the key. If passphrase is not set, an interactive prompt will be started to collect the passphrase without revealing it in the terminal.

  • address: The address corresponding the the local key
  • [passphrase]: The passphrase of the local key

func (*UserModule) GetStakedBalance

func (m *UserModule) GetStakedBalance(address string, height ...uint64) string

GetStakedBalance returns the total staked coins of an account

  • address: The address corresponding the account
  • [height]: The target block height to query (default: latest)

func (*UserModule) GetValidator

func (m *UserModule) GetValidator(includePrivKey ...bool) util.Map

GetValidator getPrivateValidator returns the address, public and private keys of the validator.

  • includePrivKey: Indicates that the private key of the validator should be included in the result

RETURNS object <map>:

  • pubkey <string>: The validator base58 public key
  • address <string>: The validator's bech32 address.
  • tmAddr <string>: The tendermint address
  • privkey <string>: The validator's base58 public key

func (*UserModule) SendCoin

func (m *UserModule) SendCoin(params map[string]interface{}, options ...interface{}) util.Map

SendCoin sendCoin sends the native coin from a source account to a destination account.

params <map>

  • value <string>: The amount of coin to send
  • to <string>: The address of the recipient
  • nonce <number|string>: The senders next account nonce
  • fee <number|string>: The transaction fee to pay
  • timestamp <number>: The unix timestamp

options <[]interface{}>

  • [0] key <string>: The signer's private key
  • [1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURNS object <map>

  • hash <string>: The transaction hash

func (*UserModule) SetCommission

func (m *UserModule) SetCommission(params map[string]interface{}, options ...interface{}) util.Map

SetCommission setCommission sets the delegator commission for an account

params <map>

  • nonce <number|string>: The senders next account nonce
  • fee <number|string>: The transaction fee to pay
  • commission <number|string>: The network commission value
  • timestamp <number>: The unix timestamp

options <[]interface{}>

  • [0] key <string>: The signer's private key
  • [1] payloadOnly <bool>: When true, returns the payload only, without sending the tx.

RETURNS object <map>:

  • hash <string>: The transaction hash

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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