fftypes

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ChartHistogramMaxBuckets max buckets that can be requested
	ChartHistogramMaxBuckets = 100
	// ChartHistogramMinBuckets min buckets that can be requested
	ChartHistogramMinBuckets = 1
)
View Source
const (
	HTTPHeadersBlobHashSHA256 = "x-ff-blob-hash-sha256"
	HTTPHeadersBlobSize       = "x-ff-blob-size"
)
View Source
const (
	FireflyOrgDIDPrefix = "did:firefly:org/"
	OrgTopic            = "ff_organizations"
)
View Source
const (
	// DefaultTopic will be set as the topic of any messages set without a topic
	DefaultTopic = "default"
)
View Source
const FFStringArrayStandardMax = 1024

FFStringArrayStandardMax is the standard length we set as a VARCHAR max in tables for a string array

View Source
const FFStringNameItemsMax = 15

Because each FFName has a max length of 64, 15 names (plus comma delimeters) is a safe max to pack into a string column of length 1024

View Source
const MaxFFBigIntHexLength = 65
View Source
const (
	NullString = "null"
)
View Source
const (
	// ShortIDlphabet is designed for easy double-click select
	ShortIDlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"
)
View Source
const (

	// SystemNamespace is the system reserved namespace name
	SystemNamespace = "ff_system"
)

Variables

View Source
var (
	// TransactionTypeNone deprecated - replaced by TransactionTypeUnpinned
	TransactionTypeNone TransactionType = ffEnum("txtype", "none")
	// TransactionTypeUnpinned indicates the message will be sent without pinning any evidence to the blockchain. Not supported for broadcast. The FireFly transaction will be used to track the sends to all group members.
	TransactionTypeUnpinned TransactionType = ffEnum("txtype", "unpinned")
	// TransactionTypeBatchPin represents a pinning transaction, that verifies the originator of the data, and sequences the event deterministically between parties
	TransactionTypeBatchPin TransactionType = ffEnum("txtype", "batch_pin")
	// TransactionTypeTokenPool represents a token pool creation
	TransactionTypeTokenPool TransactionType = ffEnum("txtype", "token_pool")
	// TransactionTypeTokenTransfer represents a token transfer
	TransactionTypeTokenTransfer TransactionType = ffEnum("txtype", "token_transfer")
	// TransactionTypeContractInvoke is a smart contract invoke
	TransactionTypeContractInvoke OpType = ffEnum("txtype", "contract_invoke")
)

Functions

func CheckValidatorType

func CheckValidatorType(ctx context.Context, validator ValidatorType) error

func FFEnumValues

func FFEnumValues(t string) []interface{}

func NewFFISchemaCompiler added in v0.13.0

func NewFFISchemaCompiler() *jsonschema.Compiler

func ParseToByteSize

func ParseToByteSize(byteString string) int64

ParseToByteSize is a standard handling of a number of bytes, in config or API options

func ParseToDuration

func ParseToDuration(durationString string) time.Duration

ParseToDuration is a standard handling of any duration string, in config or API options

func SafeHashCompare

func SafeHashCompare(h1 *Bytes32, h2 *Bytes32) bool

func ShortID

func ShortID() string

func ToStringArray

func ToStringArray(unknown interface{}) ([]string, bool)

func TokenBalanceIdentifier added in v0.11.0

func TokenBalanceIdentifier(pool *UUID, tokenIndex, identity string) string

func ValidateFFNameField

func ValidateFFNameField(ctx context.Context, str string, fieldName string) error

func ValidateFFNameFieldNoUUID added in v0.11.4

func ValidateFFNameFieldNoUUID(ctx context.Context, str string, fieldName string) error

func ValidateLength

func ValidateLength(ctx context.Context, str string, fieldName string, max int) error

func ValidateSafeCharsOnly added in v0.12.0

func ValidateSafeCharsOnly(ctx context.Context, str string, fieldName string) error

Types

type BaseFFIParamValidator added in v0.13.0

type BaseFFIParamValidator struct{}

func (BaseFFIParamValidator) Compile added in v0.13.0

func (v BaseFFIParamValidator) Compile(ctx jsonschema.CompilerContext, m map[string]interface{}) (jsonschema.ExtSchema, error)

func (*BaseFFIParamValidator) GetExtensionName added in v0.13.0

func (v *BaseFFIParamValidator) GetExtensionName() string

func (*BaseFFIParamValidator) GetMetaSchema added in v0.13.0

func (v *BaseFFIParamValidator) GetMetaSchema() *jsonschema.Schema

type Batch

type Batch struct {
	ID        *UUID       `json:"id"`
	Namespace string      `json:"namespace"`
	Type      MessageType `json:"type"`
	Node      *UUID       `json:"node,omitempty"`
	Identity
	Group      *Bytes32     `jdon:"group,omitempty"`
	Hash       *Bytes32     `json:"hash"`
	Created    *FFTime      `json:"created"`
	Confirmed  *FFTime      `json:"confirmed"`
	Payload    BatchPayload `json:"payload"`
	PayloadRef string       `json:"payloadRef,omitempty"`
	Blobs      []*Bytes32   `json:"blobs,omitempty"` // only used in-flight
}

func (*Batch) Manifest added in v0.12.0

func (b *Batch) Manifest() *Manifest

type BatchPayload

type BatchPayload struct {
	TX       TransactionRef `json:"tx"`
	Messages []*Message     `json:"messages"`
	Data     []*Data        `json:"data"`
}

func (*BatchPayload) Hash

func (ma *BatchPayload) Hash() *Bytes32

func (*BatchPayload) Scan

func (ma *BatchPayload) Scan(src interface{}) error

Scan implements sql.Scanner

func (BatchPayload) Value

func (ma BatchPayload) Value() (driver.Value, error)

Value implements sql.Valuer

type Blob

type Blob struct {
	Hash       *Bytes32 `json:"hash"`
	Size       int64    `json:"size"`
	PayloadRef string   `json:"payloadRef,omitempty"`
	Peer       string   `json:"peer,omitempty"`
	Created    *FFTime  `json:"created,omitempty"`
	Sequence   int64    `json:"-"`
}

type BlobRef

type BlobRef struct {
	Hash   *Bytes32 `json:"hash"`
	Size   int64    `json:"size"`
	Name   string   `json:"name"`
	Public string   `json:"public,omitempty"`
}

type BlockchainEvent added in v0.12.0

type BlockchainEvent struct {
	ID           *UUID          `json:"id,omitempty"`
	Sequence     int64          `json:"sequence"`
	Source       string         `json:"source,omitempty"`
	Namespace    string         `json:"namespace,omitempty"`
	Name         string         `json:"name,omitempty"`
	Subscription *UUID          `json:"subscription,omitempty"`
	ProtocolID   string         `json:"protocolId,omitempty"`
	Output       JSONObject     `json:"output,omitempty"`
	Info         JSONObject     `json:"info,omitempty"`
	Timestamp    *FFTime        `json:"timestamp,omitempty"`
	TX           TransactionRef `json:"tx"`
}

type Bytes32

type Bytes32 [32]byte

Bytes32 is a holder of a hash, that can be used to correlate onchain data with off-chain data.

func HashResult

func HashResult(hash hash.Hash) *Bytes32

func MustParseBytes32 added in v0.12.0

func MustParseBytes32(hexStr string) *Bytes32

func NewRandB32

func NewRandB32() *Bytes32

func ParseBytes32

func ParseBytes32(ctx context.Context, hexStr string) (*Bytes32, error)

func UUIDBytes

func UUIDBytes(u *UUID) *Bytes32

UUIDBytes returns the bytes of a UUID as a compressed hex string

func (*Bytes32) Equals

func (b32 *Bytes32) Equals(b2 *Bytes32) bool

func (Bytes32) MarshalText

func (b32 Bytes32) MarshalText() ([]byte, error)

func (*Bytes32) Scan

func (b32 *Bytes32) Scan(src interface{}) error

Scan implements sql.Scanner

func (*Bytes32) String

func (b32 *Bytes32) String() string

func (*Bytes32) UnmarshalText

func (b32 *Bytes32) UnmarshalText(b []byte) error

func (*Bytes32) Value

func (b32 *Bytes32) Value() (driver.Value, error)

