asset

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2018 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeUnknownAsset          sdk.CodeType      = 500
	CodeInvalidTransaction    sdk.CodeType      = 501
	CodeInvalidInput          sdk.CodeType      = 502
	CodeInvalidOutput         sdk.CodeType      = 503
	CodeInvalidAssets         sdk.CodeType      = 504
	CodeMissingField          sdk.CodeType      = 505
	CodeInvalidField          sdk.CodeType      = 506
	CodeInvalidRevokeReporter sdk.CodeType      = 507
	CodeInvalidAssetQuantity  sdk.CodeType      = 508
	CodeAssetAlreadyFinal     sdk.CodeType      = 509
	DefaultCodespace          sdk.CodespaceType = 10
)

ABCI Response Codes Base SDK reserves 500 - 599.

Variables

View Source
var (
	// Keys for store prefixes
	AssetKey             = []byte{0x00} // prefix for each key to an asset
	AccountAssetKey      = []byte{0x01} // prefix for each key to an account
	ProposalRecipientKey = []byte{0x02} // prefix for each key to an account a proposal
)

nolint

Functions

func CodeToDefaultMsg

func CodeToDefaultMsg(code sdk.CodeType) string

CodeToDefaultMsg NOTE: Don't stringer this, we'll put better messages in later.

func ErrAssetAlreadyFinal added in v0.2.1

func ErrAssetAlreadyFinal(assetID string) sdk.Error

func ErrAssetNotFound added in v0.1.0

func ErrAssetNotFound(assetID string) sdk.Error

func ErrInvalidAssetQuantity added in v0.2.1

func ErrInvalidAssetQuantity(assetID string) sdk.Error

ErrInvalidAssetQuantity ...

func ErrInvalidAssetRoot added in v0.2.1

func ErrInvalidAssetRoot(assetID string) sdk.Error

func ErrInvalidField added in v0.1.0

func ErrInvalidField(field string) sdk.Error

ErrInvalidField ...

func ErrInvalidRevokeReporter added in v0.2.2

func ErrInvalidRevokeReporter(addr sdk.Address) sdk.Error

ErrInvalidRevokeReporter is used when the reporter of a revoke reporter message is not in the asset's reporter list

func ErrInvalidTransaction added in v0.2.1

func ErrInvalidTransaction(msg string) sdk.Error

InvalidTransaction ...

func ErrMissingField

func ErrMissingField(field string) sdk.Error

ErrMissingField ...

func ErrUnknownAsset

func ErrUnknownAsset(msg string) sdk.Error

ErrUnknownAsset ...

func GetAccountAssetKey added in v0.2.2

func GetAccountAssetKey(addr sdk.Address, assetID string) []byte

GetAccountAssetKey get the key for an account for an asset

func GetAccountAssetsKey added in v0.2.2

func GetAccountAssetsKey(addr sdk.Address) []byte

GetAccountAssetsKey get the key for an account for all assets

func GetAssetKey

func GetAssetKey(assetID string) []byte

GetAssetKey get the key for the record with address

func NewHandler

func NewHandler(k Keeper) sdk.Handler

NewHandler ...

func RegisterWire added in v0.0.2

func RegisterWire(cdc *wire.Codec)

Register concrete types on wire codec

Types

type Asset

type Asset struct {
	ID         string      `json:"id"`
	Type       string      `json:"type"`
	Height     int64       `json:"height"`
	Name       string      `json:"name"`
	Owner      sdk.Address `json:"owner"`
	Reporters  Reporters   `json:"reporters"`
	Parent     string      `json:"parent"` // the id of the asset parent
	Root       string      `json:"root"`   // the id of the asset root
	Quantity   int64       `json:"quantity"`
	Company    string      `json:"company"`
	Email      string      `json:"email"`
	Final      bool        `json:"final"`
	Properties Properties  `json:"properties"`
	Materials  Materials   `json:"materials"`
	Precision  int         `json:"precision"`
	Created    int64       `json:"created"`
}

Asset asset infomation

func (Asset) CheckUpdateAttributeAuthorization added in v0.1.0

