ld

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxBlockTxsSize = 10000
)
View Source
const MaxKeepers = 64
View Source
const MaxSendOutputs = 1024

MaxSendOutputs is the maximum number of SendOutput that can be included in TransferMultiple tx. Recommend 2 ~ 100 for gas cost performance.

Variables

View Source
var (
	// AAAAAAAAAAAAAAAAAAAAAAAAAADzaDye
	RawModelID = ids.EmptyModelID
	// AAAAAAAAAAAAAAAAAAAAAAAAAAGIYKah
	CBORModelID = ids.ModelID{
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
	}
	// AAAAAAAAAAAAAAAAAAAAAAAAAALZFhrw
	JSONModelID = ids.ModelID{
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
	}
)
View Source
var EthSigner = types.NewLondonSigner(big.NewInt(2357))
View Source
var ModelNameReg = regexp.MustCompile(`^[A-Z][0-9A-Za-z]{1,127}$`)
View Source
var ModelTxTypes = TxTypes{
	TypeUpdateModelInfo,
}

TxTypes set

Functions

func Copy

func Copy(dst, src Copier) error

func FromEthBalance

func FromEthBalance(amount *big.Int) *big.Int

func MustMarshal

func MustMarshal(v Marshaler) []byte

func Recover

func Recover(errp erring.ErrPrefix, fn func() error) (err error)

func SetChainID

func SetChainID(id uint64)

SetChainID will be set when VM.Initialize

func ToEthBalance

func ToEthBalance(amount *big.Int) *big.Int

Types

type Account

type Account struct {
	Type AccountType `cbor:"t" json:"type"`
	// Nonce should increase 1 when sender issuing tx, but not increase when receiving
	Nonce uint64 `cbor:"n" json:"nonce"`
	// the decimals is 9, the smallest unit "NanoLDC" equal to gwei.
	Balance *big.Int `cbor:"b" json:"balance"`
	// M of N threshold signatures, aka MultiSig: threshold is m, keepers length is n.
	// The minimum value is 1, the maximum value is len(keepers)
	Threshold uint16 `cbor:"th" json:"threshold"`
	// keepers who can use this account, no more than 64
	// the account id must be one of them.
	Keepers     signer.Keys         `cbor:"kp" json:"keepers"`
	Tokens      map[string]*big.Int `cbor:"tk" json:"tokens"`
	NonceTable  map[uint64][]uint64 `cbor:"nt" json:"nonceTable"` // map[expire][]nonce
	Approver    signer.Key          `cbor:"ap,omitempty" json:"approver,omitempty"`
	ApproveList TxTypes             `cbor:"apl,omitempty" json:"approveList,omitempty"`
	// MaxTotalSupply only used with TokenAccount
	MaxTotalSupply *big.Int       `cbor:"mts,omitempty" json:"maxTotalSupply,omitempty"`
	Stake          *StakeConfig   `cbor:"st,omitempty" json:"stake,omitempty"`
	Lending        *LendingConfig `cbor:"le,omitempty" json:"lending,omitempty"`

	// external assignment fields
	Height    uint64      `cbor:"-" json:"height"`    // block's timestamp
	Timestamp uint64      `cbor:"-" json:"timestamp"` // block's timestamp
	ID        ids.Address `cbor:"-" json:"address"`
	// contains filtered or unexported fields
}

func (*Account) Bytes

func (a *Account) Bytes() []byte

func (*Account) CheckAsFrom added in v0.0.2

func (a *Account) CheckAsFrom(txType TxType) error

func (*Account) CheckAsTo added in v0.0.2

func (a *Account) CheckAsTo(txType TxType) error

func (*Account) Marshal

func (a *Account) Marshal() ([]byte, error)

func (*Account) SyntacticVerify

func (a *Account) SyntacticVerify() error

SyntacticVerify verifies that a *Account is well-formed.

func (*Account) Unmarshal

func (a *Account) Unmarshal(data []byte) error

func (*Account) Verify

func (a *Account) Verify(digestHash []byte, sigs signer.Sigs, accountKey signer.Key) bool

func (*Account) VerifyPlus

func (a *Account) VerifyPlus(digestHash []byte, sigs signer.Sigs, accountKey signer.Key) bool

type AccountLedger

type AccountLedger struct {
	Lending map[string]*LendingEntry `cbor:"l"`
	Stake   map[string]*StakeEntry   `cbor:"s"`
	// contains filtered or unexported fields
}

