rosetta

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockchainEmpty = "blockchain identifier has empty blockchain field"
	NetworkEmpty    = "blockchain identifier has empty network field"
	BlockNotFull    = "block identifier needs both fields filled for this request"
	BlockLength     = "block identifier has invalid hash field length"
	AddressEmpty    = "account identifier has empty address field"
	AddressLength   = "account identifier has invalid address field length"
	CurrenciesEmpty = "currency identifier list is empty"
	SymbolEmpty     = "currency identifier has empty symbol field"
	TxHashEmpty     = "transaction identifier has empty hash field"
	TxLength        = "transaction identifier has invalid hash filed length"
	TxInvalidOps    = "transaction operations are invalid"
	TxBodyEmpty     = "transaction text is empty"
	SignaturesEmpty = "signature list is empty"
)
View Source
const (
	HexIDSize      = 2 * len(flow.ZeroID)
	HexAddressSize = 2 * flow.AddressLength
)

Sizes are multiplied by two because hex-encoded strings use two characters for every byte.

Variables

View Source
var (
	ErrBlockLength     = errors.New(BlockLength)
	ErrBlockIncomplete = errors.New(BlockNotFull)
	ErrAddressLength   = errors.New(AddressLength)
	ErrTxLength        = errors.New(TxLength)
)

Functions

This section is empty.

Types

type Allow

type Allow struct {
	OperationStatuses       []meta.StatusDefinition `json:"operation_statuses"`
	OperationTypes          []string                `json:"operation_types"`
	Errors                  []meta.ErrorDefinition  `json:"errors"`
	HistoricalBalanceLookup bool                    `json:"historical_balance_lookup"`
	CallMethods             []string                `json:"call_methods"`       // not used
	BalanceExemptions       []struct{}              `json:"balance_exemptions"` // not used
	MempoolCoins            bool                    `json:"mempool_coins"`
}

type BalanceRequest

type BalanceRequest struct {
	NetworkID  identifier.Network    `json:"network_identifier"`
	BlockID    identifier.Block      `json:"block_identifier"`
	AccountID  identifier.Account    `json:"account_identifier"`
	Currencies []identifier.Currency `json:"currencies"`
}

BalanceRequest implements the request schema for /account/balance. See https://www.rosetta-api.org/docs/AccountApi.html#request

type BalanceResponse

type BalanceResponse struct {
	BlockID  identifier.Block `json:"block_identifier"`
	Balances []object.Amount  `json:"balances"`
}

BalanceResponse implements the successful response schema for /account/balance. See https://www.rosetta-api.org/docs/AccountApi.html#200---ok

type BlockRequest

type BlockRequest struct {
	NetworkID identifier.Network `json:"network_identifier"`
	BlockID   identifier.Block   `json:"block_identifier"`
}

BlockRequest implements the request schema for /block. See https://www.rosetta-api.org/docs/BlockApi.html#request

type BlockResponse

type BlockResponse struct {
	Block             *object.Block            `json:"block"`
	OtherTransactions []identifier.Transaction `json:"other_transactions,omitempty"`
}

BlockResponse implements the response schema for /block. See https://www.rosetta-api.org/docs/BlockApi.html#200---ok

type CombineRequest added in v1.2.0

type CombineRequest struct {
	NetworkID           identifier.Network `json:"network_identifier"`
	UnsignedTransaction string             `json:"unsigned_transaction"`
	Signatures          []object.Signature `json:"signatures"`
}

CombineRequest implements the request schema for /construction/combine. See https://www.rosetta-api.org/docs/ConstructionApi.html#request

type CombineResponse added in v1.2.0

type CombineResponse struct {
	SignedTransaction string `json:"signed_transaction"`
}

CombineResponse implements the response schema for /construction/combine. See https://www.rosetta-api.org/docs/ConstructionApi.html#response

type Configuration

type Configuration interface {
	Network() identifier.Network
	Version() meta.Version
	Operations() []string
	Statuses() []meta.StatusDefinition
	Errors() []meta.ErrorDefinition
	Check(rosNetID identifier.Network) error
}

Configuration represents the configuration parameters of a particular blockchain from the Rosetta API's perspective. It details some blockchain metadata, its supported operations, errors, and more. See https://www.rosetta-api.org/docs/NetworkApi.html#networkoptions

type Construction added in v1.2.0

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

Construction implements the Rosetta Construction API specification. See https://www.rosetta-api.org/docs/construction_api_introduction.html

func NewConstruction added in v1.2.0

