Documentation ¶
Overview ¶
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- func AddCommands(cli CommandRegistrar)
- func ExtractUnspentTokensFromOutput(output string) ([]*token.UnspentToken, error)
- func GetSigningIdentity(mspConfigPath, mspID, mspType string) (msp.SigningIdentity, error)
- func LoadConfig(s string) (*client.ClientConfig, error)
- func LoadLocalMSPAt(dir, id, mspType string) (msp.MSP, error)
- func LoadLocalMspRecipient(s string) (*token.TokenOwner, error)
- func LoadSerialisedRecipient(serialisedRecipientPath string) ([]byte, error)
- func LoadShares(s string) ([]*token.RecipientShare, error)
- func LoadTokenIDs(s string) ([]*token.TokenId, error)
- func LoadTokenIDsFromFile(s string) ([]*token.TokenId, error)
- func LoadTokenIDsFromJson(s string) ([]*token.TokenId, error)
- func LoadTokenOwner(s string) (*token.TokenOwner, error)
- func SubstituteShareRecipient(shares []*ShellRecipientShare) ([]*token.RecipientShare, error)
- type BaseCmd
- type CommandRegistrar
- type IssueCmd
- type JsonLoader
- type ListTokensCmd
- type Loader
- type OperationResponse
- type OperationResponseParser
- type RedeemCmd
- type ResponseParser
- type ShellRecipientShare
- type Stub
- type StubResponse
- type TokenClientStub
- func (stub *TokenClientStub) Issue(tokensToIssue []*token.Token, waitTimeout time.Duration) (StubResponse, error)
- func (stub *TokenClientStub) ListTokens() (StubResponse, error)
- func (stub *TokenClientStub) Redeem(tokenIDs []*token.TokenId, quantity string, waitTimeout time.Duration) (StubResponse, error)
- func (stub *TokenClientStub) Setup(configPath, channel, mspPath, mspID string) error
- func (stub *TokenClientStub) Transfer(tokenIDs []*token.TokenId, shares []*token.RecipientShare, ...) (StubResponse, error)
- type TransferCmd
- type UnspentTokenResponse
- type UnspentTokenResponseParser
Constants ¶
const ( IssueCommand = "issue" TransferCommand = "transfer" ListTokensCommad = "list" RedeemCommand = "redeem" )
Variables ¶
This section is empty.
Functions ¶
func AddCommands ¶
func AddCommands(cli CommandRegistrar)
AddCommands registers the discovery commands to the given CommandRegistrar
func ExtractUnspentTokensFromOutput ¶
func ExtractUnspentTokensFromOutput(output string) ([]*token.UnspentToken, error)
ExtractUnspentTokensFromOutput extracts token.UnspentToken from the output produced by UnspentTokenResponseParser
func GetSigningIdentity ¶
func GetSigningIdentity(mspConfigPath, mspID, mspType string) (msp.SigningIdentity, error)
GetSigningIdentity retrieves a signing identity from the passed arguments
func LoadConfig ¶
func LoadConfig(s string) (*client.ClientConfig, error)
LoadConfig converts tha passed string to a ClientConfig. The string can be a json string representing the ClientConfig or a path to a file containing a ClientConfig in json format
func LoadLocalMSPAt ¶
LoadLocalMSPAt loads an MSP whose configuration is stored at 'dir', and whose id and type are the passed as arguments.
func LoadLocalMspRecipient ¶
func LoadLocalMspRecipient(s string) (*token.TokenOwner, error)
LoadLocalMspRecipient constructs a TokenOwner from the signing identity at the passed msp location. Expected format of the string is <msp_id>:<path>.
func LoadSerialisedRecipient ¶
LoadSerialisedRecipient loads a serialised identity from file
func LoadShares ¶
func LoadShares(s string) ([]*token.RecipientShare, error)
LoadShares converts the passed string to an array of Shares. The string is either a json representing the shares, or a path to a file containing the json representation.
func LoadTokenIDs ¶
LoadTokenIDs converts the passed string to an array of TokenIDs. The string can be a json representing the TokenIDs, or a path to a fail containing the json representation.
func LoadTokenIDsFromFile ¶
LoadTokenIDsFromFile loads TokenIDs from the passed file supposed to contain a json representation of the TokenIDs.
func LoadTokenIDsFromJson ¶
LoadTokenIDsFromJson interprets the passed string as a json representation of TokenIDs
func LoadTokenOwner ¶
func LoadTokenOwner(s string) (*token.TokenOwner, error)
LoadTokenOwner converts the passed string to a TokenOwner. The string can be the path of the msp configuration, in this case the expected format of the string is <msp_id>:<path>, or the path to a file that contains a serialised identity.
func SubstituteShareRecipient ¶
func SubstituteShareRecipient(shares []*ShellRecipientShare) ([]*token.RecipientShare, error)
SubstituteShareRecipient scans the recipients to see if they need additional post-processing. For example, a recipient can contain the path of a file containing the serialised identity to be loaded.
Types ¶
type BaseCmd ¶
type BaseCmd struct {
// contains filtered or unexported fields
}
BaseCmd contains shared command arguments
func (*BaseCmd) SetChannel ¶
SetChannel sets the channel
func (*BaseCmd) SetMSPPath ¶
SetMSPPath sets the mspPath
type CommandRegistrar ¶
type CommandRegistrar interface { // Command adds a new top-level command to the CLI Command(name, help string, onCommand cmdcommon.CLICommand) *kingpin.CmdClause }
CommandRegistrar registers commands
type IssueCmd ¶
type IssueCmd struct { *BaseCmd // contains filtered or unexported fields }
func NewIssueCmd ¶
func NewIssueCmd(stub Stub, loader Loader, parser ResponseParser) *IssueCmd
func (*IssueCmd) SetClientConfigPath ¶
SetRecipient sets the recipient
func (*IssueCmd) SetQuantity ¶
SetQuantity sets the quantity
func (*IssueCmd) SetRecipient ¶
SetRecipient sets the recipient
type JsonLoader ¶
type JsonLoader struct { }
JsonLoader implements the Loader interface
func (*JsonLoader) Shares ¶
func (*JsonLoader) Shares(s string) ([]*token.RecipientShare, error)
func (*JsonLoader) TokenOwner ¶
func (*JsonLoader) TokenOwner(s string) (*token.TokenOwner, error)
type ListTokensCmd ¶
type ListTokensCmd struct { *BaseCmd // contains filtered or unexported fields }
func NewListTokensCmd ¶
func NewListTokensCmd(stub Stub, parser ResponseParser) *ListTokensCmd
func (*ListTokensCmd) SetClientConfigPath ¶
func (cmd *ListTokensCmd) SetClientConfigPath(clientConfigPath *string)
SetRecipient sets the recipient
type Loader ¶
type Loader interface { // TokenOwner converts a string to a token owner TokenOwner(s string) (*token.TokenOwner, error) // TokenIDs converts a string to a slice of token ids TokenIDs(s string) ([]*token.TokenId, error) Shares(s string) ([]*token.RecipientShare, error) }
Loader converts string to token objects to be used with the Stub
type OperationResponse ¶
type OperationResponseParser ¶
OperationResponseParser parses operation responses
func (*OperationResponseParser) ParseResponse ¶
func (parser *OperationResponseParser) ParseResponse(response StubResponse) error
ParseResponse parses the given response for the given channel
type RedeemCmd ¶
type RedeemCmd struct { *BaseCmd // contains filtered or unexported fields }
func NewRedeemCmd ¶
func NewRedeemCmd(stub Stub, loader Loader, parser ResponseParser) *RedeemCmd
func (*RedeemCmd) SetClientConfigPath ¶
SetClientConfigPath sets the client config path
func (*RedeemCmd) SetQuantity ¶
SetQuantity sets the quantity
func (*RedeemCmd) SetTokenIDs ¶
SetTokenIDs sets the tokenIds
type ResponseParser ¶
type ResponseParser interface { // ParseResponse parses the response and uses the given output when emitting data ParseResponse(response StubResponse) error }
ResponseParser parses responses sent from the server
type ShellRecipientShare ¶
type ShellRecipientShare struct {}
RecipientShare describes how much a recipient will receive in a token transfer
func LoadSharesFromFile ¶
func LoadSharesFromFile(s string) ([]*ShellRecipientShare, error)
LoadSharesFromFile loads from file shares in json representation.
func LoadSharesFromJson ¶
func LoadSharesFromJson(s string) ([]*ShellRecipientShare, error)
LoadSharesFromJson converts the passed json string to shares
type Stub ¶
type Stub interface { // Setup the stub Setup(configFilePath, channel, mspPath, mspID string) error // Issue is the function that the client calls to introduce tokens into the system. Issue(tokensToIssue []*token.Token, waitTimeout time.Duration) (StubResponse, error) // Transfer is the function that the client calls to transfer his tokens. Transfer(tokenIDs []*token.TokenId, shares []*token.RecipientShare, waitTimeout time.Duration) (StubResponse, error) // Redeem allows the redemption of the tokens in the input tokenIDs Redeem(tokenIDs []*token.TokenId, quantity string, waitTimeout time.Duration) (StubResponse, error) // ListTokens allows the client to submit a list request to a prover peer service; ListTokens() (StubResponse, error) }
Stub is a client for the token service
type StubResponse ¶
type StubResponse interface { }
type TokenClientStub ¶
type TokenClientStub struct {
// contains filtered or unexported fields
}
func (*TokenClientStub) Issue ¶
func (stub *TokenClientStub) Issue(tokensToIssue []*token.Token, waitTimeout time.Duration) (StubResponse, error)
func (*TokenClientStub) ListTokens ¶
func (stub *TokenClientStub) ListTokens() (StubResponse, error)
func (*TokenClientStub) Redeem ¶
func (stub *TokenClientStub) Redeem(tokenIDs []*token.TokenId, quantity string, waitTimeout time.Duration) (StubResponse, error)
func (*TokenClientStub) Setup ¶
func (stub *TokenClientStub) Setup(configPath, channel, mspPath, mspID string) error
func (*TokenClientStub) Transfer ¶
func (stub *TokenClientStub) Transfer(tokenIDs []*token.TokenId, shares []*token.RecipientShare, waitTimeout time.Duration) (StubResponse, error)
type TransferCmd ¶
type TransferCmd struct { *BaseCmd // contains filtered or unexported fields }
func NewTransferCmd ¶
func NewTransferCmd(stub Stub, loader Loader, parser ResponseParser) *TransferCmd
func (*TransferCmd) SetClientConfigPath ¶
func (cmd *TransferCmd) SetClientConfigPath(clientConfigPath *string)
SetClientConfigPath sets the client config path
func (*TransferCmd) SetShares ¶
func (cmd *TransferCmd) SetShares(shares *string)
SetShares sets the output shares
func (*TransferCmd) SetTokenIDs ¶
func (cmd *TransferCmd) SetTokenIDs(tokenIDs *string)
SetTokenIDs sets the tokenIds
type UnspentTokenResponse ¶
type UnspentTokenResponse struct {
Tokens []*token.UnspentToken
}
type UnspentTokenResponseParser ¶
UnspentTokenResponseParser parses import responses
func (*UnspentTokenResponseParser) ParseResponse ¶
func (parser *UnspentTokenResponseParser) ParseResponse(response StubResponse) error
ParseResponse parses the given response for the given channel