hiveenginego

package module
v0.0.0-...-2771bb8 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 6 Imported by: 0

README

HiveEngineGo - A client for the Hive Engine side chain on the Hive blockchain

At this time, there are only a few functions from the client. More will be added.

Example usage:

create a client:

herpc := hiveenginego.NewHiveEngineRpc("http://MyHiveEngineApi")

Query latest block info:

latestBlockInfo, err := herpc.GetLatestBlockInfo()
//Returns a struct
latestBlockNum := latestBlockInfo.BlockNumber

Get All NFT of a given symbol (return rpc resonse as raw bytes):

rawNftBytes, err := herpc.GetSymbolAllNftFast("STAR")

Get block range as the raw response from the rpc (in bytes):

rpcResponsesBytes, err := herpc.GetBlockRangeFast(start, end)

WARNING: It is not recommended to stream blocks from public APIs. They are provided as a service to users and saturating them with block requests may (rightfully) result in your IP getting banned

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BroadcastTx

type BroadcastTx struct {
}

type ContractQueryParams

type ContractQueryParams struct {
	Contract string                     `json:"contract"`
	Table    string                     `json:"table"`
	Query    interface{}                `json:"query"`
	Limit    int                        `json:"limit"`
	Offset   int                        `json:"offset"`
	Index    []ContractQueryParamsIndex `json:"indexes"`
}

type ContractQueryParamsIndex

type ContractQueryParamsIndex struct {
	Index      string `json:"index,omitempty"`
	Descending bool   `json:"descending"`
}

type ContractQueryParamsQuery

type ContractQueryParamsQuery struct {
	Account string `json:"account,omitempty"`
	NftId   string `json:"_id,omitempty"`
}

type ContractTx

type ContractTx struct {
	ContractName    string      `json:"contractName"`
	ContractAction  string      `json:"contractAction"`
	ContractPayload interface{} `json:"contractPayload"`
}

func CreateFungibleTokenTransfer

func CreateFungibleTokenTransfer(symbol string, to string, quantity string, memo string) ContractTx

func CreateNftTransfer

func CreateNftTransfer(symbol string, nftIds []int, to string, memo string) []ContractTx

type EngineBlock

type EngineBlock struct {
	BlockNumber         int             `json:"blockNumber"`
	RefHiveBlockNumber  int             `json:"refHiveBlockNumber"`
	Timestamp           string          `json:"timestamp"`
	Transactions        json.RawMessage `json:"transactions"`
	VirtualTransactions json.RawMessage `json:"virtualTransactions,omitempty"`
	Hash                string          `json:"hash"`
	DatabaseHash        string          `json:"databasehash"`
	MerkleRoot          string          `json:"merkleRoot"`
	Round               int             `json:"round"`
	RoundHash           string          `json:"roundHash"`
	Witness             string          `json:"witness"`
	SigningKey          string          `json:"signingKey"`
	RoundSignature      string          `json:"roundSignature"`
}

type EngineNft

type EngineNft struct {
	Id              int             `json:"_id"`
	Account         string          `json:"account"`
	OwnedBy         string          `json:"ownedBy"`
	LockedTokens    json.RawMessage `json:"lockedTokens"`
	Properties      json.RawMessage `json:"properties"`
	PreviousAccount string          `json:"previousAccount"`
	PreviousOwnedBy string          `json:"previousOwnedBy"`
}

type EngineStatus

type EngineStatus struct {
	LastBlockNumber             int    `json:"lastBlockNumber"`
	LastBlockRefHiveBlockNumber int    `json:"lastBlockRefHiveBlockNumber"`
	LastParsedHiveBlockNumber   int    `json:"lastParsedHiveBlockNumber"`
	LastVerifiedBlockNumber     int    `json:"lastVerifiedBlockNumber"`
	SSCnodeVersion              string `json:"SSCnodeVersion"`
	ChainId                     string `json:"chainId"`
	Domain                      string `json:"domain"`
	Lightnode                   bool   `json:"lightnode"`
	LastHash                    string `json:"lastHash"`
}

type FungibleBalance

type FungibleBalance struct {
	Id                   int    `json:"_id"`
	Account              string `json:"account"`
	Symbol               string `json:"symbol"`
	Balance              string `json:"balance"`
	Stake                string `json:"stake"`
	PendingUnstake       string `json:"pendingUnstake"`
	DelegationsIn        string `json:"delegationsIn"`
	DelegationsOut       string `json:"delegationsOut"`
	PendingUndelegations string `json:"pendingUndelegations"`
}

type FungibleTokenTransfer

type FungibleTokenTransfer struct {
	Symbol   string `json:"symbol"`
	To       string `json:"to"`
	Quantity string `json:"quantity"`
	Memo     string `json:"memo"`
}

type HiveEngineFungibleToken

