chaincode

package
v0.0.0-...-aa0c9d3 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2025 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	Type  string `json:"objectType"` //Type is used to distinguish the various types of objects in state database
	ID    string `json:"assetID"`
	Color string `json:"color"`
	Size  int    `json:"size"`
	Owner string `json:"owner"`
}

Asset describes main asset details that are visible to all organizations

type AssetPrivateDetails

type AssetPrivateDetails struct {
	ID             string `json:"assetID"`
	AppraisedValue int    `json:"appraisedValue"`
}

AssetPrivateDetails describes details that are private to owners

type SmartContract

type SmartContract struct {
	contractapi.Contract
}

SmartContract of this fabric sample

func (*SmartContract) AgreeToTransfer

AgreeToTransfer is used by the potential buyer of the asset to agree to the asset value. The agreed to appraisal value is stored in the buying orgs org specifc collection, while the buyer client ID is stored in the asset collection using a composite key

func (*SmartContract) CreateAsset

CreateAsset creates a new asset by placing the main asset details in the assetCollection that can be read by both organizations. The appraisal value is stored in the owners org specific collection.

func (*SmartContract) DeleteAsset

DeleteAsset can be used by the owner of the asset to delete the asset

func (*SmartContract) DeleteTranferAgreement

func (s *SmartContract) DeleteTranferAgreement(ctx contractapi.TransactionContextInterface) error

DeleteTranferAgreement can be used by the buyer to withdraw a proposal from the asset collection and from his own collection.

func (*SmartContract) GetAssetByRange

func (s *SmartContract) GetAssetByRange(ctx contractapi.TransactionContextInterface, startKey string, endKey string) ([]*Asset, error)

GetAssetByRange performs a range query based on the start and end keys provided. Range queries can be used to read data from private data collections, but can not be used in a transaction that also writes to private data.

func (*SmartContract) PurgeAsset

PurgeAsset can be used by the owner of the asset to delete the asset Trigger removal of the asset

func (*SmartContract) QueryAssetByOwner

func (s *SmartContract) QueryAssetByOwner(ctx contractapi.TransactionContextInterface, assetType string, owner string) ([]*Asset, error)

QueryAssetByOwner queries for assets based on assetType, owner. This is an example of a parameterized query where the query logic is baked into the chaincode, and accepting a single query parameter (owner). Only available on state databases that support rich query (e.g. CouchDB) =========================================================================================

func (*SmartContract) QueryAssets

func (s *SmartContract) QueryAssets(ctx contractapi.TransactionContextInterface, queryString string) ([]*Asset, error)

QueryAssets uses a query string to perform a query for assets. Query string matching state database syntax is passed in and executed as is. Supports ad hoc queries that can be defined at runtime by the client. If this is not desired, follow the QueryAssetByOwner example for parameterized queries. Only available on state databases that support rich query (e.g. CouchDB)

func (*SmartContract) ReadAsset

func (s *SmartContract) ReadAsset(ctx contractapi.TransactionContextInterface, assetID string) (*Asset, error)

ReadAsset reads the information from collection

func (*SmartContract) ReadAssetPrivateDetails

func (s *SmartContract) ReadAssetPrivateDetails(ctx contractapi.TransactionContextInterface, collection string, assetID string) (*AssetPrivateDetails, error)

ReadAssetPrivateDetails reads the asset private details in organization specific collection

func (*SmartContract) ReadTransferAgreement

func (s *SmartContract) ReadTransferAgreement(ctx contractapi.TransactionContextInterface, assetID string) (*TransferAgreement, error)

ReadTransferAgreement gets the buyer's identity from the transfer agreement from collection

func (*SmartContract) TransferAsset

TransferAsset transfers the asset to the new owner by setting a new owner ID

type TransferAgreement

type TransferAgreement struct {
	ID      string `json:"assetID"`
	BuyerID string `json:"buyerID"`
}

TransferAgreement describes the buyer agreement returned by ReadTransferAgreement

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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