vm

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 30 Imported by: 1

Documentation

Index

Constants

View Source
const JSONRPCEndpoint = "/nuklaiapi"
View Source
const Namespace = "controller"

Variables

View Source
var (
	ErrValidatorStakeNotFound = errors.New("validator stake not found")
	ErrDelegatorStakeNotFound = errors.New("delegator stake not found")
)
View Source
var (
	ActionParser *codec.TypeParser[chain.Action]
	AuthParser   *codec.TypeParser[chain.Auth]
	OutputParser *codec.TypeParser[codec.Typed]
)

Functions

func CreateParser

func CreateParser(genesisBytes []byte) (chain.Parser, error)

Used as a lambda function for creating ExternalSubscriberServer parser

func New

func New(options ...vm.Option) (*vm.VM, error)

New returns a VM with the indexer, websocket, rpc, and external subscriber apis enabled.

func NewParser

func NewParser(genesis *genesis.Genesis) chain.Parser

func NewWithOptions

func NewWithOptions(options ...vm.Option) (*vm.VM, error)

NewWithOptions returns a VM with the specified options

func With

func With() vm.Option

func WithEmissionBalancer

func WithEmissionBalancer() vm.Option

func WithRuntime

func WithRuntime() vm.Option

Types

type AssetArgs

type AssetArgs struct {
	Asset string `json:"asset"`
}

type AssetReply

type AssetReply struct {
	AssetType                    string `json:"assetType"`
	Name                         string `json:"name"`
	Symbol                       string `json:"symbol"`
	Decimals                     uint8  `json:"decimals"`
	Metadata                     string `json:"metadata"`
	URI                          string `json:"uri"`
	TotalSupply                  uint64 `json:"totalSupply"`
	MaxSupply                    uint64 `json:"maxSupply"`
	Owner                        string `json:"owner"`
	MintAdmin                    string `json:"mintAdmin"`
	PauseUnpauseAdmin            string `json:"pauseUnpauseAdmin"`
	FreezeUnfreezeAdmin          string `json:"freezeUnfreezeAdmin"`
	EnableDisableKYCAccountAdmin string `json:"enableDisableKYCAccountAdmin"`
}

type BalanceArgs

type BalanceArgs struct {
	Address string `json:"address"`
	Asset   string `json:"asset"`
}

type BalanceReply

type BalanceReply struct {
	Amount uint64 `json:"amount"`
}

type Config

type Config struct {
	Enabled bool `json:"enabled"`
}

func NewDefaultConfig

func NewDefaultConfig() Config

type DatasetArgs

type DatasetArgs struct {
	Dataset string `json:"dataset"`
}

type DatasetContributionArgs

type DatasetContributionArgs struct {
	ContributionID string `json:"contributionID"`
}

type DatasetContributionReply

type DatasetContributionReply struct {
	DatasetAddress string `json:"datasetAddress"`
	DataLocation   string `json:"dataLocation"`
	DataIdentifier string `json:"dataIdentifier"`
	Contributor    string `json:"contributor"`
	Active         bool   `json:"active"`
}

type DatasetReply

type DatasetReply struct {
	Name                         string `json:"name"`
	Description                  string `json:"description"`
	Categories                   string `json:"categories"`
	LicenseName                  string `json:"licenseName"`
	LicenseSymbol                string `json:"licenseSymbol"`
	LicenseURL                   string `json:"licenseURL"`
	Metadata                     string `json:"metadata"`
	IsCommunityDataset           bool   `json:"isCommunityDataset"`
	MarketplaceAssetAddress      string `json:"marketplaceAssetAddress"`
	BaseAssetAddress             string `json:"baseAssetAddress"`
	BasePrice                    uint64 `json:"basePrice"`
	RevenueModelDataShare        uint8  `json:"revenueModelDataShare"`
	RevenueModelMetadataShare    uint8  `json:"revenueModelMetadataShare"`
	RevenueModelDataOwnerCut     uint8  `json:"revenueModelDataOwnerCut"`
	RevenueModelMetadataOwnerCut uint8  `json:"revenueModelMetadataOwnerCut"`
	Owner                        string `json:"owner"`
}

