network

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NAME_KEY           = "NAME"
	SYMBOL_KEY         = "SYMBOL"
	DECIMALS_KEY       = "DECIMALS"
	BALANCE_KEY_PREFIX = "BALANCE"
)

Variables

View Source
var ErrChainIDNotInStatus = errors.New("chain id not in status")

Functions

func DatastoreEntry added in v0.2.1

func DatastoreEntry(contractAddress string, key []byte) ([]byte, error)

DatastoreEntry is a helper function to fetch datastore entry from the Massa node.

func GetNodeInfo added in v0.3.4

func GetNodeInfo() (uint64, string, error)

func NewMassaClient added in v0.2.1

func NewMassaClient() (*node.Client, error)

func SendOperation

func SendOperation(
	acc *account.Account,
	password *memguard.LockedBuffer,
	massaClient NodeFetcherInterface,
	operation sendOperation.Operation,
	fee uint64,
	chainID uint64,
) (*sendOperation.OperationResponse, error)

Types

type AccountInfos

type AccountInfos struct {
	Address          string
	CandidateBalance uint64
	Balance          uint64
}

type NetworkInfo

type NetworkInfo struct {
	Network string `json:"network"`
	URL     string `json:"url"`
	ChainID int    `json:"chainId"`
}

func GetNetworkInfo

func GetNetworkInfo() (*NetworkInfo, error)

retrieve network info from endpoint

type NodeFetcher

type NodeFetcher struct{}

func NewNodeFetcher

func NewNodeFetcher() *NodeFetcher

func (*NodeFetcher) AssetExistInNetwork added in v0.2.1

func (n *NodeFetcher) AssetExistInNetwork(contractAddress string) bool

func (*NodeFetcher) DatastoreAssetBalance added in v0.2.1

func (n *NodeFetcher) DatastoreAssetBalance(assetContractAddress, userAddress string) (string, error)

DatastoreAssetBalance retrieves the balance of a user for a given asset contract address from the Massa node.

func (*NodeFetcher) DatastoreAssetDecimals added in v0.2.1

func (n *NodeFetcher) DatastoreAssetDecimals(contractAddress string) (uint8, error)

DatastoreAssetDecimals retrieves the asset decimals for a given contract address from the Massa node.

func (*NodeFetcher) DatastoreAssetName added in v0.2.1

func (n *NodeFetcher) DatastoreAssetName(contractAddress string) (string, error)

DatastoreAssetName retrieves the asset name for a given contract address from the Massa node.

func (*NodeFetcher) DatastoreAssetSymbol added in v0.2.1

func (n *NodeFetcher) DatastoreAssetSymbol(contractAddress string) (string, error)

DatastoreAssetSymbol retrieves the asset symbol for a given contract address from the Massa node.

func (*NodeFetcher) GetAccountsInfos

func (n *NodeFetcher) GetAccountsInfos(accounts []*account.Account) ([]AccountInfos, error)

func (*NodeFetcher) MakeOperation

func (n *NodeFetcher) MakeOperation(fee uint64, operation sendOperation.Operation) ([]byte, error)

MakeOperation makes a new operation by calling Massa Station source code sendOperation.MakeOperation function.

func (*NodeFetcher) MakeRPCCall

func (n *NodeFetcher) MakeRPCCall(msg []byte, signature []byte, publicKey string) ([]string, error)

MakeRPCCall makes a new RPC call by calling Massa Station source code sendOperation.MakeRPCCall function.

type NodeFetcherInterface

type NodeFetcherInterface interface {
	GetAccountsInfos(accounts []*account.Account) ([]AccountInfos, error)
	MakeOperation(fee uint64, operation sendOperation.Operation) ([]byte, error)
	MakeRPCCall(msg []byte, signature []byte, publicKey string) ([]string, error)
	AssetExistInNetwork(contractAddress string) bool
	DatastoreAssetName(contractAddress string) (string, error)
	DatastoreAssetSymbol(contractAddress string) (string, error)
	DatastoreAssetDecimals(contractAddress string) (uint8, error)
	DatastoreAssetBalance(assetContractAddress, userAddress string) (string, error)
}

Jump to

Keyboard shortcuts

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