asset

package
v0.0.0-...-471f645 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MaxDescriptionLength uint64 = 255

Variables

View Source
var (
	ErrAccountNameNull      = errors.New("account name is null")
	ErrAssetIsExist         = errors.New("asset is exist")
	ErrAssetNotExist        = errors.New("asset not exist")
	ErrOwnerMismatch        = errors.New("asset owner mismatch")
	ErrAssetNameEmpty       = errors.New("asset name is empty")
	ErrAssetObjectEmpty     = errors.New("asset object is empty")
	ErrNewAssetObject       = errors.New("create asset object input invalid")
	ErrAssetAmountZero      = errors.New("asset amount is zero")
	ErrUpperLimit           = errors.New("asset amount over the issuance limit")
	ErrDestroyLimit         = errors.New("asset destroy exceeding the lower limit")
	ErrAssetCountNotExist   = errors.New("asset total count not exist")
	ErrAssetIDInvalid       = errors.New("asset id invalid")
	ErrAssetManagerNotExist = errors.New("asset manager name not exist")
	ErrDetailTooLong        = errors.New("detail info exceed maximum")
	ErrNegativeAmount       = errors.New("negative amount")
	ErrAmountOverMax256     = errors.New("amount over max uint256")
)

Functions

func GetAssetNameLength

func GetAssetNameLength() uint64

func GetAssetNameRegExp

func GetAssetNameRegExp() *regexp.Regexp

func SetAssetMangerName

func SetAssetMangerName(name common.Name)

SetAssetMangerName set the global asset manager name

func SetAssetNameConfig

func SetAssetNameConfig(config *Config) bool

Types

type Asset

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

func NewAsset

func NewAsset(sdb *state.StateDB) *Asset

NewAsset New create Asset

func (*Asset) CheckOwner

func (a *Asset) CheckOwner(fromName common.Name, assetID uint64) error

func (*Asset) DestroyAsset

func (a *Asset) DestroyAsset(accountName common.Name, assetID uint64, amount *big.Int) error

DestroyAsset destroy asset

func (*Asset) GetAssetAmountByTime

func (a *Asset) GetAssetAmountByTime(assetID uint64, time uint64) (*big.Int, error)

GetAssetAmountByTime get asset amount by time

func (*Asset) GetAssetFounderByID

func (a *Asset) GetAssetFounderByID(ID uint64) (common.Name, error)

GetAssetFounderByID get asset founder by ID

func (*Asset) GetAssetIDByName

func (a *Asset) GetAssetIDByName(assetName string) (uint64, error)

GetAssetIDByName get assset id by asset name

func (*Asset) GetAssetObjectByID

func (a *Asset) GetAssetObjectByID(ID uint64) (*AssetObject, error)

GetAssetObjectByID get asset by asset ID

func (*Asset) GetAssetObjectByName

func (a *Asset) GetAssetObjectByName(assetName string) (*AssetObject, error)

GetAssetObjectByName get asset object by name

func (*Asset) GetAssetObjectByTime

func (a *Asset) GetAssetObjectByTime(assetID uint64, time uint64) (*AssetObject, error)

GetAssetObjectByTime get asset object by time

func (*Asset) HasAccess

func (a *Asset) HasAccess(assetID uint64, names ...common.Name) bool

HasAccess contract asset access

func (*Asset) IncStats

func (a *Asset) IncStats(assetID uint64) error

func (*Asset) IncreaseAsset

func (a *Asset) IncreaseAsset(accountName common.Name, assetID uint64, amount *big.Int, forkID uint64) error

IncreaseAsset increase asset, upperlimit == 0 means no upper limit

func (*Asset) InitAssetCount

func (a *Asset) InitAssetCount()

InitAssetCount init asset count

func (*Asset) IsValidAssetOwner

func (a *Asset) IsValidAssetOwner(fromName common.Name, assetPrefix string, assetNames []string) (uint64, bool)

func (*Asset) IsValidMainAssetBeforeFork

func (a *Asset) IsValidMainAssetBeforeFork(assetName string) bool

func (*Asset) IsValidSubAssetBeforeFork

func (a *Asset) IsValidSubAssetBeforeFork(fromName common.Name, assetName string) (uint64, bool)

IsValidSubAssetBeforeFork check parent owner valid

func (*Asset) IssueAsset

func (a *Asset) IssueAsset(assetName string, number uint64, forkID uint64, symbol string, amount *big.Int, dec uint64, founder common.Name, owner common.Name, limit *big.Int, contract common.Name, description string) (uint64, error)

IssueAsset issue asset

func (*Asset) IssueAssetObject

func (a *Asset) IssueAssetObject(ao *AssetObject) (uint64, error)

IssueAssetObject Issue Asset Object

func (*Asset) SetAssetNewContract

func (a *Asset) SetAssetNewContract(assetID uint64, contract common.Name) error

func (*Asset) SetAssetNewOwner

func (a *Asset) SetAssetNewOwner(accountName common.Name, assetID uint64, newOwner common.Name) error

SetAssetNewOwner change asset owner

func (*Asset) SetAssetObject

func (a *Asset) SetAssetObject(ao *AssetObject) error

SetAssetObject store an asset into database