Value implements sql.Valuer

type ChangeEvent

type ChangeEvent struct {
	// The resource collection where the changed resource exists
	Collection string `json:"collection"`
	// The type of event
	Type ChangeEventType `json:"type"`
	// Namespace is set if there is a namespace associated with the changed resource
	Namespace string `json:"namespace,omitempty"`
	// UUID is set if the resource is identified by ID
	ID *UUID `json:"id,omitempty"`
	// Hash is set if the resource is identified primarily by hash (groups is currently the only example)
	Hash *Bytes32 `json:"hash,omitempty"`
	// Sequence is set if there is a local ordered sequence associated with the changed resource
	Sequence *int64 `json:"sequence,omitempty"`
}

ChangeEvent is a change to the local FireFly core node.

type ChangeEventType

type ChangeEventType string

ChangeEventType

const (
	ChangeEventTypeCreated ChangeEventType = "created"
	ChangeEventTypeUpdated ChangeEventType = "updated" // note bulk updates might not results in change events.
	ChangeEventTypeDeleted ChangeEventType = "deleted"
)

type ChartHistogram added in v0.11.2

type ChartHistogram struct {
	// Timestamp of bucket in histogram
	Timestamp *FFTime `json:"timestamp"`
	// Count for timestamp in histogram
	Count string `json:"count"`
}

ChartHistogram is a timestamp and count

type ChartHistogramInterval added in v0.11.2

type ChartHistogramInterval struct {
	// StartTime start time of histogram interval
	StartTime *FFTime `json:"startTime"`
	// EndTime end time of histogram interval
	EndTime *FFTime `json:"endTime"`
}

ChartHistogramInterval specifies lower and upper timestamps for histogram bucket

type ConfigRecord

type ConfigRecord struct {
	Key   string   `json:"key,omitempty"`
	Value *JSONAny `json:"value,omitempty"`
}

type ContractAPI added in v0.12.0

type ContractAPI struct {
	ID        *UUID         `json:"id,omitempty"`
	Namespace string        `json:"namespace,omitempty"`
	Interface *FFIReference `json:"interface"`
	Ledger    *JSONAny      `json:"ledger,omitempty"`
	Location  *JSONAny      `json:"location,omitempty"`
	Name      string        `json:"name"`
	Message   *UUID         `json:"message,omitempty"`
	URLs      ContractURLs  `json:"urls"`
}

func (*ContractAPI) LocationAndLedgerEquals added in v0.12.0

func (c *ContractAPI) LocationAndLedgerEquals(a *ContractAPI) bool

func (*ContractAPI) SetBroadcastMessage added in v0.12.0

func (c *ContractAPI) SetBroadcastMessage(msgID *UUID)

func (*ContractAPI) Topic added in v0.12.0

func (c *ContractAPI) Topic() string

func (*ContractAPI) Validate added in v0.12.0

func (c *ContractAPI) Validate(ctx context.Context, existing bool) (err error)

type ContractCallRequest added in v0.12.0

type ContractCallRequest struct {
	Type      ContractCallType       `json:"type,omitempty" ffenum:"contractcalltype"`
	Interface *UUID                  `json:"interface,omitempty"`
	Ledger    *JSONAny               `json:"ledger,omitempty"`
	Location  *JSONAny               `json:"location,omitempty"`
	Key       string                 `json:"key,omitempty"`
	Method    *FFIMethod             `json:"method,omitempty"`
	Input     map[string]interface{} `json:"input"`
}

type ContractCallType added in v0.12.0

type ContractCallType = FFEnum
var (
	// CallTypeInvoke is an invocation that submits a transaction for inclusion in the chain
	CallTypeInvoke ContractCallType = ffEnum("contractcalltype", "invoke")
	// CallTypeQuery is a query that returns data from the chain
	CallTypeQuery ContractCallType = ffEnum("contractcalltype", "query")
)

type ContractSubscribeRequest added in v0.12.0

type ContractSubscribeRequest struct {
	Interface *UUID     `json:"interface,omitempty"`
	Location  *JSONAny  `json:"location,omitempty"`
	Event     *FFIEvent `json:"event,omitempty"`
}

type ContractSubscription added in v0.12.0

type ContractSubscription struct {
	ID         *UUID               `json:"id,omitempty"`
	Interface  *FFIReference       `json:"interface,omitempty"`
	Namespace  string              `json:"namespace,omitempty"`
	Name       string              `json:"name,omitempty"`
	ProtocolID string              `json:"protocolId,omitempty"`
	Location   *JSONAny            `json:"location,omitempty"`
	Created    *FFTime             `json:"created,omitempty"`
	Event      *FFISerializedEvent `json:"event,omitempty"`
}

type ContractSubscriptionInput added in v0.12.0

type ContractSubscriptionInput struct {
	ContractSubscription
	EventID *UUID `json:"eventId,omitempty"`
}

type ContractURLs added in v0.12.0

type ContractURLs struct {
	OpenAPI string `json:"openapi"`
	UI      string `json:"ui"`
}

type DXInfo

type DXInfo struct {
	Peer     string     `json:"peer,omitempty"`
	Endpoint JSONObject `json:"endpoint,omitempty"`
}

DXInfo is the data exchange information

type Data

type Data struct {
	ID        *UUID         `json:"id,omitempty"`
	Validator ValidatorType `json:"validator"`
	Namespace string        `json:"namespace,omitempty"`
	Hash      *Bytes32      `json:"hash,omitempty"`
	Created   *FFTime       `json:"created,omitempty"`
	Datatype  *DatatypeRef  `json:"datatype,omitempty"`
	Value     *JSONAny      `json:"value"`
	Blob      *BlobRef      `json:"blob,omitempty"`

	ValueSize int64 `json:"-"` // Used internally for message size calcuation, without full payload retrieval
}

func (*Data) CalcHash

func (d *Data) CalcHash(ctx context.Context) (*Bytes32, error)

func (*Data) EstimateSize added in v0.12.0

func (d *Data) EstimateSize() int64

func (*Data) Seal

func (d *Data) Seal(ctx context.Context, blob *Blob) (err error)

type DataAndBlob

type DataAndBlob struct {
	Data *Data
	Blob *Blob
}

type DataRef

type DataRef struct {
	ID   *UUID    `json:"id,omitempty"`
	Hash *Bytes32 `json:"hash,omitempty"`

	ValueSize int64 `json:"-"` // used internally for message size calculation, without full payload retrieval
}

type DataRefOrValue

type DataRefOrValue struct {
	DataRef

	Validator ValidatorType `json:"validator,omitempty"`
	Datatype  *DatatypeRef  `json:"datatype,omitempty"`
	Value     *JSONAny      `json:"value,omitempty"`
	Blob      *BlobRef      `json:"blob,omitempty"`
}

DataRefOrValue allows a value to be specified in-line in the data array of an input message, avoiding the need for a multiple API calls.

type DataRefs

type DataRefs []*DataRef

func (DataRefs) Hash

func (d DataRefs) Hash() *Bytes32

type Datatype

type Datatype struct {
	ID        *UUID         `json:"id,omitempty"`
	Message   *UUID         `json:"message,omitempty"`
	Validator ValidatorType `json:"validator" ffenum:"validatortype"`
	Namespace string        `json:"namespace,omitempty"`
	Name      string        `json:"name,omitempty"`
	Version   string        `json:"version,omitempty"`
	Hash      *Bytes32      `json:"hash,omitempty"`
	Created   *FFTime       `json:"created,omitempty"`
	Value     *JSONAny      `json:"value,omitempty"`
}

Datatype is the structure defining a data definition, such as a JSON schema

func (*Datatype) SetBroadcastMessage

func (dt *Datatype) SetBroadcastMessage(msgID *UUID)

func (*Datatype) Topic

func (dt *Datatype) Topic() string

func (*Datatype) Validate

func (dt *Datatype) Validate(ctx context.Context, existing bool) (err error)

type DatatypeRef

type DatatypeRef struct {
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
}

func (*DatatypeRef) String

func (dr *DatatypeRef) String() string

type Definition

type Definition interface {
	// Topic returns the topic on which the object should be broadcast
	Topic() string
	// SetBroadcastMessage sets the message that broadcast the definition
	SetBroadcastMessage(msgID *UUID)
}

