chaincode

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: MIT Imports: 9 Imported by: 2

Documentation

Overview

Package chaincode implements ERC721 for HF9 Vaccination Slots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Approval

type Approval struct {
	Owner    string `json:"owner"`
	Approved string `json:"operator"`
	TokenId  string `json:"tokenId"`
}

type ApprovalForAll

type ApprovalForAll struct {
	Owner    string `json:"owner"`
	Operator string `json:"operator"`
	Approved bool   `json:"approved"`
}

type TokenIdGenerator added in v1.0.0

type TokenIdGenerator struct {
}

func (*TokenIdGenerator) HasNext added in v1.0.0

func (g *TokenIdGenerator) HasNext() bool

func (*TokenIdGenerator) Next added in v1.0.0

func (g *TokenIdGenerator) Next() string

type TokenIdGeneratorInterface added in v1.0.0

type TokenIdGeneratorInterface interface {
	HasNext() bool
	Next() string
}

type TradeOffer

type TradeOffer struct {
	Uuid          string `json:"uuid"`
	Sender        string `json:"sender"`
	SenderItem    string `json:"senderItem"`
	Recipient     string `json:"recipient"`
	RecipientItem string `json:"recipientItem"`
}

TradeOffer represents a trade offer for specific slots of specific identities.

Making an offer:

func (c *VaccinationContract) MakeOffer(ctx contractapi.TransactionContextInterface, mySlotUuid, recipient, recipientSlotUuid string) (offerUuid string, err error)

Accepting an offer:

func (c *VaccinationContract) AcceptOffer(ctx contractapi.TransactionContextInterface, offerUuid string) error

Offers are stored in the global state as offer.sender.offerUuid and offer.recipient.offerUuid offer.offerUuid. This way it enables queries by partial key.

type Transfer

type Transfer struct {
	From    string `json:"from"`
	To      string `json:"to"`
	TokenId string `json:"tokenId"`
}

type VaccinationContract

type VaccinationContract struct {
	contractapi.Contract
	IdGenerator TokenIdGeneratorInterface
}

VaccinationContract is a smart contract for managing vaccination slots. Implements ERC-721.

func (*VaccinationContract) AcceptOffer

func (*VaccinationContract) BalanceOf

func (*VaccinationContract) BurnToken added in v1.0.0

func (*VaccinationContract) ClientAccountId

func (*VaccinationContract) DeleteOffer added in v1.0.0

func (*VaccinationContract) GetApproved

func (*VaccinationContract) GetSlots

func (*VaccinationContract) IsApprovedForAll

func (c *VaccinationContract) IsApprovedForAll(ctx contractapi.TransactionContextInterface, owner string, operator string) (bool, error)

func (*VaccinationContract) IssueSlot

func (c *VaccinationContract) IssueSlot(ctx contractapi.TransactionContextInterface, vaccine, date, patient, previous string) (string, error)

IssueSlot can be used by doctors to issue vaccination slots to patients.

Vaccine must be one of the values defined VaccinationType enum.

Date format must be 2006-01-02.

func (*VaccinationContract) ListOffers added in v0.1.1

func (*VaccinationContract) MakeOffer

func (c *VaccinationContract) MakeOffer(ctx contractapi.TransactionContextInterface, mySlotUuid, recipient, recipientSlotUuid string) (offerUuid string, err error)

func (*VaccinationContract) OwnerOf

type VaccinationDate

type VaccinationDate time.Time

VaccinationDate is a simplified date format to identify specific occasions

func (*VaccinationDate) MarshalJSON

func (vd *VaccinationDate) MarshalJSON() ([]byte, error)

MarshalJSON marshals the date into 2006-01-02 format

func (*VaccinationDate) UnmarshalJSON

func (vd *VaccinationDate) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON unmarshals date from 2006-01-02 format

type VaccinationSlot

type VaccinationSlot struct {
	VaccinationSlotData
	TokenId  string `json:"tokenId"`
	Owner    string `json:"owner"`
	Approved string `json:"approved"`
}

VaccinationSlot contains ERC712 related data (this is the NFT)

type VaccinationSlotData

type VaccinationSlotData struct {
	// Type of the vaccine.
	// May change when the token is transferred.
	Type VaccinationType `json:"type"`

	// When the vaccine should be administered.
	// Never changes.
	Date VaccinationDate `json:"date"`

	// Previously administered vaccine of the same type.
	// If present it may forbid the transfer of the token.
	// May change when the token is transferred.
	Previous string `json:"previous,omitempty"`

	Burned bool `json:"burned,omitempty"`
}

VaccinationSlotData contains information about specific occasion

type VaccinationType

type VaccinationType string
const (
	Alpha   VaccinationType = "alpha"
	Bravo   VaccinationType = "bravo"
	Charlie VaccinationType = "charlie"
	Delta   VaccinationType = "delta"
	Echo    VaccinationType = "echo"
)

func (*VaccinationType) MarshalJSON

func (vt *VaccinationType) MarshalJSON() ([]byte, error)

func (*VaccinationType) UnmarshalJSON

func (vt *VaccinationType) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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