func (*Asset) UpdateAsset

func (a *Asset) UpdateAsset(accountName common.Name, assetID uint64, founderName common.Name, curForkID uint64) error

UpdateAsset change asset info

type AssetIf

type AssetIf interface {
	GetAssetIDByName(assetName common.Name) (uint64, error)
	GetAllAssetObject() []*AssetObject
	IssueAssetObject(ao *AssetObject) (uint64, error)
	IssueAsset(assetName common.Name, symbol string, amount *big.Int, owner common.Name) error
	IncreaseAsset(accountName common.Name, assetID uint64, amount *big.Int) error
	SetAssetNewOwner(accountName common.Name, assetID uint64, newOwner common.Name) error
}

type AssetObject

type AssetObject struct {
	AssetID     uint64      `json:"assetId"`
	Number      uint64      `json:"number"`
	Stats       uint64      `json:"stats"`
	AssetName   string      `json:"assetName"`
	Symbol      string      `json:"symbol"`
	Amount      *big.Int    `json:"amount"`
	Decimals    uint64      `json:"decimals"`
	Founder     common.Name `json:"founder"`
	Owner       common.Name `json:"owner"`
	AddIssue    *big.Int    `json:"addIssue"`
	UpperLimit  *big.Int    `json:"upperLimit"`
	Contract    common.Name `json:"contract"`
	Description string      `json:"description"`
}

func NewAssetObject

func NewAssetObject(assetName string, number uint64, symbol string, amount *big.Int,
	dec uint64, founder common.Name, owner common.Name,
	limit *big.Int, contract common.Name, description string) (*AssetObject, error)

func NewAssetObjectNoCheck

func NewAssetObjectNoCheck(assetName string, number uint64, symbol string,
	amount *big.Int, dec uint64, founder common.Name, owner common.Name,
	limit *big.Int, contract common.Name, description string) *AssetObject

func (*AssetObject) GetAssetAddIssue

func (ao *AssetObject) GetAssetAddIssue() *big.Int

func (*AssetObject) GetAssetAmount

func (ao *AssetObject) GetAssetAmount() *big.Int

func (*AssetObject) GetAssetContract

func (ao *AssetObject) GetAssetContract() common.Name

func (*AssetObject) GetAssetDescription

func (ao *AssetObject) GetAssetDescription() string

func (*AssetObject) GetAssetFounder

func (ao *AssetObject) GetAssetFounder() common.Name

func (*AssetObject) GetAssetID

func (ao *AssetObject) GetAssetID() uint64

func (*AssetObject) GetAssetName

func (ao *AssetObject) GetAssetName() string

func (*AssetObject) GetAssetNumber

func (ao *AssetObject) GetAssetNumber() uint64

func (*AssetObject) GetAssetOwner

func (ao *AssetObject) GetAssetOwner() common.Name

func (*AssetObject) GetAssetStats

func (ao *AssetObject) GetAssetStats() uint64

func (*AssetObject) GetContract

func (ao *AssetObject) GetContract() common.Name

func (*AssetObject) GetDecimals

func (ao *AssetObject) GetDecimals() uint64

func (*AssetObject) GetSymbol

func (ao *AssetObject) GetSymbol() string

func (*AssetObject) GetUpperLimit

func (ao *AssetObject) GetUpperLimit() *big.Int

func (*AssetObject) SetAssetAddIssue

func (ao *AssetObject) SetAssetAddIssue(amount *big.Int)

func (*AssetObject) SetAssetAmount

func (ao *AssetObject) SetAssetAmount(amount *big.Int)

func (*AssetObject) SetAssetContract

func (ao *AssetObject) SetAssetContract(contract common.Name)

func (*AssetObject) SetAssetDescription

func (ao *AssetObject) SetAssetDescription(description string)

func (*AssetObject) SetAssetFounder

func (ao *AssetObject) SetAssetFounder(f common.Name)

func (*AssetObject) SetAssetID

func (ao *AssetObject) SetAssetID(AssetID uint64)

func (*AssetObject) SetAssetName

func (ao *AssetObject) SetAssetName(assetName string)

func (*AssetObject) SetAssetNumber

func (ao *AssetObject) SetAssetNumber(number uint64)

func (*AssetObject) SetAssetOwner

func (ao *AssetObject) SetAssetOwner(owner common.Name)

func (*AssetObject) SetAssetStats

func (ao *AssetObject) SetAssetStats(count uint64)

func (*AssetObject) SetDecimals

func (ao *AssetObject) SetDecimals(dec uint64)

func (*AssetObject) SetSymbol

func (ao *AssetObject) SetSymbol(sym string)

type Config

type Config struct {
	AssetNameLevel         uint64 `json:"assetNameLevel"`
	AssetNameLength        uint64 `json:"assetNameLength"`
	MainAssetNameMinLength uint64 `json:"mainAssetNameMinLength"`
	MainAssetNameMaxLength uint64 `json:"mainAssetNameMaxLength"`
	SubAssetNameMinLength  uint64 `json:"subAssetNameMinLength"`
	SubAssetNameMaxLength  uint64 `json:"subAssetNameMaxLength"`
}

Config Asset name level

Jump to

Keyboard shortcuts

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