tokens

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransactionTypeDefineFT    uint16 = 1
	TransactionTypeDefineNFT   uint16 = 2
	TransactionTypeMintFT      uint16 = 3
	TransactionTypeMintNFT     uint16 = 4
	TransactionTypeTransferFT  uint16 = 5
	TransactionTypeTransferNFT uint16 = 6
	TransactionTypeLockToken   uint16 = 7
	TransactionTypeUnlockToken uint16 = 8
	TransactionTypeSplitFT     uint16 = 9
	TransactionTypeBurnFT      uint16 = 10
	TransactionTypeJoinFT      uint16 = 11
	TransactionTypeUpdateNFT   uint16 = 12
)
View Source
const (
	UnitIDLength   = UnitPartLength + TypePartLength
	UnitPartLength = 32
	TypePartLength = 1
)
View Source
const DefaultPartitionID types.PartitionID = 2

Variables

View Source
var (
	FungibleTokenTypeUnitType    = []byte{1}
	NonFungibleTokenTypeUnitType = []byte{2}
	FungibleTokenUnitType        = []byte{3}
	NonFungibleTokenUnitType     = []byte{4}
	FeeCreditRecordUnitType      = []byte{16}
)

Functions

func HashForNewTokenID

func HashForNewTokenID(tx *types.TransactionOrder, hashFunc crypto.Hash) ([]byte, error)

HashForNewTokenID generates new token ID (unit part of the extended identifier) from the transaction order. Use NewFungibleTokenID or NewNonFungibleTokenID to generate the extended identifier from the unit part.

func NewFeeCreditRecordID

func NewFeeCreditRecordID(shardPart []byte, unitPart []byte) types.UnitID

func NewFeeCreditRecordIDFromOwnerPredicate

func NewFeeCreditRecordIDFromOwnerPredicate(shardPart []byte, ownerPredicate []byte, latestAdditionTime uint64) (types.UnitID, error)

func NewFeeCreditRecordIDFromPublicKey

func NewFeeCreditRecordIDFromPublicKey(shardPart, pubKey []byte, latestAdditionTime uint64) (types.UnitID, error)

func NewFeeCreditRecordIDFromPublicKeyHash

func NewFeeCreditRecordIDFromPublicKeyHash(shardPart, pubKeyHash []byte, latestAdditionTime uint64) (types.UnitID, error)

func NewFungibleTokenData

func NewFungibleTokenData(typeID types.UnitID, value uint64, ownerPredicate []byte, timeout uint64) types.UnitData

func NewFungibleTokenID

func NewFungibleTokenID(shardPart []byte, unitPart []byte) types.UnitID

func NewFungibleTokenTypeData

func NewFungibleTokenTypeData(attr *DefineFungibleTokenAttributes) types.UnitData

func NewFungibleTokenTypeID

func NewFungibleTokenTypeID(shardPart []byte, unitPart []byte) types.UnitID

func NewNonFungibleTokenData

func NewNonFungibleTokenData(typeID types.UnitID, attr *MintNonFungibleTokenAttributes) types.UnitData

func NewNonFungibleTokenID

func NewNonFungibleTokenID(shardPart []byte, unitPart []byte) types.UnitID

func NewNonFungibleTokenTypeData

func NewNonFungibleTokenTypeData(attr *DefineNonFungibleTokenAttributes) types.UnitData

func NewNonFungibleTokenTypeID

func NewNonFungibleTokenTypeID(shardPart []byte, unitPart []byte) types.UnitID

func NewRandomFungibleTokenID

func NewRandomFungibleTokenID(shardPart []byte) (types.UnitID, error)

func NewRandomFungibleTokenTypeID

func NewRandomFungibleTokenTypeID(shardPart []byte) (types.UnitID, error)

func NewRandomNonFungibleTokenID

func NewRandomNonFungibleTokenID(shardPart []byte) (types.UnitID, error)

func NewRandomNonFungibleTokenTypeID

func NewRandomNonFungibleTokenTypeID(shardPart []byte) (types.UnitID, error)

func NewUnitData

func NewUnitData(unitID types.UnitID) (types.UnitData, error)

Types

type BurnFungibleTokenAttributes

type BurnFungibleTokenAttributes struct {
	TypeID             types.UnitID // identifies the type of the token to burn
	Value              uint64       // the value to burn
	TargetTokenID      types.UnitID // the target token identifier in join step
	TargetTokenCounter uint64       // the current counter value of the target token
	Counter            uint64       // the transaction counter of this token
	// contains filtered or unexported fields
}

