Documentation ¶
Index ¶
- Constants
- Variables
- func AccountBlockToTransaction(accountBlock *api.AccountBlock, includeStatus bool) (*types.Transaction, error)
- func AmountForAccountBlock(account *api.AccountBlock, negateValue bool) *types.Amount
- func BlockTypeToOperationType(blockType byte) (string, error)
- func CheckBurnOpType(operation *types.Operation) error
- func CheckFeeOpType(operation *types.Operation) error
- func CheckRequestOpType(operation *types.Operation) error
- func CheckResponseOpType(operation *types.Operation, inResponseTx bool) error
- func ConvertSecondsToMiliseconds(time int64) int64
- func CreateAccountBlock(description *TransactionDescription, metadata *ConstructionMetadata, ...) (*api.AccountBlock, error)
- func CurrencyForAccountBlock(account *api.AccountBlock) *types.Currency
- func FeeAmountForAccountBlock(accountBlock *api.AccountBlock) *types.Amount
- func FeeOperationForAccountBlock(accountBlock *api.AccountBlock, index int64, includeStatus bool) (*types.Operation, error)
- func GenerateBootstrapFile(genesisFile string, outputFile string) error
- func IsReceiveTypeOperation(opType string) bool
- func IsSendTypeOperation(opType string) bool
- func OperationTypeToBlockType(opType string) (byte, error)
- func OperationsForAccountBlock(accountBlock *api.AccountBlock, includeStatus bool) ([]*types.Operation, error)
- func OperationsForRequestAccountBlock(accountBlock *api.AccountBlock, includeStatus bool) ([]*types.Operation, error)
- func OperationsForResponseAccountBlock(accountBlock *api.AccountBlock, includeStatus bool) ([]*types.Operation, error)
- func RelatedTransactionsForAccountBlock(accountBlock *api.AccountBlock) []*types.RelatedTransaction
- func RequestOperationForAccountBlock(accountBlock *api.AccountBlock, index int64, includeStatus bool) (*types.Operation, error)
- func ResponseOperationForAccountBlock(accountBlock *api.AccountBlock, index int64, includeStatus bool) (*types.Operation, error)
- func SignData(privateKey string, message string) error
- func StartGvite(ctx context.Context, arguments string, g *errgroup.Group) error
- func StatusRef(status string, includeStatus bool) *string
- func ValidateMatch(match *parser.Match) error
- func ViteTokenToCurrency(tti string, tokenInfo api.RpcTokenInfo) (currency types.Currency)
- type Client
- func (ec *Client) Balance(ctx context.Context, account *types.AccountIdentifier, ...) (*types.AccountBalanceResponse, error)
- func (ec *Client) Block(ctx context.Context, blockIdentifier *types.PartialBlockIdentifier) (*types.Block, []*types.TransactionIdentifier, error)
- func (ec *Client) BlockTransaction(ctx context.Context, request *types.BlockTransactionRequest) (*types.Transaction, error)
- func (ec *Client) Close()
- func (ec *Client) ConstructionMetadata(ctx context.Context, options *ConstructionOptions) (*ConstructionMetadata, error)
- func (ec *Client) GenesisBlockIdentifier() *types.BlockIdentifier
- func (ec *Client) SendTransaction(ctx context.Context, tx *api.AccountBlock) error
- func (ec *Client) Status(ctx context.Context) (*types.BlockIdentifier, int64, *types.SyncStatus, []*types.Peer, error)
- type ConstructionMetadata
- type ConstructionOptions
- type RequestOperationMetadata
- type ResponseOperationMetadata
- type TransactionDescription
Constants ¶
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 ¶
var ( ErrCallParametersInvalid = errors.New("call parameters invalid") ErrCallOutputMarshal = errors.New("call output marshal") ErrCallMethodInvalid = errors.New("call method invalid") )
Client errors
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 CheckBurnOpType ¶
func CheckFeeOpType ¶
func CheckRequestOpType ¶
func CheckResponseOpType ¶
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 GenerateBootstrapFile ¶
GenerateBootstrapFile creates the bootstrap balances file for a particular genesis file.
func IsReceiveTypeOperation ¶
func IsSendTypeOperation ¶
func RelatedTransactionsForAccountBlock ¶
func RelatedTransactionsForAccountBlock(accountBlock *api.AccountBlock) []*types.RelatedTransaction
func StartGvite ¶
StartGvite starts a gvite daemon in another goroutine and logs the results to the console.
func ValidateMatch ¶
func ViteTokenToCurrency ¶
func ViteTokenToCurrency(tti string, tokenInfo api.RpcTokenInfo) (currency types.Currency)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
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) 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 ¶
Send a transaction to the blockchain
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)