type EmissionAccount

type EmissionAccount struct {
	Address           string `json:"address"`
	AccumulatedReward uint64 `json:"accumulatedReward"`
}

type EmissionReply

type EmissionReply struct {
	CurrentBlockHeight uint64                `json:"currentBlockHeight"`
	TotalSupply        uint64                `json:"totalSupply"`
	MaxSupply          uint64                `json:"maxSupply"`
	TotalStaked        uint64                `json:"totalStaked"`
	RewardsPerEpoch    uint64                `json:"rewardsPerEpoch"`
	EmissionAccount    EmissionAccount       `json:"emissionAccount"`
	EpochTracker       emission.EpochTracker `json:"epochTracker"`
}

type GenesisReply

type GenesisReply struct {
	Genesis *genesis.Genesis `json:"genesis"`
}

type JSONRPCClient

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

func NewJSONRPCClient

func NewJSONRPCClient(uri string) *JSONRPCClient

NewJSONRPCClient creates a new client object.

func (*JSONRPCClient) AllValidators

func (cli *JSONRPCClient) AllValidators(ctx context.Context) ([]*emission.Validator, error)

func (*JSONRPCClient) Asset

func (*JSONRPCClient) Balance

func (cli *JSONRPCClient) Balance(ctx context.Context, addr string, asset string) (uint64, error)

func (*JSONRPCClient) Dataset

func (cli *JSONRPCClient) Dataset(
	ctx context.Context,
	dataset string,
	useCache bool,
) (string, string, string, string, string, string, string, bool, string, string, uint64, uint8, uint8, uint8, uint8, string, error)

func (*JSONRPCClient) DatasetContribution

func (cli *JSONRPCClient) DatasetContribution(ctx context.Context, contributionID string) (string, string, string, string, bool, error)

func (*JSONRPCClient) EmissionInfo

func (*JSONRPCClient) Genesis

func (cli *JSONRPCClient) Genesis(ctx context.Context) (*genesis.Genesis, error)

func (*JSONRPCClient) Parser

func (cli *JSONRPCClient) Parser(ctx context.Context) (chain.Parser, error)

func (*JSONRPCClient) Simulate

func (cli *JSONRPCClient) Simulate(ctx context.Context, callTx actions.ContractCall, actor codec.Address) (state.Keys, uint64, error)

func (*JSONRPCClient) StakedValidators

func (cli *JSONRPCClient) StakedValidators(ctx context.Context) ([]*emission.Validator, error)

func (*JSONRPCClient) UserStake

func (cli *JSONRPCClient) UserStake(ctx context.Context, owner string, nodeID string) (uint64, uint64, uint64, string, string, error)

func (*JSONRPCClient) ValidatorStake

func (cli *JSONRPCClient) ValidatorStake(ctx context.Context, nodeID ids.NodeID) (uint64, uint64, uint64, uint64, string, string, error)

func (*JSONRPCClient) WaitForBalance

func (cli *JSONRPCClient) WaitForBalance(
	ctx context.Context,
	addr string,
	asset string,
	min uint64,
) error

type JSONRPCServer

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

func NewJSONRPCServer

func NewJSONRPCServer(vm api.VM) *JSONRPCServer

func (*JSONRPCServer) AllValidators

func (j *JSONRPCServer) AllValidators(req *http.Request, _ *struct{}, reply *ValidatorsReply) (err error)

func (*JSONRPCServer) Asset

func (j *JSONRPCServer) Asset(req *http.Request, args *AssetArgs, reply *AssetReply) error

func (*JSONRPCServer) Balance

func (j *JSONRPCServer) Balance(req *http.Request, args *BalanceArgs, reply *BalanceReply) error

func (*JSONRPCServer) Dataset

func (j *JSONRPCServer) Dataset(req *http.Request, args *DatasetArgs, reply *DatasetReply) error