func (a Asset) CheckUpdateAttributeAuthorization(address sdk.Address, prop Property) bool

CheckUpdateAttributeAuthorization returns whether the address is authorized to update the attribute

func (Asset) GetReporter added in v0.2.2

func (a Asset) GetReporter(address sdk.Address) (*Reporter, int)

CheckUpdateAttributeAuthorization returns whether the address is authorized to update the attribute

func (Asset) IsOwner

func (a Asset) IsOwner(addr sdk.Address) bool

IsOwner check is owner of the asset

type Keeper

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

Keeper ...

func NewKeeper

func NewKeeper(key sdk.StoreKey, cdc *wire.Codec) Keeper

NewKeeper - Returns the Keeper

func (Keeper) AddMaterials added in v0.2.1

func (k Keeper) AddMaterials(ctx sdk.Context, msg MsgAddMaterials) (sdk.Tags, sdk.Error)

AddMaterials add materials to the asset

func (Keeper) AddQuantity

func (k Keeper) AddQuantity(ctx sdk.Context, msg MsgAddQuantity) (sdk.Tags, sdk.Error)

AddQuantity ...

func (Keeper) CreateAsset added in v0.2.1

func (k Keeper) CreateAsset(ctx sdk.Context, msg MsgCreateAsset) (sdk.Tags, sdk.Error)

Register register new asset

func (Keeper) CreateReporter added in v0.2.2

func (k Keeper) CreateReporter(ctx sdk.Context, msg MsgCreateReporter) (sdk.Tags, sdk.Error)

CreateReporter validates and adds a new reporter to the asset, or update a reporter if there already exists one for the reporter

func (Keeper) Finalize added in v0.2.1

func (k Keeper) Finalize(ctx sdk.Context, msg MsgFinalize) (sdk.Tags, sdk.Error)

Send ...

func (Keeper) GetAsset

func (k Keeper) GetAsset(ctx sdk.Context, assetID string) (asset Asset, found bool)

GetAsset get asset by IDS

func (Keeper) RevokeReporter added in v0.2.2

func (k Keeper) RevokeReporter(ctx sdk.Context, msg MsgRevokeReporter) (sdk.Tags, sdk.Error)

RevokeReporter delete reporter

func (Keeper) SetAsset added in v0.2.2

func (k Keeper) SetAsset(ctx sdk.Context, asset Asset)

set the main record holding asset details

func (Keeper) SubtractQuantity

func (k Keeper) SubtractQuantity(ctx sdk.Context, msg MsgSubtractQuantity) (sdk.Tags, sdk.Error)

SubtractQuantity subtract quantity of the asset

func (Keeper) Transfer added in v0.2.2

func (k Keeper) Transfer(ctx sdk.Context, msg MsgTransfer) (sdk.Tags, sdk.Error)

Transfer transfer asset

func (Keeper) UpdateProperties added in v0.2.2

func (k Keeper) UpdateProperties(ctx sdk.Context, msg MsgUpdateProperties) (sdk.Tags, sdk.Error)

UpdateAttribute ...

type Location

type Location struct {
	Latitude  string `json:"latitude"`
	Longitude string `json:"longitude"`
}

type Material added in v0.1.0

type Material struct {
	AssetID  string `json:"asset_id"`
	Quantity int64  `json:"quantity"`
}

Material defines the total material of new asset

func (Material) Plus added in v0.1.0

func (material Material) Plus(materialB Material) Material

Adds quantities of two assets with same asset

func (Material) SameAssetAs added in v0.1.0

func (material Material) SameAssetAs(other Material) bool

SameDenomAs returns true if the two assets are the same asset

type Materials added in v0.1.0

type Materials []Material

Materials - list of materials

func (Materials) Len added in v0.1.0

func (materials Materials) Len() int

nolint

func (Materials) Less added in v0.1.0

func (materials Materials) Less(i, j int) bool

func (Materials) Plus added in v0.1.0

func (materials Materials) Plus(materialsB Materials) Materials

Plus combines two sets of materials CONTRACT: Plus will never return materials where one Material has a 0 quantity.

