apitypes

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DistributionModeBroadcast   = fftypes.FFEnumValue("distmode", "broadcast")
	DistributionModeLoadBalance = fftypes.FFEnumValue("distmode", "load_balance")
)
View Source
var (
	EventStreamTypeWebhook   = fftypes.FFEnumValue("estype", "webhook")
	EventStreamTypeWebSocket = fftypes.FFEnumValue("estype", "websocket")
)
View Source
var (
	ErrorHandlingTypeBlock = fftypes.FFEnumValue("ehtype", "block")
	ErrorHandlingTypeSkip  = fftypes.FFEnumValue("ehtype", "skip")
)

Functions

func CheckUpdateBool

func CheckUpdateBool(changed bool, merged **bool, old *bool, new *bool, defValue bool) bool

CheckUpdateBool helper merges supplied configuration, with a base, and applies a default if unset

func CheckUpdateDuration

func CheckUpdateDuration(changed bool, merged **fftypes.FFDuration, old *fftypes.FFDuration, new *fftypes.FFDuration, defValue fftypes.FFDuration) bool

CheckUpdateDuration helper merges supplied configuration, with a base, and applies a default if unset

func CheckUpdateEnum

func CheckUpdateEnum(changed bool, merged **fftypes.FFEnum, old *fftypes.FFEnum, new *fftypes.FFEnum, defValue fftypes.FFEnum) bool

CheckUpdateEnum helper merges supplied configuration, with a base, and applies a default if unset

func CheckUpdateString

func CheckUpdateString(changed bool, merged **string, old *string, new *string, defValue string) bool

CheckUpdateString helper merges supplied configuration, with a base, and applies a default if unset

func CheckUpdateStringMap

func CheckUpdateStringMap(changed bool, merged *map[string]string, old map[string]string, new map[string]string) bool

CheckUpdateStringMap helper merges supplied configuration, with a base, and applies a default if unset

func CheckUpdateUint64

func CheckUpdateUint64(changed bool, merged **uint64, old *uint64, new *uint64, defValue int64) bool

CheckUpdateUint64 helper merges supplied configuration, with a base, and applies a default if unset

func NewULID

func NewULID() *fftypes.UUID

NewULID returns a Universally Unique Lexicographically Sortable Identifier (ULID). For consistency we impersonate the formatting of a UUID, so they can be used interchangeably. This can be used in database tables to ensure monotonic increasing identifiers.

Types

type BaseRequest

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

BaseRequest is the common headers to all requests, and captures the full input payload for later decoding to a specific type

func (*BaseRequest) UnmarshalJSON

func (br *BaseRequest) UnmarshalJSON(data []byte) error

func (*BaseRequest) UnmarshalTo

func (br *BaseRequest) UnmarshalTo(o interface{}) error

type ContractDeployRequest

type ContractDeployRequest struct {
	Headers RequestHeaders `json:"headers"`
	ffcapi.ContractDeployPrepareRequest
}

ContractDeployRequest is the payload sent to initiate a new transaction

type DistributionMode

type DistributionMode = fftypes.FFEnum

type ErrorHandlingType

type ErrorHandlingType = fftypes.FFEnum

type EventContext

type EventContext struct {
	StreamID       *fftypes.UUID `json:"streamId"`     // the ID of the event stream for this event
	EthCompatSubID *fftypes.UUID `json:"subId"`        // ID of the listener - EthCompat "subscription" naming
	ListenerName   string        `json:"listenerName"` // name of the listener
}

type EventStream

type EventStream struct {
	ID        *fftypes.UUID    `ffstruct:"eventstream" json:"id"`
	Created   *fftypes.FFTime  `ffstruct:"eventstream" json:"created"`
	Updated   *fftypes.FFTime  `ffstruct:"eventstream" json:"updated"`
	Name      *string          `ffstruct:"eventstream" json:"name,omitempty"`
	Suspended *bool            `ffstruct:"eventstream" json:"suspended,omitempty"`
	Type      *EventStreamType `ffstruct:"eventstream" json:"type,omitempty" ffenum:"estype"`

	ErrorHandling     *ErrorHandlingType  `ffstruct:"eventstream" json:"errorHandling"`
	BatchSize         *uint64             `ffstruct:"eventstream" json:"batchSize"`
	BatchTimeout      *fftypes.FFDuration `ffstruct:"eventstream" json:"batchTimeout"`
	RetryTimeout      *fftypes.FFDuration `ffstruct:"eventstream" json:"retryTimeout"`
	BlockedRetryDelay *fftypes.FFDuration `ffstruct:"eventstream" json:"blockedRetryDelay"`

	EthCompatBatchTimeoutMS       *uint64 `ffstruct:"eventstream" json:"batchTimeoutMS,omitempty"`       // input only, for backwards compatibility
	EthCompatRetryTimeoutSec      *uint64 `ffstruct:"eventstream" json:"retryTimeoutSec,omitempty"`      // input only, for backwards compatibility
	EthCompatBlockedRetryDelaySec *uint64 `ffstruct:"eventstream" json:"blockedRetryDelaySec,omitempty"` // input only, for backwards compatibility

	Webhook   *WebhookConfig   `ffstruct:"eventstream" json:"webhook,omitempty"`
	WebSocket *WebSocketConfig `ffstruct:"eventstream" json:"websocket,omitempty"`
}