Definition is implemented by all objects that can be broadcast as system definitions to the network

type EmptyInput

type EmptyInput struct{}

EmptyInput represents an API with no input fields, but requiring a JSON content type on the request

type Event

type Event struct {
	ID        *UUID     `json:"id"`
	Sequence  int64     `json:"sequence"`
	Type      EventType `json:"type" ffenum:"eventtype"`
	Namespace string    `json:"namespace"`
	Reference *UUID     `json:"reference"`
	Created   *FFTime   `json:"created"`
}

Event is an activity in the system, delivered reliably to applications, that indicates something has happened in the network

func NewEvent

func NewEvent(t EventType, ns string, ref *UUID) *Event

func (*Event) LocalSequence

func (e *Event) LocalSequence() int64

type EventDelivery

type EventDelivery struct {
	Event
	Subscription SubscriptionRef `json:"subscription"`
	Message      *Message        `json:"message,omitempty"`
}

EventDelivery adds the referred object to an event, as well as details of the subscription that caused the event to be dispatched to an applciation.

type EventDeliveryResponse

type EventDeliveryResponse struct {
	ID           *UUID           `json:"id"`
	Rejected     bool            `json:"rejected,omitempty"`
	Info         string          `json:"info,omitempty"`
	Subscription SubscriptionRef `json:"subscription"`
	Reply        *MessageInOut   `json:"reply,omitempty"`
}

EventDeliveryResponse is the payload an application sends back, to confirm it has accepted (or rejected) the event and as such does not need to receive it again.

type EventType

type EventType = FFEnum

EventType indicates what the event means, as well as what the Reference in the event refers to

var (
	// EventTypeTransactionSubmitted occurs only on the node that initiates a tranaction, when the transaction is submitted
	EventTypeTransactionSubmitted EventType = ffEnum("eventtype", "transaction_submitted")
	// EventTypeMessageConfirmed is the most important event type in the system. This means a message and all of its data
	// is available for processing by an application. Most applications only need to listen to this event type
	EventTypeMessageConfirmed EventType = ffEnum("eventtype", "message_confirmed")
	// EventTypeMessageRejected occurs if a message is received and confirmed from a sequencing perspective, but is rejected as invalid (mismatch to schema, or duplicate system broadcast)
	EventTypeMessageRejected EventType = ffEnum("eventtype", "message_rejected")
	// EventTypeNamespaceConfirmed occurs when a new namespace is ready for use (on the namespace itself)
	EventTypeNamespaceConfirmed EventType = ffEnum("eventtype", "namespace_confirmed")
	// EventTypeDatatypeConfirmed occurs when a new datatype is ready for use (on the namespace of the datatype)
	EventTypeDatatypeConfirmed EventType = ffEnum("eventtype", "datatype_confirmed")
	// EventTypeGroupConfirmed occurs when a new group is ready to use (on the namespace of the group, on all group participants)
	EventTypeGroupConfirmed EventType = ffEnum("eventtype", "group_confirmed")
	// EventTypePoolConfirmed occurs when a new token pool is ready for use
	EventTypePoolConfirmed EventType = ffEnum("eventtype", "token_pool_confirmed")
	// EventTypeTransferConfirmed occurs when a token transfer has been confirmed
	EventTypeTransferConfirmed EventType = ffEnum("eventtype", "token_transfer_confirmed")
	// EventTypeTransferOpFailed occurs when a token transfer submitted by this node has failed (based on feedback from connector)
	EventTypeTransferOpFailed EventType = ffEnum("eventtype", "token_transfer_op_failed")
	// EventTypeContractInterfaceConfirmed occurs when a new contract interface has been confirmed
	EventTypeContractInterfaceConfirmed EventType = ffEnum("eventtype", "contract_interface_confirmed")
	// EventTypeContractAPIConfirmed occurs when a new contract API has been confirmed
	EventTypeContractAPIConfirmed EventType = ffEnum("eventtype", "contract_api_confirmed")
	// EventTypeBlockchainEvent occurs when a new event has been recorded from the blockchain
	EventTypeBlockchainEvent EventType = ffEnum("eventtype", "blockchain_event")
)

type FFBigInt added in v0.12.0

type FFBigInt big.Int

FFBigInt is a wrapper on a Go big.Int that standardizes JSON and DB serialization

func NewFFBigInt added in v0.12.0

func NewFFBigInt(x int64) *FFBigInt

func (*FFBigInt) Equals added in v0.12.0

func (i *FFBigInt) Equals(i2 *FFBigInt) bool

func (*FFBigInt) Int added in v0.12.0

func (i *FFBigInt) Int() *big.Int

func (FFBigInt) MarshalText added in v0.12.0

func (i FFBigInt) MarshalText() ([]byte, error)

func (*FFBigInt) Scan added in v0.12.0

func (i *FFBigInt) Scan(src interface{}) error

func (*FFBigInt) UnmarshalJSON added in v0.12.0

func (i *FFBigInt) UnmarshalJSON(b []byte) error

func (FFBigInt) Value added in v0.12.0

func (i FFBigInt) Value() (driver.Value, error)

type FFDuration

type FFDuration time.Duration

FFDuration is serialized to JSON in the string format of time.Duration It can be unmarshalled from a number, or a string. - If it is a string in time.Duration format, that will be used - If it is a string that can be parsed as an int64, that will be used in Milliseconds - If it is a number, that will be used in Milliseconds

func ParseDurationString

func ParseDurationString(durationString string, def time.Duration) (FFDuration, error)

ParseDurationString is a standard handling of any duration string, in config or API options

func (*FFDuration) MarshalJSON

func (fd *FFDuration) MarshalJSON() ([]byte, error)

func (*FFDuration) Scan

func (fd *FFDuration) Scan(src interface{}) error

Scan implements sql.Scanner

func (*FFDuration) String

func (fd *FFDuration) String() string

func (*FFDuration) UnmarshalJSON

func (fd *FFDuration) UnmarshalJSON(b []byte) error

func (*FFDuration) Value

func (fd *FFDuration) Value() (driver.Value, error)

Value implements sql.Valuer

type FFEnum

type FFEnum string

func (FFEnum) Equals

func (ts FFEnum) Equals(ts2 FFEnum) bool

func (FFEnum) Lower

func (ts FFEnum) Lower() FFEnum

func (FFEnum) String

func (ts FFEnum) String() string

func (*FFEnum) UnmarshalText

func (ts *FFEnum) UnmarshalText(b []byte) error

func (FFEnum) Value

func (ts FFEnum) Value() (driver.Value, error)

type FFI added in v0.12.0

type FFI struct {
	ID          *UUID        `json:"id,omitempty"`
	Message     *UUID        `json:"message,omitempty"`
	Namespace   string       `json:"namespace,omitempty"`
	Name        string       `json:"name,omitempty"`
	Description string       `json:"description"`
	Version     string       `json:"version,omitempty"`
	Methods     []*FFIMethod `json:"methods,omitempty"`
	Events      []*FFIEvent  `json:"events,omitempty"`
}

func (*FFI) SetBroadcastMessage added in v0.12.0

func (f *FFI) SetBroadcastMessage(msgID *UUID)

func (*FFI) Topic added in v0.12.0

func (f *FFI) Topic() string

func (*FFI) Validate added in v0.12.0

func (f *FFI) Validate(ctx context.Context, existing bool) (err error)

type FFIEvent added in v0.12.0

type FFIEvent struct {
	ID        *UUID  `json:"id,omitempty"`
	Contract  *UUID  `json:"contract,omitempty"`
	Namespace string `json:"namespace,omitempty"`
	Pathname  string `json:"pathname,omitempty"`
	FFIEventDefinition
}

type FFIEventDefinition added in v0.12.0

type FFIEventDefinition struct {
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Params      FFIParams `json:"params"`
}

type FFIMethod added in v0.12.0

type FFIMethod struct {
	ID          *UUID     `json:"id,omitempty"`
	Contract    *UUID     `json:"contract,omitempty"`
	Name        string    `json:"name"`
	Namespace   string    `json:"namespace,omitempty"`
	Pathname    string    `json:"pathname"`
	Description string    `json:"description"`
	Params      FFIParams `json:"params"`
	Returns     FFIParams `json:"returns"`
}

