chaincode

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: MIT Imports: 8 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 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. 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
}

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

func (*VaccinationContract) AcceptOffer

func (*VaccinationContract) Approve

func (c *VaccinationContract) Approve(ctx contractapi.TransactionContextInterface, operator string, tokenId string) (bool, error)

func (*VaccinationContract) BalanceOf

func (*VaccinationContract) ClientAccountId

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 string) (string, error)

func (*VaccinationContract) MakeOffer

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

func (*VaccinationContract) OwnerOf

func (*VaccinationContract) SetApprovalForAll

func (c *VaccinationContract) SetApprovalForAll(ctx contractapi.TransactionContextInterface, operator string, approved bool) (bool, error)

func (*VaccinationContract) TransferFrom

func (c *VaccinationContract) TransferFrom(ctx contractapi.TransactionContextInterface, from string, to string, tokenId string) (bool, error)

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

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