type EventStreamCheckpoint

type EventStreamCheckpoint struct {
	StreamID  *fftypes.UUID                    `json:"streamId"`
	Time      *fftypes.FFTime                  `json:"time"`
	Listeners map[fftypes.UUID]json.RawMessage `json:"listeners"`
}

type EventStreamStatus

type EventStreamStatus string
const (
	EventStreamStatusStarted  EventStreamStatus = "started"
	EventStreamStatusStopping EventStreamStatus = "stopping"
	EventStreamStatusStopped  EventStreamStatus = "stopped"
	EventStreamStatusDeleted  EventStreamStatus = "deleted"
)

type EventStreamType

type EventStreamType = fftypes.FFEnum

type EventStreamWithStatus

type EventStreamWithStatus struct {
	EventStream
	Status EventStreamStatus `ffstruct:"eventstream" json:"status"`
}

type EventWithContext

type EventWithContext struct {
	StandardContext EventContext
	ffcapi.Event
}

EventWithContext is what is delivered There is custom serialization to flatten the whole structure, so all the custom `info` fields from the connector are alongside the required context fields. The `data` is kept separate

func (*EventWithContext) MarshalJSON

func (e *EventWithContext) MarshalJSON() ([]byte, error)

func (*EventWithContext) UnmarshalJSON

func (e *EventWithContext) UnmarshalJSON(b []byte) error

Note on unmarshal info will be a map with all the fields (except "data")

type Listener

type Listener struct {
	ID               *fftypes.UUID     `ffstruct:"listener" json:"id,omitempty"`
	Created          *fftypes.FFTime   `ffstruct:"listener" json:"created"`
	Updated          *fftypes.FFTime   `ffstruct:"listener" json:"updated"`
	Name             *string           `ffstruct:"listener" json:"name"`
	StreamID         *fftypes.UUID     `ffstruct:"listener" json:"stream" ffexcludeoutput:"true"`
	EthCompatAddress *string           `ffstruct:"listener" json:"address,omitempty"`
	EthCompatEvent   *fftypes.JSONAny  `ffstruct:"listener" json:"event,omitempty"`
	EthCompatMethods *fftypes.JSONAny  `ffstruct:"listener" json:"methods,omitempty"`
	Filters          []fftypes.JSONAny `ffstruct:"listener" json:"filters"`
	Options          *fftypes.JSONAny  `ffstruct:"listener" json:"options"`
	Signature        string            `ffstruct:"listener" json:"signature,omitempty" ffexcludeinput:"true"`
	FromBlock        *string           `ffstruct:"listener" json:"fromBlock,omitempty"`
}

type ManagedTX

type ManagedTX struct {
	ID                 string                             `json:"id"`
	Created            *fftypes.FFTime                    `json:"created"`
	Updated            *fftypes.FFTime                    `json:"updated"`
	Status             TxStatus                           `json:"status"`
	SequenceID         *fftypes.UUID                      `json:"sequenceId"`
	Nonce              *fftypes.FFBigInt                  `json:"nonce"`
	Gas                *fftypes.FFBigInt                  `json:"gas"`
	TransactionHeaders ffcapi.TransactionHeaders          `json:"transactionHeaders"`
	TransactionData    string                             `json:"transactionData"`
	TransactionHash    string                             `json:"transactionHash,omitempty"`
	GasPrice           *fftypes.JSONAny                   `json:"gasPrice"`
	PolicyInfo         *fftypes.JSONAny                   `json:"policyInfo"`
	FirstSubmit        *fftypes.FFTime                    `json:"firstSubmit,omitempty"`
	LastSubmit         *fftypes.FFTime                    `json:"lastSubmit,omitempty"`
	Receipt            *ffcapi.TransactionReceiptResponse `json:"receipt,omitempty"`
	ErrorMessage       string                             `json:"errorMessage,omitempty"`
	ErrorHistory       []*ManagedTXError                  `json:"errorHistory"`
	Confirmations      []confirmations.BlockInfo          `json:"confirmations,omitempty"`
}

