Skip to content
This repository was archived by the owner on Feb 9, 2021. It is now read-only.

Commit 6d0f535

Browse files
committed
Import release v0.9.2
This is a legacy import of the release originally managed in pure github. You may find the history of this release in the archives here: https://github.com/hyperledger-archives/fabric-chaintool/releases/tag/v0.9.2 Change-Id: Ie550b43bed85c66a5b90733bd686000645ea4914 Signed-off-by: Gregory Haskins <gregory.haskins@gmail.com>
1 parent 3c23654 commit 6d0f535

File tree

9 files changed

+63
-11
lines changed

9 files changed

+63
-11
lines changed

examples/invoker/src/chaincode/chaincode.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ specific language governing permissions and limitations
1717
under the License.
1818
*/
1919

20-
package chaincode
20+
package main
2121

2222
import (
2323
"fmt"
@@ -90,7 +90,7 @@ func (t *ChaincodeExample) CheckBalance(stub shim.ChaincodeStubInterface, param
9090

9191
func main() {
9292
self := &ChaincodeExample{}
93-
interfaces := ccs.Interfaces {
93+
interfaces := ccs.Interfaces{
9494
"org.hyperledger.chaincode.example02": self,
9595
"appinit": self,
9696
}

project.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
(defproject chaintool "0.9.1"
2-
:description "hyperledger chaincode tool"
3-
:url "https://github.com/ghaskins/chaintool"
1+
(defproject chaintool "0.9.2"
2+
:description "Hyperledger Fabric chaincode tool"
3+
:url "https://github.com/hyperledger/fabric-chaintool"
44
:license {:name "Apache License"
55
:url "http://www.apache.org/licenses/LICENSE-2.0.txt"}
66
:min-lein-version "2.0.0"

resources/generators/golang.stg

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,19 +424,26 @@ implementclient(txn, intf, func) ::=
424424
func <func.name>(stub shim.ChaincodeStubInterface, chaincodeName string<if(func.param)>, params *<func.param><endif>) <\\>
425425
<if(func.rettype)>(*<func.rettype>, error)<else>error<endif> {
426426

427-
args := make([]string, 1)
427+
<if(func.param)>
428+
args := make([][]byte, 2)
429+
<else>
430+
args := make([][]byte, 1)
431+
<endif>
428432
var err error
429433

434+
args[0] = []byte(<compositename(txn, intf, func)>)
435+
430436
<if(func.param)>
431437
_pboutput, err := proto.Marshal(params)
432438
if (err != nil) {
433439
return <if(func.rettype)>nil, <endif>err
434440
}
435441

436-
args[0] = base64.StdEncoding.EncodeToString(_pboutput)
442+
args[1] = make([]byte, base64.StdEncoding.EncodedLen(len(_pboutput)))
443+
base64.StdEncoding.Encode(args[1], _pboutput)
437444
<endif>
438445

439-
<if(func.rettype)>_result, err :=<else>_, err =<endif> stub.<if(txn)>Invoke<else>Query<endif>Chaincode(chaincodeName, <compositename(txn, intf, func)>, args)
446+
<if(func.rettype)>_result, err :=<else>_, err =<endif> stub.<if(txn)>Invoke<else>Query<endif>Chaincode(chaincodeName, args)
440447

441448
<if(func.rettype)>
442449
result := &<func.rettype>{}

src/chaintool/build/core.clj

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
1616
[chaintool.platforms.api :as platforms.api])
1717
(:refer-clojure :exclude [compile]))
1818

19-
(defn compile [{:keys [config] :as params}]
19+
20+
(defn- run [fcn {:keys [config] :as params}]
2021
(when-let [platform (platforms.core/find config)]
21-
;; generate platform output (shim, protobufs, etc)
22-
(platforms.api/build platform params)))
22+
(fcn platform params)))
23+
24+
;; generate platform output (shim, protobufs, etc)
25+
(defn compile [params]
26+
(run platforms.api/build params))
27+
28+
;; display environment variables used for build
29+
(defn env [params]
30+
(run platforms.api/env params))

src/chaintool/core.clj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
[chaintool.subcommands.package :as packagecmd]
2222
[chaintool.subcommands.proto :as protocmd]
2323
[chaintool.subcommands.unpack :as unpackcmd]
24+
[chaintool.subcommands.env :as envcmd]
2425
[chaintool.util :as util]
2526
[clojure.string :as string]
2627
[clojure.tools.cli :refer [parse-opts]]
@@ -78,6 +79,10 @@
7879
:validate (fn [options arguments] (= (count arguments) 1))
7980
:options common-options}
8081

82+
{:name "env" :desc "Display variables used in the build environment"
83+
:handler envcmd/run
84+
:options common-path-options}
85+
8186
{:name "proto" :desc "Compiles a CCI file to a .proto"
8287
:handler protocmd/run
8388
:arguments "path/to/file.cci"

src/chaintool/platforms/api.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
(ns chaintool.platforms.api)
1616

1717
(defprotocol Platform
18+
;; Displays environment variables relevant to the build environment
19+
(env [this params])
1820
;; Compiles the platform
1921
(build [this params])
2022
;; Cleans any previous builds of the platform

src/chaintool/platforms/golang/system.clj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
(deftype GolangSystemPlatform []
4242
platforms.api/Platform
4343

44+
;;-----------------------------------------------------------------
45+
;; env - Emits the GOPATH used for building system chaincode
46+
;;-----------------------------------------------------------------
47+
(env [_ _])
48+
4449
;;-----------------------------------------------------------------
4550
;; build - generates all golang platform artifacts within the
4651
;; default location in the build area

src/chaintool/platforms/golang/userspace.clj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
(deftype GolangUserspacePlatform []
3131
platforms.api/Platform
3232

33+
;;-----------------------------------------------------------------
34+
;; env - Emits the GOPATH used for building golang chaincode
35+
;;-----------------------------------------------------------------
36+
(env [_ {:keys [path]}]
37+
(println (str "GOPATH=" (buildgopath path))))
38+
3339
;;-----------------------------------------------------------------
3440
;; build - generates all golang platform artifacts within the
3541
;; default location in the build area

src/chaintool/subcommands/env.clj

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
;; Licensed under the Apache License, Version 2.0 (the "License");
2+
;; you may not use this file except in compliance with the License.
3+
;; You may obtain a copy of the License at
4+
;;
5+
;; http://www.apache.org/licenses/LICENSE-2.0
6+
;;
7+
;; Unless required by applicable law or agreed to in writing, software
8+
;; distributed under the License is distributed on an "AS IS" BASIS,
9+
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
;; See the License for the specific language governing permissions and
11+
;; limitations under the License.
12+
13+
(ns chaintool.subcommands.env
14+
(:require [chaintool.config.util :as config.util]
15+
[chaintool.build.core :as build.core]))
16+
17+
(defn run [options args]
18+
(let [[path config] (config.util/load-from-options options)]
19+
(build.core/env {:path path :config config})))

0 commit comments

Comments
 (0)