tokens

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddToken    = "store-token"
	DeleteToken = "delete-token"
)

Variables

This section is empty.

Functions

func NewTransaction

func NewTransaction(notifier events.Publisher, tx *tokendb.Transaction, tmsID token.TMSID) (*transaction, error)

func WrapMetadataWithType

func WrapMetadataWithType(typ driver.Type, id driver.Metadata) (driver.Metadata, error)

func WrapWithType

func WrapWithType(typ driver.Type, id driver.Token) (driver.Token, error)

Types

type Cache

type Cache interface {
	Get(key string) (*CacheEntry, bool)
	Add(key string, value *CacheEntry)
	Delete(key string)
}

type CacheEntry

type CacheEntry struct {
	Request  *token.Request
	ToSpend  []*token2.ID
	ToAppend []TokenToAppend
}

type DBStorage

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

func NewDBStorage

func NewDBStorage(notifier events.Publisher, tokenDB *tokendb.StoreService, tmsID token.TMSID) (*DBStorage, error)

func (*DBStorage) NewTransaction

func (d *DBStorage) NewTransaction() (*transaction, error)

func (*DBStorage) StorePublicParams

func (d *DBStorage) StorePublicParams(ctx context.Context, raw []byte) error

func (*DBStorage) TransactionExists

func (d *DBStorage) TransactionExists(ctx context.Context, id string) (bool, error)

type Flags

type Flags struct {
	Mine    bool
	Auditor bool
	Issuer  bool
}

type GetTMSProviderFunc

type GetTMSProviderFunc = func() *token.ManagementServiceProvider

type MetaData

type MetaData interface {
	SpentTokenID() []*token2.ID
}

type NetworkProvider added in v0.5.0

type NetworkProvider interface {
	GetNetwork(network string, channel string) (*network.Network, error)
}

type Service added in v0.5.0

type Service struct {
	TMSProvider     TMSProvider
	NetworkProvider NetworkProvider
	Storage         *DBStorage

	RequestsCache Cache
}

Service is the interface for the token service

func GetService

func GetService(sp token.ServiceProvider, tmsID token.TMSID) (*Service, error)

GetService returns the Service instance for the passed TMS

func (*Service) Append added in v0.5.0

func (t *Service) Append(ctx context.Context, tmsID token.TMSID, txID token.RequestAnchor, request *token.Request) (err error)

func (*Service) AppendRaw added in v0.5.0

func (t *Service) AppendRaw(ctx context.Context, tmsID token.TMSID, txID token.RequestAnchor, requestRaw []byte) (err error)

func (*Service) AppendTransaction added in v0.5.0

func (t *Service) AppendTransaction(ctx context.Context, tx Transaction) (err error)

AppendTransaction appends the content of the passed transaction to the token db. If the transaction is already in there, nothing more happens. The operation is atomic.

func (*Service) CacheRequest added in v0.5.0

func (t *Service) CacheRequest(ctx context.Context, tmsID token.TMSID, request *token.Request) error

func (*Service) DeleteTokens added in v0.5.0

func (t *Service) DeleteTokens(ctx context.Context, ids ...*token2.ID) (err error)

DeleteTokens marks the entries corresponding to the passed token ids as deleted. The deletion is attributed to the caller of this function.

func (*Service) DeleteTokensBy added in v0.5.0

func (t *Service) DeleteTokensBy(ctx context.Context, deletedBy string, ids ...*token2.ID) (err error)

DeleteTokensBy marks the entries corresponding to the passed token ids as deleted. The deletion is attributed to the passed deletedBy argument.

func (*Service) GetCachedTokenRequest added in v0.5.0

func (t *Service) GetCachedTokenRequest(txID string) *token.Request

func (*Service) PruneInvalidUnspentTokens added in v0.5.0

func (t *Service) PruneInvalidUnspentTokens(ctx context.Context) ([]*token2.ID, error)

PruneInvalidUnspentTokens checks that each unspent token is actually available on the ledger. Those that are not available are deleted. The function returns the list of deleted token ids

func (*Service) SetSpendableBySupportedTokenTypes added in v0.5.0

func (t *Service) SetSpendableBySupportedTokenTypes(types []token2.Format) error

func (*Service) SetSpendableFlag added in v0.5.0

func (t *Service) SetSpendableFlag(value bool, ids ...*token2.ID) error

func (*Service) SetSupportedTokenFormats added in v0.5.0

func (t *Service) SetSupportedTokenFormats(tokenTypes []token2.Format) error

func (*Service) StorePublicParams added in v0.5.0

func (t *Service) StorePublicParams(ctx context.Context, raw []byte) error

StorePublicParams stores the passed public parameters in the token db

func (*Service) UnsupportedTokensIteratorBy added in v0.5.0

func (t *Service) UnsupportedTokensIteratorBy(ctx context.Context, walletID string, typ token2.Type) (driver.UnsupportedTokensIterator, error)

UnsupportedTokensIteratorBy returns the minimum information for upgrade about the tokens that are not supported

type ServiceManager added in v0.5.0

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

ServiceManager handles the services

func NewServiceManager added in v0.5.0

func NewServiceManager(
	tmsProvider TMSProvider,
	storeServiceManager StoreServiceManager,
	networkProvider NetworkProvider,
	notifier events.Publisher,
) *ServiceManager

NewServiceManager creates a new Service manager.

func (*ServiceManager) ServiceByTMSId added in v0.5.0

func (cm *ServiceManager) ServiceByTMSId(tmsID token.TMSID) (*Service, error)

ServiceByTMSId returns the Service for the given TMS

type StoreServiceManager added in v0.5.0

type StoreServiceManager db.StoreServiceManager[*tokendb.StoreService]

type TMSProvider

type TMSProvider interface {
	GetManagementService(opts ...token.ServiceOption) (*token.ManagementService, error)
}

type TokenMessage

type TokenMessage struct {
	TMSID     token.TMSID
	WalletID  string
	TokenType token2.Type
	TxID      string
	Index     uint64
}

type TokenProcessorEvent

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

func NewTokenProcessorEvent

func NewTokenProcessorEvent(topic string, message *TokenMessage) *TokenProcessorEvent

func (*TokenProcessorEvent) Message

func (t *TokenProcessorEvent) Message() interface{}

func (*TokenProcessorEvent) Topic

func (t *TokenProcessorEvent) Topic() string

type TokenToAppend

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

type Transaction

type Transaction interface {
	ID() string
	Network() string
	Channel() string
	Namespace() string
	Request() *token.Request
}

Transaction models a token transaction

type TypedMetadata

type TypedMetadata struct {
	// Type encodes the metadata type
	Type driver.Type
	// Metadata encodes the metadata itself
	Metadata driver.Metadata
}

TypedMetadata encodes metadata with a type.

func UnmarshalTypedMetadata

func UnmarshalTypedMetadata(metadata driver.Metadata) (*TypedMetadata, error)

func (TypedMetadata) Bytes

func (i TypedMetadata) Bytes() ([]byte, error)

type TypedToken

type TypedToken struct {
	// Type encodes the token's type
	Type driver.Type
	// Token encodes the token itself
	Token driver.Token
}

TypedToken encodes a token with a type.

func UnmarshalTypedToken

func UnmarshalTypedToken(token driver.Token) (*TypedToken, error)

func (TypedToken) Bytes

func (i TypedToken) Bytes() ([]byte, error)

type UnspendableTokensIterator added in v0.5.0

type UnspendableTokensIterator = driver.UnsupportedTokensIterator

Directories

Path Synopsis
core

Jump to

Keyboard shortcuts

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