core

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: MIT Imports: 37 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// CreateFrom - Channel transference creation From
	CreateFrom typeOperation = iota
	// CreateTo - Channel transference creation To
	CreateTo
	// CancelFrom - cancellation in the From
	CancelFrom
)
View Source
const (
	// BalanceTokenLockedEvent - event on token balance locked
	BalanceTokenLockedEvent = "BalanceTokenLocked"
	// BalanceTokenUnlockedEvent - event on token balance unlocked
	BalanceTokenUnlockedEvent = "BalanceTokenUnlocked"
	// BalanceAllowedLockedEvent - event on allowed balance locked
	BalanceAllowedLockedEvent = "BalanceAllowedLocked"
	// BalanceAllowedUnlockedEvent - event on allowed balance unlocked
	BalanceAllowedUnlockedEvent = "BalanceAllowedUnlocked"
)
View Source
const (
	// MultiSwapCompositeType is a composite key for multiswap
	MultiSwapCompositeType = "multi_swap"
	// MultiSwapReason is a reason for multiswap
	MultiSwapReason = "multi_swap"
	// MultiSwapKeyEvent is a reason for multiswap
	MultiSwapKeyEvent = "multi_swap_key"
)
View Source
const (
	// ErrIncorrectSwap is a reason for multiswap
	ErrIncorrectSwap = "incorrect swap"
	// ErrIncorrectKey is a reason for multiswap
	ErrIncorrectKey = "incorrect key"
)
View Source
const DocsKey = "documents"

DocsKey is a key for documents

View Source
const ErrMethodAlreadyDefined = "pure method has already been defined"

ErrMethodAlreadyDefined is an error message

View Source
const (
	// ErrMethodNotImplemented is the error message for not implemented methods
	ErrMethodNotImplemented = "method is not implemented for query"
)

Variables

View Source
var (
	// ErrBigIntFromString - error on big int from string
	ErrBigIntFromString = errors.New("big int from string")
	// ErrPlatformAdminOnly - error on platform admin only
	ErrPlatformAdminOnly = errors.New("platform admin only")
	// ErrEmptyLockID - error on empty lock id
	ErrEmptyLockID = errors.New("empty lock id")
	// ErrReason - error on reason
	ErrReason = errors.New("empty reason")
	// ErrLockNotExists - error on lock not exists
	ErrLockNotExists = errors.New("lock not exists")
	// ErrAddressRequired - error on address required
	ErrAddressRequired = errors.New("address required")
	// ErrAmountRequired - error on amount required
	ErrAmountRequired = errors.New("amount required")
	// ErrTokenTickerRequired - error on token ticker required
	ErrTokenTickerRequired = errors.New("token ticker required")
	// ErrAlredyExist - error on alredy exist
	ErrAlredyExist = errors.New("lock alredy exist")
	// ErrInsufficientFunds - error on insufficient funds
	ErrInsufficientFunds = errors.New("insufficient funds to process")
)

Functions

func AddDocs

func AddDocs(stub shim.ChaincodeStubInterface, rawDocs string) error

AddDocs adds documents to the ledger

func CheckSign

func CheckSign(stub shim.ChaincodeStubInterface, fn string, args []string, auth []string) (*types.Address, string, error)

CheckSign checks the signature of the transaction

func DeleteDoc

func DeleteDoc(stub shim.ChaincodeStubInterface, docID string) error

DeleteDoc deletes document from the ledger

func GivenBalanceAdd

func GivenBalanceAdd(stub shim.ChaincodeStubInterface, contract string, amount *big.Int) error

GivenBalanceAdd adds given balance to given contract

func GivenBalanceSub

func GivenBalanceSub(stub shim.ChaincodeStubInterface, contract string, amount *big.Int) error

GivenBalanceSub subtracts given balance from given contract

func Logger

func Logger() *logging.Logger

Logger returns the logger for chaincode

func MultiSwapDel

func MultiSwapDel(stub shim.ChaincodeStubInterface, swapID string) error

MultiSwapDel - deletes multiswap from the ledger

