vite

package
v0.0.0-...-96e9b90 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// NodeVersion is the version of gvite we are using.
	NodeVersion = "2.10.2"

	// Blockchain is Vite.
	Blockchain string = "vite"

	// MainnetNetwork is the value of the network
	// in MainnetNetworkIdentifier.
	MainnetNetwork string = "mainnet"

	// Testnet is the value of the network
	// in TestnetNetworkIdentifier.
	TestnetNetwork string = "testnet"

	// Devnet is the value of the network
	// in DevnetNetworkIdentifier.
	DevnetNetwork string = "devnet"

	// Symbol is the symbol value
	// used in Currency.
	Symbol = "VITE"

	// Decimals is the decimals value
	// used in Currency.
	Decimals = 18

	CreateContractOpType = "CREATE_CONTRACT"
	RequestOpType        = "REQUEST"
	MintOpType           = "MINT"
	ResponseOpType       = "RESPONSE"
	ResponseFailOpType   = "RESPONSE_FAIL"
	RefundOpType         = "REFUND"
	GenesisOpType        = "GENESIS"
	FeeOpType            = "FEE"
	BurnOpType           = "BURN"

	// SuccessStatus is the status of any
	// operation considered successful.
	SuccessStatus string = "SUCCESS"

	// IntentStatus is the status of any
	// pending operation
	IntentStatus string = "INTENT"

	RevertedStatus string = "REVERTED"

	ExceedMaxDepthStatus string = "EXCEED_MAX_DEPTH"

	// Known addresses
	MintAddress string = "vite_000000000000000000000000000000000000000595292d996d"

	// HistoricalBalanceSupported is whether
	// historical balance is supported.
	HistoricalBalanceSupported = true

	// GenesisBlockIndex is the index of the
	// genesis block.
	GenesisBlockIndex = int64(1)

	// MainnetGviteArguments are the arguments to start a mainnet gvite instance.
	MainnetGviteArguments = `--config=/app/vite/node_config.json`

	// IncludeMempoolCoins does not apply to rosetta-vite as it is not UTXO-based.
	IncludeMempoolCoins = false

	// InlineTransactions - weather to return transactions inline in the block or
	// as otherTransactions
	InlineTransactions = true

	MetadataToAddressKey     string = "toAddress"
	MetadataSendBlockHashKey string = "sendBlockHash"
)

Variables

View Source
var (
	ErrCallParametersInvalid = errors.New("call parameters invalid")
	ErrCallOutputMarshal     = errors.New("call output marshal")
	ErrCallMethodInvalid     = errors.New("call method invalid")
)

Client errors

View Source
var (
	// TestnetGviteArguments are the arguments to start a testnet gvite instance.
	TestnetGviteArguments = fmt.Sprintf("%s --networkid 2", MainnetGviteArguments)

	// Currency is the *types.Currency for all
	// Vite networks.
	Currency = &types.Currency{
		Symbol:   Symbol,
		Decimals: Decimals,
	}

	// OperationTypes are all suppoorted operation types.
	OperationTypes = []string{
		CreateContractOpType,
		RequestOpType,
		MintOpType,
		ResponseOpType,
		ResponseFailOpType,
		RefundOpType,
		GenesisOpType,
		FeeOpType,
		BurnOpType,
	}

	// OperationStatuses are all supported operation statuses.
	OperationStatuses = []*types.OperationStatus{
		{
			Status:     SuccessStatus,
			Successful: true,
		},
		{
			Status:     RevertedStatus,
			Successful: false,
		},
		{
			Status:     ExceedMaxDepthStatus,
			Successful: false,
		},
	}

	// CallMethods are all supported call methods.
	CallMethods = []string{}
)

Functions

func AccountBlockToTransaction

func AccountBlockToTransaction(accountBlock *api.AccountBlock, includeStatus bool) (*types.Transaction, error)

Converts a vite account block to a rosetta transaction

func AmountForAccountBlock

func AmountForAccountBlock(account *api.AccountBlock, negateValue bool) *types.Amount

func BlockTypeToOperationType

func BlockTypeToOperationType(blockType byte) (string, error)

func CheckBurnOpType

func CheckBurnOpType(operation *types.Operation) error

func CheckFeeOpType

func CheckFeeOpType(operation *types.Operation) error

func CheckRequestOpType

func CheckRequestOpType(operation *types.Operation) error

func CheckResponseOpType

func CheckResponseOpType(operation *types.Operation, inResponseTx bool) error

func ConvertSecondsToMiliseconds

func ConvertSecondsToMiliseconds(time int64) int64

func CreateAccountBlock

func CreateAccountBlock(
	description *TransactionDescription,
	metadata *ConstructionMetadata,
	publicKey *types.PublicKey,
) (*api.AccountBlock, error)

func CurrencyForAccountBlock

func CurrencyForAccountBlock(account *api.AccountBlock) *types.Currency

func FeeAmountForAccountBlock

func FeeAmountForAccountBlock(accountBlock *api.AccountBlock) *types.Amount

func FeeOperationForAccountBlock

func FeeOperationForAccountBlock(accountBlock *api.AccountBlock, index int64, includeStatus bool) (*types.Operation, error)

func GenerateBootstrapFile

func GenerateBootstrapFile(genesisFile string, outputFile string) error

GenerateBootstrapFile creates the bootstrap balances file for a particular genesis file.

func IsReceiveTypeOperation

func IsReceiveTypeOperation(opType string) bool

func IsSendTypeOperation

func IsSendTypeOperation(opType string) bool