func (*AccountLedger) Bytes

func (a *AccountLedger) Bytes() []byte

func (*AccountLedger) Marshal

func (a *AccountLedger) Marshal() ([]byte, error)

func (*AccountLedger) SyntacticVerify

func (a *AccountLedger) SyntacticVerify() error

SyntacticVerify verifies that a *AccountLedger is well-formed.

func (*AccountLedger) Unmarshal

func (a *AccountLedger) Unmarshal(data []byte) error

type AccountType

type AccountType uint16

AccountType is an uint16 representing the type of account

const (
	NativeAccount AccountType = iota
	TokenAccount              // The first byte of account address must be $
	StakeAccount              // The first byte of account address must be #
)

func (AccountType) MarshalJSON

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

func (AccountType) String

func (t AccountType) String() string

type Block

type Block struct {
	Parent    ids.ID32 `cbor:"p" json:"parent"` // The genesis block's parent ID is ids.Empty.
	State     ids.ID32 `cbor:"s" json:"state"`
	PCHeight  uint64   `cbor:"ph" json:"pChainHeight"` // AVAX P Chain Height
	Height    uint64   `cbor:"h" json:"height"`        // The genesis block is at 0.
	Timestamp uint64   `cbor:"ts" json:"timestamp"`    // The genesis block is at 0.
	Gas       uint64   `cbor:"g" json:"gas"`           // This block's total gas units.
	GasPrice  uint64   `cbor:"gp" json:"gasPrice"`     // This block's gas price
	// Gas rebate rate received by this block's miners, 0 ~ 1000, equal to 0~10 times.
	GasRebateRate uint64 `cbor:"gr" json:"gasRebateRate"`
	// The address of validator (convert to valid StakeAccount) who build this block.
	// All tips and 20% of total gas rebate are distributed to this stakeAccount.
	// Total gas rebate = Gas * GasRebateRate * GasPrice / 100
	Builder ids.Address `cbor:"b" json:"builder"`
	// All validators (convert to valid StakeAccounts), sorted by Stake Balance.
	// 80% of total gas rebate are distributed to these stakeAccounts
	Validators ids.IDList[ids.StakeSymbol] `cbor:"vs" json:"validators"`
	Txs        ids.IDList[ids.ID32]        `cbor:"txs" json:"txs"`

	// external assignment fields
	ID ids.ID32 `cbor:"-" json:"id"`
	// contains filtered or unexported fields
}

func (*Block) Bytes

func (b *Block) Bytes() []byte

func (*Block) Marshal

func (b *Block) Marshal() ([]byte, error)

func (*Block) SyntacticVerify

func (b *Block) SyntacticVerify() error

SyntacticVerify verifies that a *Block is well-formed.

func (*Block) Unmarshal

func (b *Block) Unmarshal(data []byte) error

type Copier

type Copier interface {
	Marshal() ([]byte, error)
	Unmarshal([]byte) error
	SyntacticVerify() error
}

type DataInfo

type DataInfo struct {
	ModelID ids.ModelID `cbor:"m" json:"mid"` // model id
	// data version,the initial value is 1, should increase 1 when updating,
	// 0 indicates that the data is invalid, for example, deleted or punished.
	Version uint64 `cbor:"v" json:"version"`
	// MultiSig: m of n, threshold is m, keepers length is n.
	// The minimum value is 0, means no one can update the data.
	// the maximum value is len(keepers)
	Threshold uint16 `cbor:"th" json:"threshold"`
	// keepers who owned this data, no more than 64
	Keepers     signer.Keys      `cbor:"kp" json:"keepers"`
	Approver    signer.Key       `cbor:"ap" json:"approver,omitempty"`
	ApproveList TxTypes          `cbor:"apl" json:"approveList,omitempty"`
	Payload     encoding.RawData `cbor:"pl" json:"payload"`
	// data signature claims
	SigClaims *SigClaims `cbor:"sc,omitempty" json:"sigClaims,omitempty"`
	// data signature signing by a certificate authority
	Sig *signer.Sig `cbor:"s,omitempty" json:"sig,omitempty"`

	// external assignment fields
	ID ids.DataID `cbor:"-" json:"id"`
	// contains filtered or unexported fields
}

func (*DataInfo) Bytes