func MultiSwapLoad

func MultiSwapLoad(stub shim.ChaincodeStubInterface, swapID string) (*proto.MultiSwap, error)

MultiSwapLoad - loads multiswap from the ledger

func MultiSwapSave

func MultiSwapSave(stub shim.ChaincodeStubInterface, swapID string, swap *proto.MultiSwap) ([]byte, error)

MultiSwapSave - saves multiswap to the ledger

func ParseContract

func ParseContract(in BaseContractInterface, options *ContractOptions) (map[string]*Fn, error)

ParseContract parses contract

func SwapDel

func SwapDel(stub shim.ChaincodeStubInterface, swapID string) error

SwapDel deletes swap

func SwapLoad

func SwapLoad(stub shim.ChaincodeStubInterface, swapID string) (*proto.Swap, error)

SwapLoad returns swap by id

func SwapSave

func SwapSave(stub shim.ChaincodeStubInterface, swapID string, s *proto.Swap) ([]byte, error)

SwapSave saves swap

func ToLowerFirstLetter

func ToLowerFirstLetter(in string) string

ToLowerFirstLetter converts first letter to lower case

Types

type BaseContract

type BaseContract struct {
	// contains filtered or unexported fields
}

BaseContract is a base contract for all contracts

func (*BaseContract) AllowedBalanceAdd

func (bc *BaseContract) AllowedBalanceAdd(token string, address *types.Address, amount *big.Int, reason string) error

AllowedBalanceAdd adds allowed balance to given address

func (*BaseContract) AllowedBalanceBurnLocked

func (bc *BaseContract) AllowedBalanceBurnLocked(token string, address *types.Address, amount *big.Int, reason string) error

AllowedBalanceBurnLocked burns locked allowed balance for given address

func (*BaseContract) AllowedBalanceGet

func (bc *BaseContract) AllowedBalanceGet(token string, address *types.Address) (*big.Int, error)

AllowedBalanceGet returns allowed balance for given address

func (*BaseContract) AllowedBalanceGetAll

func (bc *BaseContract) AllowedBalanceGetAll(addr *types.Address) (map[string]string, error)

AllowedBalanceGetAll returns all allowed balances for given address

func (*BaseContract) AllowedBalanceLock

func (bc *BaseContract) AllowedBalanceLock(token string, address *types.Address, amount *big.Int) error

AllowedBalanceLock locks allowed balance for given address

func (*BaseContract) AllowedBalanceSub

func (bc *BaseContract) AllowedBalanceSub(token string, address *types.Address, amount *big.Int, reason string) error

AllowedBalanceSub subtracts allowed balance from given address

func (*BaseContract) AllowedBalanceTransfer

func (bc *BaseContract) AllowedBalanceTransfer(token string, from *types.Address, to *types.Address, amount *big.Int, reason string) error

AllowedBalanceTransfer transfers allowed balance from one address to another

func (*BaseContract) AllowedBalanceTransferLocked

func (bc *BaseContract) AllowedBalanceTransferLocked(token string, from *types.Address, to *types.Address, amount *big.Int, reason string) error

AllowedBalanceTransferLocked transfers locked allowed balance from one address to another

func (*BaseContract) AllowedBalanceUnLock

func (bc *BaseContract) AllowedBalanceUnLock(token string, address *types.Address, amount *big.Int) error

AllowedBalanceUnLock unlocks allowed balance for given address

func (*BaseContract) AllowedIndustrialBalanceAdd

func (bc *BaseContract) AllowedIndustrialBalanceAdd(address *types.Address, industrialAssets []*pb.Asset, reason string) error

AllowedIndustrialBalanceAdd adds allowed balance to given address

func (*BaseContract) AllowedIndustrialBalanceSub

func (bc *BaseContract) AllowedIndustrialBalanceSub(address *types.Address, industrialAssets []*pb.Asset, reason string) error

AllowedIndustrialBalanceSub subtracts allowed balance from given address

func (*BaseContract) AllowedIndustrialBalanceTransfer

