asset

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 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
	CodeInvalidRevokeRecipient sdk.CodeType      = 507
	CodeInvalidAssetQuantity   sdk.CodeType      = 508
	CodeAssetAlreadyFinal      sdk.CodeType      = 509
	CodeInvalidAssetRoot       sdk.CodeType      = 5090
	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 a candidate
)

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 ErrInvalidRevokeRecipient added in v0.1.0

func ErrInvalidRevokeRecipient(addr sdk.Address) sdk.Error

ErrInvalidRevokeRecipient is used when the recipient of a revoke proposal message is not in the asset's proposal 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 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 AddQuantityMsg

type AddQuantityMsg struct {
	Issuer    sdk.Address `json:"issuer"`
	ID        string      `json:"id"`
	Quantity  int64       `json:"quantity"`
	Materials Materials   `json:"materials"`
}

AddQuantityMsg ... ---------------------------------------------------------------

func (AddQuantityMsg) Get

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

func (AddQuantityMsg) GetSignBytes

func (msg AddQuantityMsg) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (AddQuantityMsg) GetSigners

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

func (AddQuantityMsg) String

func (msg AddQuantityMsg) String() string

func (AddQuantityMsg) Type

func (msg AddQuantityMsg) Type() string

func (AddQuantityMsg) ValidateBasic

func (msg AddQuantityMsg) ValidateBasic() sdk.Error

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

type AnswerProposalMsg

type AnswerProposalMsg struct {
	AssetID   string         `json:"asset_id"`
	Recipient sdk.Address    `json:"recipient"`
	Response  ProposalStatus `json:"response"`
}

AnswerProposalMsg ...

func (AnswerProposalMsg) Get

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

func (AnswerProposalMsg) GetSignBytes

func (msg AnswerProposalMsg) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (AnswerProposalMsg) GetSigners

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

func (AnswerProposalMsg) String

func (msg AnswerProposalMsg) String() string

func (AnswerProposalMsg) Type

func (msg AnswerProposalMsg) Type() string

func (AnswerProposalMsg) ValidateBasic

func (msg AnswerProposalMsg) ValidateBasic() sdk.Error

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

type Asset

type Asset struct {
	ID          string      `json:"id"`
	Name        string      `json:"name"`
	Issuer      sdk.Address `json:"issuer"`
	Owner       sdk.Address `json:"owner"`
	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"`
	Propertipes Propertipes `json:"propertipes"`
	Proposals   Proposals   `json:"proposals"`
	Materials   Materials   `json:"materials"`
}

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) IsIssuer added in v0.2.1

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

IsIssuer check is issuer of the asset

func (Asset) IsOwner

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

IsOwner check is owner of the asset

func (Asset) ValidateProposalAnswer added in v0.1.0

func (a Asset) ValidateProposalAnswer(recipient sdk.Address, answer ProposalStatus) (proposal *Proposal, proposalIndex int, authorized bool)

ValidateProposalAnswer checks whether the recipient is authorized to answer, if authorized then returns the existing proposal and its index

func (Asset) ValidatePropossal added in v0.1.0

func (a Asset) ValidatePropossal(issuer sdk.Address, recipient sdk.Address) (*Proposal, int, bool)

ValidatePropossal returns whether the address is authorized to create a new proposal, optionally return a proposal and its index if a proposal for the recipient already exists

type AttributeType added in v0.1.0

type AttributeType int

AttributeType define the type ò the attribute

const (
	AttributeTypeBytes AttributeType = iota
	AttributeTypeString
	AttributeTypeBoolean
	AttributeTypeNumber
	AttributeTypeEnum
	AttributeTypeLocation
)

All avaliable type ò the attribute

type CreateProposalMsg

type CreateProposalMsg struct {
	AssetID     string       `json:"asset_id"`
	Issuer      sdk.Address  `json:"issuer"`
	Recipient   sdk.Address  `json:"recipient"`
	Propertipes []string     `json:"propertipes"`
	Role        ProposalRole `json:"role"`
}

CreateProposalMsg ...

func (CreateProposalMsg) Get

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

func (CreateProposalMsg) GetSignBytes

