Documentation ¶
Index ¶
- Constants
- type API
- type BlockInfo
- type CreateBlockListenerRequest
- type CreateBlockListenerResponse
- type ErrorReason
- type ErrorResponse
- type ExecQueryRequest
- type ExecQueryResponse
- type GetBlockInfoByHashRequest
- type GetBlockInfoByHashResponse
- type GetBlockInfoByNumberRequest
- type GetBlockInfoByNumberResponse
- type GetGasPriceRequest
- type GetGasPriceResponse
- type GetNewBlockHashesRequest
- type GetNewBlockHashesResponse
- type GetNextNonceRequest
- type GetNextNonceResponse
- type GetReceiptRequest
- type GetReceiptResponse
- type Header
- type PrepareTransactionRequest
- type PrepareTransactionResponse
- type RequestBase
- type RequestID
- type RequestType
- type ResponseBase
- type SendTransactionRequest
- type SendTransactionResponse
- type TransactionHeaders
- type TransactionInput
- type Variant
- type Version
Constants ¶
const RequestTypeCreateBlockListener = "create_block_listener"
const VersionCurrent = Version1_0_0
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { CreateBlockListener(ctx context.Context, req *CreateBlockListenerRequest) (*CreateBlockListenerResponse, ErrorReason, error) ExecQuery(ctx context.Context, req *ExecQueryRequest) (*ExecQueryResponse, ErrorReason, error) GetBlockInfoByHash(ctx context.Context, req *GetBlockInfoByHashRequest) (*GetBlockInfoByHashResponse, ErrorReason, error) GetBlockInfoByNumber(ctx context.Context, req *GetBlockInfoByNumberRequest) (*GetBlockInfoByNumberResponse, ErrorReason, error) GetGasPrice(ctx context.Context, req *GetGasPriceRequest) (*GetGasPriceResponse, ErrorReason, error) GetNewBlockHashes(ctx context.Context, req *GetNewBlockHashesRequest) (*GetNewBlockHashesResponse, ErrorReason, error) GetNextNonce(ctx context.Context, req *GetNextNonceRequest) (*GetNextNonceResponse, ErrorReason, error) GetReceipt(ctx context.Context, req *GetReceiptRequest) (*GetReceiptResponse, ErrorReason, error) PrepareTransaction(ctx context.Context, req *PrepareTransactionRequest) (*PrepareTransactionResponse, ErrorReason, error) SendTransaction(ctx context.Context, req *SendTransactionRequest) (*SendTransactionResponse, ErrorReason, error) }
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 Header ¶
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 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 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.