encoder

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthProof

type AuthProof func(txo *types.TransactionOrder) ([]byte, error)

returns authorization proof (aka OwnerProof) of the txo.

type PartitionTxType

type PartitionTxType struct {
	Partition types.PartitionID
	TxType    uint16 // tx type id
}

type TVEnc

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

TVEnc is an encoder for serializing data info format which can be parsed by Unicity Rust predicate SDK.

Encodes simple data as {type id; data} pairs, to encode more complex data structures additional "tag" can be assigned to each "data record" (see EncodeTagged method).

func (*TVEnc) Bytes

func (enc *TVEnc) Bytes() ([]byte, error)

Bytes returns the serialized representation of the data so far and error if any happened during encoding. Buffer is not reset!

func (*TVEnc) Encode

func (enc *TVEnc) Encode(item any)

func (*TVEnc) EncodeTagged

func (enc *TVEnc) EncodeTagged(tag Tag, item any)

func (*TVEnc) WriteBytes

func (enc *TVEnc) WriteBytes(value []byte)

func (*TVEnc) WriteString

func (enc *TVEnc) WriteString(value string)

func (*TVEnc) WriteUInt32

func (enc *TVEnc) WriteUInt32(value uint32)

func (*TVEnc) WriteUInt64

func (enc *TVEnc) WriteUInt64(value uint64)

type TXSystemEncoder

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

TXSystemEncoder is "generic" tx system encoder, parts specific to given tx system (which wants to use it with Wazero WASM predicates) must be added using Register*Encoder methods.

func New

func New(partition types.PartitionID, f ...any) (TXSystemEncoder, error)

func (TXSystemEncoder) AuthProof

func (enc TXSystemEncoder) AuthProof(txo *types.TransactionOrder) ([]byte, error)

func (TXSystemEncoder) Encode

func (enc TXSystemEncoder) Encode(obj any, ver uint32, getHandle func(obj any) uint32) ([]byte, error)

Encode serializes well known types (not tx system specific) to representation WASM predicate SDK can load.

  • obj: data to serialize, must be of "well known type";
  • ver: version of the encoding/object the predicate expects;
  • getHandle: callback to register variable in the execution context, returns handle of the new variable. Ie instead of "flattening" sub-object it can be registered and it's handle returned as part of response allowing predicate to load the sub-object with next call.

func (*TXSystemEncoder) RegisterAttrEncoder

func (enc *TXSystemEncoder) RegisterAttrEncoder(id PartitionTxType, encoder TxAttributesEncoder) error

RegisterAttrEncoder registers tx attribute encoder.

func (*TXSystemEncoder) RegisterAuthProof

func (enc *TXSystemEncoder) RegisterAuthProof(id PartitionTxType, handler AuthProof) error

func (*TXSystemEncoder) RegisterTxAttributeEncoders

func (enc *TXSystemEncoder) RegisterTxAttributeEncoders(reg func(func(id PartitionTxType, enc TxAttributesEncoder) error) error, filter func(PartitionTxType) bool) error

RegisterTxAttributeEncoders is like RegisterAttrEncoder but allows to filter out undesired encoders.

  • reg: func which attempts to register "all" encoders but for each "filter" is executed and only these for which filter returned true actual registration is attempted.

func (*TXSystemEncoder) RegisterUnitDataEncoder

func (enc *TXSystemEncoder) RegisterUnitDataEncoder(ud any, encoder UnitDataEncoder) error

func (TXSystemEncoder) TxAttributes

func (enc TXSystemEncoder) TxAttributes(txo *types.TransactionOrder, ver uint32) ([]byte, error)

func (TXSystemEncoder) UnitData

func (enc TXSystemEncoder) UnitData(unit state.Unit, ver uint32) ([]byte, error)

type Tag

type Tag = uint8

type TxAttributesEncoder

type TxAttributesEncoder func(txo *types.TransactionOrder, ver uint32) ([]byte, error)

returns tx order attributes encoded to WASM representation

type UnitDataEncoder

type UnitDataEncoder func(data types.UnitData, ver uint32) ([]byte, error)

returns unit data encoded to WASM representation

Jump to

Keyboard shortcuts

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