asset

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2018 License: Apache-2.0, Apache-2.0 Imports: 9 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
	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 ErrAssetNotFound added in v0.1.0

func ErrAssetNotFound(assetID string) sdk.Error

func ErrInvalidAssets

func ErrInvalidAssets(msg string) sdk.Error

func ErrInvalidField added in v0.1.0

func ErrInvalidField(field string) sdk.Error

ErrInvalidField ...

func ErrInvalidInput

func ErrInvalidInput(msg string) sdk.Error

func ErrInvalidOutput

func ErrInvalidOutput(msg string) sdk.Error

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 ErrMissingField

func ErrMissingField(field string) sdk.Error

ErrMissingField ...

func ErrNoInputs

func ErrNoInputs() sdk.Error

func ErrNoOutputs

func ErrNoOutputs() sdk.Error

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 InvalidTransaction

func InvalidTransaction(msg string) sdk.Error

InvalidTransaction ...

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"`
	Quantity   int64       `json:"quantity"`
	Company    string      `json:"company"`
	Email      string      `json:"email"`
	Attributes []Attribute `json:"attributes"`
	Proposals  Proposals   `json:"proposals"`
	Materials  Materials   `json:"materials"`
}

Assets ...

func (Asset) CheckUpdateAttributeAuthorization added in v0.1.0

func (a Asset) CheckUpdateAttributeAuthorization(address sdk.Address, attr Attribute) bool

CheckUpdateAttributeAuthorization returns whether the address is authorized to update the attribute

func (Asset) IsOwner

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

IsOwner ....

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 Attribute

type Attribute 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"`
}

Attribute ...

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, bank bank.Keeper) Keeper

NewKeeper - Returns the Keeper

func (Keeper) AddQuantity

func (k Keeper) AddQuantity(ctx sdk.Context, msg AddQuantityMsg) (sdk.Coins, 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) 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) 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) RegisterAsset

func (k Keeper) RegisterAsset(ctx sdk.Context, asset Asset) (sdk.Coins, sdk.Tags, sdk.Error)

Register register new 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) SubtractQuantity

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

SubtractQuantity ...

func (Keeper) UpdateAttribute

func (k Keeper) UpdateAttribute(ctx sdk.Context, msg UpdateAttrMsg) (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"`
	Issuer    sdk.Address `json:"issuer"`
	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 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 RegisterMsg

type RegisterMsg struct {
	Issuer   sdk.Address `json:"issuer"`
	ID       string      `json:"id"`
	Name     string      `json:"name"`
	Quantity int64       `json:"quantity"`

	// Company info
	Company string `json:"company"`
	Email   string `json:"email"`
}

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

func NewRegisterMsg

func NewRegisterMsg(issuer sdk.Address, id, name string, quantity int64, company, email string) RegisterMsg

NewRegisterMsg new record create msg

func (RegisterMsg) Get

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

func (RegisterMsg) GetSignBytes

func (msg RegisterMsg) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (RegisterMsg) GetSigners

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

func (RegisterMsg) String

func (msg RegisterMsg) String() string

func (RegisterMsg) Type

func (msg RegisterMsg) Type() string

nolint ...

func (RegisterMsg) ValidateBasic

func (msg RegisterMsg) ValidateBasic() sdk.Error

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

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

type UpdateAttrMsg

type UpdateAttrMsg struct {
	Issuer     sdk.Address `json:"issuer"`
	ID         string      `json:"id"`
	Attributes []Attribute `json:"attribute"`
}

UpdateAttrMsg ... ---------------------------------------------------------------

func (UpdateAttrMsg) Get

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

func (UpdateAttrMsg) GetSignBytes

func (msg UpdateAttrMsg) GetSignBytes() []byte

GetSignBytes Get the bytes for the message signer to sign on

func (UpdateAttrMsg) GetSigners

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

func (UpdateAttrMsg) String

func (msg UpdateAttrMsg) String() string

func (UpdateAttrMsg) Type

func (msg UpdateAttrMsg) Type() string

func (UpdateAttrMsg) ValidateBasic

func (msg UpdateAttrMsg) ValidateBasic() sdk.Error

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

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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