func OperationTypeToBlockType

func OperationTypeToBlockType(opType string) (byte, error)

func OperationsForAccountBlock

func OperationsForAccountBlock(accountBlock *api.AccountBlock, includeStatus bool) ([]*types.Operation, error)

func OperationsForRequestAccountBlock

func OperationsForRequestAccountBlock(accountBlock *api.AccountBlock, includeStatus bool) ([]*types.Operation, error)

func OperationsForResponseAccountBlock

func OperationsForResponseAccountBlock(accountBlock *api.AccountBlock, includeStatus bool) ([]*types.Operation, error)

func RelatedTransactionsForAccountBlock

func RelatedTransactionsForAccountBlock(accountBlock *api.AccountBlock) []*types.RelatedTransaction

func RequestOperationForAccountBlock

func RequestOperationForAccountBlock(accountBlock *api.AccountBlock, index int64, includeStatus bool) (*types.Operation, error)

func ResponseOperationForAccountBlock

func ResponseOperationForAccountBlock(accountBlock *api.AccountBlock, index int64, includeStatus bool) (*types.Operation, error)

func SignData

func SignData(privateKey string, message string) error

func StartGvite

func StartGvite(ctx context.Context, arguments string, g *errgroup.Group) error

StartGvite starts a gvite daemon in another goroutine and logs the results to the console.

func StatusRef

func StatusRef(status string, includeStatus bool) *string

func ValidateMatch

func ValidateMatch(match *parser.Match) error

func ViteTokenToCurrency

func ViteTokenToCurrency(tti string, tokenInfo api.RpcTokenInfo) (currency types.Currency)

Types

type Client

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

func NewClient

func NewClient(url string, inlineTransactions bool) (*Client, error)

NewClient creates a Client that from the provided url and params.

func (*Client) Balance

func (ec *Client) Balance(
	ctx context.Context,
	account *types.AccountIdentifier,
	currencies []*types.Currency,
	blockIdentifier *types.PartialBlockIdentifier,
) (*types.AccountBalanceResponse, error)

Balance returns the balance of a vite address at the given snapshot block identifier if blockIdentifier is nil, balances for the latest snapshot block are returned

func (*Client) Block

func (ec *Client) Block(
	ctx context.Context,
	blockIdentifier *types.PartialBlockIdentifier,
) (*types.Block, []*types.TransactionIdentifier, error)

Block returns a populated block at the *RosettaTypes.PartialBlockIdentifier. If neither the hash or index is populated in the blockIdentifier, the current block is returned.

func (*Client) BlockTransaction

func (ec *Client) BlockTransaction(
	ctx context.Context,
	request *types.BlockTransactionRequest,
) (*types.Transaction, error)

Transaction

func (*Client) Close

func (ec *Client) Close()

Close shuts down the RPC client connection.

func (*Client) ConstructionMetadata

func (ec *Client) ConstructionMetadata(
	ctx context.Context,
	options *ConstructionOptions,
) (*ConstructionMetadata, error)

func (*Client) GenesisBlockIdentifier

func (ec *Client) GenesisBlockIdentifier() *types.BlockIdentifier

GenesisBlockIdentifier returns cached genesis block identifier

func (*Client) SendTransaction

func (ec *Client) SendTransaction(ctx context.Context, tx *api.AccountBlock) error

Send a transaction to the blockchain

func (*Client) Status

Status returns gvite status information for determining node healthiness.

type ConstructionMetadata

type ConstructionMetadata struct {
	Height       uint64  `json:"height"`
	PreviousHash string  `json:"previousHash"`
	Difficulty   *string `json:"difficulty,omitempty"`
	Nonce        *string `json:"nonce,omitempty"`
}

Defines construction metadata

type ConstructionOptions

type ConstructionOptions struct {
	OperationType      string                  `json:"operation_type"`
	Account            types.AccountIdentifier `json:"account_identifier"`
	ToAccount          types.AccountIdentifier `json:"to_account"`
	Amount             types.Amount            `json:"amount"`
	FetchPreviousBlock string                  `json:"fetch_previous_block"`
	UsePow             string                  `json:"use_pow"`
	Data               []byte                  `json:"data,omitempty"`
}

Defines construction preprocess options

func ConstructionPreprocess

func ConstructionPreprocess(
	operations []*types.Operation,
	metadata map[string]interface{},
) (*ConstructionOptions, []*types.AccountIdentifier, error)

type RequestOperationMetadata

type RequestOperationMetadata struct {
	ToAddress string `json:"toAddress"`
	Data      []byte `json:"data,omitempty"`
}

Defines Request Operation metadata

type ResponseOperationMetadata

type ResponseOperationMetadata struct {
	SendBlockHash string `json:"sendBlockHash"`
	Data          []byte `json:"data,omitempty"`
}

Defines Response Operation Metadata

type TransactionDescription

type TransactionDescription struct {
	OperationType string
	Account       types.AccountIdentifier
	FromAccount   *types.AccountIdentifier
	ToAccount     types.AccountIdentifier
	SendBlockHash *types.TransactionIdentifier
	// Amount & Fee should always be positive
	Amount types.Amount
	Fee    *types.Amount
	Data   []byte
}

Defines transaction description from matched operations

func MatchRequestTransaction

func MatchRequestTransaction(operations []*types.Operation) (*TransactionDescription, error)

func MatchResponseTransaction

func MatchResponseTransaction(operations []*types.Operation) (*TransactionDescription, error)

func MatchTransaction

func MatchTransaction(operations []*types.Operation) (*TransactionDescription, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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