func (t *DataInfo) Bytes() []byte

func (*DataInfo) Clone

func (t *DataInfo) Clone() *DataInfo

func (*DataInfo) MarkDeleted

func (t *DataInfo) MarkDeleted(data []byte) error

func (*DataInfo) Marshal

func (t *DataInfo) Marshal() ([]byte, error)

func (*DataInfo) Patch

func (t *DataInfo) Patch(operations []byte) ([]byte, error)

Patch applies a patch to the data, returns the patched data. It will not change the data.

func (*DataInfo) SyntacticVerify

func (t *DataInfo) SyntacticVerify() error

SyntacticVerify verifies that a *DataInfo is well-formed.

func (*DataInfo) Unmarshal

func (t *DataInfo) Unmarshal(data []byte) error

func (*DataInfo) ValidSigClaims

func (t *DataInfo) ValidSigClaims() error

ValidSigClaims should be called after DataInfo.SyntacticVerify. ValidSigClaims should be called with DataInfo.ID.

func (*DataInfo) Verify

func (t *DataInfo) Verify(digestHash []byte, sigs signer.Sigs) bool

func (*DataInfo) VerifyPlus

func (t *DataInfo) VerifyPlus(digestHash []byte, sigs signer.Sigs) bool

type IPLDModel

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

func NewIPLDModel

func NewIPLDModel(name string, sc string) (*IPLDModel, error)

func (*IPLDModel) ApplyPatch

func (l *IPLDModel) ApplyPatch(doc, operations []byte) ([]byte, error)

func (*IPLDModel) Decode

func (l *IPLDModel) Decode(doc []byte) (node datamodel.Node, err error)

func (*IPLDModel) Name

func (l *IPLDModel) Name() string

func (*IPLDModel) Schema

func (l *IPLDModel) Schema() string

func (*IPLDModel) Type

func (l *IPLDModel) Type() schema.Type

func (*IPLDModel) Valid

func (l *IPLDModel) Valid(data []byte) error

type LendingConfig

type LendingConfig struct {
	Token           ids.TokenSymbol `json:"token"`
	DailyInterest   uint64          `json:"dailyInterest"`   // 1_000_000 == 100%, should be in [1, 10_000]
	OverdueInterest uint64          `json:"overdueInterest"` // 1_000_000 == 100%, should be in [1, 10_000]
	MinAmount       *big.Int        `json:"minAmount"`
	MaxAmount       *big.Int        `json:"maxAmount"`
	// contains filtered or unexported fields
}

func (*LendingConfig) Marshal

func (c *LendingConfig) Marshal() ([]byte, error)

func (*LendingConfig) SyntacticVerify

func (c *LendingConfig) SyntacticVerify() error

SyntacticVerify verifies that a *LendingConfig is well-formed.

func (*LendingConfig) Unmarshal

func (c *LendingConfig) Unmarshal(data []byte) error

type LendingEntry

type LendingEntry struct {
	Amount   *big.Int `json:"amount"`
	UpdateAt uint64   `json:"updateAt"`
	DueTime  uint64   `json:"dueTime"`
	// contains filtered or unexported fields
}

type Marshaler

type Marshaler interface {
	Marshal() ([]byte, error)
}

type ModelInfo

type ModelInfo struct {
	// model name, should match ^[A-Z][0-9A-Za-z]{1,127}$
	Name string `cbor:"n" json:"name"`
	// MultiSig: m of n, threshold is m, keepers length is n.
	// The minimum value is 0, means any one using the model don't need to approve.
	// the maximum value is len(keepers)
	Threshold uint16 `cbor:"th" json:"threshold"`
	// keepers who owned this model, no more than 64
	// Creating data using this model requires keepers to sign.
	// no keepers or threshold is 0 means don't need sign.
	Keepers  signer.Keys `cbor:"kp" json:"keepers"`
	Approver signer.Key  `cbor:"ap" json:"approver,omitempty"`
	Schema   string      `cbor:"sc" json:"schema"`

	// external assignment fields
	ID ids.ModelID `cbor:"-" json:"id"`
	// contains filtered or unexported fields
}

func (*ModelInfo) Bytes

func (t *ModelInfo) Bytes() []byte

func (*ModelInfo) Marshal

func (t *ModelInfo) Marshal() ([]byte, error)

func (*ModelInfo) Model

