entity

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const RFC3339MicroZeroPadded = "2006-01-02T15:04:05.000000Z07:00"

Variables

Functions

func GetTxDataStateBytes

func GetTxDataStateBytes(chainId string, nonceTime Time, txData TxData) []byte

GetTxDataStateBytes returns the sorted and marshaled json representation of a TxData ready to be signed.

Types

type HexBytes added in v1.3.0

type HexBytes []byte

HexBytes allows to json marshal/unmarshal a byte array into an hex encoded string.

func (HexBytes) MarshalJSON added in v1.3.0

func (hb HexBytes) MarshalJSON() ([]byte, error)

MarshalJSON encodes a byte array to an hex string.

func (HexBytes) String added in v1.3.0

func (hb HexBytes) String() string

String returns the hex string representation of a byte array.

func (*HexBytes) UnmarshalJSON added in v1.3.0

func (hb *HexBytes) UnmarshalJSON(data []byte) error

UnmarshalJSON converts an hex encoded string into a byte array.

type Time

type Time struct {
	time.Time
}

Time is a time.Time wrapper.

func GetCurrentTime added in v1.1.0

func GetCurrentTime() Time

GetCurrentTime returns a well formatted custom time.Now()

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON converts a Time into a time.Time and marshals its UTC value with a microseconds precision.

type Tx

type Tx struct {
	// To avoid replay attack, this value is checked in the replay protector.
	NonceTime Time `json:"nonce_time" validate:"required"`

	// Transaction data, this value is handled by the application.
	Data TxData `json:"data" validate:"required"`

	// Transaction signer and signature info to identify the sender.
	SignerFqId string            `json:"signer_fqid" validate:"required,fqid"`
	Signature  ed25519.Signature `json:"signature" validate:"required,len=64"`
}

Tx wraps a TxData with its signature, its signer id and a nonce time.

func (Tx) MarshalJSON

func (a Tx) MarshalJSON() ([]byte, error)

MarshalJSON encodes a Tx to add the TxData type information.

func (*Tx) UnmarshalJSON

func (a *Tx) UnmarshalJSON(data []byte) error

UnmarshalJSON converts an encoded Tx and create the concrete TxData according to its type information.

type TxAlias

type TxAlias Tx

TxAlias is useful to avoid triggering the custom Tx MarshalJSON method.

type TxData

type TxData interface {
	// To fetch all the entity state ids a TxData can create/update/delete.
	// This is also used to index Txs.
	GetStateIds(signerCompanyBcId string) map[string]string

	// To identify which plugin should handle this TxData.
	GetNamespace() string

	// To identify its subtype.
	GetType() string
}

TxData interface defines the methods a concrete TxData must implement.

func UnmarshalTxData added in v1.3.10

func UnmarshalTxData(txDataWrapper *serializer.UnmarshalWrapper) (TxData, error)

UnmarshalTxData accepts a wrapper and tries to unmarshal its value according to its string type.

type TxSigner added in v1.3.0

type TxSigner struct {
	FqId       string
	PrivateKey *ed25519.PrivateKey
}

TxSigner contains all information about a Tx signer.

func NewTxSigner added in v1.3.0

func NewTxSigner(fqId string, privateKey *ed25519.PrivateKey) *TxSigner

TxSigner constructor.

type UnknownTxData added in v1.3.9

type UnknownTxData struct {
	Type string `json:"-"`
	json.RawMessage
}

UnknownTxData is useful to unmarshal and marshal back a tx data of unknown type.

func (UnknownTxData) GetNamespace added in v1.3.9

func (utd UnknownTxData) GetNamespace() string

func (UnknownTxData) GetStateIds added in v1.3.9

func (utd UnknownTxData) GetStateIds(signerCompanyBcId string) map[string]string

func (UnknownTxData) GetType added in v1.3.9

func (utd UnknownTxData) GetType() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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