func NewConstruction(config Configuration, transact Transactor, retrieve Retriever, validate Validator) *Construction

NewConstruction creates a new instance of the Construction API using the given configuration to handle transaction construction requests. TODO: Decide if the retriever dependency should be kept or this functionality should be part of the transactor. => https://github.com/optakt/flow-dps/issues/406

func (*Construction) Combine added in v1.2.0

func (c *Construction) Combine(ctx echo.Context) error

Combine implements the /construction/combine endpoint of the Rosetta Construction API. It creates a signed transaction by combining an unsigned transaction and a list of signatures. See https://www.rosetta-api.org/docs/ConstructionApi.html#constructioncombine

func (*Construction) Hash added in v1.2.0

func (c *Construction) Hash(ctx echo.Context) error

Hash implements the /construction/hash endpoint of the Rosetta Construction API. It returns the transaction ID of a signed transaction. See https://www.rosetta-api.org/docs/ConstructionApi.html#constructionhash

func (*Construction) Metadata added in v1.2.0

func (c *Construction) Metadata(ctx echo.Context) error

Metadata implements the /construction/metadata endpoint of the Rosetta Construction API. Metadata endpoint returns information required for constructing the transaction. For Flow, that information includes the reference block and sequence number. Reference block is the last indexed block, and is used to track transaction expiration. Sequence number is the proposer account's public key sequence number. Sequence number is incremented for each transaction and is used to prevent replay attacks. See https://www.rosetta-api.org/docs/ConstructionApi.html#constructionmetadata

func (*Construction) Parse added in v1.2.0

func (c *Construction) Parse(ctx echo.Context) error

Parse implements the /construction/parse endpoint of the Rosetta Construction API. Parse endpoint parses both signed and unsigned transactions to understand the transaction's intent. Endpoint returns the list of operations, any relevant metadata, and, in the case of signed transaction, the list of signers. See https://www.rosetta-api.org/docs/ConstructionApi.html#constructionparse

func (*Construction) Payloads added in v1.2.0

func (c *Construction) Payloads(ctx echo.Context) error

Payloads implements the /construction/payloads endpoint of the Rosetta Construction API. It receives an array of operations and all other relevant information required to construct an unsigned transaction. Operations must deterministically describe the intent of the transaction. Besides the unsigned transaction text, this endpoint also returns the list of payloads that should be signed. See https://www.rosetta-api.org/docs/ConstructionApi.html#constructionpayloads

func (*Construction) Preprocess added in v1.2.0

func (c *Construction) Preprocess(ctx echo.Context) error

Preprocess implements the /construction/preprocess endpoint of the Rosetta Construction API. Preprocess receives a list of operations that should deterministically specify the intent of the transaction. Preprocess endpoint returns the `options` object that will be sent **unmodified** to /construction/metadata, effectively creating the metadata request. See https://www.rosetta-api.org/docs/ConstructionApi.html#constructionpreprocess

func (*Construction) Submit added in v1.2.0

func (c *Construction) Submit(ctx echo.Context) error

Submit implements the /construction/submit endpoint of the Rosetta Construction API. Submit endpoint receives the fully constructed, signed transaction and submits it for execution to the Flow network using the SendTransaction API call of the Flow Access API. See https://www.rosetta-api.org/docs/ConstructionApi.html#constructionsubmit

type Data

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

Data implements the Rosetta Data API specification. See https://www.rosetta-api.org/docs/data_api_introduction.html

func NewData

func NewData(config Configuration, retrieve Retriever, validate Validator) *Data

NewData creates a new instance of the Data API using the given configuration to answer configuration queries and the given retriever to answer blockchain data queries.

func (*Data) Balance

func (d *Data) Balance(ctx echo.Context) error

Balance implements the /account/balance endpoint of the Rosetta Data API. See https://www.rosetta-api.org/docs/AccountApi.html#accountbalance

func (*Data) Block

func (d *Data) Block(ctx echo.Context) error

Block implements the /block endpoint of the Rosetta Data API. See https://www.rosetta-api.org/docs/BlockApi.html#block

func (*Data) Networks

func (d *Data) Networks(ctx echo.Context) error

Networks implements the /network/list endpoint of the Rosetta Data API. See https://www.rosetta-api.org/docs/NetworkApi.html#networklist

func (*Data) Options

func (d *Data) Options(ctx echo.Context) error

Options implements the /network/options endpoint of the Rosetta Data API. See https://www.rosetta-api.org/docs/NetworkApi.html#networkoptions