func (t *ModelInfo) Model() *IPLDModel

func (*ModelInfo) SyntacticVerify

func (t *ModelInfo) SyntacticVerify() error

SyntacticVerify verifies that a *ModelInfo is well-formed.

func (*ModelInfo) Unmarshal

func (t *ModelInfo) Unmarshal(data []byte) error

func (*ModelInfo) Verify

func (t *ModelInfo) Verify(digestHash []byte, sigs signer.Sigs) bool

func (*ModelInfo) VerifyPlus

func (t *ModelInfo) VerifyPlus(digestHash []byte, sigs signer.Sigs) bool

type ObjectType

type ObjectType uint16
const (
	AddressObject ObjectType = iota
	LedgerObject
	ModelObject
	DataObject
)

func (ObjectType) MarshalJSON

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

func (ObjectType) String

func (t ObjectType) String() string

type SendOutput

type SendOutput struct {
	To     ids.Address `cbor:"to" json:"to"` // Address of the recipient
	Amount *big.Int    `cbor:"a" json:"amount"`
}

SendOutput specifies that [Amount] of token be sent to [To]

type SendOutputs

type SendOutputs []SendOutput

func (SendOutputs) Marshal

func (so SendOutputs) Marshal() ([]byte, error)

func (SendOutputs) SyntacticVerify

func (so SendOutputs) SyntacticVerify() error

func (*SendOutputs) Unmarshal

func (so *SendOutputs) Unmarshal(data []byte) error

type SigClaims

type SigClaims struct {
	Issuer     ids.DataID  `cbor:"1,keyasint" json:"iss"` // the id of certificate authority
	Subject    ids.DataID  `cbor:"2,keyasint" json:"sub"` // the id of DataInfo
	Audience   ids.ModelID `cbor:"3,keyasint" json:"aud"` // the model id of DataInfo
	Expiration uint64      `cbor:"4,keyasint" json:"exp"`
	NotBefore  uint64      `cbor:"5,keyasint" json:"nbf"`
	IssuedAt   uint64      `cbor:"6,keyasint" json:"iat"`
	CWTID      ids.ID32    `cbor:"7,keyasint" json:"cti"` // the hash of DataInfo.Payload
	// contains filtered or unexported fields
}

SigClaims is a set of claims that used to sign a DataInfo. reference to https://www.rfc-editor.org/rfc/rfc8392.html#section-3

func (*SigClaims) Bytes

func (s *SigClaims) Bytes() []byte

func (*SigClaims) Marshal

func (s *SigClaims) Marshal() ([]byte, error)

func (*SigClaims) SyntacticVerify

func (s *SigClaims) SyntacticVerify() error

func (*SigClaims) Unmarshal

func (s *SigClaims) Unmarshal(data []byte) error

type StakeConfig

type StakeConfig struct {
	Token ids.TokenSymbol `json:"token"`
	// 0: account keepers can not use stake token
	// 1: account keepers can take a stake in other stake account
	// 2: in addition to 1, account keepers can transfer stake token to other account
	Type        uint16   `json:"type"`
	LockTime    uint64   `json:"lockTime"`
	WithdrawFee uint64   `json:"withdrawFee"` // 1_000_000 == 100%, should be in [1, 200_000]
	MinAmount   *big.Int `json:"minAmount"`
	MaxAmount   *big.Int `json:"maxAmount"`
	// contains filtered or unexported fields
}

func (*StakeConfig) Marshal

func (c *StakeConfig) Marshal() ([]byte, error)

func (*StakeConfig) SyntacticVerify

func (c *StakeConfig) SyntacticVerify() error

SyntacticVerify verifies that a *StakeConfig is well-formed.

func (*StakeConfig) Unmarshal

func (c *StakeConfig) Unmarshal(data []byte) error

type StakeEntry

type StakeEntry struct {
	Amount   *big.Int    `json:"amount"`
	LockTime uint64      `json:"lockTime"`
	Approver *signer.Key `json:"approver"`
	// contains filtered or unexported fields
}

type State

type State struct {
	Parent   ids.ID32            `cbor:"p" json:"parent"` // The genesis State's parent ID is ids.Empty.
	Accounts map[string]ids.ID32 `cbor:"a" json:"accounts"`
	Ledgers  map[string]ids.ID32 `cbor:"l" json:"ledgers"`
	Datas    map[string]ids.ID32 `cbor:"d" json:"datas"`
	Models   map[string]ids.ID32 `cbor:"m" json:"models"`

	// external assignment fields
	ID ids.ID32 `cbor:"-" json:"id"`
	// contains filtered or unexported fields
}