func (msg CreateProposalMsg) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (CreateProposalMsg) GetSigners

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

func (CreateProposalMsg) String

func (msg CreateProposalMsg) String() string

func (CreateProposalMsg) Type

func (msg CreateProposalMsg) Type() string

func (CreateProposalMsg) ValidateBasic

func (msg CreateProposalMsg) ValidateBasic() sdk.Error

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

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 AddQuantityMsg) (sdk.Tags, sdk.Error)

AddQuantity ...

func (Keeper) AnswerProposal added in v0.1.0

func (k Keeper) AnswerProposal(ctx sdk.Context, msg AnswerProposalMsg) (sdk.Tags, sdk.Error)

AnswerProposal update the status of the proposal of the recipient if the answer is valid

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) CreateProposal added in v0.1.0

func (k Keeper) CreateProposal(ctx sdk.Context, msg CreateProposalMsg) (sdk.Tags, sdk.Error)

CreateProposal validates and adds a new proposal to the asset, or update a propsal if there already exists one for the recipient

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

GetAsset get asset by IDS

func (Keeper) Has

func (k Keeper) Has(ctx sdk.Context, assetID string) bool

Has asset

func (Keeper) RevokeProposal added in v0.1.0

func (k Keeper) RevokeProposal(ctx sdk.Context, msg RevokeProposalMsg) (sdk.Tags, sdk.Error)

RevokeProposal delete some properties from an existing proposal and will delete the proposal if there is no property left

func (Keeper) Send added in v0.2.1

func (k Keeper) Send(ctx sdk.Context, msg MsgSend) (sdk.Tags, sdk.Error)

Send ...

func (Keeper) SubtractQuantity

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

SubtractQuantity ...

func (Keeper) UpdatePropertipes added in v0.2.1

func (k Keeper) UpdatePropertipes(ctx sdk.Context, msg MsgUpdatePropertipes) (sdk.Tags, sdk.Error)

UpdateAttribute ...

type Location

type Location struct {
	Latitude  float64 `json:"latitude" amino:"unsafe"`
	Longitude float64 `json:"longitude" amino:"unsafe"`
}

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 MsgCreateAsset added in v0.2.1