type BurnFungibleTokenAuthProof

type BurnFungibleTokenAuthProof struct {
	OwnerProof           []byte   // input to satisfy the owner predicate of the source token
	TokenTypeOwnerProofs [][]byte // inputs to satisfy the owner predicates inherited from the types
	// contains filtered or unexported fields
}

type DefineFungibleTokenAttributes

type DefineFungibleTokenAttributes struct {
	Symbol                   string       // the symbol (short name) of this token type; note that the symbols are not guaranteed to be unique
	Name                     string       // the long name of this token type
	Icon                     *Icon        // the icon of this token type
	ParentTypeID             types.UnitID // identifies the parent type that this type derives from; nil indicates there is no parent type
	DecimalPlaces            uint32       // the number of decimal places to display for values of tokens of the new type
	SubTypeCreationPredicate []byte       // the predicate clause that controls defining new subtypes of this type
	TokenMintingPredicate    []byte       // the predicate clause that controls minting new tokens of this type
	TokenTypeOwnerPredicate  []byte       // the predicate clause that all tokens of this type (and of subtypes of this type) inherit into their owner predicates
	// contains filtered or unexported fields
}

type DefineFungibleTokenAuthProof

type DefineFungibleTokenAuthProof struct {
	SubTypeCreationProofs [][]byte // inputs to satisfy the subtype creation predicates of all parents
	// contains filtered or unexported fields
}

type DefineNonFungibleTokenAttributes

type DefineNonFungibleTokenAttributes struct {
	Symbol                   string       // the symbol (short name) of this token type; note that the symbols are not guaranteed to be unique
	Name                     string       // the long name of this token type
	Icon                     *Icon        // the optional icon of this token type
	ParentTypeID             types.UnitID // identifies the parent type that this type derives from; nil indicates there is no parent type
	SubTypeCreationPredicate []byte       // the predicate clause that controls defining new subtypes of this type
	TokenMintingPredicate    []byte       // the predicate clause that controls minting new tokens of this type
	TokenTypeOwnerPredicate  []byte       // the predicate clause that all tokens of the new type (and of subtypes of it) inherit into their owner predicates
	DataUpdatePredicate      []byte       // the clause that all tokens of this type (and of subtypes of this type) inherit into their data update predicates
	// contains filtered or unexported fields
}

type DefineNonFungibleTokenAuthProof

type DefineNonFungibleTokenAuthProof struct {
	SubTypeCreationProofs [][]byte // inputs to satisfy the subtype predicates of the parent types
	// contains filtered or unexported fields
}

type FungibleTokenData

type FungibleTokenData struct {
	TokenType      types.UnitID `json:"tokenType"`      // the type of this token
	Value          uint64       `json:"value,string"`   // the value of this token
	OwnerPredicate hex.Bytes    `json:"ownerPredicate"` // the owner predicate of this token
	Locked         uint64       `json:"locked,string"`  // the lock status of this token (non-zero value means locked)
	Counter        uint64       `json:"counter,string"` // the transaction counter of this token
	Timeout        uint64       `json:"timeout,string"` // the earliest round number when this token may be deleted if the balance goes to zero
	// contains filtered or unexported fields
}

func (*FungibleTokenData) Copy

func (f *FungibleTokenData) Copy() types.UnitData

func (*FungibleTokenData) GetCounter

func (f *FungibleTokenData) GetCounter() uint64

func (*FungibleTokenData) IsLocked

func (f *FungibleTokenData) IsLocked() uint64

func (*FungibleTokenData) Owner

func (f *FungibleTokenData) Owner() []byte

func (*FungibleTokenData) SummaryValueInput

func (f *FungibleTokenData) SummaryValueInput() uint64

func (*FungibleTokenData) Write

func (f *FungibleTokenData) Write(hasher abhash.Hasher)

type FungibleTokenTypeData

type FungibleTokenTypeData struct {
	Symbol                   string       `json:"symbol"`
	Name                     string       `json:"name"`
	Icon                     *Icon        `json:"icon"`
	ParentTypeID             types.UnitID `json:"parentTypeId"`             // identifies the parent type that this type derives from; nil indicates there is no parent type
	DecimalPlaces            uint32       `json:"decimalPlaces"`            // is the number of decimal places to display for values of tokens of this type
	SubTypeCreationPredicate hex.Bytes    `json:"subTypeCreationPredicate"` // the predicate clause that controls defining new subtypes of this type
	TokenMintingPredicate    hex.Bytes    `json:"tokenMintingPredicate"`    // the predicate clause that controls minting new tokens of this type
	TokenTypeOwnerPredicate  hex.Bytes    `json:"tokenTypeOwnerPredicate"`  // the predicate clause that all tokens of this type (and of subtypes of this type) inherit into their owner predicates
	// contains filtered or unexported fields
}