type FFIParam added in v0.12.0

type FFIParam struct {
	Name   string   `json:"name"`
	Schema *JSONAny `json:"schema,omitempty"`
}

type FFIParamValidator added in v0.12.0

type FFIParamValidator interface {
	Compile(ctx jsonschema.CompilerContext, m map[string]interface{}) (jsonschema.ExtSchema, error)
	GetMetaSchema() *jsonschema.Schema
	GetExtensionName() string
}

type FFIParams added in v0.12.0

type FFIParams []*FFIParam

func (*FFIParams) Scan added in v0.12.0

func (m *FFIParams) Scan(src interface{}) error

Scan implements sql.Scanner

func (FFIParams) Value added in v0.12.0

func (m FFIParams) Value() (driver.Value, error)

type FFIReference added in v0.12.0

type FFIReference struct {
	ID      *UUID  `json:"id,omitempty"`
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
}

type FFISerializedEvent added in v0.12.0

type FFISerializedEvent struct {
	FFIEventDefinition
}

func (*FFISerializedEvent) Scan added in v0.12.0

func (fse *FFISerializedEvent) Scan(src interface{}) error

Scan implements sql.Scanner

func (FFISerializedEvent) Value added in v0.12.0

func (fse FFISerializedEvent) Value() (driver.Value, error)

type FFStringArray added in v0.12.0

type FFStringArray []string

FFStringArray is an array of strings, each conforming to the requirements of a FireFly name

func NewFFStringArray added in v0.12.0

func NewFFStringArray(initialContent ...string) FFStringArray

func (FFStringArray) AddToSortedSet added in v0.12.0

func (sa FFStringArray) AddToSortedSet(newValues ...string) (res FFStringArray, changed bool)

AddToSortedSet determines if the new string is already in the set of strings (case insensitive), and if not it adds it to the list (lower case) and returns a new slice of alphabetically sorted strings reference and true. If no change is made, the original reference is returned and false.

func (*FFStringArray) Scan added in v0.12.0

func (sa *FFStringArray) Scan(src interface{}) error

func (FFStringArray) String added in v0.12.0

func (sa FFStringArray) String() string

func (FFStringArray) Validate added in v0.12.0

func (sa FFStringArray) Validate(ctx context.Context, fieldName string, isName bool) error

func (FFStringArray) Value added in v0.12.0

func (sa FFStringArray) Value() (driver.Value, error)

type FFTime

type FFTime time.Time

FFTime is serialized to JSON on the API in RFC3339 nanosecond UTC time (noting that JavaScript can parse this format happily into millisecond time with Date.pase()). It is persisted as a nanosecond resolution timestamp in the database. It can be parsed from RFC3339, or unix timestamps (second, millisecond or nanosecond resolution)

func Now

func Now() *FFTime

func ParseTimeString added in v0.12.0

func ParseTimeString(str string) (*FFTime, error)

func UnixTime

func UnixTime(unixTime int64) *FFTime

func ZeroTime

func ZeroTime() FFTime

func (*FFTime) Equal

func (ft *FFTime) Equal(ft2 *FFTime) bool

func (*FFTime) MarshalJSON

func (ft *FFTime) MarshalJSON() ([]byte, error)

func (*FFTime) Scan

func (ft *FFTime) Scan(src interface{}) error

Scan implements sql.Scanner

func (FFTime) String

func (ft FFTime) String() string

func (*FFTime) Time added in v0.11.0

func (ft *FFTime) Time() *time.Time

func (*FFTime) UnixNano

func (ft *FFTime) UnixNano() int64

func (*FFTime) UnmarshalText

func (ft *FFTime) UnmarshalText(b []byte) error

func (FFTime) Value

func (ft FFTime) Value() (driver.Value, error)

Value implements sql.Valuer

type Group

type Group struct {
	GroupIdentity
	Message *UUID    `json:"message,omitempty"`
	Hash    *Bytes32 `json:"hash,omitempty"`
	Created *FFTime  `json:"created,omitempty"`
}

func (*Group) Seal

func (group *Group) Seal()

func (*Group) SetBroadcastMessage

func (group *Group) SetBroadcastMessage(msgID *UUID)

func (*Group) Topic

func (group *Group) Topic() string

func (*Group) Validate

func (group *Group) Validate(ctx context.Context, existing bool) (err error)

type GroupIdentity

type GroupIdentity struct {
	Ledger    *UUID   `json:"ledger,omitempty"`
	Namespace string  `json:"namespace,omitempty"`
	Name      string  `json:"name"`
	Members   Members `json:"members"`
}

func (*GroupIdentity) Hash

func (man *GroupIdentity) Hash() *Bytes32

type HexUUID

type HexUUID = Bytes32

HexUUID is 32 character ASCII string containing the hex representation of UUID, with the dashes of the canonical representation removed

type Identity

type Identity struct {
	Author string `json:"author,omitempty"`
	Key    string `json:"key,omitempty"`
}

Identity is the nested structure representing an identity, that might comprise a resolvable by FireFly identity DID, a blockchain signing key, or both.

type InlineData

type InlineData []*DataRefOrValue

InlineData is an array of data references or values

type InputGroup

type InputGroup struct {
	Name    string        `json:"name,omitempty"`
	Ledger  *UUID         `json:"ledger,omitempty"`
	Members []MemberInput `json:"members"`
}

InputGroup declares a group in-line for auotmatic resolution, without having to define a group up-front

type JSONAny added in v0.12.0

type JSONAny string

JSONAny uses raw encode/decode to preserve field order, and can handle any types of field. It validates the JSON can be unmarshalled, but does not change the order. It does however trim out whitespace

func JSONAnyPtr added in v0.12.0

func JSONAnyPtr(str string) *JSONAny

func JSONAnyPtrBytes added in v0.12.0

func JSONAnyPtrBytes(b []byte) *JSONAny

func (*JSONAny) Bytes added in v0.12.0

func (h *JSONAny) Bytes() []byte

func (*JSONAny) Hash added in v0.12.0

func (h *JSONAny) Hash() *Bytes32

func (*JSONAny) IsNil added in v0.12.0

func (h *JSONAny) IsNil() bool

func (*JSONAny) JSONObject added in v0.12.0

func (h *JSONAny) JSONObject() JSONObject

JSONObject attempts to de-serailize the contained structure as a JSON Object (map) Safe and will never return nil Will return an empty object if the type is array, string, bool, number etc.

func (*JSONAny) JSONObjectNowarn added in v0.12.0

func (h *JSONAny) JSONObjectNowarn() JSONObject

JSONObjectNowarn acts the same as JSONObject, but does not warn if the value cannot be parsed as an object

func (*JSONAny) JSONObjectOk added in v0.12.0

func (h *JSONAny) JSONObjectOk(noWarn ...bool) (JSONObject, bool)

func (*JSONAny) Length added in v0.12.0

func (h *JSONAny) Length() int64

func (JSONAny) MarshalJSON added in v0.12.0

func (h JSONAny) MarshalJSON() ([]byte, error)

func (*JSONAny) Scan added in v0.12.0

func (h *JSONAny) Scan(src interface{}) error

Scan implements sql.Scanner

func (*JSONAny) String added in v0.12.0

func (h *JSONAny) String() string

func (*JSONAny) UnmarshalJSON added in v0.12.0

func (h *JSONAny) UnmarshalJSON(b []byte) error

type JSONObject

type JSONObject map[string]interface{}

JSONObject is a holder of a hash, that can be used to correlate onchain data with off-chain data.

func (JSONObject) GetBool

func (jd JSONObject) GetBool(key string) bool

func (JSONObject) GetInt64 added in v0.12.0

func (jd JSONObject) GetInt64(key string) int64

func (JSONObject) GetInteger added in v0.12.0

func (jd JSONObject) GetInteger(key string) *big.Int

func (JSONObject) GetObject

func (jd JSONObject) GetObject(key string) JSONObject

func (JSONObject) GetObjectArray

func (jd JSONObject) GetObjectArray(key string) JSONObjectArray

func (JSONObject) GetObjectArrayOk

func (jd JSONObject) GetObjectArrayOk(key string) (JSONObjectArray, bool)

