types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// WaitForTx waits for the transaction to be mined by TSN
	WaitForTx(ctx context.Context, txHash transactions.TxHash, interval time.Duration) (*transactions.TcTxQueryResponse, error)
	// GetKwilClient returns the kwil client used by the client
	GetKwilClient() *kwilClientPkg.Client
	// DeployStream deploys a new stream
	DeployStream(ctx context.Context, streamId util.StreamId, streamType StreamType) (transactions.TxHash, error)
	// DestroyStream destroys a stream
	DestroyStream(ctx context.Context, streamId util.StreamId) (transactions.TxHash, error)
	// LoadStream loads a already deployed stream, permitting its API usage
	LoadStream(stream StreamLocator) (IStream, error)
	// LoadPrimitiveStream loads a already deployed primitive stream, permitting its API usage
	LoadPrimitiveStream(stream StreamLocator) (IPrimitiveStream, error)
	// LoadComposedStream loads a already deployed composed stream, permitting its API usage
	LoadComposedStream(stream StreamLocator) (IComposedStream, error)
	/*
	 * utils for the client
	 */
	// Create a new stream locator
	OwnStreamLocator(streamId util.StreamId) StreamLocator
	// Address of the signer used by the client
	Address() util.EthereumAddress
}

type DescribeTaxonomiesParams

type DescribeTaxonomiesParams struct {
	// LatestVersion if true, will return the latest version of the taxonomy only
	LatestVersion bool
}

type GetIndexInput

type GetIndexInput = GetRecordInput

type GetRecordInput

type GetRecordInput struct {
	DateFrom *civil.Date
	DateTo   *civil.Date
	FrozenAt *time.Time
}

type IComposedStream

type IComposedStream interface {
	// IStream methods are also available in IPrimitiveStream
	IStream
	// DescribeTaxonomies returns the taxonomy of the stream
	DescribeTaxonomies(ctx context.Context, params DescribeTaxonomiesParams) ([]TaxonomyItem, error)
	// SetTaxonomy sets the taxonomy of the stream
	SetTaxonomy(ctx context.Context, taxonomies []TaxonomyItem) (transactions.TxHash, error)
}

type IPrimitiveStream

type IPrimitiveStream interface {
	// IStream methods are also available in IPrimitiveStream
	IStream
	// InsertRecords inserts records into the stream
	InsertRecords(ctx context.Context, inputs []InsertRecordInput) (transactions.TxHash, error)
}

type IStream

type IStream interface {
	// InitializeStream initializes the stream. Majority of other methods need the stream to be initialized
	InitializeStream(ctx context.Context) (transactions.TxHash, error)
	// GetRecord reads the records of the stream within the given date range
	GetRecord(ctx context.Context, input GetRecordInput) ([]StreamRecord, error)
	// GetIndex reads the index of the stream within the given date range
	GetIndex(ctx context.Context, input GetIndexInput) ([]StreamIndex, error)

	// SetReadVisibility sets the read visibility of the stream -- Private or Public
	SetReadVisibility(ctx context.Context, visibility util.VisibilityEnum) (transactions.TxHash, error)
	// GetReadVisibility gets the read visibility of the stream -- Private or Public
	GetReadVisibility(ctx context.Context) (*util.VisibilityEnum, error)
	// SetComposeVisibility sets the compose visibility of the stream -- Private or Public
	SetComposeVisibility(ctx context.Context, visibility util.VisibilityEnum) (transactions.TxHash, error)
	// GetComposeVisibility gets the compose visibility of the stream -- Private or Public
	GetComposeVisibility(ctx context.Context) (*util.VisibilityEnum, error)

	// AllowReadWallet allows a wallet to read the stream, if reading is private
	AllowReadWallet(ctx context.Context, wallet util.EthereumAddress) (transactions.TxHash, error)
	// DisableReadWallet disables a wallet from reading the stream
	DisableReadWallet(ctx context.Context, wallet util.EthereumAddress) (transactions.TxHash, error)
	// AllowComposeStream allows a stream to use this stream as child, if composing is private
	AllowComposeStream(ctx context.Context, locator StreamLocator) (transactions.TxHash, error)
	// DisableComposeStream disables a stream from using this stream as child
	DisableComposeStream(ctx context.Context, locator StreamLocator) (transactions.TxHash, error)

	// GetAllowedReadWallets gets the wallets allowed to read the stream
	GetAllowedReadWallets(ctx context.Context) ([]util.EthereumAddress, error)
	// GetAllowedComposeStreams gets the streams allowed to compose this stream
	GetAllowedComposeStreams(ctx context.Context) ([]StreamLocator, error)
}

type InsertRecordInput

type InsertRecordInput struct {
	DateValue civil.Date
	Value     int
}

type MetadataKey

type MetadataKey string
const (
	ReadonlyKey           MetadataKey = "readonly_key"
	StreamOwner           MetadataKey = "stream_owner"
	TypeKey               MetadataKey = "type"
	ComposeVisibilityKey  MetadataKey = "compose_visibility"
	ReadVisibilityKey     MetadataKey = "read_visibility"
	AllowReadWalletKey    MetadataKey = "allow_read_wallet"
	AllowComposeStreamKey MetadataKey = "allow_compose_stream"
)

func (MetadataKey) GetType

func (s MetadataKey) GetType() MetadataType

func (MetadataKey) String

func (s MetadataKey) String() string

type MetadataType

type MetadataType string
const (
	MetadataTypeInt    MetadataType = "int"
	MetadataTypeBool   MetadataType = "bool"
	MetadataTypeFloat  MetadataType = "float"
	MetadataTypeString MetadataType = "string"
	MetadataTypeRef    MetadataType = "ref"
)

func (MetadataType) StringFromValue

func (s MetadataType) StringFromValue(valueObj MetadataValue) (string, error)

type MetadataValue

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

func NewMetadataValue

func NewMetadataValue[T string | int | bool | float64 | MetadataValue](value T) MetadataValue

type StreamIndex

type StreamIndex = StreamRecord

type StreamLocator

type StreamLocator struct {
	// StreamId is the unique identifier of the stream, used as name of the deployed contract
	StreamId util.StreamId
	// DataProvider is the address of the data provider, it's the deployer of the stream
	DataProvider util.EthereumAddress
}

StreamLocator is a struct that contains the StreamId and the DataProvider

type StreamRecord

type StreamRecord struct {
	DateValue civil.Date
	Value     apd.Decimal
}

type StreamType

type StreamType string
const (
	StreamTypeComposed  StreamType = "composed"
	StreamTypePrimitive StreamType = "primitive"
)

type TaxonomyItem

type TaxonomyItem struct {
	ChildStream StreamLocator
	Weight      float64
}

Jump to

Keyboard shortcuts

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