func (bc *BaseContract) AllowedIndustrialBalanceTransfer(from *types.Address, to *types.Address, industrialAssets []*pb.Asset, reason string) error

AllowedIndustrialBalanceTransfer transfers allowed balance from one address to another

func (*BaseContract) GetAtomyzeSKI

func (bc *BaseContract) GetAtomyzeSKI() []byte

GetAtomyzeSKI returns atomyzeSKI

func (*BaseContract) GetInitArg

func (bc *BaseContract) GetInitArg(idx int) string

GetInitArg returns init arg by index

func (*BaseContract) GetInitArgsLen

func (bc *BaseContract) GetInitArgsLen() int

GetInitArgsLen returns init args len

func (*BaseContract) GetMethods

func (bc *BaseContract) GetMethods() []string

GetMethods returns list of methods

func (*BaseContract) GetStub

GetStub returns stub

func (*BaseContract) IndustrialBalanceAdd

func (bc *BaseContract) IndustrialBalanceAdd(token string, address *types.Address, amount *big.Int, reason string) error

IndustrialBalanceAdd adds industrial balance to given address

func (*BaseContract) IndustrialBalanceBurnLocked

func (bc *BaseContract) IndustrialBalanceBurnLocked(token string, address *types.Address, amount *big.Int, reason string) error

IndustrialBalanceBurnLocked burns locked industrial balance for given address

func (*BaseContract) IndustrialBalanceGet

func (bc *BaseContract) IndustrialBalanceGet(address *types.Address) (map[string]string, error)

IndustrialBalanceGet returns industrial balance for given address

func (*BaseContract) IndustrialBalanceGetLocked

func (bc *BaseContract) IndustrialBalanceGetLocked(address *types.Address) (map[string]string, error)

IndustrialBalanceGetLocked returns locked industrial balance for given address

func (*BaseContract) IndustrialBalanceLock

func (bc *BaseContract) IndustrialBalanceLock(token string, address *types.Address, amount *big.Int) error

IndustrialBalanceLock locks industrial balance for given address

func (*BaseContract) IndustrialBalanceSub

func (bc *BaseContract) IndustrialBalanceSub(token string, address *types.Address, amount *big.Int, reason string) error

IndustrialBalanceSub subtracts industrial balance from given address

func (*BaseContract) IndustrialBalanceTransfer

func (bc *BaseContract) IndustrialBalanceTransfer(token string, from *types.Address, to *types.Address, amount *big.Int, reason string) error

IndustrialBalanceTransfer transfers industrial balance from one address to another

func (*BaseContract) IndustrialBalanceTransferLocked

func (bc *BaseContract) IndustrialBalanceTransferLocked(token string, from *types.Address, to *types.Address, amount *big.Int, reason string) error

IndustrialBalanceTransferLocked transfers locked industrial balance from one address to another

func (*BaseContract) IndustrialBalanceUnLock

func (bc *BaseContract) IndustrialBalanceUnLock(token string, address *types.Address, amount *big.Int) error

IndustrialBalanceUnLock unlocks industrial balance for given address

func (*BaseContract) NBTxCommitCCTransferFrom

func (bc *BaseContract) NBTxCommitCCTransferFrom(id string) error

NBTxCommitCCTransferFrom - transaction writes the commit flag in the transfer in the From channel. Executed after successful creation of a mating part in the channel To (TxCreateCCTransferTo) This transaction is sent only by the channel-transfer service with a "robot" certificate

func (*BaseContract) NBTxDeleteCCTransferFrom

func (bc *BaseContract) NBTxDeleteCCTransferFrom(id string) error

NBTxDeleteCCTransferFrom - transaction deletes the transfer record in the channel From. Performed after successful removal in the canal To (NBTxDeleteCCTransferTo) This transaction is sent only by the channel-transfer service with a "robot" certificate

func (*BaseContract) NBTxDeleteCCTransferTo

func (bc *BaseContract) NBTxDeleteCCTransferTo(id string) error