type HiveEngineFungibleToken struct {
	FungibleId           int             `json:"_id"`
	Issuer               string          `json:"issuer"`
	Symbol               string          `json:"symbol"`
	Name                 string          `json:"name"`
	MetaData             json.RawMessage `json:"metadata"`
	DelegationEnabled    bool            `json:"delegationEnabled"`
	Precision            int             `json:"precision"`
	StakingEnabled       bool            `json:"stakingEnabled"`
	UndelegationCooldown int             `json:"undelegationCooldown"`
	UnstakingCooldown    int             `json:"unstakingCooldown"`
}

type HiveEngineRpcNode

type HiveEngineRpcNode struct {
	Endpoints engineApiEndpoints
	RpcNode   rpcServer
}

func NewHiveEngineRpc

func NewHiveEngineRpc(addr string) *HiveEngineRpcNode

func NewHiveEngineRpcWithOpts

func NewHiveEngineRpcWithOpts(addr string, blockchain string, contracts string, maxConn int, maxBatch int) *HiveEngineRpcNode

func (HiveEngineRpcNode) GetAllFungibleTokens

func (h HiveEngineRpcNode) GetAllFungibleTokens() ([]HiveEngineFungibleToken, error)

func (HiveEngineRpcNode) GetAllWitnesses

func (h HiveEngineRpcNode) GetAllWitnesses() ([]Witness, error)

func (HiveEngineRpcNode) GetBlockRange

func (h HiveEngineRpcNode) GetBlockRange(startBlock int, endBlock int) ([][]byte, error)

func (HiveEngineRpcNode) GetBlockRangeFast

func (h HiveEngineRpcNode) GetBlockRangeFast(startBlock int, endBlock int) ([][]byte, error)

func (HiveEngineRpcNode) GetLatestBlockInfo

func (h HiveEngineRpcNode) GetLatestBlockInfo() (*EngineBlock, error)

func (HiveEngineRpcNode) GetStatus

func (h HiveEngineRpcNode) GetStatus() (*EngineStatus, error)

func (HiveEngineRpcNode) GetSymbolAllNft

func (h HiveEngineRpcNode) GetSymbolAllNft(nftSymbol string) ([]EngineNft, error)

func (HiveEngineRpcNode) GetSymbolAllNftFast

func (h HiveEngineRpcNode) GetSymbolAllNftFast(nftSymbol string) ([][]byte, error)

func (HiveEngineRpcNode) GetSymbolAllNftMarket

func (h HiveEngineRpcNode) GetSymbolAllNftMarket(nftSymbol string, chunkSize int) ([]NftMarketOffer, error)

func (HiveEngineRpcNode) QueryContract

func (h HiveEngineRpcNode) QueryContract(qParams ContractQueryParams) ([]byte, error)

func (HiveEngineRpcNode) QueryContractBatch

func (h HiveEngineRpcNode) QueryContractBatch(qParams []ContractQueryParams) ([][]byte, error)

type NftMarketOffer

type NftMarketOffer struct {
	Id          int             `json:"_id"`
	Account     string          `json:"account"`
	OwnedBy     string          `json:"ownedBy"`
	NftId       string          `json:"nftId"`
	Grouping    json.RawMessage `json:"grouping"`
	Timestamp   int             `json:"timestamp"`
	Price       string          `json:"price"`
	PriceDec    json.RawMessage `json:"priceDec"`
	PriceSymbol string          `json:"priceSymbol"`
	Fee         int             `json:"fee"`
}

type NftTransferPayload

type NftTransferPayload struct {
	Nfts []NftsForNftTransfer `json:"nfts"`
	To   string               `json:"to"`
	Memo string               `json:"memo,omitempty"`
}

type NftsForNftTransfer

type NftsForNftTransfer struct {
	Symbol string   `json:"symbol"`
	Ids    []string `json:"ids"`
}

type QueryIDRange

type QueryIDRange struct {
	Id QueryIntRange `json:"_id"`
}

type QueryIntRange

type QueryIntRange struct {
	GreaterThanEqual int `json:"$gte,omitempty"`
	LessThanEqual    int `json:"$lte,omitempty"`
}

type Witness

type Witness struct {
	Id                 int             `json:"_id"`
	Account            string          `json:"account"`
	ApprovalWeight     json.RawMessage `json:"approvalWeight"`
	SigningKey         string          `json:"signingKey"`
	Ip                 string          `json:"ip"`
	IpVersion          int             `json:"ipVersion"`
	RPCPort            int             `json:"RPCPort"`
	P2PPort            int             `json:"P2PPort"`
	Enabled            bool            `json:"enabled"`
	MissedRounds       int             `json:"missedRounds"`
	MissedRoundsInARow int             `json:"missedRoundsInARow"`
	VerifiedRounds     int             `json:"verifiedRounds"`
	LastRoundVerified  int             `json:"lastRoundVerified"`
	LastBlockVerified  int             `json:"lastBlockVerified"`
}

Jump to

Keyboard shortcuts

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