commercialpaper

package
v0.0.0-...-c986c8d Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCommercialPaperKey

func CreateCommercialPaperKey(issuer string, paperNumber string) string

CreateCommercialPaperKey creates a key for commercial papers

func Deserialize

func Deserialize(bytes []byte, cp *CommercialPaper) error

Deserialize formats the commercial paper from JSON bytes

Types

type CommercialPaper

type CommercialPaper struct {
	PaperNumber      string `json:"paperNumber"`
	Issuer           string `json:"issuer"`
	IssueDateTime    string `json:"issueDateTime"`
	FaceValue        int    `json:"faceValue"`
	MaturityDateTime string `json:"maturityDateTime"`
	Owner            string `json:"owner"`
	// contains filtered or unexported fields
}

CommercialPaper defines a commercial paper

func (*CommercialPaper) GetSplitKey

func (cp *CommercialPaper) GetSplitKey() []string

GetSplitKey returns values which should be used to form key

func (*CommercialPaper) GetState

func (cp *CommercialPaper) GetState() State

GetState returns the state

func (*CommercialPaper) IsIssued

func (cp *CommercialPaper) IsIssued() bool

IsIssued returns true if state is issued

func (*CommercialPaper) IsRedeemed

func (cp *CommercialPaper) IsRedeemed() bool

IsRedeemed returns true if state is redeemed

func (*CommercialPaper) IsTrading

func (cp *CommercialPaper) IsTrading() bool

IsTrading returns true if state is trading

func (CommercialPaper) MarshalJSON

func (cp CommercialPaper) MarshalJSON() ([]byte, error)

MarshalJSON special handler for managing JSON marshalling

func (*CommercialPaper) Serialize

func (cp *CommercialPaper) Serialize() ([]byte, error)

Serialize formats the commercial paper as JSON bytes

func (*CommercialPaper) SetIssued

func (cp *CommercialPaper) SetIssued()

SetIssued returns the state to issued

func (*CommercialPaper) SetRedeemed

func (cp *CommercialPaper) SetRedeemed()

SetRedeemed sets the state to redeemed

func (*CommercialPaper) SetTrading

func (cp *CommercialPaper) SetTrading()

SetTrading sets the state to trading

func (*CommercialPaper) UnmarshalJSON

func (cp *CommercialPaper) UnmarshalJSON(data []byte) error

UnmarshalJSON special handler for managing JSON marshalling

type Contract

type Contract struct {
	contractapi.Contract
}

Contract chaincode that defines the business logic for managing commercial paper

func (*Contract) Buy

func (c *Contract) Buy(ctx TransactionContextInterface, issuer string, paperNumber string, currentOwner string, newOwner string, price int, purchaseDateTime string) (*CommercialPaper, error)

Buy updates a commercial paper to be in trading status and sets the new owner

func (*Contract) Instantiate

func (c *Contract) Instantiate()

Instantiate does nothing

func (*Contract) Issue

func (c *Contract) Issue(ctx TransactionContextInterface, issuer string, paperNumber string, issueDateTime string, maturityDateTime string, faceValue int) (*CommercialPaper, error)

Issue creates a new commercial paper and stores it in the world state

func (*Contract) Redeem

func (c *Contract) Redeem(ctx TransactionContextInterface, issuer string, paperNumber string, redeemingOwner string, redeenDateTime string) (*CommercialPaper, error)

Redeem updates a commercial paper status to be redeemed

type ListInterface

type ListInterface interface {
	AddPaper(*CommercialPaper) error
	GetPaper(string, string) (*CommercialPaper, error)
	UpdatePaper(*CommercialPaper) error
}

ListInterface defines functionality needed to interact with the world state on behalf of a commercial paper

type State

type State uint

State enum for commercial paper state property

const (
	// ISSUED state for when a paper has been issued
	ISSUED State = iota + 1
	// TRADING state for when a paper is trading
	TRADING
	// REDEEMED state for when a paper has been redeemed
	REDEEMED
)

func (State) String

func (state State) String() string

type TransactionContext

type TransactionContext struct {
	contractapi.TransactionContext
	// contains filtered or unexported fields
}

TransactionContext implementation of TransactionContextInterface for use with commercial paper contract

func (*TransactionContext) GetPaperList

func (tc *TransactionContext) GetPaperList() ListInterface

GetPaperList return paper list

type TransactionContextInterface

type TransactionContextInterface interface {
	contractapi.TransactionContextInterface
	GetPaperList() ListInterface
}

TransactionContextInterface an interface to describe the minimum required functions for a transaction context in the commercial paper

Jump to

Keyboard shortcuts

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