chaincode

package
v0.0.0-...-8619d99 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChannelHoldingKey

func ChannelHoldingKey(id channel.ID, addr wallet.Address) string

ChannelHoldingKey generates the key for storing holdings on the stub.

func StateRegKey

func StateRegKey(id channel.ID) string

StateRegKey generates the key for storing the channel state on the stub.

func UnmarshalAddress

func UnmarshalAddress(addrStr string) (wallet.Address, error)

UnmarshalAddress implements custom unmarshalling of wallet addresses.

func UnmarshalAddresses

func UnmarshalAddresses(addrsStr string) ([]wallet.Address, error)

UnmarshalAddresses unmarshalls an array of wallet addresses.

func UnmarshalID

func UnmarshalID(idStr string) (adj.AccountID, error)

UnmarshalID unmarshalls a fabric ID.

Types

type Adjudicator

type Adjudicator struct {
	contractapi.Contract
}

Adjudicator is the chaincode that implements the adjudicator.

func (*Adjudicator) BurnToken

func (a *Adjudicator) BurnToken(ctx contractapi.TransactionContextInterface,
	amountStr string) error

BurnToken unmarshalls the given argument to forward the burning request. The callee is derived from the transaction context.

func (*Adjudicator) Deposit

func (a *Adjudicator) Deposit(ctx contractapi.TransactionContextInterface,
	chID channel.ID, partStr string, amountStr string) error

Deposit unmarshalls the given arguments to forward the deposit request.

func (*Adjudicator) Holding

Holding unmarshalls the given arguments to forward the holding request. It returns the holding amount as a marshalled (string) *big.Int.

func (*Adjudicator) MintToken

func (a *Adjudicator) MintToken(ctx contractapi.TransactionContextInterface,
	amountStr string) error

MintToken unmarshalls the given argument to forward the minting request. The callee is derived from the transaction context.

func (*Adjudicator) Register

Register unmarshalls the given argument to forward the register request.

func (*Adjudicator) StateReg

StateReg unmarshalls the given argument to forward the state reg request. It returns the retrieved state reg marshalled as string.

func (*Adjudicator) TokenBalance

TokenBalance unmarshalls the given argument to forward the token balance request. It returns the balance as a marshalled (string) *big.Int.

func (*Adjudicator) TotalHolding

func (a *Adjudicator) TotalHolding(ctx contractapi.TransactionContextInterface,
	id channel.ID, partsStr string) (string, error)

TotalHolding unmarshalls the given arguments to forward the total holding request. It returns the sum of all holding amount of the given participants as a marshalled (string) *big.Int.

func (*Adjudicator) TransferToken

func (a *Adjudicator) TransferToken(ctx contractapi.TransactionContextInterface,
	receiverStr string, amountStr string) error

TransferToken unmarshalls the given arguments to forward the token transfer request. The sender of the tokens is derived from the transaction context.

func (*Adjudicator) Withdraw

Withdraw unmarshalls the given argument to forward the withdrawal request. It returns the withdrawal amount as a marshalled (string) *big.Int.

type AssetHolder

type AssetHolder struct {
	contractapi.Contract
}

AssetHolder is the chaincode that implements the AssetHolder. This skips the checks of the Adjudicator and uses a different ledger to store data. Hence, it is intended for directly testing the AssetHolder chaincode.

func (*AssetHolder) Deposit

func (h *AssetHolder) Deposit(ctx contractapi.TransactionContextInterface,
	id channel.ID, partStr string, amountStr string) error

Deposit unmarshalls the given arguments to forward the deposit request.

func (*AssetHolder) Holding

Holding unmarshalls the given arguments to forward the holding request. It returns the holding amount as a marshalled (string) *big.Int.

func (*AssetHolder) TotalHolding

func (h *AssetHolder) TotalHolding(ctx contractapi.TransactionContextInterface,
	id channel.ID, partsStr string) (string, error)

TotalHolding unmarshalls the given arguments to forward the total holding request. It returns the sum of all holding amount of the given participants as a marshalled (string) *big.Int.

func (*AssetHolder) Withdraw

Withdraw unmarshalls the given argument to forward the withdrawal request. It returns the withdrawal amount as a marshalled (string) *big.Int.

type StubAsset

type StubAsset struct {
	Stub shim.ChaincodeStubInterface
}

StubAsset is an on-chain asset.

func NewStubAsset

NewStubAsset returns an Asset that uses the stub of the transaction context for storing asset holdings.

func (StubAsset) BalanceOf

func (s StubAsset) BalanceOf(id adj.AccountID) (*big.Int, error)

BalanceOf returns the amount of tokens the given id holds. If the id is unknown, zero is returned.

func (StubAsset) Burn

func (s StubAsset) Burn(id adj.AccountID, amount *big.Int) error

Burn removes the desired amount of token from the given id. The id must be the callee of the transaction invoking Burn.

func (StubAsset) Mint

func (s StubAsset) Mint(id adj.AccountID, amount *big.Int) error

Mint creates the desired amount of token for the given id. The id must be the callee of the transaction invoking Mint.

func (StubAsset) Transfer

func (s StubAsset) Transfer(sender adj.AccountID, receiver adj.AccountID, amount *big.Int) error

Transfer checks if the proposed transfer is valid and transfers the given amount of coins from the sender to the receiver. The sender must be the callee of the transaction invoking Transfer.

type StubLedger

type StubLedger struct {
	Stub shim.ChaincodeStubInterface
}

StubLedger is an on-chain ledger.

func NewStubLedger

NewStubLedger returns a ledger that uses the stub of the transaction context for storing information.

func (*StubLedger) GetHolding

func (l *StubLedger) GetHolding(id channel.ID, addr wallet.Address) (*big.Int, error)

GetHolding retrieves the current channel holding of the given address.

func (*StubLedger) GetState

func (l *StubLedger) GetState(id channel.ID) (*adj.StateReg, error)

GetState retrieves the current channel state.

func (*StubLedger) Now

func (l *StubLedger) Now() adj.Timestamp

Now retrieves the transaction timestamp.

func (*StubLedger) PutHolding

func (l *StubLedger) PutHolding(id channel.ID, addr wallet.Address, holding *big.Int) error

PutHolding overwrites the current address channel holdings with the given holding.

func (*StubLedger) PutState

func (l *StubLedger) PutState(sr *adj.StateReg) error

PutState overwrites the current channel state with the given one.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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