func (*FungibleTokenTypeData) Copy

func (*FungibleTokenTypeData) Owner

func (f *FungibleTokenTypeData) Owner() []byte

func (*FungibleTokenTypeData) SummaryValueInput

func (f *FungibleTokenTypeData) SummaryValueInput() uint64

func (*FungibleTokenTypeData) Write

func (f *FungibleTokenTypeData) Write(hasher abhash.Hasher)

type Icon

type Icon struct {
	Type string `json:"type"` // the MIME content type identifying an image format
	Data []byte `json:"data"` // the image in the format specified by type
	// contains filtered or unexported fields
}

func (*Icon) Copy

func (i *Icon) Copy() *Icon

type JoinFungibleTokenAttributes

type JoinFungibleTokenAttributes struct {
	BurnTokenProofs []*types.TxRecordProof // the transaction records and proofs that burned the source tokens
	// contains filtered or unexported fields
}

type JoinFungibleTokenAuthProof

type JoinFungibleTokenAuthProof struct {
	OwnerProof           []byte   // input to satisfy the owner predicate of the target token
	TokenTypeOwnerProofs [][]byte // inputs to satisfy the owner predicates inherited from the types
	// contains filtered or unexported fields
}

type LockTokenAttributes

type LockTokenAttributes struct {
	LockStatus uint64 // status of the lock, non-zero value means locked
	Counter    uint64 // the transaction counter of this token
	// contains filtered or unexported fields
}

type LockTokenAuthProof

type LockTokenAuthProof struct {
	OwnerProof []byte // input to satisfy the owner predicate of the target token
	// contains filtered or unexported fields
}

type MintFungibleTokenAttributes

type MintFungibleTokenAttributes struct {
	TypeID         types.UnitID // the type of the new token
	Value          uint64       // the value of the new token
	OwnerPredicate []byte       // the initial owner predicate of the new token
	Nonce          uint64       // optional nonce
	// contains filtered or unexported fields
}

type MintFungibleTokenAuthProof

type MintFungibleTokenAuthProof struct {
	TokenMintingProof []byte // input to satisfy the token minting predicate of the type
	// contains filtered or unexported fields
}

type MintNonFungibleTokenAttributes

type MintNonFungibleTokenAttributes struct {
	TypeID              types.UnitID // the type of the new token
	Name                string       // the name of the new token
	URI                 string       // the optional URI of an external resource associated with the new token
	Data                []byte       // the optional data associated with the new token
	OwnerPredicate      []byte       // the initial owner predicate of the new token
	DataUpdatePredicate []byte       // the data update predicate of the new token
	Nonce               uint64       // optional nonce
	// contains filtered or unexported fields
}

type MintNonFungibleTokenAuthProof

type MintNonFungibleTokenAuthProof struct {
	TokenMintingProof []byte // the input to satisfy the token minting predicate of the type
	// contains filtered or unexported fields
}

type NonFungibleTokenData

type NonFungibleTokenData struct {
	TypeID              types.UnitID `json:"typeID"`              // the type of this token
	Name                string       `json:"name"`                // the optional long name of this token
	URI                 string       `json:"uri"`                 // the optional URI of an external resource associated with this token
	Data                hex.Bytes    `json:"data"`                // the optional data associated with this token
	OwnerPredicate      hex.Bytes    `json:"ownerPredicate"`      // the owner predicate of this token
	DataUpdatePredicate hex.Bytes    `json:"dataUpdatePredicate"` // the data update predicate;
	Locked              uint64       `json:"locked,string"`       // the lock status of this token (non-zero value means locked)
	Counter             uint64       `json:"counter,string"`      // the transaction counter of this token
	// contains filtered or unexported fields
}

func (*NonFungibleTokenData) Copy

func (*NonFungibleTokenData) GetCounter

func (n *NonFungibleTokenData) GetCounter() uint64

func (*NonFungibleTokenData) IsLocked

func (n *NonFungibleTokenData) IsLocked() uint64

func (*NonFungibleTokenData) Owner

func (n *NonFungibleTokenData) Owner() []byte

func (*NonFungibleTokenData) SummaryValueInput

func (n *NonFungibleTokenData) SummaryValueInput() uint64