func NewState

func NewState(parent ids.ID32) *State

func (*State) Bytes

func (s *State) Bytes() []byte

func (*State) Clone

func (s *State) Clone() *State

func (*State) Marshal

func (s *State) Marshal() ([]byte, error)

func (*State) MarshalJSON added in v0.1.0

func (s *State) MarshalJSON() ([]byte, error)

func (*State) SyntacticVerify

func (s *State) SyntacticVerify() error

SyntacticVerify verifies that a *State is well-formed.

func (*State) Unmarshal

func (s *State) Unmarshal(data []byte) error

func (*State) UpdateAccount

func (s *State) UpdateAccount(id ids.Address, data []byte)

func (*State) UpdateData

func (s *State) UpdateData(id ids.DataID, data []byte)

func (*State) UpdateLedger

func (s *State) UpdateLedger(id ids.Address, data []byte)

func (*State) UpdateModel

func (s *State) UpdateModel(id ids.ModelID, data []byte)

type Transaction

type Transaction struct {
	Tx           TxData      `cbor:"tx" json:"tx"`
	Signatures   signer.Sigs `cbor:"ss,omitempty" json:"sigs,omitempty"`
	ExSignatures signer.Sigs `cbor:"es,omitempty" json:"exSigs,omitempty"`

	// external assignment fields
	ID        ids.ID32 `cbor:"-" json:"id"`
	Err       error    `cbor:"-" json:"error,omitempty"`
	Height    uint64   `cbor:"-" json:"-"` // block's timestamp
	Timestamp uint64   `cbor:"-" json:"-"` // block's timestamp
	// contains filtered or unexported fields
}

func NewBatchTx

func NewBatchTx(txs ...*Transaction) (*Transaction, error)

func (*Transaction) Bytes

func (t *Transaction) Bytes() []byte

func (*Transaction) Copy

func (t *Transaction) Copy() *Transaction

Copy is not a deep copy, used for json.Marshaling

func (*Transaction) Eth

func (t *Transaction) Eth() *TxEth

func (*Transaction) ExHash

func (t *Transaction) ExHash() []byte

func (*Transaction) ExSignWith

func (t *Transaction) ExSignWith(signers ...signer.Signer) error

func (*Transaction) Gas

func (t *Transaction) Gas() uint64

func (*Transaction) IDs

func (t *Transaction) IDs() ids.IDList[ids.ID32]

func (*Transaction) IsApproved

func (t *Transaction) IsApproved(
	approver signer.Key, approveList TxTypes, byEx bool) bool

func (*Transaction) IsBatched

func (t *Transaction) IsBatched() bool

func (*Transaction) Marshal

func (t *Transaction) Marshal() ([]byte, error)

func (*Transaction) SignWith

func (t *Transaction) SignWith(signers ...signer.Signer) error

func (*Transaction) Size

func (t *Transaction) Size() int

func (*Transaction) SyntacticVerify

func (t *Transaction) SyntacticVerify() error

SyntacticVerify verifies that a *Transaction is well-formed.

func (*Transaction) TxHash

func (t *Transaction) TxHash() []byte

func (*Transaction) Txs

func (t *Transaction) Txs() Txs

func (*Transaction) Unmarshal

func (t *Transaction) Unmarshal(data []byte) error

type TxAccounter

type TxAccounter struct {
	Threshold   *uint16          `cbor:"th,omitempty" json:"threshold,omitempty"`
	Keepers     *signer.Keys     `cbor:"kp,omitempty" json:"keepers,omitempty"`
	Approver    *signer.Key      `cbor:"ap,omitempty" json:"approver,omitempty"`
	ApproveList *TxTypes         `cbor:"apl,omitempty" json:"approveList,omitempty"`
	Amount      *big.Int         `cbor:"a,omitempty" json:"amount,omitempty"`
	Name        string           `cbor:"n,omitempty" json:"name,omitempty"`
	Data        encoding.RawData `cbor:"d,omitempty" json:"data,omitempty"`
	// contains filtered or unexported fields
}

TxAccounter

func (*TxAccounter) Bytes