func (*Data) Status

func (d *Data) Status(ctx echo.Context) error

Status implements the /network/status endpoint of the Rosetta Data API. See https://www.rosetta-api.org/docs/NetworkApi.html#networkstatus

func (*Data) Transaction

func (d *Data) Transaction(ctx echo.Context) error

Transaction implements the /block/transaction endpoint of the Rosetta Data API. See https://www.rosetta-api.org/docs/BlockApi.html#blocktransaction

type Error

type Error struct {
	meta.ErrorDefinition
	Description string                 `json:"description"`
	Details     map[string]interface{} `json:"details,omitempty"`
}

Error represents an error as defined by the Rosetta API specification. It contains an error definition, which has an error code, error message and retriable flag that never change, as well as a description and a list of details to provide more granular error information. See: https://www.rosetta-api.org/docs/api_objects.html#error

type HashRequest added in v1.2.0

type HashRequest struct {
	NetworkID         identifier.Network `json:"network_identifier"`
	SignedTransaction string             `json:"signed_transaction"`
}

HashRequest implements the request schema for /construction/hash. See https://www.rosetta-api.org/docs/ConstructionApi.html#request-2

type HashResponse added in v1.2.0

type HashResponse struct {
	TransactionID identifier.Transaction `json:"transaction_identifier"`
}

HashResponse implements the response schema for /construction/hash. See https://www.rosetta-api.org/docs/ConstructionApi.html#response-2

type MetadataRequest added in v1.2.0

type MetadataRequest struct {
	NetworkID identifier.Network `json:"network_identifier"`
	Options   object.Options     `json:"options"`
}

MetadataRequest implements the request schema for /construction/metadata. `Options` object in this request is generated by a call to `/construction/preprocess`, and should be sent unaltered as returned by that endpoint. See https://www.rosetta-api.org/docs/ConstructionApi.html#request-3

type MetadataResponse added in v1.2.0

type MetadataResponse struct {
	Metadata object.Metadata `json:"metadata"`
}

MetadataResponse implements the response schema for /construction/metadata. See https://www.rosetta-api.org/docs/ConstructionApi.html#response-3

type NetworksRequest

type NetworksRequest struct {
}

NetworksRequest implements the empty request schema for the /network/list endpoint. See https://www.rosetta-api.org/docs/NetworkApi.html#request

type NetworksResponse

type NetworksResponse struct {
	NetworkIDs []identifier.Network `json:"network_identifiers"`
}

NetworksResponse implements the successful response schema for the /network/list endpoint. See https://www.rosetta-api.org/docs/NetworkApi.html#200---ok

type OptionsRequest

type OptionsRequest struct {
	NetworkID identifier.Network `json:"network_identifier"`
}

OptionsRequest implements the empty request schema for the /network/options endpoint. See https://www.rosetta-api.org/docs/NetworkApi.html#request-1

type OptionsResponse

type OptionsResponse struct {
	Version meta.Version `json:"version"`
	Allow   Allow        `json:"allow"`
}

OptionsResponse implements the successful response schema for the /network/options endpoint. See https://www.rosetta-api.org/docs/NetworkApi.html#200---ok-1

type ParseRequest added in v1.2.0

type ParseRequest struct {
	NetworkID   identifier.Network `json:"network_identifier"`
	Signed      bool               `json:"signed"`
	Transaction string             `json:"transaction"`
}

ParseRequest implements the request schema for /construction/parse. See https://www.rosetta-api.org/docs/ConstructionApi.html#request-4

type ParseResponse added in v1.2.0

type ParseResponse struct {
	Operations []object.Operation   `json:"operations"`
	SignerIDs  []identifier.Account `json:"account_identifier_signers,omitempty"`
	Metadata   object.Metadata      `json:"metadata,omitempty"`
}

ParseResponse implements the response schema for /construction/parse. See https://www.rosetta-api.org/docs/ConstructionApi.html#response-4

type PayloadsRequest added in v1.2.0

type PayloadsRequest struct {
	NetworkID  identifier.Network `json:"network_identifier"`
	Operations []object.Operation `json:"operations"`
	Metadata   object.Metadata    `json:"metadata"`
}

PayloadsRequest implements the request schema for /construction/payloads. See https://www.rosetta-api.org/docs/ConstructionApi.html#request-5

type PayloadsResponse added in v1.2.0

type PayloadsResponse struct {
	Transaction string                  `json:"unsigned_transaction"`
	Payloads    []object.SigningPayload `json:"payloads"`
}

