asset

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2018 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//AliasPrefix is asset alias prefix
	AliasPrefix = "ALS:"
	//ExternalAssetPrefix is external definition assets prefix
	ExternalAssetPrefix = "EXA"
)

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 AliasKey

func AliasKey(name string) []byte

func Annotated

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

Annotated annotate the asset

func CalcExtAssetKey

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

CalcExtAssetKey return store external assets key

func Key

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

Key asset store prefix

Types

type Asset

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

Asset describe asset on bytom chain

var DefaultNativeAsset *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) DecodeIssueAction

func (reg *Registry) DecodeIssueAction(data []byte) (txbuilder.Action, error)

DecodeIssueAction unmarshal JSON-encoded data of asset issue action

func (*Registry) Define

func (reg *Registry) Define(xpubs []chainkd.XPub, quorum int, definition map[string]interface{}, alias string, tags map[string]interface{}) (*Asset, error)

Define defines a new Asset.

func (*Registry) FindByAlias

func (reg *Registry) FindByAlias(ctx context.Context, 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) GetIDByAlias

func (reg *Registry) GetIDByAlias(alias string) (string, error)

GetIDByAlias return AssetID string and nil by asset alias,if err ,return "" and err

func (*Registry) ListAssets

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

ListAssets returns the accounts in the db

func (*Registry) NewIssueAction

func (reg *Registry) NewIssueAction(assetAmount bc.AssetAmount) txbuilder.Action

NewIssueAction create a new asset issue action

func (*Registry) UpdateAssetAlias

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

UpdateAssetAlias updates oldAlias to newAlias

func (*Registry) UpdateTags

func (reg *Registry) UpdateTags(ctx context.Context, assetInfo string, tags map[string]interface{}) (err error)

UpdateTags modifies the tags of the specified asset. The asset may be identified either by id or alias, but not both.

Jump to

Keyboard shortcuts

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