types

package
v0.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoParent = TokenTypeID(nil)

Functions

func NewP2pkhAuthProofSignature

func NewP2pkhAuthProofSignature(txo *types.TransactionOrder, signer crypto.Signer) ([]byte, error)

NewP2pkhAuthProofSignature creates a standard P2PKH predicate signature for AuthProof.

func NewP2pkhAuthProofSignatureFromKey

func NewP2pkhAuthProofSignatureFromKey(txo *types.TransactionOrder, privKey []byte) ([]byte, error)

NewP2pkhAuthProofSignatureFromKey creates a standard P2PKH predicate signature for AuthProof.

func NewP2pkhFeeProofSignature

func NewP2pkhFeeProofSignature(txo *types.TransactionOrder, signer crypto.Signer) ([]byte, error)

NewP2pkhFeeProofSignature creates a standard P2PKH fee predicate signature for FeeProof.

func NewP2pkhFeeSignatureFromKey

func NewP2pkhFeeSignatureFromKey(txo *types.TransactionOrder, privKey []byte) ([]byte, error)

NewP2pkhFeeSignatureFromKey creates a standard P2PKH fee predicate signature for FeeProof.

func NewP2pkhSignature

func NewP2pkhSignature(signer crypto.Signer, sigBytesFn func() ([]byte, error)) ([]byte, error)

NewP2pkhSignature creates a standard P2PKH predicate signature.

func NewTransactionOrder

func NewTransactionOrder(networkID types.NetworkID, systemID types.SystemID, unitID types.UnitID, txType uint16, attr any, opts ...Option) (*types.TransactionOrder, error)

Types

type Bill

type Bill struct {
	NetworkID  types.NetworkID
	SystemID   types.SystemID
	ID         types.UnitID
	Value      uint64
	LockStatus uint64
	Counter    uint64
}

func (*Bill) Lock

func (b *Bill) Lock(lockStatus uint64, txOptions ...Option) (*types.TransactionOrder, error)

func (*Bill) ReclaimFromFeeCredit

func (b *Bill) ReclaimFromFeeCredit(closeFCProof *types.TxRecordProof, txOptions ...Option) (*types.TransactionOrder, error)

func (*Bill) Split

func (b *Bill) Split(targetUnits []*money.TargetUnit, txOptions ...Option) (*types.TransactionOrder, error)

func (*Bill) SwapWithDustCollector

func (b *Bill) SwapWithDustCollector(transDCProofs []*types.TxRecordProof, txOptions ...Option) (*types.TransactionOrder, error)

func (*Bill) Transfer

func (b *Bill) Transfer(newOwnerPredicate []byte, txOptions ...Option) (*types.TransactionOrder, error)

func (*Bill) TransferToDustCollector

func (b *Bill) TransferToDustCollector(targetBill *Bill, txOptions ...Option) (*types.TransactionOrder, error)

func (*Bill) TransferToFeeCredit

func (b *Bill) TransferToFeeCredit(fcr *FeeCreditRecord, amount uint64, latestAdditionTime uint64, txOptions ...Option) (*types.TransactionOrder, error)

func (*Bill) Unlock

func (b *Bill) Unlock(txOptions ...Option) (*types.TransactionOrder, error)

type FeeCreditRecord

type FeeCreditRecord struct {
	NetworkID  types.NetworkID
	SystemID   types.SystemID
	ID         types.UnitID
	Balance    uint64
	Timeout    uint64
	LockStatus uint64
	Counter    *uint64
}

func (*FeeCreditRecord) AddFeeCredit

func (f *FeeCreditRecord) AddFeeCredit(ownerPredicate []byte, transFCProof *types.TxRecordProof, txOptions ...Option) (*types.TransactionOrder, error)

func (*FeeCreditRecord) CloseFeeCredit

func (f *FeeCreditRecord) CloseFeeCredit(targetBillID types.UnitID, targetBillCounter uint64, txOptions ...Option) (*types.TransactionOrder, error)

func (*FeeCreditRecord) DeleteFeeCredit

func (f *FeeCreditRecord) DeleteFeeCredit(txOptions ...Option) (*types.TransactionOrder, error)

func (*FeeCreditRecord) Lock

func (f *FeeCreditRecord) Lock(lockStatus uint64, txOptions ...Option) (*types.TransactionOrder, error)

func (*FeeCreditRecord) SetFeeCredit

func (f *FeeCreditRecord) SetFeeCredit(ownerPredicate []byte, amount uint64, txOptions ...Option) (*types.TransactionOrder, error)

func (*FeeCreditRecord) Unlock

func (f *FeeCreditRecord) Unlock(txOptions ...Option) (*types.TransactionOrder, error)

type FungibleToken

type FungibleToken struct {
	NetworkID      types.NetworkID
	SystemID       types.SystemID
	ID             TokenID
	Symbol         string
	TypeID         TokenTypeID
	TypeName       string
	OwnerPredicate []byte // TODO: could use sdktypes.Predicate?
	Counter        uint64
	LockStatus     uint64
	Amount         uint64
	DecimalPlaces  uint32
	Burned         bool
}