PayloadsResponse implements the response schema for /construction/payloads. See https://www.rosetta-api.org/docs/ConstructionApi.html#response-5

type PreprocessRequest added in v1.2.0

type PreprocessRequest struct {
	NetworkID  identifier.Network `json:"network_identifier"`
	Operations []object.Operation `json:"operations"`
}

PreprocessRequest implements the request schema for /construction/preprocess. See https://www.rosetta-api.org/docs/ConstructionApi.html#request-6

type PreprocessResponse added in v1.2.0

type PreprocessResponse struct {
	object.Options `json:"options,omitempty"`
}

PreprocessResponse implements the response schema for /construction/preprocess. See https://www.rosetta-api.org/docs/ConstructionApi.html#response-6

type Retriever

type Retriever interface {
	Oldest() (identifier.Block, time.Time, error)
	Current() (identifier.Block, time.Time, error)
	Block(rosBlockID identifier.Block) (*object.Block, []identifier.Transaction, error)
	Transaction(rosBlockID identifier.Block, rosTxID identifier.Transaction) (*object.Transaction, error)
	Balances(rosBlockID identifier.Block, rosAccountID identifier.Account, rosCurrencies []identifier.Currency) (identifier.Block, []object.Amount, error)
	Sequence(rosBlockID identifier.Block, rosAccountID identifier.Account, index int) (uint64, error)
}

type StatusRequest

type StatusRequest struct {
	NetworkID identifier.Network `json:"network_identifier"`
}

StatusRequest implements the request schema for /network/status. See https://www.rosetta-api.org/docs/NetworkApi.html#request-2

type StatusResponse

type StatusResponse struct {
	CurrentBlockID        identifier.Block `json:"current_block_identifier"`
	CurrentBlockTimestamp int64            `json:"current_block_timestamp"`
	OldestBlockID         identifier.Block `json:"oldest_block_identifier"`
	GenesisBlockID        identifier.Block `json:"genesis_block_identifier"`
	Peers                 []struct{}       `json:"peers"` // not used
}

StatusResponse implements the successful response schema for /network/status. See https://www.rosetta-api.org/docs/NetworkApi.html#200---ok-2

type SubmitRequest added in v1.2.0

type SubmitRequest struct {
	NetworkID         identifier.Network `json:"network_identifier"`
	SignedTransaction string             `json:"signed_transaction"`
}

SubmitRequest implements the request schema for /construction/submit. See https://www.rosetta-api.org/docs/ConstructionApi.html#request-7

type SubmitResponse added in v1.2.0

type SubmitResponse struct {
	TransactionID identifier.Transaction `json:"transaction_identifier"`
}

SubmitResponse implements the response schema for /construction/submit. See https://www.rosetta-api.org/docs/ConstructionApi.html#response-7

type TransactionRequest

type TransactionRequest struct {
	NetworkID     identifier.Network     `json:"network_identifier"`
	BlockID       identifier.Block       `json:"block_identifier"`
	TransactionID identifier.Transaction `json:"transaction_identifier"`
}

TransactionRequest implements the request schema for /block/transaction. See https://www.rosetta-api.org/docs/BlockApi.html#request-1

type TransactionResponse

type TransactionResponse struct {
	Transaction *object.Transaction `json:"transaction"`
}

TransactionResponse implements the successful response schema for /block/transaction. See https://www.rosetta-api.org/docs/BlockApi.html#200---ok-1

type Transactor added in v1.2.0

type Transactor interface {
	DeriveIntent(operations []object.Operation) (intent *transactor.Intent, err error)
	CompileTransaction(refBlockID identifier.Block, intent *transactor.Intent, sequence uint64) (unsigned string, err error)
	HashPayload(rosBlockID identifier.Block, unsigned string, signer identifier.Account) (algo string, hash string, err error)
	ParseTransaction(payload string) (refBlockID identifier.Block, sequence uint64, operations []object.Operation, signers []identifier.Account, err error)
	AttachSignatures(unsigned string, signatures []object.Signature) (signed string, err error)
	TransactionIdentifier(signed string) (rosTxID identifier.Transaction, err error)
	SubmitTransaction(signed string) (rosTxID identifier.Transaction, err error)
}

Transactor is used by the Rosetta Construction API to handle transaction related operations.

type Validator added in v1.3.0

type Validator interface {
	Request(interface{}) error
	CompleteBlockID(identifier.Block) error
}

Jump to

Keyboard shortcuts

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