ffcapi

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const RequestTypeCreateBlockListener = "create_block_listener"
View Source
const VersionCurrent = Version1_0_0

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockInfo

type BlockInfo struct {
	BlockNumber       *fftypes.FFBigInt `json:"blockNumber"`
	BlockHash         string            `json:"blockHash"`
	ParentHash        string            `json:"parentHash"`
	TransactionHashes []string          `json:"transactionHashes"`
}

type CreateBlockListenerRequest

type CreateBlockListenerRequest struct {
	RequestBase
}

func (*CreateBlockListenerRequest) RequestType

func (r *CreateBlockListenerRequest) RequestType() RequestType

type CreateBlockListenerResponse

type CreateBlockListenerResponse struct {
	ResponseBase
	ListenerID string `json:"listenerId"`
}

type ErrorReason

type ErrorReason string

ErrorReason are a set of standard error conditions that a blockchain connector can return from execution, that affect the action of the transaction manager to the response. It is important that error mapping is performed for each of these classification

const (
	// ErrorReasonInvalidInputs transaction inputs could not be parsed by the connector according to the interface (nothing was sent to the blockchain)
	ErrorReasonInvalidInputs ErrorReason = "invalid_inputs"
	// ErrorReasonTransactionReverted on-chain execution (only expected to be returned when the connector is doing gas estimation, or executing a query)
	ErrorReasonTransactionReverted ErrorReason = "transaction_reverted"
	// ErrorReasonNonceTooLow on transaction submission, if the nonce has already been used for a transaction that has made it into a block on canonical chain known to the local node
	ErrorReasonNonceTooLow ErrorReason = "nonce_too_low"
	// ErrorReasonTransactionUnderpriced if the transaction is rejected due to too low gas price. Either because it was too low according to the minimum configured on the node, or because it's a rescue transaction without a price bump.
	ErrorReasonTransactionUnderpriced ErrorReason = "transaction_underpriced"
	// ErrorReasonInsufficientFunds if the transaction is rejected due to not having enough of the underlying network coin (ether etc.) in your wallet
	ErrorReasonInsufficientFunds ErrorReason = "insufficient_funds"
	// ErrorReasonNotFound if the requested object (block/receipt etc.) was not found
	ErrorReasonNotFound ErrorReason = "not_found"
	// ErrorKnownTransaction if the exact transaction is already known
	ErrorKnownTransaction ErrorReason = "known_transaction"
)

type ErrorResponse

type ErrorResponse struct {
	Reason ErrorReason `json:"reason,omitempty"`
	Error  string      `json:"error"`
}

ErrorResponse allows blockchain connectors to encode useful information about an error in a JSON response body. This should be accompanied with a suitable non-success HTTP response code. However, the "reason" (if supplied) is the only information that will be used to change the transaction manager's handling of the error.

type ExecQueryRequest

type ExecQueryRequest struct {
	RequestBase
	TransactionInput
	BlockNumber *fftypes.FFBigInt `json:"blockNumber,omitempty"`
}

ExecQueryRequest requests execution of a smart contract method in order to either: 1) Query state 2) Attempt to extract the revert reason from an on-chain failure to execute a transaction

See the list of standard error reasons that should be returned for situations that can be detected by the back-end connector.

func (*ExecQueryRequest) RequestType

func (r *ExecQueryRequest) RequestType() RequestType

type ExecQueryResponse

type ExecQueryResponse struct {
	ResponseBase
	Outputs []*fftypes.JSONAny `json:"outputs"`
}

type GetBlockInfoByHashRequest

type GetBlockInfoByHashRequest struct {
	RequestBase
	BlockHash string `json:"blockHash"`
}

func (*GetBlockInfoByHashRequest) RequestType

func (r *GetBlockInfoByHashRequest) RequestType() RequestType

type GetBlockInfoByHashResponse

type GetBlockInfoByHashResponse struct {
	ResponseBase
	BlockInfo
}

type GetBlockInfoByNumberRequest

type GetBlockInfoByNumberRequest struct {
	RequestBase
	BlockNumber *fftypes.FFBigInt `json:"blockNumber"`
}

func (*GetBlockInfoByNumberRequest) RequestType

func (r *GetBlockInfoByNumberRequest) RequestType() RequestType

type GetBlockInfoByNumberResponse

type GetBlockInfoByNumberResponse struct {
	ResponseBase
	BlockInfo
}

type GetGasPriceRequest

type GetGasPriceRequest struct {
	RequestBase
}

GetGasPriceRequest used to do a query for the next nonce to use for a given signing identity. This is only used when there are no pending operations outstanding for this signer known to the transaction manager.

func (*GetGasPriceRequest) RequestType

func (r *GetGasPriceRequest) RequestType() RequestType

type GetGasPriceResponse

type GetGasPriceResponse struct {
	ResponseBase
	GasPrice *fftypes.JSONAny
}

type GetNewBlockHashesRequest

type GetNewBlockHashesRequest struct {
	RequestBase
	ListenerID string `json:"listenerId"`
}

func (*GetNewBlockHashesRequest) RequestType

func (r *GetNewBlockHashesRequest) RequestType() RequestType

type GetNewBlockHashesResponse

type GetNewBlockHashesResponse struct {
	ResponseBase
	BlockHashes []string `json:"blockHashes"`
}

type GetNextNonceRequest

type GetNextNonceRequest struct {
	RequestBase
	Signer string `json:"signer"`
}

GetNextNonceRequest used to do a query for the next nonce to use for a given signing identity. This is only used when there are no pending operations outstanding for this signer known to the transaction manager.

func (*GetNextNonceRequest) RequestType

func (r *GetNextNonceRequest) RequestType() RequestType

type GetNextNonceResponse