func (JSONObject) GetObjectOk

func (jd JSONObject) GetObjectOk(key string) (JSONObject, bool)

func (JSONObject) GetString

func (jd JSONObject) GetString(key string) string

func (JSONObject) GetStringArray

func (jd JSONObject) GetStringArray(key string) []string

func (JSONObject) GetStringArrayOk

func (jd JSONObject) GetStringArrayOk(key string) ([]string, bool)

func (JSONObject) GetStringOk

func (jd JSONObject) GetStringOk(key string) (string, bool)

func (JSONObject) Hash

func (jd JSONObject) Hash(jsonDesc string) (*Bytes32, error)

func (*JSONObject) Scan

func (jd *JSONObject) Scan(src interface{}) error

Scan implements sql.Scanner

func (JSONObject) String

func (jd JSONObject) String() string

func (JSONObject) Value

func (jd JSONObject) Value() (driver.Value, error)

Value implements sql.Valuer

type JSONObjectArray

type JSONObjectArray []JSONObject

JSONObjectArray is an array of JSONObject

func ToJSONObjectArray

func ToJSONObjectArray(unknown interface{}) (JSONObjectArray, bool)

func (JSONObjectArray) Hash

func (jd JSONObjectArray) Hash(jsonDesc string) (*Bytes32, error)

func (*JSONObjectArray) Scan

func (jd *JSONObjectArray) Scan(src interface{}) error

Scan implements sql.Scanner

func (JSONObjectArray) String

func (jd JSONObjectArray) String() string

func (JSONObjectArray) Value

func (jd JSONObjectArray) Value() (driver.Value, error)

type LocallySequenced

type LocallySequenced interface {
	LocalSequence() int64
}

type Manifest added in v0.12.0

type Manifest struct {
	Messages []MessageRef `json:"messages"`
	Data     []DataRef    `json:"data"`
}

Manifest is a list of references to messages and data

func (*Manifest) String added in v0.12.0

func (mf *Manifest) String() string

type Member

type Member struct {
	Identity string `json:"identity,omitempty"`
	Node     *UUID  `json:"node,omitempty"`
}

type MemberInput

type MemberInput struct {
	Identity string `json:"identity,omitempty"`
	Node     string `json:"node,omitempty"`
}

type Members

type Members []*Member

func (Members) Len

func (m Members) Len() int

func (Members) Less

func (m Members) Less(i, j int) bool

func (Members) Swap

func (m Members) Swap(i, j int)

type Message

type Message struct {
	Header    MessageHeader `json:"header"`
	Hash      *Bytes32      `json:"hash,omitempty"`
	BatchID   *UUID         `json:"batch,omitempty"`
	State     MessageState  `json:"state,omitempty" ffenum:"messagestate"`
	Confirmed *FFTime       `json:"confirmed,omitempty"`
	Data      DataRefs      `json:"data"`
	Pins      FFStringArray `json:"pins,omitempty"`
	Sequence  int64         `json:"-"` // Local database sequence used internally for batch assembly
}

Message is the envelope by which coordinated data exchange can happen between parties in the network Data is passed by reference in these messages, and a chain of hashes covering the data and the details of the message, provides a verification against tampering.

func (*Message) DupDataCheck

func (m *Message) DupDataCheck(ctx context.Context) (err error)

func (*Message) EstimateSize added in v0.12.0

func (m *Message) EstimateSize(includeDataRefs bool) int64

func (*Message) LocalSequence

func (m *Message) LocalSequence() int64

func (*Message) Seal

func (m *Message) Seal(ctx context.Context) (err error)

func (*Message) Verify

func (m *Message) Verify(ctx context.Context) error

type MessageHeader

type MessageHeader struct {
	ID     *UUID           `json:"id,omitempty"`
	CID    *UUID           `json:"cid,omitempty"`
	Type   MessageType     `json:"type" ffenum:"messagetype"`
	TxType TransactionType `json:"txtype,omitempty"`
	Identity
	Created   *FFTime       `json:"created,omitempty"`
	Namespace string        `json:"namespace,omitempty"`
	Group     *Bytes32      `json:"group,omitempty"`
	Topics    FFStringArray `json:"topics,omitempty"`
	Tag       string        `json:"tag,omitempty"`
	DataHash  *Bytes32      `json:"datahash,omitempty"`
}

MessageHeader contains all fields that contribute to the hash The order of the serialization mut not change, once released

func (*MessageHeader) Hash

func (h *MessageHeader) Hash() *Bytes32

type MessageInOut

type MessageInOut struct {
	Message
	InlineData InlineData  `json:"data"`
	Group      *InputGroup `json:"group,omitempty"`
}

MessageInOut allows API users to submit values in-line in the payload submitted, which will be broken out and stored separately during the call.

func (*MessageInOut) SetInlineData

func (m *MessageInOut) SetInlineData(data []*Data)

type MessageRef

type MessageRef struct {
	ID   *UUID    `json:"id,omitempty"`
	Hash *Bytes32 `json:"hash,omitempty"`
}

MessageRef is a lightweight data structure that can be used to refer to a message

type MessageState added in v0.11.0

type MessageState = FFEnum

MessageState is the current transmission/confirmation state of a message

var (
	// MessageStateStaged is a message created locally which is not ready to send
	MessageStateStaged MessageState = ffEnum("messagestate", "staged")
	// MessageStateReady is a message created locally which is ready to send
	MessageStateReady MessageState = ffEnum("messagestate", "ready")
	// MessageStateSent is a message created locally which has been sent in a batch
	MessageStateSent MessageState = ffEnum("messagestate", "sent")
	// MessageStatePending is a message that has been received but is awaiting aggregation/confirmation
	MessageStatePending MessageState = ffEnum("messagestate", "pending")
	// MessageStateConfirmed is a message that has completed all required confirmations (blockchain if pinned, token transfer if transfer coupled, etc)
	MessageStateConfirmed MessageState = ffEnum("messagestate", "confirmed")
	// MessageStateRejected is a message that has completed confirmation, but has been rejected by FireFly
	MessageStateRejected MessageState = ffEnum("messagestate", "rejected")
)

type MessageType

type MessageType = FFEnum

MessageType is the fundamental type of a message

var (
	// MessageTypeDefinition is a message broadcasting a definition of a system type, pre-defined by firefly (namespaces, members, data definitions, etc.)
	MessageTypeDefinition MessageType = ffEnum("messagetype", "definition")
	// MessageTypeBroadcast is a broadcast message, meaning it is intended to be visible by all parties in the network
	MessageTypeBroadcast MessageType = ffEnum("messagetype", "broadcast")
	// MessageTypePrivate is a private message, meaning it is only sent explicitly to individual parties in the network
	MessageTypePrivate MessageType = ffEnum("messagetype", "private")
	// MessageTypeGroupInit is a special private message that contains the definition of the group
	MessageTypeGroupInit MessageType = ffEnum("messagetype", "groupinit")
	// MessageTypeTransferBroadcast is a broadcast message to accompany/annotate a token transfer
	MessageTypeTransferBroadcast MessageType = ffEnum("messagetype", "transfer_broadcast")
	// MessageTypeTransferPrivate is a private message to accompany/annotate a token transfer
	MessageTypeTransferPrivate MessageType = ffEnum("messagetype", "transfer_private")
)

type Multipart

type Multipart struct {
	Filename string
	Mimetype string
	Data     io.Reader
}

Multipart represents streaming data in a multi-part upload

type Named

type Named interface {
	Name() string
}

type Namespace

type Namespace struct {
	ID          *UUID         `json:"id"`
	Message     *UUID         `json:"message,omitempty"`
	Name        string        `json:"name"`
	Description string        `json:"description"`
	Type        NamespaceType `json:"type" ffenum:"namespacetype"`
	Created     *FFTime       `json:"created"`
}

Namespace is a isolate set of named resources, to allow multiple applications to co-exist in the same network, with the same named objects. Can be used for use case segregation, or multi-tenancy.

func (*Namespace) SetBroadcastMessage

func (ns *Namespace) SetBroadcastMessage(msgID *UUID)

func (*Namespace) Topic

func (ns *Namespace) Topic() string

func (*Namespace) Validate

