token

package
v2.0.0-alpha+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

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

View Source
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

func LoadLocalMSPAt(dir, id, mspType string) (msp.MSP, error)

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

func LoadSerialisedRecipient(serialisedRecipientPath string) ([]byte, error)

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

func LoadTokenIDs(s string) ([]*token.TokenId, error)

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

func LoadTokenIDsFromFile(s string) ([]*token.TokenId, error)

LoadTokenIDsFromFile loads TokenIDs from the passed file supposed to contain a json representation of the TokenIDs.

func LoadTokenIDsFromJson

func LoadTokenIDsFromJson(s string) ([]*token.TokenId, error)

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) GetArgs

func (cmd *BaseCmd) GetArgs() (string, string, string)

GetArgs returns the arguments

func (*BaseCmd) SetChannel

func (cmd *BaseCmd) SetChannel(channel *string)

SetChannel sets the channel

func (*BaseCmd) SetMSPId

func (cmd *BaseCmd) SetMSPId(mspID *string)

SetMSPId sets the mspID

func (*BaseCmd) SetMSPPath

func (cmd *BaseCmd) SetMSPPath(mspPath *string)

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) Execute

func (cmd *IssueCmd) Execute(conf common.Config) error

func (*IssueCmd) SetClientConfigPath

func (cmd *IssueCmd) SetClientConfigPath(clientConfigPath *string)

SetRecipient sets the recipient

func (*IssueCmd) SetQuantity

func (cmd *IssueCmd) SetQuantity(quantity *string)

SetQuantity sets the quantity

func (*IssueCmd) SetRecipient

func (cmd *IssueCmd) SetRecipient(recipient *string)

SetRecipient sets the recipient

func (*IssueCmd) SetType

func (cmd *IssueCmd) SetType(ttype *string)

SetType sets the type

type JsonLoader

type JsonLoader struct {
}

JsonLoader implements the Loader interface

func (*JsonLoader) Shares

func (*JsonLoader) Shares(s string) ([]*token.RecipientShare, error)

func (*JsonLoader) TokenIDs

func (*JsonLoader) TokenIDs(s string) ([]*token.TokenId, 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) Execute

func (cmd *ListTokensCmd) Execute(conf common.Config) error

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 converts a string to a slice of RecipientShare
	Shares(s string) ([]*token.RecipientShare, error)
}

Loader converts string to token objects to be used with the Stub

type OperationResponse

type OperationResponse struct {
	Envelope  *common.Envelope
	TxID      string
	Status    *common.Status
	Committed bool
}

type OperationResponseParser

type OperationResponseParser struct {
	io.Writer
}

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) Execute

func (cmd *RedeemCmd) Execute(conf common.Config) error

func (*RedeemCmd) SetClientConfigPath

func (cmd *RedeemCmd) SetClientConfigPath(clientConfigPath *string)

SetClientConfigPath sets the client config path

func (*RedeemCmd) SetQuantity

func (cmd *RedeemCmd) SetQuantity(quantity *string)

SetQuantity sets the quantity

func (*RedeemCmd) SetTokenIDs

func (cmd *RedeemCmd) SetTokenIDs(tokenIDs *string)

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 {
	Recipient string
	Quantity  string
}

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) Execute

func (cmd *TransferCmd) Execute(conf common.Config) error

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

type UnspentTokenResponseParser struct {
	io.Writer
}

UnspentTokenResponseParser parses import responses

func (*UnspentTokenResponseParser) ParseResponse

func (parser *UnspentTokenResponseParser) ParseResponse(response StubResponse) error

ParseResponse parses the given response for the given channel

Directories

Path Synopsis
Code generated by mockery v1.0.0.
Code generated by mockery v1.0.0.

Jump to

Keyboard shortcuts

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