type GetNextNonceResponse struct {
	ResponseBase
	Nonce *fftypes.FFBigInt `json:"nonce"`
}

type GetReceiptRequest

type GetReceiptRequest struct {
	RequestBase
	TransactionHash string `json:"transactionHash"`
}

func (*GetReceiptRequest) RequestType

func (r *GetReceiptRequest) RequestType() RequestType

type GetReceiptResponse

type GetReceiptResponse struct {
	ResponseBase
	BlockNumber      *fftypes.FFBigInt `json:"blockNumber"`
	TransactionIndex *fftypes.FFBigInt `json:"transactinIndex"`
	BlockHash        string            `json:"blockHash"`
	Success          bool              `json:"success"`
	ExtraInfo        fftypes.JSONAny   `json:"extraInfo"`
}
type Header struct {
	RequestID   *fftypes.UUID `json:"id"`      // Unique for each request
	Version     Version       `json:"version"` // The API version
	Variant     Variant       `json:"variant"` // Defines the format of the input/output bodies, which FFTM operates pass-through on from FireFly core to the Blockchain connector
	RequestType RequestType   `json:"type"`    // The type of the request, which defines how it should be processed, and the structure of the rest of the payload
}

Header is included consistently as a "ffcapi" structure on each request

type PrepareTransactionRequest

type PrepareTransactionRequest struct {
	RequestBase
	TransactionInput
}

PrepareTransactionRequest is used to prepare a set of JSON formatted developer friendly inputs, into a raw transaction ready for submission to the blockchain.

The connector is responsible for encoding the transaction ready for sumission, and returning the hash for the transaction as well as a string serialization of the pre-signed raw transaction in a format of its own choosing (hex etc.). The hash is expected to be a function of: - the method signature - the signing identity - the nonce - the particular blockchain the transaction is submitted to - the input parameters

If "gas" is not supplied, the connector is expected to perform gas estimation prior to generating the payload.

See the list of standard error reasons that should be returned for situations that can be detected by the back-end connector.

func (*PrepareTransactionRequest) RequestType

func (r *PrepareTransactionRequest) RequestType() RequestType

type PrepareTransactionResponse

type PrepareTransactionResponse struct {
	ResponseBase
	Gas             *fftypes.FFBigInt `json:"gas"`
	TransactionData string            `json:"transactionData"`
}

type RequestBase

type RequestBase struct {
	FFCAPI Header `json:"ffcapi"`
}

func (*RequestBase) FFCAPIHeader

func (r *RequestBase) FFCAPIHeader() *Header

type RequestID

type RequestID string

type RequestType

type RequestType string

RequestType for each request is defined in the individual file

const RequestTypeExecQuery RequestType = "exec_query"
const RequestTypeGetBlockInfoByHash RequestType = "get_block_info_by_hash"
const RequestTypeGetBlockInfoByNumber RequestType = "get_block_info_by_number"
const RequestTypeGetGasPrice RequestType = "get_gas_price"
const RequestTypeGetNewBlockHashes RequestType = "get_new_block_hashes"
const RequestTypeGetNextNonce RequestType = "get_next_nonce"
const RequestTypeGetReceipt RequestType = "get_receipt"
const RequestTypePrepareTransaction RequestType = "prepare_transaction"
const RequestTypeSendTransaction RequestType = "send_transaction"

type ResponseBase

type ResponseBase struct {
	ErrorResponse
}

func (*ResponseBase) ErrorMessage

func (r *ResponseBase) ErrorMessage() string

func (*ResponseBase) ErrorReason

func (r *ResponseBase) ErrorReason() ErrorReason

type SendTransactionRequest

type SendTransactionRequest struct {
	RequestBase
	GasPrice *fftypes.JSONAny `json:"gasPrice,omitempty"` // can be a simple string/number, or a complex object - contract is between policy engine and blockchain connector
	TransactionHeaders
	TransactionData string `json:"transactionData"`
}

SendTransactionRequest is used to send a transaction to the blockchain. The connector is responsible for adding it to the transaction pool of the blockchain, noting the transaction hash has already been calculated in the prepare step previously.

func (*SendTransactionRequest) RequestType

func (r *SendTransactionRequest) RequestType() RequestType

type SendTransactionResponse

type SendTransactionResponse struct {
	ResponseBase
	TransactionHash string `json:"transactionHash"`
}

type TransactionHeaders

type TransactionHeaders struct {
	From  string            `json:"from"`
	To    string            `json:"to,omitempty"`
	Nonce *fftypes.FFBigInt `json:"nonce,omitempty"`
	Gas   *fftypes.FFBigInt `json:"gas,omitempty"`
	Value *fftypes.FFBigInt `json:"value,omitempty"`
}

type TransactionInput

type TransactionInput struct {
	TransactionHeaders
	Method fftypes.JSONAny    `json:"method"`
	Params []*fftypes.JSONAny `json:"params"`
}

TransactionInput is a standardized set of parameters that describe a transaction submission to a blockchain. For convenience, ths structure is compatible with the EthConnect `SendTransaction` structure, for the subset of usage made by FireFly core / Tokens connectors. - Numberic values such as nonce/gas/gasPrice, are all passed as string encoded Base 10 integers - From/To are passed as strings, and are pass-through for FFTM from the values it receives from FireFly core after signing key resolution - The interface is a structure describing the method to invoke. The `variant` in the header tells you how to decode it. For variant=evm it will be an ABI method definition - The supplied value is passed through for each input parameter. It could be any JSON type (simple number/boolean/string, or complex object/array). The blockchain connection is responsible for serializing these according to the rules in the interface.

type Variant

type Variant string
const (
	VariantEVM Variant = "evm"
)

type Version

type Version string

Semver API versioning

const (
	Version1_0_0 Version = "v1.0.0"
)

Jump to

Keyboard shortcuts

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