func (t *TxAccounter) Bytes() []byte

func (*TxAccounter) Marshal

func (t *TxAccounter) Marshal() ([]byte, error)

func (*TxAccounter) SyntacticVerify

func (t *TxAccounter) SyntacticVerify() error

SyntacticVerify verifies that a *TxAccounter is well-formed.

func (*TxAccounter) Unmarshal

func (t *TxAccounter) Unmarshal(data []byte) error

type TxData

type TxData struct {
	Type      TxType           `cbor:"t" json:"type"`
	ChainID   uint64           `cbor:"c" json:"chainID"`
	Nonce     uint64           `cbor:"n" json:"nonce"`
	GasTip    uint64           `cbor:"gt" json:"gasTip"`
	GasFeeCap uint64           `cbor:"gf" json:"gasFeeCap"`
	From      ids.Address      `cbor:"fr" json:"from"`                   // Address of the sender
	To        *ids.Address     `cbor:"to,omitempty" json:"to,omitempty"` // Address of the recipient
	Token     *ids.TokenSymbol `cbor:"tk,omitempty" json:"token,omitempty"`
	Amount    *big.Int         `cbor:"a,omitempty" json:"amount,omitempty"`
	Data      encoding.RawData `cbor:"d,omitempty" json:"data,omitempty"`
	// contains filtered or unexported fields
}

TxData represents a complete transaction issued from client

func (*TxData) Bytes

func (t *TxData) Bytes() []byte

func (*TxData) Marshal

func (t *TxData) Marshal() ([]byte, error)

func (*TxData) SyntacticVerify

func (t *TxData) SyntacticVerify() error

SyntacticVerify verifies that a *TxData is well-formed.

func (*TxData) ToTransaction

func (t *TxData) ToTransaction() *Transaction

func (*TxData) Unmarshal

func (t *TxData) Unmarshal(data []byte) error

type TxEth

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

func (*TxEth) Bytes

func (t *TxEth) Bytes() []byte

func (*TxEth) Data

func (t *TxEth) Data() []byte

func (*TxEth) Marshal

func (t *TxEth) Marshal() ([]byte, error)

func (*TxEth) MarshalJSON

func (t *TxEth) MarshalJSON() ([]byte, error)

func (*TxEth) RawSignatureValues

func (t *TxEth) RawSignatureValues() (v, r, s *big.Int)

func (*TxEth) Signers

func (t *TxEth) Signers() (signer.Keys, error)

func (*TxEth) SyntacticVerify

func (t *TxEth) SyntacticVerify() error

SyntacticVerify verifies that a *TxEth is well-formed.

func (*TxEth) ToTransaction

func (t *TxEth) ToTransaction() *Transaction

func (*TxEth) Unmarshal

func (t *TxEth) Unmarshal(data []byte) error

type TxExchanger

type TxExchanger struct {
	Nonce     uint64          `cbor:"n" json:"nonce"`    // saler' account nonce
	Sell      ids.TokenSymbol `cbor:"st" json:"sell"`    // token symbol to sell
	Receive   ids.TokenSymbol `cbor:"rt" json:"receive"` // token symbol to receive
	Quota     *big.Int        `cbor:"q" json:"quota"`    // token sales quota per a tx
	Minimum   *big.Int        `cbor:"m" json:"minimum"`  // minimum amount to buy
	Price     *big.Int        `cbor:"p" json:"price"`    // receive token amount = Quota * Price
	Expire    uint64          `cbor:"e" json:"expire"`
	Payee     ids.Address     `cbor:"py" json:"payee"`
	Purchaser *ids.Address    `cbor:"to,omitempty" json:"purchaser,omitempty"` // optional designated purchaser
	// contains filtered or unexported fields
}

TxExchanger

func (*TxExchanger) Bytes

func (t *TxExchanger) Bytes() []byte

func (*TxExchanger) Marshal

func (t *TxExchanger) Marshal() ([]byte, error)

func (*TxExchanger) SyntacticVerify

func (t *TxExchanger) SyntacticVerify() error

SyntacticVerify verifies that a *TxExchanger is well-formed.

func (*TxExchanger) Unmarshal

func (t *TxExchanger) Unmarshal(data []byte) error

type TxIsApprovedFn

type TxIsApprovedFn func(signer.Key, TxTypes, bool) bool

type TxTester