func (*NonFungibleTokenData) Write

func (n *NonFungibleTokenData) Write(hasher abhash.Hasher)

type NonFungibleTokenTypeData

type NonFungibleTokenTypeData struct {
	Symbol                   string       `json:"symbol"`
	Name                     string       `json:"name"`
	Icon                     *Icon        `json:"icon"`
	ParentTypeID             types.UnitID `json:"parentTypeId"`             // identifies the parent type that this type derives from; nil indicates there is no parent type
	SubTypeCreationPredicate hex.Bytes    `json:"subTypeCreationPredicate"` // the predicate clause that controls defining new subtypes of this type
	TokenMintingPredicate    hex.Bytes    `json:"tokenMintingPredicate"`    // the predicate clause that controls minting new tokens of this type
	TokenTypeOwnerPredicate  hex.Bytes    `json:"tokenTypeOwnerPredicate"`  // the predicate clause that all tokens of this type (and of subtypes of this type) inherit into their owner predicates
	DataUpdatePredicate      hex.Bytes    `json:"dataUpdatePredicate"`      // the predicate clause that all tokens of this type (and of subtypes of this type) inherit into their data update predicates
	// contains filtered or unexported fields
}

func (*NonFungibleTokenTypeData) Copy

func (*NonFungibleTokenTypeData) Owner

func (n *NonFungibleTokenTypeData) Owner() []byte

func (*NonFungibleTokenTypeData) SummaryValueInput

func (n *NonFungibleTokenTypeData) SummaryValueInput() uint64

func (*NonFungibleTokenTypeData) Write

func (n *NonFungibleTokenTypeData) Write(hasher abhash.Hasher)

type SplitFungibleTokenAttributes

type SplitFungibleTokenAttributes struct {
	TypeID            types.UnitID // identifies the type of the token
	TargetValue       uint64       // the value of the new token
	NewOwnerPredicate []byte       // the owner predicate of the new token
	Counter           uint64       // the transaction counter of this token
	// contains filtered or unexported fields
}

type SplitFungibleTokenAuthProof

type SplitFungibleTokenAuthProof struct {
	OwnerProof           []byte   // input to satisfy the current owner predicate of the token
	TokenTypeOwnerProofs [][]byte // inputs to satisfy the owner predicates inherited from the types
	// contains filtered or unexported fields
}

type TransferFungibleTokenAttributes

type TransferFungibleTokenAttributes struct {
	TypeID            types.UnitID // identifies the type of the token
	Value             uint64       // the value to transfer
	NewOwnerPredicate []byte       // the initial owner predicate of the new token
	Counter           uint64       // the transaction counter of this token
	// contains filtered or unexported fields
}

type TransferFungibleTokenAuthProof

type TransferFungibleTokenAuthProof struct {
	OwnerProof           []byte   // input to satisfy the current owner predicate of the token
	TokenTypeOwnerProofs [][]byte // inputs to satisfy the owner predicates inherited from the types
	// contains filtered or unexported fields
}

type TransferNonFungibleTokenAttributes

type TransferNonFungibleTokenAttributes struct {
	TypeID            types.UnitID // identifies the type of the token
	NewOwnerPredicate []byte       // the new owner predicate of the token
	Counter           uint64       // the transaction counter of this token
	// contains filtered or unexported fields
}

type TransferNonFungibleTokenAuthProof

type TransferNonFungibleTokenAuthProof struct {
	OwnerProof           []byte   // input to satisfy the current owner predicate of the token
	TokenTypeOwnerProofs [][]byte // inputs to satisfy the owner predicates inherited from the types
	// contains filtered or unexported fields
}

type UnlockTokenAttributes

type UnlockTokenAttributes struct {
	Counter uint64 // the transaction counter of this token
	// contains filtered or unexported fields
}

type UnlockTokenAuthProof

type UnlockTokenAuthProof struct {
	OwnerProof []byte // input to satisfy the owner predicate of the target token
	// contains filtered or unexported fields
}

type UpdateNonFungibleTokenAttributes

type UpdateNonFungibleTokenAttributes struct {
	Data    []byte // the new data to replace the data currently associated with the token
	Counter uint64 // the transaction counter of this token
	// contains filtered or unexported fields
}

type UpdateNonFungibleTokenAuthProof

type UpdateNonFungibleTokenAuthProof struct {
	TokenDataUpdateProof      []byte   // input to satisfy token's data update predicate
	TokenTypeDataUpdateProofs [][]byte // inputs to satisfy the data update predicates inherited from the types
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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