func (Materials) Sort added in v0.1.0

func (materials Materials) Sort() Materials

Sort is a helper function to sort the set of materials inplace

func (Materials) Swap added in v0.1.0

func (materials Materials) Swap(i, j int)

type MsgAddMaterials added in v0.1.0

type MsgAddMaterials struct {
	AssetID   string      `json:"asset_id"`
	Sender    sdk.Address `json:"sender"`
	Materials Materials   `json:"materials"`
}

MsgAddMaterials ...

func (MsgAddMaterials) Get added in v0.1.0

func (msg MsgAddMaterials) Get(key interface{}) (value interface{})

func (MsgAddMaterials) GetSignBytes added in v0.1.0

func (msg MsgAddMaterials) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (MsgAddMaterials) GetSigners added in v0.1.0

func (msg MsgAddMaterials) GetSigners() []sdk.Address

func (MsgAddMaterials) String added in v0.1.0

func (msg MsgAddMaterials) String() string

func (MsgAddMaterials) Type added in v0.1.0

func (msg MsgAddMaterials) Type() string

func (MsgAddMaterials) ValidateBasic added in v0.1.0

func (msg MsgAddMaterials) ValidateBasic() sdk.Error

ValidateBasic Validate Basic is used to quickly disqualify obviously invalid messages quickly

type MsgAddQuantity added in v0.2.2

type MsgAddQuantity struct {
	Sender   sdk.Address `json:"sender"`
	AssetID  string      `json:"asset_id"`
	Quantity int64       `json:"quantity"`
}

MsgAddQuantity ... ---------------------------------------------------------------

func (MsgAddQuantity) Get added in v0.2.2

func (msg MsgAddQuantity) Get(key interface{}) (value interface{})

func (MsgAddQuantity) GetSignBytes added in v0.2.2

func (msg MsgAddQuantity) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (MsgAddQuantity) GetSigners added in v0.2.2

func (msg MsgAddQuantity) GetSigners() []sdk.Address

func (MsgAddQuantity) String added in v0.2.2

func (msg MsgAddQuantity) String() string

func (MsgAddQuantity) Type added in v0.2.2

func (msg MsgAddQuantity) Type() string

func (MsgAddQuantity) ValidateBasic added in v0.2.2

func (msg MsgAddQuantity) ValidateBasic() sdk.Error

ValidateBasic Validate Basic is used to quickly disqualify obviously invalid messages quickly

type MsgCreateAsset added in v0.2.1

type MsgCreateAsset struct {
	Sender     sdk.Address `json:"sender"`
	AssetID    string      `json:"asset_id"`
	AssetType  string      `json:"asset_type"`
	Name       string      `json:"name"`
	Quantity   int64       `json:"quantity"`
	Parent     string      `json:"parent"` // the id of the  parent asset
	Materials  Materials   `json:"materials"`
	Properties Properties  `json:"properties"`
	Precision  int         `json:"precision"`
}

MsgCreateAsset A really msg record create type, these fields are can be entirely arbitrary and custom to your message

func NewMsgCreateAsset added in v0.2.1

func NewMsgCreateAsset(sender sdk.Address, id, name string, quantity int64, parent string) MsgCreateAsset

NewMsgCreateAsset new record create msg

func (MsgCreateAsset) Get added in v0.2.1

func (msg MsgCreateAsset) Get(key interface{}) (value interface{})

func (MsgCreateAsset) GetSignBytes added in v0.2.1

func (msg MsgCreateAsset) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (MsgCreateAsset) GetSigners added in v0.2.1

func (msg MsgCreateAsset) GetSigners() []sdk.Address

func (MsgCreateAsset) String added in v0.2.1

func (msg MsgCreateAsset) String() string

func (MsgCreateAsset) Type added in v0.2.1

func (msg MsgCreateAsset) Type() string

nolint ...

func (MsgCreateAsset) ValidateBasic added in v0.2.1

func (msg MsgCreateAsset) ValidateBasic() sdk.Error

ValidateBasic Validate Basic is used to quickly disqualify obviously invalid messages quickly

type MsgCreateReporter added in v0.2.2