func (*JSONRPCServer) DatasetContribution

func (j *JSONRPCServer) DatasetContribution(req *http.Request, args *DatasetContributionArgs, reply *DatasetContributionReply) (err error)

func (*JSONRPCServer) EmissionInfo

func (j *JSONRPCServer) EmissionInfo(req *http.Request, _ *struct{}, reply *EmissionReply) (err error)

func (*JSONRPCServer) Genesis

func (j *JSONRPCServer) Genesis(_ *http.Request, _ *struct{}, reply *GenesisReply) (err error)

func (*JSONRPCServer) SimulateCallContractTx

func (j *JSONRPCServer) SimulateCallContractTx(req *http.Request, args *SimulateCallTxArgs, reply *SimulateCallTxReply) (err error)

func (*JSONRPCServer) StakedValidators

func (j *JSONRPCServer) StakedValidators(req *http.Request, _ *struct{}, reply *ValidatorsReply) (err error)

func (*JSONRPCServer) UserStake

func (j *JSONRPCServer) UserStake(req *http.Request, args *UserStakeArgs, reply *UserStakeReply) (err error)

func (*JSONRPCServer) ValidatorStake

func (j *JSONRPCServer) ValidatorStake(req *http.Request, args *ValidatorStakeArgs, reply *ValidatorStakeReply) (err error)

type Parser

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

func (*Parser) ActionRegistry

func (*Parser) ActionRegistry() chain.ActionRegistry

func (*Parser) AuthRegistry

func (*Parser) AuthRegistry() chain.AuthRegistry

func (*Parser) OutputRegistry

func (*Parser) OutputRegistry() chain.OutputRegistry

func (*Parser) Rules

func (p *Parser) Rules(_ int64) chain.Rules

func (*Parser) StateManager

func (*Parser) StateManager() chain.StateManager

type SimulateCallTxArgs

type SimulateCallTxArgs struct {
	CallTx actions.ContractCall `json:"callTx"`
	Actor  codec.Address        `json:"actor"`
}

type SimulateCallTxReply

type SimulateCallTxReply struct {
	StateKeys    []SimulateStateKey `json:"stateKeys"`
	FuelConsumed uint64             `json:"fuel"`
}

type SimulateStateKey

type SimulateStateKey struct {
	HexKey      string `json:"hex"`
	Permissions byte   `json:"perm"`
}

type UserStakeArgs

type UserStakeArgs struct {
	Owner  string `json:"owner"`
	NodeID string `json:"nodeID"`
}

type UserStakeReply

type UserStakeReply struct {
	StakeStartBlock uint64 `json:"stakeStartBlock"` // Start block of the stake
	StakeEndBlock   uint64 `json:"stakeEndBlock"`   // End block of the stake
	StakedAmount    uint64 `json:"stakedAmount"`    // Amount of NAI staked
	RewardAddress   string `json:"rewardAddress"`   // Address to receive rewards
	OwnerAddress    string `json:"ownerAddress"`    // Address of the owner who delegated
}

type ValidatorStakeArgs

type ValidatorStakeArgs struct {
	NodeID ids.NodeID `json:"nodeID"`
}

type ValidatorStakeReply

type ValidatorStakeReply struct {
	StakeStartBlock   uint64 `json:"stakeStartBlock"`   // Start block of the stake
	StakeEndBlock     uint64 `json:"stakeEndBlock"`     // End block of the stake
	StakedAmount      uint64 `json:"stakedAmount"`      // Amount of NAI staked
	DelegationFeeRate uint64 `json:"delegationFeeRate"` // Delegation fee rate
	RewardAddress     string `json:"rewardAddress"`     // Address to receive rewards
	OwnerAddress      string `json:"ownerAddress"`      // Address of the owner who registered the validator
}

type ValidatorsReply

type ValidatorsReply struct {
	Validators []*emission.Validator `json:"validators"`
}

Jump to

Keyboard shortcuts

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