Documentation ¶
Index ¶
- func ChannelHoldingKey(id channel.ID, addr wallet.Address) string
- func StateRegKey(id channel.ID) string
- func UnmarshalAddress(addrStr string) (wallet.Address, error)
- func UnmarshalAddresses(addrsStr string) ([]wallet.Address, error)
- func UnmarshalID(idStr string) (adj.AccountID, error)
- type Adjudicator
- func (a *Adjudicator) BurnToken(ctx contractapi.TransactionContextInterface, amountStr string) error
- func (a *Adjudicator) Deposit(ctx contractapi.TransactionContextInterface, chID channel.ID, partStr string, ...) error
- func (a *Adjudicator) Holding(ctx contractapi.TransactionContextInterface, id channel.ID, partStr string) (string, error)
- func (a *Adjudicator) MintToken(ctx contractapi.TransactionContextInterface, amountStr string) error
- func (a *Adjudicator) Register(ctx contractapi.TransactionContextInterface, chStr string) error
- func (a *Adjudicator) StateReg(ctx contractapi.TransactionContextInterface, id channel.ID) (string, error)
- func (a *Adjudicator) TokenBalance(ctx contractapi.TransactionContextInterface, id string) (string, error)
- func (a *Adjudicator) TotalHolding(ctx contractapi.TransactionContextInterface, id channel.ID, partsStr string) (string, error)
- func (a *Adjudicator) TransferToken(ctx contractapi.TransactionContextInterface, receiverStr string, ...) error
- func (a *Adjudicator) Withdraw(ctx contractapi.TransactionContextInterface, reqStr string) (string, error)
- type AssetHolder
- func (h *AssetHolder) Deposit(ctx contractapi.TransactionContextInterface, id channel.ID, partStr string, ...) error
- func (h *AssetHolder) Holding(ctx contractapi.TransactionContextInterface, id channel.ID, partStr string) (string, error)
- func (h *AssetHolder) TotalHolding(ctx contractapi.TransactionContextInterface, id channel.ID, partsStr string) (string, error)
- func (h *AssetHolder) Withdraw(ctx contractapi.TransactionContextInterface, id channel.ID, partStr string) (string, error)
- type StubAsset
- type StubLedger
- func (l *StubLedger) GetHolding(id channel.ID, addr wallet.Address) (*big.Int, error)
- func (l *StubLedger) GetState(id channel.ID) (*adj.StateReg, error)
- func (l *StubLedger) Now() adj.Timestamp
- func (l *StubLedger) PutHolding(id channel.ID, addr wallet.Address, holding *big.Int) error
- func (l *StubLedger) PutState(sr *adj.StateReg) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChannelHoldingKey ¶
ChannelHoldingKey generates the key for storing holdings on the stub.
func StateRegKey ¶
StateRegKey generates the key for storing the channel state on the stub.
func UnmarshalAddress ¶
UnmarshalAddress implements custom unmarshalling of wallet addresses.
func UnmarshalAddresses ¶
UnmarshalAddresses unmarshalls an array of wallet addresses.
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 ¶
func (a *Adjudicator) Holding(ctx contractapi.TransactionContextInterface, id channel.ID, partStr string) (string, error)
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 ¶
func (a *Adjudicator) Register(ctx contractapi.TransactionContextInterface, chStr string) error
Register unmarshalls the given argument to forward the register request.
func (*Adjudicator) StateReg ¶
func (a *Adjudicator) StateReg(ctx contractapi.TransactionContextInterface, id channel.ID) (string, error)
StateReg unmarshalls the given argument to forward the state reg request. It returns the retrieved state reg marshalled as string.
func (*Adjudicator) TokenBalance ¶
func (a *Adjudicator) TokenBalance(ctx contractapi.TransactionContextInterface, id string) (string, error)
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 ¶
func (a *Adjudicator) Withdraw(ctx contractapi.TransactionContextInterface, reqStr string) (string, error)
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 ¶
func (h *AssetHolder) Holding(ctx contractapi.TransactionContextInterface, id channel.ID, partStr string) (string, error)
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 ¶
func (h *AssetHolder) Withdraw(ctx contractapi.TransactionContextInterface, id channel.ID, partStr string) (string, error)
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 ¶
func NewStubAsset(ctx contractapi.TransactionContextInterface) *StubAsset
NewStubAsset returns an Asset that uses the stub of the transaction context for storing asset holdings.
func (StubAsset) BalanceOf ¶
BalanceOf returns the amount of tokens the given id holds. If the id is unknown, zero is returned.
func (StubAsset) Burn ¶
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 ¶
Mint creates the desired amount of token for the given id. The id must be the callee of the transaction invoking Mint.
type StubLedger ¶
type StubLedger struct {
Stub shim.ChaincodeStubInterface
}
StubLedger is an on-chain ledger.
func NewStubLedger ¶
func NewStubLedger(ctx contractapi.TransactionContextInterface) *StubLedger
NewStubLedger returns a ledger that uses the stub of the transaction context for storing information.
func (*StubLedger) GetHolding ¶
GetHolding retrieves the current channel holding of the given address.
func (*StubLedger) Now ¶
func (l *StubLedger) Now() adj.Timestamp
Now retrieves the transaction timestamp.
func (*StubLedger) PutHolding ¶
PutHolding overwrites the current address channel holdings with the given holding.