asset

package
v4.8.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: AGPL-3.0 Imports: 12 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateAlias = errors.New("duplicate asset alias")
	ErrDuplicateAsset = errors.New("duplicate asset id")
	ErrSerializing    = errors.New("serializing asset definition")
	ErrMarshalAsset   = errors.New("failed marshal asset")
	ErrFindAsset      = errors.New("fail to find asset")
	ErrInternalAsset  = errors.New("btm has been defined as the internal asset")
	ErrNullAlias      = errors.New("null asset alias")
)

pre-define errors for supporting bytom errorFormatter

Functions

func Annotated

func Annotated(a *Asset) (*query.AnnotatedAsset, error)

Annotated annotate the asset

func ExtAssetKey

func ExtAssetKey(id *bc.AssetID) []byte

ExtAssetKey return store external assets key

func Key

func Key(id *bc.AssetID) []byte

Key store asset prefix

Types

type Asset

type Asset struct {
	AssetID           bc.AssetID             `json:"id"`
	Alias             *string                `json:"alias"`
	VMVersion         uint64                 `json:"vm_version"`
	RawDefinitionByte chainjson.HexBytes     `json:"raw_definition_byte"`
	DefinitionMap     map[string]interface{} `json:"definition"`
}

Asset describe asset on bytom chain

var DefaultNativeAsset *Asset

DefaultNativeAsset native BTM asset

type Registry

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

Registry tracks and stores all known assets on a blockchain.

func NewRegistry

func NewRegistry(db dbm.DB, chain *protocol.Chain) *Registry

NewRegistry create new registry

func (*Registry) FindByAlias

func (reg *Registry) FindByAlias(alias string) (*Asset, error)

FindByAlias retrieves an Asset record along with its signer, given an asset alias.

func (*Registry) FindByID

func (reg *Registry) FindByID(ctx context.Context, id *bc.AssetID) (*Asset, error)

FindByID retrieves an Asset record along with its signer, given an assetID.

func (*Registry) GetAliasByID

func (reg *Registry) GetAliasByID(id string) string

GetAliasByID return asset alias string by AssetID string

func (*Registry) GetAsset

func (reg *Registry) GetAsset(id string) (*Asset, error)

GetAsset get asset by assetID

func (*Registry) ListAssets

func (reg *Registry) ListAssets(id string) ([]*Asset, error)

ListAssets returns the accounts in the db

func (*Registry) SaveAsset

func (reg *Registry) SaveAsset(a *Asset, alias string) error

SaveAsset store asset

func (*Registry) UpdateAssetAlias

func (reg *Registry) UpdateAssetAlias(id, newAlias string) error

UpdateAssetAlias updates asset alias

Jump to

Keyboard shortcuts

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