func (*FungibleToken) Burn

func (t *FungibleToken) Burn(targetTokenID types.UnitID, targetTokenCounter uint64, txOptions ...Option) (*types.TransactionOrder, error)

func (*FungibleToken) GetID

func (t *FungibleToken) GetID() TokenID

func (*FungibleToken) GetLockStatus

func (t *FungibleToken) GetLockStatus() uint64

func (*FungibleToken) GetOwnerPredicate

func (t *FungibleToken) GetOwnerPredicate() Predicate

func (*FungibleToken) Join

func (t *FungibleToken) Join(burnTxProofs []*types.TxRecordProof, txOptions ...Option) (*types.TransactionOrder, error)

func (*FungibleToken) Lock

func (t *FungibleToken) Lock(lockStatus uint64, txOptions ...Option) (*types.TransactionOrder, error)

func (*FungibleToken) Mint

func (t *FungibleToken) Mint(txOptions ...Option) (*types.TransactionOrder, error)

func (*FungibleToken) Split

func (t *FungibleToken) Split(amount uint64, ownerPredicate []byte, txOptions ...Option) (*types.TransactionOrder, error)

func (*FungibleToken) Transfer

func (t *FungibleToken) Transfer(ownerPredicate []byte, txOptions ...Option) (*types.TransactionOrder, error)

func (*FungibleToken) Unlock

func (t *FungibleToken) Unlock(txOptions ...Option) (*types.TransactionOrder, error)

type FungibleTokenType

type FungibleTokenType struct {
	NetworkID                types.NetworkID
	SystemID                 types.SystemID
	ID                       TokenTypeID
	ParentTypeID             TokenTypeID
	Symbol                   string
	Name                     string
	Icon                     *tokens.Icon
	SubTypeCreationPredicate Predicate
	TokenMintingPredicate    Predicate
	TokenTypeOwnerPredicate  Predicate
	DecimalPlaces            uint32
}

func (*FungibleTokenType) Define

func (tt *FungibleTokenType) Define(txOptions ...Option) (*types.TransactionOrder, error)

type MoneyPartitionClient

type MoneyPartitionClient interface {
	PartitionClient

	GetBill(ctx context.Context, unitID types.UnitID) (*Bill, error)
	GetBills(ctx context.Context, ownerID []byte) ([]*Bill, error)
}

type MoneyTxSigner

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

MoneyTxSigner helper struct to generate standard transaction signatures.

func NewMoneyTxSigner

func NewMoneyTxSigner(signer abcrypto.Signer) (*MoneyTxSigner, error)

func NewMoneyTxSignerFromKey

func NewMoneyTxSignerFromKey(privKey []byte) (*MoneyTxSigner, error)

func (*MoneyTxSigner) AddAuthProof

func (s *MoneyTxSigner) AddAuthProof(tx *types.TransactionOrder) error

func (*MoneyTxSigner) AddFeeProof

func (s *MoneyTxSigner) AddFeeProof(tx *types.TransactionOrder) error

func (*MoneyTxSigner) SignTx

func (s *MoneyTxSigner) SignTx(tx *types.TransactionOrder) error

SignTx generates transaction specific P2PKH AuthProof and FeeProof.

type NodeInfoResponse

type NodeInfoResponse struct {
	NetworkID           types.NetworkID `json:"networkId"` // hex encoded network identifier
	SystemID            types.SystemID  `json:"systemId"`  // hex encoded system identifier
	Name                string          `json:"name"`      // one of [money node | tokens node | evm node]
	Self                PeerInfo        `json:"self"`      // information about this peer
	BootstrapNodes      []PeerInfo      `json:"bootstrapNodes"`
	RootValidators      []PeerInfo      `json:"rootValidators"`
	PartitionValidators []PeerInfo      `json:"partitionValidators"`
	OpenConnections     []PeerInfo      `json:"openConnections"` // all libp2p connections to other peers in the network
}

type NonFungibleToken

type NonFungibleToken struct {
	NetworkID           types.NetworkID
	SystemID            types.SystemID
	ID                  TokenID
	Symbol              string
	TypeID              TokenTypeID
	TypeName            string
	OwnerPredicate      []byte // TODO: could use sdktypes.Predicate?
	Counter             uint64
	LockStatus          uint64
	Name                string
	URI                 string
	Data                []byte
	DataUpdatePredicate Predicate
}

func (*NonFungibleToken) GetID

func (t *NonFungibleToken) GetID() TokenID

func (*NonFungibleToken) GetLockStatus

func (t *NonFungibleToken) GetLockStatus() uint64

func (*NonFungibleToken) GetOwnerPredicate

func (t *NonFungibleToken) GetOwnerPredicate() Predicate

func (*NonFungibleToken) Lock