type TxTester struct {
	ObjectType ObjectType      `cbor:"ot" json:"objectType"`
	ObjectID   string          `cbor:"oid" json:"objectID"`
	Tests      cborpatch.Patch `cbor:"ts" json:"tests"`

	// external assignment fields
	ID32 ids.ID32 `cbor:"-" json:"-"`
	ID20 ids.ID20 `cbor:"-" json:"-"`
	// contains filtered or unexported fields
}

TxTester

func (*TxTester) Bytes

func (t *TxTester) Bytes() []byte

func (*TxTester) Marshal

func (t *TxTester) Marshal() ([]byte, error)

func (*TxTester) SyntacticVerify

func (t *TxTester) SyntacticVerify() error

SyntacticVerify verifies that a *TxTester is well-formed.

func (*TxTester) Test

func (t *TxTester) Test(doc []byte) error

func (*TxTester) Unmarshal

func (t *TxTester) Unmarshal(data []byte) error

type TxTransfer

type TxTransfer struct {
	Nonce  uint64           `cbor:"n,omitempty" json:"nonce,omitempty"`  // sender's nonce
	From   *ids.Address     `cbor:"fr,omitempty" json:"from,omitempty"`  // amount sender
	To     *ids.Address     `cbor:"to,omitempty" json:"to,omitempty"`    // amount recipient
	Token  *ids.TokenSymbol `cbor:"tk,omitempty" json:"token,omitempty"` // token symbol, default is NativeToken
	Amount *big.Int         `cbor:"a,omitempty" json:"amount,omitempty"` // transfer amount
	Expire uint64           `cbor:"e,omitempty" json:"expire,omitempty"`
	Data   encoding.RawData `cbor:"d,omitempty" json:"data,omitempty"`
	// contains filtered or unexported fields
}

TxTransfer is a hybrid data model for:

TxTransferPay{To[, Token, Amount, Expire, Data]} TxTransferCash{Nonce, From, Amount, Expire[, Token, To, Data]} TxTakeStake{Nonce, From, To, Amount, Expire[, Data]}

func (*TxTransfer) Bytes

func (t *TxTransfer) Bytes() []byte

func (*TxTransfer) Marshal

func (t *TxTransfer) Marshal() ([]byte, error)

func (*TxTransfer) SyntacticVerify

func (t *TxTransfer) SyntacticVerify() error

SyntacticVerify verifies that a *TxTransfer is well-formed.

func (*TxTransfer) Unmarshal

func (t *TxTransfer) Unmarshal(data []byte) error

type TxType

type TxType uint16

TxType is an uint16 representing the type of the tx. to avoid encode/decode TxTypes as []uint8, aka []byte.

const (
	// The "test" transaction tests that a value of data at the target location
	// is equal to a specified value.
	// It should be in a batch txn.
	TypeTest TxType = iota

	// Transfer
	TypeEth              // Sends token to a address in ETH transaction
	TypeTransfer         // Sends token to a address
	TypeTransferPay      // Sends token to the address who request payment
	TypeTransferCash     // Transfer token to sender, like cashing a check.
	TypeTransferMultiple // Sends token to multiple addresses.
	TypeExchange         // Exchanges tokens
)
const (
	// Punishs transaction can be issued by genesisAccount
	// we can only punish illegal data
	TypePunish TxType = 16 + iota

	// Model
	TypeCreateModel     // Creates a data model
	TypeUpdateModelInfo // Updates data model's info

	// Data
	TypeCreateData           // Creates a data from the model
	TypeUpdateData           // Updates the data's data
	TypeUpgradeData          // Updates the data's model and data
	TypeUpdateDataInfo       // Updates data's info, such as keepers, threshold, approvers, sigClaims, etc.
	TypeUpdateDataInfoByAuth // Updates data's info by authorization
	TypeDeleteData           // Deletes the data
)
const (
	// Account
	TypeUpdateNonceTable  TxType = 32 + iota // Add or update nonce with expire time
	TypeUpdateAccountInfo                    // Updates account's Keepers and Threshold
	TypeCreateToken                          // Creates a token account
	TypeDestroyToken                         // Destroy a token account
	TypeCreateStake                          // Creates a stake account
	TypeResetStake                           // Reset a stake account
	TypeDestroyStake                         // Destroy a stake account
	TypeTakeStake                            // take a stake in
	TypeWithdrawStake                        // Withdraw stake
	TypeUpdateStakeApprover
	TypeOpenLending
	TypeCloseLending
	TypeBorrow
	TypeRepay
)