func (ns *Namespace) Validate(ctx context.Context, existing bool) (err error)

type NamespaceType

type NamespaceType = FFEnum

NamespaceType describes when the namespace was created from local configuration, or broadcast through the network

var (
	// NamespaceTypeLocal is a namespace that only exists because it was defined in the local configuration of the node
	NamespaceTypeLocal NamespaceType = ffEnum("namespacetype", "local")
	// NamespaceTypeBroadcast is a namespace that was broadcast through the network. Broadcast namespaces can overwrite a local namespace
	NamespaceTypeBroadcast NamespaceType = ffEnum("namespacetype", "broadcast")
	// NamespaceTypeSystem is a reserved namespace used by FireFly itself
	NamespaceTypeSystem NamespaceType = ffEnum("namespacetype", "system")
)

type NextPin

type NextPin struct {
	Context  *Bytes32 `json:"context"`
	Identity string   `json:"identity"`
	Hash     *Bytes32 `json:"hash"`
	Nonce    int64    `json:"nonce"`
	Sequence int64    `json:"_"` // Local database sequence used internally for update efficiency
}

type Node

type Node struct {
	ID          *UUID   `json:"id"`
	Message     *UUID   `json:"message,omitempty"`
	Owner       string  `json:"owner,omitempty"`
	Name        string  `json:"name,omitempty"`
	Description string  `json:"description,omitempty"`
	DX          DXInfo  `json:"dx"`
	Created     *FFTime `json:"created,omitempty"`
}

Node is a FireFly node within the network

func (*Node) SetBroadcastMessage

func (n *Node) SetBroadcastMessage(msgID *UUID)

func (*Node) Topic

func (n *Node) Topic() string

func (*Node) Validate

func (n *Node) Validate(ctx context.Context, existing bool) (err error)

type NodeStatus

type NodeStatus struct {
	Node     NodeStatusNode     `json:"node"`
	Org      NodeStatusOrg      `json:"org"`
	Defaults NodeStatusDefaults `json:"defaults"`
}

NodeStatus is a set of information that represents the health, and identity of a node

type NodeStatusDefaults

type NodeStatusDefaults struct {
	Namespace string `json:"namespace"`
}

NodeStatusDefaults is information about core configuration th

type NodeStatusNode

type NodeStatusNode struct {
	Name       string `json:"name"`
	Registered bool   `json:"registered"`
	ID         *UUID  `json:"id,omitempty"`
}

NodeStatusNode is the information about the local node, returned in the node status

type NodeStatusOrg

type NodeStatusOrg struct {
	Name       string `json:"name"`
	Registered bool   `json:"registered"`
	Identity   string `json:"identity,omitempty"`
	ID         *UUID  `json:"id,omitempty"`
}

NodeStatusOrg is the information about the node owning org, returned in the node status

type Nonce

type Nonce struct {
	Context *Bytes32 `json:"hash"`
	Nonce   int64    `json:"nonce"`
	Group   *Bytes32 `json:"group,omitempty"`
	Topic   string   `json:"topic"`
}

Nonce is this local node's state record for the context of a group+topic combination. It records the node's latest allocated sequence number for the context. A context is a hash of a GroupID and a topic, concattenated together

type Offset

type Offset struct {
	Type    OffsetType `json:"type" ffenum:"offsettype"`
	Name    string     `json:"name"`
	Current int64      `json:"current,omitempty"`

	RowID int64 `json:"-"`
}

Offset is a simple stored data structure that records a sequence position within another collection

type OffsetType

type OffsetType = FFEnum
var (
	// OffsetTypeBatch is an offset stored by the batch manager on the messages table
	OffsetTypeBatch OffsetType = ffEnum("offsettype", "batch")
	// OffsetTypeAggregator is an offset stored by the aggregator on the events table
	OffsetTypeAggregator OffsetType = ffEnum("offsettype", "aggregator")
	// OffsetTypeSubscription is an offeset stored by a dispatcher on the events table
	OffsetTypeSubscription OffsetType = ffEnum("offsettype", "subscription")
)

type OpStatus

type OpStatus string

OpStatus is the current status of an operation

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

type OpType

type OpType = FFEnum

OpType describes mechanical steps in the process that have to be performed, might be asynchronous, and have results in the back-end systems that might need to be correlated with messages by operators.

var (
	// OpTypeBlockchainBatchPin is a blockchain transaction to pin a batch
	OpTypeBlockchainBatchPin OpType = ffEnum("optype", "blockchain_batch_pin")
	// OpTypeBlockchainInvoke is a smart contract invoke
	OpTypeBlockchainInvoke OpType = ffEnum("optype", "blockchain_invoke")
	// OpTypePublicStorageBatchBroadcast is a public storage operation to store broadcast data
	OpTypePublicStorageBatchBroadcast OpType = ffEnum("optype", "publicstorage_batch_broadcast")
	// OpTypeDataExchangeBatchSend is a private send
	OpTypeDataExchangeBatchSend OpType = ffEnum("optype", "dataexchange_batch_send")
	// OpTypeDataExchangeBlobSend is a private send
	OpTypeDataExchangeBlobSend OpType = ffEnum("optype", "dataexchange_blob_send")
	// OpTypeTokenCreatePool is a token pool creation
	OpTypeTokenCreatePool OpType = ffEnum("optype", "token_create_pool")
	// OpTypeTokenActivatePool is a token pool activation
	OpTypeTokenActivatePool OpType = ffEnum("optype", "token_activate_pool")
	// OpTypeTokenTransfer is a token transfer
	OpTypeTokenTransfer OpType = ffEnum("optype", "token_transfer")
)

type Operation

type Operation struct {
	ID          *UUID      `json:"id"`
	Namespace   string     `json:"namespace"`
	Transaction *UUID      `json:"tx"`
	Type        OpType     `json:"type" ffenum:"optype"`
	Status      OpStatus   `json:"status"`
	Error       string     `json:"error,omitempty"`
	Plugin      string     `json:"plugin"`
	Input       JSONObject `json:"input,omitempty"`
	Output      JSONObject `json:"output,omitempty"`
	Created     *FFTime    `json:"created,omitempty"`
	Updated     *FFTime    `json:"updated,omitempty"`
}

Operation is a description of an action performed as part of a transaction submitted by this node

func NewOperation added in v0.13.0

func NewOperation(plugin Named, namespace string, tx *UUID, opType OpType) *Operation

NewOperation creates a new operation in a transaction

type Organization

type Organization struct {
	ID          *UUID      `json:"id"`
	Message     *UUID      `json:"message,omitempty"`
	Parent      string     `json:"parent,omitempty"`
	Identity    string     `json:"identity,omitempty"`
	Name        string     `json:"name,omitempty"`
	Description string     `json:"description,omitempty"`
	Profile     JSONObject `json:"profile,omitempty"`
	Created     *FFTime    `json:"created,omitempty"`
}

Organization is a top-level identity in the network

func (*Organization) GetDID

func (org *Organization) GetDID() string

func (*Organization) SetBroadcastMessage

func (org *Organization) SetBroadcastMessage(msgID *UUID)

func (*Organization) Topic

func (org *Organization) Topic() string

func (*Organization) Validate

func (org *Organization) Validate(ctx context.Context, existing bool) (err error)

type Pin

type Pin struct {
	Sequence   int64    `json:"sequence,omitempty"`
	Masked     bool     `json:"masked,omitempty"`
	Hash       *Bytes32 `json:"hash,omitempty"`
	Batch      *UUID    `json:"batch,omitempty"`
	Index      int64    `json:"index,omitempty"`
	Dispatched bool     `json:"dispatched,omitempty"`
	Created    *FFTime  `json:"created,omitempty"`
}

Pin represents a ledger-pinning event that has been detected from the blockchain, in the sequence that it was detected.

A batch contains many messages, and each of those messages can be on a different topic (or topics) All messages on the same topic must be processed in the order that the batch pinning events arrive from the blockchain.

As we need to correlate the on-chain events, with off-chain data that might arrive at a different time (or never), we "park" all pinned sequences first, then only complete them (and generate the associated events) once all the data has been assembled for all messages on that sequence, within that batch.

