Documentation ¶
Index ¶
- Variables
- func Annotated(a *Asset) (*query.AnnotatedAsset, error)
- func ExtAssetKey(id *bc.AssetID) []byte
- func Key(id *bc.AssetID) []byte
- type Asset
- type Image
- type Registry
- func (reg *Registry) Backup() (*Image, error)
- func (reg *Registry) DecodeIssueAction(data []byte) (txbuilder.Action, error)
- func (reg *Registry) Define(xpubs []chainkd.XPub, quorum int, definition map[string]interface{}, ...) (*Asset, error)
- func (reg *Registry) FindByAlias(alias string) (*Asset, error)
- func (reg *Registry) FindByID(ctx context.Context, id *bc.AssetID) (*Asset, error)
- func (reg *Registry) GetAliasByID(id string) string
- func (reg *Registry) GetAsset(id string) (*Asset, error)
- func (reg *Registry) ListAssets(id string) ([]*Asset, error)
- func (reg *Registry) NewIssueAction(assetAmount bc.AssetAmount) txbuilder.Action
- func (reg *Registry) Restore(image *Image) error
- func (reg *Registry) SaveAsset(a *Asset, alias string) error
- func (reg *Registry) UpdateAssetAlias(id, newAlias string) error
Constants ¶
This section is empty.
Variables ¶
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 ¶ added in v0.5.0
ExtAssetKey return store external assets key
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"` 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 Image ¶ added in v0.5.0
type Image struct {
Assets []*Asset `json:"assets"`
}
Image is the struct for hold export asset data
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry tracks and stores all known assets on a blockchain.
func NewRegistry ¶
NewRegistry create new registry
func (*Registry) DecodeIssueAction ¶
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) (*Asset, error)
Define defines a new Asset.
func (*Registry) FindByAlias ¶
FindByAlias retrieves an Asset record along with its signer, given an asset alias.
func (*Registry) FindByID ¶
FindByID retrieves an Asset record along with its signer, given an assetID.
func (*Registry) GetAliasByID ¶
GetAliasByID return asset alias string by AssetID string
func (*Registry) ListAssets ¶
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 ¶
UpdateAssetAlias updates asset alias