Documentation ¶
Index ¶
- Constants
- Variables
- func Copy(dst, src Copier) error
- func FromEthBalance(amount *big.Int) *big.Int
- func MustMarshal(v Marshaler) []byte
- func Recover(errp erring.ErrPrefix, fn func() error) (err error)
- func SetChainID(id uint64)
- func ToEthBalance(amount *big.Int) *big.Int
- type Account
- func (a *Account) Bytes() []byte
- func (a *Account) CheckAsFrom(txType TxType) error
- func (a *Account) CheckAsTo(txType TxType) error
- func (a *Account) Marshal() ([]byte, error)
- func (a *Account) SyntacticVerify() error
- func (a *Account) Unmarshal(data []byte) error
- func (a *Account) Verify(digestHash []byte, sigs signer.Sigs, accountKey signer.Key) bool
- func (a *Account) VerifyPlus(digestHash []byte, sigs signer.Sigs, accountKey signer.Key) bool
- type AccountLedger
- type AccountType
- type Block
- type Copier
- type DataInfo
- func (t *DataInfo) Bytes() []byte
- func (t *DataInfo) Clone() *DataInfo
- func (t *DataInfo) MarkDeleted(data []byte) error
- func (t *DataInfo) Marshal() ([]byte, error)
- func (t *DataInfo) Patch(operations []byte) ([]byte, error)
- func (t *DataInfo) SyntacticVerify() error
- func (t *DataInfo) Unmarshal(data []byte) error
- func (t *DataInfo) ValidSigClaims() error
- func (t *DataInfo) Verify(digestHash []byte, sigs signer.Sigs) bool
- func (t *DataInfo) VerifyPlus(digestHash []byte, sigs signer.Sigs) bool
- type IPLDModel
- type LendingConfig
- type LendingEntry
- type Marshaler
- type ModelInfo
- func (t *ModelInfo) Bytes() []byte
- func (t *ModelInfo) Marshal() ([]byte, error)
- func (t *ModelInfo) Model() *IPLDModel
- func (t *ModelInfo) SyntacticVerify() error
- func (t *ModelInfo) Unmarshal(data []byte) error
- func (t *ModelInfo) Verify(digestHash []byte, sigs signer.Sigs) bool
- func (t *ModelInfo) VerifyPlus(digestHash []byte, sigs signer.Sigs) bool
- type ObjectType
- type SendOutput
- type SendOutputs
- type SigClaims
- type StakeConfig
- type StakeEntry
- type State
- func (s *State) Bytes() []byte
- func (s *State) Clone() *State
- func (s *State) Marshal() ([]byte, error)
- func (s *State) MarshalJSON() ([]byte, error)
- func (s *State) SyntacticVerify() error
- func (s *State) Unmarshal(data []byte) error
- func (s *State) UpdateAccount(id ids.Address, data []byte)
- func (s *State) UpdateData(id ids.DataID, data []byte)
- func (s *State) UpdateLedger(id ids.Address, data []byte)
- func (s *State) UpdateModel(id ids.ModelID, data []byte)
- type Transaction
- func (t *Transaction) Bytes() []byte
- func (t *Transaction) Copy() *Transaction
- func (t *Transaction) Eth() *TxEth
- func (t *Transaction) ExHash() []byte
- func (t *Transaction) ExSignWith(signers ...signer.Signer) error
- func (t *Transaction) Gas() uint64
- func (t *Transaction) IDs() ids.IDList[ids.ID32]
- func (t *Transaction) IsApproved(approver signer.Key, approveList TxTypes, byEx bool) bool
- func (t *Transaction) IsBatched() bool
- func (t *Transaction) Marshal() ([]byte, error)
- func (t *Transaction) SignWith(signers ...signer.Signer) error
- func (t *Transaction) Size() int
- func (t *Transaction) SyntacticVerify() error
- func (t *Transaction) TxHash() []byte
- func (t *Transaction) Txs() Txs
- func (t *Transaction) Unmarshal(data []byte) error
- type TxAccounter
- type TxData
- type TxEth
- func (t *TxEth) Bytes() []byte
- func (t *TxEth) Data() []byte
- func (t *TxEth) Marshal() ([]byte, error)
- func (t *TxEth) MarshalJSON() ([]byte, error)
- func (t *TxEth) RawSignatureValues() (v, r, s *big.Int)
- func (t *TxEth) Signers() (signer.Keys, error)
- func (t *TxEth) SyntacticVerify() error
- func (t *TxEth) ToTransaction() *Transaction
- func (t *TxEth) Unmarshal(data []byte) error
- type TxExchanger
- type TxIsApprovedFn
- type TxTester
- type TxTransfer
- type TxType
- type TxTypes
- type TxUpdater
- type Txs
Constants ¶
const (
MaxBlockTxsSize = 10000
)
const MaxKeepers = 64
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 ¶
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, } )
var AccountTxTypes = TxTypes{ TypeUpdateNonceTable, TypeUpdateAccountInfo, TypeCreateToken, TypeDestroyToken, TypeCreateStake, TypeResetStake, TypeDestroyStake, TypeTakeStake, TypeWithdrawStake, TypeUpdateStakeApprover, TypeOpenLending, TypeCloseLending, TypeBorrow, TypeRepay, }
var AllTxTypes = TxTypes{ TypeTest, TypePunish, TypeCreateModel, TypeCreateData, }.Union( TransferTxTypes, ModelTxTypes, DataTxTypes, AccountTxTypes, )
var DataTxTypes = TxTypes{ TypeUpdateData, TypeUpgradeData, TypeUpdateDataInfo, TypeUpdateDataInfoByAuth, TypeDeleteData, }
var EthSigner = types.NewLondonSigner(big.NewInt(2357))
var ModelNameReg = regexp.MustCompile(`^[A-Z][0-9A-Za-z]{1,127}$`)
var ModelTxTypes = TxTypes{ TypeUpdateModelInfo, }
var StakeFromTxTypes0 = TxTypes{ TypeUpdateAccountInfo, TypeUpdateNonceTable, TypeResetStake, TypeDestroyStake, }
var StakeFromTxTypes1 = TxTypes{ TypeTakeStake, TypeWithdrawStake, TypeUpdateStakeApprover, TypeOpenLending, TypeCloseLending, }.Union(StakeFromTxTypes0)
var StakeFromTxTypes2 = TxTypes{ TypeEth, TypeTransfer, TypeTransferMultiple, }.Union(StakeFromTxTypes1)
var StakeToTxTypes = TxTypes{ TypeTest, TypeEth, TypeTransfer, TypeCreateStake, TypeTakeStake, TypeWithdrawStake, TypeUpdateStakeApprover, TypeBorrow, TypeRepay, }
var TokenFromTxTypes = TxTypes{ TypeEth, TypeTransfer, TypeUpdateAccountInfo, TypeUpdateNonceTable, TypeDestroyToken, TypeOpenLending, TypeCloseLending, }
var TokenToTxTypes = TxTypes{ TypeTest, TypeEth, TypeTransfer, TypeExchange, TypeCreateToken, TypeBorrow, TypeRepay, }
var TransferTxTypes = TxTypes{ TypeEth, TypeTransfer, TypeTransferPay, TypeTransferCash, TypeTransferMultiple, TypeExchange, }
TxTypes set
Functions ¶
func MustMarshal ¶
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) CheckAsFrom ¶ added in v0.0.2
func (*Account) SyntacticVerify ¶
SyntacticVerify verifies that a *Account is well-formed.
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) SyntacticVerify ¶
SyntacticVerify verifies that a *Block is well-formed.
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) MarkDeleted ¶
func (*DataInfo) Patch ¶
Patch applies a patch to the data, returns the patched data. It will not change the data.
func (*DataInfo) SyntacticVerify ¶
SyntacticVerify verifies that a *DataInfo is well-formed.
func (*DataInfo) ValidSigClaims ¶
ValidSigClaims should be called after DataInfo.SyntacticVerify. ValidSigClaims should be called with DataInfo.ID.
type IPLDModel ¶
type IPLDModel struct {
// contains filtered or unexported fields
}
func (*IPLDModel) ApplyPatch ¶
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 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) SyntacticVerify ¶
SyntacticVerify verifies that a *ModelInfo is well-formed.
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) SyntacticVerify ¶
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 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 (*State) MarshalJSON ¶ added in v0.1.0
func (*State) SyntacticVerify ¶
SyntacticVerify verifies that a *State is well-formed.
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) IsApproved ¶
func (*Transaction) IsBatched ¶
func (t *Transaction) IsBatched() bool
func (*Transaction) Marshal ¶
func (t *Transaction) Marshal() ([]byte, 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) SyntacticVerify ¶
SyntacticVerify verifies that a *TxData is well-formed.
func (*TxData) ToTransaction ¶
func (t *TxData) ToTransaction() *Transaction
type TxEth ¶
type TxEth struct {
// contains filtered or unexported fields
}
func (*TxEth) MarshalJSON ¶
func (*TxEth) RawSignatureValues ¶
func (*TxEth) SyntacticVerify ¶
SyntacticVerify verifies that a *TxEth is well-formed.
func (*TxEth) ToTransaction ¶
func (t *TxEth) ToTransaction() *Transaction
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 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) SyntacticVerify ¶
SyntacticVerify verifies that a *TxTester is well-formed.
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) MarshalJSON ¶
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) SyntacticVerify ¶
SyntacticVerify verifies that a *TxUpdater is well-formed.