NBTxDeleteCCTransferTo - transaction deletes transfer record in channel To. Executed after a successful commit in the From channel (NBTxCommitCCTransferFrom) This transaction is sent only by the channel-transfer service with a "robot" certificate

func (*BaseContract) QueryBuildInfo

func (bc *BaseContract) QueryBuildInfo() (*debug.BuildInfo, error)

QueryBuildInfo returns debug.BuildInfo struct with build information, stored in binary file or error if it is occurs

func (*BaseContract) QueryChannelTransferFrom

func (bc *BaseContract) QueryChannelTransferFrom(id string) (*pb.CCTransfer, error)

QueryChannelTransferFrom - receiving a transfer record from the channel From

func (*BaseContract) QueryChannelTransferTo

func (bc *BaseContract) QueryChannelTransferTo(id string) (*pb.CCTransfer, error)

QueryChannelTransferTo - receiving a transfer record from the channel To

func (*BaseContract) QueryChannelTransfersFrom

func (bc *BaseContract) QueryChannelTransfersFrom(pageSize int64, bookmark string) (*pb.CCTransfers, error)

QueryChannelTransfersFrom - getting all transfer records from the channel From You can receive them in parts (chunks)

func (*BaseContract) QueryCoreChaincodeIDName

func (bc *BaseContract) QueryCoreChaincodeIDName() (string, error)

QueryCoreChaincodeIDName returns CORE_CHAINCODE_ID_NAME

func (*BaseContract) QueryGetLockedAllowedBalance

func (bc *BaseContract) QueryGetLockedAllowedBalance(
	lockID string,
) (*proto.AllowedBalanceLock, error)

QueryGetLockedAllowedBalance - returns the existing blocking of the allowedbalance AllowedBalanceLock

func (*BaseContract) QueryGetLockedTokenBalance

func (bc *BaseContract) QueryGetLockedTokenBalance(
	lockID string,
) (*proto.TokenBalanceLock, error)

QueryGetLockedTokenBalance - returns an existing balance token lock TokenBalanceLock

func (*BaseContract) QueryGetNonce

func (bc *BaseContract) QueryGetNonce(owner *types.Address) (string, error)

QueryGetNonce returns nonce

func (*BaseContract) QueryGroupBalanceOf

func (bc *BaseContract) QueryGroupBalanceOf(address *types.Address) (map[string]string, error)

QueryGroupBalanceOf - returns balance of the token for user address

func (*BaseContract) QueryMultiSwapGet

func (bc *BaseContract) QueryMultiSwapGet(swapID string) (*proto.MultiSwap, error)

QueryMultiSwapGet - returns multiswap by id

func (*BaseContract) QueryNameOfFiles

func (bc *BaseContract) QueryNameOfFiles() ([]string, error)

QueryNameOfFiles returns list path/name of embed files

func (*BaseContract) QuerySrcFile

func (bc *BaseContract) QuerySrcFile(name string) (string, error)

QuerySrcFile returns file

func (*BaseContract) QuerySrcPartFile

func (bc *BaseContract) QuerySrcPartFile(name string, start int, end int) (string, error)

QuerySrcPartFile returns part of file start - include end - exclude

func (*BaseContract) QuerySwapGet

func (bc *BaseContract) QuerySwapGet(swapID string) (*proto.Swap, error)

QuerySwapGet returns swap by id

func (*BaseContract) QuerySystemEnv

func (bc *BaseContract) QuerySystemEnv() (map[string]string, error)

QuerySystemEnv returns system environment

func (*BaseContract) TokenBalanceAdd

func (bc *BaseContract) TokenBalanceAdd(address *types.Address, amount *big.Int, reason string) error

TokenBalanceAdd adds token balance to given address

func (*BaseContract) TokenBalanceBurnLocked

func (bc *BaseContract) TokenBalanceBurnLocked(address *types.Address, amount *big.Int, reason string) error

TokenBalanceBurnLocked burns locked token balance for given address

func (*BaseContract) TokenBalanceGet

func (bc *BaseContract) TokenBalanceGet(address *types.Address) (*big.Int, error)

TokenBalanceGet returns token balance for given address

