contract

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2019 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Overview

Package contract implements generate and deploy chaincode for hyperledger fabric

Package contract implements generate and deploy chaincode for hyperledger fabric

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func NewGenerator

func NewGenerator(opts *GenOptions) contract.Generator

NewGenerator is the generator constructor

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type DeployOption added in v0.1.3

type DeployOption func(d *Deployer, opts *Options) error

DeployOption func for each Opts argument

func WithChaincodeID added in v0.1.3

func WithChaincodeID(ccID string) DeployOption

WithChaincodeID sets the ID of the chaincode to be deployed

func WithChaincodeInitArgs added in v0.1.3

func WithChaincodeInitArgs(ccArgs string) DeployOption

WithChaincodeInitArgs sets the init-args for instantiating the chaincode

func WithChaincodePath added in v0.1.3

func WithChaincodePath(ccPath string) DeployOption

WithChaincodePath sets the chaincode source code location, which should be the full path of the generated source code folder

func WithChaincodePolicy added in v0.1.3

func WithChaincodePolicy(ccPolicy string) DeployOption

WithChaincodePolicy sets the policy for instantiating the chaincode

func WithChaincodeVersion added in v0.1.3

func WithChaincodeVersion(ccVersion string) DeployOption

WithChaincodeVersion sets the version of the chaincode to be deployed

func WithChannelID added in v0.1.3

func WithChannelID(channelID string) DeployOption

WithChannelID sets the Fabric channel for instantiating the chaincode

func WithFabricConfig added in v0.1.3

func WithFabricConfig(configFiles ...string) DeployOption

WithFabricConfig sets the local fabric network config yaml and entity matcher override file if necessary

func WithOrgName added in v0.1.3

func WithOrgName(org string) DeployOption

WithOrgName sets org name of a fabric network member

func WithUserName added in v0.1.3

func WithUserName(user string) DeployOption

WithUserName sets admin user name of the org

type Deployer

type Deployer struct {
}

Deployer defines the deployer attributes

func (*Deployer) Deploy

func (d *Deployer) Deploy(options ...DeployOption) error

Deploy deploys a smart contract for the given options

func (*Deployer) Instantiate added in v0.1.3

func (d *Deployer) Instantiate(options ...DeployOption) error

Instantiate starts instances for a smart contract on specified channel and org

type GenOptions

type GenOptions struct {
	TargetDir         string
	ModelFile         string
	Version           string
	EnableTxnSecurity bool
}

GenOptions defines the generator options

func NewGenOptions

func NewGenOptions(targetPath, modelFile, version string, enableSecurity bool) *GenOptions

NewGenOptions is the options constructor

type Generator

type Generator struct {
	Opts *GenOptions
}

Generator defines the generator attributes

func (*Generator) Generate

func (d *Generator) Generate() error

Generate generates a smart contract for the given options

type Options

type Options struct {
	ChaincodeID         string
	ChaincodePath       string
	ChaincodeRoot       string
	ChaincodeVersion    string
	NetworkConfigPath   string
	NetworkOverridePath string
	UserName            string
	OrgName             string
	ChaincodePolicy     string
	ChaincodeInitArgs   string
	ChannelID           string
}

Options defines the deployer options

type ResourceRef

type ResourceRef struct {
	Name string
	Ref  string
	ID   string
}

type TemplateData

type TemplateData struct {
	CCName            string
	ActivityRefs      map[string]ResourceRef
	TriggerRefs       map[string]ResourceRef
	Functions         map[string]string
	EnableTxnSecurity bool
}

Jump to

Keyboard shortcuts

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