func (TxType) Gas

func (t TxType) Gas() uint64

func (TxType) MarshalJSON

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

func (TxType) String

func (t TxType) String() string

type TxTypes

type TxTypes []TxType

func (TxTypes) CheckDuplicate

func (ts TxTypes) CheckDuplicate() error

func (TxTypes) Has

func (ts TxTypes) Has(ty TxType) bool

func (TxTypes) Union

func (ts TxTypes) Union(tss ...TxTypes) TxTypes

type TxUpdater

type TxUpdater struct {
	ID          *ids.DataID      `cbor:"id,omitempty" json:"id,omitempty"`     // data id
	ModelID     *ids.ModelID     `cbor:"mid,omitempty" json:"mid,omitempty"`   // model id
	Version     uint64           `cbor:"v,omitempty" json:"version,omitempty"` // data version
	Threshold   *uint16          `cbor:"th,omitempty" json:"threshold,omitempty"`
	Keepers     *signer.Keys     `cbor:"kp,omitempty" json:"keepers,omitempty"`
	Approver    *signer.Key      `cbor:"ap,omitempty" json:"approver,omitempty"`
	ApproveList *TxTypes         `cbor:"apl,omitempty" json:"approveList,omitempty"`
	Token       *ids.TokenSymbol `cbor:"tk,omitempty" json:"token,omitempty"` // token symbol, default is NativeToken
	To          *ids.Address     `cbor:"to,omitempty" json:"to,omitempty"`    // optional recipient
	Amount      *big.Int         `cbor:"a,omitempty" json:"amount,omitempty"` // transfer amount
	SigClaims   *SigClaims       `cbor:"sc,omitempty" json:"sigClaims,omitempty"`
	Sig         *signer.Sig      `cbor:"s,omitempty" json:"sig,omitempty"`
	Expire      uint64           `cbor:"e,omitempty" json:"expire,omitempty"`
	Data        encoding.RawData `cbor:"d,omitempty" json:"data,omitempty"`
	// contains filtered or unexported fields
}

TxUpdater is a hybrid data model for:

TxCreateData{ModelID, Version, Threshold, Keepers, Data[, Approver, ApproveList]} no model keepers TxCreateData{ModelID, Version, To, Amount, Threshold, Keepers, Data, Expire[, Approver, ApproveList]} with model keepers

TxUpdateData{ID, Version, Data} no model keepers TxUpdateData{ID, Version, SigClaims, Sig, Data} no model keepers TxUpdateData{ID, Version, To, Amount, Data, Expire} with model keepers TxUpdateData{ID, Version, SigClaims, Sig, To, Amount, Data, Expire} with model keepers TxUpgradeData{ID, Version, To, Amount, Data, Expire} with model keepers TxUpgradeData{ID, Version, SigClaims, Sig, To, Amount, Data, Expire} with model keepers

TxDeleteData{ID, Version[, Data]}

TxUpdateDataInfo{ID, Version, Threshold, Keepers[, SigClaims, Sig, Approver, ApproveList]} TxUpdateDataInfoByAuth{ID, Version, To, Amount, Threshold, Keepers, Expire[, Approver, ApproveList, Token]}

TxUpdateModelInfo{ModelID, Threshold, Keepers[, Approver]}

func (*TxUpdater) Bytes

func (t *TxUpdater) Bytes() []byte

func (*TxUpdater) Marshal

func (t *TxUpdater) Marshal() ([]byte, error)

func (*TxUpdater) SyntacticVerify

func (t *TxUpdater) SyntacticVerify() error

SyntacticVerify verifies that a *TxUpdater is well-formed.

func (*TxUpdater) Unmarshal

func (t *TxUpdater) Unmarshal(data []byte) error

type Txs

type Txs []*Transaction

func (Txs) IDs

func (txs Txs) IDs() ids.IDList[ids.ID32]

func (Txs) Marshal

func (txs Txs) Marshal() ([]byte, error)

func (Txs) Size

func (txs Txs) Size() int

func (Txs) Sort

func (txs Txs) Sort()

func (Txs) To

func (txs Txs) To() (*Transaction, error)

func (*Txs) Unmarshal

func (txs *Txs) Unmarshal(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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