asset

package
v0.0.2-unstable Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2019 License: GPL-3.0 Imports: 8 Imported by: 7

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

This section is empty.

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")
	ErrAssetCountNotExist = errors.New("asset total count not exist")
	ErrAssetIdInvalid     = errors.New("asset id invalid")
)

Functions

This section is empty.

Types

type Asset

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

func NewAsset

func NewAsset(sdb *state.StateDB) *Asset

New create Asset

func (*Asset) GetAllAssetObject

func (a *Asset) GetAllAssetObject() ([]*AssetObject, error)

func (*Asset) GetAssetIdByName

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

get assset id by asset name

func (*Asset) GetAssetObjectById

func (a *Asset) GetAssetObjectById(id uint64) (*AssetObject, error)

get asset by asset id

func (*Asset) GetAssetObjectByName

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

get asset object by name

func (*Asset) IncreaseAsset

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

increase asset

func (*Asset) InitAssetCount

func (a *Asset) InitAssetCount()

InitAssetCount init asset count

func (*Asset) IssueAsset

func (a *Asset) IssueAsset(assetName string, symbol string, amount *big.Int, dec uint64, owner common.Name) error

issue asset

func (*Asset) IssueAssetObject

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

Issue Asset Object

func (*Asset) SetAssetNewOwner

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

change asset owner

func (*Asset) SetAssetObject

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

add an asset and store 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,omitempty"`
	AssetName string      `json:"assetname,omitempty"`
	Symbol    string      `json:"symbol,omitempty"`
	Amount    *big.Int    `json:"amount,omitempty"`
	Decimals  uint64      `json:"decimals,omitempty"`
	Owner     common.Name `json:"owner,omitempty"`
}

func NewAssetObject

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

func (*AssetObject) GetAssetAmount

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

func (*AssetObject) GetAssetId

func (ao *AssetObject) GetAssetId() uint64

func (*AssetObject) GetAssetName

func (ao *AssetObject) GetAssetName() string

func (*AssetObject) GetAssetOwner

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

func (*AssetObject) GetDecimals

func (ao *AssetObject) GetDecimals() uint64

func (*AssetObject) GetSymbol

func (ao *AssetObject) GetSymbol() string

func (*AssetObject) SetAssetAmount

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

func (*AssetObject) SetAssetId

func (ao *AssetObject) SetAssetId(assetId uint64)

func (*AssetObject) SetAssetName

func (ao *AssetObject) SetAssetName(assetName string)

func (*AssetObject) SetAssetOwner

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

func (*AssetObject) SetDecimals

func (ao *AssetObject) SetDecimals(dec uint64)

func (*AssetObject) SetSymbol

func (ao *AssetObject) SetSymbol(sym string)

Jump to

Keyboard shortcuts

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