Documentation ¶
Overview ¶
Copyright 2018 The Fractal Team Authors This file is part of the fractal project.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func GetAssetNameLength() uint64
- func GetAssetNameRegExp() *regexp.Regexp
- func SetAssetMangerName(name common.Name)
- func SetAssetNameConfig(config *Config) bool
- type Asset
- func (a *Asset) CheckOwner(fromName common.Name, assetID uint64) error
- func (a *Asset) DestroyAsset(accountName common.Name, assetId uint64, amount *big.Int) error
- func (a *Asset) GetAssetAmountByTime(assetID uint64, time uint64) (*big.Int, error)
- func (a *Asset) GetAssetFounderById(id uint64) (common.Name, error)
- func (a *Asset) GetAssetIdByName(assetName string) (uint64, error)
- func (a *Asset) GetAssetObjectById(id uint64) (*AssetObject, error)
- func (a *Asset) GetAssetObjectByName(assetName string) (*AssetObject, error)
- func (a *Asset) GetAssetObjectByTime(assetID uint64, time uint64) (*AssetObject, error)
- func (a *Asset) HasAccess(assetID uint64, names ...common.Name) bool
- func (a *Asset) IncStats(assetID uint64) error
- func (a *Asset) IncreaseAsset(accountName common.Name, assetId uint64, amount *big.Int) error
- func (a *Asset) InitAssetCount()
- func (a *Asset) IsValidAssetOwner(fromName common.Name, assetPrex string, assetNames []string) (uint64, bool)
- func (a *Asset) IsValidMainAssetBeforeFork(assetName string) bool
- func (a *Asset) IsValidSubAssetBeforeFork(fromName common.Name, assetName string) (uint64, bool)
- func (a *Asset) IssueAsset(assetName string, number uint64, forkID uint64, symbol string, amount *big.Int, ...) (uint64, error)
- func (a *Asset) IssueAssetObject(ao *AssetObject) (uint64, error)
- func (a *Asset) SetAssetNewContract(assetID uint64, contract common.Name) error
- func (a *Asset) SetAssetNewOwner(accountName common.Name, assetId uint64, newOwner common.Name) error
- func (a *Asset) SetAssetObject(ao *AssetObject) error
- func (a *Asset) UpdateAsset(accountName common.Name, assetID uint64, founderName common.Name) error
- type AssetIf
- type AssetObject
- func (ao *AssetObject) GetAssetAddIssue() *big.Int
- func (ao *AssetObject) GetAssetAmount() *big.Int
- func (ao *AssetObject) GetAssetContract() common.Name
- func (ao *AssetObject) GetAssetDescription() string
- func (ao *AssetObject) GetAssetFounder() common.Name
- func (ao *AssetObject) GetAssetId() uint64
- func (ao *AssetObject) GetAssetName() string
- func (ao *AssetObject) GetAssetNumber() uint64
- func (ao *AssetObject) GetAssetOwner() common.Name
- func (ao *AssetObject) GetAssetStats() uint64
- func (ao *AssetObject) GetContract() common.Name
- func (ao *AssetObject) GetDecimals() uint64
- func (ao *AssetObject) GetSymbol() string
- func (ao *AssetObject) GetUpperLimit() *big.Int
- func (ao *AssetObject) SetAssetAddIssue(amount *big.Int)
- func (ao *AssetObject) SetAssetAmount(amount *big.Int)
- func (ao *AssetObject) SetAssetContract(contract common.Name)
- func (ao *AssetObject) SetAssetDescription(description string)
- func (ao *AssetObject) SetAssetFounder(f common.Name)
- func (ao *AssetObject) SetAssetId(assetId uint64)
- func (ao *AssetObject) SetAssetName(assetName string)
- func (ao *AssetObject) SetAssetNumber(number uint64)
- func (ao *AssetObject) SetAssetOwner(owner common.Name)
- func (ao *AssetObject) SetAssetStats(count uint64)
- func (ao *AssetObject) SetDecimals(dec uint64)
- func (ao *AssetObject) SetSymbol(sym string)
- type Config
Constants ¶
const MaxDescriptionLength uint64 = 255
Variables ¶
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 maxmium") ErrNegativeAmount = errors.New("negative amount") )
Functions ¶
func GetAssetNameLength ¶ added in v0.0.16
func GetAssetNameLength() uint64
func GetAssetNameRegExp ¶ added in v0.0.9
func SetAssetMangerName ¶ added in v0.0.7
SetAssetMangerName set the global asset manager name
func SetAssetNameConfig ¶ added in v0.0.7
Types ¶
type Asset ¶
type Asset struct {
// contains filtered or unexported fields
}
func (*Asset) CheckOwner ¶ added in v0.0.16
func (*Asset) DestroyAsset ¶ added in v0.0.7
DestroyAsset destroy asset
func (*Asset) GetAssetAmountByTime ¶
GetAssetAmountByTime get asset amount by time
func (*Asset) GetAssetFounderById ¶
GetAssetFounderById get asset founder by id
func (*Asset) GetAssetIdByName ¶
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) IncreaseAsset ¶
IncreaseAsset increase asset, upperlimit == 0 means no upper limit
func (*Asset) IsValidAssetOwner ¶ added in v0.0.22
func (*Asset) IsValidMainAssetBeforeFork ¶ added in v0.0.22
func (*Asset) IsValidSubAssetBeforeFork ¶ added in v0.0.22
IsValidOwner 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 ¶ added in v0.0.16
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
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 }
export
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 NewAssetObjectNoCheck ¶ added in v0.0.22
func (*AssetObject) GetAssetAddIssue ¶
func (ao *AssetObject) GetAssetAddIssue() *big.Int
func (*AssetObject) GetAssetAmount ¶
func (ao *AssetObject) GetAssetAmount() *big.Int
func (*AssetObject) GetAssetContract ¶ added in v0.0.7
func (ao *AssetObject) GetAssetContract() common.Name
func (*AssetObject) GetAssetDescription ¶ added in v0.0.11
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 ¶ added in v0.0.7
func (ao *AssetObject) GetAssetNumber() uint64
func (*AssetObject) GetAssetOwner ¶
func (ao *AssetObject) GetAssetOwner() common.Name
func (*AssetObject) GetAssetStats ¶ added in v0.0.16
func (ao *AssetObject) GetAssetStats() uint64
func (*AssetObject) GetContract ¶ added in v0.0.7
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 ¶ added in v0.0.7
func (ao *AssetObject) SetAssetContract(contract common.Name)
func (*AssetObject) SetAssetDescription ¶ added in v0.0.11
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 ¶ added in v0.0.7
func (ao *AssetObject) SetAssetNumber(number uint64)
func (*AssetObject) SetAssetOwner ¶
func (ao *AssetObject) SetAssetOwner(owner common.Name)
func (*AssetObject) SetAssetStats ¶ added in v0.0.16
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 ¶ added in v0.0.7
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