We might park the pin first (from the blockchain), or park the batch first (if it arrived first off-chain). There's a third part as well that can block a message, which is large blob data moving separately to the batch. If we get the private message, then the batch, before receiving the blob data - we have to upgrade a batch-park, to a pin-park. This is because the sequence must be in the order the pins arrive.

func (*Pin) LocalSequence

func (p *Pin) LocalSequence() int64

type RESTError

type RESTError struct {
	Error string `json:"error"`
}

type SubOptsFirstEvent

type SubOptsFirstEvent string

SubOptsFirstEvent picks the first event that should be dispatched on the subscription, and can be a string containing an exact sequence as well as one of the enum values

const (
	// SubOptsFirstEventOldest indicates all events should be dispatched to the subscription
	SubOptsFirstEventOldest SubOptsFirstEvent = "oldest"
	// SubOptsFirstEventNewest indicates only newly received events should be dispatched to the subscription
	SubOptsFirstEventNewest SubOptsFirstEvent = "newest"
)

type Subscription

type Subscription struct {
	SubscriptionRef

	Transport string              `json:"transport"`
	Filter    SubscriptionFilter  `json:"filter"`
	Options   SubscriptionOptions `json:"options"`
	Ephemeral bool                `json:"ephemeral,omitempty"`
	Created   *FFTime             `json:"created"`
	Updated   *FFTime             `json:"updated"`
}

Subscription is a binding between the stream of events within a namespace, and an event interface - such as an application listening on websockets

type SubscriptionCoreOptions

type SubscriptionCoreOptions struct {
	FirstEvent *SubOptsFirstEvent `json:"firstEvent,omitempty"`
	ReadAhead  *uint16            `json:"readAhead,omitempty"`
	WithData   *bool              `json:"withData,omitempty"`
}

SubscriptionCoreOptions are the core options that apply across all transports

type SubscriptionFilter

type SubscriptionFilter struct {
	Events string `json:"events,omitempty"`
	Topics string `json:"topics,omitempty"`
	Tag    string `json:"tag,omitempty"`
	Group  string `json:"group,omitempty"`
	Author string `json:"author,omitempty"`
}

SubscriptionFilter contains regular expressions to match against events. All must match for an event to be dispatched to a subscription

type SubscriptionOptions

type SubscriptionOptions struct {
	SubscriptionCoreOptions

	// Ephemeral subscriptions only can add this option to enable change events
	ChangeEvents bool `json:"-"`
	// contains filtered or unexported fields
}

SubscriptionOptions cutomize the behavior of subscriptions

func (SubscriptionOptions) MarshalJSON

func (so SubscriptionOptions) MarshalJSON() ([]byte, error)

func (*SubscriptionOptions) Scan

func (so *SubscriptionOptions) Scan(src interface{}) error

Scan implements sql.Scanner

func (*SubscriptionOptions) TransportOptions

func (so *SubscriptionOptions) TransportOptions() JSONObject

func (*SubscriptionOptions) UnmarshalJSON

func (so *SubscriptionOptions) UnmarshalJSON(b []byte) error

func (SubscriptionOptions) Value

func (so SubscriptionOptions) Value() (driver.Value, error)

Value implements sql.Valuer

type SubscriptionRef

type SubscriptionRef struct {
	ID        *UUID  `json:"id"`
	Namespace string `json:"namespace"`
	Name      string `json:"name"`
}

SubscriptionRef are the fields that can be used to refer to a subscription

type SystemTag

type SystemTag string
const (

	// SystemTagDefineDatatype is the topic for messages that broadcast data definitions
	SystemTagDefineDatatype SystemTag = "ff_define_datatype"

	// SystemTagDefineNamespace is the topic for messages that broadcast namespace definitions
	SystemTagDefineNamespace SystemTag = "ff_define_namespace"

	// SystemTagDefineOrganization is the topic for messages that broadcast organization definitions
	SystemTagDefineOrganization SystemTag = "ff_define_organization"

	// SystemTagDefineNode is the topic for messages that broadcast node definitions
	SystemTagDefineNode SystemTag = "ff_define_node"

	// SystemTagDefineGroup is the topic for messages that send the definition of a group, to all parties in that group
	SystemTagDefineGroup SystemTag = "ff_define_group"

	// SystemTagDefinePool is the topic for messages that broadcast data definitions
	SystemTagDefinePool SystemTag = "ff_define_pool"

	// SystemTagDefineFFI is the topic for messages that broadcast contract FFIs
	SystemTagDefineFFI SystemTag = "ff_define_ffi"

	// SystemTagDefineContractAPI is the topic for messages that broadcast contract APIs
	SystemTagDefineContractAPI SystemTag = "ff_define_contract_api"
)

type TokenAccount

type TokenAccount struct {
	Key string `json:"key,omitempty"`
}

Currently these types are just filtered views of TokenBalance. If more fields/aggregation become needed, they might merit a new table in the database.

type TokenAccountPool added in v0.11.0

type TokenAccountPool struct {
	Pool *UUID `json:"pool,omitempty"`
}

type TokenBalance added in v0.11.0

type TokenBalance struct {
	Pool       *UUID    `json:"pool,omitempty"`
	TokenIndex string   `json:"tokenIndex,omitempty"`
	URI        string   `json:"uri,omitempty"`
	Connector  string   `json:"connector,omitempty"`
	Namespace  string   `json:"namespace,omitempty"`
	Key        string   `json:"key,omitempty"`
	Balance    FFBigInt `json:"balance"`
	Updated    *FFTime  `json:"updated,omitempty"`
}

func (*TokenBalance) Identifier added in v0.11.0

func (t *TokenBalance) Identifier() string

type TokenConnector added in v0.11.0

type TokenConnector struct {
	Name string `json:"name,omitempty"`
}

type TokenPool

type TokenPool struct {
	ID         *UUID          `json:"id,omitempty"`
	Type       TokenType      `json:"type" ffenum:"tokentype"`
	Namespace  string         `json:"namespace,omitempty"`
	Name       string         `json:"name,omitempty"`
	Standard   string         `json:"standard,omitempty"`
	ProtocolID string         `json:"protocolId,omitempty"`
	Key        string         `json:"key,omitempty"`
	Symbol     string         `json:"symbol,omitempty"`
	Connector  string         `json:"connector,omitempty"`
	Message    *UUID          `json:"message,omitempty"`
	State      TokenPoolState `json:"state,omitempty" ffenum:"tokenpoolstate"`
	Created    *FFTime        `json:"created,omitempty"`
	Config     JSONObject     `json:"config,omitempty"` // for REST calls only (not stored)
	TX         TransactionRef `json:"tx,omitempty"`
}

func (*TokenPool) Validate

func (t *TokenPool) Validate(ctx context.Context) (err error)

type TokenPoolAnnouncement

type TokenPoolAnnouncement struct {
	Pool  *TokenPool       `json:"pool"`
	Event *BlockchainEvent `json:"event"`
}

func (*TokenPoolAnnouncement) SetBroadcastMessage added in v0.11.0

func (t *TokenPoolAnnouncement) SetBroadcastMessage(msgID *UUID)

func (*TokenPoolAnnouncement) Topic added in v0.11.0

func (t *TokenPoolAnnouncement) Topic() string

type TokenPoolState added in v0.11.0

type TokenPoolState = FFEnum

TokenPoolState is the current confirmation state of a token pool

var (
	// TokenPoolStateUnknown is a token pool that may not yet be activated
	// (should not be used in the code - only set via database migration for previously-created pools)
	TokenPoolStateUnknown TokenPoolState = ffEnum("tokenpoolstate", "unknown")
	// TokenPoolStatePending is a token pool that has been announced but not yet confirmed
	TokenPoolStatePending TokenPoolState = ffEnum("tokenpoolstate", "pending")
	// TokenPoolStateConfirmed is a token pool that has been confirmed on chain
	TokenPoolStateConfirmed TokenPoolState = ffEnum("tokenpoolstate", "confirmed")
)

type TokenTransfer