type MsgCreateReporter struct {
	Sender     sdk.Address `json:"sender"`
	Reporter   sdk.Address `json:"reporter"`
	AssetID    string      `json:"asset_id"`
	Properties []string    `json:"properties"`
}

MsgSend ...

func (MsgCreateReporter) Get added in v0.2.2

func (msg MsgCreateReporter) Get(key interface{}) (value interface{})

func (MsgCreateReporter) GetSignBytes added in v0.2.2

func (msg MsgCreateReporter) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (MsgCreateReporter) GetSigners added in v0.2.2

func (msg MsgCreateReporter) GetSigners() []sdk.Address

func (MsgCreateReporter) String added in v0.2.2

func (msg MsgCreateReporter) String() string

func (MsgCreateReporter) Type added in v0.2.2

func (msg MsgCreateReporter) Type() string

func (MsgCreateReporter) ValidateBasic added in v0.2.2

func (msg MsgCreateReporter) ValidateBasic() sdk.Error

ValidateBasic Validate Basic is used to quickly disqualify obviously invalid messages quickly

type MsgFinalize added in v0.2.1

type MsgFinalize struct {
	Sender  sdk.Address `json:"sender"`
	AssetID string      `json:"asset_id"`
}

MsgSend ...

func (MsgFinalize) Get added in v0.2.1

func (msg MsgFinalize) Get(key interface{}) (value interface{})

func (MsgFinalize) GetSignBytes added in v0.2.1

func (msg MsgFinalize) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (MsgFinalize) GetSigners added in v0.2.1

func (msg MsgFinalize) GetSigners() []sdk.Address

func (MsgFinalize) String added in v0.2.1

func (msg MsgFinalize) String() string

func (MsgFinalize) Type added in v0.2.1

func (msg MsgFinalize) Type() string

func (MsgFinalize) ValidateBasic added in v0.2.1

func (msg MsgFinalize) ValidateBasic() sdk.Error

ValidateBasic Validate Basic is used to quickly disqualify obviously invalid messages quickly

type MsgRevokeReporter added in v0.2.2

type MsgRevokeReporter struct {
	Sender   sdk.Address `json:"sender"`
	Reporter sdk.Address `json:"reporter"`
	AssetID  string      `json:"asset_id"`
}

MsgRevokeReporter ...

func (MsgRevokeReporter) Get added in v0.2.2

func (msg MsgRevokeReporter) Get(key interface{}) (value interface{})

func (MsgRevokeReporter) GetSignBytes added in v0.2.2

func (msg MsgRevokeReporter) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (MsgRevokeReporter) GetSigners added in v0.2.2

func (msg MsgRevokeReporter) GetSigners() []sdk.Address

func (MsgRevokeReporter) String added in v0.2.2

func (msg MsgRevokeReporter) String() string

func (MsgRevokeReporter) Type added in v0.2.2

func (msg MsgRevokeReporter) Type() string

func (MsgRevokeReporter) ValidateBasic added in v0.2.2

func (msg MsgRevokeReporter) ValidateBasic() sdk.Error

ValidateBasic Validate Basic is used to quickly disqualify obviously invalid messages quickly

type MsgSubtractQuantity added in v0.2.2

type MsgSubtractQuantity struct {
	Sender   sdk.Address `json:"sender"`
	AssetID  string      `json:"asset_id"`
	Quantity int64       `json:"quantity"`
}

MsgSubtractQuantity ... ---------------------------------------------------------------

func (MsgSubtractQuantity) Get added in v0.2.2

func (msg MsgSubtractQuantity) Get(key interface{}) (value interface{})

func (MsgSubtractQuantity) GetSignBytes added in v0.2.2

func (msg MsgSubtractQuantity) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (MsgSubtractQuantity) GetSigners added in v0.2.2

func (msg MsgSubtractQuantity) GetSigners() []sdk.Address

func (MsgSubtractQuantity) String added in v0.2.2

func (msg MsgSubtractQuantity) String() string

func (MsgSubtractQuantity) Type added in v0.2.2

func (msg MsgSubtractQuantity) Type() string