ManagedTX is the structure stored for each new transaction request, using the external ID of the operation

Indexing:

Multiple index collection are stored for the managed transactions, to allow them to be managed including:

- Nonce allocation: this is a critical index, and why cleanup is so important (mentioned below).
  We use this index to determine the next nonce to assign to a given signing key.
- Created time: a timestamp ordered index for the transactions for convenient ordering.
  the key includes the ID of the TX for uniqueness.
- Pending sequence: An entry in this index only exists while the transaction is pending, and is
  ordered by a UUIDv1 sequence allocated to each entry.

Index cleanup after partial write:

  • All indexes are stored before the TX itself.
  • When listing back entries, the persistence layer will automatically clean up indexes if the underlying TX they refer to is not available. For this reason the index records are written first.

type ManagedTXError

type ManagedTXError struct {
	Time   *fftypes.FFTime    `json:"time"`
	Error  string             `json:"error,omitempty"`
	Mapped ffcapi.ErrorReason `json:"mapped,omitempty"`
}

type QueryRequest

type QueryRequest struct {
	Headers RequestHeaders `json:"headers"`
	ffcapi.TransactionInput
}

QueryRequest is the request payload to send to perform a synchronous query against the blockchain state

type QueryResponse

type QueryResponse ffcapi.QueryInvokeResponse

QueryResponse is the response payload for a query

type ReplyHeaders

type ReplyHeaders struct {
	RequestID string    `json:"requestId"`
	Type      ReplyType `json:"type"`
}

type ReplyType

type ReplyType string
const (
	TransactionUpdate        ReplyType = "TransactionUpdate"
	TransactionUpdateSuccess ReplyType = "TransactionSuccess"
	TransactionUpdateFailure ReplyType = "TransactionFailure"
)

type RequestHeaders

type RequestHeaders struct {
	ID   string      `ffstruct:"fftmrequest" json:"id"`
	Type RequestType `json:"type"`
}

type RequestType

type RequestType string
const (
	RequestTypeSendTransaction RequestType = "SendTransaction"
	RequestTypeQuery           RequestType = "Query"
	RequestTypeDeploy          RequestType = "DeployContract"
)

type TransactionRequest

type TransactionRequest struct {
	Headers RequestHeaders `json:"headers"`
	ffcapi.TransactionInput
}

TransactionRequest is the payload sent to initiate a new transaction

type TransactionUpdateReply

type TransactionUpdateReply struct {
	Headers ReplyHeaders `json:"headers"`
	ManagedTX
}

TransactionUpdateReply add a "headers" structure that allows a processor of websocket replies/updates to filter on a standard structure to know how to process the message. Extensible to update update types in the future.

type TxStatus

type TxStatus string

TxStatus is the current status of a transaction

const (
	// TxStatusPending indicates the operation has been submitted, but is not yet confirmed as successful or failed
	TxStatusPending TxStatus = "Pending"
	// TxStatusSucceeded the infrastructure runtime has returned success for the operation
	TxStatusSucceeded TxStatus = "Succeeded"
	// TxStatusFailed happens when an error is reported by the infrastructure runtime
	TxStatusFailed TxStatus = "Failed"
)

type WebSocketConfig

type WebSocketConfig struct {
	DistributionMode *DistributionMode `ffstruct:"wsconfig" json:"distributionMode,omitempty"`
	Topic            *string           `ffstruct:"wsconfig" json:"topic,omitempty"`
}

type WebhookConfig

type WebhookConfig struct {
	URL                        *string             `ffstruct:"whconfig" json:"url,omitempty"`
	Headers                    map[string]string   `ffstruct:"whconfig" json:"headers,omitempty"`
	TLSkipHostVerify           *bool               `ffstruct:"whconfig" json:"tlsSkipHostVerify,omitempty"`
	RequestTimeout             *fftypes.FFDuration `ffstruct:"whconfig" json:"requestTimeout,omitempty"`
	EthCompatRequestTimeoutSec *int64              `ffstruct:"whconfig" json:"requestTimeoutSec,omitempty"` // input only, for backwards compatibility
}

Jump to

Keyboard shortcuts

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