type MsgCreateAsset struct {
	Issuer      sdk.Address `json:"issuer"`
	AssetID     string      `json:"asset_id"`
	Name        string      `json:"name"`
	Quantity    int64       `json:"quantity"`
	Parent      string      `json:"parent"` // the id of the  parent asset
	Materials   Materials   `json:"materials"`
	Propertipes Propertipes `json:"propertipes"`
}

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(issuer 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 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 MsgSend added in v0.2.1

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

MsgSend ...

func (MsgSend) Get added in v0.2.1

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

func (MsgSend) GetSignBytes added in v0.2.1

func (msg MsgSend) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (MsgSend) GetSigners added in v0.2.1

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

func (MsgSend) String added in v0.2.1

func (msg MsgSend) String() string

func (MsgSend) Type added in v0.2.1

func (msg MsgSend) Type() string

func (MsgSend) ValidateBasic added in v0.2.1

func (msg MsgSend) ValidateBasic() sdk.Error

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

type MsgUpdatePropertipes added in v0.2.1

type MsgUpdatePropertipes struct {
	Issuer      sdk.Address `json:"issuer"`
	ID          string      `json:"id"`
	Propertipes Propertipes `json:"propertipes"`
}

MsgUpdatePropertipes ... ---------------------------------------------------------------

func (MsgUpdatePropertipes) Get added in v0.2.1

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

func (MsgUpdatePropertipes) GetSignBytes added in v0.2.1

func (msg MsgUpdatePropertipes) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (MsgUpdatePropertipes) GetSigners added in v0.2.1

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

func (MsgUpdatePropertipes) String added in v0.2.1

func (msg MsgUpdatePropertipes) String() string

func (MsgUpdatePropertipes) Type added in v0.2.1

func (msg MsgUpdatePropertipes) Type() string

func (MsgUpdatePropertipes) ValidateBasic added in v0.2.1

func (msg MsgUpdatePropertipes) ValidateBasic() sdk.Error

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

type Propertipes added in v0.2.1

type Propertipes []Property

list all propertipes

func (Propertipes) Adds added in v0.2.1

func (propertipesA Propertipes) Adds(othersB ...Property) Propertipes

func (Propertipes) Len added in v0.2.1

func (propertipes Propertipes) Len() int

nolint

func (Propertipes) Less added in v0.2.1

func (propertipes Propertipes) Less(i, j int) bool

func (Propertipes) Sort added in v0.2.1

func (propertipes Propertipes) Sort() Propertipes

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

func (Propertipes) Swap added in v0.2.1

func (propertipes Propertipes) Swap(i, j int)

type Property added in v0.2.1

type Property struct {
	Name         string        `json:"name"`
	Type         AttributeType `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"`
}

Property property of the asset

type Proposal

type Proposal struct {
	Role       ProposalRole   `json:"role"`       // The role assigned to the recipient
	Status     ProposalStatus `json:"status"`     // The response of the recipient
	Properties []string       `json:"properties"` // The asset's attributes name that the recipient is authorized to update
	Issuer     sdk.Address    `json:"issuer"`     // The proposal issuer
	Recipient  sdk.Address    `json:"recipient"`  // The recipient of the proposal
}

Proposal is an invitation to manage an asset

func (*Proposal) AddProperties added in v0.1.0

func (p *Proposal) AddProperties(properties []string)

AddProperties add new properties to the proposal, filtering existing value

func (*Proposal) IsAccepted added in v0.1.0

func (p *Proposal) IsAccepted() bool

IsAccepted returns true if the proposal was accepted

func (*Proposal) RemoveProperties added in v0.1.0

func (p *Proposal) RemoveProperties(removedProperties []string)

RemoveProperties removes the listed properties from the proposal

type ProposalRole added in v0.1.0

type ProposalRole int

ProposalRole defines the authority of the proposal's recipient

const (
	// RoleReporter is authorized to update the asset's attributes
	// whose name is included in the proposal's properties field
	RoleReporter ProposalRole = iota

	// RoleOwner has the same authorization as RoleReporter
	// but also authorized to make proposal to other recipient
	RoleOwner
)

type ProposalStatus added in v0.1.0

type ProposalStatus int

ProposalStatus define the status of the proposal

const (
	StatusPending  ProposalStatus = iota // The recipient has not answered
	StatusAccepted                       // The recipient accepted the proposal
	StatusRefused                        // The recipient refused the proposal
)

All available status of the proposal

type Proposals

type Proposals []Proposal

Proposals is a sclice of Proposal

type RevokeProposalMsg

type RevokeProposalMsg struct {
	AssetID     string      `json:"asset_id"`
	Issuer      sdk.Address `json:"issuer"`
	Recipient   sdk.Address `json:"recipient"`
	Propertipes []string    `json:"propertipes"`
}

RevokeProposalMsg ...

func (RevokeProposalMsg) Get

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

func (RevokeProposalMsg) GetSignBytes

func (msg RevokeProposalMsg) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (RevokeProposalMsg) GetSigners

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

func (RevokeProposalMsg) String

func (msg RevokeProposalMsg) String() string

func (RevokeProposalMsg) Type

func (msg RevokeProposalMsg) Type() string

func (RevokeProposalMsg) ValidateBasic

func (msg RevokeProposalMsg) ValidateBasic() sdk.Error

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

type SubtractQuantityMsg

type SubtractQuantityMsg struct {
	Issuer   sdk.Address `json:"issuer"`
	ID       string      `json:"id"`
	Quantity int64       `json:"quantity"`
}

AddQuantityMsg ... ---------------------------------------------------------------

func (SubtractQuantityMsg) Get

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

func (SubtractQuantityMsg) GetSignBytes

func (msg SubtractQuantityMsg) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (SubtractQuantityMsg) GetSigners

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

func (SubtractQuantityMsg) String

func (msg SubtractQuantityMsg) String() string

func (SubtractQuantityMsg) Type

func (msg SubtractQuantityMsg) Type() string

func (SubtractQuantityMsg) ValidateBasic

func (msg SubtractQuantityMsg) ValidateBasic() sdk.Error

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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