func (*BaseContract) TokenBalanceGetLocked

func (bc *BaseContract) TokenBalanceGetLocked(address *types.Address) (*big.Int, error)

TokenBalanceGetLocked returns locked token balance for given address

func (*BaseContract) TokenBalanceLock

func (bc *BaseContract) TokenBalanceLock(address *types.Address, amount *big.Int) error

TokenBalanceLock locks token balance for given address

func (*BaseContract) TokenBalanceSub

func (bc *BaseContract) TokenBalanceSub(address *types.Address, amount *big.Int, reason string) error

TokenBalanceSub subtracts token balance from given address

func (*BaseContract) TokenBalanceTransfer

func (bc *BaseContract) TokenBalanceTransfer(from *types.Address, to *types.Address, amount *big.Int, reason string) error

TokenBalanceTransfer transfers token balance from one address to another

func (*BaseContract) TokenBalanceTransferLocked

func (bc *BaseContract) TokenBalanceTransferLocked(from *types.Address, to *types.Address, amount *big.Int, reason string) error

TokenBalanceTransferLocked transfers locked token balance from one address to another

func (*BaseContract) TokenBalanceUnlock

func (bc *BaseContract) TokenBalanceUnlock(address *types.Address, amount *big.Int) error

TokenBalanceUnlock unlocks token balance for given address

func (*BaseContract) TxCancelCCTransferFrom

func (bc *BaseContract) TxCancelCCTransferFrom(id string) error

TxCancelCCTransferFrom - transaction cancels (deletes) the transfer record in the From channel returns balances to the user. If the service cannot create a response part in the "To" channel within some timeout, it is required to cancel the transfer. After TxChannelTransferByAdmin or TxChannelTransferByCustomer This transaction is sent only by the channel-transfer service with a "robot" certificate

func (*BaseContract) TxChannelTransferByAdmin

func (bc *BaseContract) TxChannelTransferByAdmin(
	sender *types.Sender,
	idTransfer string,
	to string,
	idUser *types.Address,
	token string,
	amount *big.Int,
) (string, error)

TxChannelTransferByAdmin - transaction initiating transfer between channels. Signed by the channel admin (site). The tokens are transferred from idUser to the same user. After the checks, a transfer record is created and the user's balances are reduced.

func (*BaseContract) TxChannelTransferByCustomer

func (bc *BaseContract) TxChannelTransferByCustomer(
	sender *types.Sender,
	idTransfer string,
	to string,
	token string,
	amount *big.Int,
) (string, error)

TxChannelTransferByCustomer - transaction initiating transfer between channels. The owner of tokens signs. Tokens are transferred to themselveselves. After the checks, a transfer record is created and the user's balances are reduced.

func (*BaseContract) TxCreateCCTransferTo

func (bc *BaseContract) TxCreateCCTransferTo(dataIn string) (string, error)

TxCreateCCTransferTo - transaction creates a transfer (already with commit sign) in the channel To and increases the user's balances. The transaction must be executed after the initiating transfer transaction (TxChannelTransferByAdmin or TxChannelTransferByCustomer). This transaction is sent only by the channel-transfer service with a "robot" certificate

func (*BaseContract) TxHealthCheck

func (bc *BaseContract) TxHealthCheck(_ *types.Sender) error

TxHealthCheck can be called by an administrator of the contract for checking if the business logic of the chaincode is still alive.

func (*BaseContract) TxLockAllowedBalance

func (bc *BaseContract) TxLockAllowedBalance(
	sender *types.Sender,
	req *proto.BalanceLockRequest,
) error

TxLockAllowedBalance - blocks tokens on the user's allowedbalance method calls the chaincode admin, the input is a BalanceLockRequest

func (*BaseContract) TxLockTokenBalance

func (bc *BaseContract) TxLockTokenBalance(
	sender *types.Sender,
	req *proto.BalanceLockRequest,
) error

TxLockTokenBalance - blocks tokens on the user's token balance method is called by the chaincode admin, the input is BalanceLockRequest

func (*BaseContract) TxMultiSwapBegin

