asset

package
v0.0.0-...-6d4bf48 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Package asset maintains a registry of all assets on a blockchain.

Index

Constants

View Source
const PinName = "asset"

PinName is used to identify the pin associated with the asset block processor.

Variables

View Source
var (
	ErrDuplicateAlias = errors.New("duplicate asset alias")
	ErrBadIdentifier  = errors.New("either ID or alias must be specified, and not both")
)

Functions

func Annotated

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

Types

type Asset

type Asset struct {
	AssetID          bc.AssetID
	Alias            *string
	VMVersion        uint64
	IssuanceProgram  []byte
	InitialBlockHash bc.Hash
	Signer           *signers.Signer
	Tags             map[string]interface{}
	// contains filtered or unexported fields
}

func (*Asset) Definition

func (asset *Asset) Definition() (map[string]interface{}, error)

func (*Asset) RawDefinition

func (asset *Asset) RawDefinition() []byte

func (*Asset) SetDefinition

func (asset *Asset) SetDefinition(def map[string]interface{}) error

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 pg.DB, chain *protocol.Chain, pinStore *pin.Store) *Registry

func (*Registry) AnnotateTxs

func (reg *Registry) AnnotateTxs(ctx context.Context, txs []*query.AnnotatedTx) error

func (*Registry) DecodeIssueAction

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

func (*Registry) Define

func (reg *Registry) Define(ctx context.Context, xpubs []chainkd.XPub, quorum int, definition map[string]interface{}, alias string, tags map[string]interface{}, clientToken string) (*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) IndexAssets

func (reg *Registry) IndexAssets(indexer Saver)

func (*Registry) NewIssueAction

func (reg *Registry) NewIssueAction(assetAmount bc.AssetAmount, referenceData chainjson.Map) txbuilder.Action

func (*Registry) ProcessBlocks

func (reg *Registry) ProcessBlocks(ctx context.Context)

func (*Registry) UpdateTags

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

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

type Saver

type Saver interface {
	SaveAnnotatedAsset(context.Context, *query.AnnotatedAsset, string) error
}

A Saver is responsible for saving an annotated asset object for indexing and retrieval. If the Core is configured not to provide search services, SaveAnnotatedAsset can be a no-op.

Jump to

Keyboard shortcuts

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