func (t *NonFungibleToken) Lock(lockStatus uint64, txOptions ...Option) (*types.TransactionOrder, error)

func (*NonFungibleToken) Mint

func (t *NonFungibleToken) Mint(txOptions ...Option) (*types.TransactionOrder, error)

func (*NonFungibleToken) Transfer

func (t *NonFungibleToken) Transfer(ownerPredicate []byte, txOptions ...Option) (*types.TransactionOrder, error)

func (*NonFungibleToken) Unlock

func (t *NonFungibleToken) Unlock(txOptions ...Option) (*types.TransactionOrder, error)

func (*NonFungibleToken) Update

func (t *NonFungibleToken) Update(data []byte, txOptions ...Option) (*types.TransactionOrder, error)

type NonFungibleTokenType

type NonFungibleTokenType struct {
	NetworkID                types.NetworkID
	SystemID                 types.SystemID
	ID                       TokenTypeID
	ParentTypeID             TokenTypeID
	Symbol                   string
	Name                     string
	Icon                     *tokens.Icon
	SubTypeCreationPredicate Predicate
	TokenMintingPredicate    Predicate
	TokenTypeOwnerPredicate  Predicate
	DataUpdatePredicate      Predicate
}

func (*NonFungibleTokenType) Define

func (tt *NonFungibleTokenType) Define(txOptions ...Option) (*types.TransactionOrder, error)

type Option

type Option func(*Options)

func WithFeeCreditRecordID

func WithFeeCreditRecordID(feeCreditRecordID types.UnitID) Option

func WithMaxFee

func WithMaxFee(maxFee uint64) Option

func WithReferenceNumber

func WithReferenceNumber(referenceNumber []byte) Option

func WithTimeout

func WithTimeout(timeout uint64) Option

type Options

type Options struct {
	Timeout           uint64
	FeeCreditRecordID types.UnitID
	MaxFee            uint64
	ReferenceNumber   []byte
}

func OptionsWithDefaults

func OptionsWithDefaults(txOptions []Option) *Options

type PartitionClient

type PartitionClient interface {
	GetNodeInfo(ctx context.Context) (*NodeInfoResponse, error)
	GetRoundNumber(ctx context.Context) (uint64, error)
	SendTransaction(ctx context.Context, tx *types.TransactionOrder) ([]byte, error)
	ConfirmTransaction(ctx context.Context, tx *types.TransactionOrder, log *slog.Logger) (*types.TxRecordProof, error)
	GetTransactionProof(ctx context.Context, txHash types.Bytes) (*types.TxRecordProof, error)
	GetFeeCreditRecordByOwnerID(ctx context.Context, ownerID []byte) (*FeeCreditRecord, error)
	Close()
}

type PeerInfo

type PeerInfo struct {
	Identifier string   `json:"identifier"`
	Addresses  []string `json:"addresses"`
}

type Predicate

type Predicate []byte

type PubKey

type PubKey []byte

func (PubKey) Hash

func (pk PubKey) Hash() PubKeyHash

type PubKeyHash

type PubKeyHash []byte

type TokenID

type TokenID = types.UnitID

type TokenTypeID

type TokenTypeID = types.UnitID

type TokensPartitionClient

type TokensPartitionClient interface {
	PartitionClient

	GetFungibleToken(ctx context.Context, id TokenID) (*FungibleToken, error)
	GetFungibleTokens(ctx context.Context, ownerID []byte) ([]*FungibleToken, error)
	GetFungibleTokenTypes(ctx context.Context, creator PubKey) ([]*FungibleTokenType, error)
	GetFungibleTokenTypeHierarchy(ctx context.Context, typeID TokenTypeID) ([]*FungibleTokenType, error)

	GetNonFungibleToken(ctx context.Context, id TokenID) (*NonFungibleToken, error)
	GetNonFungibleTokens(ctx context.Context, ownerID []byte) ([]*NonFungibleToken, error)
	GetNonFungibleTokenTypes(ctx context.Context, creator PubKey) ([]*NonFungibleTokenType, error)
	GetNonFungibleTokenTypeHierarchy(ctx context.Context, typeID TokenTypeID) ([]*NonFungibleTokenType, error)
}

type TransactionRecordAndProof

type TransactionRecordAndProof struct {
	TxRecordProof types.Bytes `json:"txRecordProof"`
}

func (*TransactionRecordAndProof) ToBaseType

func (t *TransactionRecordAndProof) ToBaseType() (*types.TxRecordProof, error)

type TxHash

type TxHash []byte

type Unit

type Unit[T any] struct {
	NetworkID  types.NetworkID       `json:"networkId"`
	SystemID   types.SystemID        `json:"systemId"`
	UnitID     types.UnitID          `json:"unitId"`
	Data       T                     `json:"data"`
	StateProof *types.UnitStateProof `json:"stateProof,omitempty"`
}

Jump to

Keyboard shortcuts

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