func (bc *BaseContract) TxMultiSwapBegin(sender *types.Sender, token string, multiSwapAssets types.MultiSwapAssets, contractTo string, hash types.Hex) (string, error)

TxMultiSwapBegin - creates multiswap

func (*BaseContract) TxMultiSwapCancel

func (bc *BaseContract) TxMultiSwapCancel(sender *types.Sender, swapID string) error

TxMultiSwapCancel - cancels multiswap

func (*BaseContract) TxSwapBegin

func (bc *BaseContract) TxSwapBegin(sender *types.Sender, token string, contractTo string, amount *big.Int, hash types.Hex) (string, error)

TxSwapBegin creates swap

func (*BaseContract) TxSwapCancel

func (bc *BaseContract) TxSwapCancel(_ *types.Sender, swapID string) error

TxSwapCancel cancels swap

func (*BaseContract) TxUnlockAllowedBalance

func (bc *BaseContract) TxUnlockAllowedBalance(
	sender *types.Sender,
	req *proto.BalanceLockRequest,
) error

TxUnlockAllowedBalance - unblocks (fully or partially) tokens on the user's allowedbalance method calls the chaincode admin, the input is a BalanceLockRequest

func (*BaseContract) TxUnlockTokenBalance

func (bc *BaseContract) TxUnlockTokenBalance(
	sender *types.Sender,
	req *proto.BalanceLockRequest,
) error

TxUnlockTokenBalance - unblocks (fully or partially) tokens on the user's token balance method is called by the chaincode admin, the input is BalanceLockRequest

type BaseContractInterface

type BaseContractInterface interface {
	GetStub() shim.ChaincodeStubInterface
	GetID() string

	TokenBalanceTransfer(from *types.Address, to *types.Address, amount *big.Int, reason string) error
	AllowedBalanceTransfer(token string, from *types.Address, to *types.Address, amount *big.Int, reason string) error

	TokenBalanceGet(address *types.Address) (*big.Int, error)
	TokenBalanceAdd(address *types.Address, amount *big.Int, reason string) error
	TokenBalanceSub(address *types.Address, amount *big.Int, reason string) error

	AllowedBalanceGet(token string, address *types.Address) (*big.Int, error)
	AllowedBalanceAdd(token string, address *types.Address, amount *big.Int, reason string) error
	AllowedBalanceSub(token string, address *types.Address, amount *big.Int, reason string) error

	AllowedBalanceGetAll(address *types.Address) (map[string]string, error)

	IndustrialBalanceGet(address *types.Address) (map[string]string, error)
	IndustrialBalanceTransfer(token string, from *types.Address, to *types.Address, amount *big.Int, reason string) error
	IndustrialBalanceAdd(token string, address *types.Address, amount *big.Int, reason string) error
	IndustrialBalanceSub(token string, address *types.Address, amount *big.Int, reason string) error

	AllowedIndustrialBalanceAdd(address *types.Address, industrialAssets []*pb.Asset, reason string) error
	AllowedIndustrialBalanceSub(address *types.Address, industrialAssets []*pb.Asset, reason string) error
	AllowedIndustrialBalanceTransfer(from *types.Address, to *types.Address, industrialAssets []*pb.Asset, reason string) error
	// contains filtered or unexported methods
}

BaseContractInterface is a base contract interface for all contracts

type BatchTxStub

type BatchTxStub struct {
	// contains filtered or unexported fields
}

BatchTxStub is a stub for batch transaction

func (*BatchTxStub) AddAccountingRecord

func (bts *BatchTxStub) AddAccountingRecord(token string, from *types.Address, to *types.Address, amount *big.Int, reason string)

AddAccountingRecord adds accounting record to a batchTxStub accounting

func (*BatchTxStub) Commit

func (bts *BatchTxStub) Commit() ([]*proto.WriteElement, []*proto.Event)

Commit puts state from a batchTxStub cache to the batchStub cache

func (*BatchTxStub) DelState

func (bts *BatchTxStub) DelState(key string) error