type TokenTransfer struct {
	Type            TokenTransferType `json:"type" ffenum:"tokentransfertype"`
	LocalID         *UUID             `json:"localId,omitempty"`
	Pool            *UUID             `json:"pool,omitempty"`
	TokenIndex      string            `json:"tokenIndex,omitempty"`
	URI             string            `json:"uri,omitempty"`
	Connector       string            `json:"connector,omitempty"`
	Namespace       string            `json:"namespace,omitempty"`
	Key             string            `json:"key,omitempty"`
	From            string            `json:"from,omitempty"`
	To              string            `json:"to,omitempty"`
	Amount          FFBigInt          `json:"amount"`
	ProtocolID      string            `json:"protocolId,omitempty"`
	Message         *UUID             `json:"message,omitempty"`
	MessageHash     *Bytes32          `json:"messageHash,omitempty"`
	Created         *FFTime           `json:"created,omitempty"`
	TX              TransactionRef    `json:"tx"`
	BlockchainEvent *UUID             `json:"blockchainEvent,omitempty"`
}

type TokenTransferInput added in v0.10.1

type TokenTransferInput struct {
	TokenTransfer
	Message *MessageInOut `json:"message,omitempty"`
	Pool    string        `json:"pool,omitempty"`
}

type TokenTransferType

type TokenTransferType = FFEnum

type TokenType

type TokenType = FFEnum
var (
	TokenTypeFungible    TokenType = ffEnum("tokentype", "fungible")
	TokenTypeNonFungible TokenType = ffEnum("tokentype", "nonfungible")
)
var (
	TokenTransferTypeMint     TokenType = ffEnum("tokentransfertype", "mint")
	TokenTransferTypeBurn     TokenType = ffEnum("tokentransfertype", "burn")
	TokenTransferTypeTransfer TokenType = ffEnum("tokentransfertype", "transfer")
)

type Transaction

type Transaction struct {
	ID            *UUID           `json:"id,omitempty"`
	Namespace     string          `json:"namespace,omitempty"`
	Type          TransactionType `json:"type" ffenum:"txtype"`
	Created       *FFTime         `json:"created"`
	BlockchainIDs FFStringArray   `json:"blockchainIds,omitempty"`
}

Transaction is a unit of work sent or received by this node It serves as a container for one or more Operations, BlockchainEvents, and other related objects

type TransactionRef

type TransactionRef struct {
	Type TransactionType `json:"type"`
	ID   *UUID           `json:"id,omitempty"`
}

TransactionRef refers to a transaction, in other types

type TransactionStatus added in v0.12.0

type TransactionStatus struct {
	Status  OpStatus                    `json:"status"`
	Details []*TransactionStatusDetails `json:"details"`
}

type TransactionStatusDetails added in v0.12.0

type TransactionStatusDetails struct {
	Type      TransactionStatusType `json:"type"`
	SubType   string                `json:"subtype,omitempty"`
	Status    OpStatus              `json:"status"`
	Timestamp *FFTime               `json:"timestamp,omitempty"`
	ID        *UUID                 `json:"id,omitempty"`
	Error     string                `json:"error,omitempty"`
	Info      JSONObject            `json:"info,omitempty"`
}

type TransactionStatusType added in v0.12.0

type TransactionStatusType string
var (
	TransactionStatusTypeOperation       TransactionStatusType = "Operation"
	TransactionStatusTypeBlockchainEvent TransactionStatusType = "BlockchainEvent"
	TransactionStatusTypeBatch           TransactionStatusType = "Batch"
	TransactionStatusTypeTokenPool       TransactionStatusType = "TokenPool"
	TransactionStatusTypeTokenTransfer   TransactionStatusType = "TokenTransfer"
)

type TransactionType

type TransactionType = FFEnum

type TransportPayloadType

type TransportPayloadType = FFEnum
var (
	TransportPayloadTypeMessage TransportPayloadType = ffEnum("transportpayload", "message")
	TransportPayloadTypeBatch   TransportPayloadType = ffEnum("transportpayload", "batch")
)

type TransportStatusUpdate added in v0.12.0

type TransportStatusUpdate struct {
	Error    string     `json:"error,omitempty"`
	Manifest string     `json:"manifest,omitempty"`
	Info     JSONObject `json:"info,omitempty"`
}

type TransportWrapper

type TransportWrapper struct {
	Group *Group `json:"group,omitempty"`
	Batch *Batch `json:"batch,omitempty"`
}

TransportWrapper wraps paylaods over data exchange transfers, for easy deserialization at target

type UUID

type UUID uuid.UUID

UUID is a wrapper on a UUID implementation, ensuring Value handles nil

func MustParseUUID

func MustParseUUID(uuidStr string) *UUID

func NewUUID

func NewUUID() *UUID

func ParseUUID

func ParseUUID(ctx context.Context, uuidStr string) (*UUID, error)

func (*UUID) Equals

func (u *UUID) Equals(u2 *UUID) bool

func (UUID) MarshalBinary

func (u UUID) MarshalBinary() ([]byte, error)

func (UUID) MarshalText

func (u UUID) MarshalText() ([]byte, error)

func (*UUID) Scan

func (u *UUID) Scan(src interface{}) error

func (*UUID) String

func (u *UUID) String() string

func (*UUID) UnmarshalBinary

func (u *UUID) UnmarshalBinary(b []byte) error

func (*UUID) UnmarshalText

func (u *UUID) UnmarshalText(b []byte) error

func (*UUID) Value

func (u *UUID) Value() (driver.Value, error)

type ValidatorType

type ValidatorType = FFEnum
var (
	// ValidatorTypeJSON is the validator type for JSON Schema validation
	ValidatorTypeJSON ValidatorType = ffEnum("validatortype", "json")
	// ValidatorTypeNone explicitly disables validation, even when a datatype is set. Allowing categorization of datatype without validation.
	ValidatorTypeNone ValidatorType = ffEnum("validatortype", "none")
	// ValidatorTypeSystemDefinition is the validator type for system definitions
	ValidatorTypeSystemDefinition ValidatorType = ffEnum("validatortype", "definition")
)

type WSChangeNotification

type WSChangeNotification struct {
	WSClientActionBase

	ChangeEvent *ChangeEvent `json:"change"`
}

WSChangeNotification is a special notification type for a change event, that does *not* require an ack

type WSClientActionAckPayload

type WSClientActionAckPayload struct {
	WSClientActionBase

	ID           *UUID            `json:"id,omitempty"`
	Subscription *SubscriptionRef `json:"subscription,omitempty"`
}

WSClientActionAckPayload acknowldges a received event (not applicable in AutoAck mode)

type WSClientActionBase

type WSClientActionBase struct {
	Type WSClientPayloadType `json:"type,omitempty"`
}

WSClientActionBase is the base fields of all client actions sent on the websocket

type WSClientActionStartPayload

type WSClientActionStartPayload struct {
	WSClientActionBase

	AutoAck      *bool               `json:"autoack"`
	Namespace    string              `json:"namespace"`
	Name         string              `json:"name"`
	Ephemeral    bool                `json:"ephemeral"`
	Filter       SubscriptionFilter  `json:"filter"`
	Options      SubscriptionOptions `json:"options"`
	ChangeEvents string              `json:"changeEvents,omitempty"`
}

WSClientActionStartPayload starts a subscription on this socket - either an existing one, or creating an ephemeral one

type WSClientPayloadType

type WSClientPayloadType = FFEnum

WSClientPayloadType actions go from client->server

var (
	// WSClientActionStart is a request to the server to start delivering messages to the client
	WSClientActionStart WSClientPayloadType = ffEnum("wstype", "start")
	// WSClientActionAck acknowledges an event that was delivered, allowing further messages to be sent
	WSClientActionAck WSClientPayloadType = ffEnum("wstype", "ack")

	// WSProtocolErrorEventType is a special event "type" field for server to send the client, if it performs a ProtocolError
	WSProtocolErrorEventType WSClientPayloadType = ffEnum("wstype", "protocol_error")

	// WSClientActionChangeNotifcation a special event type that is a local database change event, and never requires an ack
	WSClientActionChangeNotifcation WSClientPayloadType = ffEnum("wstype", "change_notification")
)

type WSProtocolErrorPayload

type WSProtocolErrorPayload struct {
	Type  WSClientPayloadType `json:"type" ffenum:"wstype"`
	Error string              `json:"error"`
}

WSProtocolErrorPayload is sent to the client by the server in the case of a protocol error

Jump to

Keyboard shortcuts

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