func (MsgSubtractQuantity) ValidateBasic added in v0.2.2

func (msg MsgSubtractQuantity) ValidateBasic() sdk.Error

ValidateBasic Validate Basic is used to quickly disqualify obviously invalid messages quickly

type MsgTransfer added in v0.2.2

type MsgTransfer struct {
	Sender    sdk.Address `json:"sender"`
	Recipient sdk.Address `json:"recipient"`
	Assets    []string    `json:"assets"`
}

MsgTransfer ...

func (MsgTransfer) Get added in v0.2.2

func (msg MsgTransfer) Get(key interface{}) (value interface{})

func (MsgTransfer) GetSignBytes added in v0.2.2

func (msg MsgTransfer) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (MsgTransfer) GetSigners added in v0.2.2

func (msg MsgTransfer) GetSigners() []sdk.Address

func (MsgTransfer) String added in v0.2.2

func (msg MsgTransfer) String() string

func (MsgTransfer) Type added in v0.2.2

func (msg MsgTransfer) Type() string

func (MsgTransfer) ValidateBasic added in v0.2.2

func (msg MsgTransfer) ValidateBasic() sdk.Error

ValidateBasic Validate Basic is used to quickly disqualify obviously invalid messages quickly

type MsgUpdateProperties added in v0.2.2

type MsgUpdateProperties struct {
	Sender     sdk.Address `json:"sender"`
	AssetID    string      `json:"asset_id"`
	Properties Properties  `json:"properties"`
}

MsgUpdateProperties ... ---------------------------------------------------------------

func (MsgUpdateProperties) Get added in v0.2.2

func (msg MsgUpdateProperties) Get(key interface{}) (value interface{})

func (MsgUpdateProperties) GetSignBytes added in v0.2.2

func (msg MsgUpdateProperties) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (MsgUpdateProperties) GetSigners added in v0.2.2

func (msg MsgUpdateProperties) GetSigners() []sdk.Address

func (MsgUpdateProperties) String added in v0.2.2

func (msg MsgUpdateProperties) String() string

func (MsgUpdateProperties) Type added in v0.2.2

func (msg MsgUpdateProperties) Type() string

func (MsgUpdateProperties) ValidateBasic added in v0.2.2

func (msg MsgUpdateProperties) ValidateBasic() sdk.Error

ValidateBasic Validate Basic is used to quickly disqualify obviously invalid messages quickly

type Properties added in v0.2.2

type Properties []Property

list all properties

func (Properties) Adds added in v0.2.2

func (propertiesA Properties) Adds(othersB ...Property) Properties

func (Properties) Len added in v0.2.2

func (properties Properties) Len() int

nolint

func (Properties) Less added in v0.2.2

func (properties Properties) Less(i, j int) bool

func (Properties) Sort added in v0.2.2

func (properties Properties) Sort() Properties

Sort is a helper function to sort the set of materials inplace

func (Properties) Swap added in v0.2.2

func (properties Properties) Swap(i, j int)

type Property added in v0.2.1

type Property struct {
	Name         string       `json:"name"`
	Type         PropertyType `json:"type"`
	BytesValue   []byte       `json:"bytes_value"`
	StringValue  string       `json:"string_value"`
	BooleanValue bool         `json:"boolean_value"`
	NumberValue  int64        `json:"number_value"`
	EnumValue    []string     `json:"enum_value"`
	Location     Location     `json:"location_value"`
	Precision    int          `json:"precision"`
}

Property property of the asset

type PropertyType added in v0.2.2

type PropertyType int

PropertyType define the type of the property

const (
	PropertyTypeBytes PropertyType = iota + 1
	PropertyTypeString
	PropertyTypeBoolean
	PropertyTypeNumber
	PropertyTypeEnum
	PropertyTypeLocation
)

All avaliable type ò the attribute

type Reporter added in v0.2.2

type Reporter struct {
	Addr       sdk.Address `json:"address"`
	Properties []string    `json:"properties"`
	Created    int64       `json:"created"`
}

type Reporters added in v0.2.2

type Reporters []Reporter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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