DelState marks state in batchTxStub as deleted

func (*BatchTxStub) GetState

func (bts *BatchTxStub) GetState(key string) ([]byte, error)

GetState returns state from batchTxStub cache or, if absent, from batchState cache

func (*BatchTxStub) GetTxID

func (bts *BatchTxStub) GetTxID() string

GetTxID returns batchTxStub transaction ID

func (*BatchTxStub) PutState

func (bts *BatchTxStub) PutState(key string, value []byte) error

PutState puts state to the batchTxStub's cache

func (*BatchTxStub) SetEvent

func (bts *BatchTxStub) SetEvent(name string, payload []byte) error

SetEvent sets payload to a batchTxStub events

type ChainCode

type ChainCode struct {
	// contains filtered or unexported fields
}

ChainCode is a chaincode struct which implements shim.Chaincode interface

func NewCC

func NewCC(
	cc BaseContractInterface,
	options *ContractOptions,
	chOptions ...ChaincodeOption,
) (*ChainCode, error)

NewCC creates new ChainCode

func (*ChainCode) BatchHandler

func (cc *ChainCode) BatchHandler(stub shim.ChaincodeStubInterface, funcName string, fn *Fn, args []string) peer.Response

BatchHandler handles batch process

func (*ChainCode) FetchFnByName

func (cc *ChainCode) FetchFnByName(f string) (*Fn, error)

FetchFnByName fetches function by name

func (*ChainCode) Init

Init initializes chaincode

func (*ChainCode) Invoke

func (cc *ChainCode) Invoke(stub shim.ChaincodeStubInterface) (r peer.Response)

Invoke invokes chaincode

func (*ChainCode) Start

func (cc *ChainCode) Start() error

Start starts chaincode

func (*ChainCode) ValidateTxID

func (cc *ChainCode) ValidateTxID(stub shim.ChaincodeStubInterface) error

ValidateTxID validates tx id

type ChaincodeOption

type ChaincodeOption func(opts *chaincodeOptions) error

ChaincodeOption func for each Opts argument

func WithSrcFS

func WithSrcFS(fs *embed.FS) ChaincodeOption

WithSrcFS specifies a set src fs

type ContractOptions

type ContractOptions struct {
	DisabledFunctions  []string
	DisableSwaps       bool
	DisableMultiSwaps  bool
	TxTTL              uint
	BatchPrefix        string
	NonceTTL           uint
	IsOtherNoncePrefix bool
}

ContractOptions is a struct for contract options

type Doc

type Doc struct {
	ID   string `json:"id"`
	Hash string `json:"hash"`
}

Doc json struct

func DocumentsList

func DocumentsList(stub shim.ChaincodeStubInterface) ([]Doc, error)

DocumentsList returns list of documents

type Fn

type Fn struct {
	// contains filtered or unexported fields
}

Fn is a struct for function

type In

type In struct {
	// contains filtered or unexported fields
}

In is a struct for input parameters

type NonceCheckFn

type NonceCheckFn func(shim.ChaincodeStubInterface, *types.Sender, uint64) error

NonceCheckFn is a function for checking nonce

type StateKey

type StateKey byte

StateKey is a type for state keys

const (
	StateKeyNonce StateKey = iota + 42 // This prefix is used for nons at RU and CH
	StateKeyTokenBalance
	StateKeyAllowedBalance
	StateKeyGivenBalance
	StateKeyLockedTokenBalance
	StateKeyLockedAllowedBalance
	StateKeyPassedNonce // This prefix is used for nones at the US
	StateKeyExternalLockedToken
	StateKeyExternalLockedAllowed
)

StateKey constants

type TxResponse

type TxResponse struct {
	Method     string                    `json:"method"`
	Error      string                    `json:"error,omitempty"`
	Result     string                    `json:"result"`
	Events     map[string][]byte         `json:"events,omitempty"`
	Accounting []*proto.AccountingRecord `json:"accounting"`
}

TxResponse is a response for a single transaction in a batch

Directories

Path Synopsis
big

Jump to

Keyboard shortcuts

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