Compare commits

...

959 commits

Author SHA1 Message Date
James Taylor
a2c40e6522
test-network-k8s: ghcr.io for Hyperledger images (#1416)
Some checks failed
Test Network BFT Orderer 🍟 / basic (java, cryptogen) (push) Has been cancelled
Test Network BFT Orderer 🍟 / basic (javascript, ca) (push) Has been cancelled
Test Network BFT Orderer 🍟 / basic (javascript, cryptogen) (push) Has been cancelled
Test Network BFT Orderer 🍟 / basic (typescript, ca) (push) Has been cancelled
Test Network BFT Orderer 🍟 / basic (typescript, cryptogen) (push) Has been cancelled
Test Network Events 💡 / events (go, events) (push) Has been cancelled
Test Network Events 💡 / events (java, events) (push) Has been cancelled
Test Network Events 💡 / events (javascript, events) (push) Has been cancelled
Test Network HSM 🍏 / hsm (go) (push) Has been cancelled
Test Network HSM 🍏 / hsm (java) (push) Has been cancelled
Test Network HSM 🍏 / hsm (javascript) (push) Has been cancelled
Test Network HSM 🍏 / hsm (typescript) (push) Has been cancelled
Kubernetes Test Network 🍒 / ccaas-java (push) Has been cancelled
Kubernetes Test Network 🍒 / ccaas-external (push) Has been cancelled
Kubernetes Test Network 🍒 / k8s-builder (push) Has been cancelled
Kubernetes Test Network 🍒 / multi-namespace (push) Has been cancelled
Kubernetes Test Network 🍒 / bft-orderer (push) Has been cancelled
Test Network Ledger 🥑 / basic (go, ledger) (push) Has been cancelled
Test Network Ledger 🥑 / basic (javascript, ledger) (push) Has been cancelled
Test Network Ledger 🥑 / basic (typescript, ledger) (push) Has been cancelled
Test Network Off Chain 🍔 / off-chain (go) (push) Has been cancelled
Test Network Off Chain 🍔 / off-chain (java) (push) Has been cancelled
Test Network Off Chain 🍔 / off-chain (javascript) (push) Has been cancelled
Test Network Off Chain 🍔 / off-chain (typescript) (push) Has been cancelled
Test Network Private 🔒 / private (go, private) (push) Has been cancelled
Test Network Private 🔒 / private (java, private) (push) Has been cancelled
Test Network Private 🔒 / private (typescript, private) (push) Has been cancelled
Test Network SBE 🎵 / SBE (java, sbe) (push) Has been cancelled
Test Network SBE 🎵 / SBE (typescript, sbe) (push) Has been cancelled
Test Network Secured 🔔 / secured (go, secured) (push) Has been cancelled
Default to using ghcr.io for Hyperledger images in the k8s test network

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2026-05-21 11:30:24 +01:00
Arnav Vinod Deshpande
d999452f88
weak ordering implementation in sort.slice (#1414)
Signed-off-by: rootp1 <arnav.iitr@gmail.com>
2026-05-05 11:47:26 +01:00
dependabot[bot]
bf7e75c6c1
Bump actions/upload-artifact from 7.0.0 to 7.0.1 (#1401)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-13 10:36:17 +01:00
dependabot[bot]
33ecb67a89 Bump the npm_and_yarn group across 2 directories with 1 update
Bumps the npm_and_yarn group with 1 update in the /asset-transfer-basic/rest-api-typescript directory: [axios](https://github.com/axios/axios).
Bumps the npm_and_yarn group with 1 update in the /full-stack-asset-transfer-guide/applications/conga-cards directory: [axios](https://github.com/axios/axios).


Updates `axios` from 1.13.5 to 1.15.0
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.13.5...v1.15.0)

Updates `axios` from 1.13.5 to 1.15.0
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.13.5...v1.15.0)

---
updated-dependencies:
- dependency-name: axios
  dependency-version: 1.15.0
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: axios
  dependency-version: 1.15.0
  dependency-type: direct:production
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-13 12:32:39 +09:00
dependabot[bot]
da2240f993
Bump actions/upload-artifact from 6.0.0 to 7.0.0 (#1389)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-02 10:12:58 +00:00
dependabot[bot]
d845f6f47b
Bump @angular/core in rest-api-typescript (#1388)
- Updates `bn.js` from 4.12.0 to 4.12.3
- Updates `minimatch` from 3.1.2 to 3.1.5
- Updates `@angular/core` from 14.3.0 to 21.2.0

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-27 11:29:33 +00:00
dependabot[bot]
3ec2523ec7
Bump asset-transfer-basic/rest-api-typescript dependencies (#1381)
- Updates `js-yaml` from 3.14.1 to 3.14.2
- Updates `axios` from 1.11.0 to 1.13.5
- Updates `body-parser` from 2.2.0 to 2.2.2
- Updates `lodash` from 4.17.21 to 4.17.23
- Updates `qs` from 6.14.0 to 6.15.0
- Updates `tmp` from 0.0.33 to 0.2.5
- Updates `validator` from 13.11.0 to 13.15.26
- Updates `@angular/common` from 14.3.0 to 21.1.5
- Updates `@angular/compiler` from 14.3.0 to 21.1.5

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-27 09:48:51 +00:00
Mark S. Lewis
80a29f44af
Update Fabric to v2.5.15 and v3.1.4 (#1385)
These Fabric versions resolve compatibility issues with Docker engine
v29.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2026-02-27 11:14:28 +09:00
Mark S. Lewis
42ff1e629b
Fix ESLint failures (#1386)
- Updates to ESLint v10 and fixes lint failures.
- Aligns tsconfig on Node 20, which is the current minimum required Node
  version.
- Adds package-lock.json files to source control to avoid future random
  failures when dependencies update.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2026-02-26 13:20:40 +09:00
dependabot[bot]
4f70b668aa
Bump token-sdk indirect dependencies (#1382)
Updates `github.com/sirupsen/logrus` from 1.9.0 to 1.9.1
Updates `golang.org/x/crypto` from 0.40.0 to 0.45.0
Updates `github.com/sirupsen/logrus` from 1.8.1 to 1.8.3
Updates `github.com/consensys/gnark-crypto` from 0.12.1 to 0.18.1

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-22 20:45:07 +00:00
Tatsuya Sato
385a35b744
Fix KIND cluster creation for test-network-k8s (#1375)
This PR replaces deprecated containerd registry.mirrors configuration with
config_path mode and hosts.toml, required for containerd 2.x
(KIND v0.27.0+). The old configuration prevents the CRI plugin
from loading, causing kubelet to fail on startup.

Also, this fixes CA enrollment in create_node_local_MSP() to specify
port 443 explicitly, and other minor issues, including removing
redundant throws from Java close() methods.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
Co-authored-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2026-02-09 10:16:42 +00:00
dependabot[bot]
d669a3fccf
Bump actions/checkout from 5 to 6 (#1365)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-24 11:51:42 +00:00
Mark S. Lewis
5e9b5f725b Remove empty test-network Docker Compose files
Empty Docker Conpose YAML files can cause errors with old Docker Compose
versions due to bugs in their YAML handling. Since these files are empty
and have no functional purpose, this change removes the files and
references to them in scripts.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-11-17 13:29:14 -05:00
Mark S. Lewis
bdaeac199d
Update Go error handling for v1.10 client API (#1362)
The Fabric Gateway client API v1.10.0 provides simplified access to Go
error details. This change updates sample client application to use this
latest version of the client API, and updates Go client applications to
reflect the error handling changes.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-11-10 09:53:58 +09:00
Mark S. Lewis
f865a9ea51
Fix private-data TypeScript chaincode (#1357)
The build is only testing the Go chaincode for the
asset-transfer-private-data sample. The behavior of the TypeScript
chaincode implementation is not consistent with the Go and Java
versions, which prevents it from working correctly.

This change fixes the TypeScript chaincode implementation for the
asset-transfer-private-data sample so that it works correctly.
Additionally, some JSON property names are explicitly set in the Go
client application sample, which prevented it from working with the Java
and TypeScript chaincode implementations.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-11-04 10:55:27 -05:00
Mark S. Lewis
a72b2b5132
Remove obsolete version element from compose files (#1361)
The version element is obsolete and unused since Compose v1 was
deprecated in favour of Compose v2 in 2022, and reached end-of-life in
2023. The version element generates warning messages running Docker
Compose commands when bringing up and down the test-network, which
adds unnecessary noise and can be confusing for users.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-11-04 10:52:28 -05:00
dulanting
a35f8b7cfc chore: remove repetitive words
Signed-off-by: dulanting <dulanting@outlook.jp>
2025-10-28 17:13:19 +09:00
dependabot[bot]
be2b835d4c
Bump brace-expansion from 1.1.11 to 1.1.12 (#1350)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-24 22:40:24 +01:00
Mark S. Lewis
c5539270f6
Update runtime and tool versions (#1354)
- Node latest LTS
- Go latest stable
- Fabric 2.5.14, 3.1.3
- Just 1.43.0
- k9s 0.50.15
- Kind 0.30.0
- yq 4.48.1
- nvm 0.40.3

This addresses build breakages due to back-level versions.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-10-21 13:04:55 -04:00
dependabot[bot]
918077e4de
Bump actions/setup-java from 4 to 5 (#1346)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-21 10:55:07 +01:00
dependabot[bot]
74b73003e4
Bump actions/setup-node from 5 to 6 (#1355)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-21 09:57:36 +01:00
dependabot[bot]
dd3aab87ce
Bump quic-go from 0.48.2 to 0.49.1 (#1353)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-21 09:50:10 +01:00
dependabot[bot]
301db81411
Bump actions/checkout from 4 to 5 (#1345)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-19 00:56:35 +01:00
Mark S. Lewis
62f51d3efb
Support Java 25 (#1352)
- Update Gradle to 9.1.0.
- Update shadow plugin to 9.2.2.
- Requires a minimum of Java 17 to run Gradle.
- Chaincode and applications still target Java 11.
- Use release option instead of Gradle toolchain since the toolchain
  download can cause issues when building Docker images.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-10-06 12:26:52 -04:00
Mark S. Lewis
6130e1b9e8
Fix high-throughput sample (#1351)
Build failures because the startFabric.sh script specified that the
chaincode required initialization, which is both legacy behavior and is
unnecessary.

The chaincode is updated to use the Contract API instead of the legacy /
low-level chaincode API. The client application is also simplified.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-10-06 21:36:09 +09:00
dependabot[bot]
ad1950554d
Bump actions/setup-node from 4 to 5 (#1348)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-09-09 09:35:08 +01:00
Mark S. Lewis
1a0afd858d
Use Gradle wrapper in asset-transfer-ledger-queries (#1349)
The CI script invoked Gradle directly, which could picker newer Gradle
versions not compatible with the build definition. This change uses the
Gradle wrapper included in the client application sample.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-09-09 10:08:28 +09:00
dependabot[bot]
7f0f4a24fa
Bump the go_modules group across 17 directories with 2 updates (#1342)
- Updates `golang.org/x/net` from 0.34.0 to 0.38.0
- Updates `github.com/getkin/kin-openapi` from 0.120.0 to 0.131.0

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-28 18:10:42 +01:00
dependabot[bot]
5c09f5d619
Bump the go_modules group across 5 directories with 3 updates (#1341)
- Updates `golang.org/x/net` from 0.38.0 to 0.42.0
- Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6
- Updates `github.com/golang/glog` from 1.2.4 to 1.2.5

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-28 14:09:02 +01:00
James Taylor
4dd37dd29b
test-network-k8s: bump fabric-builder-k8s (#1340)
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2025-07-28 12:33:42 +01:00
dependabot[bot]
7e1ddbccc0 Bump the go_modules group across 6 directories with 4 updates
Bumps the go_modules group with 1 update in the /high-throughput/application-go directory: [golang.org/x/net](https://github.com/golang/net).
Bumps the go_modules group with 2 updates in the /high-throughput/chaincode-go directory: [golang.org/x/net](https://github.com/golang/net) and google.golang.org/protobuf.
Bumps the go_modules group with 4 updates in the /token-sdk/auditor directory: [golang.org/x/net](https://github.com/golang/net), google.golang.org/protobuf, [github.com/golang/glog](https://github.com/golang/glog) and [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang).
Bumps the go_modules group with 2 updates in the /token-sdk/e2e directory: [golang.org/x/net](https://github.com/golang/net) and google.golang.org/protobuf.
Bumps the go_modules group with 4 updates in the /token-sdk/issuer directory: [golang.org/x/net](https://github.com/golang/net), google.golang.org/protobuf, [github.com/golang/glog](https://github.com/golang/glog) and [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang).
Bumps the go_modules group with 4 updates in the /token-sdk/owner directory: [golang.org/x/net](https://github.com/golang/net), google.golang.org/protobuf, [github.com/golang/glog](https://github.com/golang/glog) and [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang).


Updates `golang.org/x/net` from 0.41.0 to 0.42.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `golang.org/x/net` from 0.41.0 to 0.42.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `golang.org/x/net` from 0.41.0 to 0.42.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `golang.org/x/net` from 0.41.0 to 0.42.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `golang.org/x/net` from 0.41.0 to 0.42.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `golang.org/x/net` from 0.41.0 to 0.42.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `golang.org/x/net` from 0.9.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.30.0 to 1.33.0

Updates `golang.org/x/net` from 0.9.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.30.0 to 1.33.0

Updates `golang.org/x/net` from 0.9.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.30.0 to 1.33.0

Updates `golang.org/x/net` from 0.9.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.30.0 to 1.33.0

Updates `golang.org/x/net` from 0.9.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.30.0 to 1.33.0

Updates `golang.org/x/net` from 0.9.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.30.0 to 1.33.0

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `github.com/golang/glog` from 1.1.0 to 1.2.4
- [Release notes](https://github.com/golang/glog/releases)
- [Commits](https://github.com/golang/glog/compare/v1.1.0...v1.2.4)

Updates `github.com/prometheus/client_golang` from 1.19.1 to 1.22.0
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.19.1...v1.22.0)

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `github.com/golang/glog` from 1.1.0 to 1.2.4
- [Release notes](https://github.com/golang/glog/releases)
- [Commits](https://github.com/golang/glog/compare/v1.1.0...v1.2.4)

Updates `github.com/prometheus/client_golang` from 1.19.1 to 1.22.0
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.19.1...v1.22.0)

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `github.com/golang/glog` from 1.1.0 to 1.2.4
- [Release notes](https://github.com/golang/glog/releases)
- [Commits](https://github.com/golang/glog/compare/v1.1.0...v1.2.4)

Updates `github.com/prometheus/client_golang` from 1.19.1 to 1.22.0
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.19.1...v1.22.0)

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `golang.org/x/net` from 0.21.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `golang.org/x/net` from 0.21.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `golang.org/x/net` from 0.21.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `golang.org/x/net` from 0.21.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `golang.org/x/net` from 0.21.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `golang.org/x/net` from 0.21.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `github.com/golang/glog` from 1.1.0 to 1.2.4
- [Release notes](https://github.com/golang/glog/releases)
- [Commits](https://github.com/golang/glog/compare/v1.1.0...v1.2.4)

Updates `github.com/prometheus/client_golang` from 1.19.1 to 1.22.0
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.19.1...v1.22.0)

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `github.com/golang/glog` from 1.1.0 to 1.2.4
- [Release notes](https://github.com/golang/glog/releases)
- [Commits](https://github.com/golang/glog/compare/v1.1.0...v1.2.4)

Updates `github.com/prometheus/client_golang` from 1.19.1 to 1.22.0
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.19.1...v1.22.0)

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `github.com/golang/glog` from 1.1.0 to 1.2.4
- [Release notes](https://github.com/golang/glog/releases)
- [Commits](https://github.com/golang/glog/compare/v1.1.0...v1.2.4)

Updates `github.com/prometheus/client_golang` from 1.19.1 to 1.22.0
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.19.1...v1.22.0)

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `github.com/golang/glog` from 1.1.0 to 1.2.4
- [Release notes](https://github.com/golang/glog/releases)
- [Commits](https://github.com/golang/glog/compare/v1.1.0...v1.2.4)

Updates `github.com/prometheus/client_golang` from 1.19.1 to 1.22.0
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.19.1...v1.22.0)

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `github.com/golang/glog` from 1.1.0 to 1.2.4
- [Release notes](https://github.com/golang/glog/releases)
- [Commits](https://github.com/golang/glog/compare/v1.1.0...v1.2.4)

Updates `github.com/prometheus/client_golang` from 1.19.1 to 1.22.0
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.19.1...v1.22.0)

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

Updates `github.com/golang/glog` from 1.1.0 to 1.2.4
- [Release notes](https://github.com/golang/glog/releases)
- [Commits](https://github.com/golang/glog/compare/v1.1.0...v1.2.4)

Updates `github.com/prometheus/client_golang` from 1.19.1 to 1.22.0
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.19.1...v1.22.0)

Updates `golang.org/x/net` from 0.28.0 to 0.38.0
- [Commits](https://github.com/golang/net/compare/v0.41.0...v0.42.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.36.6

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.42.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.42.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.42.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.42.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.42.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.42.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.33.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.33.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.33.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.33.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.33.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.33.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/golang/glog
  dependency-version: 1.2.4
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/prometheus/client_golang
  dependency-version: 1.22.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/golang/glog
  dependency-version: 1.2.4
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/prometheus/client_golang
  dependency-version: 1.22.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/golang/glog
  dependency-version: 1.2.4
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/prometheus/client_golang
  dependency-version: 1.22.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/golang/glog
  dependency-version: 1.2.4
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/prometheus/client_golang
  dependency-version: 1.22.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/golang/glog
  dependency-version: 1.2.4
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/prometheus/client_golang
  dependency-version: 1.22.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/golang/glog
  dependency-version: 1.2.4
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/prometheus/client_golang
  dependency-version: 1.22.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/golang/glog
  dependency-version: 1.2.4
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/prometheus/client_golang
  dependency-version: 1.22.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/golang/glog
  dependency-version: 1.2.4
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/prometheus/client_golang
  dependency-version: 1.22.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/golang/glog
  dependency-version: 1.2.4
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: github.com/prometheus/client_golang
  dependency-version: 1.22.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.36.6
  dependency-type: indirect
  dependency-group: go_modules
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-27 20:42:54 -04:00
Mark S. Lewis
4c97d4c12b
Use Fabric Gateway client API in high-throughput (#1338)
The high-throughput sample used the deprecated Go SDK. This change
updates the sample to use the currently supported Fabric Gateway client
API and adds some automated testing to ensure the sample works
correctly.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-07-27 14:47:22 -04:00
dependabot[bot]
84089e8ee3
Bump express and @types/express (#1337)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-25 11:15:50 +01:00
Mark S. Lewis
7bee4f76d0
Update fabric-gateway to v1.8.0 (#1336)
Node 20+ is now required. This is the oldest currently support LTS
version of Node.js.

Docker images are moved to Node 22, which is the current LTS release.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-07-25 17:10:49 +09:00
Mark S. Lewis
4fabd87648 Enhance Go off_chain_data for consistency
Add some methods to the parsing API within the Go off_chain_data sample
for consistency with the Node and Java implementations:

- ToProto() on Block, Transaction and NamespaceReadWriteSet.
- ValidationCode() on Transaction.
- Creator() on Transaction

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-07-24 16:58:06 +09:00
Tatsuya Sato
cc85f96d9e
Bump fabric to v2.5.13 and v3.1.1 (#1328)
Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2025-05-12 09:08:44 +01:00
David Enyeart
5fa5abbbcf Improve logging for test-network-nano-bash CA
Make the CA script logging more readable for users
trying to understand the fabric-ca-client commands.

Print the actual command to the log and remove the
debug logging which adds noise.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2025-04-15 09:07:30 +09:00
Aadithyan Raju
b82a309d91
NixOS support (Multi-Linux Distro Support) (#1310)
Signed-off-by: AadithyanRaju <aadithyan75@gmail.com>
Signed-off-by: Aadithyan Raju <93834376+AadithyanRaju@users.noreply.github.com>
2025-03-24 19:15:58 +00:00
Thomas Leung
16d6d751da update fabric operations console docs
Signed-off-by: Thomas Leung <thomas.leung@ibm.com>
2025-03-22 08:28:26 -04:00
Tatsuya Sato
f36309dbfe ci: Bump Fabric to v3.1.0 for BFT Orderer tests
Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2025-03-18 23:45:47 -04:00
Dave Enyeart
bf0dded403
Bump couchdb to 3.4.2 (#1318)
Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2025-03-18 18:57:54 +00:00
Mark S. Lewis
9df15968ce Detect node start using healthz
Use the operations service health check to detect when nodes are started
in test-network-nano-bash instead of using arbitrary sleeps. Depending
on the host machine and whether CAs are used, this can reduce network
start time by up to 15 seconds.

Also ensure the Docker socket location is set correctly for Docker
contexts that use a non-default location. This is required to prevent
the health service from returning Docker connection errors.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-03-13 22:23:26 -04:00
Satoshi Ito
7daf8e406b Implement TypeScript version of asset-transfer-ledger-queries
This commit implements the TypeScript version of the asset-transfer-ledger-queries Chaincode.

Resolves #1232

Signed-off-by: Satoshi Ito <satoshi.ito.tf@hitachi.com>
2025-03-14 11:13:07 +09:00
dependabot[bot]
2261bd5374
Bump the go_modules group across 26 directories with 6 updates (#1315)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-12 21:18:47 +00:00
dependabot[bot]
cfdfe967b6
Bump the npm_and_yarn group across 1 directory with 11 updates (#1252)
Bumps the npm_and_yarn group with 5 updates in the /asset-transfer-basic/rest-api-typescript directory:

| Package | From | To |
| --- | --- | --- |
| [express](https://github.com/expressjs/express) | `4.18.2` | `4.20.0` |
| [fabric-network](https://github.com/hyperledger/fabric-sdk-node) | `2.2.19` | `2.2.20` |
| [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) | `7.22.20` | `7.25.6` |
| [braces](https://github.com/micromatch/braces) | `3.0.2` | `3.0.3` |
| [msgpackr](https://github.com/kriszyp/msgpackr) | `1.9.9` | `1.11.0` |

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-12 14:17:19 +00:00
Tatsuya Sato
9d62db6730
Bump fabric to v2.5.12 (#1314)
This patch bumps fabric to v2.5.12.
It also updates some parts of fabric-ca that were missed in the previous update.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2025-03-12 10:45:51 +00:00
Stanislav Jakuschevskij
6a5e5ddc12
Add off-chain-data go client application (#1269)
Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>
2025-03-05 17:26:33 +00:00
Mark S. Lewis
aa0c9d3004
Pull Fabric images from GitHub Container Registry (#1307)
By default, Docker images are referenced from Docker Hub. This has now
applied rate limiting that is causing builds to fail. Current Fabric
v2.5 and chaincode container Docker images are also published to GitHub
Container Registry, which does not impose rate limits and will be
located closer to the GitHub Actions runners.

This change:

- Updates to latest Fabric component versions, which are available in
  GHCR. The Fabric install script defaults to GHCR as the Docker
  registry for versions that are available here.
- Pulls and re-tags chaincode container images from GHCR in advance of
  running tests in the build. This avoids them being pulled from Docker
  Hub during test execution.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-02-23 10:53:41 -05:00
Dave Enyeart
8547618f06
Fix intermittent errors with test-network ca (#1305)
If CA server hasn't finished initialization then the initial register and enroll requests will fail.
Instead of waiting 3 seconds, actually check if CA service is ready.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2025-02-21 10:41:13 +00:00
Dave Enyeart
50699a6801
Fix intermittent errors with test-network ca (#1304)
If CA server hasn't finished initialization then the initial
register and enroll requests will fail.
Waiting 3 seconds resolves the issue.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2025-02-20 22:14:35 +00:00
David Enyeart
e1d8779f2a Add connection profile to test-network-nano-bash
Add connection profile to test-network-nano-bash
to enable legacy SDK apps.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2025-02-19 15:21:29 +09:00
Dave Enyeart
839f79343b
Fix test-network-nano-bash orderer4 enrollment (#1302)
Fix test-network-nano-bash orderer4 enrollment.
Also improve error handling and messages in CA interaction.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2025-02-18 19:48:25 +00:00
Tatsuya Sato
63bb2282fe
test-network: Add support for using BFT consensus with CA (#1301)
Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2025-02-18 17:44:43 +00:00
Mark S. Lewis
5e91d365d4 Update to Go 1.23
Go 1.24 was released on 2025-02-11. At this point Go 1.22 become an
unsupported Go runtime.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-02-12 08:34:17 -05:00
Dave Enyeart
0126ca518e
Update CA server bin path in test-network-nano-bash (#1299)
test-network-nano-bash is often used with locally built
fabric and fabric-ca binaries.
As such the intent is to first look for locally
built binaries and then fall back to binaries downloaded
with the samples.
This was correct for fabric binaries but not the fabric-ca binaries.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2025-02-12 11:10:10 +00:00
Tatsuya Sato
b8d462c22a
Bump fabric to v2.5.11 (#1298)
Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2025-02-03 09:52:12 +00:00
Tatsuya Sato
31c8ef0197
test-network-k8s: Add documentation for initial BFT orderer support (#1297)
Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2025-01-30 14:20:18 +00:00
Tatsuya Sato
fcb6e69e0d
CI: Add BFT Orderer support (#1296)
This patch adds BFT Orderer testing to the CI workflows.
The following test environments are updated:
- test-network
- test-network-k8s

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2025-01-29 09:47:34 +00:00
Tatsuya Sato
714bcb0a9f
test-network-k8s: Introduce initial support for BFT orderers (#1294)
This patch adds initial support for BFT orderers in the test-network-k8s.
When `TEST_NETWORK_ORDERER_TYPE` is set to `bft`, the network launches
four orderers configured with SmartBFT.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2025-01-27 10:06:03 +00:00
munapower
859c025e57
Translated into Spanish the Fabric Gateway section and minor corrections (#1292)
Signed-off-by: munapower <mmunaro@hotmail.com>
2025-01-17 15:14:45 +00:00
Tatsuya Sato
f174360f14
Update test-network-k8s to support both v2.5 and v3.0 (#1291)
The existing orderer configuration file is incompatible with v3.0,
and the v3.0 configuration does not work with v2.5.
To support both versions, configuration settings have been updated to
use environment variables instead of referencing static configuration
files.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2025-01-16 23:15:00 +00:00
Mark S. Lewis
b50ae22f73
Fix shellcheck linting failure (#1293)
Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-01-16 17:26:21 -05:00
munapower
00bd6aa65c Fix issue 1289 with missing parameter in peer chaincode lifecycle command
Signed-off-by: munapower <mmunaro@hotmail.com>
2025-01-10 18:18:26 -05:00
Tatsuya Sato
858e3564a4
Update some old links (#1287)
Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2025-01-07 10:59:19 +00:00
Mark S. Lewis
e1a64665db
Update fabric-contract-api-go to v2.2.0 (#1283)
Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-12-25 18:06:01 +09:00
leo
898d333efb
docs: Quotation marks are used incorrectly. (#1282)
Signed-off-by: RiceChuan <lc582041246@gmail.com>
2024-12-24 09:52:40 +00:00
Arne Rutjes
5e0e5a1550 make version regex posix compliant so that it works on mac
Signed-off-by: Arne Rutjes <arne123@gmail.com>
2024-12-16 16:06:42 -05:00
Mark S. Lewis
8538e32437
Update Gradle version and shadow plugin (#1278)
The shadow plugin is now maintained by the GradleUp organization. Change
to use the current plugin ID and latest version.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-12-11 08:04:56 -05:00
Andi
b71a4587dc
chore: use errors.New to replace fmt.Errorf with no parameters (#1277)
Also remove repetitive words.

Signed-off-by: ChengenH <hce19970702@gmail.com>
2024-12-10 11:15:02 +00:00
Mark S. Lewis
15ab2e5da8
Fix invoke CLI commands in full-stack guide (#1276)
A behaviour change in microfab means that the orderer endpoint needs to
be explicitly specified when using the peer CLI to submit transactions.
Ideally the microfab environment would not require this but the
documented commands do not currently work without this.

This change updates the full-stack-asset-transfer-guide documentation so
that CLI commands include the orderer endpoint explicitly.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-12-07 15:05:30 -05:00
Mark S. Lewis
b11239aac0
Update fabric-contract-api-go to v2.1.0 (#1275)
Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-12-07 08:36:56 -05:00
Mark S. Lewis
1aa3822788 Fix build with new microfab release
The new microfab release seems to start slower than the previous
release. This might be due to a change from solo to raft consensus. This
causes failures in the full-stack-asset-transfer appdev tests. Chaincode
deployment fails since the channel is not yet available.

Instead of increasing the sleep time after launching microfab, this
change attempts to wait however long is required by looking for the
"Microfab started" message in the container log before proceeding.

The test script is also updated to correctly stop the external chaincode
process when the script exits. Previously the process ID of the npm
command used to lauch the chaincode was captured rather than the actual
chaincode process.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-11-27 21:20:37 -05:00
David Enyeart
30b6186440 Update maintainers
Update maintainers to reflect activty from the past year.
- Retire Josh Kneubuhl, Matthew White, Arnaud Le Hors, Nikhil Gupta.
- Add Mark Lewis

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2024-11-12 09:07:30 -05:00
Tatsuya Sato
dd94aae3d5 Update chaincode container versions in k8s samples
This patch updates chaincode container versions to 2.5 in the following
samples:
- test-network-k8s
- full-stack-asset-transfer-guide

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2024-11-07 17:13:06 -05:00
Mark S. Lewis
8136eb4f5e Update test-network chaincode container versions
The test-network peer configuration specifies $(TWO_DIGIT_VERSION) as
the tag for the Node and Java chaincode containers. For Fabric v3.0,
this requests fabric-nodeenv:3.0 and fabric-javaenv:3.0 Docker images to
host Node and Java chaincode respectively. These images do not exist,
which causes deployment of Node and Java chaincode to fail when using
Fabric v3.0. Fabric v3.0 continues to use fabric-nodeenv:2.5 and
fabric-javaenv:2.5.

This change updates the test-network peer configuration to explicitly
specify `2.5` as the Node and Java chaincode Docker image tags. This is
(currently) the correct version for both Fabric v2.5 and Fabric v3.0.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-11-06 19:38:53 +09:00
Stanislav Jakuschevskij
9b199d4e0b Add private data go application
Created project directory, app.go and connect.go files. Reused the logic for
connect.go from the events application and added second organization setup.

Implemented private data transaction example in go as described in the main
documentation in "Tutorials/Using Private Data in Fabric".

Updated README.md with the command to run the go application and the script
which runs the application in the Github Actions workflow.

Fixed typos and punctuation in the private data typescript application.

Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>
2024-10-31 16:30:25 -04:00
Mark S. Lewis
e23bc6714e Simplify Java client error-handling example
The latest fabric-gateway client API release (v1.7.0) includes the gRPC error
details in the GatewayExcetion stack trace so it is not necessary to
programmatically access them to demonstrate that they are present.

This change updates the asset-transfer-basic/application-gateway-java
sample to simplify the updateNonExistentAsset example method. It also:

- Updates all samples to use the latest fabric-gateway release.
- Adds equivalent Maven POM files for fabric-gateway application samples.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-10-24 23:45:04 -04:00
Stanislav Jakuschevskij
51e3a533dc Remove cli from podman compose file
Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>
2024-10-22 16:50:08 -04:00
Mark S. Lewis
f16e9e6de5 Consistent Go version in go.mod and go.work files
The repository currently uses Go 1.22 to test samples in the automated
build. This change sets the Go version in all go.mod (and go.work) files
to Go 1.22.0, and removes any Go toolchain entries.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-10-14 10:25:34 -04:00
Mark S. Lewis
b931df3a5f Explicitly specify hash in client applications
For some signing implementations, such as ed25519, a non-default hash
implementation must be specified when creating the Gateway connection in
client applications. Rather than relying on the default hash algorithm,
it is probably good practice in general to specify an algorithm that is
compatible with your signing implementation.

This change explicitly specifies the hash algorithm to raise visibility
of the option to select the hash algorithm.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-10-07 12:25:40 -04:00
Mark S. Lewis
e37e991c4c Update applications to use fabric-gateway v1.6.0
Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-09-25 13:18:45 +09:00
David Enyeart
137f365ec9 Bump ubuntu to 22.04 in CI
Since Fabric v3.0 builds on ubuntu 22.04,
it is necessary for samples CI to run on ubuntu 22.04.

Both Fabric v2.5 components (ubuntu 20.04) and
Fabric v3.0 components (ubuntu 22.04) work on
ubuntu 22.04 runtime.

The update also requires shell script updates to pass linting.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2024-09-19 10:27:26 +09:00
Tatsuya Sato
ce5aa883ee test-network-k8s: Improve prereqs logic
This patch improves prereqs logic in test-network-k8s.
- Use the newer install script instead of bootstrap.sh
- Download binaries matching the Docker image versions, instead of the latest version
- Add checks for Fabric versions to ensure consistency between images and binaries

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2024-08-21 12:29:22 -04:00
Tatsuya Sato
5c5e98bb3d Fix the default chaincode version to "1.0" in test-network
Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2024-08-20 13:15:11 -04:00
Mark S. Lewis
3826626d00 Configure dependabot updates to GitHub Actions
Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-07-29 15:50:33 -04:00
takayuki-nagai
50b69f6157
Add document about how to benchmark the performance using Hyperledger Caliper (#1238)
Add document about how to benchmark the performance using Hyperledger Caliper

Signed-off-by: takayuki-nagai <takayuki.nagai.nu@hitachi.com>
Co-authored-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2024-07-17 17:46:23 +09:00
chinmayi
604a0a561b Fix directory path for chaincode-external
Signed-off-by: chinmayi <chinmayishaan2316@gmail.com>
2024-06-24 16:27:16 -04:00
Mark S. Lewis
110e732259 Update Go chaincode to fabric-contract-api-go/v2
Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-06-21 15:18:12 -04:00
Mark S. Lewis
7258b4f4ab Add JavaScript asset-transfer-basic application
While the TypeScript application sample is essentially identical (with
the addition of some type declarations), there seems to be sufficient
uncertainty amongst JavaScript developers not familiar with TypeScript
on how best to implement a JavaScript application that it is worthwhile
having one plain JavaScript sample using the current client API.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-06-21 12:16:31 -04:00
Mark S. Lewis
76088d0273 Remove legacy sample applications
The removed samples make use of deprecated legacy client SDKs. They all
have equivalent samples implemented using the currently supported Fabric
Gateway client API, and are therefore redundant.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-06-19 10:38:52 -04:00
David Enyeart
e334b7527a Bump fabric to v2.5.9
Bump fabric to v2.5.9.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2024-06-19 11:59:47 +09:00
Mark S. Lewis
c077dae79c Update TypeScript implementations
- Dependency updates
- ESLint flat configuration format, replacing deprecated configuration
- Minor fixes to compile and lint issues
- Consistent TypeScript formatting with .editorconfig

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-06-18 06:51:58 -04:00
Chris Elder
a4f0a2c5b2 Change CA ports in test-network-nano-bash
Signed-off-by: Chris Elder <celder@Chriss-MacBook-Pro.local>
2024-06-15 16:43:43 -04:00
Chris Elder
3622a5e383 Add chaincode logging for binary chaincode in test-network-nano-bash
- Correct sh compability in ca_utils.sh
- Correct linux compatibility in external builder

Signed-off-by: Chris Elder <celder628@gmail.com>
Signed-off-by: Chris Elder <celder@Chriss-MacBook-Pro.local>
2024-06-14 13:10:53 -04:00
Mark S. Lewis
29e695187a Use more specific chaincode package versions
This demonstrates good practice in restricting the chaincode package
versions to those applicable for the specific Fabric (major/minor)
version targeted for deployment.

Also some corrections to the repository README. Particularly referring
to other branches for samples targeted at earlier Fabric versions, since
samples in the main branch may exploit features not available in older
Fabric releases, which can cause confusion for end users.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-06-14 00:24:08 -04:00
Chris Elder
179bc96846 Add external builders for golang and node chaincode to test-network-nano-bash
The external builders will build and launch binary chaincode instead of docker containers.

Signed-off-by: Chris Elder <celder628@gmail.com>
2024-06-06 17:51:34 -04:00
Tatsuya Sato
e4af8fe198 test-network-k8s: bump k8s-builder and couchdb
Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2024-06-04 12:56:19 -04:00
Mark S. Lewis
0ed34585e1 Update Node chaincode for v2.5.5 release
Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-06-03 15:27:51 -04:00
Chris Elder
3c63eac4e3 Add CA capability to test-network-nano-bash
This change adds:
- shell scripts to start CAs for each org
- optional flag (-c) to network.sh to start CAs
- generate crypto material in the same format as cryptogen using the CAs
- describe how to start the CAs using terminals

Signed-off-by: Chris Elder <celder@chriss-mbp.raleigh.ibm.com>
2024-05-28 23:31:18 -04:00
David Enyeart
92f028c08d Bump dependencies
Go to 1.22
CouchDB to 3.3.3
Fabric to 2.5.8
Fabric-CA to 1.5.11

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2024-05-28 11:38:28 +09:00
James Taylor
1058f9ffe1 Update test-network-k8s
Add required permissions for upcoming k8s builder release

Also adds ttl to install jobs and configures the k8s builder prefix

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2024-05-27 13:49:37 +09:00
Mark S. Lewis
d3e2a90ad5 Update test dependencies for Java chaincode
This resolves mocking errors using the latest Java chaincode shim and
very old versions of Mockito.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-05-21 22:19:39 -04:00
David Enyeart
bf61094231 Remove double quotes for env variables
Double quotes have caused issues in some environments,
e.g. see https://github.com/hyperledger/fabric/issues/4358

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2024-05-07 01:06:09 +09:00
Dave Enyeart
effe8ff980
Switch microfab to hyperledger-labs version (#1203)
full-stack-asset-transfer points to an old image
that no longer exists.
Point to the hyperledger-labs microfab image instead.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2024-05-03 10:03:27 +01:00
David Enyeart
2fa83c957a GHA: Use ubuntu-20.04 for local forks
GHA: Use ubuntu-20.04 for local forks
since local forks don't have access to fabric-ubuntu-20.04.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2024-04-30 12:35:31 -04:00
David Enyeart
4763bcae8d test-network error message if jq not installed
With removal of fabric-tools image, test-network
now depends on jq being installed locally.

This commit logs an error message if jq commands
fail due to jq not being installed locally.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2024-04-30 14:48:25 +09:00
James Taylor
0db64487e5 Update nano test network
Fix regression in network.sh and update peer scripts to allow
chaincodeListenAddress and chaincodeAddress to be overridden if
required

Also updates the nano test network readme to describe the new
environment variables for the k8s builder

Fixes #1198

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2024-04-29 10:42:41 -04:00
Mark S. Lewis
42b9b60ebc Update Go gRPC dependency
grpc.Dial() is (soon to be) deprecated in current gRPC versions. Use grpc.NewClient() instead.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-04-24 16:24:37 +09:00
Tatsuya Sato
c691cf94a9 Refactor test-network post-decoupling fabric-tools image
This patch aims to refactor the test-network in several aspects,
following the decoupling of the fabric-tools image from fabric-samples.

- Rename 'test_network_home' env var to 'TEST_NETWORK_HOME'
- Dedicate the intermediate artifacts related to configtx to
channel-artifacts
- Refer to core.yaml in fabric-samples/config, similar to org1 and 2,
  instead of adding a new core file
- Remove unnecessary functions and comments for CLI container
- Other minor modifications

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2024-04-18 13:41:28 -04:00
David Enyeart
820368571d test-network envVar.sh script improvement
Change shell script to use single equals.

In my shell environment single bracket with double equals did not work.
It caused failure when running the chaincode-external tutorial README.

It looks like for maximum portability, it is best to use single bracket with single equals.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2024-04-12 12:55:48 +09:00
Mark S. Lewis
d4ce4cfadc Update asset-transfer-sbe/chaincode-java
Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-04-11 22:57:57 -04:00
Tatsuya Sato
02bcb44ad4 Fix docs and scripts for asset-transfer-basic as an external service
Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2024-04-11 15:24:37 -04:00
Sam Yuan
ebbc419933
Decouple fabric tools image from fabric sample (#1186)
* Decouple fabric tools image from fabric sample
* update with review comments

Signed-off-by: Sam Yuan <yy19902439@126.com>
2024-04-06 19:07:18 +09:00
Mark S. Lewis
66c9992bf3 Add Go chaincode for asset-transfer-events
Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-04-03 13:47:31 -04:00
Mark S. Lewis
a5eea8cd5c Read first client cert from cert directory
Allow client applications to work regardless of whether network was creating using a CA or cryptogen since they create different client certificate file names.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-03-04 09:50:43 -05:00
Mark S. Lewis
db86460086 Use latest v2.5 fabric-chaincode-java
- Update Gradle wrappers
- Update shadow plugin

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-02-25 22:13:26 -05:00
Mark S. Lewis
6dc2fa4f81 Update GitHub action versions
Avoid using deprecated action versions based on Node versions prior to Node 18.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2024-02-25 22:11:28 -05:00
Arne Rutjes
a708af9159 add optional extra arguments to lifecycle commands for more flexibility
Signed-off-by: Arne Rutjes <arne123@gmail.com>
2024-02-09 09:16:58 -05:00
uniform64
02d9f8c58b add support for docker compose v2 (fix #730)
fix bugs in #1140

Signed-off-by: uniform64 <jiny2048@gmail.com>
2023-12-12 09:14:06 -05:00
uniform64
cdb126d061
add support for docker compose v2 (fix #730) (#1140)
* add support for docker compose v2 (fix #730)

Signed-off-by: uniform64 <jiny2048@gmail.com>

* add support for docker compose v2 (fix #730)
some missing places in the previous commit

Signed-off-by: uniform64 <jiny2048@gmail.com>

---------

Signed-off-by: uniform64 <jiny2048@gmail.com>
2023-12-11 08:13:25 +01:00
Tatsuya Sato
07e7ee4ab6
test-network: Update comments to reflect channel profile name changes (#1146)
Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2023-12-11 08:08:47 +01:00
Mark S. Lewis
ce6e519fab Use Executor in asset-transfer-events/application-gateway-java
The default ForkJoinPool.commonPool may have limited capacity in some environments, risking deadlock. This implementation also better demonstrates handling of connection errors.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2023-12-04 11:31:07 -05:00
Mark S. Lewis
c0a0104ca1 Fix test-network chaincode-as-a-service deployment
Resolves a regression introduced in e73bb717db.

Previous change defaulted to "auto" as the sequence number but omitted the call to generate the correct sequence number for the "auto" value. This resulted in "auto" being used as the sequence number, which is an error since an integer is required.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2023-11-07 16:12:07 -05:00
Mark S. Lewis
0f4f62c340 Use fabric-gateway v1.4
Also update some GitHub Actions versions.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2023-10-25 17:30:29 +09:00
Chris Elder
e73bb717db Add chaincode utilities
This change is meant to help cover end user functionality
that was previously covered by the blockchain VSCode Plugin.

Functions added:
- cc mode with package, list chaincode, invoke and query functions
- auto sequencing for chaincode deployment
- move variables into config file

Signed-off-by: Chris Elder <celder@Chriss-MacBook-Air.local>
2023-10-10 12:24:23 -04:00
Arne Rutjes
99a1f49da0 add token sdk sample application
Signed-off-by: Arne Rutjes <arne123@gmail.com>
2023-10-10 09:00:23 -04:00
hexnikolas
62f304a98f Update AssetTransfer.java
added missing quotation mark (") in href

Signed-off-by: hexnikolas <114026707+hexnikolas@users.noreply.github.com>
2023-09-29 13:57:48 -04:00
Tatsuya Sato
23dc50c9ae FSAT: Update ansible playbooks for compatibility with K8s v1.25.x
The originally used image of Hyperledger Fabric Ansible Collection was
not compatible with K8s v1.25.x. This patch replaces the image with
the latest hyperledger-labs/fabric-ansible-collection.

Additionally, deprecated notations in the latest Kustomize,
patchesJson and patchesStrategicMerge, have been replaced with the
recommended syntax to prevent ansible task execution failures.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2023-09-29 13:57:10 -04:00
Tatsuya Sato
f4f3201c0e FSAT: Update fabric-operator for compatibility with v1.25.x
This patch updates fabric-operator to utilize PodSecurity Admission
controller for Kubernetes v1.25.x.

This change is based on the following PR:
https://github.com/hyperledger-labs/fabric-operator/pull/82

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2023-09-29 13:57:10 -04:00
Tatsuya Sato
d07bac37df Bump versions of software used in CI tests to latest
This patch updates the versions of software used in CI tests to the latest:
- Fabric
- GO
- KIND, kubectl

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2023-09-29 13:57:10 -04:00
Tatsuya Sato
bda72cac00 Move publishing of REST sample Image from AZP to GHA
This patch moves publishing of REST sample image from AZP to GHA.
This was the last job running on AZP.
Also, this patch fixes an error encounterd during the image build.
Publishing of REST sample image is now only executed when pushing to main.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2023-09-28 12:38:43 -04:00
Arne Rutjes
98f748155b add a retry to the test-network ccaas chaincode init command
Without this, the init command fails if the chaincode container is not ready.

Signed-off-by: Arne Rutjes <arne123@gmail.com>
2023-09-27 08:14:33 -06:00
Aditya Joshi
9441772423 updated help message for CFSSL
Signed-off-by: Aditya Joshi <adityaprakashjoshi1@gmail.com>
2023-09-27 08:08:20 -06:00
Aditya Joshi
e63c7d564e cfssl to generating certificates
Signed-off-by: Aditya Joshi <adityaprakashjoshi1@gmail.com>
2023-09-27 08:08:20 -06:00
Mark S. Lewis
6e71f634e2 Fixes for build breakages
Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2023-09-19 13:08:40 -04:00
Mark S. Lewis
30f70f6e73 Update TypeScript HSM sample application
- Update to Node 16.
- Simplify SKI code using Node standard packages and avoiding use of jsrsasign.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2023-09-19 13:08:40 -04:00
Tatsuya Sato
f2c1c59c50 Fix OrdererEndpoints in test-network's bft sample
This patch fixes the description of orderer2-4 in OrdererEndpoints
in test-network's bft-config/configtx.yaml.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2023-08-29 11:03:22 -04:00
Tatsuya Sato
7d5aaf11e2
Improve BFT sample on test-network (#1083)
This patch includes:
- Fixed a minor bug in the parsing of the BFT flag
- Added check for when a user attempts to use BFT orderer in
  Fabric network with CA
- Update of printHelp for use of the BFT flag
- Fixed explanations

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2023-08-28 15:38:14 +02:00
arkadipiven
eb16caf3d5 Fix test-network to work with BFT consensus.
Added a new option for creating channel:
Running ./network.sh createChannel -bft will initiate a channel running BFT orderers.
Using ./network.sh up -bft will initiate dockers for bft environment.
Added option for 4 orderers.

Add add_new_orderer_to_config.py which is referenced in the fabric official docs.

Signed-off-by: Arkadi Piven <arkadi.piven@ibm.com>
Signed-off-by: arkadipiven <arkadi7770@gmail.com>
2023-08-22 10:54:41 -04:00
munapower
a6d8f44fdb minor documentation fixes smart contract dev
Signed-off-by: munapower <mmunaro@hotmail.com>
2023-07-28 14:19:58 +09:00
munapower
5870033fcb spanish translation smart contract dev
Signed-off-by: munapower <mmunaro@hotmail.com>
2023-07-28 14:19:58 +09:00
geekya215
9ee0aac2ae
fix typo in high-througput/README.md (#1073)
Signed-off-by: geekya215 <geekya215@gmail.com>
2023-07-14 17:42:13 +09:00
Zhaoxuan "Tony" Wu
c04253d554
fix(test-network): ignore the error output when killing CCAAS containers (#1063)
Signed-off-by: Tony Wu <tonywu3027@me.com>
2023-07-04 13:01:30 +09:00
yjwxfq
7671bdd7c6 Update token_contract.go, checking the input params > 0 in function sub().
Signed-off-by: yjwxfq <112159687+yjwxfq@users.noreply.github.com>
2023-06-20 12:21:41 -04:00
yjwxfq
9a4920d565 Update token_contract.go, modify the overflow judgment condition for function sub().
The general overflow judgment condition for function sub is not in every case.
The judgment result is wrong in the condition of b < 0 && q >=0
for example, b = -3, q = 2, diff = -5, it's not overflow,
but if (diff > b) == (b >= 0 && q >= 0) wil be true.

for another example, b = -3, q = maxint, b-q is overflow,
but if (diff > b) == (b >= 0 && q >= 0) wil be false.

Signed-off-by: yjwxfq <112159687+yjwxfq@users.noreply.github.com>
2023-06-20 12:21:41 -04:00
Pushp Vashisht
bc3a6bfa05
Fix typo (#1048)
Signed-off-by: Pushp Vashisht <pushptyagi1@gmail.com>
2023-06-20 07:17:16 +02:00
Tatsuya Sato
2c0fe75438 Minor improvements on test-network-nano-bash
- Fix typos
- Update gitignore

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2023-06-16 16:45:22 -04:00
Tatsuya Sato
bb98f1e582 FSAT: Extend sleep time to stabilize integration test
This patch extends the sleep time to wait for starting
nginx by following the description on
full-stack-asset-transfer-guide/justfile
to stabilize the intergration test

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2023-06-16 16:44:36 -04:00
Dave Enyeart
ae9e7e8df8
test-network-nano-bash chaincode id and waitForEvent improvements (#1052)
- Use calculatepackageid to set CHAINCODE_ID
- Use waitForEvent to wait for commit event intead of 2s sleep

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-06-09 21:48:39 +09:00
Arkadi Piven
81390fbbbf Fix nano-bash-bft sample to work with channel-participation.
remove dependency on deprecated system-channel.

Signed-off-by: Arkadi Piven <arkadi.piven@ibm.com>
Signed-off-by: arkadipiven <arkadi7770@gmail.com>
2023-06-07 10:17:46 -04:00
yjwxfq
20009ecd02 Update token_contract.go, modify the overflow judgment condition for function add()
Signed-off-by: yjwxfq <112159687+yjwxfq@users.noreply.github.com>
2023-06-06 15:26:09 -04:00
Ry Jones
2f11c4410f
chore(docs): fix discord link (#1044)
Signed-off-by: Ry Jones <ry@linux.com>
2023-05-25 16:41:02 +02:00
David Enyeart
5df2404b08 Nominate Tatsuya Sato as fabric-samples maintainer
Tatsuya has been helping to groom fabric-samples for multiple years.
More recently, Tatsuya has helped to keep test-network-k8s
and full-stack-asset-transfer samples working well.
Tatsuya has expressed interest in becoming a maintainer and
I would welcome the addition!

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-05-22 07:53:42 -04:00
yunusemrekarakose
4691478bfb Update package.json
Signed-off-by: yunusemrekarakose <yemre05@hotmail.com.tr>
2023-05-17 13:40:30 -04:00
yunusemrekarakose
3d747bdcd3 Update package.json
Signed-off-by: yunusemrekarakose <yemre05@hotmail.com.tr>
2023-05-17 13:40:30 -04:00
Yunus Emre Karaköse
8f62557843 chaincode-typescript
Signed-off-by: YunusEmreKarakose <yemre05@hotmail.com.tr>
Signed-off-by: Ry Jones <ry@linux.com>
Signed-off-by: yunusemrekarakose <yemre05@hotmail.com.tr>
2023-05-17 13:40:30 -04:00
Tatsuya Sato
5c020f2a71 Update FSAT to use Fabric 2.5 by default
This patch updates full-stack-asset-transfer to Fabric 2.5 by default.
In particular, since k8s-builder-peer is set as the default value for
peer image, it needs to be updated to use 0.11.0, which is derived
from Fabric v2.5 image, as the version default value.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2023-05-17 13:23:08 -04:00
Tatsuya Sato
f8f52cab71 test-network-k8s: Update k8s CC builder to 0.11.0
This patch updates k8s CC builder to 0.11.0 to resolve the
distribution mismatch between k8s-builder base image and fabric-peer
base image.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2023-05-09 22:11:57 -04:00
David Enyeart
57127ac75a Update test-network-k8s to Fabric v2.5
Update test-network-k8s to use Fabric v2.5.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-05-09 22:11:57 -04:00
Mark S. Lewis
e93cfacf1f Use Java gRPC instead of Netty API to establish TLS connections
Include specific gRPC TLS implementation in dependencies instead of relying on an appropriate one to be present as a transitive dependency.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2023-05-08 14:17:21 -04:00
Dave Enyeart
84f9ba1dc4
Update CI to Fabric v2.5.1 (#1032)
Update CI to use Fabric v2.5.1.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-05-05 13:34:07 +01:00
Dave Enyeart
e1d077582a
Bump CouchDB to 3.3.2 (#1028)
Bump CouchDB to 3.3.2.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-05-05 13:26:28 +01:00
Dave Enyeart
9a382c8fab
Add test-network org3 affilication (#1026)
The org3 affiliation is needed when registering users for org3.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-05-05 13:24:44 +01:00
Mark S. Lewis
628331d1a2 Fix error in full-stack-asset-transfer-guide docs
- Set correct CERTIFICATE file name in application ChaincodeEvents exercise.
- Add required environment variables to application AssetTransfer exercise, rather than rely on the RunApplication exercise being run in the same terminal first.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2023-05-02 12:46:03 -04:00
Javier Ruiz
74c48ec5aa Fix DOKS section
Signed-off-by: Javier Ruiz <japi@kolokium.com>
2023-05-01 15:21:08 -04:00
Mark S. Lewis
3eaabe789c Fix build failure in full-stack-asset-transfer
A typo in the 10-appdev-e2e.sh script caused the shell to exit with an error status, and the killall command appears to match some key processes in the runner so removing.

Also:
- Update sample application and smart contract to Node 18, using the latest fabric-contact-api release.
- Use release versions of Fabric v2.5 and update tool versions in workflow set up.
- Use GitHub Action to install just instead of curl of install script.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2023-04-27 16:07:36 -04:00
Arnaud J Le Hors
36ad010124 Fix erc-1155 sample README
Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2023-04-24 17:27:08 -04:00
wisecoach
9e38280be2 fixed test-network-k8s/scripts/test_network.sh missing
fixed test-network-k8s/scripts/channel.sh missing

Signed-off-by: wisecoach <827165648@qq.com>
2023-04-24 17:11:12 -04:00
Ry Jones
c2f106adf1 chore(ci): use dedicated Fabric runners
Signed-off-by: Ry Jones <ry@linux.com>
2023-04-20 17:26:24 -07:00
Tatsuya Sato
aa153474f2
Fix npm problems on asset-transfer-basic/chaincode-typescript (#935)
* Fix npm problems on asset-transfer-basic/chaincode-typescript

This patch fixes npm problems on
asset-transfer-basic/chaincode-typescript.
- Sync npm-shrinkwrap.json with package.json to fix the npm ci error
- Update the version of TypeScript to avoid the type error on logform

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>

* Update npm-shrinkwrap.json

Fix dependencies

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>

---------

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
Co-authored-by: Arnaud J Le Hors <lehors@us.ibm.com>
2023-04-20 17:18:43 +02:00
Krishnasuri Narayanam
2c831e4590
GetID to return clientId in base64 form (#771)
Signed-off-by: Krishnasuri Narayanam <knaraya3@in.ibm.com>
Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
Co-authored-by: Arnaud J Le Hors <lehors@us.ibm.com>
2023-04-20 15:28:52 +02:00
Ry Jones
21361ae7b4 Apply suggestions from code review
Signed-off-by: Ry Jones <ry@linux.com>
2023-04-19 08:18:16 -07:00
David Enyeart
73e4d98dd9 Cancel existing workflows on subsequent PR push
Cancel existing workflows on subsequent PR push.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-04-19 08:18:16 -07:00
Matthew B White
7c42ff3d8e
Update the npm-shirnkwrap.json (node 16 used) (#1018)
Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2023-04-12 15:18:58 +02:00
Matthew B White
67ae2c9d02 Correct the private data collection information
For the asset transfer example (https://hyperledger-fabric.readthedocs.io/en/release-2.5/private_data_tutorial.html#pd-use-case)
the are three private data collections, one per org and one shared between the orgs.

The shared collection didn't have an endorsement policy so inheritted the chaincodes; this was specifically set away from the default
to be OR(Org1MSP,Org2MSP).   The documentation says this is to ensure that either organization can create and asset.

However this isn't really necassary, the endorsement policy should be lowest level; so this PR moves the endorsement policy to
the collection.  The documentation does I believe lead to a false understanding

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2023-03-22 16:19:56 -04:00
Dave Enyeart
75b8419113
Sample apps should exit code 1 upon failure (#1003)
Ensure that all sample applications return exit code 1 upon failure
so that github actions can report the failure.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-03-17 13:18:18 +00:00
Dave Enyeart
00c561457f
Update samples to use Fabric v2.5.0-beta2 by default (#1006)
Update samples to use Fabric v2.5.0-beta2 by default.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-03-17 13:17:39 +00:00
Dave Enyeart
efbecb6d10
Add debug logging to CI scripts (#1007)
Add debug logging to CI scripts.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-03-17 13:11:30 +00:00
Dave Enyeart
97a400ea28
Bump couchdb to 3.2.2 (#1008)
Bump couchdb to 3.2.2.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-03-17 13:08:55 +00:00
Dave Enyeart
dada89c710
Remove csr.hosts from msp enrollments (#1009)
Flag --csr.hosts is only relevant for tls enrollments, it adds the SAN to the TLS cert.
For msp enrollments, the cert is only used for identity, therefore there is no need for SAN and no need to pass --csr.hosts.
Having --csr.hosts for msp enrollments is misleading, this commit removes it.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-03-17 13:08:03 +00:00
Mark S. Lewis
85fbbc0924 Fix Node HSM sample
Also:
- Tidy up README documentation.
- Add MacOS/Homebrew (Apple silicon) default SoftHSM library location to HSM scripts and sample applications to avoid the need to explicitly override the library location when running the sample.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2023-03-14 11:33:21 -04:00
Dave Enyeart
eb787b7afa
Update Go and Go dependencies (#996)
* Update go dependencies

Update go dependencies in sample chaincodes and applications

Signed-off-by: David Enyeart <enyeart@us.ibm.com>

* Update to Go 1.19.6

Update to Go 1.19.6

Signed-off-by: David Enyeart <enyeart@us.ibm.com>

---------

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-03-07 14:44:33 +00:00
Dave Enyeart
488e74ed08
asset-transfer-basic CI improvements (#998)
* Return exit(1) if application-java fails

If application-java fails, return an exit(1) code,
so that callers such as Github Actions CI can detect the failure.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>

* asset-transfer-basic CI improvements

- Application failure should result in CI failure
- Automatically remove wallet from prior runs
- Fix chaincode name issues, allow chaincode name to be passed from CI
- Fix appUser collisions (duplicate registration failures)
- Fix key create collisions across apps (in cases where same chaincode is used for multiple apps)

Signed-off-by: David Enyeart <enyeart@us.ibm.com>

---------

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-03-07 09:43:10 +00:00
Tatsuya Sato
199e290f5e
Fix gradle version used in asset-transfer-basic/chaincode-java image build to 7 (#961)
This patch fixes the gradle version used in asset-transfer-basic/
chaincode-java build to 7.

The reason is because the gradle version in the gradle:jdk11-alpine
image is updated from 7 to 8, which seems to cause the build to fail.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2023-03-02 12:05:44 +00:00
David Enyeart
128950edca Fix go lint issue
Fix go lint issue by running goimports.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-03-02 00:44:36 -05:00
Dave Enyeart
f7b3a7703f Revert "Bump github.com/prometheus/client_golang (#932)"
This reverts commit a0b2822e71.
2023-03-01 11:51:42 -05:00
Dave Enyeart
1816d24732 Revert "Bump github.com/prometheus/client_golang (#933)"
This reverts commit fd4332d9c0.
2023-03-01 11:51:26 -05:00
David Enyeart
3af7eddcd3 Remove heritage chaincode samples
The samples repository has been refactored to focus on an asset transfer series of samples.
The goal of the samples repository is to align with the fabric documentation tutorials
with minimal other distractions.
The heritage samples were left in place for a period of time until the asset transfer series stabilized.
It is now time to purge the heritage samples.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-03-01 11:50:47 -05:00
David Enyeart
b8c2448bc6 Remove changelog script
Manual changelog is no longer created since github provides a changelog.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2023-03-01 11:20:43 -05:00
dependabot[bot]
fd4332d9c0
Bump github.com/prometheus/client_golang (#933)
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.1.0 to 1.11.1.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.1.0...v1.11.1)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-23 16:18:03 +01:00
dependabot[bot]
a0b2822e71
Bump github.com/prometheus/client_golang (#932)
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.1.0 to 1.11.1.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.1.0...v1.11.1)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-23 16:07:47 +01:00
dependabot[bot]
c723d812e9
Bump github.com/prometheus/client_golang in /fabcar/go (#931)
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.1.0 to 1.11.1.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.1.0...v1.11.1)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-15 13:21:17 +01:00
Mark S. Lewis
10e9377555 Avoid explicit import of grpc-js or fabric-protos in TypeScript apps
Rely on the dependencies of @hyperledger/fabric-gateway making these packages transitively available. Having explicit dependency versions in the application can cause type conflicts due to private member changes in the gRPC Client class across versions.

Also fix some missing or incorrect Node types and engines version contraints.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2023-02-10 11:36:41 -05:00
Matthew B White
cb886be466 Commercial Paper
The Commercial Paper example code hasn't kept pace with the state-of-the-art of writing applications and chaincode

Whilst the scenario is still a valid usecase, the example itself is not helping - in fact causing confusion.

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2023-01-31 21:25:52 -05:00
jkneubuh
c986c8d227
Run FSAT tests with 2.5 images, binaries, and trigger on all builds for regression coverage (#919)
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2023-01-27 09:49:52 -05:00
Matthew B White
5bc925a3d8
Add in 2.5 java test (#917)
Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2023-01-25 09:03:46 -05:00
HousniAbdellatife
406d7e9d36
fix java contract paperkey parameter in commercial paper example (#905)
Signed-off-by: HousniAbdellatife <abdellatife.housni@gmail.com>
2023-01-25 08:48:10 -05:00
dependabot[bot]
9b1de5e0b1
Bump minimatch in /asset-transfer-basic/rest-api-typescript (#887)
Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2.
- [Release notes](https://github.com/isaacs/minimatch/releases)
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-24 09:35:08 -05:00
dependabot[bot]
a231e12caa
Bump json5 in /asset-transfer-basic/rest-api-typescript (#898)
Bumps [json5](https://github.com/json5/json5) from 2.2.0 to 2.2.3.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v2.2.0...v2.2.3)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-24 09:34:28 -05:00
dependabot[bot]
7c46fdb087
Bump cookiejar in /asset-transfer-basic/rest-api-typescript (#916)
Bumps [cookiejar](https://github.com/bmeck/node-cookiejar) from 2.1.2 to 2.1.4.
- [Release notes](https://github.com/bmeck/node-cookiejar/releases)
- [Commits](https://github.com/bmeck/node-cookiejar/commits)

---
updated-dependencies:
- dependency-name: cookiejar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-24 08:47:59 -05:00
Matthew B White
795673dee3
Add in examples and notes on using PurgePrivateData (#878)
* Add in examples and notes on using PurgePrivateData

- Update the configtx.yaml to enable the 2.5 capabillity
- Added purge into the chancode
- Added pruge into the application client code.

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>

* Temporarily remove java cc test

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2023-01-23 11:40:52 -05:00
jkneubuh
124adb43f9
run test suites with 2.5 binaries and images (#906)
* run test suites with 2.5 binaries and images

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Swap to use the Helper Function to create policies (#907)

The old way used the direct protobuf functions, there is a helper function
in the chaincode does exactly that.

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
Co-authored-by: Matthew B White <whitemat@uk.ibm.com>
2023-01-18 16:05:40 +00:00
Arnaud J Le Hors
0fe4d091d2
Fix network.sh (#886)
This adds a missing reference to $CONTAINER_CLI.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2023-01-18 09:16:05 -05:00
Rubén
bcb2e1c910
fix chaincodes typo (#900)
Signed-off-by: Rubén <20502699+rubcv@users.noreply.github.com>

Signed-off-by: Rubén <20502699+rubcv@users.noreply.github.com>
2023-01-18 09:14:38 -05:00
Sam Yuan
5095954756
doc: add zh version for Fabric Full Stack Development Workshop Cloud Native Fabric part (#901)
Signed-off-by: Sam Yuan <yy19902439@126.com>
2023-01-18 09:13:54 -05:00
Matthew B White
e7d3b41287
Swap to use the Helper Function to create policies (#908)
The old way used the direct protobuf functions, there is a helper function
in the chaincode does exactly that.

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2023-01-18 07:25:07 -05:00
Matthew B White
a70547dd94
Update the name of the certificate. (#902)
Late 2022 it was discovered that when used via the CA, the certificate had a fixed named covention. cert.pem

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2023-01-09 10:16:03 -05:00
Ramesh M
1e6fe3b261
Update 13-kube-public-cloud.md (#891)
Signed-off-by: Ramesh M <62267259+ramdisk-ott@users.noreply.github.com>
2023-01-03 14:06:55 -05:00
skypos99
b23274b945
Update 10-kube.md (#890)
Signed-off-by: skypos99 <116450739+skypos99@users.noreply.github.com>

Signed-off-by: skypos99 <116450739+skypos99@users.noreply.github.com>
2023-01-03 14:03:59 -05:00
Deepak Singh
09959b967d
Update org1-peer2.yaml (#882)
Fixing TLS issues while using org1-peer-gateway-svc.${DOMAIN}.
This would be needed so there are no TLS issues when sending requests.

Signed-off-by: Deepak Singh <91736795+blockguardian@users.noreply.github.com>

Signed-off-by: Deepak Singh <91736795+blockguardian@users.noreply.github.com>
2023-01-03 14:02:45 -05:00
Marcus Brandenburger
8d0e632d86
Clean up full-stack-asset-trasfer-guide docs (#889)
Remove old repository (hyperledgendary) link from readme diagram.

Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
2022-12-14 11:24:23 -05:00
Parameswaran Selvam
f838d6b5a8
added a check for prereq into deploycc script (#884)
Signed-off-by: Parameswaran Selvam <parselva@in.ibm.com>

Signed-off-by: Parameswaran Selvam <parselva@in.ibm.com>
2022-12-14 09:31:10 +01:00
dependabot[bot]
a96efaebde
Bump qs and express in /asset-transfer-basic/rest-api-typescript (#880)
Bumps [qs](https://github.com/ljharb/qs) to 6.11.0 and updates ancestor dependencies [qs](https://github.com/ljharb/qs), [qs](https://github.com/ljharb/qs) and [express](https://github.com/expressjs/express). These dependencies need to be updated together.


Updates `qs` from 6.10.2 to 6.11.0
- [Release notes](https://github.com/ljharb/qs/releases)
- [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ljharb/qs/compare/v6.10.2...v6.11.0)

Updates `qs` from 6.10.1 to 6.11.0
- [Release notes](https://github.com/ljharb/qs/releases)
- [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ljharb/qs/compare/v6.10.2...v6.11.0)

Updates `express` from 4.17.1 to 4.18.2
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.17.1...4.18.2)

---
updated-dependencies:
- dependency-name: qs
  dependency-type: indirect
- dependency-name: qs
  dependency-type: indirect
- dependency-name: express
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-14 09:23:23 +01:00
ali
05c06f4931
Fixed comment consistency problem (#844)
* fixed comment consistency problem with erc20 chaincode

Signed-off-by: Ali Shahverdi <ali@Alis-MacBook-Pro.local>

* added more comment consistancy fix

Signed-off-by: Ali Shahverdi <ali@Alis-MacBook-Pro.local>

* added more comment consistancy fix

Signed-off-by: Ali Shahverdi <ali@Alis-MacBook-Pro.local>

* added more comment consistancy fix

Signed-off-by: Ali Shahverdi <ali@Alis-MacBook-Pro.local>

* added more comment consistancy fix

Signed-off-by: Ali Shahverdi <ali@Alis-MacBook-Pro.local>

Signed-off-by: Ali Shahverdi <ali@Alis-MacBook-Pro.local>
Co-authored-by: Ali Shahverdi <ali@Alis-MacBook-Pro.local>
2022-12-14 09:18:21 +01:00
Basil K Y
b2de360e1c
REST api added for asset transfer in Golang (#836)
* REST api added for asset transfer in Golang

Signed-off-by: Basil K Y <techiebasil@gmail.com>

* add go.sum to git

Signed-off-by: Basil K Y <techiebasil@gmail.com>

* fix golint error

Signed-off-by: Basil K Y <techiebasil@gmail.com>

Signed-off-by: Basil K Y <techiebasil@gmail.com>
2022-12-14 09:16:09 +01:00
Mark S. Lewis
4109e741e4
Parse transaction creator to Identity in off_chain_data samples (#883)
Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-12-13 13:18:50 +00:00
Mark S. Lewis
a6028cd398
Fix asset-transfer-basic/application-gateway-go (#874)
Error handling example used a transaction invocation with the wrong number of arguments and so did not demonstrate the same error condition as other language samples. The error handling code was also not as comprehensive as it should be.

Also changed the console output throughout to match the content and format of the Node and Java samples.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-11-30 13:21:49 +00:00
Satoshi Ito
22e1af4935
Minor fixes to the ingress setting (#850)
This patch fixes the ingress setting so that the peer-gateway works correctly.

Signed-off-by: Satoshi Ito <satoshi.ito.tf@hitachi.com>
2022-11-21 14:44:59 -05:00
Matthew B White
2e421139a0
Remove mistaken msp path (#873)
Signed-off-by: Matthew B White <whitemat@uk.ibm.com>

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2022-11-18 15:54:08 +01:00
Josh Kneubuhl
fd2fffbd43 review feedback: un-pin fabric CLI targets
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-11-15 16:08:24 -05:00
Josh Kneubuhl
94a1542782 Run Full Stack Asset Transfer Guide tests on GHA
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-11-15 16:08:24 -05:00
Josh Kneubuhl
38a36c65d3 Move the remaining sample tests from Azure to GHA
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-11-15 11:18:11 -05:00
Josh Kneubuhl
b7b06b9de3 Move Kube Test Network tests from Azure -> GHA
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-11-14 22:55:18 -05:00
Josh Kneubuhl
156f6d42fb Delete commercial paper and fabcar tests from Azure
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-11-14 16:25:27 -05:00
jkneubuh
0ce94bbb9b
Move lint and test-network-basic tests from Azure to GHA - READY FOR MERGE (#862)
* Move Test Network Basic tests from Azure to GHA

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Move linters from Azure to GHA

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Apply review comments - pin java, node, and go runtimes

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-11-14 13:36:55 +00:00
Josh Kneubuhl
34734cfff2 Add FSAT appdev E2E test
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-11-11 13:18:29 -05:00
jkneubuh
60a61b8241
Only run GHA on PRs targeting the mainline (#860)
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-11-11 10:16:58 -05:00
jkneubuh
e908a30d3a
Activate GHA on the fabric-samples project (#859)
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-11-11 13:21:26 +00:00
Ry Jones
2c5ce16f0b Default branch
Add issues

Signed-off-by: Ry Jones <ry@linux.com>
2022-11-10 10:03:03 -08:00
jkneubuh
a299e18e26
Moves the Full Stack Asset Transfer Development Guide to fabric-samples (#852)
* Import Full Stack Asset Transfer Guide at commit fb554befdbbeff9e69159b54fce0b811603f29c7

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Update the workshop with a new WORKSHOP_PATH under fabric-samples

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Update the workshop with a new WORKSHOP_PATH under fabric-samples

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* missed a .git ignored directory on add

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Updates to run the workshop on the Apple M1

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Workaround for https://github.com/eslint/eslint/issues/15299 in the contract tslinter

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Build an arch-specific CC images on M1

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* empty commit - force a build

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* revert an accidental commit that was building the top-level asset-transfer as arm64

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-11-10 10:40:27 -05:00
Tatsuya Sato
49749c6584
Minor fixes and improvements to test-network-k8s (#849)
Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2022-10-26 05:43:26 -04:00
Mark S. Lewis
63cc77bdc3
Avoid usage of deprecated ioutil Go package (#843)
* Refactor Go files
1. replace deprecated ioutil functions (ioutil is deprecated since Go 1.16)
2. fix variable names that collide with imported package name
3. fix typos

Also update Go version specified by Go modules to ensure a Go version is used in which ioutil is deprecated and replacement functions are available in os and io packages.

Signed-off-by: Tommy TIAN <xtianae@connect.ust.hk>
Co-authored-by: Mark S. Lewis <mark_lewis@uk.ibm.com>

* Specify go 1.18 instead of go 1.19 in go.mod files

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>

Signed-off-by: Tommy TIAN <xtianae@connect.ust.hk>
Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
Co-authored-by: Tommy TIAN <xtianae@connect.ust.hk>
2022-10-25 07:04:39 -04:00
Mark S. Lewis
c323c95807
Update samples to use fabric-gateway v1.1.1 (#842)
Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-10-20 17:43:55 +01:00
yjwxfq
6b989299e0
Fix chaincode/abstore, add parameter judgment when the transaction makes payment. (#825)
Signed-off-by: yjwxfq <yjwxfq@163.com>

Signed-off-by: yjwxfq <yjwxfq@163.com>
2022-10-20 15:49:47 +01:00
James Taylor
0aa853e0c3 Update go chaincode samples
Update to the latest github.com/hyperledger/fabric-contract-api-go

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2022-10-18 15:28:20 -04:00
dependabot[bot]
ea533d61b9
Bump passport in /asset-transfer-basic/rest-api-typescript (#828)
Bumps [passport](https://github.com/jaredhanson/passport) from 0.4.1 to 0.6.0.
- [Release notes](https://github.com/jaredhanson/passport/releases)
- [Changelog](https://github.com/jaredhanson/passport/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jaredhanson/passport/compare/v0.4.1...v0.6.0)

---
updated-dependencies:
- dependency-name: passport
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-09 17:48:14 +02:00
dependabot[bot]
3841318020
Bump moment-timezone in /asset-transfer-basic/rest-api-typescript (#821)
Bumps [moment-timezone](https://github.com/moment/moment-timezone) from 0.5.33 to 0.5.37.
- [Release notes](https://github.com/moment/moment-timezone/releases)
- [Changelog](https://github.com/moment/moment-timezone/blob/develop/changelog.md)
- [Commits](https://github.com/moment/moment-timezone/compare/0.5.33...0.5.37)

---
updated-dependencies:
- dependency-name: moment-timezone
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-09 17:47:05 +02:00
dependabot[bot]
a4245810a0
Bump jsrsasign in /asset-transfer-basic/rest-api-typescript (#795)
Bumps [jsrsasign](https://github.com/kjur/jsrsasign) from 10.5.1 to 10.5.26.
- [Release notes](https://github.com/kjur/jsrsasign/releases)
- [Changelog](https://github.com/kjur/jsrsasign/blob/master/ChangeLog.txt)
- [Commits](https://github.com/kjur/jsrsasign/compare/10.5.1...10.5.26)

---
updated-dependencies:
- dependency-name: jsrsasign
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-09 14:33:44 +02:00
dependabot[bot]
f39e55e6f5
Bump moment in /asset-transfer-basic/rest-api-typescript (#794)
Bumps [moment](https://github.com/moment/moment) from 2.29.2 to 2.29.4.
- [Release notes](https://github.com/moment/moment/releases)
- [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/moment/moment/compare/2.29.2...2.29.4)

---
updated-dependencies:
- dependency-name: moment
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-09 14:33:01 +02:00
James Taylor
4eff55b75b
Fix test network chaincode deploy (#827)
Correctly check for installed chaincode and enable the same chaincode to be deployed on different channels

Signed-off-by: James Taylor <jamest@uk.ibm.com>

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2022-09-09 12:33:27 +01:00
James Taylor
01da596ae1 Update nano test network
Fix minor bugs, and add network.sh script to simplify standing up the network

Note: the updated peerNadmin.sh scripts no longer create or join a channel and now only configure the environment for the relevant peer

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2022-08-29 02:31:49 -04:00
Basil K Y
d1b3253cc5
separate namespace for each organization (#817)
* seperate namespace for each organization

Signed-off-by: Basil K Y <techiebasil@gmail.com>

* rest server working

Signed-off-by: Basil K Y <techiebasil@gmail.com>

* use single namespace by default, fix k8s buider

Signed-off-by: Basil K Y <techiebasil@gmail.com>

* added ci test for testing k8s n/w on multiple namespaces

Signed-off-by: Basil K Y <techiebasil@gmail.com>

* fix: access rest server via gateway

Signed-off-by: Basil K Y <techiebasil@gmail.com>

Signed-off-by: Basil K Y <techiebasil@gmail.com>
2022-08-26 12:39:45 -04:00
dependabot[bot]
70c5aa7a28
Bump nconf in /asset-transfer-basic/rest-api-typescript (#722)
Bumps [nconf](https://github.com/flatiron/nconf) from 0.11.3 to 0.11.4.
- [Release notes](https://github.com/flatiron/nconf/releases)
- [Changelog](https://github.com/indexzero/nconf/blob/master/CHANGELOG.md)
- [Commits](https://github.com/flatiron/nconf/compare/v0.11.3...v0.11.4)

---
updated-dependencies:
- dependency-name: nconf
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-26 09:46:10 +02:00
Arnaud J Le Hors
eb3acf34eb
Update CHAINCODE_AS_A_SERVICE_TUTORIAL.md (#804)
This change fixes a few minor errors and adds a note to help the user.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2022-08-22 17:13:06 -04:00
Stefan Obermeier
cd4db0bc8b
use existing const instead of local string (#815)
Signed-off-by: Stefan Obermeier <st.obermeier@seeburger.de>

Signed-off-by: Stefan Obermeier <st.obermeier@seeburger.de>
2022-08-19 15:50:56 -04:00
jkneubuh
1e8fd5cd56
Update k8s CC builder to v7.2; Use *.localho.st loopback domain; Optionally bind docker reg to 0.0.0.0 (#811)
* Update k8s builder to v0.7.1

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Add LOCAL_REGISTRY_INTERFACE option to bind the insecure docker registry to alternate NICs

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Switch from *.vcap.me -> *.localho.st for the default loopback domain name

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-08-08 12:05:48 +01:00
jkneubuh
9f9cec7195
Run RCAADMIN registration on the host OS, not in k8s (#809)
* Run RCAADMIN registration on the host OS, not in k8s

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Fix a typo that caused the log trailer to not exit cleanly on error

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* allow a node registration to have been previously created.  This allows for multiple 'network up' targets to be run.

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-08-05 13:17:05 +01:00
Arnaud J Le Hors
a1b7d20ebe Clarifies podman instructions for test-network
Also reverts to using install-fabric.sh which is preferred over bootstrap.sh.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2022-08-03 13:38:06 -04:00
Arnaud J Le Hors
6ede244d2b Use alpine based gradle image to build basic transfer java CC container
This changes the base image used to build the chaincode-as-a-service
java container to the alpine version which is sufficient and less
taxing than using the full gradle:jdk11 one.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2022-08-03 12:07:20 -04:00
Arnaud J Le Hors
bfe8f6e04d Update podman support information
This change updates the test-network README with up-to-date information
about using podman on Mac and improves support for podman in deployCCAAS.sh

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2022-08-03 12:06:39 -04:00
Arnaud J Le Hors
8403da7386 Fix vulnerabilities in typescript chaincode deps
npm audit reveals several high and one critical vulnerabilities in the dependencies:

ansi-regex  4.0.0 - 4.1.0
Severity: high
Inefficient Regular Expression Complexity in chalk/ansi-regex - https://github.com/advisories/GHSA-93q8-gq69-wqmw
fix available via `npm audit fix`
node_modules/nyc/node_modules/ansi-regex

minimist  <=1.2.5
Severity: critical
Prototype Pollution in minimist - https://github.com/advisories/GHSA-xvch-5gv4-984h
Prototype Pollution in minimist - https://github.com/advisories/GHSA-vh95-rmgr-6w4m
fix available via `npm audit fix --force`
Will install mocha@10.0.0, which is a breaking change
node_modules/minimist
node_modules/ts-node/node_modules/minimist
  mkdirp  0.4.1 - 0.5.1
  Depends on vulnerable versions of minimist
  node_modules/mkdirp
    mocha  1.21.5 - 6.2.2 || 7.0.0-esm1 - 7.1.0
    Depends on vulnerable versions of mkdirp
    node_modules/mocha

protobufjs  6.11.0 - 6.11.2
Severity: high
Prototype Pollution in protobufjs - https://github.com/advisories/GHSA-g954-5hwp-pp24
fix available via `npm audit fix`
node_modules/protobufjs

5 vulnerabilities (2 moderate, 2 high, 1 critical)

This change (from running npm audit fix --force) removes all of them:
npm audit
found 0 vulnerabilities

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2022-08-03 12:00:58 -04:00
Mark S. Lewis
51397fe78a
Add getCreator() to parsed transaction in off_chain_data sample (#806)
Example of how the client identity that submitted a transaction can be obtained.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-08-03 11:35:31 +01:00
jkneubuh
cb4355125f
Feature/ca v1.5.5 (#788)
* bump CA to v1.5.5; Fabric to v2.4.4

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Reorganizes the kube test network environment default parameters to align on column boundaries.

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Run k8s sample network tests against latest MAJOR.MINOR release of fabric, CA docker hub images.

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-08-01 14:58:12 +01:00
Matthew B White
4bbffdf2f2
Update Node.js dockerfile (#805)
Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2022-08-01 11:50:47 +00:00
Mark S. Lewis
41717d76f2
Fix link in off_chain_data README (#793)
Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-07-18 08:56:17 +01:00
Saptha Surendran
6aa3017ccb
Added hsm samples using Gateway (#759)
* Added hsmm Samples using Gateway

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* Used asset-transfer-basic chaincode

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* moved samples under asset-transfer-basic

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* ci pipeline changes

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* HSM config path changed

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* added pkcs11 enabled ca

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* HSM template added

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* moved  binaries to fabric  samples bin
added go mod and go sum
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* Gopath reverrted back to localDirectory

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* go mod added and cleanup

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* test file directory

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* test file directory

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* migrate to latest gateway and go version

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* hsm script changes
Readme changes
Added npm prepare

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* moved samples out of asset-transfer-basic

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* Name changes

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* code refactor

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* go vet by tag

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* pkcs11 tag added to lint script

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* Readme updates

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* application-typescript code refactor

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* readme note added

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2022-07-15 09:18:30 -04:00
Dave Enyeart
f32f77b129
Update secured asset transfer sample (#781)
A recent commit added the potential buyer to an asset's state based endorsement policy.
That change was problematic because if the transfer fell through, the buyer lost control of the asset,
in that they could no longer update the asset or change the sell price or sell to somebody else.

The asset state based endorsement policy is now based on the seller only, and we document
that additional parties could be added such as a trusted third party (although no
such party exists in test network at this time).

This commit also re-adds some necessary verifications, and make other minor edits and
comments to help users understand the sample.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2022-07-13 14:09:14 -04:00
destinysky
9f844e5de3
Fix namespace in k8s configuration files (#784)
Issues:
1. When the name of NETWORK_NAME or NS in file "network" (i.e., the namespace in k8s) is changed from "test-network", the resources in the k8s cluster cannot be created successfully when the command "./network up" is executed.
Error message: error: the namespace from the provided object "test-network" does not match the namespace "xxxxxx". You must pass '--namespace=test-network' to perform this operation.
2. org2-cc.yaml is not completed.

Fix:
1. Replace "test-network" in yaml files in folder "kube" with "${NS}".
2. Complete "org2-cc-template.yaml" by referring to "org1-cc-template.yaml".

Signed-off-by: destinysky <kangrui10@126.com>
2022-07-04 08:36:36 -04:00
Mark S. Lewis
12f59398ba
Fix asset-transfer-events sample Java chaincode (#782)
- chaincode-java Gradle project name did not match the instructions or the chaincode name used by the sample application code.
- Added test of Java chaincode to CI pipeline.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-07-01 12:28:52 +01:00
Mark S. Lewis
f8e7bfe803
Update Gateway samples for v1.1 release (#779)
- Updated build to use Go 1.18 since Go 1.16 is no longer supported.
- Use Java 11 in updated samples, and take advantage of new language features.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-06-30 15:46:32 +01:00
Satoshi Ito
3d3f15ce30
Fix test-network-k8s docs (#776)
This patch fixes errors in the document.
Fix errors as follows:

- Change shell script arguments
- Correct display results

Signed-off-by: Satoshi Ito <satoshi.ito.tf@hitachi.com>
2022-06-24 12:21:24 -04:00
Rajat Sharma
d270488450 minor documentation updated
Signed-off-by: Rajat Sharma <connecttorajat@outlook.com>
2022-06-23 07:44:44 -04:00
Rajat Sharma
654335ebd4 readme updated to resolve minor issues.
Signed-off-by: Rajat Sharma <connecttorajat@outlook.com>
2022-06-23 07:44:44 -04:00
Josh Kneubuhl
15a4772493 Bump chaincode builder to v0.6.0 : +couchdb indexes
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-06-22 16:19:12 -04:00
dependabot[bot]
05c1a1459f
Bump protobufjs in /asset-transfer-basic/rest-api-typescript (#755)
Bumps [protobufjs](https://github.com/protobufjs/protobuf.js) from 6.11.2 to 6.11.3.
- [Release notes](https://github.com/protobufjs/protobuf.js/releases)
- [Changelog](https://github.com/protobufjs/protobuf.js/blob/v6.11.3/CHANGELOG.md)
- [Commits](https://github.com/protobufjs/protobuf.js/compare/v6.11.2...v6.11.3)

---
updated-dependencies:
- dependency-name: protobufjs
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-21 18:13:38 -04:00
fraVlaca
a26eae23e1
added fixes to documentation and readmes + small fix to erc721 and erc 20 java chaincode gradle.settings (#773)
Signed-off-by: fraVlaca <ocsenarf@outlook.com>
2022-06-21 17:40:25 -04:00
fraVlaca
d65bcf8ad1
added last fixes for asset-transfer-secured-agreement (#772)
Signed-off-by: fraVlaca <ocsenarf@outlook.com>
2022-06-21 13:10:06 -04:00
Rajat Sharma
8c3534baa3 ERC20: changes made to prevent subtraction overflow
Signed-off-by: Rajat Sharma <connecttorajat@outlook.com>
2022-06-20 08:54:33 -04:00
Rajat Sharma
dc015eb3eb ERC1155: subtraction overflow issue resolved
Signed-off-by: Rajat Sharma <connecttorajat@outlook.com>
2022-06-20 08:54:33 -04:00
Rajat Sharma
fc2494aebd ERC20: check for token initialized changed
Signed-off-by: Rajat Sharma <connecttorajat@outlook.com>
2022-06-15 11:06:03 -04:00
Rajat Sharma
194aff808d ERC:721 check for key already present changed
Signed-off-by: Rajat Sharma <connecttorajat@outlook.com>
2022-06-15 11:06:03 -04:00
Rajat Sharma
e00841bd10 function CheckInitialized renamed
Signed-off-by: Rajat Sharma <connecttorajat@outlook.com>
2022-06-15 11:06:03 -04:00
Rajat Sharma
ef42c0a094 check for Intitialized changed
Signed-off-by: Rajat Sharma <connecttorajat@outlook.com>
2022-06-15 11:06:03 -04:00
Mark S. Lewis
adfd850e64 Use new default call options API in Java off_chain_data sample
Also use hyperlinks for easier navigation to code mentioned in the README.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-06-14 11:34:10 -04:00
Zakaria Hossain Foysal
8ca50df4ff
Update setOrgEnv.sh (#748)
Type found in line 36 of setOrgEnv.sh file

Signed-off-by: Zakaria Hossain Foysal <zakaria15-9556@diu.edu.bd>
2022-05-26 13:55:02 +01:00
jkneubuh
525ff9f590
Feature/fabric builder k8s (#739)
* Support the fabric-builder-k8s for the chaincode "easy button."

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Run the CI/CD test suite using the correct matrix env for k8s builder

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Incorporate review feedback : remove zz_unused and pkgk8scc routines

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-05-26 13:52:25 +01:00
Mark S. Lewis
636a273a48
Java off-chain data store sample using Fabric Gateway (#749)
Also minor implementation changes to TypeScript sample for better consistency between implementations.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-05-26 13:42:41 +01:00
fraVlaca
94867dd517
updated and improved asset-transfer-secured-agreement sample (#751)
Signed-off-by: fraVlaca <ocsenarf@outlook.com>
2022-05-26 13:42:01 +01:00
sapthasurendran
4681fe7865
Secured agreement samples using gateway (#630)
* initial commit

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

Code refactor

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* readme

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* lint fix

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* adopted best practises

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* code refactor

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* updated azure pipeline to include the app

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* mapped json and client object

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* Moved contract interactions to contractWrapper

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* salt value unexported

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* moved try catch from contract wrapper to app

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* contract wrapper refactor
moved interfaces from utils to contract wrapper

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* exported data objects

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2022-05-23 14:17:10 +01:00
fiadanza
8662b10c58
fix to replace 443 with NGINX_HTTPS_PORT (#745)
Signed-off-by: fiadanza <francesco.iadanza@gmail.com>
2022-05-19 06:16:39 -04:00
Ry Jones
eb0a616261 Remove commercial paper reference
Fixes #740

Signed-off-by: Ry Jones <ry@linux.com>
2022-05-18 12:10:00 -07:00
Tommy TIAN
9d04fc9a2e
fix typo in asset-transfer-basic (#744)
Signed-off-by: Tommy TIAN <xtianae@connect.ust.hk>
2022-05-18 12:27:08 -04:00
fraVlaca
67a1166396 added fixes to erc token samples and documentation
Signed-off-by: fraVlaca <ocsenarf@outlook.com>
2022-05-18 07:54:36 -04:00
Mark S. Lewis
05791d30bc
Off-chain data sample using Fabric Gateway client API (#736)
Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-05-17 12:49:22 +01:00
D
17d5b96493 fix error message in deployCC
Signed-off-by: D <d_kelsey@uk.ibm.com>
2022-05-13 06:28:31 -04:00
fraVlaca
5f71466295
updated erc tokens samples (#731)
Signed-off-by: fraVlaca <ocsenarf@outlook.com>
2022-05-11 10:35:10 -04:00
Tatsuya Sato
2d32a8e7e3
test-network-k8s: Add CC debugging procedures for Linux (#735)
In chaincode debugging guidance, using the Docker host alias
`host.docker.internal` is assumed.
But, the alias is not yet supported for Linux.
So, this patch adds its alternate procedure for Linux.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2022-05-11 10:25:31 -04:00
Obadah Hammoud
d3a61e1d4f Update marbles_chaincode.go
Signed-off-by: Obadah Hammoud <obadah.hammoud@outlook.com>
2022-05-09 17:41:43 -04:00
Josh Kneubuhl
fd205a1ac0 fix two README / doc bugs
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-05-09 13:43:13 -04:00
Josh Kneubuhl
0322313a9a Includes new 'cluster init' target; Prints errors to the STDOUT
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-05-09 13:43:13 -04:00
Josh Kneubuhl
f730b804cd Refine README with CPU/RAM/Docker/Rancher limits; Adds a 10s effort to delivery client connection
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-05-09 13:43:13 -04:00
Josh Kneubuhl
3a12817c4f test network runs on containerd AND mobyd
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-05-09 13:43:13 -04:00
Josh Kneubuhl
b8a6d8efbb fix a whitespace error in the OSX resolver section
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-05-09 13:43:13 -04:00
Josh Kneubuhl
366d162453 Add a note / workaround section to address slow DNS resolution on Mac
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-05-09 13:43:13 -04:00
Josh Kneubuhl
47faca36e0 Add a workaround for DNS timeouts when connecting to the orderers
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-05-09 13:43:13 -04:00
Josh Kneubuhl
914102e814 Someday, somewhere, someone will complain that 128Mi is not enough to run Fabric.
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-05-09 13:43:13 -04:00
Josh Kneubuhl
4c04b450c6 Increase the connection timeout for peer client commands - vcap DNS is too slow to resolve in 3s
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-05-09 13:43:13 -04:00
Josh Kneubuhl
7537cafcf3 Use vcap.me as CI is not able to modify the /etc/hosts with a dummy DNS domain
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-05-09 13:43:13 -04:00
Josh Kneubuhl
a02320e1cc Move the DNS quickstart section into the prereqs
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-05-09 13:43:13 -04:00
Josh Kneubuhl
49fa452864 Address review feedback - better prereq checks
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-05-09 13:43:13 -04:00
Josh Kneubuhl
9ca1cc7c63 Add configuration / guide notes on running the test network on Rancher
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-05-09 13:43:13 -04:00
Josh Kneubuhl
551250636d Run the Kube Test Network on Rancher / k3s
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-05-09 13:43:13 -04:00
Mark S. Lewis
f2fbfa410f
Enable engine-strict checks for TypeScript Gateway samples (#726)
Use an .npmrc to enable engine-strict checks so that `npm install` will fail for projects when an incompatible Node version is used, rather than confusing errors about unsupported language features occuring at runtime.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-04-29 15:59:50 +01:00
jkneubuh
eeb4e611c7
Provide clear guidance for debugging Java chaincode as a service #684 (#724)
* Addresses Issue #548 by providing a simple guide for running Java chaincode as a service with a local debugger.

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* missed a couple of bash syntax errors

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Add metadata and activate examples to the CC README

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* move ccpackage/ contents into network script

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Fix CI test - Azure mounts git checkout at a different folder root path

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Update test-network-k8s README with updated cc deploy commands

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Run basic-asset transfer CI tests with Java + golang CC in Azure

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* remove (obsolete) test-net chaincode/ folder

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Address some PR review feedback points - README reorg

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Use the SDKs contract router Main, not a local entrypoint

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* bump the build - remove trailing newlines from a README

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-04-26 15:33:14 +01:00
James Taylor
5ad54564db
Allow custom peer images for test-network-k8s (#725)
The Hyperledger provided Fabric peer images are only a sample so it would be good to make the k8s test network peer image configurable, for example to include a custom builder

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2022-04-25 15:18:52 +00:00
Tatsuya Sato
5b72281114
test-network-k8s: Remove kubectl binary (#720)
Since kubectl binary is mistakenly added again in PR#714,
this patch removes it.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2022-04-20 10:20:08 -04:00
Renjith K N
2ac6902996
Java chaincode implementation of ERC-20 token standard. (#714)
* Java erc20 chaincode implementation Signed-off-by: renjithpta <renjithkn@gmail.com>

Signed-off-by: renjithpta <renjithkn@gmail.com>

* Java erc20 chaincode implementation Signed-off-by: renjithpta <renjithkn@gmail.com>

Signed-off-by: renjithpta <renjithkn@gmail.com>

* Java erc20 chaincode implementation Signed-off-by: renjithpta <renjithkn@gmail.com>

Signed-off-by: renjithpta <renjithkn@gmail.com>

* Java erc20 token standard chaincode implementation Signed-off-by: renjithpta <renjithkn@gmail.com>

Signed-off-by: renjithpta <renjithkn@gmail.com>
2022-04-19 07:39:53 -04:00
Tatsuya Sato
92c6916223
test-network-k8s: Remove kubectl binary (#719)
Since kubectl binary is mistakenly added in PR#713,
this patch removes it.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2022-04-19 07:30:42 -04:00
Tatsuya Sato
5f88d951cf
test-network-k8s: Some minor improvements (#718)
This patch includes some minor improvements, such as:
- Fix typos and broken links
- Correct chaincode type of asset-transfer-basic-debug
  (seems it should be ccaas)

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2022-04-19 07:29:52 -04:00
dependabot[bot]
c4886eda11
Bump moment in /asset-transfer-basic/rest-api-typescript (#711)
Bumps [moment](https://github.com/moment/moment) from 2.29.1 to 2.29.2.
- [Release notes](https://github.com/moment/moment/releases)
- [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/moment/moment/compare/2.29.1...2.29.2)

---
updated-dependencies:
- dependency-name: moment
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-18 09:40:29 -04:00
Tatsuya Sato
2df09e554d
Fix typos and broken links in docs (#712)
Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2022-04-18 09:36:49 -04:00
Basil K Y
fdcf07dc25
fix wrong indentationin in the connection profile generated for Org 3 (#715)
Signed-off-by: Basil K Y <techiebasil@gmail.com>
2022-04-18 06:38:48 -04:00
Tatsuya Sato
f8df5452d8
test-network-k8s: Support for Loading images for rest sample to KIND (#713)
This patch supports for pulling all images to the local docker cache
and loading to KIND.

Also, this adds the missing docker image pulling (couchdb) for Fabric.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2022-04-18 06:13:20 -04:00
jkneubuh
5414889399
fixes #708 : ca enrollments should be made with the ROOT CA cert (#710)
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-04-08 17:05:42 +01:00
renjithpta
1617406795
Java erc721 token standard chaincode implementation. (#709)
* Java ERC721 token standard chaincode implementation Signed-off-by: renjithpta <renjithkn@gmail.com>

Signed-off-by: renjithpta <renjithkn@gmail.com>

* Java erc20 nft token standard chaincode implementation. Signed-off-by: renjithpta <renjithkn@gmail.com>

Signed-off-by: renjithpta <renjithkn@gmail.com>
2022-04-08 11:49:52 -04:00
jkneubuh
40bfa49a80
Updates the README and documentation guide for the Kube test network's usage of Nginx ingress (#697)
* Update test-network-k8s README and docs with new Nginx Ingress

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Update cert paths in application_connection target

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-04-04 04:25:59 -04:00
Matthew B White
99e7ae8536
CORS Enablement (#696)
After feedback from the community, this PR adds CORS support in, but as an option
to enable.

Along with warnings that the default wildcard origin might not be applicable
in a production use case

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2022-04-01 09:35:57 -04:00
Matthew B White
0262d264d8
Add in a -not -path option to find to prevent the command finding (#699)
hidden directories (typically .git) to lint

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2022-04-01 08:40:28 -04:00
jkneubuh
a3ae179efb
test-network-k8s : Connect to Fabric services via Nginx Ingress - READY FOR MERGE (#692)
* Access the test network services via a local Nginx ingress controller.

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Run E2E / CI test suite against the Ingress based k8s test network

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Improved wait for Nginx Ingress - this was causing some test flakes

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-03-31 17:12:51 +01:00
Matthew B White
9fa171f824
Update the REST Example (#689)
1. The default chaincode use Capitalized JSON Names, whereas for new asset the REST validation didn't.. Adjusted
so it matches the chaincode

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2022-03-31 08:19:34 -04:00
Dave Kelsey
57919f528d
fix chaincode breakage in asset-transfer-basic (#694)
only broken in main branch, not in release-2.2

Signed-off-by: D <d_kelsey@uk.ibm.com>

Co-authored-by: D <d_kelsey@uk.ibm.com>
2022-03-31 08:38:05 +01:00
James Wilson
e1fb6269dc
Fix typo (#683)
* Fix Typo

Set up as two words functions as a verb.

Signed-off-by: James Wilson <jgwilson1214@gmail.com>
2022-03-23 15:18:22 +01:00
Charalampos Argyriou
bb57b3cf8f
Override default port of CA connection (#678)
Signed-off-by: Charalarg <charalarg@gmail.com>
2022-03-16 15:28:25 -04:00
sapthasurendran
f01eeab663
Private data samples migration (#574)
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

Updated application flow

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

Add grpc dependency in package.json

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

Update CI pipelines to run new app
Updated application description in package.json
Fixed chaincode name
Code Refactor
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2022-03-09 08:51:48 +00:00
Yuki Kondo
70cce456d4
fix docs: Chaincode-as-a-service tutorial (#663)
This PR fixes the followings to run the tutorial.
- Add an instruction to set PATH to call the `peer` command.
- Correct an option for `deployCCAAS` to debug Chaincode.

Signed-off-by: Yuki Kondo <yuki.kondo.ob@hitachi.com>
2022-03-09 08:49:34 +00:00
Dave Enyeart
2f3e9ffe3e
Fix ledger queries sample (#655)
-Go chaincode - Paginated range query should return the bookmark so that next page can be requested
-Javascript chaincode - Make query return JSON consistent with Go chaincode
-Javascript app was broken at bookmark query due to invalid JSON parsing from inconsistent chaincode responses
-Javascript and Java app had incorrect comments

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2022-03-09 08:49:03 +00:00
Arnaud J Le Hors
8d7f3ca037
Fix sample external chaincode Dockerfile (#645)
Podman isn't as lenient as docker when it comes to the syntax of the
Dockerfile and insists on getting the ARG command properly scoped.
This fixes this error:
...
[2/2] STEP 12/15: EXPOSE $CC_SERVER_PORT
Error: error building at STEP "EXPOSE $CC_SERVER_PORT": EXPOSE requires at least one argument

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2022-03-09 08:47:59 +00:00
Arnaud J Le Hors
daf08981dd
Add external chaincode service for Nano Test Network (#650)
This addresses Issue #504. This extends the test-network-nano-bash
sample to offer an option to run a fabric network without using any
containers at all. The chaincode is running as an external service
directly on the host machine.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2022-03-09 08:47:31 +00:00
James Taylor
4d2d51214c
Remove bash dependency from test network nano (#671)
The scripts do not require bash so switch to sh and add shellcheck linting

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2022-03-09 08:46:56 +00:00
Dave Enyeart
67d3c65847
Update test-network-k8s to use two digit version (#668)
Instead of using the Fabric and Fabric CA three digit version (2.4.3),
utilize the two digit version (2.4).
Each time a Fabric/FabricCA release is pushed to dockerhub the two digit version tag is updated.
This approach simplifies maintenance so that scripts don't have to be updated for every
third digit release.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2022-03-03 18:16:19 -05:00
D
b2d74ddbab fix addOrg3 for test network
Also added testing addOrg3 to build pipeline

Signed-off-by: D <d_kelsey@uk.ibm.com>
2022-03-03 17:14:49 -05:00
jkneubuh
dcc5e5650c
Update test network to fabric 2.4.3 (#660)
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-02-28 08:07:14 -05:00
Dave Enyeart
f50b52ad56
Remove duplicate erc-721 Go chaincode sample (#656)
erc-721 Go chaincode was delivered to both /go and /chaincode-go directories.
This commit removes the /go implementation.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2022-02-23 09:34:40 +01:00
Matias Salimbene
5b480ce597
refactor folder structure to match other token samples (#652)
* go port to token-erc-721

Signed-off-by: Matias Salimbene <matias.saimbene@gmail.com>
Signed-off-by: Matias Salimbene <matias.salimbene@gmail.com>

* refactor folder structure

Signed-off-by: Matias Salimbene <matias.salimbene@gmail.com>

* refactor folder structure

Signed-off-by: Matias Salimbene <matias.salimbene@gmail.com>

* refactor chaincode go folder structure

Signed-off-by: Matias Salimbene <matias.salimbene@gmail.com>

* refactor folder struncture

Signed-off-by: Matias Salimbene <matias.salimbene@gmail.com>

Co-authored-by: Matias Salimbene <matias.saimbene@gmail.com>
2022-02-21 13:10:18 +00:00
Sam Yuan
2457b387c4
impl for couchdb supports in test0network8s as hardcode (#651)
* impl for couchdb supports in test0network8s as hardcode

Signed-off-by: Sam Yuan <yy19902439@126.com>

* fix up according to pr review comments

Signed-off-by: Sam Yuan <yy19902439@126.com>
2022-02-21 06:07:24 -05:00
Kieran O Mahony
50a6dd62ad
Issue 602 (#641)
* check if running

Signed-off-by: Kieran O Mahony <Kieran.O.Mahony1@ibm.com>

* fix indent

Signed-off-by: Kieran O Mahony <Kieran.O.Mahony1@ibm.com>

better detection in create channel

Signed-off-by: Kieran O Mahony <Kieran.O.Mahony1@ibm.com>

bring network down first case

Signed-off-by: Kieran O Mahony <Kieran.O.Mahony1@ibm.com>

bring network down first case

changed count of containers to 4

Signed-off-by: Kieran O Mahony <Kieran.O.Mahony1@ibm.com>

add echo

Signed-off-by: Kieran O Mahony <Kieran.O.Mahony1@ibm.com>

typo

Signed-off-by: Kieran O Mahony <Kieran.O.Mahony1@ibm.com>

Co-authored-by: Kieran O Mahony <Kieran.O.Mahony1@ibm.com>
2022-02-20 22:43:01 -05:00
Arnaud J Le Hors
75bdde97cd
Improve REST sample README (#647)
Add that one needs to have the ledger initialized for the sample to
work.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2022-02-17 16:55:26 +00:00
Matias Salimbene
c309c364ce
go port to token-erc-721 (#625)
Signed-off-by: Matias Salimbene <matias.saimbene@gmail.com>

Co-authored-by: Matias Salimbene <matias.saimbene@gmail.com>
2022-02-15 14:58:51 +00:00
dependabot[bot]
6739199db2
Bump follow-redirects in /asset-transfer-basic/rest-api-typescript (#643)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.7 to 1.14.8.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.7...v1.14.8)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-15 15:36:23 +01:00
Charalampos Argyriou
f3db0572d0
test-network-k8s: High availability on application connection profiles (#639)
* Add peer gateway-svc as dnsNames on each peer's certificate

Signed-off-by: Charalarg <charalarg@gmail.com>

* Replace peer1 connections with gateway-svc in connection profiles of applications

Signed-off-by: Charalarg <charalarg@gmail.com>

* Update the org2 peer Gateway CSR host aliases to reference org2

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

Co-authored-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-02-14 04:54:09 -05:00
Mark S. Lewis
bee24a7615
Add README to asset-transfer-basic sample (#638)
Also:
- Refactor application-gateway-java slightly to reflect more idiomatic Java class structure, in line with asset-transfer-events sample.
- Correctly handle unexpected error case where key file is missing.
- Update Gradle wrapper for application-gateway-java.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-02-10 13:52:46 +00:00
Mark S. Lewis
58606efc06
Java gateway application sample for asset-transfer-events (#628)
Co-authored-by: deeptiraom <41100100+deeptiraom@users.noreply.github.com>
Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>

Co-authored-by: deeptiraom <41100100+deeptiraom@users.noreply.github.com>
2022-02-09 09:59:14 +00:00
jkneubuh
fee6a44fcd
Run a basic-asset-transfer CI test on Kubernetes (#637)
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-02-08 15:51:02 +00:00
Matthew B White
19b8f6bcbd
Podman experimental and not native MacOs (#636)
Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2022-02-08 15:39:39 +01:00
Matthew B White
ecbf3f5db1
Support for using podman with the test-network (#596)
* Experimental Support for using podman with the test-network

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>

* supplement podman with nerdctl

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* adds experimental support for nerdctl compose

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* install fabric images to containerd with 'nerdctl' pull

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Podman Support

Use a core set of compose files, with overlays for specific details.
In the case of podman, the overlays refer to a specific core.yaml for the peer that distables the use of teh
docker daemon

In the case of docker, the overlays add enable the docker daemon accesss for the peer to create chaincode
containers

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>

Co-authored-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-02-08 06:41:56 -05:00
Matthew B White
b50611575b
Make network.sh more tolerant (#634)
The network.sh is dependent onbeing executed from the test-network directory
This PR makes it a little more tolerant, and will add a bin directgory based on the location
of the script - not just the PWD

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2022-02-08 12:08:59 +01:00
jkneubuh
35be8f7425
Employs the Kubernetes cert-manager for storage and organization of TLS certificates. (#612)
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-02-08 09:31:09 +00:00
James Taylor
e7074ba941
Update REST sample with Redis password (#629)
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2022-02-04 14:27:40 +00:00
James Taylor
5edae7c444
Update samples to use published fabric-rest-sample (#626)
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2022-02-03 12:15:29 -05:00
Mark S. Lewis
a492d7d241
Fixes to TypeScript asset-transfer-events to match Go sample (#619)
Changed:
- Console output formatting
- Transaction arguments
- Readability and comments of code
- Linting rules
- Missing semicolons
- Package name and descrption

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-02-03 10:13:54 -05:00
Ry Jones
975c9773bd Add credentials
Signed-off-by: Ry Jones <ry@linux.com>
2022-02-03 05:30:12 -08:00
Mark S. Lewis
d652275ef0
Run Go Gateway events sample in CI (#620)
Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-02-02 14:50:21 -05:00
sapthasurendran
1a79d131b4
Asset-Transfer-Events Migration to Use Fabric-Gateway (#565)
* Gateway Migration for events application

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* Documentation Error Fix

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* Updated ci pipelines to include the app
Readme update
Wait for events to complete
Refactor code for events replay
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2022-02-02 17:01:42 +00:00
James Taylor
980da6f8aa
Add REST sample to CI (#611)
Build, test, and publish the REST server sample

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2022-02-02 16:34:08 +00:00
Kieran O Mahony
62d9b03125
updating readme with all samples (#618)
* updating readme with all samples

Signed-off-by: Kieran O Mahony <Kieran.O.Mahony1@ibm.com>

* add eol

Signed-off-by: Kieran O Mahony <Kieran.O.Mahony1@ibm.com>

Co-authored-by: Kieran O Mahony <Kieran.O.Mahony1@ibm.com>
2022-02-02 16:23:24 +00:00
Dave Kelsey
893bc29bbe
further grafana dashboard improvements (#614)
- removed unused overrides
- addressed issue using $__interval which doesn't work as well as
$interval
- addressed issue where multiple channels may not give correct output
Signed-off-by: D <d_kelsey@uk.ibm.com>

Co-authored-by: D <d_kelsey@uk.ibm.com>
2022-02-02 15:30:09 +00:00
Dave Enyeart
9e9b8d3138
Update test-network to use org level ca-cert.pem (#609)
Although test network scripts functionally worked, they demonstrated
some strange patterns around use of the ca cert.

This change makes it clear that the ca cert is configured and used
at the org level, and not related to any individual peer or orderer node.
Also that when connecting to individual servers, clients can pass the
org level CA cert as the root of trust when establishing TLS connections.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2022-02-02 09:03:20 +00:00
James Taylor
5d3cc66c25
Convert comments to tsdoc in REST sample (#606)
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2022-02-01 17:12:07 +01:00
Dave Kelsey
e2d351ed61
Minor improvement to test network docs (#607)
Also fix the version of prometheus and grafana being used
to ensure the queries remain compatible as well as avoid
issues whether they may not work if latest images already
exist on machine but are not at a level that will work

Signed-off-by: D <d_kelsey@uk.ibm.com>

Co-authored-by: D <d_kelsey@uk.ibm.com>
2022-02-01 15:53:30 +00:00
Dave Kelsey
f79190e88b
Update the grafana dashboard (#610)
Addresses some incorrect queries

Signed-off-by: D <d_kelsey@uk.ibm.com>

Co-authored-by: D <d_kelsey@uk.ibm.com>
2022-02-01 15:51:53 +00:00
Arnaud J Le Hors
730976a70e
Fix CHAINCODE_AS_A_SERVICE_TUTORIAL.md (#598)
This fixes several typos and more importantly add an instruction to
set FABRIC_CFG_PATH without which the peer command fails.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2022-01-29 16:19:50 -05:00
Mark S. Lewis
6f2b9c9d9a
Fix markdown logical structure in asset-transfer-events/README.md (#601)
Fenced code blocks within a list were at the wrong level if indentation and so logically terminated the list.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-01-27 20:19:49 +01:00
Mark S. Lewis
e33943cf4c
Refactor of asset transfer events Go sample for Fabric Gateway (#600)
Split boiler-plate connection code into a separate file since the basic sample already covers this aspect. The `app.go` file now only presents the main application code, making it much easier for readers to view.

Also changed the event replay code to use a different style of reading from the real-time eventing example, demonstrating the use of timeouts while reading events we expect to arrive quickly, and avoiding any possibility of the main application execution hanging indefinitely.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-01-27 09:39:16 -05:00
deeptiraom
e372006be7
client java application using gateway api in java sdk (#572)
* Added for client java application using gateway api in java sdk

Signed-off-by: deeptiraom <41100100+deeptiraom@users.noreply.github.com>

* removed eclipse plugin for gradle

Signed-off-by: deeptiraom <41100100+deeptiraom@users.noreply.github.com>
2022-01-27 13:57:14 +00:00
Mark S. Lewis
2581f10984
Asset transfer events Go sample for Fabric Gateway (#597)
Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-01-26 16:52:53 -05:00
Mark S. Lewis
0f877fad4d
Remove JCenter as a Gradle package repository (#589)
JCenter is deprecated, can no longer be published to, and is scheduled for removal. It is now causing build failures. Replace with Maven Central.

Also remove mavenLocal() as this is not recommended practice:

- https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:case-for-maven-local

Note that Jitpack still needs to be included as a package repository for Java chaincode since it has dependencies on an old version of com.github.everit-org.json-schema:org.everit.json.schema that is only published there.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-01-26 16:29:09 -05:00
fraVlaca
77431f5b39
add prometheus/grafana performances sample into test-network directory (#576)
Signed-off-by: fraVlaca <ocsenarf@outlook.com>

added promethesus-grafana server to test-network

Signed-off-by: fraVlaca <ocsenarf@outlook.com>

changed image for cadvisor to version that works on Linux

Signed-off-by: fraVlaca <ocsenarf@outlook.com>

improved documentation on README and tweaked docker-compose file

Signed-off-by: fraVlaca <ocsenarf@outlook.com>

updated and fixed documentation for the prometheus/grafana sample for the test-network

Signed-off-by: fraVlaca <ocsenarf@outlook.com>

final modification to grafana dashboard and prom/graf docs

Signed-off-by: fraVlaca <ocsenarf@outlook.com>
2022-01-20 09:37:37 +00:00
dependabot[bot]
84c101fb8a
Bump follow-redirects in /asset-transfer-basic/rest-api-typescript (#584)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.6 to 1.14.7.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.6...v1.14.7)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-19 14:36:23 +01:00
Eugene
e0d11fe8de
remove shift after verbose (#586)
Signed-off-by: eugene9467 <eugene@kth.tw>

Co-authored-by: eugene9467 <eugene@kth.tw>
2022-01-19 14:35:20 +01:00
Vinay Aggarwal
29ff95e2c6
Added 'jq' to prerequisite and readme for k8s test network (#582)
Signed-off-by: Vinay <vinayaggarwal@softwaysolutions.com>

Co-authored-by: Vinay <vinayaggarwal@softwaysolutions.com>
2022-01-14 13:13:06 -05:00
sapthasurendran
48fe95ee30
Added missing dependency,Updated ci pipelines to include gateway go application (#577)
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2022-01-12 13:41:38 +00:00
James Taylor
887e4a3578
Update REST sample readme (#575)
Move signposts to sample source files from index.ts to the readme and reinforce the key aspects of the sample

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2022-01-12 10:38:44 +00:00
Mark S. Lewis
3457690148
Default timeouts for basic Gateway TypeScript sample (#573)
Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2022-01-07 15:37:13 +00:00
Justin Yang
0d7fa171d1
test-network: Fix a indentation for readability (#568)
Additionally, remove a trailing white space

Signed-off-by: Justin Yang <justin.yang@themedium.io>
2021-12-22 09:56:10 -05:00
Matthew B White
e07a9ff86b
Adding examples of CCAAS and support into the test-network-k8s (#527)
* Changes to the test-network k8s deployment to use the
built-in as-a-service chaincode builder from the Peer Container

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>

* Remove the ccaas init container from org2 peer; tweak docs on ccaas config

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

Co-authored-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2021-12-17 14:09:03 +00:00
Matthew B White
96623f1bd5
Adding examples of CCAAS and support into the test-network (#560)
- Updated the test-network with examples of runnig CCAAS
- Updating the asset transfer basic with how to run chaincode as a service.

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2021-12-17 13:18:22 +00:00
James Taylor
ad20a5178d
Add build status to readme (#564)
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-16 11:37:05 +00:00
Matthew B White
c646c5904f
Merge pull request #510 from jt-nti/rest-sample
Initial REST sample
2021-12-15 17:27:53 +00:00
James Taylor
dd59991b57 Merge remote-tracking branch 'fabric-rest-sample/prepare-samples-pr' into rest-sample 2021-12-15 14:26:49 +00:00
James Taylor
af2f6e005c Prepare REST sample for fabric-samples repository
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-15 14:25:09 +00:00
James Taylor
fce803af24 Add jobs spec tests
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-15 14:24:58 +00:00
James Taylor
dfe79f7fb4 Add comments to jobs.ts
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-15 14:24:34 +00:00
sapthasurendran
0208892429
Go samples Migration to fabric-gateway (#561)
* go packages

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* Go sample Migration  to fabric-gateway

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

lint script changes

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

lint fixes

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

Upgrade go to 1.16

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

add go mod

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

To match with docs

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

lint updates

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-15 10:26:46 +00:00
James Taylor
5447e3534d Add node, and npm version requirements
Match the versions required in asset-transfer-basic/application-typescript

Also update to latest version of fabric-network

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
711f1f560b Use app.locals to store contracts and jobq
“The app.locals object has properties that are local variables within the application.”

…which looks like a better option than app.get and app.set for app settings.

Also passes app to the initJobQueueWorker function for consistency.

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
66199000ca Fix lint errors
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
5d92abc52d Clarify retry logic
Improve the separation between Fabric logic and the job queue implementation details

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
b0256a57b5 Signpost configuration details
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
5a32d803c9 Use user credentials
Use User1 certificate and private key for org1 and org2 instead of Admin credentials

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
2d7da062d8 Update Dockerfile
Fabric is on alpine 3.14 so update the sample to match

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
b1bc6663b8 Update readme
Minor changes for Fabric 2.4 and the main branch of fabric-samples

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
ad3fd7e832 Update retry logic
Previously transactions were only retried after being successfully endorsed, and always with the same transaction ID

Transactions will now be added to a queue for processing and will also be retried if endorsement fails (with a different transaction id for invalid transactions)

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
Josh Kneubuhl
3e49e92703 wrong Dockerfile path - try again
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2021-12-14 14:31:23 +00:00
Josh Kneubuhl
211523eb9f Set up a GitHub action to publish the image to ghcr.io/hyperledgendary/fabric-rest-sample
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
0456a9e94c Move error related functions to errors.ts
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
fd269237d4 Add comments to fabric.ts
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
00a2dea50b Add block event listener config
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
f1a9fea77d Fix lint errors
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
e6738818e5 Update readmes
Move usage instructions to the node sample directory and add overview/next steps
to top level readme

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
sapthasurendran
9aec7ffd2a Clear Transaction when no contract found
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
bf91df7ef3 Update transaction retry to use correct user
Also improves test coverage

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:21 +00:00
James Taylor
82b1249f4e Improve Docker support
- default command should be start, rather than start:dev in the docker image
- added a multistage build
- fixed node-gyp error
- removed dev dependencies
- added a start:dotenv script to support a .env file in production (may be useful for
k8s later)
- updated Readme and generateEnv script to simplify the setup
- updated external network in docker-compose.yaml to match the test network

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:21 +00:00
James Taylor
5d1adddd03 Refactor health routes in to separate file
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:21 +00:00
James Taylor
45683b2a1a Simplify fabric code
Attempt to make fabric code easier to document

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:21 +00:00
James Taylor
862080773e Initial API tests
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:21 +00:00
sapthasurendran
6477333743 redis mock class
code cleanup

created fabric.spec

redis testcases and additional checks

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:21 +00:00
James Taylor
f904adbf6f Add config spec tests
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:20 +00:00
James Taylor
e81a7a8b46 Update port number config
Discovered that env-var will validate port numbers, which is nice

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:20 +00:00
sapthasurendran
5bea58e501 retry condition moved to startretryloop
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:20 +00:00
sapthasurendran
b8509490ad retry count check
build err fix

retry condition testcase

retryCount to maxRetryCount

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:18 +00:00
sapthasurendran
73049e0153 docker file for app
readme update for docker

added dockerignore

added dumb-init

env var added to compose

readme update

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:17 +00:00
James Taylor
4277f4a68f Fix dist output
The jest.config.ts file was causing unintended changes to the dist folder

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:15 +00:00
James Taylor
9f48a42418 Initial test framework
Add Jest test framework

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:15 +00:00
sapthasurendran
9ae66c76da switch gateway based on user org
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

initialized fabric components to global app const

getcontractforOrg for transaction router

removed org and reused identityOrg1

env.sample file update

liveness api update

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:15 +00:00
James Taylor
05f7026e58 Update api key header
Use more common X-Api-Key header with no prefix

Also updates Unauthorized response to include a json error body
and simplifies working with new API key via curl and the vscode
rest client

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:13 +00:00
sapthasurendran
c3a34ef559 apikey auth for Org1
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

removed auth check from live,ready apis..

code format

http file changes for apikey

comments for getting api key

readme update for apikey usage

replaced -H with --header

apikey config made mandatory

fix linting

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:13 +00:00
sapthasurendran
d4318c381a liveness
used fabric protos insted of blockdecoder

changed import statement

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

revert back eslintrc

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

function name change

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

format changes

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:12 +00:00
sapthasurendran
fc769cfcb0 event handler strategy changes
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:11 +00:00
sapthasurendran
31b08b9151 removed txn commit event handler
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:10 +00:00
sapthasurendran
5d6e916436 changed getContract arg
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:09 +00:00
sapthasurendran
550e95f091 Added blockEvent handler
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:05 +00:00
sapthasurendran
804f4a6468 added getNetwork functionality
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:00 +00:00
James Taylor
19e28d817b Fix retry
Adding multiple contracts had broken the retry loop

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:57 +00:00
James Taylor
3667dd9322 Add Jira link to readme
Also adds new transactions endpoint example

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
432da5defd Add get transaction endpoint
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
60aedf1b82 Refactor transaction logic
Remove duplication and handle errors from the asset transfer smart contract

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
273fc2833a Add REST Client demo file
Add demo file for use with the REST Client for Visual Studio Code

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
400367e8a6 Add get all assets endpoint
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
d810128fcd Add patch endpoint
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
8250359db6 Add delete and put endpoints
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
8ebca62b40 Fix lint errors
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
f06f1eed4b Update logging
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
d9e0de606b Update readme
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
3b50404763 Initial create asset logic
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
324f1c8683 Specify query handler strategy
Avoid load on a single peer by specifying the PREFER_MSPID_SCOPE_ROUND_ROBIN
strategy

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
9c98450946 Initial asset route
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
1f8bc889cf Enable alwaysStrict compile option
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
063b21dd3f Initial REST API skeleton
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00
James Taylor
bbf7096e44 Initial commit
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:39 +00:00
Mark S. Lewis
72559dfbb5
More Gateway asset-transfer-basic tweaks to support docs (#556)
Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2021-12-10 08:51:21 +00:00
sapthasurendran
9df7e9f86d
Configtxlator script changes (#552)
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-09 11:37:38 +00:00
Baran Kılıç
06d67ecbfa
Add acknowledgement text for erc1155 chaincode (#554)
Signed-off-by: Baran Kılıç <baran.kilic@boun.edu.tr>
2021-12-09 10:21:16 +00:00
Mark S. Lewis
f151039f8a
Updates to asset-transfer-basic Gateway sample to align with docs (#553)
Also install goimports globally to run the linting check rather than installing to each gomodule, which was causing dependency conflicts.

Signed-off-by: Mark S. Lewis <mark_lewis@uk.ibm.com>
2021-12-09 10:20:52 +00:00
sapthasurendran
e963ddc726
lint Fix (#555)
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-09 09:44:25 +00:00
David Faulstich Diniz Reis
7fd6edb662
Query assets with pagination functions of marbles02 and asset_transfer_ledger_chaincode chaincodes without ResponseMetadata fetchedRecordsCount and bookmark (#547)
Signed-off-by: David Faulstich Diniz Reis <davidfdr@gmail.com>
2021-11-25 15:51:51 +00:00
fraVlaca
ce66638035
Extend test network to support prometheus/grafana performances framework (#542)
Signed-off-by: fraVlaca <ocsenarf@outlook.com>
2021-11-24 16:04:42 +00:00
Matthew B White
a97e8d1267
Get label for chaincode from metadata.json (#509)
Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2021-11-22 08:25:38 -05:00
sapthasurendran
3d17cf066d
Updated fabric-gateway changes and added node14 dependency (#539)
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-11-22 08:55:14 +00:00
Dave Enyeart
f898a3768d
Update test-network-k8s readme with High Availability doc link (#540)
Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2021-11-22 08:54:39 +00:00
Dave Enyeart
22c54b4690
Fix test network nano peer4 id (#541)
Fix CORE_PEER_ID for peer4.
This fix ensures that peer3 and peer4 don't share the
same chaincode container.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2021-11-22 08:54:14 +00:00
jkneubuh
ab19b8e01d
Address Issue #511 with docs and better error handling (#533)
* Address Issue #511 with docs and better error handling

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Set the TEST_NETWORK_FABRIC_VERSION in documentation for local development.

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2021-11-19 16:09:58 +00:00
Matthew B White
d19a7e4b02
Setup basic HA features for the Peers (#532)
- Add a new label to each peer to mark which org it is in
- Create new service per org, that matches this label - so the service can pick from one of multiple pods
- Update the kubeproxy to give more choice of ha stratergies
- Update the application configmaps and samples to refer to this new service rather than specific peers

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2021-11-19 16:08:26 +00:00
denyeart
271dfbb9bc
Nominate Josh Kneubuhl as fabric-samples maintainer (#536)
Josh has been helping to update samples for the Kubernetes age.
He has contributed the test-network-k8s sample and has been active in
managing fabric-samples issues. Let's welcome Josh
as a fabric-samples maintainer!

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2021-11-15 08:36:43 +00:00
James Taylor
60d5d3e218
Update application-gateway-typescript (#531)
The fabric-gateway node module has been renamed to @hyperledger/fabric-gateway

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-11-11 09:35:50 +00:00
denyeart
4640ab2e69
Retire dormant maintainers (#535)
Several fabric-samples maintainers have moved on to other projects.
See maintainer policies at
https://hyperledger-fabric.readthedocs.io/en/latest/CONTRIBUTING.html#becoming-a-maintainer

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2021-11-10 21:15:21 +01:00
James Taylor
d2eef4786d
Update node version in CI (#534)
Several Fabric projects have updated their supported node versions and 16.x is the active LTS version

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-11-10 17:17:18 +00:00
jkneubuh
8183da6666
Add an option to stage docker images locally to KIND (#528)
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2021-11-10 09:56:57 +00:00
Tatsuya Sato
8c1c36ae09 Fix type error when using the latest sort-keys-recursive
The latest version (2.1.2) of sort-keys-recursive adds TypeScript
typing, which includes export default function.
This change has caused the TS2349 type error.

This patch modifies the import form in assetTransfer.ts to fix the error.

Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2021-11-05 11:47:55 -04:00
Sam Yuan
0a1efc45cd
nit fixs (#519)
1. busybox latest image tag
2. pull images with more images
3. load images to kind cluster at local

Signed-off-by: Sam Yuan <yy19902439@126.com>
2021-11-02 15:43:31 +00:00
Matthew B White
6627cd6d65 review cmts
Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2021-11-01 16:15:30 -04:00
Matthew B White
337584045d Updated logging
- updated the logging for the application command; wasn't very good
- added some information to the help option. the current settings
  useful if you're not sure what you've set

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2021-11-01 16:15:30 -04:00
Matthew B White
cc8123bdc5 Remove temporary buildfiles
Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2021-11-01 16:12:58 -04:00
jkneubuh
1b1ef046c1
Allow overrides of the docker registry for fabric images (#518)
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2021-10-27 16:24:26 +01:00
Justin Yang
d47b2c286a
test-network: Make the regexp of checking version more strict (#515)
Signed-off-by: Justin Yang <justin.yang@themedium.io>
2021-10-26 11:24:15 +01:00
denyeart
3ba21b4f11
Fix function comment in asset-transfer-ledger-queries (#502)
Fix typo in function comment.

Thanks to RobertBetschinger for finding this issue.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2021-10-26 11:22:42 +01:00
Sam Yuan
d81684fa0a
resolve for #512 (#513)
Signed-off-by: Sam Yuan <yy19902439@126.com>
2021-10-25 16:02:06 +01:00
sapthasurendran
5355fb1b39 Asset Transfer typescript app using fabric-gateway
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

Added Fabric gateway and removed ca,tslint dependencies

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

eslint migration

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

Added gitignore

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

Transaction Flow Changes

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

Removed serviceClient import,removed outer try catch from main

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

updated fabric-gateway version

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

transaction verification flow change

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

Improved main function readability

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

extra comments

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

Updated fabric-gateway to latest

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-10-15 09:51:16 -04:00
jkneubuh
576b2e74c9
Do not weep for the KIND prototype. The [new one](test-network-k8s) is much better. (#503)
"Farewell! thou art too dear for my possessing,
And like enough thou knowst thy estimate.
The Charter of thy worth gives thee releasing;
My bonds in thee are all determinate.
For how do I hold thee but by thy granting,
And for that riches where is my deserving?
The cause of this fair gift in me is wanting,
And so my patent back again is swerving.
Thy self thou gav'st, thy own worth then not knowing,
Or me, to whom thou gav'st it, else mistaking,
So thy great gift, upon misprision growing,
Comes home again, on better judgement making.
   Thus have I had thee as a dream doth flatter:
   In sleep a king, but waking no such matter."

  - bill

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2021-10-07 14:08:22 -04:00
jkneubuh
30fb81a341
Run the fabric test network on Kubernetes (#498)
* Run the fabric test network on Kubernetes

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Re-LINT

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2021-10-06 15:50:39 +00:00
Matthew B White
3ba63b15d6
Update go.mod (#500)
Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2021-10-06 11:35:43 -04:00
nao
216d422f11
Fix: Cannot launch chaincode in nano bash in Linux (#468)
CHAINCODEADDRESS is set to host.docker.internal which is
only available in MAC and Windows environments.
For that reason, it cannot launch chaincode on Linux.
This PR sets CHAINCODEADDRESS to 127.0.0.1 instead of
host.docker.internal.

Signed-off-by: Nao Nishijima <nao.nishijima.xt@hitachi.com>
2021-10-06 13:34:04 +01:00
sapthasurendran
56a1bf3e19
* Made consistent lint command (#495)
* Removed global install of lint modules
* Fixed Lint Issues

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

added lint script forapplication javascript

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

updated lint command  for chaincode javascript

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

updated lint script

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

remove installing dependencies

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

added lint script to js projects

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

added more lint scripts

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

added more lint scripts

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

added missing npm lint command

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

added missing eslint npm module

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

Fix missing npm lint command

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

added missing eslint npm module to auction-simple javascctipt app

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

added eslint npm module

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

added eslint dependency

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

added eslint dependency

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

added eslint dependency

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

Single command for ts js lint

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

Fix or condition in lint.sh

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-10-06 13:33:29 +01:00
denyeart
ee959a2eb0
Update to Go 1.16.7 (#491)
Update Go to 1.16.7 and run "go mod tidy"
to clean up go modules in samples.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2021-10-01 09:16:56 +01:00
Baran Kılıç
98028c7da0 Fix ERC1155 chaincode indeterminism caused by iterating maps in Go
The functions BatchTransferFrom and BatchTransferFromMultiRecipient in ERC1155 sometimes give the error `ProposalResponsePayloads do not match`. This happens because iterating maps in Go is not deterministic. As a solution, I copied the keys of the map and sorted them and iterated over the sorted keys.

Signed-off-by: Baran Kılıç <baran.kilic@boun.edu.tr>
2021-09-29 17:23:35 -04:00
Indranil Majumder
c1615b31ee Checking both the old and new lifecycle name
Signed-off-by: Indranil Majumder <indranil.majumder@navis.com>
2021-09-29 17:14:35 -04:00
Indranil Majumder
7a727eb69a changes to support couchdb 3.1.1
Signed-off-by: Indranil Majumder <indranil.majumder@navis.com>
2021-09-29 17:14:35 -04:00
jkneubuh
5860027ac8
kubernetes test network : initial commit (#471)
* This is the initial add of a test-network-kind

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Update the test-network-kind README; removes the local docker registry; updated 'clean' instructions

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

Co-authored-by: Matthew B White <mbwhite@users.noreply.github.com>
2021-09-09 14:04:07 +01:00
Matthew B White
a97c0b0359
Add in a setEnvOrg script (#487)
Helper script to set environment variables, so make it eaiser to use the peer command
from the shell command line

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2021-09-08 14:54:11 +00:00
nikhil550
38e08da13b
Rm docker files mount for CLI container (#479)
Signed-off-by: Nikhil Gupta <ngupta@triplepointliquidity.com>

Co-authored-by: Nikhil Gupta <ngupta@triplepointliquidity.com>
Co-authored-by: Arnaud J Le Hors <lehors@us.ibm.com>
2021-09-07 14:22:26 +00:00
fraVlaca
53f0ef0d92
updated chaincodes for asset-transfer-basic in order to show good example on how achieving determinism over json (#486)
* updated chaincodes for asset-trnsfer-basic in order to show good example on how achieving determinism in json

Signed-off-by: fraVlaca <ocsenarf@outlook.com>

* final fixes for chaincode-java of asset-tranfer-basic

Signed-off-by: fraVlaca <ocsenarf@outlook.com>

* removed extra unused excheptions

Signed-off-by: fraVlaca <ocsenarf@outlook.com>

* corrected indentation of contract in the chancode-javasript of asset-trnsfer-basic

Signed-off-by: fraVlaca <ocsenarf@outlook.com>

* last fixes for chaincode-javascript of asset-transfer-basic

Signed-off-by: fraVlaca <ocsenarf@outlook.com>

* last last fixes for chaincode-javascript of asset-transfer-basic

Signed-off-by: fraVlaca <ocsenarf@outlook.com>
2021-09-06 13:47:25 +01:00
Luciano da Silva Ribas
bd559c81c8
Fixed state deserialize which is an uint enum in contract definition. (#467)
Signed-off-by: Luciano da Silva Ribas <luciano.ribas+git@gmail.com>

Co-authored-by: Matthew B White <mbwhite@users.noreply.github.com>
2021-09-03 08:16:35 +00:00
QQ喵
42c456ffda
Clean install folder for Java (#475)
Signed-off-by: gqqnbig <gqqnb2005@gmail.com>

Co-authored-by: Matthew B White <mbwhite@users.noreply.github.com>
2021-09-03 07:54:36 +00:00
nao
b8edd6593f
Fix: logspec output (#470)
If ORDERER_KAFKA_VERBOSE is true, the output of /logspec will contain
the following kafka information even if it is raft orderer.
{"spec":"orderer.consensus.kafka.sarama=debug:info"}
This PR deletes environment valiable for kafka in docker-compose.

Signed-off-by: Nao Nishijima <nao.nishijima.xt@hitachi.com>
2021-09-03 08:09:51 +01:00
Arnaud J Le Hors
2b47c9f0c0
Update Compose Spec & VM Spec Version (#482)
Based on PR 449 by Brett Logan <lindluni@github.com>

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2021-09-02 10:26:14 +01:00
Baran Kılıç
36fb3a9273
Add ERC1155 chaincode in Go (#463)
Signed-off-by: Baran Kılıç <baran.kilic@boun.edu.tr>
2021-09-01 23:05:57 +02:00
fraVlaca
da65e20f7d
Updated dependencies for Json and fabric-chaincode-shim:2.+ in java samples (#481)
* fixed json dependencies for java

Signed-off-by: fraVlaca <ocsenarf@outlook.com>

* updated dependency for asset-tranfer-sbe: now declaing also org.hyperledger.fabric.protos.common

Signed-off-by: fraVlaca <ocsenarf@outlook.com>

* "corrected typo of last commit and added testImplementation 'org.hyperledger.fabric.protos.common'"

Signed-off-by: fraVlaca <ocsenarf@outlook.com>

* included correct dependecy for fabric-protos and added com.google.protobuf as well

Signed-off-by: fraVlaca <ocsenarf@outlook.com>
2021-09-01 20:19:15 +02:00
Jason Yellick
a470b20944 Retire Jason Yellick as maintainer.
It's been some time since I've had the cycles available to review
anything here, so removing myself.

Signed-off-by: Jason Yellick <jason-github@unaddressable.org>
2021-08-30 23:03:08 -04:00
denyeart
2663a07765
Test network nano bash - initial commit (#450)
Test network Nano bash provides a set of minimal bash scripts
to run a Fabric network on your local machine.
The network is functionally equivalent to the docker-based Test Network,
you can therefore run all the tutorials and samples that target the Test Network.
The Fabric release binaries are utilized rather than using docker containers
to avoid all unnecessary layers. Only the chaincode and chaincode builder
runs in a docker container behind the scenes.
Using the Fabric binaries also makes it simple for Fabric developers
to iteratively and quickly modify Fabric code and test a Fabric network as a user.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2021-08-11 13:53:47 +01:00
Tatsuya Sato
8890d49d19
Fix typo (#466)
Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
2021-08-02 13:33:25 -04:00
Saliou
fb648c519d
change docker-compose version from 2 to 2.4 on folder addOrg3/docker (#448)
* change docker-compose version from 2 to 2.4  on folder addOrg3/docker

Signed-off-by: Saliou <boomse@hotmail.fr>

* changing all  docker-compose version from 2 to 2.4 under  addOrg3/docker

Signed-off-by: Saliou <boomse@hotmail.fr>

Co-authored-by: Saliou <admin@example.com>
2021-08-02 11:50:19 +02:00
nao
31ef28e647
Support docker.sock in rootless mode (#447)
Docker version 20.10 support rootless mode. That features
changes a mount path of docker.sock.
This PR loads a mount path from DOCKER_HOST environment,
and if not set, a mount path will be /var/run/docker.sock

FAB-18481

Signed-off-by: Nao Nishijima <nao.nishijima.xt@hitachi.com>
2021-07-26 16:11:14 +02:00
James Taylor
f84754ea3b
Update CreateAsset txn in basic js and ts sample (#460)
The Golang and Java sample chaincode returned an error when trying to create an asset which already exists

JavaScript and TypeScript samples should now do the same

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-07-16 14:10:12 -04:00
ankitm123
f38845ecab
chore: minor simplification of configtx yaml (#459)
We dont need << as we are not adding or overwriting any values.

Signed-off-by: ankitm123 <ankitmohapatra123@gmail.com>
2021-07-12 17:42:23 +02:00
Yuki Kondo
d5d8ff1539
Fix off_chain_data to put data to off-chain database (#457)
The off_chain_data sample fails to put data to the off-chain
database. The application does not read fetched blocks because
it uses the old interface of `addBlockListener()` to handle
block events.

This PR fixes the application to use the latest block listener
and build the off-chain database.

Signed-off-by: Yuki Kondo <yuki.kondo.ob@hitachi.com>
2021-07-07 16:40:46 -04:00
Dave Kelsey
0d64a1b70c
New HSM Typescript Sample (#455)
Signed-off-by: D <d_kelsey@uk.ibm.com>

Co-authored-by: D <d_kelsey@uk.ibm.com>
2021-07-06 11:48:34 +01:00
yuppieghost
04806b604d
Update asset_transfer_ledger_chaincode.js (#452)
fabric 2.x use **txId ** in res.value

Signed-off-by: yuppieghost <wjj315315@gmail.com>
2021-07-06 08:36:17 +01:00
Varad Ramamoorthy
5e933c10cb
expose operations port (#453)
Signed-off-by: Varad Ramamoorthy <varad@us.ibm.com>
2021-06-30 16:07:54 -04:00
nikhil550
1cd71fd26a
Add dutch auction sample with auditor (#426)
Signed-off-by: NIKHIL E GUPTA <ngupta@symbridge.com>
2021-05-24 22:01:54 +02:00
Dave Kelsey
9f07960dae
Correct Javascript Chaincode (#445)
- In CreateAsset, await was never called on putState causing issues
especially with tools such as caliper and is not correct practice.
Unfortunately all the other examples use `return` which works but is
actually not the idiomatic way of handling promises, so here await is
chosen rather than return

Signed-off-by: D <d_kelsey@uk.ibm.com>

Co-authored-by: D <d_kelsey@uk.ibm.com>
2021-05-11 10:22:25 +01:00
denyeart
6ebf692ab8
Disable Go pprof profiling in test network (#444)
Peers and Orderers by default disable Go pprof profiling, however test
network was enabling pprof in peers by default. As a good practice,
pprof should be disabled by default and only enabled when needed
for debug profiling.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2021-04-30 11:57:30 +00:00
Matthew B White
ce5186008b
Correct index location (#443)
Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2021-04-29 11:21:41 +02:00
cena
9db8164f04
Fix typo in code comment (#442)
Signed-off-by: sukill <ckdrms622@gmail.com>
2021-04-28 08:02:30 +02:00
Arnaud J Le Hors
6d043af487 Add repolinter support
Fix link in SECURITY file, and add missing copyright and license
notices.

To check, run: repolinter --rulesetUrl https://github.com/hyperledger-labs/hyperledger-community-management-tools/raw/main/repo_structure/repolint.json

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2021-04-23 15:35:20 -04:00
Simon Stone
e9122f86e7
Resign as maintainer (#441)
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
2021-04-22 21:44:57 +01:00
Arun S M
7ee1bf793d
TLS enabled external chaincode example (#438)
* Enable TLS on asset-transfer-basic external chaincode

1. Introduce environment variables to enable or disable TLS
at runtime. Also, introduce environment variables which carries
the server key, cert and the client machine's root CA cert
information.
2. Read the environment variables to decide with appropriate
assumptions on default values to work as is today.

Signed-off-by: S m, Aruna <arun.s.m.cse@gmail.com>

* Update the chaincode.env with new options

1. Introduce four new environment variables to the default
chaincode environment file.
2. Add two new environment files for easy/automation running
of the external chaincodes for different organizations.

Note that when TLS enabled, the package contents will change.
So each organization will have their own package ID
generated unlike earlier. Also, there will be two chaincode
containers running instead of one for the given example.

Signed-off-by: S m, Aruna <arun.s.m.cse@gmail.com>

* Add docker compose file for running chaincodes

The file will build and run the chaincode on the fly.
Also, it will make use of the available files which is
configured by the user as part of execution. This will
help in bringup/bringdown of the chaincode containers.

In addition, it will help in updating the environment
variables on the go.

Signed-off-by: S m, Aruna <arun.s.m.cse@gmail.com>

* Introduce crypto directory and ignore the pem contents

The directory is used by the docker-compose file for
automation. Instructions in the README.md file will
suffice the filling up of required files in this directory.

Signed-off-by: S m, Aruna <arun.s.m.cse@gmail.com>

* Instructions on TLS enabled external chaincode server

1. Add instructions to generate a chaincode server TLS
parameters.
2. Add instructions on different parameters that peer node
expects and the chaincode expects.
3. Add instructions on steps to be followed in asset-transfer
-basic to work with iTLS enabled exteral chaincode.

Signed-off-by: S m, Aruna <arun.s.m.cse@gmail.com>

* Enable chaincode to work without TLS as well

1. Root certificate is an optional parameter supplied for
chaincode to verify the peer's connection in response.
2. If TLS is enabled, then specify the key and cert
parameters. Do not expect it otherwise.

Signed-off-by: S m, Aruna <arun.s.m.cse@gmail.com>
2021-04-20 11:06:46 +02:00
Kurt Seifried
9f7a5e8d99 Fixed information leak
Signed-off-by: Kurt Seifried <kurt@seifried.org>
Signed-off-by: Ry Jones <ry@linux.com>
2021-04-19 11:50:02 -07:00
Michał Mirończuk
c5e190680f
abstore smart contract - Fixed Aval and Bval validation (#436)
Signed-off-by: Michał Mirończuk <michalmironczuk1@gmail.com>
2021-03-31 12:50:59 -04:00
Kestutis Gudynas
3acff50554
Java chaincode samples fixed (#432)
Signed-off-by: Kestutis Gudynas <44440041+kemi04@users.noreply.github.com>
2021-03-24 12:43:54 +00:00
dvrajitha
2b662e08b4
Update RegisterUser.java (#428)
Use correct identity for the appUser (Not the same admin user certificates)

Signed-off-by: dvrajitha <dvrajitha@gmail.com>
2021-03-21 07:29:30 +01:00
David Enyeart
cbf263dc3b Update "master" branch references to "main"
Update "master" branch references to "main".

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2021-03-19 19:23:09 -04:00
Simon Stone
365172ddb3
Stop ERC-20 transfer bug when to/from accounts are the same (#425)
Using the ERC-20 sample, you can submit a transfer to and from
the same account. Because the code doesn't handle this, it ends
up minting new tokens into that account.

The correct behaviour is not specified by the ERC-20 specification,
although the OpenZeppelin implementation seems to permit it.

IMO we should just block it with an error because I can't see a use
case for allowing it and it is most likely a user error.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
2021-02-24 15:07:06 -05:00
Baran Kılıç
651f2235aa
Fix empty event in token-erc-20 example (#424)
Signed-off-by: Baran Kılıç <baran.kilic@boun.edu.tr>
2021-02-24 08:58:13 -05:00
Yuki Kondo
b88ec9f4b4
Add ERC721 non-fungible token sample for javascript Chaincode (#406)
This PR adds a new non-fungible token sample using ERC721
functionalities. It includes javascript Chaincode and the README
explaining how to mint and transfer a non-fungible token in the
Fabric's test-network.

Signed-off-by: Yuki Kondo <yuki.kondo.ob@hitachi.com>
2021-02-24 13:51:24 +00:00
nikhil550
b4db1f53a0
Updates to external chaincode readme (#422)
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>
2021-02-22 02:47:56 +01:00
nikhil550
3714bd5ad5
Update test network docker compose network name (#423)
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>
2021-02-20 10:26:04 +01:00
bblwbtd
15275a0d4d
Change docker compose file version (#421)
Signed-off-by: bblwbtd <gmyxgmyx@outlook.com>
2021-02-14 18:48:35 -05:00
Brett Logan
8eb97d92a1 Remove Stray IMAGE_TAG
Signed-off-by: Brett Logan <lindluni@github.com>
2021-02-11 18:39:26 -05:00
Brett Logan
c30ceaa675 Remove Image Tag Override
The `-i` flag was originally added to support an
upgrade sample. Since that sample is no longer available
remove the `-i` flag to clean up the network.sh options
and avoid confusion as it's possible now to specify
an image version that is no longer backwards compatible
with the new test-network with osnadmin.

Signed-off-by: Brett Logan <lindluni@github.com>
2021-02-11 18:20:43 -05:00
Brett Logan
c81ba4c411 Use Dynamic Linter
The new lint.sh script no longer requires the use
of a matrix and instead dynamically finds and lints
directories.

Signed-off-by: Brett Logan <lindluni@github.com>
2021-02-11 18:11:17 -05:00
Brett Logan
855c8e4db3 Update Go Modules
Signed-off-by: Brett Logan <lindluni@github.com>
2021-02-11 18:11:17 -05:00
Brett Logan
221203fbb4 Lock Chaincode Java Dep Version
There is a dependency conflict when using newer versions of fabric-chaincode-java

Signed-off-by: Brett Logan <lindluni@github.com>
2021-02-11 18:11:17 -05:00
Brett Logan
41bb1d0b5c Fix Linting Issues
Signed-off-by: Brett Logan <lindluni@github.com>
2021-02-11 18:11:17 -05:00
Brett Logan
2907329c20 Fix Linting and Enable ES6 Syntax
Fix a small linting issue and add the es6 tag to handle
the return of a Promise as it is not defined in the ECMA
spec.

Signed-off-by: Brett Logan <lindluni@github.com>
2021-02-11 18:11:17 -05:00
Brett Logan
65b3741a93 Additional Auction Cleanup
Remove unused orgMSP vars and replace `==`
with `===`.

Signed-off-by: Brett Logan <lindluni@github.com>
2021-02-11 18:11:17 -05:00
Brett Logan
9b071d0463 Add ESLinte to Auction Example
The auction example had no ESLint configuration.
This change adds a .eslintrc.js file that matches
the rest of the projects.

This change also fixes all the linting issue in
the auction example.

Signed-off-by: Brett Logan <lindluni@github.com>
2021-02-11 18:11:17 -05:00
Brett Logan
37513c3c2b Add Service Labels and Cleanup Using Standard Tools
Add a service label to all containers launch by compose.
This allows us to filter on the label for removing running
containers.

Use filtering for querying running containers and
images to make sure we only target the containers
and images we want to remove.

Signed-off-by: Brett Logan <lindluni@github.com>
2021-02-11 17:34:49 -05:00
Brett Logan
ae81e8b296 Remove Unused Variable
Signed-off-by: Brett Logan <lindluni@github.com>
2021-02-11 17:34:49 -05:00
Brett Logan
49bf79909d
Remove .env Files and Explicitly Name Network (#417)
There have been lots of changes and quirks with the
docker-compose .env file, this change removes the file
and explicitly creates and assigns the networks in the
compose yaml files.

Signed-off-by: Brett Logan <lindluni@github.com>
2021-02-10 21:38:35 -05:00
SamYuan1990
f67079584e try to fix CI error
Signed-off-by: SamYuan1990 <yy19902439@126.com>
2021-02-08 10:52:35 -05:00
Julian Castrence
51f76977b0 Rename --channel-id to --channelID in osadmin
Signed-off-by: Julian Castrence <juliancastrence@ibm.com>
2021-02-03 13:33:19 -05:00
nikhil550
6875049c8d
Auction sample clean up (#408)
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>

Co-authored-by: Nikhil Gupta <nikhilgupta@macbook-air.lan>
2021-02-01 10:19:45 +01:00
Andrei Lebedev
822c4c4c25
Fix crypto materials copy in commercial-paper network-starter (#410)
Signed-off-by: Andrei Lebedev <lebdron@gmail.com>
2021-01-29 10:12:59 +01:00
Waleed Mortaja
14dc7e1316
Fix creating channel when ${PWD} contains space. (#402)
* Fix creating channel when ${PWD} contains space.

If the path of the project contains spaces, the "test-network/scripts/envVar.sh" script sets the value of "$ORDERER_CA" to a value containg "${PWD}" which, in turn, contains space(s).

When the variable used in "test-network/scripts/createChannel.sh", The first part of the value (before the first space) is handled as the whole value for "--cafile". Other parts are considered to be part of the command!

I tried putting (escaped) quotes in the "test-network/scripts/envVar.sh" definition for the variable "$ORDERER_CA" to make the fix more general, but the quotation marks were sometime interpreted to be part of the path that consisted of concatenated parts somewhere and it did not work.

While this edit will fix this issue, I belive this is just a work around. I expect that there is a better way to solve the root cause of the problem instead of just fixing it in one place. Moreover, All variables/paths that may include spaces should be properly handled as well.

Thanks

Signed-off-by: Waleed Mortaja <waleedmortaja@protonmail.com>

* Double quote variables evaluations that depends on $PWD

I tried to handle most (if not all) of the variables evaluations in the project that depends on $PWD by wrapping them in double-quotations to avoid values that contains white spaces.

Some lines I was not sure if they are Okay or not but I left them as they are. Samples (not all lines) as follows:
- commercial-paper/network-clean.sh:15:DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
- commercial-paper/network-starter.sh:15:DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
- asset-transfer-basic/chaincode-javascript/node_modules/fabric-shim/coverage/fabric-shim/lib/chaincode.js.html:997: optsCpy.pem = fs.readFileSync(process.env.CORE_PEER_TLS_ROOTCERT_FILE).toString();
- commercial-paper/organization/digibank/digibank.sh:29:export PEER_PARMS="${PEER_CONN_PARMS##*( )}"

The next sample I was not really sure, but still edited it:
- test-network/addOrg3/fabric-ca/registerEnroll.sh:68:  cp ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/tlscacerts/* ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt

I deliberately ignored some lines because I think they are not problem. These lines include:
- `export` sentences
- assignment sentences like: test-network/scripts/createChannel.sh:48:  FABRIC_CFG_PATH=$PWD/../config/
- gradlew files: the line SAVED="`pwd`"
- gradlew files: the line APP_HOME="`pwd -P`"
- gradlew files: the line CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

Signed-off-by: Waleed Mortaja <waleedmortaja@protonmail.com>

* remove unnecessary leading space trimming

Signed-off-by: Waleed Mortaja <waleedmortaja@protonmail.com>

* resolved conflict with master

Co-authored-by: Arnaud J Le Hors <lehors@us.ibm.com>
2021-01-20 16:32:38 +01:00
Julian Castrence
aa7287e1e3 Update Test Network to Use osadmin
FAB-18369

Signed-off-by: Julian Castrence <juliancastrence@ibm.com>
2021-01-19 20:55:19 -05:00
Brett Logan
622cf52814 Update Fabric Dependency Version
Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2021-01-19 13:02:01 -05:00
Nikhil Gupta
5b8c4390db Cleanup of register/enroll script
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>
2021-01-18 14:22:20 -05:00
nikhil550
6fd327a347
Fix error that occurs with go CC and javascript app (#399)
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>
2021-01-13 15:37:34 -05:00
Brett Logan
08aaaf0313
Update Javascript and Typescript Deps (#403)
Update all of the Node deps to 2.2.<latest>
and regenerate existing package-lock.json files

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>

Co-authored-by: Brett Logan <brett.t.logan@ibm.com>
2021-01-13 12:19:31 -05:00
Nikhil Gupta
80a698b100 Add Attribute based access control asset transfer sample
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>
2021-01-13 01:43:15 -05:00
5pecia1
ca5c16dbae add test code about SetOption in toeknERC20.test
Signed-off-by: 5pecia1 <pdpxpd@gmail.com>
2021-01-13 00:53:46 -05:00
Will Lahti
9b8f50e2d0
Remove Org3cli and configtx.yaml anchor peers from test-network (#401)
* Remove Org3cli from test-network

FAB-18381

Signed-off-by: Will Lahti <wtlahti@us.ibm.com>

* Remove configtx.yaml anchor peers from test-network

These values were only used by configtxgen's --outputAnchorPeerUpdate
function and should not be set in a channel genesis block This is because
a peer cannot be an anchor peer for a channel until it has joined that
channel and it can't join a channel until the genesis block has been
created.

FAB-18381

Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
2021-01-11 11:27:58 -05:00
Will Lahti
b690d8f30f
Stop using deprecated outputAnchorPeersUpdate in test-network (#394)
* Stop using deprecated outputAnchorPeersUpdate in test-network

FAB-18381

Signed-off-by: Will Lahti <wtlahti@us.ibm.com>

* Improve consistency of test-network output

Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
2021-01-07 13:22:03 -05:00
Brett Logan
df752bfc7b
Explicitly Mount the Docker Unix Socket (#397)
Instead of mounted the entire /var/run directory
explicitly mount the unix socket. Mounting the entire
directory causes issues with future versions of Docker
on some platforms.

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2021-01-04 13:47:57 -05:00
Julian Castrence
27ac653c74
Completely Remove Short Name Support (#390)
Signed-off-by: Julian Castrence <juliancastrence@ibm.com>

Co-authored-by: Julian Castrence <juliancastrence@ibm.com>
2020-12-22 18:10:58 -05:00
nikhil550
377ccb0b59
Add go smart contract language to deploy commands (#393)
Signed-off-by: Nikhil Gupta <nikhilgupta@macbook-air.lan>

Co-authored-by: Nikhil Gupta <nikhilgupta@macbook-air.lan>
2020-12-18 14:57:26 +01:00
Nikhil Gupta
2e4a3275ce add full path to off chain data sample
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>
2020-12-14 10:33:11 -05:00
The Coder X Tea
541cebe154
correct typing (#391)
Signed-off-by: tuyendev <tuyendev@gmail.com>
2020-12-11 08:44:57 -05:00
Chris Gabriel
36b5788bad
Fix path in app.js operational instruction comment section (#387)
Signed-off-by: Chris Gabriel <chris@hyperchainlabs.com>
2020-12-05 10:09:00 -05:00
nikhil550
8ce46a0a8b
Move high throughput application to rc1 of GO SDK (#386)
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>
2020-12-04 11:46:29 -05:00
Andrew Coleman
637ef63425
FAB-18367 Update Go client samples to use RC1 of Go SDK (#385)
Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>
2020-12-04 08:31:59 -05:00
Julian Castrence
d6773d502c Remove Short Names and Replace With Full Path in Samples
Signed-off-by: Julian Castrence <juliancastrence@ibm.com>
2020-12-02 23:59:42 -05:00
Arnaud J Le Hors
613d269f15
Fix test-network chaincode packaging log (#383)
The chaincode packaging function wrongly implies that the packaging
operation is performed on a peer when it is in fact done locally.
This change fixes that.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-12-01 08:30:46 -05:00
Julian Castrence
0d257104aa Add Burn Function and Events
FAB-18275

Signed-off-by: Julian Castrence <juliancastrence@ibm.com>
2020-11-30 14:45:36 -05:00
nikhil550
b0ea1f6488
Add events sample to readme (#381)
Signed-off-by: NIKHIL E GUPTA <ngupta@symbridge.com>
2020-11-26 20:15:56 +01:00
Nikhil Gupta
89a98e126b Update readme for auction sample
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>
2020-11-26 00:34:33 -05:00
Sijo Cherian
757b0419b7 Java chaincode for asset transfer events sample. Tested/Compatible with js application
Signed-off-by: Sijo Cherian <sijo@ibm.com>
2020-11-26 00:04:54 -05:00
Sijo Cherian
8c9fd980b9 go chaincode now sets the Asset owner as client identity certificate string (instead of base64 str)
go chaincode now sets the Asset owner as client identity certificate string (instead of base64 str)
Reason for the update: "GetClientIdentity().GetID()" api in go chaincode returns base64 string, while same api in java chaincode returns the same data as string
go & java chaincode sets same owner string
updated js app verify method

Signed-off-by: Sijo Cherian <sijo@ibm.com>
2020-11-25 22:40:04 -05:00
Sijo Cherian
a80dc201ad java chaincode for private-data sample
Java chaincode that can be deployed via test-network, with shortname 'private'
Unit test for core transactions
Bugfix for QueryAsset txn function signature
Incorporated PR feedback

Signed-off-by: Sijo Cherian <sijo@ibm.com>
2020-11-25 22:17:30 -05:00
denyeart
e29ee4d7d9
Revert "Mount configuration files (#376)" (#380)
This reverts commit 0998528b3e.
2020-11-25 11:36:11 -05:00
nikhil550
0998528b3e
Mount configuration files (#376)
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>
2020-11-24 11:04:29 +01:00
Arnaud J Le Hors
b1e848e93c
Fix link anchor "here" in sample README (#378)
This is a pet peeve of mine: 'here' is a very poor choice for a link
anchor.
See https://lehors.wordpress.com/2009/01/29/linking-the-proper-way/

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-11-23 08:23:16 -05:00
Paul O'M
d2e2a8b683
Commercial Paper 2.x sample - enhancements and documentation (#335)
* commercial paper enhancements

Signed-off-by: Paul O'M <mahoney@uk.ibm.com>

* commercial paper enhancements

Signed-off-by: Paul O'M <mahoney@uk.ibm.com>

* commercial paper enhancements

Signed-off-by: Paul O'M <mahoney@uk.ibm.com>

* Add further README changes from #335

Signed-off-by: Paul O'M <mahoney@uk.ibm.com>

* Add further README changes from #335

Signed-off-by: Paul O'M <mahoney@uk.ibm.com>

* Add further README changes from #335

Signed-off-by: Paul O'M <mahoney@uk.ibm.com>
2020-11-23 09:56:36 +01:00
denyeart
75f491f2e4
Update ERC-20 readme (#377)
Update ERC-20 readme to indicate the new contract name
and add TransferFrom tutorial for Go chaincode.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2020-11-22 07:54:25 +01:00
Julian Castrence
1829666e3a Rename token-account-based Directory to token-erc-20
FAB-18275

Signed-off-by: Julian Castrence <juliancastrence@ibm.com>
2020-11-21 11:08:18 -05:00
Julian Castrence
d3bc97fae2
Add Chaincode Events to Transfer and Approve (#369)
FAB-18275

Signed-off-by: Julian Castrence <juliancastrence@ibm.com>

Co-authored-by: Julian Castrence <juliancastrence@ibm.com>
2020-11-12 12:44:17 -05:00
Julian Castrence
79485c5bab Implemented Approve, Allowance, and TransferFrom of ERC-20
FAB-18275

Signed-off-by: Julian Castrence <juliancastrence@ibm.com>
2020-11-10 13:41:28 -05:00
JGONGSQ
c6956e5057
Update asset_transfer_ledger_chaincode.js (#368)
the `let` def wont get the object of asset, and generate an error when init the ledger

Signed-off-by: James <james.gong927@gmail.com>
2020-11-10 15:22:05 +01:00
Arnaud J Le Hors
ff8a3c8d50
Simplify auction sample (#367)
This PR changes the auction sample to a simple blind auction with just a
single item to be sold to the highest bidder.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-11-06 13:08:34 -05:00
nikhil550
bf1d9fc667
Create auction sample (#355)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-11-06 13:09:35 +01:00
Bram Dufour
981893ab4d
Signed-off-by: Bram Dufour <britaj@bancolombia.com.co> (#366)
Added check to avoid double spent in token-utxo chaincode

In the transfer function it was possible to pass the same utxo more than once in the array of input utxos without any error. Making it possible to spend the same utxo more than once in the same transaction and like this create more tokens than minted. To fix this I changed the array that was used to store the input utxo states to a map and so utxos were stored in the map by there key, which made it possible to know if a key and so a utxo had already been used.
I tested this by setting up the test-network, deploying the token-utxo chaincode with my fix, minting a utxo and trying to spent this utxo more than once in the same transaction, which was not possible anymore. It can only be spent one time anymore with this fix.
2020-11-04 15:43:54 -05:00
Sijo Cherian
e7c74060f3
Adding assertions in private data js app (#365)
Adding assertions in js app, for CI pipeline testing
  Improved readability

Signed-off-by: Sijo Cherian <sijo@ibm.com>

Co-authored-by: Sijo Cherian <sijo@ibm.com>
2020-11-04 10:34:33 -05:00
Rijul Aggarwal
33adb8d164
asset transfer basic - application typescript (#339)
Signed-off-by: Rijul Aggarwal <rijul.aggarwal@ibm.com>

Co-authored-by: Rijul Aggarwal <rijul.aggarwal@ibm.com>
2020-11-04 10:27:09 -05:00
harrisob
9f245809bb
Add Asset-Transfer-Events (#325)
Add new chaincode and javascript application to demostrate
the use of chaincode events and block events with private data.

Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
2020-11-04 15:13:08 +01:00
nikhil550
0088222df5
Move high-throughput sample to go application (#364)
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>

high throughput app
2020-10-28 22:00:24 +01:00
Yuki Kondo
e8d6e468af
[FAB-18228] Add ERC20 fungible token sample for chaincode javascript (#327)
This PR adds ERC20 capabilities to the token-account-based sample.
It includes javascript Chaincode and the updated README to explain
how to use tokens in the Fabric test-network.

Signed-off-by: Yuki Kondo <yuki.kondo.ob@hitachi.com>
2020-10-28 10:57:44 -04:00
Arnaud J Le Hors
3fbce62c01
Fix commercial paper org scripts (#362)
The current scripts given to setup the user environment do not work
on Mac:

$ . ./magnetocorp.sh
-bash: cd: /Users/lehors/Projects/Go/src/github.com/hyperledger/fabric-samples/commercial-paper/organization/magnetocorp
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed./../../../test-network: No such file or directory
-bash: ./scripts/envVar.sh: No such file or directory
[...truncated...]
export FABRIC_CFG_PATH="/Users/lehors/Projects/Go/src/github.com/hyperledger/fabric-samples/commercial-paper/organization/magnetocorp"
export PATH="/Users/lehors/Projects/Go/src/github.com/hyperledger/fabric-samples/commercial-paper/organization/magnetocorp"
export PEER_PARMS=""
Saving session...
Saving session...

The session history related output is actually captured when setting the environment variables:

$ echo $FABRIC_CFG_PATH
/Users/lehors/Projects/Go/src/github.com/hyperledger/fabric-samples/commercial-paper/organization/magnetocorp
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed./../../../config

With this simple change the scripts work:

$ echo $FABRIC_CFG_PATH
/Users/lehors/Projects/Go/src/github.com/hyperledger/fabric-samples/commercial-paper/organization/magnetocorp/../../../config

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-10-27 12:07:49 -04:00
David Enyeart
1794c026c9 Update CouchDB to 3.1.1
Update CouchDB in CI and test-network to 3.1.1.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2020-10-22 19:18:55 -04:00
Jonas Kreusch
f9bd0097b9 Update buy.js
Fixed a typo. It should be "buy" instead of "issue"

Signed-off-by: Jonas Kreusch <krejon@googlemail.com>
2020-10-22 15:31:56 -04:00
Julian Castrence
6d47d06a9b Implemented TotalSupply function of ERC-20 Token Standard
FAB-18275

Signed-off-by: Julian Castrence <juliancastrence@ibm.com>
2020-10-22 14:05:05 -04:00
Bret Harrison
524ee2d63f Have the submitTransaction look at the results of submit.
The results of the submit must be returned by the chaincode.

Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
2020-10-22 14:00:28 -04:00
nikhil550
15740deec1
Include link to external chaincode builder doc (#356)
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>
2020-10-19 20:05:52 +02:00
nikhil550
d081d0cd3f
update high througput sample to use deployCC script (#353)
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>
2020-10-18 19:50:39 +02:00
nikhil550
d82adf3e75
Fix go SDK bug and enable go SDK test (#352)
Signed-off-by: NIKHIL E GUPTA <ngupta@symbridge.com>
2020-10-16 11:28:18 -04:00
Arnaud J Le Hors
d7abc1edeb Add Token samples to README
Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-10-14 08:12:11 -04:00
Arnaud J Le Hors
949bd9095b Fix token-account-based README terminal 2 setup
The user's PATH must be set on the first use of Terminal 2 for the
call to the fabric-ca-client command to succeed. The current README
only sets it later. This fix changes that.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-10-14 08:10:21 -04:00
Arnaud J Le Hors
cb42df6d7a Fix token-utxo-based README terminal 2 setup
The user's PATH must be set on the first use of Terminal 2 for the
call to the fabric-ca-client command to succeed. The current README
only sets it later. This fix changes that.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-10-14 08:10:01 -04:00
denyeart
882218af0f
Add UTXO token sample (go chaincode) (#319)
Add a UTXO token sample go chaincode, as well as an associated readme tutorial.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2020-10-14 08:58:24 +02:00
denyeart
fa0529c393
Add account-based token sample (go chaincode) (#318)
Add an account-based token sample go chaincode, as well as an associated readme tutorial.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2020-10-14 08:26:38 +02:00
Sijo Cherian
e7189fc62a bugfix: asset type field name in couchdb index def
Signed-off-by: Sijo Cherian <sijo@ibm.com>
2020-10-12 16:27:17 -04:00
nikhil550
c18a59ceaa
Replace private data readme with link to tutorial (#346)
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>
2020-10-12 20:01:59 +02:00
Gaurav Giri
a432e7d70c
add setStateBasedEndorsementNOutOf for typescript chaincode (#330)
Signed-off-by: Gaurav Giri <girigaurav@gmail.com>
2020-10-12 16:07:15 +02:00
NIKHIL E GUPTA
6d196bd9df Move off chain data samples to basic chaincode
Signed-off-by: NIKHIL E GUPTA <ngupta@symbridge.com>
2020-10-07 03:20:07 -04:00
NIKHIL E GUPTA
327e3a78aa Remove restart mode and add mode specific help text
Signed-off-by: NIKHIL E GUPTA <ngupta@symbridge.com>
2020-10-07 03:03:00 -04:00
nikhil550
75e3be1137
Remove instantiate comment (#343)
Signed-off-by: NIKHIL E GUPTA <ngupta@symbridge.com>
2020-10-03 07:53:52 +02:00
nikhil550
22393b629b
Link to rebased private data tutorial (#342)
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>
2020-09-25 14:09:10 +02:00
GeonWoo Kim
7f6fa7ce0c
Fix Error message application-go (#341)
[FAB-18236]
* fix Error message
* add additional logs to transaction

Signed-off-by: KIM GEONWOO <kgw8919@gmail.com>
2020-09-22 11:57:14 +02:00
Kestutis Gudynas
a461ff581e
Dependencies updated (#336)
Signed-off-by: Kestutis Gudynas <44440041+kemi04@users.noreply.github.com>
2020-09-18 12:34:34 +01:00
nikhil550
ed598f733b
Update help text for colors on mac (#337)
Signed-off-by: NIKHIL E GUPTA <ngupta@symbridge.com>
2020-09-17 14:27:21 -04:00
dependabot[bot]
f497793e57
Bump yargs-parser from 13.1.1 to 13.1.2 in /fabcar/javascript (#328)
Bumps [yargs-parser](https://github.com/yargs/yargs-parser) from 13.1.1 to 13.1.2.
- [Release notes](https://github.com/yargs/yargs-parser/releases)
- [Changelog](https://github.com/yargs/yargs-parser/blob/master/docs/CHANGELOG-full.md)
- [Commits](https://github.com/yargs/yargs-parser/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-09-16 15:20:28 -04:00
user00000001
3d2875c180
Fixed script bugs "SendTransaction failed: orderers is nil". (#326)
Signed-off-by: jiangyunbin <yunbin.jiang@anchain.ai>

Co-authored-by: jiangyunbin <yunbin.jiang@anchain.ai>
2020-09-16 10:48:39 -04:00
Nikhil Gupta
5f04e3f3af Update chaincode readme table
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>
2020-09-15 14:40:14 -04:00
nikhil550
5b7f2fcae8
Remove chaincode dev sample (#314)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-09-15 15:48:16 +02:00
nikhil550
aaaf1ba59b
Replace waiting period (#331)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-09-15 15:35:38 +02:00
IKEGAWA. Koshi
c2e6c9f46e
Fix help messages (#332)
Signed-off-by: ikegawa-koshi <koshi.ikegawa.mf@hitachi.com>
2020-09-15 08:55:36 -04:00
nikhil550
c8703df425
Update main readme for new applications (#329)
Signed-off-by: Nikhil Gupta <nikhilg550@gmail.com>
2020-09-11 09:32:47 -04:00
Bret Harrison
fdea4f0f89 Add secured agreement javascript application
Add the asset-transfer-secured-agreement javascript application
and have it run during CI.

Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
2020-09-10 11:27:23 -04:00
Bret Harrison
0bc6f89cf2 Add SBE javascript application
Add in a javascript application to show the state-based-endorsement
specific type of operations

Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
2020-09-10 11:26:21 -04:00
nikhil550
d43b7b5e64
Readme updates (#323)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-09-03 10:43:18 +02:00
Gaurav Giri
f9679ed9c9
Demonstrate NoutOf policies may be set for SBE (#316)
Signed-off-by: Gaurav Giri <girigaurav@gmail.com>
2020-09-02 14:08:07 -04:00
Sangwon Hong
8df641f10d
correct the link to the correct URL (#320)
Signed-off-by: Sangwon Hong <qpakzk@gmail.com>
2020-09-01 17:02:15 -04:00
Chris Gabriel
521d4b5873
Update script artifacts removal to reference basic.tar.gz and remove fabcar (#317)
Signed-off-by: Chris Gabriel <chris_gabriel_98@yahoo.com>

udpate artifact removal to include all .tar.gz

Signed-off-by: Chris Gabriel <chris_gabriel_98@yahoo.com>
2020-08-31 14:51:43 -04:00
Rijul Aggarwal
85320a8131
Readme links fix - point to latest (#315)
Signed-off-by: Rijul Aggarwal <rijul.aggarwal@ibm.com>

Co-authored-by: Rijul Aggarwal <rijul.aggarwal@ibm.com>
2020-08-29 18:03:25 +02:00
Kyohei Shimozato
b1471ef850
Fix duplicate code: asset-transfer-basic/application-go (#313)
Signed-off-by: zatton <ou4ei1@gmail.com>
2020-08-28 09:40:36 -04:00
Naser Mirzaei
eb88315107
add utils.sh and colorize messages (#310)
* add utils.sh and colorize messages

Signed-off-by: Naser Mirzaei <nasermirzaei89@gmail.com>

* rename utils to scriptUtils

Signed-off-by: Naser Mirzaei <nasermirzaei89@gmail.com>
2020-08-27 16:43:19 -04:00
Sijo Cherian
c1424748b0
Asset transfer private-data go-chaincode - Add unit tests (#290)
* Adding golang application for asset-transfer-basic sample. (#211)

Signed-off-by: Chongxin Luo <Chongxin.Luo@ibm.com>

Improved private data Go Chaincode in idiomatic go.

Adding go chaincode unit tests

Signed-off-by: Sijo Cherian <sijo@ibm.com>

* Added unit tests for query-asset chaincode functions

Signed-off-by: Sijo Cherian <sijo@ibm.com>

* Improved README

Signed-off-by: Sijo Cherian <sijo@ibm.com>

* Added unit tests for query-asset chaincode functions

Signed-off-by: Sijo Cherian <sijo@ibm.com>

* Fixed json.Marsal usage per review comments, Improved DeleteAsset validation

Added owner collection check for DeleteAsset chaincode
JS app now demos a new expected error on DeleteAsset by a non-owner org

Signed-off-by: Sijo Cherian <sijo@ibm.com>

Co-authored-by: Dereck <Chongxin.Luo@ibm.com>
Co-authored-by: Sijo Cherian <sijo@ibm.com>
2020-08-25 10:04:03 -04:00
Gaurav Giri
67811efc92
Smart Contract using SBE implemented in Java (#302)
* asset smart contract using sbe implemented in java

Signed-off-by: Gaurav Giri <girigaurav@gmail.com>

* add sbe chaincode to ci

Signed-off-by: Gaurav Giri <girigaurav@gmail.com>
2020-08-25 10:03:28 -04:00
Paul
94faa34930 Fixed code review items 2020-08-21 16:26:35 -04:00
Paul
69b96f85e0 Added javascript chaincode unit tests for asset-transfer-basic
Signed-off-by: Paul <pksingh8878@gmail.com>
2020-08-21 16:26:35 -04:00
Naser Mirzaei
be3ce853dc hide set +x from output
Signed-off-by: Naser Mirzaei <nasermirzaei89@gmail.com>
2020-08-21 13:03:30 -04:00
David Enyeart
b3bc39ae5f Re-enable CI tests for asset-transfer-private-data JS app
Re-enable CI tests for asset-transfer-private-data JavaScript application.

Also re-add the error when private asset details are not found in the collection,
so that the CLI instructions work as desired, and to demonstrate error
handing in the client application.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2020-08-20 16:05:42 -04:00
Dereck
8bb870f930
Fix minor issues related to asset-transfer-basic application-go (#291)
* added additional logs to application.
* minor fixes

Signed-off-by: Chongxin Luo <Chongxin.Luo@ibm.com>
2020-08-20 15:40:18 -04:00
Arnaud J Le Hors
5173e73e7b Improve basic asset transfer external chaincode detect script
This change makes the way the type property is extracted from the
metadata.json file much more robust, and therefore sets a better
example.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-08-20 12:36:30 -04:00
nikhil550
fdebe1f2e6
Update sbe transfer sample readme (#304)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-08-19 12:50:33 -04:00
Chris Gabriel
9963449387 Update README table to reflect addition of Go application
Signed-off-by: Chris Gabriel <chris@hyperchainlabs.com>
2020-08-16 23:13:03 -04:00
Brett Logan
11c05fa612 Add missing apps and chaincodes to CI
Adds the apps and chaincodes to linting and testing
CI that weren't added before.

Linting issues were corrected where necessary to make CI pass.

The Basic-Go application and Private-Javascript application
are currently disabled pending fixes currently being worked on.

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-08-16 23:11:24 -04:00
denyeart
8f180cd5a3
Update asset-transfer-basic external chaincode readme (#300)
Minor clarifications to external chaincode readme.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2020-08-15 09:49:06 +02:00
Arnaud J Le Hors
0bfdecd736 Add chaincode-external for asset-transfer-basic sample.
Improve on the initial PR to expand on the README with detailed
information on how to run the external chaincode in a container
on the test network and use the node application against it.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-08-14 15:05:00 -04:00
Sijo Cherian
36a2d3a7d0
Switched private data JS app to commons util (#294)
* Switched private data JS app to commons util

Reusing JS app & ca utils
Refactored for Org1 & Org2
assettransfer-basic JS app update for commons util refactor

Signed-off-by: Sijo Cherian <sijo@ibm.com>

* fixed assettransfer-ledgerqueries & private usage of commons util refactor

Signed-off-by: Sijo Cherian <sijo@ibm.com>

Co-authored-by: Sijo Cherian <sijo@ibm.com>
2020-08-13 08:22:05 -04:00
Bret Harrison
b92d61d5cf FIx ledger queries package.json
Update the package.json to indicate the correct sample

Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
2020-08-13 05:36:33 -04:00
Bret Harrison
f361386231 Add the javascript application for ledger queries
Add the asset-transfer-ledger-queries javascript application.
Update the CI script to run it against go and javascript chaincode.

Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
2020-08-11 22:32:34 -04:00
denyeart
8e2535ee65
Fix ledger queries chaincode-go InitLedger (#293)
The InitLedger was not writing the composite key for the color index.
Therefore TransferAssetByColor was not working.

Now InitLedger will call CreateAsset which creates both the asset
and the color index entry.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2020-08-11 17:51:05 -04:00
Dereck
155a3e7e26
Adding golang application for asset-transfer-basic sample. (#211)
Signed-off-by: Chongxin Luo <Chongxin.Luo@ibm.com>
2020-08-10 10:49:04 -04:00
NIKHIL E GUPTA
026217db9a Add sbe to help text
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-08-10 09:20:35 -04:00
denyeart
1d6d557570
Fix ledger queries sample - history and pagination (#288)
Fix history query results.
Fix paginated query results.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2020-08-10 08:15:34 -04:00
denyeart
17dbe839f1
Updates to samples README (#287)
Promote asset transfer as the primary set of samples.
Misc other updates to the README.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2020-08-10 08:12:59 -04:00
Gaurav Giri
02368e99b0 SBE Improvements and Referencing SBE in fabric-samples readme and test-network
Signed-off-by: Gaurav Giri <girigaurav@gmail.com>
2020-08-09 14:58:18 -04:00
Gaurav Giri
6e965ec55f fabric samples for state-based endorsement for chaincode typescript
Signed-off-by: Gaurav Giri <girigaurav@gmail.com>
2020-08-07 18:20:57 -04:00
tyanj
55c0b47952
[BUG] res=$? missing (#260)
Signed-off-by: tyanj <653291675@qq.com>
Signed-off-by: Ry Jones <ry@linux.com>

Co-authored-by: Ry Jones <ry@linux.com>
2020-08-07 20:22:24 +02:00
nikhil550
b9661a7ecc
Update samples readme for fabcar deprecation, new langagues (#284)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-08-07 19:25:32 +02:00
Titas
0031db5de2
Fix deployment of chaincode with higher version than 9 issue (#243)
This script fails if chaincode version is higher than 9 as 'grep' does not match ex. version equal to '10'

Signed-off-by: Titas <titas.petravicius@gmail.com>
Signed-off-by: lehors <lehors@us.ibm.com>

Co-authored-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-08-06 22:59:25 +02:00
harrisob
c0ffb1cffb
Restructure the basic javascript application to use common code. (#281)
Use common code for reading a connection profile, enrolling the admin,
registering and enrolling a user, building a wallet, and
building a certificate authority client.

Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
2020-08-06 22:07:54 +02:00
Sijo Cherian
e90554f4f8
JS App workflow for private-data asset transfer, Chaincode fixes (#252)
* Adding JS App workflow, Bugfixes in Go Chaincode

Initial impl JS App workflow, Added 2 asset sample, with transfer & delete
Bugfixes: Bug fix in ReadTransferAgreement
Improved logging in Go Chaincode, Improved Chaincode error handling, checks for execution on orgs peer, bug fix, lint issues
use addDiscoveryInterest to scope policy, instead of setEndorsingOrganizations

Signed-off-by: Sijo Cherian <sijo@ibm.com>

* added js app to CI pipeline , and linting matrix

Signed-off-by: Sijo Cherian <sijo@ibm.com>

Co-authored-by: Sijo Cherian <sijo@ibm.com>
2020-08-06 14:23:11 -04:00
r2roC
cb8e03b726
asset-transfer-ledger-queries java application. (#280)
Running TestApp: gradle runApp

Signed-off-by: r2roC <arturo@IBM.com>
2020-08-06 12:00:26 -04:00
Arnaud J Le Hors
42026e2fd4 Improve unmarshalling in asset-transfer-basic Go cc
Although the current code works thanks to Go being quite
forgiving when it comes to pointers, it doesn't exhibit
the best coding style. This patch addresses this.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-08-06 11:12:56 -04:00
Dereck
e2817762f1
Add chaincode-external for asset-transfer-basic sample. (#234)
Signed-off-by: Chongxin Luo <Chongxin.Luo@ibm.com>
2020-08-06 02:12:12 +02:00
dependabot[bot]
21572f833f
Bump elliptic from 6.5.2 to 6.5.3 in /fabcar/javascript (#273)
Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](https://github.com/indutny/elliptic/compare/v6.5.2...v6.5.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-08-05 13:25:32 -04:00
aldredb
d2fb039ba5
Correct swap JSON payload in interest_rate_swaps example (#279)
Corrected swap JSON payload so that the JSON object can be unmarshalled properly

Signed-off-by: Aldred Benedict <aldred@sg.ibm.com>
2020-08-05 13:22:21 -04:00
r2roC
6e49a18d90
I removed some unnecessary comments that I left there by accident. (#278)
I also capitalized 'Tom' as that is what the asset is initialized to.

Signed-off-by: r2roC <arturo@IBM.com>
2020-08-04 19:45:47 -04:00
r2roC
86d5a50a7c
asset-transfer-basic java application. (#276)
Matches format of js app.
Running TestApp: gradle runApp

Signed-off-by: r2roC <arturo@IBM.com>
2020-08-04 17:05:45 -04:00
Chris Gabriel
1270c8418b
Fix typo in code comment (#275)
Signed-off-by: Chris Gabriel <chris_gabriel_98@yahoo.com>
2020-08-03 22:27:16 +02:00
r2roC
e51dfb9bce asset-transfer-basic Java CC. Adapted from fabcar. Unit tests are attached. Integration testing conducted using test network and asset-transfer-basic application-js.
Signed-off-by: r2roC <arturo@IBM.com>
2020-07-31 09:00:12 -04:00
Raghu Saxena
6de6c77f8d
Update addOrg3.sh (#271)
Fixed a comment which said `Create Org1 Identities` to `Create Org3 Identities`
2020-07-29 12:05:42 -04:00
Brett Logan
1c500ba30e Use Busybox to Remove Files and Folders
We delete folders and files locally on the host system
today. If the user is not a super user the files can't
be deleted as they are created by a root user in the
containers. This change uses busybox to perform the
deletions instead so a root user can remove them.

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-27 23:55:20 -04:00
Brett Logan
59613c7e91 Add Linters
Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-27 23:51:51 -04:00
Brett Logan
e6184563ad Update CI For Asset Transfer
Pushes the scripting logic into a standalone script
and adds tests for the applications which by side-effect
also test the invoke and query functions on the chaincode.

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-27 23:51:51 -04:00
Brett Logan
4c3fe17310 Refactor GetAllAssets
GetAllAssets uses getStateByRange which returns an iterator.
Refactored code to make use of the iterator as this code did
not function in its previous state

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-27 23:51:51 -04:00
Brett Logan
bd38f9220b Capitalize Function Names
Short of creating a second application that calls
the lowerCase version of functions, since Go requires
the functions be exported, capitalizing them in the
Node and Typescript chaincode seems the simplest solution

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-27 23:51:51 -04:00
Brett Logan
06c42bf68b Clean up Node Application and Address Linting Issues
Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-27 23:51:51 -04:00
Brett Logan
73a62a6780 Clean up Node Chaincode and Address Linting Issues
Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-27 23:51:51 -04:00
Brett Logan
e31ecf3165 Decorate Typescript Chaincode
Add the contract-api specific annotations and
enable the experimental features.

Also properly format code according to the linter

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-27 23:51:51 -04:00
Brett Logan
66b4b2b86a Remove Typescript Application
As the typescript application shows no Fabric
specific features we have elected to remove it

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-27 23:51:51 -04:00
NIKHIL E GUPTA
d72be92feb private data readme edits
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-07-27 23:37:41 -04:00
r2roC
64f280a1f3 Update asset_transfer_ledger_chaincode.js
Standardized function names

Signed-off-by: r2roC <arturo@IBM.com>
2020-07-27 09:32:36 -04:00
r2roC
c2b6fcfd3f Standardized createAsset parameters, removed getAllAssets function, and changed transferAssetsBasedOnColor to match go-chaincode
Signed-off-by: r2roC <arturo@IBM.com>
2020-07-27 09:32:36 -04:00
r2roC
9a9a3d2683 Modfied .gitignore so that node_modules is the only addition to the root .gitignore
Signed-off-by: r2roC <arturo@IBM.com>
2020-07-27 09:32:36 -04:00
r2roC
1c5cf4383c Added new lines at the bottom of index.js and asset_transfer_ledger_chaincode.js. Modified node version in package.json. Modified error messages in the chaincode to all begin uppercase.
Signed-off-by: r2roC <arturo@IBM.com>
2020-07-27 09:32:36 -04:00
r2roC
666e61ec6e fixed a couple unused variable issues
Signed-off-by: r2roC <arturo@IBM.com>
2020-07-27 09:32:36 -04:00
r2roC
af81e1287f Javascript version of asset-transfer-ledger-chaincode.go
Tested using the test network
Adapted from marbles02

Signed-off-by: r2roC <arturo@IBM.com>
2020-07-27 09:32:36 -04:00
Chris Gabriel
fef45be995
Remove images folder from fabric-samples. (#266)
Signed-off-by: Chris Gabriel <chris_gabriel_98@yahoo.com>

Remove images from fabric-samples and move to docs.

Signed-off-by: Chris Gabriel <chris_gabriel_98@yahoo.com>
2020-07-25 19:43:22 +02:00
nikhil550
971af50cdf
Fix bugs in deployCC script (#265)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-07-23 23:36:33 -04:00
nikhil550
8c32a85f66
Update private data chaincode to use test network script (#249)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-07-23 14:17:50 -04:00
Arnaud J Le Hors
7771b4f216
Revert "Remove Typescript References (#258)" (#261)
This reverts commit 7a23d7872a.
2020-07-23 17:06:57 +02:00
Brett Logan
7a23d7872a
Remove Typescript References (#258)
As the Typescript examples are essentially just reiterations
of the same Javascript code, there is no benefit to having
providing examples in both languages. The functional code
was exactly the same in both languages. On the contrary it
meant we widened the surface of maitainence and thus we are
removing due to the limited benefit provided by the example
chaincode and applications.

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-22 21:57:54 +02:00
stephyee
31cce9e330
Update secured asset sample tutorial link and remove README (#257)
Signed-off-by: Tiffany Harris <tiffany.harris@ibm.com>
2020-07-22 14:45:57 -04:00
nikhil550
6acc140671
Add asset transfer series documentation to Fabric samples README (#251)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-07-21 00:33:21 +02:00
Brett Logan
daa732d3d8 Revert "WIP (#253)"
This reverts commit d5ce443bee.

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-20 13:18:45 -04:00
Brett Logan
d5ce443bee
WIP (#253)
* WIP

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>

* WIP 2

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-20 12:49:16 -04:00
Tiffany Harris
cad6b90383 Fix unmarshaling asset in ReadAsset()
Signed-off-by: Tiffany Harris <tiffany.harris@ibm.com>
2020-07-20 11:51:32 -04:00
Naser Mirzaei
12b07b40a9
use mkdir -p for create directories (#248)
Signed-off-by: Naser Mirzaei <nasermirzaei89@gmail.com>
2020-07-20 11:37:16 -04:00
nikhil550
f4c439ce8a
Add endorsement policy to chaincode deployment script (#247)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-07-17 08:58:19 -04:00
Sijo Cherian
b4ed9e5afd
Simplify asset-transfer-basic javascript application (#241)
* Improve asset-transfer-basic javascript app code by combining invoke & query.js

Adding a sample application workflow to demonstrate the chaincodes, similar to the WIP PR for basic go-application (https://github.com/hyperledger/fabric-samples/pull/211).
Simplify and document-in-code the app workflow of this sample, in a single app , instead of invoke & query setting up Gateway

Signed-off-by: Sijo Cherian <sijo@ibm.com>

improve javascript app code by combining invoke & query.js

Signed-off-by: Sijo Cherian <sijo@ibm.com>

reverted chaincode func signature

Signed-off-by: Sijo Cherian <sijo@ibm.com>

* create/updateAsset signature in sync with chaincode func change as in #227

Signed-off-by: Sijo Cherian <sijo@ibm.com>

* Tested with latest chaincode, Improved comments

Signed-off-by: Sijo Cherian <sijo@ibm.com>

Co-authored-by: Sijo Cherian <sijo@ibm.com>
2020-07-15 15:21:38 -04:00
Brett Logan
14e9ccf85b Remove QueryResult Type
There was no need for GetAllAssets to return a custom type,
it can simple return an array of all assets.

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-15 13:22:56 -04:00
Brett Logan
c621ca9eb4 Fix constructQueryResponseFromIterator
constructQueryResponseFromIterator was returning a QueryResult
slice as opposed to an Asset slice.

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-15 13:22:11 -04:00
Bret Harrison
1f27c327f3 Allow install of a chaincode
options on the network script to deploy chaincode
-ccn The name to be used as the deployed name and used as
     the short name of known chaincodes when the -ccp is not included.
   known short names
     'basic' - asset-transfer-basic
     'secure' - asset-transfer-secured-agreement
     'ledger' - asset-transfer-ledger-queries
     'private' - asset-transfer-private-data
-ccl the language of the chaincode
-ccv the version
-ccs the sequence
-ccp [optional] the path to the chaincode, when provided
     the -ccn will be the deployed name
-cci [optional] the chaincode function to call during deployment
     that will perform an initialization of the channel state
     required for this chaincode

Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
2020-07-15 10:39:12 -04:00
Brett Logan
5f80da096c Refactor Asset Query Chaincode Into Idiomatic Go
Rewrites the chaincod in idiomatic Go and cleans up
the general implementation.

A future commit should push the chaincode logic itself
into a separate package as chaincode cannot be tested
when the logic is part of the main package.

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-15 10:36:04 -04:00
Chris Gabriel
621a2c263e Fix param sequence for typescript invoke function.
Signed-off-by: Chris Gabriel <chris_gabriel_98@yahoo.com>
2020-07-12 17:29:06 -04:00
Chris Gabriel
e83aecfe0c Fix param sequence for javascript invoke function.
Signed-off-by: Chris Gabriel <chris_gabriel_98@yahoo.com>
2020-07-12 17:28:43 -04:00
Chris Gabriel
aa3ae32afb Fix param sequence in smartcontract
smartcontract_test.

Signed-off-by: Chris Gabriel <chris_gabriel_98@yahoo.com>
2020-07-12 12:12:32 -04:00
NIKHIL E GUPTA
09ebf1c1ce Initialize new private data asset transfer CC
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-07-11 08:04:37 -04:00
Brett Logan
a401bc92bc Refactor Asset Secured Chaincode Into Idiomatic Go
Rewrites the chaincode in idiomatic Go and cleans up
the general implementation.

A future commit should push the chaincode logic itself
into a separate package as chaincode cannot be tested
when the logic is part of the main package.

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-11 07:53:45 -04:00
Acmefocus
59acacbef1
run fabcar go (#232)
* add go/runfabcar.sh

Signed-off-by: Acmefocus <107723772@qq.com>

* add set hosts and env in go

Signed-off-by: Acmefocus <107723772@qq.com>

* Update fabcar/startFabric.sh

Co-authored-by: Sijo Cherian <sijocherian@users.noreply.github.com>
Signed-off-by: Acmefocus <107723772@qq.com>

* Update startFabric.sh

delete  set  /etc/hosts

Signed-off-by: Acmefocus <107723772@qq.com>

* add environment variable DISCOVERY_AS_LOCALHOST

Signed-off-by: Acmefocus <107723772@qq.com>

Co-authored-by: Sijo Cherian <sijocherian@users.noreply.github.com>
2020-07-10 16:18:05 +01:00
r2roC
1249207afd Update asset_transfer_ledger_chaincode.go
Small off-by-1 bug fix.

Signed-off-by: r2roC <arturo@IBM.com>
2020-07-10 07:39:46 -04:00
Brett Logan
426cdf1f98 Add Tests and Mocks To Asset Transfer Chaincode
Many users raise questions on how to test chaincode. It used
to be much easier with the old shim, as they could directly
use the old mock stub in the shim. Now that it no longer exists
the fabcar example can provide an example of how to test chaincode.

Also worth noting is our current directory structure of our Go
chaincodes prevents the creation of mocks due to import cycles.
This change also pushes the chaincode logic down into a `chaincode`
package.

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-10 05:59:22 -04:00
Brett Logan
a04db374aa Refactor Chaincode Into Idiomatic Go
Cleans up the code and pushes the smart contract
implementation down into a `chaincode` package.
This is in prep for implementing unit testing in the
chaincode, as you cannot mock code that is part of
the main package.

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-10 05:59:22 -04:00
James Taylor
5fe1387a89
Fix java fabcar queryAllCars (#239)
Java chaincode still does not support open ended range queries

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2020-07-09 17:32:08 +01:00
NIKHIL E GUPTA
df727853c8 Update tests for commercial paper
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-07-03 13:46:01 -04:00
NIKHIL E GUPTA
a1b7da9b5c remove link to BYFN in README
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-07-03 13:44:31 -04:00
denyeart
9291154f78
Remove gossip leader election config from samples (#223)
In Fabric v2.2, the gossip defaults are changed to make
peers org leaders instead of using leader election.
This change removes the config from the samples, so that
the samples simply inherit the new peer defaults.
This will simplify the sample configuration.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2020-07-02 15:37:15 -04:00
Dereck
1eafa98a6f
Add application-typescript to asset-transfer-basci (#221)
Signed-off-by: Chongxin Luo <Chongxin.Luo@ibm.com>
2020-07-02 13:43:48 -04:00
Dereck
fd98ec650a
Add filepath check for invoke (#222)
Signed-off-by: Chongxin Luo <Chongxin.Luo@ibm.com>
2020-07-02 13:36:47 -04:00
Brett Logan
8b54e14ee4 Use Official CouchDB 3.1 Image
Fabric 2.2 removes official support for CouchDB 2.x.
The migration to 3.1 was to address fsync issues
in the underlying storage implementation in Couch.

This change moves to CouchDB 3.1 which requires the
user to now set an admin identity at startup.

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-07-02 09:56:30 -04:00
James Taylor
7154ed8629
Update fabcar java sample build (#219)
- Update gradle version
- Switch to application plugin
  (cc is started as an app not a lib, and java-library-distribution
  is still incubating)
- make sure tests and coverage checks are run before installDist

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2020-07-01 17:12:11 +01:00
James Taylor
c0570df2f8
Fix fabcar Java chaincode test & coverage failures (#218)
Also updates queryAllCars to match other implementations

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2020-07-01 11:25:08 +01:00
Dereck
2f58fb29c4
Adding NodeJS app for asset-transfer-basic sample. (#206)
Signed-off-by: Chongxin Luo <Chongxin.Luo@ibm.com>
2020-06-30 15:36:47 -04:00
nikhil550
adfef198df
FAB-18015 (#214)
Remove first network sample if Fabric 2.2

Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-06-26 12:36:29 -04:00
Chongxin Luo
a42bbba2c5 Adding chaincode-typescript to asset-transfer-basic sample.
Signed-off-by: Chongxin Luo <Chongxin.Luo@ibm.com>
2020-06-25 12:06:13 -04:00
Chongxin Luo
bee5f6e07f Adding chaincode-js to asset-transfer-basic
Signed-off-by: Chongxin Luo <Chongxin.Luo@ibm.com>
2020-06-25 12:02:53 -04:00
Chongxin Luo
22bcf8cfa4 Fix go mod for chaincode-go
Signed-off-by: Chongxin Luo <Chongxin.Luo@ibm.com>
2020-06-25 12:01:45 -04:00
Tiffany Harris
2bd1599d83 Add asset transfer ledger queries go chaincode sample
- Add new generic asset transfer sample based on the existing marbles02 sample
- Add InitLedger() to create base assets
- Add AssetExists() to check for an assets existence in the world state

Signed-off-by: Tiffany Harris <tiffany.harris@ibm.com>
2020-06-25 09:15:01 -04:00
Tatsuya Sato
fc0c2f81d9 [FAB-18020] Add config.yaml to msp folder for User1 in test-network
This patch adds missing config.yaml to msp folder for user1 in test-network
to make user1 work properly when using FabricCA.

Signed-off-by: Tatsuya Sato <Tatsuya.Sato@hal.hitachi.com>
2020-06-23 22:45:37 -04:00
zhuzeyu
6c29fa0118 modify query number in fabcar for golang
default query number for fabcar in other programming language is 1000 cars

Signed-off-by: zhuzeyu <zhuzeyu0409@gmail.com>
2020-06-19 13:09:45 -04:00
Tiffany Harris
7b2dcbf2ed Rename GetAsset to ReadAsset
Signed-off-by: Tiffany Harris <tiffany.harris@ibm.com>
2020-06-10 08:43:33 -04:00
Tiffany Harris
f1775d7fdc Rename IssueAsset to CreateAsset
- Move go chaincode to chaincode-go subdirectory
- Add public description argument to CreateAsset()

Signed-off-by: Tiffany Harris <tiffany.harris@ibm.com>
2020-06-10 08:23:06 -04:00
Tiffany Harris
82eaaad954 Rename marbles_transfer to asset-transfer-secured-agreement
- Rename marbles_transfer to a more generic and streamlined asset
- Move sample to new directory
- Remove TODO for marbles by size query

Signed-off-by: Tiffany Harris <tiffany.harris@ibm.com>
2020-06-09 23:24:52 -04:00
Chongxin Luo
a228b16364 Initialize asset transfer basic sample.
Signed-off-by: Chongxin Luo <Chongxin.Luo@ibm.com>
2020-06-09 19:21:24 -04:00
NIKHIL E GUPTA
86c194615d Update private data marbes for smart contract api
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-06-09 15:52:35 -04:00
robmurgai
045d9b69bc
Update deployCC.sh (#199)
In queryInstalled()
Removing line:   echo PackageID is ${PACKAGE_ID}
the ```peer lifecycle chaincode queryinstalled``` cmd already prints the Package ID when successfull.

Signed-off-by: Rob Murgai <murgai@us.ibm.com>
2020-06-05 16:07:14 -04:00
Tatsuya Sato
8c7e8e1b2f
[FAB-17957] Delete --tls extra arguments from fabric-samples (#198)
`--tls` option of the peer command does not require any argument.
On the other hand, some scripts assign the arguments.

This patch deletes the unnecessary arguments.

Also, this patch fixes a minor problem on private data tutorial instructions
for base64 (Related to FAB-13777).

Signed-off-by: Tatsuya Sato <Tatsuya.Sato@hal.hitachi.com>
2020-06-04 16:49:29 -04:00
Tiffany Harris
0d247f06b7 Add VerifyAssetProperties to marbles_transfer example
- Add query to verifies asset properties
- Delete price records from buyer and seller private data collections
when transfer is complete
- Add 'receipt' for asset transfer

Signed-off-by: Tiffany Harris <tiffany.harris@ibm.com>
2020-06-04 12:34:50 -04:00
Tatsuya Sato
808f035088
[FAB-17952] Fix test-network to use the latest version of fabric-ca (#195)
To get rid of hard-coded versioning and use the latest version of fabric-ca
in test-network, this patch modifies the existence check logic of
the fabric-ca-client binary in the same way as peer and orderer.

Also, this patch updates addOrg3.sh to use cai <ca_imagetag> option.

Signed-off-by: Tatsuya Sato <Tatsuya.Sato@hal.hitachi.com>
2020-06-03 13:34:26 -04:00
Andrew Coleman
87a2bc7afd
FABG-935 Update Go fabcar sample use latest beta (#196)
Now that fabric-sdk-go beta2 has been released which contains the new programming model, update the dependency in the fabcar go sample

Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>
2020-06-03 07:47:43 +01:00
Andrew Coleman
cda88df4f6
FABG-935 GoSDK Fabcar sample (#192)
Fabcar sample demonstrating the use of the new Gateway package in the Go SDK

Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>
2020-05-27 15:19:16 +01:00
Pratik Patil
2759db2847
Disconnected from the gateway in fabcar query.js (#190)
Signed-off-by: pratikpatil024 <pratikspatil024@gmail.com>
2020-05-27 11:22:01 +02:00
Ry Jones
61107dbf84
FAB-17930: Update licenses (#191)
Signed-off-by: Ry Jones <ry@linux.com>
2020-05-26 21:43:33 +02:00
Tiffany Harris
df292e0e8d Implement sale, bid, and history queries
- Add marbles proposed sale and bid prices queries
- Add marbles history query
- Add verification of ownership when selling marble

Signed-off-by: Tiffany Harris <tiffany.harris@ibm.com>
Signed-off-by: Dereck Luo <dereckluo@gmail.com>
2020-05-25 21:22:01 -04:00
NIKHIL E GUPTA
0c61f84af7 Fix last image in transfer sample
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-05-21 14:17:41 -04:00
nikhil550
59af212cb3
Add transfer sample to readme (#189)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-05-21 15:48:31 +02:00
NIKHIL E GUPTA
577bf20fd8 Update marbles transfer images
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-05-20 17:04:14 -04:00
NIKHIL E GUPTA
6c876534bc Add function to private data hash to sample private data chaincode
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-05-20 17:02:46 -04:00
Arnaud J Le Hors
23df2d620a
FGJ-84 Update Fabcar Java app to 2.1.1 (#167)
This updates the fabcar java application to work with the fabric
gateway java version 2.1.1.
It also changes pom.xml to produce a jar file that is self contained
for ease of use.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-05-20 09:03:10 +01:00
Arnaud J Le Hors
a9968ea811
Add CHANGELOG.md with script to update it (#162)
Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-05-19 15:52:13 +01:00
Arnaud J Le Hors
2e3683c419
Add missing Copyright in some files (#163)
Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-05-19 15:50:48 +01:00
Pluto
0396bbd853
fix first network byfn.sh usage (#186)
Signed-off-by: zhuzeyu <zhuzeyu0409@gmail.com>
2020-05-19 11:49:06 +02:00
Arnaud J Le Hors
b2c486a1a4
Nominate Nikhil Cupta as Fabric-samples maintainer (#180)
Nik has been the main source of progress in the fabric-samples
repository for several months, making significant improvements with
the introduction of test-network and updates of all the different
samples around it, among other things.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-05-18 18:03:44 +02:00
NIKHIL E GUPTA
72c4bbaff0 Add asset transfer (marbles transfer) sample chaincode
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-05-15 16:28:49 -04:00
nikhil550
c750e9db6a
Remove adding current directory to path (#184)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-05-15 11:34:15 -04:00
duanmeng1992
a3d26a136d
Add CA version argument, CA version does not match fabric version, so it must use another argument (#178)
* add ca version argument,fix bug

Signed-off-by: duanmeng <duanmeng@cmss.chinamobile.com>

* codereview fix

Signed-off-by: duanmeng <duanmeng@cmss.chinamobile.com>
2020-05-08 07:13:29 +02:00
Tatsuya Sato
16d5be3bb9
[FAB-17847] Fix some wrong messages in test-network (#181)
Signed-off-by: Tatsuya Sato <Tatsuya.Sato@hal.hitachi.com>
2020-05-07 22:39:22 +02:00
NIKHIL E GUPTA
a576a27e1b Remove docker-compose-e2e file
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-05-07 11:59:49 -04:00
denyeart
93c55c59cc
Update user echo text in test network (#172)
Clarify config tx generation messages.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2020-05-04 10:18:29 +02:00
heatherlp
6f853b56a4 FABCAG-27 Update fabric-samples to use latest contract-api-go@v1.1.0
Signed-off-by: heatherlp <heatherpollard0@gmail.com>
2020-05-01 09:47:36 -04:00
nikhil550
b0d73fefe1
[FAB-17818] Update documetation in Fabric samples repo (#170)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-04-30 17:54:51 +02:00
Hongbin Mao
cedb74dea3
add miss checksum (#168)
Signed-off-by: hello2mao <hello2mao@gmail.com>
2020-04-27 12:59:24 +02:00
heatherlp
ab371d3985
FGJ-81 Update to use latest v2.1.0 of gateway-java (#166)
Signed-off-by: heatherlp <heatherpollard0@gmail.com>
2020-04-23 21:52:41 +02:00
Ry Jones
3cc16ab756
FAB-17777 Create basic settings.yaml (#165)
This represents the current settings of this repo.

Signed-off-by: Ry Jones <ry@linux.com>
2020-04-22 08:09:56 +02:00
Arnaud J Le Hors
a091687b9a Fix Fabcar java dependencies
Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-04-20 14:20:56 -04:00
charlielin
d53c1ef3b3
making commercial-paper application-java to fit 2.0.0 (#160)
Signed-off-by: linqili <charlielin06@gmail.com>

Co-authored-by: linqili <charlielin06@gmail.com>
2020-04-17 15:58:17 +02:00
denyeart
11e4c23a35
Update samples to use v2.0 or later dependencies (#161)
Update application and chaincode dependendencies to use v2.0 or
later versions in package.json, build.gradle, pom.xml files.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2020-04-17 14:29:37 +02:00
heatherlp
94beab7648 FABN-1531 Use v2.1.0 sdk-node modules
Signed-off-by: heatherlp <heatherpollard0@gmail.com>
2020-04-16 14:31:02 -04:00
Arnaud J Le Hors
8820d2ff3a Fix commercial-paper README
Fixes several errors, typos, and clarifies some of the instructions.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2020-04-16 14:29:21 -04:00
nikhil550
aa9b577f65
Remove TLS enabled switch (#155)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-04-15 08:08:43 +02:00
Pritam Singh
381fb465be
upgraded abstore golang chaincode to use contract-api package (#154)
* upgraded abstore golang chaincode to use contract-api package

Signed-off-by: Pritam Singh <pkspritam10@gmail.com>

* resolved the issue

Signed-off-by: Pritam Singh <pkspritam10@gmail.com>
2020-04-08 15:36:13 +02:00
Stefan Obermeier
5e5d2c8e01
Update java chaincode to be compatible with doc and other implementations (#149)
* Use numbers without leading zeroes for key

Signed-off-by: Stefan Obermeier <scray@stefan-obermeier.de>

* Update chaincode to be compatible with doc.

E.g. Return key of the queried record

Signed-off-by: Stefan Obermeier <scray@stefan-obermeier.de>

* Clean up

Use always whitespaces to indent the start of the line
Remove unnecessary whitespaces

Signed-off-by: Stefan Obermeier <scray@stefan-obermeier.de>
2020-04-07 09:09:10 +02:00
Brett Logan
c572c51d3a
Organize and Standardize ci Directory Content (#152)
This change organizes the `ci` directory into common-sense
subfolders and standardizes pipelines naming schemes.

Also removes the dead Jenkins code in the `./scripts` directory

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-04-06 22:20:43 +02:00
Brett Logan
aa409637b4
Perform General Cleanup (#151)
* Standardize CODEOWNERS to Match Other Projects

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>

* Remove Unused Files

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>

* Update README.md to Remeove Outdated References

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-04-06 21:49:14 +02:00
nikhil550
da41afabbf
Remove left over rm -rf command from BYFN (#148)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-04-01 19:13:26 +02:00
Ry Jones
4bb48a909c
Jenkins no longer used (#145)
Signed-off-by: Ry Jones <ry@linux.com>
2020-03-31 07:51:26 +02:00
dependabot[bot]
6f984e17f3
Bump acorn from 6.4.0 to 6.4.1 in /fabcar/javascript (#144)
Bumps [acorn](https://github.com/acornjs/acorn) from 6.4.0 to 6.4.1.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/6.4.0...6.4.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-03-31 07:49:52 +02:00
nikhil550
b155620192
Remove redundant invoke command from test network (#142)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-03-30 21:45:36 +02:00
nikhil550
851933b33e
Add enrollUser files to commercial paper (#140)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-03-30 21:38:40 +02:00
nikhil550
87600bd29b
[FAB-17268] Move fabcar sample to test network (#103)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-03-30 20:18:06 +02:00
Zak
9397788fe1
Wrong groupId on hyperledger fabric dependencies for java-application (#134)
Signed-off-by: zakariahere <zakariabouazza@fastmail.com>
Signed-off-by: Ry Jones <ry@linux.com>

Co-authored-by: Ry Jones <ry@linux.com>
2020-03-30 19:36:05 +02:00
buxiangshui
92555fb4a4
Update README.md (#133)
the path miss organization

Signed-off-by: buxiangshui <286010056@qq.com>
Signed-off-by: Ry Jones <ry@linux.com>
2020-03-30 19:24:39 +02:00
Brett Logan
59c664114d
Change Download Location of Fabric Binaries (#143)
The current scripts download the fabric binaries and place them
in `/usr/local`. Modifying the host system in CI is generally
bad practice. The `bootstrap.sh` script also downloads the
binaries into the root of the `fabric-samples` repo. It is
good practice for us to do the same in CI. We also have
several samples that make an assumption about the location
of these scripts. In the future we should re-evaluate these
examples.

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-03-30 17:51:39 +01:00
woodyjon
1f283fc698
init function does not exist on fabcar (#141)
initLedger must be called instead of init, that does not exist.
That also keeps consistency between the "with TLS" and "withtout" TLS cases.

Signed-off-by: Jonathan Gross <woodyjon@gmail.com>
2020-03-27 16:31:09 +01:00
GeonWoo Kim
defb6bbbc0
[FAB-17656] echo Generating channel.tx (#139)
echo Generating channel configuration transaction 'channel.tx'
it will be output to the console "configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel"

Signed-off-by: KIM GEONWOO <kgw8919@gmail.com>
2020-03-27 14:38:29 +01:00
YasongLi
4c7bab0c86
fix: package seletor REGEX (#135)
Signed-off-by: 李亚松 <liyasong1987x@gmail.com>
2020-03-27 14:36:30 +01:00
James Taylor
db69c6ff19
Add fabcar external service sample (#136)
Add sample which can be used with the builder scripts described in
the "Chaincode as an external service" documentation

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2020-03-20 15:06:01 +00:00
xu wu
7f5f5e6c66
[FAB-17504] add Organizations.<Org>.OrdererEndpoints and remove Orderer.Addresses (#125)
Description

The use of Orderer.Addresses in configtx.yaml is deprecated, and Organizations.<Org>.OrdererEndpoints should be used instead. Therefore, update all the fabric-samples configtx.yaml files.

Related issues

https://jira.hyperledger.org/browse/FAB-17504

Signed-off-by: xu wu <wuxu1103@163.com>
2020-03-20 16:02:44 +01:00
nikhil550
f3fc08d95f
Remove solo and kafka from test net configtx.yaml (#137)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-03-20 15:54:35 +01:00
Brett Logan
e17574d28c
Add CA's to docker test network (#124)
The CA's are not part of the `test` docker network. So
applications written and hosted on the `test` network
cannot interact with the CA

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-03-20 14:24:56 +00:00
nikhil550
faac18e6da
[FAB-17461] Move off_chain_data sample to test network (#122)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-03-20 14:23:54 +00:00
nikhil550
121a44a1d1
[FAB-17460] Move High Throughput sample to test network (#112)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>

Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-03-20 14:23:00 +00:00
Brett Logan
a2f3a66f58 Update docker image version
Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-03-10 00:04:39 -04:00
Brett Logan
e5b898c08d
Revert "first-network/scripts/*: Make Chaincode name configurable (#118)" (#131)
This reverts commit 9ef61e2d72.

Introduced regressions when running without explicitly specifying
a chaincode label

Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-02-26 01:22:13 -05:00
Anoop Vijayan Maniankara
9ef61e2d72
first-network/scripts/*: Make Chaincode name configurable (#118)
Signed-off-by: Anoop Vijayan Maniankara <anoop@tuxera.com>
2020-02-23 07:35:41 +01:00
nikhil550
e204ebb3b2
Remove reference to 2.0 beta (#111)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-02-23 07:18:29 +01:00
harrisob
3dbe116a30
FAB-17456 fabric-samples read ccp (#117)
Have the application read the common connection profile to
build a JSON object used for the gateway connect and for
a fabric-ca client instance.

Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
2020-02-18 14:05:50 +00:00
Matthew B White
965ed1fa84
[FAB-17498] Beta Images removal, test test-network (#121)
Change 2.0.0-beta to 2.0.0 when CommercialPaper uses the test network
Add test network to the azure pipelines
Correct test network envvar script

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2020-02-12 15:18:17 +00:00
nikhil550
403019e684
[FAB-17495] Remove Basic Network sample (#120)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-02-11 16:35:21 +00:00
Matthew B White
883ef995fd
[FAB-17457] Script correction (#119)
Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2020-02-11 13:57:36 +00:00
Matthew B White
b89ee34ff7
Update Commercial Paper to v2.0 Lifecycle (#109)
* WIP Commercial Paper -> Test network

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>

* Update Commercial Paper to v2.0 lifecycle

- move to using the test-network
- updating README.md to include commands to use v2.0 lifecylce
- update Contracts and Applications to use 2.0 libraries

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2020-02-11 09:38:52 +00:00
Andrew Hurt
4208644416
[FAB-17478] Update commercial paper to use go api v1.0.0 (#115)
Signed-off-by: Andrew Hurt <andrew.hurt1@ibm.com>
2020-02-07 10:53:14 +00:00
Andrew Hurt
0df5ed9269
[FAB-17477] Update fabcar to use go api v1.0.0 (#116)
Signed-off-by: Andrew Hurt <andrew.hurt1@ibm.com>
2020-02-07 10:42:47 +00:00
Matthew B White
571733f7b9 [FAB-17447] Update to 2.0.0 Libraries
NodeSDK has not been released at 2.0.0 to date

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2020-01-29 00:26:12 -05:00
nikhil550
67b4ee757b Add Org3 bugs in test network (#108)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-01-24 14:14:16 +00:00
Andrew Hurt
5b93dd0cc0 [FAB-17140] Add go commercial paper contract (#102)
Signed-off-by: Andrew Hurt <andrew.hurt1@ibm.com>
2020-01-24 14:12:30 +00:00
Brett Logan
4fe6a2507e [FABCI-482] Update Nexus URL's to Artifactory (#92)
Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-01-20 15:33:02 +00:00
NIKHIL E GUPTA
1488fbbe01 Add 1.x versions of fabric to blacklisted versions
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-01-19 17:42:22 -05:00
Brett Logan
8ca279d53d Add Support for Versioning NodeJS (#106)
Signed-off-by: Brett Logan <brett.t.logan@ibm.com>
2020-01-17 21:37:09 +01:00
nikhil550
b3b526728f FAB-17243 Add support for Fabric CA for Org3 on the (#91)
test network.

Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-01-16 22:32:12 +01:00
nikhil550
ce41ff7733 Remove references to vendoring chaincode from your gopath (#96)
in the interest rate sample README

Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2020-01-16 22:11:17 +01:00
Tatsuya Sato
4235d30cdb [FAB-17306] Fix artifact names in test-network (#97)
This patch fixes some wrong artifact names for fabric-ca in
`fabric-samples/test-network/network.sh`.

Artifacts names which include `issuerPublicKey` and `issuerRevocationPublicKey`
should start with capital letters.

Due to the wrong names, some files remain even after running the command to
bring down networks using fabric-ca.

Signed-off-by: Tatsuya Sato <Tatsuya.Sato@hal.hitachi.com>
2020-01-16 22:04:00 +01:00
Matthew B White
4c2a0a4a49 [FAB-16147] Update Commercial Paper to work with v2 (#98)
Update the applications and scripts to use the new v2
SDKs and the new lifecycle

Add in a basic script based on the readme.md that does
a basic run of the scenario

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2020-01-14 16:44:31 +00:00
Ry Jones
6d9fd6f7e1 Remove Gerrit reference
Signed-off-by: Ry Jones <ry@linux.com>
2020-01-10 11:21:22 -05:00
Arnaud J Le Hors
a026a4ffbf Fixed typo (#90)
Originally submitted as PR81 by https://github.com/ArkiZh

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2019-12-16 08:33:58 +00:00
Fábio Nogueira de Lucena
cdb0e8b40c TYPO (#89)
magentocorp.sh instead of magnetocorp.sh

Signed-off-by: kyriosdata <fabio@inf.ufg.br>
2019-12-16 07:22:39 +01:00
Matthew B White
94ac8b6050 Update to use beta levels of modules (#88)
Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2019-12-13 20:20:58 +00:00
Arnaud J Le Hors
b565448a70
Merge pull request #85 from nikhil550/testNetFixes
Fix test network bugs for adding org3
2019-12-13 15:49:50 +01:00
Arnaud J Le Hors
7b0534a70a
Merge pull request #87 from mbwhite/byfn-cc-name
[FAB-16844] Correct BYFN CC name
2019-12-13 15:32:17 +01:00
Matthew B White
d84863340c [FAB-16844] Correct BYFN CC name
Correct chaincode name regexp in byfn.sh so it is not restricted
to one named chaincode.

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
2019-12-13 13:53:35 +00:00
NIKHIL E GUPTA
73267e1f7f Fix test network bugs for adding org3
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2019-12-12 12:34:59 -05:00
Arnaud J Le Hors
66ac1adcdf
Merge pull request #80 from nikhil550/FAB-17145
[FAB-17145] Add test network to Fabric Samples
2019-12-12 11:12:28 +01:00
NIKHIL E GUPTA
5d58254280 [FAB-17145] Add test network to Fabric Samples
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2019-12-11 10:28:39 -05:00
Arnaud J Le Hors
28d357b814
Merge pull request #82 from satota2/FAB-17062
[FAB-17062] Fix typos in Commercial Paper readme
2019-12-04 07:20:55 +01:00
Tatsuya Sato
e9f2957afe [FAB-17062] Fix typos in Commercial Paper readme
This patch fixes some typos in Commercial Paper readme.

Signed-off-by: Tatsuya Sato <Tatsuya.Sato@hal.hitachi.com>
2019-12-04 01:54:45 +00:00
Simon Stone
4c0cc56e01
Merge pull request #78 from awjh-ibm/fabcar-go
[FAB-17139] Update fabcar go to new programming model
2019-12-03 22:09:55 +00:00
Simon Stone
ac121774fc
Merge pull request #75 from hyperledger/dependabot/npm_and_yarn/commercial-paper/organization/magnetocorp/application/eslint-utils-1.4.3
Bump eslint-utils from 1.4.0 to 1.4.3 in /commercial-paper/organization/magnetocorp/application
2019-11-27 09:55:14 +00:00
Simon Stone
1b9749af3f
Merge pull request #77 from yeasy/FAB-17121
[FAB-17121] Use new bootstrap config in orderer
2019-11-27 09:54:46 +00:00
Baohua Yang
36694d08e5 [FAB-17121] Use new bootstrap config in orderer
It includes two config changes in fabric recently:

* GenesisMethod --> BootstrapMethod
* GenesisFile --> BootstrapFile

Signed-off-by: Baohua Yang <yangbaohua@gmail.com>
Signed-off-by: Baohua Yang <baohua.yang@oracle.com>
2019-11-26 11:41:19 -08:00
Andrew Hurt
429f087c5a
update fabcar go to new programming model
Signed-off-by: Andrew Hurt <andrew.hurt1@ibm.com>
2019-11-25 16:57:20 +00:00
Simon Stone
f1a86435a0
Merge branch 'master' into dependabot/npm_and_yarn/commercial-paper/organization/magnetocorp/application/eslint-utils-1.4.3 2019-11-15 09:42:38 +00:00
Simon Stone
118fe07e9e
Merge pull request #69 from lehors/FAB-16284-remove-E2E-file-BYFN
[FAB-16284] Remove E2E file and -f option from BYFN
2019-11-15 09:40:12 +00:00
dependabot[bot]
1467086f30
Bump eslint-utils
Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.4.0 to 1.4.3.
- [Release notes](https://github.com/mysticatea/eslint-utils/releases)
- [Commits](https://github.com/mysticatea/eslint-utils/compare/v1.4.0...v1.4.3)

Signed-off-by: dependabot[bot] <support@github.com>
2019-11-14 16:27:21 +00:00
Simon Stone
3a8c3170ed
Merge branch 'master' into FAB-16284-remove-E2E-file-BYFN 2019-11-13 15:28:36 +00:00
Ry Jones
33f349a5f5 Remove Stalebot
Signed-off-by: Ry Jones <ry@linux.com>
2019-11-04 22:44:53 -05:00
Ry Jones
0e200ab61e
Merge branch 'master' into FAB-16284-remove-E2E-file-BYFN 2019-10-28 01:02:51 -07:00
Arnaud J Le Hors
c4d8bb74cf
Merge pull request #70 from hyperledger/samples_stalebot
Change stalebot settings
2019-10-27 17:20:21 +01:00
Brett Logan
6af43bfdab Change stalebot settings
Signed-off-by: Brett Logan <Brett.T.Logan@ibm.com>
2019-10-26 11:51:16 -04:00
Arnaud J Le Hors
48804014d3 [FAB-16284] Remove E2E file and -f option from BYFN
Remove leftover call to removed ReplacePrivateKey function which
makes calling ./byfn.sh up fail if cryptogen hasn't been run first.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2019-10-25 22:41:38 +02:00
Simon Stone
fe96f60311 [FAB-16850] Set up CI with Azure Pipelines
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I3821a329ec5eb439ce0f27cfbc71b28e6b0b8a09
2019-10-17 09:53:11 +01:00
Simon Stone
81aabf4c0b [FAB-16849] Various updates for Java version of FabCar
- Update .gitignore
- Use builds on Sonatype, not Nexus
- Enable new discovery as localhost flag

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: Ia0904cedf953b5ecbf6aaf859245a9bb431d3f76
2019-10-16 17:12:48 +01:00
Simon Stone
a42b858bc4 Update FabCar to reflect wallet API changes
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I845aa7af376b9a21da9f285079c025c71c43a2cf
2019-10-07 05:18:16 -04:00
Simon Stone
890f9eab9f [FAB-16713] Fix npm audit warnings
Also add .gitignore files for abstore/marbles02, as these are
currently missing.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I9f9da3e5289a275dd26c1021ea8de80def605e36
2019-10-07 04:16:39 -04:00
David Enyeart
e48e804828 [FAB-16776] Move BYFN up to V2_0 capabilities
Using V2_0_0 capabilities will turn on identification of admins
via node OU, and will fix the failing sample since cryptogen
is now setup to generate admins via node OU.

Change-Id: I30ff651a112bd88c93f6563f5e4414f8d2c6693e
Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2019-10-06 16:30:19 -04:00
Ry Jones
7b65a25a86 [IN-68] Add default GitHub SECURITY policy
Signed-off-by: Ry Jones <ry@linux.com>
Change-Id: Ie805816e929f4449689214c74964b71eac56e31d
2019-09-25 10:22:26 -07:00
Simon Stone
333dbd0baa Merge "[FAB-16668] fabcar chaincode modify console output" 2019-09-24 16:10:54 +00:00
bjzhang03
408e0e873c [FAB-16619] Fix the policy warning
This fixes #FAB-16619

Change-Id: I251d10bc9dc9baf4f7e7d20cc11a34703baffc52
Signed-off-by: bjzhang03 <bjzhang03@foxmail.com>
(cherry picked from commit 7e8edb3189)
2019-09-24 13:09:48 +00:00
SteveKIM
670d446139 [FAB-16668] fabcar chaincode modify console output
Signed-off-by: SteveKIM <khktoto@gmail.com>
Change-Id: I6f549c9ed6e3142b2476d1cd8674d2a6d453668f
2019-09-24 13:08:20 +00:00
Simon Stone
f2939e29c6 [FAB-6415] Java 11 support for Commercial Paper sample
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I3de1927a67723044899dce7ec22d4e46e4c6b944
2019-09-24 09:41:02 +01:00
Simon Stone
3d19014bd7 [FAB-6415] Java 11 support for FabCar sample
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I97cd3ab48f6f2fe828c3328adfaf706be5124387
2019-09-24 09:41:02 +01:00
Simon Stone
e2b7cb7464 [FAB-6415] Java 11 support for abstore sample
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: Ie66fc453cba72dee4ad84b5d1e77feb64a37f678
2019-09-24 09:41:02 +01:00
Simon Stone
db48612180 [FAB-6415] Increase chaincode execute timeout
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I553f4cba445c5c93bb4c04214e37eed88f664d77
2019-09-24 09:40:56 +01:00
Matthew White
7010c503ac Merge "[FAB-16607] Update FabCar to reflect CC updates" 2019-09-19 13:01:35 +00:00
Simon Stone
521a7ffc4a [FAB-16607] Update FabCar to reflect CC updates
Node.js CC:
As a result of using the new protobufjs library, certain
external APIs have changed in the Node.js chaincode. The
samples need to be updated to use these new APIs.

Java CC:
As a result of moving to Java 11, we hit this issue:
https://github.com/gradle/gradle/issues/8286
The sample needs to be updated to specify the absolute
path to checkstyle's suppression.xml.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I4db886b3feff46d165e05a7eda624230b65f9cbe
2019-09-19 13:26:51 +01:00
Dongming
c13a5ec8f6 [FAB-16528] marbles private chaincode sync up
This CR is part 2 of porting changes in marbles
private in fabric/integration by FAB-15894 back
to fabric-samples

Signed-off-by: Dongming <dongming@ibm.com>
Change-Id: Ic823bdf4c3c571f43b4700452c50fd4283d35262
2019-09-11 12:35:25 -04:00
Dongming
3fad853c15 [FAB-16528] marbles private chaincode sync up
This CR is to port minor changes made in marbles
private in fabric/integration by FAB-15894 back
to fabric-samples.

Signed-off-by: Dongming <dongming@ibm.com>
Change-Id: I3d729f0d692dbd24e11c1cce45233eda5ddb4831
2019-09-06 12:49:22 -04:00
Simon Stone
86ff0e6581 Merge "[FAB-16362] adding chaincode excution comments" 2019-09-06 12:11:26 +00:00
Simon Stone
2bd54352dd Merge "[FAB-16489] Add CODEOWNERS" 2019-09-02 08:49:55 +00:00
Ry Jones
8b9b82f747 [FAB-16489] Add CODEOWNERS
Signed-off-by: Ry Jones <ry@linux.com>
Change-Id: I3727040fe1d8c188c20a84804acb2709288bdf41
2019-08-31 19:05:45 +00:00
Ry Jones
a6ce915106 [FAB-16487] Update eslint
Signed-off-by: Ry Jones <ry@linux.com>
Change-Id: I69233df8716f0bc081b67c771fb7eeaac6fc9d52
2019-08-30 12:09:52 -07:00
jaehyun
48082cfa95 [FAB-16362] adding chaincode excution comments
adding chaincode excution comments

Signed-off-by: jaehyun <jaehyun@lgcns.com>
Change-Id: I61ce32561f68fb8db8e0dc3f0d18b0564aaafb70
2019-08-30 10:28:39 +09:00
rthatcher
1d379f341d [FAB-16474] marbles02 chaincode error
Signed-off-by: rthatcher <robert.thatcher@uk.ibm.com>
Change-Id: I72d857b2fe905cbb75e33b76b1ac838e83e6f756
2019-08-29 16:05:50 +01:00
Simon Stone
18712ca8f6 [FAB-16133] Remove Solo consensus from BYFN
A Solo ordering node offers no benefits over
a single node Raft ordering node. Raft is the
best practice for Fabric v2.0, and should be
the only option in the BYFN sample going
forwards.

This CR removes Solo and the consensus related
options from BYFN, and always uses Raft.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I686cb68d8bc8fc9a231a0fa680263175451f2820
2019-08-27 10:00:07 +01:00
Varun Agarwal
91c720a7ff [FAB-16390] Added filter for invalid transactions
Signed-off-by: Varun Agarwal <varunagarwal315@gmail.com>
Change-Id: Idb6c57e047bba9a176b312f86d05c2ee21aeb175
(cherry picked from commit f86ec95726)
2019-08-25 19:09:06 +00:00
Matthew Sykes
1d3e267bbd Redirect samples to fabric-{chaincode,protos}-go
FAB-16401 #done

Change-Id: I9e6c3857cf1842ccf43d7fa0d25ff64dbeae12d0
Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
2019-08-23 17:25:16 +00:00
Brett Logan
398a5b1a1d [FABCI-394] Remove AnsiColor Wrapper
Signed-off-by: Brett Logan <Brett.T.Logan@ibm.com>
Change-Id: I51158ccf006ec7be9c0b4506a4902f023c845a16
2019-08-19 23:30:14 +00:00
Arnaud J Le Hors
72ecf45088 Merge "[FAB-16310] Vendor Go dependencies in all samples" 2019-08-15 16:51:49 +00:00
Arnaud J Le Hors
82d886b1b4 Merge "[FAB-16285] Update blacklisted versions in BYFN" 2019-08-15 16:48:19 +00:00
Arnaud J Le Hors
08e980080a Merge "[FAB-16284] Remove E2E file and -f option from BYFN" 2019-08-15 16:48:00 +00:00
Arnaud J Le Hors
1fb272473d Merge "[FAB-16277] Update BYFN w/ Raft ports in Docker network" 2019-08-15 16:42:33 +00:00
Simon Stone
ce154e044b [FAB-16310] Vendor Go dependencies in all samples
All samples that deploy Go chaincode must now vendor
their dependencies before deployment, due to changes
in FAB-5177 which stop the shim being available at
deployment time. This CR adds the command:

"GO111MODULE=on go mod vendor"

... to all scripts/readmes as appropriate.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: If0a2cc3a20dc943917d8325a8905427a79eb2400
2019-08-15 11:44:00 +01:00
Simon Stone
6ea7c71c6c [FAB-16285] Update blacklisted versions in BYFN
Update the blacklisted versions in BYFN so that
BYFN from Fabric v2.0 samples refuses to work
with binaries and Docker images from Fabric v1.x.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I7fceb7f2b7635830ada35e2e47988d84b9ee14c3
2019-08-12 17:43:35 +01:00
Simon Stone
86cd831f93 [FAB-16284] Remove E2E file and -f option from BYFN
The docker-compose-e2e-template.yaml file and generated
docker-compose-e2e.yaml file should not be used any more,
and should be removed. The associated Docker Compose
file argument (-f docker-compose-e2e.yaml) should also
be removed.

Users wishing to deploy BYFN with a CA should use the new
-a option, and we should probably just make that the default
anyway.

There are associated documentation changes required for
this which I will do in another CR.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: Ie7fc0b809b44cbb2a7d55865ce8f3e887e0e7c58
2019-08-12 17:33:27 +01:00
Will Lahti
0063abed2a Update stale script name in interest rate swaps
FAB-16283 #done

Change-Id: I0db01dbceaa9a3f81703a9194167636a6b47bcac
Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
2019-08-12 12:02:33 -04:00
Simon Stone
3907507981 [FAB-16277] Update BYFN w/ Raft ports in Docker network
Update the Raft ordering nodes to use the same ports
inside the Docker network as they are mapped to outside
of the Docker network (7050, 8050, 9050, 10050, 11050).

This enables applications to work using service
discovery, whether those applications are running inside
or outside the Docker network.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I40b24653d76b6e60c73b754cd7e1544c333e0021
2019-08-12 16:12:09 +01:00
Simon Stone
5d8f287c40 Merge "[FAB-14813] Channel event sample in fabric-samples" 2019-08-09 08:04:25 +00:00
Chris Elder
33b0065d69 [FAB-14813] Channel event sample in fabric-samples
Add a channel event handler sample to master and
update for lifecyce.


Change-Id: I5420ddc7070dbee785218ce5960f7604ac799f90
Signed-off-by: Chris Elder <chris.elder@us.ibm.com>
(cherry picked from commit 1efd213110)
2019-08-08 20:12:35 +00:00
Arnaud J Le Hors
4ff4105ba1 Merge "[FAB-16198] Run "go mod vendor" for FabCar Go contract" 2019-08-08 17:54:46 +00:00
Arnaud J Le Hors
977ba9ff28 Merge "[FAB-16132] Remove Kafka consensus from BYFN" 2019-08-08 17:42:59 +00:00
Simon Stone
a3dc349276 Merge "[FAB-15213] Update Commercial Paper for Java" 2019-08-08 16:49:54 +00:00
Arnaud J Le Hors
33b43b6550 Merge "[FAB-16232] Remove FabToken sample" 2019-08-08 13:37:07 +00:00
Simon Stone
b62d5bd77b [FAB-16132] Remove Kafka consensus from BYFN
Remove Kafka as a consensus mechanism option
in BYFN, including all related configuration.

Users wishing to configure Kafka (not best
practice) in Fabric v2.0 can consult the
Fabric v1.4 and earlier samples.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I3bbffc876a6b64831cb6b2bdfac28a88cc013bdf
2019-08-08 13:07:27 +01:00
Matthew B. White
9b1452508f [FAB-15213] Update Commercial Paper for Java
Update with Java Contract

Change-Id: Iced5568a248c1474ae4b6fb0352d23e49ebfc252
Signed-off-by: Matthew B. White <whitemat@uk.ibm.com>
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2019-08-07 11:18:37 +01:00
Simon Stone
4158877505 [FAB-16232] Remove FabToken sample
The FabToken sample needs to be removed, as the FabToken code
itself is being removed/disabled by Angelo De Caro due to it
not being included in Fabric v2.0. Additionally, the FabToken
sample is subject to sporadic CI failures, which we are trying
to clean up.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: Id434d384493f030d2407ca2f9d8687b0681a3723
2019-08-06 09:14:39 +01:00
Simon Stone
b6380cc88c [FAB-16198] Run "go mod vendor" for FabCar Go contract
FAB-15782 added go.mod files for versioned dependencies,
but "go mod vendor" is never run before deploying the
FabCar Go contract either by the user or in CI.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I958d426ca72938a2051bf95d6ecc4c6e3cd1d7b2
2019-08-02 15:48:48 +01:00
Simon Stone
639848a31d [FAB-16197] Add connection profiles to .gitignore
Connection profiles are now generated during BYFN
execution, and should not be tracked via Git. Also,
the remaining connection profiles for Org3 need to
be removed as they are no longer used/valid.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: Ifb76e2a183643a26e95781b455f8c42fc2935928
2019-08-02 14:30:05 +01:00
Simon Stone
3996db59dc [FAB-12219] abstore node -> javascript
Rename the abstore node directory as the sample code
within is JavaScript, and we are planning to add a
TypeScript version as well.

This change also requires updates to BYFN to reflect
the renamed directory.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I1cd554c6598ac7cc71e2b0c65ab541cfaa477354
2019-08-02 11:22:56 +01:00
Simon Stone
14ac271c63 [FAB-12219] marbles02 node -> javascript
Rename the marbles02 node directory as the sample code
within is JavaScript, and we are planning to add a
TypeScript version as well.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I423c8cf78fa16be057f762316e8b3d60b73df7ba
2019-08-02 10:07:31 +01:00
Simon Stone
13f16e5d6d [FGJ-4] CI tests for FabCar Java sample
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I2b28c69a2f3ec0e3d87252ef4a585b4a46fddcbd
2019-07-30 17:23:08 +01:00
Simon Stone
81be9da421 Merge "[FAB-15625] Add UT for Simple Asset Chaincode" 2019-07-30 14:11:49 +00:00
andrew-coleman
171a7d2275 FGJ-4 Fabcar sample
Implementation of Fabcar client for Java Gateway SDK
Changes to first-network to generate the CCP files with
embedded PEM certificates rather than paths to files on disk

Change-Id: Iff15425e96ce28c6f96079cee474c35868fab554
Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>

FGJ-4 split java fabcar into separate classes

Incorporate review comments from previous CR
Split enroll/register/transactions into separate classes

Change-Id: I384cec59c7f53a37864bfc28be11e785a61421f3
Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>

FGJ-4 add license header to fabcar java sample

Change-Id: Ic658fe3bdece9875ca3ceaf28d94c5fb48879083
Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>
2019-07-30 14:07:14 +01:00
Tatsuya Sato
868f9d01ca [FAB-15625] Add UT for Simple Asset Chaincode
This patch adds unit test for chaincode/sacc.

The positive test cases are aligned with the manual testing procedures
described in `fabric/docs/source/chaincode4ade.rst`.

FAB-15625 #done

Patch-set #4: adjust to new shim Mockup location

Change-Id: Ic3625e885f6e49507859af7d5f0bfa136eb7a757
Signed-off-by: Tatsuya Sato <Tatsuya.Sato@hal.hitachi.com>
Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2019-07-30 12:56:06 +00:00
Simon Stone
597d1508e1 [FAB-14532] Remove LL FabCar sample
Remove the Fabric v2.0 version of the low-level FabCar sample. We
should not be advertising how to use the low-level APIs at this
point. The low-level samples are still available for Fabric v1.4
to show the difference between the low-level and high-level APIs.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I87b7edf477064b79f449f618f48902b9495e7d4a
2019-07-30 12:03:18 +01:00
Will Lahti
583ff8f6d4 Use renamed CheckCommitReadiness function
FAB-16111 #done

Change-Id: Iacdbd59515b71cb692935b0afbd1c678e0f55851
Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
2019-07-30 09:51:06 +00:00
James Taylor
750f937218 [FAB-15213] Add Java FabCar sample contract
Change-Id: I0ae40c2a02aea8293a348038e3e1bd02f7030509
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2019-07-29 11:59:30 +00:00
Simon Stone
abbda9575f [FAB-15897] Improve FabCar test logging
Collect logs from all existing Docker containers instead
of just limiting it to a predefined (and incorrect) set.

Also clean up the directory structure for the logs, and
remove any networks/volumes after each test run.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: Ifcf88baeb9ba4d42f757f7cd23ab2a178ab39b41
2019-07-29 11:03:10 +01:00
David Enyeart
dd8150abf3 [FAB-15104] Remove versions from fabric-samples readme
Remove versions from fabric-samples readme so that
it doesn't need to be maintained for each release.
Also clarify the bootstrap.sh download instructions.

Change-Id: I4ef80e048b0d8f27429059635e57e08a8c70c0fa
Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2019-07-19 19:12:07 +00:00
kukgini
1387aa8319 [FAB-15927] Better expression for golang
Better for loop expression and veriable scope for golang

Signed-off-by: kukgini <kukgini@gmail.com>
Change-Id: I83a4ead246039b5b10334467f17c808465492725
2019-07-17 07:48:48 +00:00
Matthew Sykes
61c33d3fba [FAB-15973] use --output json on simulatecommit
Change-Id: Ic31b390898f1981a0138935990ff11a3902007ee
Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
2019-07-16 12:24:11 -04:00
Matthew White
7a5f3398a9 Merge "[FAB-15717] fix Error Unexpected end of JSON input" 2019-07-15 09:43:14 +00:00
Jason Yellick
e8c0ca1b03 Merge "FAB-15782 Sample Go CC should include deps" 2019-07-11 20:00:09 +00:00
Gari Singh
a872358668 Merge "[FAB-15723] Fix script and instruction with ccenv" 2019-07-10 09:45:20 +00:00
Tatsuya Sato
8bbdd0faf0 [FAB-15716] Fix instructions for dev-mode
This patch fixes the instructions for dev-mode.

For the commands to start the chaincode to work properly,
this patch modifies the commands.
- Use peer.address flag (instead of the unused env var after FAB-14770)
- Add CORE_PEER_TLS_ENABLED=false (dev-mode is for non-TLS mode only)

FAB-15716 #done

Signed-off-by: Tatsuya Sato <Tatsuya.Sato@hal.hitachi.com>
Change-Id: I160d22389bb611c5b96ee880497266f06d25abd7
2019-07-03 20:30:26 +00:00
Will Lahti
0254d67b37 QueryApprovalStatus -> SimulateCommitChaincodeDef
Update samples now that QueryApprovalStatus has been renamed
to SimulateCommitChaincodeDefinition.

FAB-15831 #done

Change-Id: I4e12ca2c8424bf8d6537e77e1a9de7fd3723636d
Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
2019-07-02 13:37:20 -04:00
Arnaud J Le Hors
0acd3eb935 Merge "[FAB-15104] Remove scripts/bootstrap.sh" 2019-06-26 12:59:28 +00:00
Gari Singh
c57d67ce80 FAB-15782 Sample Go CC should include deps
The ccenv used to build Go chaincode is being
updated to no longer include the shim
dependency.  Go chaincode must now vendor
all of its dependencies prior to being
packaged and installed.

Go chaincodes have been updated to include
go.mod for versioned dependencies.

Change-Id: Ib971cd3f841d5c92a509450bd85f6e424cc60c6e
Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
2019-06-25 09:50:31 -04:00
Gari Singh
6ba5a19c2c Update to Go 1.12.5 in ci.properties
FAB-15809 #done

Change-Id: I2decb07cb97d7f655926d8606de26aba100fcd94
Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
2019-06-25 05:12:48 -04:00
Tatsuya Sato
1774a25de8 [FAB-15723] Fix script and instruction with ccenv
This patch fixes the script and instruction with the ccenv container.

Running chaincode dev-mode fails because bash was removed from the
ccenv by FAB-15670.
This patch changes the command from /bin/bash to /bin/sh.

FAB-15723 #done

Change-Id: Ibf31ce9170e606988302bf46d8dac98b62e2043e
Signed-off-by: Tatsuya Sato <Tatsuya.Sato@hal.hitachi.com>
2019-06-18 17:42:24 +00:00
Cefold
6ae711cf7b [FAB-15717] fix Error Unexpected end of JSON input
Change-Id: If5700abbe8315ece19e488e2d1ee0e0a7f0b8f49
Signed-off-by: Huida Liu <cefold@gmail.com>
2019-06-18 14:56:18 +00:00
Yukihiko
5be56d3f77 [FAB-15104] Remove scripts/bootstrap.sh
Removed scripts/bootstrap.sh file and updated the README.md
with steps to download bootstrap.sh from Fabric repository.

Signed-off-by: Yukihiko <hirayanagi@jp.fujitsu.com>
Change-Id: I50357c702c8b357fedaf8ccd1ec97ef6c4429371
2019-06-14 14:39:32 +10:00
Yuki Kondo
779f8f3418 [FAB-15649]Fix Fabcar to install Chaincode on all peers
CI Fabcar javascript test fails because a query proposal is
sent to a peer which does not have Chaincode. The query handler
in fabric-network does not consider if Chaincode is installed on
target peers.

As a workaround, this CR adds steps installing Chaincode
on all peers during the setup.

Change-Id: Iaff0c5bde8c54cef12a176b55e13d70173ee8108
Signed-off-by: Yuki Kondo <yuki.kondo@hal.hitachi.com>
2019-06-12 20:07:16 +00:00
NIKHIL E GUPTA
7c5f5d39c9 [FAB-15199] Update interest rate sample
Update interest rate sample for chaincode
lifecycle

Change-Id: I8e481dda11a757d5fe76105098307141a67dff60
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2019-06-12 17:43:22 +00:00
Simon Stone
f0dca20446 [FAB-14532] Remove LL FabCar sample
Remove the Fabric v2.0 version of the low-level FabCar sample. We
should not be advertising how to use the low-level APIs at this
point. The low-level samples are still available for Fabric v1.4
to show the difference between the low-level and high-level APIs.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: I0faef40d4cfddc689e6d7184491fd3759a3558a1
2019-06-10 19:17:29 +01:00
Arnaud J Le Hors
ae91463639 Merge "[FAB-13769] Add UT code to ABAC sample Chaincode" 2019-06-05 12:07:13 +00:00
Simon Stone
9225122fb3 Merge "[FAB-15601] BYFN: Fix MAX_RETRY for couchdb" 2019-06-05 11:04:32 +00:00
Arnaud J Le Hors
423b2ffe18 Merge "[FAB-9329] Remove the unused variable in BYFN/EYFN" 2019-06-05 09:18:51 +00:00
Tatsuya Sato
1ed1a10af6 [FAB-15573] Fix typo in fabric-samples-ci.md
This patch fixes typo in docs/fabric-samples-ci.md

Change-Id: I814efb14d47e3509e3f785504b8d6d2ef26399a0
Signed-off-by: Tatsuya Sato <Tatsuya.Sato@hal.hitachi.com>
2019-06-04 21:23:14 +00:00
Arnaud J Le Hors
2e7fec9da8 [FAB-15601] BYFN: Fix MAX_RETRY for couchdb
CR31665 increased MAX_RETRY to 15 which allowed the fabcar go test
to succeed but the fabcar javascript test still fails. This sets
it to 20 in hope this will be enough.

Change-Id: I51a0e24893634d773b12341f5b87d49d2bbf7cb6
Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2019-06-03 16:30:54 +02:00
Yuki Kondo
1e9e4c4dce [FAB-9329] Remove the unused variable in BYFN/EYFN
This CR removes the unused variable 'OS_ARCH' from byfn.sh,
eyfn.sh and interest swap in fabric-samples.

FAB-9329 #done

Change-Id: I0d1b87679d66bec1d9e4aaee9e770305f9c8f4b9
Signed-off-by: Yuki Kondo <yuki.kondo@hal.hitachi.com>
2019-06-03 10:42:47 +00:00
Yuki Kondo
964c09fe00 [FAB-15601] BYFN: Fix MAX_RETRY for couchdb
BYFN and Fabcar with couchdb are failing intermittently
because CLI sends a request for joining a Channel before
a Peer connects to the couchdb.
This CR changes the value of MAX_RETRY from 10 to 15
as a workaround.

FAB-15601 #done

Change-Id: I8d91fa224c585cc52c9dfabebb808b8909253900
Signed-off-by: Yuki Kondo <yuki.kondo@hal.hitachi.com>
2019-05-31 23:50:36 +00:00
Arnaud J Le Hors
0b12e687fb Merge "[FAB-15127] Update high throughput sample" 2019-05-28 16:37:42 +00:00
NIKHIL E GUPTA
41dca99e5a [FAB-15127] Update high throughput sample
Update high throughput sample scripts for
chaincode lifecycle

Change-Id: I8e7f9d98bb62d75a779e2767b0e165a36a700d43
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
2019-05-28 11:04:31 -04:00
Matthew White
876662e244 Merge "[FAB-14487] Make FabCar use BYFN, not basic-network" 2019-05-28 10:24:00 +00:00
Arnaud J Le Hors
f331828701 Merge "Use official CouchDB image" 2019-05-21 08:09:21 +00:00
Arnaud J Le Hors
11a534fac7 Merge "[FAB-14369]Fix dev mode failing to build Chaincode" 2019-05-16 14:15:52 +00:00
Arnaud J Le Hors
ccf765ad56 Merge "[FAB-15051] delStandard() function for high-throughput" 2019-05-16 13:45:53 +00:00
Gari Singh
3fe014a8c2 Use official CouchDB image
Replace fabric-couchdb image with
official CouchDB library image.

FAB-15353 #done

Change-Id: I248fb452419f590553ad578141dbfb3ab1fb5dd5
Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
2019-05-05 09:01:01 -04:00
Simon Stone
f2d0fa05e4 [FAB-14487] Make FabCar use BYFN, not basic-network
Update FabCar to use BYFN. As a result, the sample
client applications need to change so that they use
the correct connection profile paths, and so that
they use service discovery.

Change-Id: If02b7fb4ad308c6a7d1e1aa9f953e1bc4e942719
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
2019-05-03 08:51:17 +01:00
Matthew White
25d7de4fa6 Merge "[FAB-14486] Extend BYFN to opt skip chaincode deploy" 2019-04-25 13:03:07 +00:00
Matthew White
e639321395 Merge "[FAB-14485] Extend BYFN to opt inc cert authorities" 2019-04-25 13:02:31 +00:00
Matthew White
061abe1c2c Merge "[FAB-14330] Add connection profiles for BYFN and EYFN" 2019-04-25 13:01:36 +00:00
Gari Singh
e9c36499b6 FAB-15276 Fix license statements
Update from ISC to Apache-2.0

FAB-15276 #done

Change-Id: Icb4fb6bcc26c283463472ecb1a47062c799be548
Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
2019-04-25 05:36:37 -04:00
Simon Stone
b0bb79ee8e Merge "FAB-14444" 2019-04-24 21:46:46 +00:00
Simon Stone
fbe403616f [FAB-14486] Extend BYFN to opt skip chaincode deploy
Add a new "-n" option to byfn.sh that optionally skips
the deployment of the abstore chaincode. When BYFN is
used as a network for other samples, we don't really
want the default chaincode deployed.

Change-Id: I6b4043a5c0bcedbeec431cc4a860a3b12da8d8f6
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
2019-04-24 22:21:42 +01:00
Simon Stone
0c4141f2a1 [FAB-14485] Extend BYFN to opt inc cert authorities
Add a new "-a" option to byfn.sh that optionally deploys
certificate authorities (in Docker containers) for
organisation 1 and 2.

Change-Id: Ib58c46941aa6e8e58bac01aa3349e97d1f93b930
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
2019-04-24 22:20:38 +01:00
Simon Stone
529b83bc95 [FAB-14330] Add connection profiles for BYFN and EYFN
Add connection profiles as part of the BYFN and EYFN
samples. The connection profiles can be used by client
applications using the Fabric SDKs to connect to those
networks.

Each organisation needs its own connection profile
that contains the set of peers that organisation
should  use to connect to the network. Orderers and
channels are not needed, as they can be determined
by using service discovery.

Connection profiles can be specified in either JSON
or YAML, so provide both.

Change-Id: Ie8e3d2aef6475b324e5be8ebdada4c594c2235ae
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
2019-04-24 22:20:13 +01:00
Gari Singh
dd08f70739 Merge "Update maintainers for fabric-samples" 2019-04-11 20:17:28 +00:00
Wenjian Qiao
2c21c83a8c [FABN-1184] Update fabtoken/README.md
Change-Id: I2cdd071ab93ca54133ad452eec894c4c28c296b5
Signed-off-by: Wenjian Qiao <wenjianq@gmail.com>
2019-04-11 15:45:59 +00:00
Wenjian Qiao
5056a23cbf [FABN-1184] Add CI script for fabtoken sample app
Change-Id: I611d9249c177a8bbc7e36d0406b81eb8e69dfa3e
Signed-off-by: Wenjian Qiao <wenjianq@gmail.com>
2019-04-11 09:53:48 -04:00
David Enyeart
5d6db959fb Update maintainers for fabric-samples
Previously fabric-samples utilized the fabric list of maintainers. Over time
other contributors have become active. The fabric maintainers will use this
CR to vote for a new set of fabric-samples mainatiners, with the initial list
based on developers with the most contributions and reviews for fabric-samples
over the last 12 months.

Additionally, change fabric-samples from a two +2 policy to a
non-author code review policy.

Change-Id: I9c479f2e8a3dd7389e6e317aa4430cba1df9f3b3
Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2019-04-11 00:30:20 -04:00
Gari Singh
fdf88df4c5 Merge "[FABN-1184] Implement fabtoken sample app" 2019-04-09 14:28:13 +00:00
David Enyeart
f5278157ac [FAB-15119] Fix BYFN with Java chaincode
The issue is that BYFN passes "Init" function while the
sample Java chaincode checks for "init" function.

Within the init function, there is no need to check the function
argument that is passed in. The sample Go chaincode and Node.js
chaincode do not check the function argument. This change makes
sample Java chaincode behave the same way.

Change-Id: I802978e1276e92a3d420b3f4a391ff66a352d321
Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2019-04-09 05:42:08 -04:00
wenjian3
8245252acc [FABN-1184] Implement fabtoken sample app
- implement sample app to issue, transfer, redeem and list tokens
- change basic-network/crypto-config.yaml user count to 2
- regenerate crypto and channel config via generate.sh
- add fabtoken/README.md

Change-Id: I8d270c95b29e4af9c432fb05e7e8dc6be7bbc069
Signed-off-by: Wenjian Qiao <wenjianq@gmail.com>
2019-04-08 14:33:43 -04:00
rameshthoomu
1bd1c2f355 FABCI-284 Update CI Pipeline script
This patch updates CI pipeline scripts which utilizes global shared
library reusable functions. It also creates ci.properties file with
all the parameters required to test the fabric-samples patch.

Change-Id: I9ed97c8dd0c07a3677042dbda034043e8a19a0f1
Signed-off-by: rameshthoomu <rameshbabu.thoomu@gmail.com>
2019-04-05 20:37:23 +00:00
Alessandro Sorniotti
c24abf9c01 [FAB-15022] Basic-network support for new lifecycle
This change set upgrades config files, scripts and fixtures for the
basic-network sample.

Changes are as follows:
 - configtx.yaml was amended adding capabilities and policies required
   to bootstrap a 2.0 channel
 - crypto-config.yaml was amended adding support for node OUs (so that
   policies involving peers, admins and clients can be evaluated)
 - generate.sh was amended adding the name of the orderer system channel
 - generate.sh is executed, producing fixtures in the crypto-config and 
   config directories
 - docker-compose.yml is changed specifying the correct SKI after
   crypto material has been regenerated
 - finally, startFabric.sh has been upgraded to use the new lifecycle

Change-Id: I201a98e3bf4d9717741539f572719aa687f4bb63
Signed-off-by: Alessandro Sorniotti <ale.linux@sopit.net>
2019-04-05 17:01:45 +00:00
Ethan Fox
b64fd45da0 [FAB-15051] delStandard() function for high-throughput
This change is to add a delStandard() function to the
high-throughput fabric sample, as well as fix a typo
in putStandard(). In addition to modifying the
chaincode, an additional bash script,
'del-traditional.sh', was created to remotely delete
a created asset from within the docker CLI in
accordance with the sample walkthrough.

This change is necessary to demonstrate the full
capability of the fabric Shim library, such that no
assets remain on the ledger that the user doesn't want

This change was tested on a local deployment of
Fabric 1.4, using the 'Basic Network' asset that
was created by Ethan Fox for internal use by the
IBM Blockchain Innovation Unit within GBS Global.

Change-Id: I34488dc3131f817563568a43f923856fecb07a5a
Signed-off-by: Ethan Fox <Ethan.Fox@ibm.com>
2019-04-04 15:13:09 -04:00
Gari Singh
3e68a7eff8 FAB-14784 Remove balance-transfer
This sample does not demonstrate best
practices.

Change-Id: I80fb5a7748ac6d067e52e8e0601a46cfb15cb0ac
Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
2019-03-30 07:37:30 -04:00
Alessandro Sorniotti
eb3fe0810f [FAB-14779] QueryApprovalStatus step in byfn
Between the approve and commit steps we add a QueryApprovalStatus to verify
whether peers are ready to commit the chaincode definition.

Change-Id: I18805a4180fa61da07d2bca321c6355660f772fc
Signed-off-by: Alessandro Sorniotti <ale.linux@sopit.net>
2019-03-28 14:00:37 +00:00
Alessandro Sorniotti
d24577fb5d Merge "[FAB-14711] update byfn with new lifecycle" 2019-03-26 17:14:09 +00:00
Alessandro Sorniotti
27774297ec [FAB-14711] update byfn with new lifecycle
Change-Id: I24dd3e85f6dedab52b05ce3103ee06435f01f9a3
Signed-off-by: Alessandro Sorniotti <ale.linux@sopit.net>
2019-03-26 16:25:14 +01:00
David Enyeart
9a6a625f8c Merge "FAB-14531 BYFN Raft with 5 nodes" 2019-03-22 00:53:33 +00:00
Yuki Kondo
aec3389792 [FAB-12215]WYFA:Remove chainId in tx proposal request
A sample application in Write Your First Application has an
unnecessary parameter “chainId” in a transaction proposal request.
Since a channel name is included in a channel object, it is not
required in a request.

This CR removes the parameter ”chainId” from the sample code.

FAB-12215 #done

Change-Id: I1e9b24c791a2129534766805855d05e78b050149
Signed-off-by: Yuki Kondo <yuki.kondo@hal.hitachi.com>
2019-03-17 11:51:32 +00:00
Jason Yellick
ee5b438913 Merge "FAB-14633 Remove apt-get from eyfn.sh" 2019-03-14 17:45:09 +00:00
Jason Yellick
b5d50265e4 FAB-14633 Remove apt-get from eyfn.sh
The tools and fabric images are all alpine based now and do not have
apt-get.  Instead, they are prepopulated with jq.  This CR simply
removes the attempt to install jq (which always fails) and acts as a
red-herring when trying to debug.

Change-Id: I8fe83dc4a9ba6995ebfb2786cee45fe0e591b85a
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
2019-03-13 14:02:09 -04:00
Yoav Tock
efaadd329d FAB-14531 BYFN Raft with 5 nodes
Extend the 3-node etcd/raft cluster in BYFN to 5 nodes, in
order to better support the documentation effort. This will
allow users to experiment creating channels with less then
5 nodes, but avoid the pitfalls of a 2-node cluster.

Change-Id: I5ba1d6039b4bb4864b2b97271de81fbfe91b4fb5
Signed-off-by: Yoav Tock <tock@il.ibm.com>
2019-03-07 15:00:04 +02:00
NickLatkovich
d63047cac9 FAB-14444
Awaiting of wallet importing in fabcar

Change-Id: Ib4a43f75850728794b90b58add7956de113cac80
Signed-off-by: NickLatkovich <nicklatkovich@gmail.com>
2019-03-01 18:55:35 +03:00
Yuki Kondo
7e3d428269 [FAB-14369]Fix dev mode failing to build Chaincode
Building Chaincode fails with the ccenv container created from
Alpine because go build process can't import the shim package.
GOPATH in ccenv changed from "/opt/gopath" to "/go" due to the
move to Alpine. However, docker-compose-simple.yaml still has
`GOPATH=/opt/gopath`.
This CR removes the environment variable.

FAB-14369 #done

Change-Id: I18d9861d9b6f45c1548169fbb143e7883f8ba207
Signed-off-by: Yuki Kondo <yuki.kondo@hal.hitachi.com>
2019-03-01 01:30:45 +00:00
Yacov Manevich
ed0f1cc9ea Merge "FAB-12762 Add etcd/raft consensus option to BYFN" 2019-02-28 16:17:46 +00:00
Yoav Tock
420ba2311c FAB-12762 Add etcd/raft consensus option to BYFN
Augment the fabric-samples first-network sample to include an option
to choose etcd/raft as consensus-type.

Extend the -o flag so that it allows users to choose between the
solo, kafka, or etcdraft consensus-type for the ordering service.

Use three orderer nodes.

Change-Id: Ibc4c3564220466aef0a87baee4a2d594e5554a62
Signed-off-by: Yoav Tock <tock@il.ibm.com>
2019-02-28 16:09:17 +02:00
Christopher Ferris
4eaad65db2 Merge "Correct broken link" 2019-02-26 21:36:21 +00:00
David Enyeart
f734aaef05 Merge "[FAB-13933] Fix misspellings" 2019-02-25 18:09:58 +00:00
Jason Yellick
2b68c80716 FAB-14317 Add default policies to org3
Configtxgen was failing to print the org definition for org3 because it
was missing the required policies for the org definition.  This caused a
failure in the CI test for adding an org.

Because it will be needed in the future, this CR also adds the new
lifecycle endorsement and general endorsement policies to the
configtx.yamls as well.

Change-Id: Ie53165231cf8afe6377b51a28625797b15ca78ec
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
2019-02-24 20:56:35 -05:00
David Enyeart
7b673ffd2f Merge "[FAB-14268] Make BYFN/EYFN ports match external ports" 2019-02-22 16:17:59 +00:00
Kostas Christidis
b0f3770648 Merge "Fix doc link Fix variable error" 2019-02-22 14:41:02 +00:00
Gari Singh
44ab2bbd15 Merge "FAB-13489 fabric-samples add error msg" 2019-02-22 13:00:58 +00:00
Gari Singh
e6894e82fb Merge "[FAB-14162] Pin fabric-samples in master to "unstable"" 2019-02-22 13:00:08 +00:00
Gari Singh
f94753cfa4 Merge "[FAB-11796]high-throughput:Remove unnecessary prunesafe" 2019-02-22 12:58:21 +00:00
Simon Stone
f942010fa6 [FAB-14268] Make BYFN/EYFN ports match external ports
Update both BYFN and EYFN so that the peer request and
chaincode ports match the externally mapped ports. This
enables applications both inside and outside the Docker
network to use service discovery to interact with these
networks (see the JIRA for more details).

Change-Id: I73c36dfdb269ec4225376fb04b1e7a087363e4cc
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
2019-02-21 14:57:39 +00:00
Jason Yellick
4e2ce23e43 FAB-14271 Add channel policies to channel config
Previously, configtxgen would auto-populate policies if they were
omitted.  This presented some problems for specifying partial policy
schemes, like only overriding one policy.  Support for omitting policies
was deprecated in v1.3 and has been removed for v2.0.0.

Change-Id: Ie01bf8f05911358a0af144f2fe2df2667c2bf12e
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
2019-02-20 14:08:40 -05:00
Yuki Kondo
f26477c99d [FAB-11796]high-throughput:Remove unnecessary prunesafe
fabric-samples/high-throughput is a sample Chaincode for
delta-based transaction model. When executing `update`, a new delta
for a particular variable is updated to the ledger. The sum of a
variable is updated to ledger by deleting all of its delta rows
while computing the sum. The current Chaincode has two types of
pruning functions. However, there is no difference in terms of
Fabric's transaction model.

This CR adds the following changes.
- Remove unnecessary `pruneSafe` function.
- Change the name of function from `pruneFast` to `prune`.
- Update or delete related scripts.
- Improve a related documentation.

FAB-11796 #done

Change-Id: I5daa21554e53d77b7b5081f02a2846a85ec06f9a
Signed-off-by: Yuki Kondo <yuki.kondo@hal.hitachi.com>
2019-02-15 18:27:15 +00:00
David Enyeart
137327a009 [FAB-14162] Pin fabric-samples in master to "unstable"
Pin fabric-samples in master to "unstable" so that latest node modules get used by default.

Change-Id: I36df30cb108a350c8e59756ed0d2f03610eb1d73
Signed-off-by: David Enyeart <enyeart@us.ibm.com>
2019-02-12 13:08:22 -05:00
Arnaud J Le Hors
6007c0974c [FAB-13862] Rename example02 ABstore
Updated chaincode, BYFN, and all other references to example02 to use
the new name ABstore.

Change-Id: I04c177f9de68eb913f4384fd643aa69631143d58
Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2019-01-30 09:02:23 +01:00
Daisuke IIZUKA
94cb6033de [FAB-13933] Fix misspellings
Fix misspellings of "Prerequesites" to "Prerequisites",
and "prinicpal" to "principal"

Change-Id: I1024cc0f720bedddee3286b2520ab3824d7a1d5b
Signed-off-by: Daisuke IIZUKA <daisuke.iizuka.ag@hitachi.com>
2019-01-29 02:16:17 +00:00
BigManing
a8a55395af Fix doc link
Fix variable error

Change-Id: I24cae31cc3df080b8906812b81f63b15795dc6e5
Signed-off-by: BigManing <lingshui2008@qq.com>
2019-01-24 16:47:03 +08:00
Yuki Kondo
b0cda61eaf [FAB-13769] Add UT code to ABAC sample Chaincode
This CR adds unit test code to the ABAC sample Chaincode to show
how to use MockStub for Chaincode that uses the `cid` package.
To test the access control in Chaincode method, Creator field in
MockStub is set by reading mspID and certificate with attributes.

FAB-13769 #done

Change-Id: Iddc5ea105b25afcc18b8ff54cf359d2b9406e829
Signed-off-by: Yuki Kondo <yuki.kondo@hal.hitachi.com>
2019-01-18 21:20:48 +00:00
Arnaud J Le Hors
c7438e1f7c [FAB-13668] BYFN's container volume mapping is bad
Updated compose files and scripts to use the correct mapping.

Change-Id: Iccbe384393c2736c5ba197d70ef6a124588ad588
Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2019-01-14 16:17:30 +01:00
Bret Harrison
e48b2dece9 FAB-13489 fabric-samples add error msg
Add error messages and update console logging.

Change-Id: Ic4ffd73ffa098121d7af03f8d2e5383b79f832c0
Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
2019-01-07 18:03:15 -05:00
Rich Zhao
62699415f7 Correct broken link
Change-Id: I22071c820f5b281ae158a5c4caec9f8e4b283822
Signed-off-by: Rich Zhao <zhao.zhenhua@gmail.com>
2019-01-04 23:19:20 +00:00
1510 changed files with 170499 additions and 37016 deletions

19
fabcar/javascript/.editorconfig → .editorconfig Executable file → Normal file
View file

@ -1,16 +1,17 @@
#
# SPDX-License-Identifier: Apache-2.0
#
root = true root = true
[*] [*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8 charset = utf-8
trim_trailing_whitespace = true indent_style = space
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true
[*.{mj,cj,j,t}s]
indent_size = 4
quote_type = single
[*.json]
indent_size = 4
[*.md] [*.md]
trim_trailing_whitespace = false max_line_length = off

53
.github/actions/fsat-setup/action.yaml vendored Normal file
View file

@ -0,0 +1,53 @@
name: Set up the Full Stack Asset Transfer Guide Dependencies
description: Set up the Full Stack Asset Transfer Guide Dependencies
inputs:
node-version:
description: Version of node
default: "lts/*"
just-version:
description: Just Version
default: "1.43.0"
k9s-version:
description: k9s Version
default: v0.50.15
fabric-version:
description: Version of Hyperledger Fabric
default: "2.5.15"
ca-version:
description: Version of Hyperledger Fabric CA
default: "1.5.15"
runs:
using: "composite"
steps:
- uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node-version }}
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: Install k9s
shell: bash
run: |
curl --fail --silent --show-error -L https://github.com/derailed/k9s/releases/download/${{ inputs.k9s-version }}/k9s_Linux_amd64.tar.gz -o /tmp/k9s_Linux_amd64.tar.gz
tar -zxf /tmp/k9s_Linux_amd64.tar.gz -C /usr/local/bin k9s
sudo chown root /usr/local/bin/k9s
sudo chmod 755 /usr/local/bin/k9s
- name: Install just
uses: taiki-e/install-action@v2
with:
tool: just@${{ inputs.just-version }}
- name: Install weft
shell: bash
run: |
npm install -g @hyperledger-labs/weft
- name: Install fabric CLI
shell: bash
working-directory: full-stack-asset-transfer-guide
run: |
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh \
| bash -s -- binary --fabric-version ${{ inputs.fabric-version }} --ca-version ${{ inputs.ca-version }}
echo ${PWD}/bin >> $GITHUB_PATH

View file

@ -0,0 +1,63 @@
name: Set up Test Network Runner
description: Set up the Test Network Runtime
inputs:
go-version:
description: Version of go
default: stable
node-version:
description: Version of node
default: "lts/*"
java-version:
description: Version of JDK
default: 25.x
fabric-version:
description: Version of Hyperledger Fabric
default: 2.5.15
ca-version:
description: Version of Hyperledger Fabric CA
default: 1.5.15
runs:
using: "composite"
steps:
- uses: actions/setup-go@v6
with:
go-version: ${{ inputs.go-version }}
cache-dependency-path: "**/go.sum"
- uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node-version }}
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: ${{ inputs.java-version }}
cache: gradle
- name: Install fabric CLI
shell: bash
run: |
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh \
| bash -s -- binary --fabric-version ${{ inputs.fabric-version }} --ca-version ${{ inputs.ca-version }}
echo ${PWD}/bin >> $GITHUB_PATH
- name: Pull Fabric Docker Images
shell: bash
run: |
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh \
| bash -s -- docker --fabric-version ${{ inputs.fabric-version }} --ca-version ${{ inputs.ca-version }}
- name: Pull chaincode container images
shell: bash
run: |
docker pull ghcr.io/hyperledger/fabric-nodeenv:2.5
docker tag ghcr.io/hyperledger/fabric-nodeenv:2.5 hyperledger/fabric-nodeenv:2.5
docker pull ghcr.io/hyperledger/fabric-javaenv:2.5
docker tag ghcr.io/hyperledger/fabric-javaenv:2.5 hyperledger/fabric-javaenv:2.5
- name: Install retry CLI
shell: bash
run: curl -sSL https://raw.githubusercontent.com/kadwanev/retry/master/retry -o ./bin/retry && chmod +x ./bin/retry

6
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly

14
.github/settings.yml vendored Normal file
View file

@ -0,0 +1,14 @@
repository:
name: fabric-samples
description: Samples for Hyperledger Fabric
homepage: https://lf-hyperledger.atlassian.net/wiki/spaces/fabric
default_branch: main
has_downloads: true
has_issues: true
has_projects: false
has_wiki: false
archived: false
private: false
allow_squash_merge: true
allow_merge_commit: false
allow_rebase_merge: true

27
.github/stale.yml vendored
View file

@ -1,27 +0,0 @@
# SPDX-License-Identifier: Apache-2.0
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 0
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 1
# Issues with these labels will never be considered stale
# CAUTION: These issues are likely to get _less_ attention since stale bot
# will never nag anyone about them. Stale bot just reflects the community's
# actual priorities and adding labels to this list will not change that.
# If issues you care about are going stale, you need to work with the
# community to raise their profile, e.g. add more information, reach out on
# Rocket.Chat, join a community call, etc.
# WARNING: Please do not change these labels without seeking community
# consensus first!
# Label to use when marking an issue as stale
staleLabel: stale
only: pulls
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
Thank you for your contribution!
Please use gerrit for the changes, see
[documentation here](https://hyperledger-fabric.readthedocs.io/en/latest/CONTRIBUTING.html)
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: >
Thank you for your contribution!
Please use gerrit for the changes, see
[documentation here](https://hyperledger-fabric.readthedocs.io/en/latest/CONTRIBUTING.html)

65
.github/workflows/lint.yaml vendored Normal file
View file

@ -0,0 +1,65 @@
#
# SPDX-License-Identifier: Apache-2.0
#
name: Lint 🎉
run-name: ${{ github.actor }} is linting fabric-samples 🎉
on:
workflow_dispatch:
push:
branches: ["main", "release-2.5"]
pull_request:
branches: ["main", "release-2.5"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
NODE_VER: "lts/*"
JAVA_VER: 25.x
jobs:
go:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- uses: actions/setup-go@v6
with:
go-version: stable
- uses: actions/checkout@v6
- run: go install golang.org/x/tools/cmd/goimports@latest
- run: ci/scripts/lint-go.sh
typescript:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VER }}
- run: ci/scripts/lint-typescript.sh
javascript:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VER }}
- run: ci/scripts/lint-javascript.sh
java:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: ${{ env.JAVA_VER }}
- run: ci/scripts/lint-java.sh
shell:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- uses: actions/checkout@v6
- run: ci/scripts/lint-shell.sh

58
.github/workflows/rest-sample.yaml vendored Normal file
View file

@ -0,0 +1,58 @@
#
# SPDX-License-Identifier: Apache-2.0
#
name: REST Sample 🐧
run-name: ${{ github.actor }} is testing the REST Sample 🐧
env:
NODE_VER: "lts/*"
on:
workflow_dispatch:
push:
branches: ["main", "release-2.5"]
paths: ["asset-transfer-basic/rest-api-typescript/**"]
pull_request:
branches: ["main", "release-2.5"]
paths: ["asset-transfer-basic/rest-api-typescript/**"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test-sample:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- name: Checkout
uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VER }}
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: Install REST Sample Dependencies
working-directory: asset-transfer-basic/rest-api-typescript
run: npm install
- name: Build REST Sample Application
run: npm run build
working-directory: asset-transfer-basic/rest-api-typescript
- name: Test REST Sample Application
run: npm test
working-directory: asset-transfer-basic/rest-api-typescript
- name: Build REST Sample Docker Image
run: docker build -t ghcr.io/hyperledger/fabric-rest-sample .
working-directory: asset-transfer-basic/rest-api-typescript
- name: Publish REST Sample Docker Image
if: github.event_name == 'push' && (github.ref == 'refs/heads/main')
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker push ghcr.io/hyperledger/fabric-rest-sample:latest
working-directory: asset-transfer-basic/rest-api-typescript

59
.github/workflows/test-fsat.yaml vendored Normal file
View file

@ -0,0 +1,59 @@
name: Full Stack Asset Transfer Guide 🚀
run-name: ${{ github.actor }} is testing the Full Stack Asset Transfer Guide 🚀
on:
workflow_dispatch:
pull_request:
branches:
- "main"
- "release-2.5"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
ansible:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- uses: actions/checkout@v6
- name: Set up Full Stack Runtime
uses: ./.github/actions/fsat-setup
- run: just test-ansible
working-directory: full-stack-asset-transfer-guide
appdev:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- uses: actions/checkout@v6
- name: Set up Full Stack Runtime
uses: ./.github/actions/fsat-setup
- run: just test-appdev
working-directory: full-stack-asset-transfer-guide
chaincode:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- uses: actions/checkout@v6
- name: Set up Full Stack Runtime
uses: ./.github/actions/fsat-setup
- run: just test-chaincode
working-directory: full-stack-asset-transfer-guide
cloud:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- uses: actions/checkout@v6
- name: Set up Full Stack Runtime
uses: ./.github/actions/fsat-setup
- run: just test-cloud
working-directory: full-stack-asset-transfer-guide
console:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- uses: actions/checkout@v6
- name: Set up Full Stack Runtime
uses: ./.github/actions/fsat-setup
- run: just test-console
working-directory: full-stack-asset-transfer-guide

View file

@ -0,0 +1,49 @@
#
# SPDX-License-Identifier: Apache-2.0
#
name: Test High Throughput
run-name: ${{ github.actor }} is running the High Throughput tests
on:
workflow_dispatch:
push:
branches: ["main", "release-2.5"]
pull_request:
branches: ["main", "release-2.5"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
basic:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up test network runtime
uses: ./.github/actions/test-network-setup
- name: Start Fabric
working-directory: high-throughput
run: ./startFabric.sh
- name: Test High Throughput
working-directory: high-throughput/application-go
run: |
go run . manyUpdates testvar1 100 +
go run . prune testvar1
go run . get testvar1
go run . update testvar1 100 +
go run . get testvar1
go run . delete testvar1
go run . manyUpdatesTraditional testvar2 100 +
go run . getstandard testvar2
go run . updatestandard testvar2 100 +
go run . getstandard testvar2
go run . delstandard testvar2
- name: Stop Fabric
working-directory: high-throughput
run: ./networkDown.sh

View file

@ -0,0 +1,39 @@
#
# SPDX-License-Identifier: Apache-2.0
#
name: Test Network Basic 🔎
run-name: ${{ github.actor }} is running the Test Network Basic tests 🔎
on:
workflow_dispatch:
push:
branches: [ "main", "release-2.5" ]
pull_request:
branches: [ "main", "release-2.5" ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
basic:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
strategy:
matrix:
chaincode-language:
- go
- javascript
- typescript
- java
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up the test network runtime
uses: ./.github/actions/test-network-setup
- name: Run Test Network Basic
working-directory: test-network
run: ../ci/scripts/run-test-network-basic.sh
env:
CHAINCODE_LANGUAGE: ${{ matrix.chaincode-language }}

View file

@ -0,0 +1,49 @@
#
# SPDX-License-Identifier: Apache-2.0
#
name: Test Network BFT Orderer 🍟
run-name: ${{ github.actor }} is running the Test Network with BFT Orderer tests 🍟
on:
workflow_dispatch:
push:
branches: ["main"]
pull_request:
branches: ["main"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
basic:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
strategy:
matrix:
chaincode-language:
- go
- javascript
- typescript
- java
crypto:
- cryptogen
- ca
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up the test network runtime
uses: ./.github/actions/test-network-setup
# Note: The default Fabric version for CI is currently the latest LTS (v2.5.x).
# To test BFT Orderers, Fabric v3.x is explicitly specified here.
with:
fabric-version: 3.1.4
- name: Run Test Network with BFT Orderers
working-directory: test-network
run: ../ci/scripts/run-test-network-basic.sh
env:
CHAINCODE_LANGUAGE: ${{ matrix.chaincode-language }}
ORDERER_TYPE: bft
CRYPTO: ${{ matrix.crypto }}

View file

@ -0,0 +1,41 @@
#
# SPDX-License-Identifier: Apache-2.0
#
name: Test Network Events 💡
run-name: ${{ github.actor }} is running the Test Network Events tests 💡
on:
workflow_dispatch:
push:
branches: [ "main", "release-2.5" ]
pull_request:
branches: [ "main", "release-2.5" ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
events:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
strategy:
matrix:
chaincode-language:
- go
- javascript
- java
chaincode-name:
- events
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up the test network runtime
uses: ./.github/actions/test-network-setup
- name: Run Test
working-directory: test-network
run: ../ci/scripts/run-test-network-events.sh
env:
CHAINCODE_NAME: ${{ matrix.chaincode-name }}
CHAINCODE_LANGUAGE: ${{ matrix.chaincode-language }}

51
.github/workflows/test-network-hsm.yaml vendored Normal file
View file

@ -0,0 +1,51 @@
#
# SPDX-License-Identifier: Apache-2.0
#
name: Test Network HSM 🍏
run-name: ${{ github.actor }} is running the Test Network HSM tests 🍏
on:
workflow_dispatch:
push:
branches: [ "main", "release-2.5" ]
pull_request:
branches: [ "main", "release-2.5" ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
hsm:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
strategy:
matrix:
chaincode-language:
- go
- javascript
- typescript
- java
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up the test network runtime
uses: ./.github/actions/test-network-setup
- name: Install SoftHSM
run: sudo apt install -y softhsm2
- name: Set up SoftHSM
env:
TMPDIR: ${{ runner.temp }}
SOFTHSM2_CONF: ${{ github.workspace }}/softhsm2.conf
run: |
echo "directories.tokendir = ${TMPDIR}" > "${SOFTHSM2_CONF}"
softhsm2-util --init-token --slot 0 --label "ForFabric" --pin 98765432 --so-pin 1234
- name: Run Test Network HSM
working-directory: test-network
env:
CHAINCODE_LANGUAGE: ${{ matrix.chaincode-language }}
SOFTHSM2_CONF: ${{ github.workspace }}/softhsm2.conf
run: ../ci/scripts/run-test-network-hsm.sh

124
.github/workflows/test-network-k8s.yaml vendored Normal file
View file

@ -0,0 +1,124 @@
#
# SPDX-License-Identifier: Apache-2.0
#
name: Kubernetes Test Network 🍒
run-name: ${{ github.actor }} is testing the Kubernetes Test Network 🍒
on:
workflow_dispatch:
push:
branches: [ "main", "release-2.5" ]
pull_request:
branches: [ "main", "release-2.5" ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
ccaas-java:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Test the network
id: run-test
working-directory: test-network-k8s
run: ../ci/scripts/run-k8s-test-network-basic.sh
env:
CLIENT_LANGUAGE: typescript
CHAINCODE_LANGUAGE: java
- name: Upload failure logs
if: ${{ failure() && steps.run-test.conclusion == 'failure' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ github.job }}-logs
path: test-network-k8s/network-debug.log
ccaas-external:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Test the network
id: run-test
working-directory: test-network-k8s
run: ../ci/scripts/run-k8s-test-network-basic.sh
env:
CLIENT_LANGUAGE: typescript
CHAINCODE_LANGUAGE: external
- name: Upload failure logs
if: ${{ failure() && steps.run-test.conclusion == 'failure' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ github.job }}-logs
path: test-network-k8s/network-debug.log
k8s-builder:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Test the network
id: run-test
working-directory: test-network-k8s
run: ../ci/scripts/run-k8s-test-network-basic.sh
env:
CHAINCODE_NAME: basic
CHAINCODE_LANGUAGE: java
CHAINCODE_BUILDER: k8s
- name: Upload failure logs
if: ${{ failure() && steps.run-test.conclusion == 'failure' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ github.job }}-logs
path: test-network-k8s/network-debug.log
multi-namespace:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Test the network
id: run-test
working-directory: test-network-k8s
run: ../ci/scripts/run-k8s-test-network-basic.sh
env:
ORG0_NS: org0-namespace
ORG1_NS: org1-namespace
ORG2_NS: org2-namespace
CHAINCODE_NAME: basic
CHAINCODE_LANGUAGE: java
CHAINCODE_BUILDER: k8s
- name: Upload failure logs
if: ${{ failure() && steps.run-test.conclusion == 'failure' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ github.job }}-logs
path: test-network-k8s/network-debug.log
bft-orderer:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
# This job requires Fabric v3.0 or later, which is only supported on 'main'.
# Ensure it does not run on 'release-2.5' or earlier versions.
if: ${{ github.ref == 'refs/heads/main' || github.event.pull_request.base.ref == 'main' }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Test the network
id: run-test
working-directory: test-network-k8s
run: ../ci/scripts/run-k8s-test-network-basic.sh
env:
CLIENT_LANGUAGE: typescript
CHAINCODE_LANGUAGE: java
# Note: The default Fabric version for CI is currently the latest LTS (v2.5.x).
# To test BFT Orderers, Fabric v3.x is explicitly specified here.
FABRIC_VERSION: '3.1'
ORDERER_TYPE: bft
- name: Upload failure logs
if: ${{ failure() && steps.run-test.conclusion == 'failure' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ github.job }}-logs
path: test-network-k8s/network-debug.log

View file

@ -0,0 +1,41 @@
#
# SPDX-License-Identifier: Apache-2.0
#
name: Test Network Ledger 🥑
run-name: ${{ github.actor }} is running the Test Network Ledger tests 🥑
on:
workflow_dispatch:
push:
branches: [ "main", "release-2.5" ]
pull_request:
branches: [ "main", "release-2.5" ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
basic:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
strategy:
matrix:
chaincode-language:
- go
- javascript
- typescript
chaincode-name:
- ledger
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up the test network runtime
uses: ./.github/actions/test-network-setup
- name: Run Test
working-directory: test-network
run: ../ci/scripts/run-test-network-ledger.sh
env:
CHAINCODE_NAME: ${{ matrix.chaincode-name }}
CHAINCODE_LANGUAGE: ${{ matrix.chaincode-language }}

View file

@ -0,0 +1,39 @@
#
# SPDX-License-Identifier: Apache-2.0
#
name: Test Network Off Chain 🍔
run-name: ${{ github.actor }} is running the Test Network Off Chain tests 🍔
on:
workflow_dispatch:
push:
branches: [ "main", "release-2.5" ]
pull_request:
branches: [ "main", "release-2.5" ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
off-chain:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
strategy:
matrix:
chaincode-language:
- go
- javascript
- typescript
- java
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up the test network runtime
uses: ./.github/actions/test-network-setup
- name: Run Test Network Off Chain
working-directory: test-network
env:
CHAINCODE_LANGUAGE: ${{ matrix.chaincode-language }}
run: ../ci/scripts/run-test-network-off-chain.sh

View file

@ -0,0 +1,41 @@
#
# SPDX-License-Identifier: Apache-2.0
#
name: Test Network Private 🔒
run-name: ${{ github.actor }} is running the Test Network Private tests 🔒
on:
workflow_dispatch:
push:
branches: ["main", "release-2.5"]
pull_request:
branches: ["main", "release-2.5"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
private:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
strategy:
matrix:
chaincode-language:
- go
- java
- typescript
chaincode-name:
- private
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up the test network runtime
uses: ./.github/actions/test-network-setup
- name: Run Test
working-directory: test-network
run: ../ci/scripts/run-test-network-private.sh
env:
CHAINCODE_NAME: ${{ matrix.chaincode-name }}
CHAINCODE_LANGUAGE: ${{ matrix.chaincode-language }}

40
.github/workflows/test-network-sbe.yaml vendored Normal file
View file

@ -0,0 +1,40 @@
#
# SPDX-License-Identifier: Apache-2.0
#
name: Test Network SBE 🎵
run-name: ${{ github.actor }} is running the Test Network SBE tests 🎵
on:
workflow_dispatch:
push:
branches: [ "main", "release-2.5" ]
pull_request:
branches: [ "main", "release-2.5" ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
SBE:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
strategy:
matrix:
chaincode-language:
- typescript
- java
chaincode-name:
- sbe
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up the test network runtime
uses: ./.github/actions/test-network-setup
- name: Run Test
working-directory: test-network
run: ../ci/scripts/run-test-network-sbe.sh
env:
CHAINCODE_NAME: ${{ matrix.chaincode-name }}
CHAINCODE_LANGUAGE: ${{ matrix.chaincode-language }}

View file

@ -0,0 +1,39 @@
#
# SPDX-License-Identifier: Apache-2.0
#
name: Test Network Secured 🔔
run-name: ${{ github.actor }} is running the Test Network Secured tests 🔔
on:
workflow_dispatch:
push:
branches: [ "main", "release-2.5" ]
pull_request:
branches: [ "main", "release-2.5" ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
secured:
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
strategy:
matrix:
chaincode-language:
- go
chaincode-name:
- secured
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up the test network runtime
uses: ./.github/actions/test-network-setup
- name: Run Test
working-directory: test-network
run: ../ci/scripts/run-test-network-secured.sh
env:
CHAINCODE_NAME: ${{ matrix.chaincode-name }}
CHAINCODE_LANGUAGE: ${{ matrix.chaincode-language }}

28
.gitignore vendored
View file

@ -4,8 +4,30 @@
.#* .#*
# Vim file artifacts # Vim file artifacts
.*.sw* .*.sw*
# installed platform-specific binaries
/bin
/config
.DS_Store .DS_Store
.project .project
# omit Go vendor directories
vendor/
.vscode
.gradle
.idea
# Dependency directories
node_modules/
# Ignore Gradle build output directory
build
# Ignore Maven build output directory
target
# Eclipse
.classpath
.settings
# installed Fabric binaries etc.
/bin/
builders/
config/
external-chaincode/
install-fabric.sh
# override the ignore of all config/ folders
!full-stack-asset-transfer-guide/infrastructure/sample-network/config

View file

@ -1,5 +0,0 @@
# SPDX-License-Identifier: Apache-2.0
[gerrit]
host=gerrit.hyperledger.org
port=29418
project=fabric-samples

2660
CHANGELOG.md Normal file

File diff suppressed because it is too large Load diff

4
CODEOWNERS Normal file
View file

@ -0,0 +1,4 @@
# SPDX-License-Identifier: Apache-2.0
# Fabric Samples Maintainers
* @hyperledger/fabric-samples-maintainers

View file

@ -2,7 +2,7 @@ Code of Conduct Guidelines
========================== ==========================
Please review the Hyperledger [Code of Please review the Hyperledger [Code of
Conduct](https://wiki.hyperledger.org/community/hyperledger-project-code-of-conduct) Conduct](https://lf-hyperledger.atlassian.net/wiki/spaces/HYP/pages/19595281/Hyperledger+Code+of+Conduct)
before participating. It is important that we keep things civil. before participating. It is important that we keep things civil.
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>. <a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.

View file

@ -9,10 +9,10 @@ docs to learn how to make contributions to this exciting project.
## Code of Conduct Guidelines <a name="conduct"></a> ## Code of Conduct Guidelines <a name="conduct"></a>
See our [Code of Conduct Guidelines](../blob/master/CODE_OF_CONDUCT.md). See our [Code of Conduct Guidelines](./CODE_OF_CONDUCT.md).
## Maintainers <a name="maintainers"></a> ## Maintainers <a name="maintainers"></a>
Should you have any questions or concerns, please reach out to one of the project's [Maintainers](../blob/master/MAINTAINERS.md). Should you have any questions or concerns, please reach out to one of the project's [Maintainers](./MAINTAINERS.md).
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>. <a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.

155
Jenkinsfile vendored
View file

@ -1,155 +0,0 @@
// Copyright IBM Corp All Rights Reserved
//
// SPDX-License-Identifier: Apache-2.0
//
// Pipeline script for fabric-samples
node ('hyp-x') { // trigger build on x86_64 node
timestamps {
try {
def ROOTDIR = pwd() // workspace dir (/w/workspace/<job_name>
def nodeHome = tool 'nodejs-8.11.3'
env.ARCH = "amd64"
env.VERSION = sh(returnStdout: true, script: 'curl -O https://raw.githubusercontent.com/hyperledger/fabric/master/Makefile && cat Makefile | grep "BASE_VERSION =" | cut -d "=" -f2').trim()
env.VERSION = "$VERSION" // BASE_VERSION from fabric Makefile
env.BASE_IMAGE_VER = sh(returnStdout: true, script: 'cat Makefile | grep "BASEIMAGE_RELEASE =" | cut -d "=" -f2').trim() // BASEIMAGE Version from fabric Makefile
env.IMAGE_TAG = "${ARCH}-${VERSION}-stable" // fabric latest stable version from nexus
env.PROJECT_VERSION = "${VERSION}-stable"
env.BASE_IMAGE_TAG = "${ARCH}-${BASE_IMAGE_VER}" //fabric baseimage version
env.PROJECT_DIR = "gopath/src/github.com/hyperledger"
env.GOPATH = "$WORKSPACE/gopath"
env.PATH = "$GOPATH/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:${nodeHome}/bin:$PATH"
def jobname = sh(returnStdout: true, script: 'echo ${JOB_NAME} | grep -q "verify" && echo patchset || echo merge').trim()
def failure_stage = "none"
// delete working directory
deleteDir()
stage("Fetch Patchset") { // fetch gerrit refspec on latest commit
try {
if (jobname == "patchset") {
println "$GERRIT_REFSPEC"
println "$GERRIT_BRANCH"
checkout([
$class: 'GitSCM',
branches: [[name: '$GERRIT_REFSPEC']],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'gopath/src/github.com/hyperledger/$PROJECT'], [$class: 'CheckoutOption', timeout: 10]],
userRemoteConfigs: [[credentialsId: 'hyperledger-jobbuilder', name: 'origin', refspec: '$GERRIT_REFSPEC:$GERRIT_REFSPEC', url: '$GIT_BASE']]])
} else {
// Clone fabric-samples on merge
println "Clone $PROJECT repository"
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/heads/$GERRIT_BRANCH']],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'gopath/src/github.com/hyperledger/$PROJECT']],
userRemoteConfigs: [[credentialsId: 'hyperledger-jobbuilder', name: 'origin', refspec: '+refs/heads/$GERRIT_BRANCH:refs/remotes/origin/$GERRIT_BRANCH', url: '$GIT_BASE']]])
}
dir("${ROOTDIR}/$PROJECT_DIR/$PROJECT") {
sh '''
# Print last two commit details
echo
git log -n2 --pretty=oneline --abbrev-commit
echo
'''
}
}
catch (err) {
failure_stage = "Fetch patchset"
currentBuild.result = 'FAILURE'
throw err
}
}
// clean environment and get env data
stage("Clean Environment - Get Env Info") {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-samples/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --clean_Environment --env_Info'
}
}
catch (err) {
failure_stage = "Clean Environment - Get Env Info"
currentBuild.result = 'FAILURE'
throw err
}
}
// Pull Third_party Images
stage("Pull third_party Images") {
// making the output color coded
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-samples/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --pull_Thirdparty_Images'
}
}
catch (err) {
failure_stage = "Pull third_party docker images"
currentBuild.result = 'FAILURE'
throw err
}
}
}
// Pull Fabric, fabric-ca Images
stage("Pull Docker Images") {
// making the output color coded
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-samples/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --pull_Docker_Images'
}
}
catch (err) {
failure_stage = "Pull fabric, fabric-ca docker images"
currentBuild.result = 'FAILURE'
throw err
}
}
}
// Run byfn, eyfn tests (default, custom channel, couchdb, nodejs chaincode)
stage("Run byfn_eyfn Tests") {
// making the output color coded
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-samples/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --byfn_eyfn_Tests'
}
}
catch (err) {
failure_stage = "byfn_eyfn_Tests"
currentBuild.result = 'FAILURE'
throw err
}
}
}
// Run fabcar tests
stage("Run FabCar Tests") {
// making the output color coded
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("${ROOTDIR}/$PROJECT_DIR/fabric-samples/scripts/Jenkins_Scripts") {
sh './CI_Script.sh --fabcar_Tests'
}
}
catch (err) {
failure_stage = "fabcar_Tests"
currentBuild.result = 'FAILURE'
throw err
}
}
}
} finally {
// Archive the artifacts
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*.log'
// Sends notification to Rocket.Chat jenkins-robot channel
if (env.JOB_NAME == "fabric-samples-merge-job") {
if (currentBuild.result == 'FAILURE') { // Other values: SUCCESS, UNSTABLE
rocketSend message: "Build Notification - STATUS: *${currentBuild.result}* - BRANCH: *${env.GERRIT_BRANCH}* - PROJECT: *${env.PROJECT}* - (<${env.BUILD_URL}|Open>)"
}
}
}
// End Timestamps block
}
// End Node block
}

View file

@ -1,5 +1,14 @@
## Hyperledger Fabric Maintainers Maintainers
===========
[MAINTAINERS](http://hyperledger-fabric.readthedocs.io/en/latest/MAINTAINERS.html) fabric-samples uses a non-author code review policy, requiring a single approval from a non-author maintainer.
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a> | Name | GitHub | Discord ID | email |
|---------------------------|------------------|------------------|-------------------------------------|
| Dave Enyeart | denyeart | Dave Enyeart | enyeart@us.ibm.com |
| Mark Lewis | bestbeforetoday | bestbeforetoday | Mark.S.Lewis@outlook.com |
| Tatsuya Sato | satota2 | satota2 | tatsuya.sato.so@hitachi.com |
Also: Please see the [Release Manager section](https://github.com/hyperledger/fabric/blob/main/MAINTAINERS.md)
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.

View file

@ -1,23 +1,69 @@
[//]: # (SPDX-License-Identifier: CC-BY-4.0) [//]: # (SPDX-License-Identifier: CC-BY-4.0)
## Hyperledger Fabric Samples # Hyperledger Fabric Samples
Please visit the [installation instructions](http://hyperledger-fabric.readthedocs.io/en/latest/install.html) You can use Fabric samples to get started working with Hyperledger Fabric, explore important Fabric features, and learn how to build applications that can interact with blockchain networks using the Fabric SDKs. To learn more about Hyperledger Fabric, visit the [Fabric documentation](https://hyperledger-fabric.readthedocs.io/en/latest).
to ensure you have the correct prerequisites installed. Please use the
version of the documentation that matches the version of the software you
intend to use to ensure alignment.
## Download Binaries and Docker Images Note that this branch contains samples for the latest Fabric release. For older Fabric versions, refer to the corresponding branches:
The [`scripts/bootstrap.sh`](https://github.com/hyperledger/fabric-samples/blob/release-1.3/scripts/bootstrap.sh) - [release-2.2](https://github.com/hyperledger/fabric-samples/tree/release-2.2)
script will preload all of the requisite docker - [release-1.4](https://github.com/hyperledger/fabric-samples/tree/release-1.4)
images for Hyperledger Fabric and tag them with the 'latest' tag. Optionally,
specify a version for fabric, fabric-ca and thirdparty images. Default versions ## Getting started with the Fabric samples
are 1.4.0-rc2, 1.4.0-rc2 and 0.4.14 respectively.
To use the Fabric samples, you need to download the Fabric Docker images and the Fabric CLI tools. First, make sure that you have installed all of the [Fabric prerequisites](https://hyperledger-fabric.readthedocs.io/en/latest/prereqs.html). You can then follow the instructions to [Install the Fabric Samples, Binaries, and Docker Images](https://hyperledger-fabric.readthedocs.io/en/latest/install.html) in the Fabric documentation. In addition to downloading the Fabric images and tool binaries, the Fabric samples will also be cloned to your local machine.
## Test network
The [Fabric test network](test-network) in the samples repository provides a Docker Compose based test network with two
Organization peers and an ordering service node. You can use it on your local machine to run the samples listed below.
You can also use it to deploy and test your own Fabric chaincodes and applications. To get started, see
the [test network tutorial](https://hyperledger-fabric.readthedocs.io/en/latest/test_network.html).
The [Kubernetes Test Network](test-network-k8s) sample builds upon the Compose network, constructing a Fabric
network with peer, orderer, and CA infrastructure nodes running on Kubernetes. In addition to providing a sample
Kubernetes guide, the Kube test network can be used as a platform to author and debug _cloud ready_ Fabric Client
applications on a development or CI workstation.
## Asset transfer samples and tutorials
The asset transfer series provides a series of sample smart contracts and applications to demonstrate how to store and transfer assets using Hyperledger Fabric.
Each sample and associated tutorial in the series demonstrates a different core capability in Hyperledger Fabric. The **Basic** sample provides an introduction on how
to write smart contracts and how to interact with a Fabric network using the Fabric SDKs. The **Ledger queries**, **Private data**, and **State-based endorsement**
samples demonstrate these additional capabilities. Finally, the **Secured agreement** sample demonstrates how to bring all the capabilities together to securely
transfer an asset in a more realistic transfer scenario.
| **Smart Contract** | **Description** | **Tutorial** | **Smart contract languages** | **Application languages** |
| -----------|------------------------------|----------|---------|---------|
| [Basic](asset-transfer-basic) | The Basic sample smart contract that allows you to create and transfer an asset by putting data on the ledger and retrieving it. This sample is recommended for new Fabric users. | [Writing your first application](https://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html) | Go, JavaScript, TypeScript, Java | Go, TypeScript, Java |
| [Ledger queries](asset-transfer-ledger-queries) | The ledger queries sample demonstrates range queries and transaction updates using range queries (applicable for both LevelDB and CouchDB state databases), and how to deploy an index with your chaincode to support JSON queries (applicable for CouchDB state database only). | [Using CouchDB](https://hyperledger-fabric.readthedocs.io/en/latest/couchdb_tutorial.html) | Go, JavaScript | Java, JavaScript |
| [Private data](asset-transfer-private-data) | This sample demonstrates the use of private data collections, how to manage private data collections with the chaincode lifecycle, and how the private data hash can be used to verify private data on the ledger. It also demonstrates how to control asset updates and transfers using client-based ownership and access control. | [Using Private Data](https://hyperledger-fabric.readthedocs.io/en/latest/private_data_tutorial.html) | Go, TypeScript, Java | TypeScript |
| [State-Based Endorsement](asset-transfer-sbe) | This sample demonstrates how to override the chaincode-level endorsement policy to set endorsement policies at the key-level (data/asset level). | [Using State-based endorsement](https://github.com/hyperledger/fabric-samples/tree/main/asset-transfer-sbe) | Java, TypeScript | JavaScript |
| [Secured agreement](asset-transfer-secured-agreement) | Smart contract that uses implicit private data collections, state-based endorsement, and organization-based ownership and access control to keep data private and securely transfer an asset with the consent of both the current owner and buyer. | [Secured asset transfer](https://hyperledger-fabric.readthedocs.io/en/latest/secured_asset_transfer/secured_private_asset_transfer_tutorial.html) | Go | TypeScript |
| [Events](asset-transfer-events) | The events sample demonstrates how smart contracts can emit events that are read by the applications interacting with the network. | [README](asset-transfer-events/README.md) | Go, JavaScript, Java | Go, TypeScript, Java |
| [Attribute-based access control](asset-transfer-abac) | Demonstrates the use of attribute and identity based access control using a simple asset transfer scenario | [README](asset-transfer-abac/README.md) | Go | _None_ |
## Full stack asset transfer guide
The [full stack asset transfer guide](full-stack-asset-transfer-guide#readme) workshop demonstrates how a generic asset transfer solution for Hyperledger Fabric can be developed and deployed. This covers chaincode development, client application development, and deployment to a production-like environment.
## Additional samples
Additional samples demonstrate various Fabric use cases and application patterns.
| **Sample** | **Description** | **Documentation** |
| -------------|------------------------------|------------------|
| [Off chain data](off_chain_data) | Learn how to use block events to build an off-chain database for reporting and analytics. | [Peer channel-based event services](https://hyperledger-fabric.readthedocs.io/en/latest/peer_event_services.html) |
| [Token SDK](token-sdk) | Sample REST API around the Hyperledger Labs [Token SDK](https://github.com/hyperledger-labs/fabric-token-sdk) for privacy friendly (zero knowledge proof) UTXO transactions. | [README](token-sdk/README.md) |
| [Token ERC-20](token-erc-20) | Smart contract demonstrating how to create and transfer fungible tokens using an account-based model. | [README](token-erc-20/README.md) |
| [Token UTXO](token-utxo) | Smart contract demonstrating how to create and transfer fungible tokens using a UTXO (unspent transaction output) model. | [README](token-utxo/README.md) |
| [Token ERC-1155](token-erc-1155) | Smart contract demonstrating how to create and transfer multiple tokens (both fungible and non-fungible) using an account based model. | [README](token-erc-1155/README.md) |
| [Token ERC-721](token-erc-721) | Smart contract demonstrating how to create and transfer non-fungible tokens using an account-based model. | [README](token-erc-721/README.md) |
| [High throughput](high-throughput) | Learn how you can design your smart contract to avoid transaction collisions in high volume environments. | [README](high-throughput/README.md) |
| [Simple Auction](auction-simple) | Run an auction where bids are kept private until the auction is closed, after which users can reveal their bid. | [README](auction-simple/README.md) |
| [Dutch Auction](auction-dutch) | Run an auction in which multiple items of the same type can be sold to more than one buyer. This example also includes the ability to add an auditor organization. | [README](auction-dutch/README.md) |
```bash
./scripts/bootstrap.sh [version] [ca version] [thirdparty_version]
```
## License <a name="license"></a> ## License <a name="license"></a>

11
SECURITY.md Normal file
View file

@ -0,0 +1,11 @@
# Hyperledger Security Policy
## Reporting a Security Bug
If you think you have discovered a security issue in any of the Hyperledger projects, we'd love to hear from you. We will take all security bugs seriously and if confirmed upon investigation we will patch it within a reasonable amount of time and release a public security bulletin discussing the impact and credit the discoverer.
There are two ways to report a security bug. The easiest is to email a description of the flaw and any related information (e.g. reproduction steps, version) to [security at hyperledger dot org](mailto:security@hyperledger.org).
The other way is to file a confidential security bug in the repository's [security advisories page](https://github.com/hyperledger/fabric/security/advisories). Guidance can be found in the GitHub documentation on [privately reporting a security vulnerability](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability).
The process by which the Hyperledger Security Team handles security bugs is documented further in our [Defect Response page](https://lf-hyperledger.atlassian.net/wiki/spaces/SEC/pages/20283618/Defect+Response) on our [wiki](https://lf-hyperledger.atlassian.net/wiki).

View file

@ -0,0 +1,173 @@
# Attribute based access control
The `asset-transfer-abac` sample demonstrates the use of Attribute-based access control within the context of a simple asset transfer scenario. The sample also uses authorization based on individual client identities to allow the users that interact with the network to own assets on the blockchain ledger.
Attribute-Based Access Control (ABAC) refers to the ability to restrict access to certain functionality within a smart contract based on the attributes within a users certificate. For example, you may want certain functions within a smart contract to be used only by application administrators. ABAC allows organizations to provide elevated access to certain users without requiring those users be administrators of the network. For more information, see [Attribute-based access control](https://hyperledger-fabric-ca.readthedocs.io/en/latest/users-guide.html#attribute-based-access-control) in the Fabric CA users guide.
The `asset-transfer-abac` smart contract allows you to create assets that can be updated or transferred by the asset owner. However, the ability to create or remove assets from the ledger is restricted to identities with the `abac.creator=true` attribute. The identity that creates the asset is assigned as the asset owner. Only the owner can transfer the asset to a new owner or update the asset properties. In the course of the tutorial, we will use the Fabric CA client to create identities with the attribute required to create a new asset. We will then transfer the asset to another identity and demonstrate how the `GetID()` function can be used to enforce asset ownership. We will then use the owner identity to delete the asset. Both Attribute based access control and the `GetID()` function are provided by the [Client Identity Chaincode Library](https://github.com/hyperledger/fabric-chaincode-go/blob/master/pkg/cid/README.md).
## Start the network and deploy the smart contract
We can use the Fabric test network to deploy and interact with the `asset-transfer-abac` smart contract. Run the following command to change into the test network directory and bring down any running nodes:
```
cd fabric-samples/test-network
./network.sh down
```
Run the following command to deploy the test network using Certificate Authorities:
```
./network.sh up createChannel -ca
```
You can then use the test network script to deploy the `asset-transfer-abac` smart contract to a channel on the network:
```
./network.sh deployCC -ccn abac -ccp ../asset-transfer-abac/chaincode-go/ -ccl go
```
## Register identities with attributes
We can use the one of the test network Certificate Authorities to register and enroll identities with the attribute of `abac.creator=true`. First, we need to set the following environment variables in order to use the Fabric CA client.
```
export PATH=${PWD}/../bin:${PWD}:$PATH
export FABRIC_CFG_PATH=$PWD/../config/
```
We will create the identities using the Org1 CA. Set the Fabric CA client home to the MSP of the Org1 CA admin:
```
export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org1.example.com/
```
There are two ways to generate certificates with attributes added. We will use both methods and create two identities in the process. The first method is to specify that the attribute be added to the certificate by default when the identity is registered. The following command will register an identity named creator1 with the attribute of `abac.creator=true`.
```
fabric-ca-client register --id.name creator1 --id.secret creator1pw --id.type client --id.affiliation org1 --id.attrs 'abac.creator=true:ecert' --tls.certfiles "${PWD}/organizations/fabric-ca/org1/tls-cert.pem"
```
The `ecert` suffix adds the attribute to the certificate automatically when the identity is enrolled. As a result, the following enroll command will contain the attribute that was provided in the registration command.
```
fabric-ca-client enroll -u https://creator1:creator1pw@localhost:7054 --caname ca-org1 -M "${PWD}/organizations/peerOrganizations/org1.example.com/users/creator1@org1.example.com/msp" --tls.certfiles "${PWD}/organizations/fabric-ca/org1/tls-cert.pem"
```
Now that we have enrolled the identity, run the command below to copy the Node OU configuration file into the creator1 MSP folder.
```
cp "${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml" "${PWD}/organizations/peerOrganizations/org1.example.com/users/creator1@org1.example.com/msp/config.yaml"
```
The second method is to request that the attribute be added upon enrollment. The following command will register an identity named creator2 with the same `abac.creator` attribute.
```
fabric-ca-client register --id.name creator2 --id.secret creator2pw --id.type client --id.affiliation org1 --id.attrs 'abac.creator=true:' --tls.certfiles "${PWD}/organizations/fabric-ca/org1/tls-cert.pem"
```
The following enroll command will add the attribute to the certificate:
```
fabric-ca-client enroll -u https://creator2:creator2pw@localhost:7054 --caname ca-org1 --enrollment.attrs "abac.creator" -M "${PWD}/organizations/peerOrganizations/org1.example.com/users/creator2@org1.example.com/msp" --tls.certfiles "${PWD}/organizations/fabric-ca/org1/tls-cert.pem"
```
Run the command below to copy the Node OU configuration file into the creator2 MSP folder.
```
cp "${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml" "${PWD}/organizations/peerOrganizations/org1.example.com/users/creator2@org1.example.com/msp/config.yaml"
```
## Create an asset
You can use either identity with the `abac.creator=true` attribute to create an asset using the `asset-transfer-abac` smart contract. We will set the following environment variables to use the first identity that was generated, creator1:
```
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID=Org1MSP
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/creator1@org1.example.com/msp
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_ADDRESS=localhost:7051
export TARGET_TLS_OPTIONS=(-o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt")
```
Run the following command to create Asset1:
```
peer chaincode invoke "${TARGET_TLS_OPTIONS[@]}" -C mychannel -n abac -c '{"function":"CreateAsset","Args":["Asset1","blue","20","100"]}'
```
You can use the command below to query the asset on the ledger:
```
peer chaincode query -C mychannel -n abac -c '{"function":"ReadAsset","Args":["Asset1"]}'
```
The result will list the creator1 identity as the asset owner. The `GetID()` API reads the name and issuer from the certificate of the identity that submitted the transaction and assigns that identity as the asset owner:
```
{"ID":"Asset1","color":"blue","size":20,"owner":"x509::CN=creator1,OU=client+OU=org1,O=Hyperledger,ST=North Carolina,C=US::CN=ca.org1.example.com,O=org1.example.com,L=Durham,ST=North Carolina,C=US","appraisedValue":100}
```
## Transfer the asset
As the owner of Asset1, the creator1 identity has the ability to transfer the asset to another owner. In order to transfer the asset, the owner needs to provide the name and issuer of the new owner to the `TransferAsset` function. The `asset-transfer-abac` smart contract has a `GetSubmittingClientIdentity` function that allows users to retrieve their certificate information and provide it to the asset owner out of band (we omit this step). Issue the command below to transfer Asset1 to the user1 identity from Org1 that was created when the test network was deployed:
```
export RECIPIENT="x509::CN=user1,OU=client,O=Hyperledger,ST=North Carolina,C=US::CN=ca.org1.example.com,O=org1.example.com,L=Durham,ST=North Carolina,C=US"
peer chaincode invoke "${TARGET_TLS_OPTIONS[@]}" -C mychannel -n abac -c '{"function":"TransferAsset","Args":["Asset1","'"$RECIPIENT"'"]}'
```
Query the ledger to verify that the asset has a new owner:
```
peer chaincode query -C mychannel -n abac -c '{"function":"ReadAsset","Args":["Asset1"]}'
```
We can see that Asset1 with is now owned by User1:
```
{"ID":"Asset1","color":"blue","size":20,"owner":"x509::CN=user1,OU=client,O=Hyperledger,ST=North Carolina,C=US::CN=ca.org1.example.com,O=org1.example.com,L=Durham,ST=North Carolina,C=US","appraisedValue":100}
```
## Update the asset
Now that the asset has been transferred, the new owner can update the asset properties. The smart contract uses the `GetID()` API to ensure that the update is being submitted by the asset owner. To demonstrate the difference between identity and attribute based access control, lets try to update the asset using the creator1 identity first:
```
peer chaincode invoke "${TARGET_TLS_OPTIONS[@]}" -C mychannel -n abac -c '{"function":"UpdateAsset","Args":["Asset1","green","20","100"]}'
```
Even though creator1 can create new assets, the smart contract detects that the transaction was not submitted by the identity that owns the asset, user1. The command returns the following error:
```
Error: endorsement failure during invoke. response: status:500 message:"submitting client not authorized to update asset, does not own asset"
```
Run the following command to operate as the asset owner by setting the MSP path to User1:
```
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp
```
We can now update the asset. Run the following command to change the asset color from blue to green. All other aspects of the asset will remain unchanged.
```
peer chaincode invoke "${TARGET_TLS_OPTIONS[@]}" -C mychannel -n abac -c '{"function":"UpdateAsset","Args":["Asset1","green","20","100"]}'
```
Run the query command again to verify that the asset has changed color:
```
peer chaincode query -C mychannel -n abac -c '{"function":"ReadAsset","Args":["Asset1"]}'
```
The result will display that Asset1 is now green:
```
{"ID":"Asset1","color":"green","size":20,"owner":"x509::CN=user1,OU=client,O=Hyperledger,ST=North Carolina,C=US::CN=ca.org1.example.com,O=org1.example.com,L=Durham,ST=North Carolina,C=US","appraisedValue":100}
```
## Delete the asset
The owner also has the ability to delete the asset. Run the following command to remove Asset1 from the ledger:
```
peer chaincode invoke "${TARGET_TLS_OPTIONS[@]}" -C mychannel -n abac -c '{"function":"DeleteAsset","Args":["Asset1"]}'
```
If you query the ledger once more, you will see that Asset1 no longer exists:
```
peer chaincode query -C mychannel -n abac -c '{"function":"ReadAsset","Args":["Asset1"]}'
```
While we are operating as User1, we can demonstrate attribute based access control by trying to create an asset using an identity without the `abac.creator=true` attribute. Run the following command to try to create Asset1 as User1:
```
peer chaincode invoke "${TARGET_TLS_OPTIONS[@]}" -C mychannel -n abac -c '{"function":"CreateAsset","Args":["Asset2","red","20","100"]}'
```
The smart contract will return the following error:
```
Error: endorsement failure during invoke. response: status:500 message:"submitting client not authorized to create asset, does not have abac.creator role"
```
## Clean up
When you are finished, you can run the following command to bring down the test network:
```
./network.sh down
```

View file

@ -0,0 +1,26 @@
module github.com/hyperledger/fabric-samples/asset-transfer-abac/chaincode-go
go 1.23.0
require github.com/hyperledger/fabric-contract-api-go/v2 v2.2.0
require (
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/hyperledger/fabric-chaincode-go/v2 v2.0.0 // indirect
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.4 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/text v0.23.0 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/grpc v1.71.0 // indirect
google.golang.org/protobuf v1.36.4 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

View file

@ -0,0 +1,81 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ=
github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4=
github.com/go-openapi/spec v0.21.0 h1:LTVzPc3p/RzRnkQqLRndbAzjY0d0BCL72A6j3CdL9ZY=
github.com/go-openapi/spec v0.21.0/go.mod h1:78u6VdPw81XU44qEWGhtr982gJ5BWg2c0I5XwVMotYk=
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hyperledger/fabric-chaincode-go/v2 v2.0.0 h1:IhkHfrl5X/fVnmB6pWeCYCdIJRi9bxj+WTnVN8DtW3c=
github.com/hyperledger/fabric-chaincode-go/v2 v2.0.0/go.mod h1:PHHaFffjw7p7n9bmCfcm7RqDqYdivNEsJdiNIKZo5Lk=
github.com/hyperledger/fabric-contract-api-go/v2 v2.2.0 h1:rmUoBmciB0GL/miqcbJmJbgp5QTWoJUrZo+CNxrNLF4=
github.com/hyperledger/fabric-contract-api-go/v2 v2.2.0/go.mod h1:FeWeO/jwGjiME7ak3GufqKIcwkejtzrDG4QxbfKydWs=
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.4 h1:YJrd+gMaeY0/vsN0aS0QkEKTivGoUnSRIXxGJ7KI+Pc=
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.4/go.mod h1:bau/6AJhvEcu9GKKYHlDXAxXKzYNfhP6xu2GXuxEcFk=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=
go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=
go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A=
go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU=
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w=
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=
google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View file

@ -0,0 +1,214 @@
package abac
import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/hyperledger/fabric-contract-api-go/v2/contractapi"
)
// SmartContract provides functions for managing an Asset
type SmartContract struct {
contractapi.Contract
}
// Asset describes basic details of what makes up a simple asset
type Asset struct {
ID string `json:"ID"`
Color string `json:"color"`
Size int `json:"size"`
Owner string `json:"owner"`
AppraisedValue int `json:"appraisedValue"`
}
// CreateAsset issues a new asset to the world state with given details.
func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface, id string, color string, size int, appraisedValue int) error {
// Demonstrate the use of Attribute-Based Access Control (ABAC) by checking
// to see if the caller has the "abac.creator" attribute with a value of true;
// if not, return an error.
err := ctx.GetClientIdentity().AssertAttributeValue("abac.creator", "true")
if err != nil {
return fmt.Errorf("submitting client not authorized to create asset, does not have abac.creator role")
}
exists, err := s.AssetExists(ctx, id)
if err != nil {
return err
}
if exists {
return fmt.Errorf("the asset %s already exists", id)
}
// Get ID of submitting client identity
clientID, err := s.GetSubmittingClientIdentity(ctx)
if err != nil {
return err
}
asset := Asset{
ID: id,
Color: color,
Size: size,
Owner: clientID,
AppraisedValue: appraisedValue,
}
assetJSON, err := json.Marshal(asset)
if err != nil {
return err
}
return ctx.GetStub().PutState(id, assetJSON)
}
// UpdateAsset updates an existing asset in the world state with provided parameters.
func (s *SmartContract) UpdateAsset(ctx contractapi.TransactionContextInterface, id string, newColor string, newSize int, newValue int) error {
asset, err := s.ReadAsset(ctx, id)
if err != nil {
return err
}
clientID, err := s.GetSubmittingClientIdentity(ctx)
if err != nil {
return err
}
if clientID != asset.Owner {
return fmt.Errorf("submitting client not authorized to update asset, does not own asset")
}
asset.Color = newColor
asset.Size = newSize
asset.AppraisedValue = newValue
assetJSON, err := json.Marshal(asset)
if err != nil {
return err
}
return ctx.GetStub().PutState(id, assetJSON)
}
// DeleteAsset deletes a given asset from the world state.
func (s *SmartContract) DeleteAsset(ctx contractapi.TransactionContextInterface, id string) error {
asset, err := s.ReadAsset(ctx, id)
if err != nil {
return err
}
clientID, err := s.GetSubmittingClientIdentity(ctx)
if err != nil {
return err
}
if clientID != asset.Owner {
return fmt.Errorf("submitting client not authorized to update asset, does not own asset")
}
return ctx.GetStub().DelState(id)
}
// TransferAsset updates the owner field of asset with given id in world state.
func (s *SmartContract) TransferAsset(ctx contractapi.TransactionContextInterface, id string, newOwner string) error {
asset, err := s.ReadAsset(ctx, id)
if err != nil {
return err
}
clientID, err := s.GetSubmittingClientIdentity(ctx)
if err != nil {
return err
}
if clientID != asset.Owner {
return fmt.Errorf("submitting client not authorized to update asset, does not own asset")
}
asset.Owner = newOwner
assetJSON, err := json.Marshal(asset)
if err != nil {
return err
}
return ctx.GetStub().PutState(id, assetJSON)
}
// ReadAsset returns the asset stored in the world state with given id.
func (s *SmartContract) ReadAsset(ctx contractapi.TransactionContextInterface, id string) (*Asset, error) {
assetJSON, err := ctx.GetStub().GetState(id)
if err != nil {
return nil, fmt.Errorf("failed to read from world state: %v", err)
}
if assetJSON == nil {
return nil, fmt.Errorf("the asset %s does not exist", id)
}
var asset Asset
err = json.Unmarshal(assetJSON, &asset)
if err != nil {
return nil, err
}
return &asset, nil
}
// GetAllAssets returns all assets found in world state
func (s *SmartContract) GetAllAssets(ctx contractapi.TransactionContextInterface) ([]*Asset, error) {
// range query with empty string for startKey and endKey does an
// open-ended query of all assets in the chaincode namespace.
resultsIterator, err := ctx.GetStub().GetStateByRange("", "")
if err != nil {
return nil, err
}
defer resultsIterator.Close()
var assets []*Asset
for resultsIterator.HasNext() {
queryResponse, err := resultsIterator.Next()
if err != nil {
return nil, err
}
var asset Asset
err = json.Unmarshal(queryResponse.Value, &asset)
if err != nil {
return nil, err
}
assets = append(assets, &asset)
}
return assets, nil
}
// AssetExists returns true when asset with given ID exists in world state
func (s *SmartContract) AssetExists(ctx contractapi.TransactionContextInterface, id string) (bool, error) {
assetJSON, err := ctx.GetStub().GetState(id)
if err != nil {
return false, fmt.Errorf("failed to read from world state: %v", err)
}
return assetJSON != nil, nil
}
// GetSubmittingClientIdentity returns the name and issuer of the identity that
// invokes the smart contract. This function base64 decodes the identity string
// before returning the value to the client or smart contract.
func (s *SmartContract) GetSubmittingClientIdentity(ctx contractapi.TransactionContextInterface) (string, error) {
b64ID, err := ctx.GetClientIdentity().GetID()
if err != nil {
return "", fmt.Errorf("Failed to read clientID: %v", err)
}
decodeID, err := base64.StdEncoding.DecodeString(b64ID)
if err != nil {
return "", fmt.Errorf("failed to base64 decode clientID: %v", err)
}
return string(decodeID), nil
}

View file

@ -0,0 +1,23 @@
/*
SPDX-License-Identifier: Apache-2.0
*/
package main
import (
"log"
"github.com/hyperledger/fabric-contract-api-go/v2/contractapi"
abac "github.com/hyperledger/fabric-samples/asset-transfer-abac/chaincode-go/smart-contract"
)
func main() {
abacSmartContract, err := contractapi.NewChaincode(&abac.SmartContract{})
if err != nil {
log.Panicf("Error creating abac chaincode: %v", err)
}
if err := abacSmartContract.Start(); err != nil {
log.Panicf("Error starting abac chaincode: %v", err)
}
}

2
asset-transfer-basic/.gitignore vendored Executable file
View file

@ -0,0 +1,2 @@
wallet
!wallet/.gitkeep

View file

@ -0,0 +1,107 @@
# Asset transfer basic sample
The asset transfer basic sample demonstrates:
- Connecting a client application to a Fabric blockchain network.
- Submitting smart contract transactions to update ledger state.
- Evaluating smart contract transactions to query ledger state.
- Handling errors in transaction invocation.
## About the sample
This sample includes smart contract and application code in multiple languages. This sample shows create, read, update, transfer and delete of an asset.
For a more detailed walk-through of the application code and client API usage, refer to the [Running a Fabric Application tutorial](https://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html) in the main Hyperledger Fabric documentation.
### Application
Follow the execution flow in the client application code, and corresponding output on running the application. Pay attention to the sequence of:
- Transaction invocations (console output like "**--> Submit Transaction**" and "**--> Evaluate Transaction**").
- Results returned by transactions (console output like "**\*\*\* Result**").
### Smart Contract
The smart contract (in folder `chaincode-xyz`) implements the following functions to support the application:
- CreateAsset
- ReadAsset
- UpdateAsset
- DeleteAsset
- TransferAsset
Note that the asset transfer implemented by the smart contract is a simplified scenario, without ownership validation, meant only to demonstrate how to invoke transactions.
## Running the sample
The Fabric test network is used to deploy and run this sample. Follow these steps in order:
1. Create the test network and a channel (from the `test-network` folder).
```
./network.sh up createChannel -c mychannel -ca
```
1. Deploy one of the smart contract implementations (from the `test-network` folder).
- To deploy the **TypeScript** chaincode implementation:
```shell
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-typescript/ -ccl typescript
```
- To deploy the **JavaScript** chaincode implementation:
```shell
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-javascript/ -ccl javascript
```
- To deploy the **Go** chaincode implementation:
```shell
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go/ -ccl go
```
- To deploy the **Java** chaincode implementation:
```shell
./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-java/ -ccl java
```
1. Run the application (from the `asset-transfer-basic` folder).
- To run the **TypeScript** sample application:
```shell
cd application-gateway-typescript
npm install
npm start
```
- To run the **JavaScript** sample application:
```shell
cd application-gateway-javascript
npm install
npm start
```
- To run the **Go** sample application:
```shell
cd application-gateway-go
go run .
```
- To run the **Java** sample application:
```shell
cd application-gateway-java
./gradlew run
```
## Clean up
When you are finished, you can bring down the test network (from the `test-network` folder). The command will remove all the nodes of the test network, and delete any ledger data that you created.
```shell
./network.sh down
```

View file

@ -0,0 +1,275 @@
/*
Copyright 2021 IBM All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package main
import (
"bytes"
"context"
"crypto/x509"
"encoding/json"
"errors"
"fmt"
"os"
"path"
"time"
"github.com/hyperledger/fabric-gateway/pkg/client"
"github.com/hyperledger/fabric-gateway/pkg/hash"
"github.com/hyperledger/fabric-gateway/pkg/identity"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/status"
)
const (
mspID = "Org1MSP"
cryptoPath = "../../test-network/organizations/peerOrganizations/org1.example.com"
certPath = cryptoPath + "/users/User1@org1.example.com/msp/signcerts"
keyPath = cryptoPath + "/users/User1@org1.example.com/msp/keystore"
tlsCertPath = cryptoPath + "/peers/peer0.org1.example.com/tls/ca.crt"
peerEndpoint = "dns:///localhost:7051"
gatewayPeer = "peer0.org1.example.com"
)
var now = time.Now()
var assetId = fmt.Sprintf("asset%d", now.Unix()*1e3+int64(now.Nanosecond())/1e6)
func main() {
// The gRPC client connection should be shared by all Gateway connections to this endpoint
clientConnection := newGrpcConnection()
defer clientConnection.Close()
id := newIdentity()
sign := newSign()
// Create a Gateway connection for a specific client identity
gw, err := client.Connect(
id,
client.WithSign(sign),
client.WithHash(hash.SHA256),
client.WithClientConnection(clientConnection),
// Default timeouts for different gRPC calls
client.WithEvaluateTimeout(5*time.Second),
client.WithEndorseTimeout(15*time.Second),
client.WithSubmitTimeout(5*time.Second),
client.WithCommitStatusTimeout(1*time.Minute),
)
if err != nil {
panic(err)
}
defer gw.Close()
// Override default values for chaincode and channel name as they may differ in testing contexts.
chaincodeName := "basic"
if ccname := os.Getenv("CHAINCODE_NAME"); ccname != "" {
chaincodeName = ccname
}
channelName := "mychannel"
if cname := os.Getenv("CHANNEL_NAME"); cname != "" {
channelName = cname
}
network := gw.GetNetwork(channelName)
contract := network.GetContract(chaincodeName)
initLedger(contract)
getAllAssets(contract)
createAsset(contract)
readAssetByID(contract)
transferAssetAsync(contract)
exampleErrorHandling(contract)
}
// newGrpcConnection creates a gRPC connection to the Gateway server.
func newGrpcConnection() *grpc.ClientConn {
certificatePEM, err := os.ReadFile(tlsCertPath)
if err != nil {
panic(fmt.Errorf("failed to read TLS certifcate file: %w", err))
}
certificate, err := identity.CertificateFromPEM(certificatePEM)
if err != nil {
panic(err)
}
certPool := x509.NewCertPool()
certPool.AddCert(certificate)
transportCredentials := credentials.NewClientTLSFromCert(certPool, gatewayPeer)
connection, err := grpc.NewClient(peerEndpoint, grpc.WithTransportCredentials(transportCredentials))
if err != nil {
panic(fmt.Errorf("failed to create gRPC connection: %w", err))
}
return connection
}
// newIdentity creates a client identity for this Gateway connection using an X.509 certificate.
func newIdentity() *identity.X509Identity {
certificatePEM, err := readFirstFile(certPath)
if err != nil {
panic(fmt.Errorf("failed to read certificate file: %w", err))
}
certificate, err := identity.CertificateFromPEM(certificatePEM)
if err != nil {
panic(err)
}
id, err := identity.NewX509Identity(mspID, certificate)
if err != nil {
panic(err)
}
return id
}
// newSign creates a function that generates a digital signature from a message digest using a private key.
func newSign() identity.Sign {
privateKeyPEM, err := readFirstFile(keyPath)
if err != nil {
panic(fmt.Errorf("failed to read private key file: %w", err))
}
privateKey, err := identity.PrivateKeyFromPEM(privateKeyPEM)
if err != nil {
panic(err)
}
sign, err := identity.NewPrivateKeySign(privateKey)
if err != nil {
panic(err)
}
return sign
}
func readFirstFile(dirPath string) ([]byte, error) {
dir, err := os.Open(dirPath)
if err != nil {
return nil, err
}
fileNames, err := dir.Readdirnames(1)
if err != nil {
return nil, err
}
return os.ReadFile(path.Join(dirPath, fileNames[0]))
}
// This type of transaction would typically only be run once by an application the first time it was started after its
// initial deployment. A new version of the chaincode deployed later would likely not need to run an "init" function.
func initLedger(contract *client.Contract) {
fmt.Printf("\n--> Submit Transaction: InitLedger, function creates the initial set of assets on the ledger \n")
_, err := contract.SubmitTransaction("InitLedger")
if err != nil {
panic(fmt.Errorf("failed to submit transaction: %w", err))
}
fmt.Printf("*** Transaction committed successfully\n")
}
// Evaluate a transaction to query ledger state.
func getAllAssets(contract *client.Contract) {
fmt.Println("\n--> Evaluate Transaction: GetAllAssets, function returns all the current assets on the ledger")
evaluateResult, err := contract.EvaluateTransaction("GetAllAssets")
if err != nil {
panic(fmt.Errorf("failed to evaluate transaction: %w", err))
}
result := formatJSON(evaluateResult)
fmt.Printf("*** Result:%s\n", result)
}
// Submit a transaction synchronously, blocking until it has been committed to the ledger.
func createAsset(contract *client.Contract) {
fmt.Printf("\n--> Submit Transaction: CreateAsset, creates new asset with ID, Color, Size, Owner and AppraisedValue arguments \n")
_, err := contract.SubmitTransaction("CreateAsset", assetId, "yellow", "5", "Tom", "1300")
if err != nil {
panic(fmt.Errorf("failed to submit transaction: %w", err))
}
fmt.Printf("*** Transaction committed successfully\n")
}
// Evaluate a transaction by assetID to query ledger state.
func readAssetByID(contract *client.Contract) {
fmt.Printf("\n--> Evaluate Transaction: ReadAsset, function returns asset attributes\n")
evaluateResult, err := contract.EvaluateTransaction("ReadAsset", assetId)
if err != nil {
panic(fmt.Errorf("failed to evaluate transaction: %w", err))
}
result := formatJSON(evaluateResult)
fmt.Printf("*** Result:%s\n", result)
}
// Submit transaction asynchronously, blocking until the transaction has been sent to the orderer, and allowing
// this thread to process the chaincode response (e.g. update a UI) without waiting for the commit notification
func transferAssetAsync(contract *client.Contract) {
fmt.Printf("\n--> Async Submit Transaction: TransferAsset, updates existing asset owner")
submitResult, commit, err := contract.SubmitAsync("TransferAsset", client.WithArguments(assetId, "Mark"))
if err != nil {
panic(fmt.Errorf("failed to submit transaction asynchronously: %w", err))
}
fmt.Printf("\n*** Successfully submitted transaction to transfer ownership from %s to Mark. \n", string(submitResult))
fmt.Println("*** Waiting for transaction commit.")
if commitStatus, err := commit.Status(); err != nil {
panic(fmt.Errorf("failed to get commit status: %w", err))
} else if !commitStatus.Successful {
panic(fmt.Errorf("transaction %s failed to commit with status: %d", commitStatus.TransactionID, int32(commitStatus.Code)))
}
fmt.Printf("*** Transaction committed successfully\n")
}
// Submit transaction, passing in the wrong number of arguments ,expected to throw an error containing details of any error responses from the smart contract.
func exampleErrorHandling(contract *client.Contract) {
fmt.Println("\n--> Submit Transaction: UpdateAsset asset70, asset70 does not exist and should return an error")
_, err := contract.SubmitTransaction("UpdateAsset", "asset70", "blue", "5", "Tomoko", "300")
if err == nil {
panic("******** FAILED to return an error")
}
fmt.Println("*** Successfully caught the error:")
var commitStatusErr *client.CommitStatusError
var transactionErr *client.TransactionError
if errors.As(err, &commitStatusErr) {
if errors.Is(err, context.DeadlineExceeded) {
fmt.Printf("Timeout waiting for transaction %s commit status: %s\n", commitStatusErr.TransactionID, commitStatusErr)
} else {
fmt.Printf("Error obtaining commit status for transaction %s with gRPC status %v: %s\n", commitStatusErr.TransactionID, status.Code(commitStatusErr), commitStatusErr)
}
} else if errors.As(err, &transactionErr) {
// The error could be an EndorseError, SubmitError or CommitError.
fmt.Println(err)
fmt.Printf("TransactionID: %s\n", transactionErr.TransactionID)
} else {
panic(fmt.Errorf("unexpected error type %T: %w", err, err))
}
}
// Format JSON data
func formatJSON(data []byte) string {
var prettyJSON bytes.Buffer
if err := json.Indent(&prettyJSON, data, "", " "); err != nil {
panic(fmt.Errorf("failed to parse JSON: %w", err))
}
return prettyJSON.String()
}

View file

@ -0,0 +1,18 @@
module assetTransfer
go 1.24.0
require (
github.com/hyperledger/fabric-gateway v1.10.0
google.golang.org/grpc v1.76.0
)
require (
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.7 // indirect
github.com/miekg/pkcs11 v1.1.1 // indirect
golang.org/x/net v0.42.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/text v0.28.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect
google.golang.org/protobuf v1.36.10 // indirect
)

View file

@ -0,0 +1,52 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hyperledger/fabric-gateway v1.10.0 h1:x5z/pofdVYIqgMo9QWejubfAZYCSt94WdUPj4Wipdeg=
github.com/hyperledger/fabric-gateway v1.10.0/go.mod h1:fSFS1vQkPZq6inNvzsnI/7PCaKSU+UZOZ6uAuau0Yq0=
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.7 h1:sQ5qv8vQQfwewa1JlCiSCC8dLElmaU2/frLolpgibEY=
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.7/go.mod h1:bJnwzfv03oZQeCc863pdGTDgf5nmCy6Za3RAE7d2XsQ=
github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU=
github.com/miekg/pkcs11 v1.1.1/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ=
go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I=
go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE=
go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E=
go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI=
go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg=
go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc=
go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps=
go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4=
go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0=
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A=
google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c=
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View file

@ -0,0 +1,37 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* User Manual available at https://docs.gradle.org/6.5/userguide/tutorial_java_projects.html
*/
plugins {
// Apply the application plugin to add support for building a CLI application.
id 'application'
}
ext {
javaMainClass = "application.java.App"
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.hyperledger.fabric:fabric-gateway:1.10.0'
implementation platform('com.google.protobuf:protobuf-bom:4.33.0')
implementation platform('io.grpc:grpc-bom:1.76.0')
compileOnly 'io.grpc:grpc-api'
runtimeOnly 'io.grpc:grpc-netty-shaded'
implementation 'com.google.code.gson:gson:2.13.2'
}
compileJava {
options.release = 11
}
application {
// Define the main class for the application.
mainClass = 'App'
}

View file

@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -0,0 +1,252 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View file

@ -0,0 +1,94 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View file

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.hyperledger.fabric.example</groupId>
<artifactId>asset-transfer-basic</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-bom</artifactId>
<version>4.33.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-bom</artifactId>
<version>1.76.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.hyperledger.fabric</groupId>
<artifactId>fabric-gateway</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be
moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see
https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see
https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<!-- site lifecycle, see
https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.6.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View file

@ -0,0 +1,10 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/6.5/userguide/multi_project_builds.html
*/
rootProject.name = 'asset-transfer-basic'

View file

@ -0,0 +1,244 @@
/*
* Copyright IBM Corp. All Rights Reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParser;
import io.grpc.Grpc;
import io.grpc.ManagedChannel;
import io.grpc.TlsChannelCredentials;
import org.hyperledger.fabric.client.CommitException;
import org.hyperledger.fabric.client.CommitStatusException;
import org.hyperledger.fabric.client.Contract;
import org.hyperledger.fabric.client.EndorseException;
import org.hyperledger.fabric.client.Gateway;
import org.hyperledger.fabric.client.GatewayException;
import org.hyperledger.fabric.client.Hash;
import org.hyperledger.fabric.client.SubmitException;
import org.hyperledger.fabric.client.identity.Identities;
import org.hyperledger.fabric.client.identity.Identity;
import org.hyperledger.fabric.client.identity.Signer;
import org.hyperledger.fabric.client.identity.Signers;
import org.hyperledger.fabric.client.identity.X509Identity;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.InvalidKeyException;
import java.security.cert.CertificateException;
import java.time.Instant;
import java.util.concurrent.TimeUnit;
public final class App {
private static final String MSP_ID = System.getenv().getOrDefault("MSP_ID", "Org1MSP");
private static final String CHANNEL_NAME = System.getenv().getOrDefault("CHANNEL_NAME", "mychannel");
private static final String CHAINCODE_NAME = System.getenv().getOrDefault("CHAINCODE_NAME", "basic");
// Path to crypto materials.
private static final Path CRYPTO_PATH = Paths.get("../../test-network/organizations/peerOrganizations/org1.example.com");
// Path to user certificate.
private static final Path CERT_DIR_PATH = CRYPTO_PATH.resolve(Paths.get("users/User1@org1.example.com/msp/signcerts"));
// Path to user private key directory.
private static final Path KEY_DIR_PATH = CRYPTO_PATH.resolve(Paths.get("users/User1@org1.example.com/msp/keystore"));
// Path to peer tls certificate.
private static final Path TLS_CERT_PATH = CRYPTO_PATH.resolve(Paths.get("peers/peer0.org1.example.com/tls/ca.crt"));
// Gateway peer end point.
private static final String PEER_ENDPOINT = "localhost:7051";
private static final String OVERRIDE_AUTH = "peer0.org1.example.com";
private final Contract contract;
private final String assetId = "asset" + Instant.now().toEpochMilli();
private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
public static void main(final String[] args) throws Exception {
// The gRPC client connection should be shared by all Gateway connections to
// this endpoint.
var channel = newGrpcConnection();
var builder = Gateway.newInstance()
.identity(newIdentity())
.signer(newSigner())
.hash(Hash.SHA256)
.connection(channel)
// Default timeouts for different gRPC calls
.evaluateOptions(options -> options.withDeadlineAfter(5, TimeUnit.SECONDS))
.endorseOptions(options -> options.withDeadlineAfter(15, TimeUnit.SECONDS))
.submitOptions(options -> options.withDeadlineAfter(5, TimeUnit.SECONDS))
.commitStatusOptions(options -> options.withDeadlineAfter(1, TimeUnit.MINUTES));
try (var gateway = builder.connect()) {
new App(gateway).run();
} finally {
channel.shutdownNow().awaitTermination(5, TimeUnit.SECONDS);
}
}
private static ManagedChannel newGrpcConnection() throws IOException {
var credentials = TlsChannelCredentials.newBuilder()
.trustManager(TLS_CERT_PATH.toFile())
.build();
return Grpc.newChannelBuilder(PEER_ENDPOINT, credentials)
.overrideAuthority(OVERRIDE_AUTH)
.build();
}
private static Identity newIdentity() throws IOException, CertificateException {
try (var certReader = Files.newBufferedReader(getFirstFilePath(CERT_DIR_PATH))) {
var certificate = Identities.readX509Certificate(certReader);
return new X509Identity(MSP_ID, certificate);
}
}
private static Signer newSigner() throws IOException, InvalidKeyException {
try (var keyReader = Files.newBufferedReader(getFirstFilePath(KEY_DIR_PATH))) {
var privateKey = Identities.readPrivateKey(keyReader);
return Signers.newPrivateKeySigner(privateKey);
}
}
private static Path getFirstFilePath(Path dirPath) throws IOException {
try (var keyFiles = Files.list(dirPath)) {
return keyFiles.findFirst().orElseThrow();
}
}
public App(final Gateway gateway) {
// Get a network instance representing the channel where the smart contract is
// deployed.
var network = gateway.getNetwork(CHANNEL_NAME);
// Get the smart contract from the network.
contract = network.getContract(CHAINCODE_NAME);
}
public void run() throws GatewayException, CommitException {
// Initialize a set of asset data on the ledger using the chaincode 'InitLedger' function.
initLedger();
// Return all the current assets on the ledger.
getAllAssets();
// Create a new asset on the ledger.
createAsset();
// Update an existing asset asynchronously.
transferAssetAsync();
// Get the asset details by assetID.
readAssetById();
// Update an asset which does not exist.
updateNonExistentAsset();
}
/**
* This type of transaction would typically only be run once by an application
* the first time it was started after its initial deployment. A new version of
* the chaincode deployed later would likely not need to run an "init" function.
*/
private void initLedger() throws EndorseException, SubmitException, CommitStatusException, CommitException {
System.out.println("\n--> Submit Transaction: InitLedger, function creates the initial set of assets on the ledger");
contract.submitTransaction("InitLedger");
System.out.println("*** Transaction committed successfully");
}
/**
* Evaluate a transaction to query ledger state.
*/
private void getAllAssets() throws GatewayException {
System.out.println("\n--> Evaluate Transaction: GetAllAssets, function returns all the current assets on the ledger");
var result = contract.evaluateTransaction("GetAllAssets");
System.out.println("*** Result: " + prettyJson(result));
}
private String prettyJson(final byte[] json) {
return prettyJson(new String(json, StandardCharsets.UTF_8));
}
private String prettyJson(final String json) {
var parsedJson = JsonParser.parseString(json);
return gson.toJson(parsedJson);
}
/**
* Submit a transaction synchronously, blocking until it has been committed to
* the ledger.
*/
private void createAsset() throws EndorseException, SubmitException, CommitStatusException, CommitException {
System.out.println("\n--> Submit Transaction: CreateAsset, creates new asset with ID, Color, Size, Owner and AppraisedValue arguments");
contract.submitTransaction("CreateAsset", assetId, "yellow", "5", "Tom", "1300");
System.out.println("*** Transaction committed successfully");
}
/**
* Submit transaction asynchronously, allowing the application to process the
* smart contract response (e.g. update a UI) while waiting for the commit
* notification.
*/
private void transferAssetAsync() throws EndorseException, SubmitException, CommitStatusException {
System.out.println("\n--> Async Submit Transaction: TransferAsset, updates existing asset owner");
var commit = contract.newProposal("TransferAsset")
.addArguments(assetId, "Saptha")
.build()
.endorse()
.submitAsync();
var result = commit.getResult();
var oldOwner = new String(result, StandardCharsets.UTF_8);
System.out.println("*** Successfully submitted transaction to transfer ownership from " + oldOwner + " to Saptha");
System.out.println("*** Waiting for transaction commit");
var status = commit.getStatus();
if (!status.isSuccessful()) {
throw new RuntimeException("Transaction " + status.getTransactionId() +
" failed to commit with status code " + status.getCode());
}
System.out.println("*** Transaction committed successfully");
}
private void readAssetById() throws GatewayException {
System.out.println("\n--> Evaluate Transaction: ReadAsset, function returns asset attributes");
var evaluateResult = contract.evaluateTransaction("ReadAsset", assetId);
System.out.println("*** Result:" + prettyJson(evaluateResult));
}
/**
* submitTransaction() will throw an error containing details of any error
* responses from the smart contract.
*/
private void updateNonExistentAsset() {
try {
System.out.println("\n--> Submit Transaction: UpdateAsset asset70, asset70 does not exist and should return an error");
contract.submitTransaction("UpdateAsset", "asset70", "blue", "5", "Tomoko", "300");
System.out.println("******** FAILED to return an error");
} catch (EndorseException | SubmitException | CommitStatusException e) {
System.out.println("*** Successfully caught the error:");
e.printStackTrace(System.out);
System.out.println("Transaction ID: " + e.getTransactionId());
} catch (CommitException e) {
System.out.println("*** Successfully caught the error:");
e.printStackTrace(System.out);
System.out.println("Transaction ID: " + e.getTransactionId());
System.out.println("Status code: " + e.getCode());
}
}
}

View file

@ -0,0 +1,11 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# Coverage directory used by tools like istanbul
coverage
# Dependency directories
node_modules/
jspm_packages/

View file

@ -0,0 +1 @@
engine-strict=true

View file

@ -0,0 +1,15 @@
import js from '@eslint/js';
import globals from 'globals';
export default [
js.configs.recommended,
{
languageOptions: {
ecmaVersion: 2023,
sourceType: 'commonjs',
globals: {
...globals.node,
},
},
},
];

View file

@ -0,0 +1,25 @@
{
"name": "asset-transfer-basic",
"version": "1.0.0",
"description": "Asset Transfer Basic Application implemented in JavaScript using fabric-gateway",
"engines": {
"node": ">=20"
},
"scripts": {
"lint": "eslint src",
"pretest": "npm run lint",
"start": "node src/app.js"
},
"engineStrict": true,
"author": "Hyperledger",
"license": "Apache-2.0",
"dependencies": {
"@grpc/grpc-js": "^1.14.0",
"@hyperledger/fabric-gateway": "^1.10.0"
},
"devDependencies": {
"@eslint/js": "^9.5.0",
"eslint": "^9.5.0",
"globals": "^15.6.0"
}
}

View file

@ -0,0 +1,301 @@
/*
* Copyright IBM Corp. All Rights Reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
const grpc = require('@grpc/grpc-js');
const { connect, hash, signers } = require('@hyperledger/fabric-gateway');
const crypto = require('node:crypto');
const fs = require('node:fs/promises');
const path = require('node:path');
const { TextDecoder } = require('node:util');
const channelName = envOrDefault('CHANNEL_NAME', 'mychannel');
const chaincodeName = envOrDefault('CHAINCODE_NAME', 'basic');
const mspId = envOrDefault('MSP_ID', 'Org1MSP');
// Path to crypto materials.
const cryptoPath = envOrDefault(
'CRYPTO_PATH',
path.resolve(
__dirname,
'..',
'..',
'..',
'test-network',
'organizations',
'peerOrganizations',
'org1.example.com'
)
);
// Path to user private key directory.
const keyDirectoryPath = envOrDefault(
'KEY_DIRECTORY_PATH',
path.resolve(
cryptoPath,
'users',
'User1@org1.example.com',
'msp',
'keystore'
)
);
// Path to user certificate directory.
const certDirectoryPath = envOrDefault(
'CERT_DIRECTORY_PATH',
path.resolve(
cryptoPath,
'users',
'User1@org1.example.com',
'msp',
'signcerts'
)
);
// Path to peer tls certificate.
const tlsCertPath = envOrDefault(
'TLS_CERT_PATH',
path.resolve(cryptoPath, 'peers', 'peer0.org1.example.com', 'tls', 'ca.crt')
);
// Gateway peer endpoint.
const peerEndpoint = envOrDefault('PEER_ENDPOINT', 'localhost:7051');
// Gateway peer SSL host name override.
const peerHostAlias = envOrDefault('PEER_HOST_ALIAS', 'peer0.org1.example.com');
const utf8Decoder = new TextDecoder();
const assetId = `asset${String(Date.now())}`;
async function main() {
displayInputParameters();
// The gRPC client connection should be shared by all Gateway connections to this endpoint.
const client = await newGrpcConnection();
const gateway = connect({
client,
identity: await newIdentity(),
signer: await newSigner(),
hash: hash.sha256,
// Default timeouts for different gRPC calls
evaluateOptions: () => {
return { deadline: Date.now() + 5000 }; // 5 seconds
},
endorseOptions: () => {
return { deadline: Date.now() + 15000 }; // 15 seconds
},
submitOptions: () => {
return { deadline: Date.now() + 5000 }; // 5 seconds
},
commitStatusOptions: () => {
return { deadline: Date.now() + 60000 }; // 1 minute
},
});
try {
// Get a network instance representing the channel where the smart contract is deployed.
const network = gateway.getNetwork(channelName);
// Get the smart contract from the network.
const contract = network.getContract(chaincodeName);
// Initialize a set of asset data on the ledger using the chaincode 'InitLedger' function.
await initLedger(contract);
// Return all the current assets on the ledger.
await getAllAssets(contract);
// Create a new asset on the ledger.
await createAsset(contract);
// Update an existing asset asynchronously.
await transferAssetAsync(contract);
// Get the asset details by assetID.
await readAssetByID(contract);
// Update an asset which does not exist.
await updateNonExistentAsset(contract);
} finally {
gateway.close();
client.close();
}
}
main().catch((error) => {
console.error('******** FAILED to run the application:', error);
process.exitCode = 1;
});
async function newGrpcConnection() {
const tlsRootCert = await fs.readFile(tlsCertPath);
const tlsCredentials = grpc.credentials.createSsl(tlsRootCert);
return new grpc.Client(peerEndpoint, tlsCredentials, {
'grpc.ssl_target_name_override': peerHostAlias,
});
}
async function newIdentity() {
const certPath = await getFirstDirFileName(certDirectoryPath);
const credentials = await fs.readFile(certPath);
return { mspId, credentials };
}
async function getFirstDirFileName(dirPath) {
const files = await fs.readdir(dirPath);
const file = files[0];
if (!file) {
throw new Error(`No files in directory: ${dirPath}`);
}
return path.join(dirPath, file);
}
async function newSigner() {
const keyPath = await getFirstDirFileName(keyDirectoryPath);
const privateKeyPem = await fs.readFile(keyPath);
const privateKey = crypto.createPrivateKey(privateKeyPem);
return signers.newPrivateKeySigner(privateKey);
}
/**
* This type of transaction would typically only be run once by an application the first time it was started after its
* initial deployment. A new version of the chaincode deployed later would likely not need to run an "init" function.
*/
async function initLedger(contract) {
console.log(
'\n--> Submit Transaction: InitLedger, function creates the initial set of assets on the ledger'
);
await contract.submitTransaction('InitLedger');
console.log('*** Transaction committed successfully');
}
/**
* Evaluate a transaction to query ledger state.
*/
async function getAllAssets(contract) {
console.log(
'\n--> Evaluate Transaction: GetAllAssets, function returns all the current assets on the ledger'
);
const resultBytes = await contract.evaluateTransaction('GetAllAssets');
const resultJson = utf8Decoder.decode(resultBytes);
const result = JSON.parse(resultJson);
console.log('*** Result:', result);
}
/**
* Submit a transaction synchronously, blocking until it has been committed to the ledger.
*/
async function createAsset(contract) {
console.log(
'\n--> Submit Transaction: CreateAsset, creates new asset with ID, Color, Size, Owner and AppraisedValue arguments'
);
await contract.submitTransaction(
'CreateAsset',
assetId,
'yellow',
'5',
'Tom',
'1300'
);
console.log('*** Transaction committed successfully');
}
/**
* Submit transaction asynchronously, allowing the application to process the smart contract response (e.g. update a UI)
* while waiting for the commit notification.
*/
async function transferAssetAsync(contract) {
console.log(
'\n--> Async Submit Transaction: TransferAsset, updates existing asset owner'
);
const commit = await contract.submitAsync('TransferAsset', {
arguments: [assetId, 'Saptha'],
});
const oldOwner = utf8Decoder.decode(commit.getResult());
console.log(
`*** Successfully submitted transaction to transfer ownership from ${oldOwner} to Saptha`
);
console.log('*** Waiting for transaction commit');
const status = await commit.getStatus();
if (!status.successful) {
throw new Error(
`Transaction ${
status.transactionId
} failed to commit with status code ${String(status.code)}`
);
}
console.log('*** Transaction committed successfully');
}
async function readAssetByID(contract) {
console.log(
'\n--> Evaluate Transaction: ReadAsset, function returns asset attributes'
);
const resultBytes = await contract.evaluateTransaction(
'ReadAsset',
assetId
);
const resultJson = utf8Decoder.decode(resultBytes);
const result = JSON.parse(resultJson);
console.log('*** Result:', result);
}
/**
* submitTransaction() will throw an error containing details of any error responses from the smart contract.
*/
async function updateNonExistentAsset(contract) {
console.log(
'\n--> Submit Transaction: UpdateAsset asset70, asset70 does not exist and should return an error'
);
try {
await contract.submitTransaction(
'UpdateAsset',
'asset70',
'blue',
'5',
'Tomoko',
'300'
);
console.log('******** FAILED to return an error');
} catch (error) {
console.log('*** Successfully caught the error: \n', error);
}
}
/**
* envOrDefault() will return the value of an environment variable, or a default value if the variable is undefined.
*/
function envOrDefault(key, defaultValue) {
return process.env[key] || defaultValue;
}
/**
* displayInputParameters() will print the global scope parameters used by the main driver routine.
*/
function displayInputParameters() {
console.log(`channelName: ${channelName}`);
console.log(`chaincodeName: ${chaincodeName}`);
console.log(`mspId: ${mspId}`);
console.log(`cryptoPath: ${cryptoPath}`);
console.log(`keyDirectoryPath: ${keyDirectoryPath}`);
console.log(`certDirectoryPath: ${certDirectoryPath}`);
console.log(`tlsCertPath: ${tlsCertPath}`);
console.log(`peerEndpoint: ${peerEndpoint}`);
console.log(`peerHostAlias: ${peerHostAlias}`);
}

View file

@ -0,0 +1,14 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# Coverage directory used by tools like istanbul
coverage
# Dependency directories
node_modules/
jspm_packages/
# Compiled TypeScript files
dist

View file

@ -0,0 +1 @@
engine-strict=true

View file

@ -0,0 +1,14 @@
import js from '@eslint/js';
import { defineConfig } from 'eslint/config';
import tseslint from 'typescript-eslint';
export default defineConfig(js.configs.recommended, ...tseslint.configs.strictTypeChecked, {
languageOptions: {
ecmaVersion: 2023,
sourceType: 'module',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: import.meta.dirname,
},
},
});

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,33 @@
{
"name": "asset-transfer-basic",
"version": "1.0.0",
"description": "Asset Transfer Basic Application implemented in typeScript using fabric-gateway",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"engines": {
"node": ">=20"
},
"scripts": {
"build": "tsc",
"build:watch": "tsc -w",
"lint": "eslint src",
"prepare": "npm run build",
"pretest": "npm run lint",
"start": "node dist/app.js"
},
"engineStrict": true,
"author": "Hyperledger",
"license": "Apache-2.0",
"dependencies": {
"@grpc/grpc-js": "^1.14.0",
"@hyperledger/fabric-gateway": "^1.10.0"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"@tsconfig/node20": "^20.1.9",
"@types/node": "^20.19.33",
"eslint": "^10.0.2",
"typescript": "~5.8",
"typescript-eslint": "^8.56.1"
}
}

View file

@ -0,0 +1,247 @@
/*
* Copyright IBM Corp. All Rights Reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
import * as grpc from '@grpc/grpc-js';
import { connect, Contract, hash, Identity, Signer, signers } from '@hyperledger/fabric-gateway';
import * as crypto from 'crypto';
import { promises as fs } from 'fs';
import * as path from 'path';
import { TextDecoder } from 'util';
const channelName = envOrDefault('CHANNEL_NAME', 'mychannel');
const chaincodeName = envOrDefault('CHAINCODE_NAME', 'basic');
const mspId = envOrDefault('MSP_ID', 'Org1MSP');
// Path to crypto materials.
const cryptoPath = envOrDefault('CRYPTO_PATH', path.resolve(__dirname, '..', '..', '..', 'test-network', 'organizations', 'peerOrganizations', 'org1.example.com'));
// Path to user private key directory.
const keyDirectoryPath = envOrDefault('KEY_DIRECTORY_PATH', path.resolve(cryptoPath, 'users', 'User1@org1.example.com', 'msp', 'keystore'));
// Path to user certificate directory.
const certDirectoryPath = envOrDefault('CERT_DIRECTORY_PATH', path.resolve(cryptoPath, 'users', 'User1@org1.example.com', 'msp', 'signcerts'));
// Path to peer tls certificate.
const tlsCertPath = envOrDefault('TLS_CERT_PATH', path.resolve(cryptoPath, 'peers', 'peer0.org1.example.com', 'tls', 'ca.crt'));
// Gateway peer endpoint.
const peerEndpoint = envOrDefault('PEER_ENDPOINT', 'localhost:7051');
// Gateway peer SSL host name override.
const peerHostAlias = envOrDefault('PEER_HOST_ALIAS', 'peer0.org1.example.com');
const utf8Decoder = new TextDecoder();
const assetId = `asset${String(Date.now())}`;
async function main(): Promise<void> {
displayInputParameters();
// The gRPC client connection should be shared by all Gateway connections to this endpoint.
const client = await newGrpcConnection();
const gateway = connect({
client,
identity: await newIdentity(),
signer: await newSigner(),
hash: hash.sha256,
// Default timeouts for different gRPC calls
evaluateOptions: () => {
return { deadline: Date.now() + 5000 }; // 5 seconds
},
endorseOptions: () => {
return { deadline: Date.now() + 15000 }; // 15 seconds
},
submitOptions: () => {
return { deadline: Date.now() + 5000 }; // 5 seconds
},
commitStatusOptions: () => {
return { deadline: Date.now() + 60000 }; // 1 minute
},
});
try {
// Get a network instance representing the channel where the smart contract is deployed.
const network = gateway.getNetwork(channelName);
// Get the smart contract from the network.
const contract = network.getContract(chaincodeName);
// Initialize a set of asset data on the ledger using the chaincode 'InitLedger' function.
await initLedger(contract);
// Return all the current assets on the ledger.
await getAllAssets(contract);
// Create a new asset on the ledger.
await createAsset(contract);
// Update an existing asset asynchronously.
await transferAssetAsync(contract);
// Get the asset details by assetID.
await readAssetByID(contract);
// Update an asset which does not exist.
await updateNonExistentAsset(contract)
} finally {
gateway.close();
client.close();
}
}
main().catch((error: unknown) => {
console.error('******** FAILED to run the application:', error);
process.exitCode = 1;
});
async function newGrpcConnection(): Promise<grpc.Client> {
const tlsRootCert = await fs.readFile(tlsCertPath);
const tlsCredentials = grpc.credentials.createSsl(tlsRootCert);
return new grpc.Client(peerEndpoint, tlsCredentials, {
'grpc.ssl_target_name_override': peerHostAlias,
});
}
async function newIdentity(): Promise<Identity> {
const certPath = await getFirstDirFileName(certDirectoryPath);
const credentials = await fs.readFile(certPath);
return { mspId, credentials };
}
async function getFirstDirFileName(dirPath: string): Promise<string> {
const files = await fs.readdir(dirPath);
const file = files[0];
if (!file) {
throw new Error(`No files in directory: ${dirPath}`);
}
return path.join(dirPath, file);
}
async function newSigner(): Promise<Signer> {
const keyPath = await getFirstDirFileName(keyDirectoryPath);
const privateKeyPem = await fs.readFile(keyPath);
const privateKey = crypto.createPrivateKey(privateKeyPem);
return signers.newPrivateKeySigner(privateKey);
}
/**
* This type of transaction would typically only be run once by an application the first time it was started after its
* initial deployment. A new version of the chaincode deployed later would likely not need to run an "init" function.
*/
async function initLedger(contract: Contract): Promise<void> {
console.log('\n--> Submit Transaction: InitLedger, function creates the initial set of assets on the ledger');
await contract.submitTransaction('InitLedger');
console.log('*** Transaction committed successfully');
}
/**
* Evaluate a transaction to query ledger state.
*/
async function getAllAssets(contract: Contract): Promise<void> {
console.log('\n--> Evaluate Transaction: GetAllAssets, function returns all the current assets on the ledger');
const resultBytes = await contract.evaluateTransaction('GetAllAssets');
const resultJson = utf8Decoder.decode(resultBytes);
const result: unknown = JSON.parse(resultJson);
console.log('*** Result:', result);
}
/**
* Submit a transaction synchronously, blocking until it has been committed to the ledger.
*/
async function createAsset(contract: Contract): Promise<void> {
console.log('\n--> Submit Transaction: CreateAsset, creates new asset with ID, Color, Size, Owner and AppraisedValue arguments');
await contract.submitTransaction(
'CreateAsset',
assetId,
'yellow',
'5',
'Tom',
'1300',
);
console.log('*** Transaction committed successfully');
}
/**
* Submit transaction asynchronously, allowing the application to process the smart contract response (e.g. update a UI)
* while waiting for the commit notification.
*/
async function transferAssetAsync(contract: Contract): Promise<void> {
console.log('\n--> Async Submit Transaction: TransferAsset, updates existing asset owner');
const commit = await contract.submitAsync('TransferAsset', {
arguments: [assetId, 'Saptha'],
});
const oldOwner = utf8Decoder.decode(commit.getResult());
console.log(`*** Successfully submitted transaction to transfer ownership from ${oldOwner} to Saptha`);
console.log('*** Waiting for transaction commit');
const status = await commit.getStatus();
if (!status.successful) {
throw new Error(`Transaction ${status.transactionId} failed to commit with status code ${String(status.code)}`);
}
console.log('*** Transaction committed successfully');
}
async function readAssetByID(contract: Contract): Promise<void> {
console.log('\n--> Evaluate Transaction: ReadAsset, function returns asset attributes');
const resultBytes = await contract.evaluateTransaction('ReadAsset', assetId);
const resultJson = utf8Decoder.decode(resultBytes);
const result: unknown = JSON.parse(resultJson);
console.log('*** Result:', result);
}
/**
* submitTransaction() will throw an error containing details of any error responses from the smart contract.
*/
async function updateNonExistentAsset(contract: Contract): Promise<void>{
console.log('\n--> Submit Transaction: UpdateAsset asset70, asset70 does not exist and should return an error');
try {
await contract.submitTransaction(
'UpdateAsset',
'asset70',
'blue',
'5',
'Tomoko',
'300',
);
console.log('******** FAILED to return an error');
} catch (error) {
console.log('*** Successfully caught the error: \n', error);
}
}
/**
* envOrDefault() will return the value of an environment variable, or a default value if the variable is undefined.
*/
function envOrDefault(key: string, defaultValue: string): string {
return process.env[key] || defaultValue;
}
/**
* displayInputParameters() will print the global scope parameters used by the main driver routine.
*/
function displayInputParameters(): void {
console.log(`channelName: ${channelName}`);
console.log(`chaincodeName: ${chaincodeName}`);
console.log(`mspId: ${mspId}`);
console.log(`cryptoPath: ${cryptoPath}`);
console.log(`keyDirectoryPath: ${keyDirectoryPath}`);
console.log(`certDirectoryPath: ${certDirectoryPath}`);
console.log(`tlsCertPath: ${tlsCertPath}`);
console.log(`peerEndpoint: ${peerEndpoint}`);
console.log(`peerHostAlias: ${peerHostAlias}`);
}

View file

@ -0,0 +1,15 @@
{
"extends": "@tsconfig/node20/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
"noUncheckedIndexedAccess": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/"],
"exclude": ["**/*.spec.*"]
}

View file

@ -0,0 +1,5 @@
chaincode.env*
*.json
*.md
*.tar.gz
*.tgz

View file

@ -0,0 +1,3 @@
*.tar.gz
*.tgz
crypto/*.pem

View file

@ -0,0 +1,14 @@
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
FROM golang:alpine
WORKDIR /go/src/github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-external
COPY . .
RUN go get -d -v ./...
RUN go install -v ./...
EXPOSE 9999
CMD ["chaincode-external"]

View file

@ -0,0 +1,252 @@
# Asset-Transfer-Basic as an external service
This sample provides an introduction to how to use external builder and launcher scripts to run chaincode as an external service to your peer. For more information, see the [Chaincode as an external service](https://hyperledger-fabric.readthedocs.io/en/latest/cc_service.html) topic in the Fabric documentation.
**Note:** each organization in a real network would need to setup and host their own instance of the external service. In this tutorial, we use the same instance for both organizations for simplicity.
## Setting up the external builder and launcher
External Builders and Launchers is an advanced feature that typically requires custom packaging of the peer image so that it contains all the tools your builder and launcher require. This sample uses very simple (and crude) shell scripts that can be run directly within the default Fabric peer images.
Open the `config/core.yaml` file at the top of the `fabric-samples` directory. If you do not have this file, follow the instructions to [Install the Samples, Binaries and Docker Images](https://hyperledger-fabric.readthedocs.io/en/latest/install.html) to download the Fabric binaries and configuration files alongside the Fabric samples.
Modify the `externalBuilders` field in the `core.yaml` file to resemble the configuration below:
```
externalBuilders:
- path: /opt/gopath/src/github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-external/sampleBuilder
name: external-sample-builder
```
This update sets the name of the external builder as `external-sample-builder`, and the path of the builder to the scripts provided in this sample. Note that this is the path within the peer container, not your local machine.
To set the path within the peer container, you will need to modify the docker compose file to mount a couple of additional volumes. Open the file `test-network/compose/docker/docker-compose-test-net.yaml`, and add to the `volumes` section of both `peer0.org1.example.com` and `peer0.org2.example.com` the following two lines:
```
- ../..:/opt/gopath/src/github.com/hyperledger/fabric-samples
- ../../config/core.yaml:/etc/hyperledger/peercfg/core.yaml
```
This update will mount the `core.yaml` that you modified into the peer container and override the configuration file within the peer image. The update also mounts the fabric-sample builder so that it can be found at the location that you specified in `core.yaml`. You also have the option of commenting out the line `- /var/run/docker.sock:/host/var/run/docker.sock`, since we no longer need to access the docker daemon from inside the peer container to launch the chaincode.
## Packaging and installing Chaincode
The Asset-Transfer-Basic external chaincode requires two environment variables to run, `CHAINCODE_SERVER_ADDRESS` and `CHAINCODE_ID`, which are described and set in the `chaincode.env` file.
You need to provide a `connection.json` configuration file to your peer in order to connect to the external Asset-Transfer-Basic service. The address specified in the `connection.json` must correspond to the `CHAINCODE_SERVER_ADDRESS` value in `chaincode.env`, which is `asset-transfer-basic.org1.example.com:9999` in our example.
Because we will run our chaincode as an external service, the chaincode itself does not need to be included in the chaincode
package that gets installed to each peer. Only the configuration and metadata information needs to be included
in the package. Since the packaging is trivial, we can manually create the chaincode package.
Open a new terminal and navigate to the `fabric-samples/asset-transfer-basic/chaincode-external` directory.
```
cd fabric-samples/asset-transfer-basic/chaincode-external
```
First, create a `code.tar.gz` archive containing the `connection.json` file:
```
tar cfz code.tar.gz connection.json
```
Then, create the chaincode package, including the `code.tar.gz` file and the supplied `metadata.json` file:
```
tar cfz asset-transfer-basic-external.tgz metadata.json code.tar.gz
```
You are now ready to deploy the external chaincode sample.
## Starting the test network
We will use the Fabric test network to run the external chaincode. Open a new terminal and navigate to the `fabric-samples/test-network` directory.
```
cd fabric-samples/test-network
```
Run the following command to deploy the test network and create a new channel:
```
./network.sh up createChannel -c mychannel -ca
```
We are now ready to deploy the external chaincode.
## Installing the external chaincode
We can't use the test network script to install an external chaincode so we will have to do a bit more work. However, we can still leverage part of the test-network scripts to make this easier.
From the `test-network` directory, set the following environment variables to use the Fabric binaries:
```
export PATH=${PWD}/../bin:$PATH
export FABRIC_CFG_PATH=$PWD/../config/
```
Run the following command to import functions from the `envVar.sh` script into your terminal. These functions allow you to act as either test network organization.
```
. ./scripts/envVar.sh
```
Run the following commands to install the `asset-transfer-basic-external.tar.gz` chaincode on org1. The `setGlobals` function simply sets the environment variables that allow you to act as org1 or org2.
```
setGlobals 1
peer lifecycle chaincode install ../asset-transfer-basic/chaincode-external/asset-transfer-basic-external.tgz
```
Install the chaincode package on the org2 peer:
```
setGlobals 2
peer lifecycle chaincode install ../asset-transfer-basic/chaincode-external/asset-transfer-basic-external.tgz
```
Run the following command to query the package ID of the chaincode that you just installed:
```
setGlobals 1
peer lifecycle chaincode queryinstalled --peerAddresses localhost:7051 --tlsRootCertFiles organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
```
The command will return output similar to the following:
```
Installed chaincodes on peer:
Package ID: basic_1.0:ecfc83f251b7c2d9ef376bc3fc20fc6b9744c0fc0a8923092af6542af94790c3, Label: basic_1.0
```
Save the package ID that was returned by the command as an environment variable. The ID will not be the same for all users, so you need to set the variable using the ID from your command window:
```
export CHAINCODE_ID=basic_1.0:ecfc83f251b7c2d9ef376bc3fc20fc6b9744c0fc0a8923092af6542af94790c3
```
## Running the Asset-Transfer-Basic external service
We are going to run the smart contract as an external service by first building and then starting a docker container. Open a new terminal and navigate back to the `chaincode-external` directory:
```
cd fabric-samples/asset-transfer-basic/chaincode-external
```
In this directory, open the `chaincode.env` file to set the `CHAINCODE_ID` variable to the same package ID that was returned by the `peer lifecycle chaincode queryinstalled` command. The value should be the same as the environment variable that you set in the previous terminal.
After you edit the `chaincode.env` file, you can use the `Dockerfile` to build an image of the external Asset-Transfer-Basic chaincode:
```
docker build -t hyperledger/asset-transfer-basic .
```
You can then run the image to start the Asset-Transfer-Basic service:
```
docker run -it --rm --name asset-transfer-basic.org1.example.com --hostname asset-transfer-basic.org1.example.com --env-file chaincode.env --network=fabric_test hyperledger/asset-transfer-basic
```
This will start and run the external chaincode service within the container.
## Deploy the Asset-Transfer-Basic external chaincode definition to the channel
Navigate back to the `test-network` directory to finish deploying the chaincode definition of the external smart contract to the channel. Make sure that your environment variables are still set.
```
setGlobals 2
peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "$PWD/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" --channelID mychannel --name basic --version 1.0 --package-id $CHAINCODE_ID --sequence 1
setGlobals 1
peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "$PWD/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" --channelID mychannel --name basic --version 1.0 --package-id $CHAINCODE_ID --sequence 1
peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "$PWD/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" --channelID mychannel --name basic --peerAddresses localhost:7051 --tlsRootCertFiles "$PWD/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --version 1.0 --sequence 1
```
The commands above approve the chaincode definition for the external chaincode and commits the definition to the channel. The resulting output should be similar to the following:
```
2020-08-05 15:41:44.982 PDT [chaincodeCmd] ClientWait -> INFO 001 txid [6bdbe040b99a45cc90a23ec21f02ea5da7be8b70590eb04ff3323ef77fdedfc7] committed with status (VALID) at localhost:7051
2020-08-05 15:41:44.983 PDT [chaincodeCmd] ClientWait -> INFO 002 txid [6bdbe040b99a45cc90a23ec21f02ea5da7be8b70590eb04ff3323ef77fdedfc7] committed with status (VALID) at localhost:9051
```
Now that we have started the chaincode service and deployed it to the channel, we can submit transactions as we would with a normal chaincode.
## Using the Asset-Transfer-Basic external chaincode
Open yet another terminal and navigate to the `fabric-samples/asset-transfer-basic/application-gateway-go` directory:
```
cd fabric-samples/asset-transfer-basic/application-gateway-go
```
Run the following commands to use the node application in this directory to test the external smart contract:
```
go run .
```
If all goes well, the program should run exactly the same as described in the "Writing Your First Application" tutorial.
## Enabling TLS for chaincode and peer communication
**Note:** This section uses an example of self-signed certificate. You may use your organization hosted CA to issue the certificate and generate a key for production deployment.
In the sample so far, you connected both peers in `test-network` to the single instance of chaincode server. However, if you would like to enable TLS between the peer nodes and the chaincode server, each peer node needs to have its own CA certificate. Enabling TLS is made possible at runtime in the chaincode.
- As a first step generate a keypair that can be used. Run these commands from the `fabric-samples/asset-transfer-basic/chaincode-external` directory.
_Find instructions to install `openssl` in [openssl.org](https://www.openssl.org/)_
For `org1.example.com`
```
openssl req -nodes -x509 -newkey rsa:4096 -keyout crypto/key1.pem -out crypto/cert1.pem -subj "/C=IN/ST=KA/L=Bangalore/O=example Inc/OU=Developer/CN=asset-transfer-basic.org1.example.com/emailAddress=dev@asset-transfer-basic.org1.example.com"
```
For `org2.example.com`
```
openssl req -nodes -x509 -newkey rsa:4096 -keyout crypto/key2.pem -out crypto/cert2.pem -subj "/C=IN/ST=KA/L=Bangalore/O=example Inc/OU=Developer/CN=asset-transfer-basic.org2.example.com/emailAddress=dev@asset-transfer-basic.org2.example.com"
```
- Copy the CA file contents for both `org1.example.com` & `org2.example.com`
```
cp ../../test-network/organizations/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem crypto/rootcert1.pem
cp ../../test-network/organizations/peerOrganizations/org2.example.com/ca/ca.org2.example.com-cert.pem crypto/rootcert2.pem
```
- Generate a client key and cert for auth purpose. You need a key and cert generated from the CA of each organization. Peer nodes act as clients to chaincode server.
- Change the `connection.json` with the below contents. The `root_cert` parameter is the root CA certificate which the chaincode server is run with. You may run the below commands to get the certificate file contents as strings and copy them when needed.
```
awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' crypto/cert1.pem
awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' crypto/cert2.pem
```
Similarly, replace the `client_key` and the `client_cert` contents with the values from the previous step.
```
{
"address": "asset-transfer-basic.org1.example.com:9999",
"dial_timeout": "10s",
"tls_required": true,
"client_auth_required": true,
"client_key": "-----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY-----",
"client_cert": "-----BEGIN CERTIFICATE---- ... -----END CERTIFICATE-----",
"root_cert": "-----BEGIN CERTIFICATE---- ... -----END CERTIFICATE-----"
}
```
- Follow the instructions in [Package](#packaging-and-installing-chaincode) and [Install](#installing-the-external-chaincode) steps for each organization. Remember that the chaincode server's address for the second organization is `asset-transfer-basic.org2.example.com:9999`.
- Copy the appropriate `CHAINCODE_ID` to both [chaincode1.env](./chaincode1.env) and [chaincode2.env](./chaincode2.env) files. Bring up the chaincode containers using the docker-compose command below
```
docker-compose up -f docker-compose-chaincode.yaml up --build -d
```
- Follow the instructions in [Finish Deployment](#finish-deploying-the-asset-transfer-basic-external-chaincode-) for each organization seperately.

View file

@ -0,0 +1,297 @@
/*
SPDX-License-Identifier: Apache-2.0
*/
package main
import (
"encoding/json"
"fmt"
"log"
"os"
"strconv"
"github.com/hyperledger/fabric-chaincode-go/v2/shim"
"github.com/hyperledger/fabric-contract-api-go/v2/contractapi"
)
type serverConfig struct {
CCID string
Address string
}
// SmartContract provides functions for managing an asset
type SmartContract struct {
contractapi.Contract
}
// Asset describes basic details of what makes up a simple asset
type Asset struct {
ID string `json:"ID"`
Color string `json:"color"`
Size int `json:"size"`
Owner string `json:"owner"`
AppraisedValue int `json:"appraisedValue"`
}
// QueryResult structure used for handling result of query
type QueryResult struct {
Key string `json:"Key"`
Record *Asset
}
// InitLedger adds a base set of cars to the ledger
func (s *SmartContract) InitLedger(ctx contractapi.TransactionContextInterface) error {
assets := []Asset{
{ID: "asset1", Color: "blue", Size: 5, Owner: "Tomoko", AppraisedValue: 300},
{ID: "asset2", Color: "red", Size: 5, Owner: "Brad", AppraisedValue: 400},
{ID: "asset3", Color: "green", Size: 10, Owner: "Jin Soo", AppraisedValue: 500},
{ID: "asset4", Color: "yellow", Size: 10, Owner: "Max", AppraisedValue: 600},
{ID: "asset5", Color: "black", Size: 15, Owner: "Adriana", AppraisedValue: 700},
{ID: "asset6", Color: "white", Size: 15, Owner: "Michel", AppraisedValue: 800},
}
for _, asset := range assets {
assetJSON, err := json.Marshal(asset)
if err != nil {
return err
}
err = ctx.GetStub().PutState(asset.ID, assetJSON)
if err != nil {
return fmt.Errorf("failed to put to world state: %v", err)
}
}
return nil
}
// CreateAsset issues a new asset to the world state with given details.
func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface, id, color string, size int, owner string, appraisedValue int) error {
exists, err := s.AssetExists(ctx, id)
if err != nil {
return err
}
if exists {
return fmt.Errorf("the asset %s already exists", id)
}
asset := Asset{
ID: id,
Color: color,
Size: size,
Owner: owner,
AppraisedValue: appraisedValue,
}
assetJSON, err := json.Marshal(asset)
if err != nil {
return err
}
return ctx.GetStub().PutState(id, assetJSON)
}
// ReadAsset returns the asset stored in the world state with given id.
func (s *SmartContract) ReadAsset(ctx contractapi.TransactionContextInterface, id string) (*Asset, error) {
assetJSON, err := ctx.GetStub().GetState(id)
if err != nil {
return nil, fmt.Errorf("failed to read from world state. %s", err.Error())
}
if assetJSON == nil {
return nil, fmt.Errorf("the asset %s does not exist", id)
}
var asset Asset
err = json.Unmarshal(assetJSON, &asset)
if err != nil {
return nil, err
}
return &asset, nil
}
// UpdateAsset updates an existing asset in the world state with provided parameters.
func (s *SmartContract) UpdateAsset(ctx contractapi.TransactionContextInterface, id, color string, size int, owner string, appraisedValue int) error {
exists, err := s.AssetExists(ctx, id)
if err != nil {
return err
}
if !exists {
return fmt.Errorf("the asset %s does not exist", id)
}
// overwriting original asset with new asset
asset := Asset{
ID: id,
Color: color,
Size: size,
Owner: owner,
AppraisedValue: appraisedValue,
}
assetJSON, err := json.Marshal(asset)
if err != nil {
return err
}
return ctx.GetStub().PutState(id, assetJSON)
}
// DeleteAsset deletes a given asset from the world state.
func (s *SmartContract) DeleteAsset(ctx contractapi.TransactionContextInterface, id string) error {
exists, err := s.AssetExists(ctx, id)
if err != nil {
return err
}
if !exists {
return fmt.Errorf("the asset %s does not exist", id)
}
return ctx.GetStub().DelState(id)
}
// AssetExists returns true when asset with given ID exists in world state
func (s *SmartContract) AssetExists(ctx contractapi.TransactionContextInterface, id string) (bool, error) {
assetJSON, err := ctx.GetStub().GetState(id)
if err != nil {
return false, fmt.Errorf("failed to read from world state. %s", err.Error())
}
return assetJSON != nil, nil
}
// TransferAsset updates the owner field of asset with given id in world state, and returns the old owner.
func (s *SmartContract) TransferAsset(ctx contractapi.TransactionContextInterface, id string, newOwner string) (string, error) {
asset, err := s.ReadAsset(ctx, id)
if err != nil {
return "", err
}
oldOwner := asset.Owner
asset.Owner = newOwner
assetJSON, err := json.Marshal(asset)
if err != nil {
return "", err
}
err = ctx.GetStub().PutState(id, assetJSON)
if err != nil {
return "", err
}
return oldOwner, nil
}
// GetAllAssets returns all assets found in world state
func (s *SmartContract) GetAllAssets(ctx contractapi.TransactionContextInterface) ([]QueryResult, error) {
// range query with empty string for startKey and endKey does an open-ended query of all assets in the chaincode namespace.
resultsIterator, err := ctx.GetStub().GetStateByRange("", "")
if err != nil {
return nil, err
}
defer resultsIterator.Close()
var results []QueryResult
for resultsIterator.HasNext() {
queryResponse, err := resultsIterator.Next()
if err != nil {
return nil, err
}
var asset Asset
err = json.Unmarshal(queryResponse.Value, &asset)
if err != nil {
return nil, err
}
queryResult := QueryResult{Key: queryResponse.Key, Record: &asset}
results = append(results, queryResult)
}
return results, nil
}
func main() {
// See chaincode.env.example
config := serverConfig{
CCID: os.Getenv("CHAINCODE_ID"),
Address: os.Getenv("CHAINCODE_SERVER_ADDRESS"),
}
chaincode, err := contractapi.NewChaincode(&SmartContract{})
if err != nil {
log.Panicf("error create asset-transfer-basic chaincode: %s", err)
}
server := &shim.ChaincodeServer{
CCID: config.CCID,
Address: config.Address,
CC: chaincode,
TLSProps: getTLSProperties(),
}
if err := server.Start(); err != nil {
log.Panicf("error starting asset-transfer-basic chaincode: %s", err)
}
}
func getTLSProperties() shim.TLSProperties {
// Check if chaincode is TLS enabled
tlsDisabledStr := getEnvOrDefault("CHAINCODE_TLS_DISABLED", "true")
key := getEnvOrDefault("CHAINCODE_TLS_KEY", "")
cert := getEnvOrDefault("CHAINCODE_TLS_CERT", "")
clientCACert := getEnvOrDefault("CHAINCODE_CLIENT_CA_CERT", "")
// convert tlsDisabledStr to boolean
tlsDisabled := getBoolOrDefault(tlsDisabledStr, false)
var keyBytes, certBytes, clientCACertBytes []byte
var err error
if !tlsDisabled {
keyBytes, err = os.ReadFile(key)
if err != nil {
log.Panicf("error while reading the crypto file: %s", err)
}
certBytes, err = os.ReadFile(cert)
if err != nil {
log.Panicf("error while reading the crypto file: %s", err)
}
}
// Did not request for the peer cert verification
if clientCACert != "" {
clientCACertBytes, err = os.ReadFile(clientCACert)
if err != nil {
log.Panicf("error while reading the crypto file: %s", err)
}
}
return shim.TLSProperties{
Disabled: tlsDisabled,
Key: keyBytes,
Cert: certBytes,
ClientCACerts: clientCACertBytes,
}
}
func getEnvOrDefault(env, defaultVal string) string {
value, ok := os.LookupEnv(env)
if !ok {
value = defaultVal
}
return value
}
// Note that the method returns default value if the string
// cannot be parsed!
func getBoolOrDefault(value string, defaultVal bool) bool {
parsed, err := strconv.ParseBool(value)
if err != nil {
return defaultVal
}
return parsed
}

View file

@ -0,0 +1,24 @@
# CHAINCODE_SERVER_ADDRESS must be set to the host and port where the peer can
# connect to the chaincode server
CHAINCODE_SERVER_ADDRESS=asset-transfer-basic.org1.example.com:9999
# CHAINCODE_ID must be set to the Package ID that is assigned to the chaincode
# on install. The `peer lifecycle chaincode queryinstalled` command can be
# used to get the ID after install if required
CHAINCODE_ID=basic_1.0:0262396ccaffaa2174bc09f750f742319c4f14d60b16334d2c8921b6842c090c
# Optional parameters that will be used for TLS connection between peer node
# and the chaincode.
# TLS is disabled by default, uncomment the following line to enable TLS connection
# CHAINCODE_TLS_DISABLED=false
# Following variables will be ignored if TLS is not enabled.
# They need to be in PEM format
# CHAINCODE_TLS_KEY=/path/to/private/key/file
# CHAINCODE_TLS_CERT=/path/to/public/cert/file
# The following variable will be used by the chaincode server to verify the
# connection from the peer node.
# Note that when this is set a single chaincode server cannot be shared
# across organizations unless their root CA is same.
# CHAINCODE_CLIENT_CA_CERT=/path/to/peer/organization/root/ca/cert/file

View file

@ -0,0 +1,24 @@
# CHAINCODE_SERVER_ADDRESS must be set to the host and port where the peer can
# connect to the chaincode server
CHAINCODE_SERVER_ADDRESS=asset-transfer-basic.org1.example.com:9999
# CHAINCODE_ID must be set to the Package ID that is assigned to the chaincode
# on install. The `peer lifecycle chaincode queryinstalled` command can be
# used to get the ID after install if required
CHAINCODE_ID=basic_1.0:6726c6b6d8ff66fcf5710b72c6ce512d24f118c51c3de510b3d43e51fa592a7d
# Optional parameters that will be used for TLS connection between peer node
# and the chaincode.
# TLS is disabled by default, uncomment the following line to enable TLS connection
CHAINCODE_TLS_DISABLED=false
# Following variables will be ignored if TLS is not enabled.
# They need to be in PEM format
CHAINCODE_TLS_KEY=/crypto/key1.pem
CHAINCODE_TLS_CERT=/crypto/cert1.pem
# The following variable will be used by the chaincode server to verify the
# connection from the peer node.
# Note that when this is set a single chaincode server cannot be shared
# across organizations unless their root CA is same.
CHAINCODE_CLIENT_CA_CERT=/crypto/rootcert1.pem

View file

@ -0,0 +1,24 @@
# CHAINCODE_SERVER_ADDRESS must be set to the host and port where the peer can
# connect to the chaincode server
CHAINCODE_SERVER_ADDRESS=asset-transfer-basic.org2.example.com:9999
# CHAINCODE_ID must be set to the Package ID that is assigned to the chaincode
# on install. The `peer lifecycle chaincode queryinstalled` command can be
# used to get the ID after install if required
CHAINCODE_ID=basic_1.0:e8f9052385e3763ecf5635591155da05d8efbb6905ccbfc1c7229eb6bd28df1b
# Optional parameters that will be used for TLS connection between peer node
# and the chaincode.
# TLS is disabled by default, uncomment the following line to enable TLS connection
CHAINCODE_TLS_DISABLED=false
# Following variables will be ignored if TLS is not enabled.
# They need to be in PEM format
CHAINCODE_TLS_KEY=/crypto/key2.pem
CHAINCODE_TLS_CERT=/crypto/cert2.pem
# The following variable will be used by the chaincode server to verify the
# connection from the peer node.
# Note that when this is set a single chaincode server cannot be shared
# across organizations unless their root CA is same.
CHAINCODE_CLIENT_CA_CERT=/crypto/rootcert2.pem

View file

@ -0,0 +1,5 @@
{
"address": "asset-transfer-basic.org1.example.com:9999",
"dial_timeout": "10s",
"tls_required": false
}

View file

@ -0,0 +1,30 @@
networks:
docker_test:
external: true
services:
asset-transfer-basic.org1.example.com:
build: .
container_name: asset-transfer-basic.org1.example.com
hostname: asset-transfer-basic.org1.example.com
volumes:
- ./crypto:/crypto
env_file:
- chaincode1.env
networks:
docker_test:
expose:
- 9999
asset-transfer-basic.org2.example.com:
build: .
container_name: asset-transfer-basic.org2.example.com
hostname: asset-transfer-basic.org2.example.com
volumes:
- ./crypto:/crypto
env_file:
- chaincode2.env
networks:
docker_test:
expose:
- 9999

View file

@ -0,0 +1,28 @@
module github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-external
go 1.23.0
require (
github.com/hyperledger/fabric-chaincode-go/v2 v2.0.0
github.com/hyperledger/fabric-contract-api-go/v2 v2.2.0
)
require (
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.4 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/text v0.23.0 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/grpc v1.71.0 // indirect
google.golang.org/protobuf v1.36.4 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

View file

@ -0,0 +1,81 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ=
github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4=
github.com/go-openapi/spec v0.21.0 h1:LTVzPc3p/RzRnkQqLRndbAzjY0d0BCL72A6j3CdL9ZY=
github.com/go-openapi/spec v0.21.0/go.mod h1:78u6VdPw81XU44qEWGhtr982gJ5BWg2c0I5XwVMotYk=
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hyperledger/fabric-chaincode-go/v2 v2.0.0 h1:IhkHfrl5X/fVnmB6pWeCYCdIJRi9bxj+WTnVN8DtW3c=
github.com/hyperledger/fabric-chaincode-go/v2 v2.0.0/go.mod h1:PHHaFffjw7p7n9bmCfcm7RqDqYdivNEsJdiNIKZo5Lk=
github.com/hyperledger/fabric-contract-api-go/v2 v2.2.0 h1:rmUoBmciB0GL/miqcbJmJbgp5QTWoJUrZo+CNxrNLF4=
github.com/hyperledger/fabric-contract-api-go/v2 v2.2.0/go.mod h1:FeWeO/jwGjiME7ak3GufqKIcwkejtzrDG4QxbfKydWs=
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.4 h1:YJrd+gMaeY0/vsN0aS0QkEKTivGoUnSRIXxGJ7KI+Pc=
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.4/go.mod h1:bau/6AJhvEcu9GKKYHlDXAxXKzYNfhP6xu2GXuxEcFk=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=
go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=
go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A=
go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU=
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w=
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=
google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View file

@ -0,0 +1,4 @@
{
"type": "external",
"label": "basic_1.0"
}

View file

@ -0,0 +1,21 @@
#!/bin/bash
set -euo pipefail
SOURCE=$1
OUTPUT=$3
#external chaincodes expect connection.json file in the chaincode package
if [ ! -f "$SOURCE/connection.json" ]; then
>&2 echo "$SOURCE/connection.json not found"
exit 1
fi
#simply copy the endpoint information to specified output location
cp $SOURCE/connection.json $OUTPUT/connection.json
if [ -d "$SOURCE/metadata" ]; then
cp -a $SOURCE/metadata $OUTPUT/metadata
fi
exit 0

View file

@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail
METADIR=$2
# check if the "type" field is set to "external"
# crude way without jq which is not in the default fabric peer image
TYPE=$(tr -d '\n' < "$METADIR/metadata.json" | awk -F':' '{ for (i = 1; i < NF; i++){ if ($i~/type/) { print $(i+1); break }}}'| cut -d\" -f2)
if [ "$TYPE" = "external" ]; then
exit 0
fi
exit 1

View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail
BLD="$1"
RELEASE="$2"
if [ -d "$BLD/metadata" ]; then
cp -a "$BLD/metadata/"* "$RELEASE/"
fi
#external chaincodes expect artifacts to be placed under "$RELEASE"/chaincode/server
if [ -f $BLD/connection.json ]; then
mkdir -p "$RELEASE"/chaincode/server
cp $BLD/connection.json "$RELEASE"/chaincode/server
#if tls_required is true, copy TLS files (using above example, the fully qualified path for these fils would be "$RELEASE"/chaincode/server/tls)
exit 0
fi
exit 1

View file

@ -0,0 +1,23 @@
/*
SPDX-License-Identifier: Apache-2.0
*/
package main
import (
"log"
"github.com/hyperledger/fabric-contract-api-go/v2/contractapi"
"github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go/chaincode"
)
func main() {
assetChaincode, err := contractapi.NewChaincode(&chaincode.SmartContract{})
if err != nil {
log.Panicf("Error creating asset-transfer-basic chaincode: %v", err)
}
if err := assetChaincode.Start(); err != nil {
log.Panicf("Error starting asset-transfer-basic chaincode: %v", err)
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,235 @@
// Code generated by counterfeiter. DO NOT EDIT.
package mocks
import (
"sync"
"github.com/hyperledger/fabric-protos-go-apiv2/ledger/queryresult"
)
type StateQueryIterator struct {
CloseStub func() error
closeMutex sync.RWMutex
closeArgsForCall []struct {
}
closeReturns struct {
result1 error
}
closeReturnsOnCall map[int]struct {
result1 error
}
HasNextStub func() bool
hasNextMutex sync.RWMutex
hasNextArgsForCall []struct {
}
hasNextReturns struct {
result1 bool
}
hasNextReturnsOnCall map[int]struct {
result1 bool
}
NextStub func() (*queryresult.KV, error)
nextMutex sync.RWMutex
nextArgsForCall []struct {
}
nextReturns struct {
result1 *queryresult.KV
result2 error
}
nextReturnsOnCall map[int]struct {
result1 *queryresult.KV
result2 error
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *StateQueryIterator) Close() error {
fake.closeMutex.Lock()
ret, specificReturn := fake.closeReturnsOnCall[len(fake.closeArgsForCall)]
fake.closeArgsForCall = append(fake.closeArgsForCall, struct {
}{})
stub := fake.CloseStub
fakeReturns := fake.closeReturns
fake.recordInvocation("Close", []interface{}{})
fake.closeMutex.Unlock()
if stub != nil {
return stub()
}
if specificReturn {
return ret.result1
}
return fakeReturns.result1
}
func (fake *StateQueryIterator) CloseCallCount() int {
fake.closeMutex.RLock()
defer fake.closeMutex.RUnlock()
return len(fake.closeArgsForCall)
}
func (fake *StateQueryIterator) CloseCalls(stub func() error) {
fake.closeMutex.Lock()
defer fake.closeMutex.Unlock()
fake.CloseStub = stub
}
func (fake *StateQueryIterator) CloseReturns(result1 error) {
fake.closeMutex.Lock()
defer fake.closeMutex.Unlock()
fake.CloseStub = nil
fake.closeReturns = struct {
result1 error
}{result1}
}
func (fake *StateQueryIterator) CloseReturnsOnCall(i int, result1 error) {
fake.closeMutex.Lock()
defer fake.closeMutex.Unlock()
fake.CloseStub = nil
if fake.closeReturnsOnCall == nil {
fake.closeReturnsOnCall = make(map[int]struct {
result1 error
})
}
fake.closeReturnsOnCall[i] = struct {
result1 error
}{result1}
}
func (fake *StateQueryIterator) HasNext() bool {
fake.hasNextMutex.Lock()
ret, specificReturn := fake.hasNextReturnsOnCall[len(fake.hasNextArgsForCall)]
fake.hasNextArgsForCall = append(fake.hasNextArgsForCall, struct {
}{})
stub := fake.HasNextStub
fakeReturns := fake.hasNextReturns
fake.recordInvocation("HasNext", []interface{}{})
fake.hasNextMutex.Unlock()
if stub != nil {
return stub()
}
if specificReturn {
return ret.result1
}
return fakeReturns.result1
}
func (fake *StateQueryIterator) HasNextCallCount() int {
fake.hasNextMutex.RLock()
defer fake.hasNextMutex.RUnlock()
return len(fake.hasNextArgsForCall)
}
func (fake *StateQueryIterator) HasNextCalls(stub func() bool) {
fake.hasNextMutex.Lock()
defer fake.hasNextMutex.Unlock()
fake.HasNextStub = stub
}
func (fake *StateQueryIterator) HasNextReturns(result1 bool) {
fake.hasNextMutex.Lock()
defer fake.hasNextMutex.Unlock()
fake.HasNextStub = nil
fake.hasNextReturns = struct {
result1 bool
}{result1}
}
func (fake *StateQueryIterator) HasNextReturnsOnCall(i int, result1 bool) {
fake.hasNextMutex.Lock()
defer fake.hasNextMutex.Unlock()
fake.HasNextStub = nil
if fake.hasNextReturnsOnCall == nil {
fake.hasNextReturnsOnCall = make(map[int]struct {
result1 bool
})
}
fake.hasNextReturnsOnCall[i] = struct {
result1 bool
}{result1}
}
func (fake *StateQueryIterator) Next() (*queryresult.KV, error) {
fake.nextMutex.Lock()
ret, specificReturn := fake.nextReturnsOnCall[len(fake.nextArgsForCall)]
fake.nextArgsForCall = append(fake.nextArgsForCall, struct {
}{})
stub := fake.NextStub
fakeReturns := fake.nextReturns
fake.recordInvocation("Next", []interface{}{})
fake.nextMutex.Unlock()
if stub != nil {
return stub()
}
if specificReturn {
return ret.result1, ret.result2
}
return fakeReturns.result1, fakeReturns.result2
}
func (fake *StateQueryIterator) NextCallCount() int {
fake.nextMutex.RLock()
defer fake.nextMutex.RUnlock()
return len(fake.nextArgsForCall)
}
func (fake *StateQueryIterator) NextCalls(stub func() (*queryresult.KV, error)) {
fake.nextMutex.Lock()
defer fake.nextMutex.Unlock()
fake.NextStub = stub
}
func (fake *StateQueryIterator) NextReturns(result1 *queryresult.KV, result2 error) {
fake.nextMutex.Lock()
defer fake.nextMutex.Unlock()
fake.NextStub = nil
fake.nextReturns = struct {
result1 *queryresult.KV
result2 error
}{result1, result2}
}
func (fake *StateQueryIterator) NextReturnsOnCall(i int, result1 *queryresult.KV, result2 error) {
fake.nextMutex.Lock()
defer fake.nextMutex.Unlock()
fake.NextStub = nil
if fake.nextReturnsOnCall == nil {
fake.nextReturnsOnCall = make(map[int]struct {
result1 *queryresult.KV
result2 error
})
}
fake.nextReturnsOnCall[i] = struct {
result1 *queryresult.KV
result2 error
}{result1, result2}
}
func (fake *StateQueryIterator) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
fake.closeMutex.RLock()
defer fake.closeMutex.RUnlock()
fake.hasNextMutex.RLock()
defer fake.hasNextMutex.RUnlock()
fake.nextMutex.RLock()
defer fake.nextMutex.RUnlock()
copiedInvocations := map[string][][]interface{}{}
for key, value := range fake.invocations {
copiedInvocations[key] = value
}
return copiedInvocations
}
func (fake *StateQueryIterator) recordInvocation(key string, args []interface{}) {
fake.invocationsMutex.Lock()
defer fake.invocationsMutex.Unlock()
if fake.invocations == nil {
fake.invocations = map[string][][]interface{}{}
}
if fake.invocations[key] == nil {
fake.invocations[key] = [][]interface{}{}
}
fake.invocations[key] = append(fake.invocations[key], args)
}

View file

@ -0,0 +1,166 @@
// Code generated by counterfeiter. DO NOT EDIT.
package mocks
import (
"sync"
"github.com/hyperledger/fabric-chaincode-go/v2/pkg/cid"
"github.com/hyperledger/fabric-chaincode-go/v2/shim"
)
type TransactionContext struct {
GetClientIdentityStub func() cid.ClientIdentity
getClientIdentityMutex sync.RWMutex
getClientIdentityArgsForCall []struct {
}
getClientIdentityReturns struct {
result1 cid.ClientIdentity
}
getClientIdentityReturnsOnCall map[int]struct {
result1 cid.ClientIdentity
}
GetStubStub func() shim.ChaincodeStubInterface
getStubMutex sync.RWMutex
getStubArgsForCall []struct {
}
getStubReturns struct {
result1 shim.ChaincodeStubInterface
}
getStubReturnsOnCall map[int]struct {
result1 shim.ChaincodeStubInterface
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *TransactionContext) GetClientIdentity() cid.ClientIdentity {
fake.getClientIdentityMutex.Lock()
ret, specificReturn := fake.getClientIdentityReturnsOnCall[len(fake.getClientIdentityArgsForCall)]
fake.getClientIdentityArgsForCall = append(fake.getClientIdentityArgsForCall, struct {
}{})
stub := fake.GetClientIdentityStub
fakeReturns := fake.getClientIdentityReturns
fake.recordInvocation("GetClientIdentity", []interface{}{})
fake.getClientIdentityMutex.Unlock()
if stub != nil {
return stub()
}
if specificReturn {
return ret.result1
}
return fakeReturns.result1
}
func (fake *TransactionContext) GetClientIdentityCallCount() int {
fake.getClientIdentityMutex.RLock()
defer fake.getClientIdentityMutex.RUnlock()
return len(fake.getClientIdentityArgsForCall)
}
func (fake *TransactionContext) GetClientIdentityCalls(stub func() cid.ClientIdentity) {
fake.getClientIdentityMutex.Lock()
defer fake.getClientIdentityMutex.Unlock()
fake.GetClientIdentityStub = stub
}
func (fake *TransactionContext) GetClientIdentityReturns(result1 cid.ClientIdentity) {
fake.getClientIdentityMutex.Lock()
defer fake.getClientIdentityMutex.Unlock()
fake.GetClientIdentityStub = nil
fake.getClientIdentityReturns = struct {
result1 cid.ClientIdentity
}{result1}
}
func (fake *TransactionContext) GetClientIdentityReturnsOnCall(i int, result1 cid.ClientIdentity) {
fake.getClientIdentityMutex.Lock()
defer fake.getClientIdentityMutex.Unlock()
fake.GetClientIdentityStub = nil
if fake.getClientIdentityReturnsOnCall == nil {
fake.getClientIdentityReturnsOnCall = make(map[int]struct {
result1 cid.ClientIdentity
})
}
fake.getClientIdentityReturnsOnCall[i] = struct {
result1 cid.ClientIdentity
}{result1}
}
func (fake *TransactionContext) GetStub() shim.ChaincodeStubInterface {
fake.getStubMutex.Lock()
ret, specificReturn := fake.getStubReturnsOnCall[len(fake.getStubArgsForCall)]
fake.getStubArgsForCall = append(fake.getStubArgsForCall, struct {
}{})
stub := fake.GetStubStub
fakeReturns := fake.getStubReturns
fake.recordInvocation("GetStub", []interface{}{})
fake.getStubMutex.Unlock()
if stub != nil {
return stub()
}
if specificReturn {
return ret.result1
}
return fakeReturns.result1
}
func (fake *TransactionContext) GetStubCallCount() int {
fake.getStubMutex.RLock()
defer fake.getStubMutex.RUnlock()
return len(fake.getStubArgsForCall)
}
func (fake *TransactionContext) GetStubCalls(stub func() shim.ChaincodeStubInterface) {
fake.getStubMutex.Lock()
defer fake.getStubMutex.Unlock()
fake.GetStubStub = stub
}
func (fake *TransactionContext) GetStubReturns(result1 shim.ChaincodeStubInterface) {
fake.getStubMutex.Lock()
defer fake.getStubMutex.Unlock()
fake.GetStubStub = nil
fake.getStubReturns = struct {
result1 shim.ChaincodeStubInterface
}{result1}
}
func (fake *TransactionContext) GetStubReturnsOnCall(i int, result1 shim.ChaincodeStubInterface) {
fake.getStubMutex.Lock()
defer fake.getStubMutex.Unlock()
fake.GetStubStub = nil
if fake.getStubReturnsOnCall == nil {
fake.getStubReturnsOnCall = make(map[int]struct {
result1 shim.ChaincodeStubInterface
})
}
fake.getStubReturnsOnCall[i] = struct {
result1 shim.ChaincodeStubInterface
}{result1}
}
func (fake *TransactionContext) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
fake.getClientIdentityMutex.RLock()
defer fake.getClientIdentityMutex.RUnlock()
fake.getStubMutex.RLock()
defer fake.getStubMutex.RUnlock()
copiedInvocations := map[string][][]interface{}{}
for key, value := range fake.invocations {
copiedInvocations[key] = value
}
return copiedInvocations
}
func (fake *TransactionContext) recordInvocation(key string, args []interface{}) {
fake.invocationsMutex.Lock()
defer fake.invocationsMutex.Unlock()
if fake.invocations == nil {
fake.invocations = map[string][][]interface{}{}
}
if fake.invocations[key] == nil {
fake.invocations[key] = [][]interface{}{}
}
fake.invocations[key] = append(fake.invocations[key], args)
}

View file

@ -0,0 +1,194 @@
package chaincode
import (
"encoding/json"
"fmt"
"github.com/hyperledger/fabric-contract-api-go/v2/contractapi"
)
// SmartContract provides functions for managing an Asset
type SmartContract struct {
contractapi.Contract
}
// Asset describes basic details of what makes up a simple asset
// Insert struct field in alphabetic order => to achieve determinism across languages
// golang keeps the order when marshal to json but doesn't order automatically
type Asset struct {
AppraisedValue int `json:"AppraisedValue"`
Color string `json:"Color"`
ID string `json:"ID"`
Owner string `json:"Owner"`
Size int `json:"Size"`
}
// InitLedger adds a base set of assets to the ledger
func (s *SmartContract) InitLedger(ctx contractapi.TransactionContextInterface) error {
assets := []Asset{
{ID: "asset1", Color: "blue", Size: 5, Owner: "Tomoko", AppraisedValue: 300},
{ID: "asset2", Color: "red", Size: 5, Owner: "Brad", AppraisedValue: 400},
{ID: "asset3", Color: "green", Size: 10, Owner: "Jin Soo", AppraisedValue: 500},
{ID: "asset4", Color: "yellow", Size: 10, Owner: "Max", AppraisedValue: 600},
{ID: "asset5", Color: "black", Size: 15, Owner: "Adriana", AppraisedValue: 700},
{ID: "asset6", Color: "white", Size: 15, Owner: "Michel", AppraisedValue: 800},
}
for _, asset := range assets {
assetJSON, err := json.Marshal(asset)
if err != nil {
return err
}
err = ctx.GetStub().PutState(asset.ID, assetJSON)
if err != nil {
return fmt.Errorf("failed to put to world state. %v", err)
}
}
return nil
}
// CreateAsset issues a new asset to the world state with given details.
func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface, id string, color string, size int, owner string, appraisedValue int) error {
exists, err := s.AssetExists(ctx, id)
if err != nil {
return err
}
if exists {
return fmt.Errorf("the asset %s already exists", id)
}
asset := Asset{
ID: id,
Color: color,
Size: size,
Owner: owner,
AppraisedValue: appraisedValue,
}
assetJSON, err := json.Marshal(asset)
if err != nil {
return err
}
return ctx.GetStub().PutState(id, assetJSON)
}
// ReadAsset returns the asset stored in the world state with given id.
func (s *SmartContract) ReadAsset(ctx contractapi.TransactionContextInterface, id string) (*Asset, error) {
assetJSON, err := ctx.GetStub().GetState(id)
if err != nil {
return nil, fmt.Errorf("failed to read from world state: %v", err)
}
if assetJSON == nil {
return nil, fmt.Errorf("the asset %s does not exist", id)
}
var asset Asset
err = json.Unmarshal(assetJSON, &asset)
if err != nil {
return nil, err
}
return &asset, nil
}
// UpdateAsset updates an existing asset in the world state with provided parameters.
func (s *SmartContract) UpdateAsset(ctx contractapi.TransactionContextInterface, id string, color string, size int, owner string, appraisedValue int) error {
exists, err := s.AssetExists(ctx, id)
if err != nil {
return err
}
if !exists {
return fmt.Errorf("the asset %s does not exist", id)
}
// overwriting original asset with new asset
asset := Asset{
ID: id,
Color: color,
Size: size,
Owner: owner,
AppraisedValue: appraisedValue,
}
assetJSON, err := json.Marshal(asset)
if err != nil {
return err
}
return ctx.GetStub().PutState(id, assetJSON)
}
// DeleteAsset deletes an given asset from the world state.
func (s *SmartContract) DeleteAsset(ctx contractapi.TransactionContextInterface, id string) error {
exists, err := s.AssetExists(ctx, id)
if err != nil {
return err
}
if !exists {
return fmt.Errorf("the asset %s does not exist", id)
}
return ctx.GetStub().DelState(id)
}
// AssetExists returns true when asset with given ID exists in world state
func (s *SmartContract) AssetExists(ctx contractapi.TransactionContextInterface, id string) (bool, error) {
assetJSON, err := ctx.GetStub().GetState(id)
if err != nil {
return false, fmt.Errorf("failed to read from world state: %v", err)
}
return assetJSON != nil, nil
}
// TransferAsset updates the owner field of asset with given id in world state, and returns the old owner.
func (s *SmartContract) TransferAsset(ctx contractapi.TransactionContextInterface, id string, newOwner string) (string, error) {
asset, err := s.ReadAsset(ctx, id)
if err != nil {
return "", err
}
oldOwner := asset.Owner
asset.Owner = newOwner
assetJSON, err := json.Marshal(asset)
if err != nil {
return "", err
}
err = ctx.GetStub().PutState(id, assetJSON)
if err != nil {
return "", err
}
return oldOwner, nil
}
// GetAllAssets returns all assets found in world state
func (s *SmartContract) GetAllAssets(ctx contractapi.TransactionContextInterface) ([]*Asset, error) {
// range query with empty string for startKey and endKey does an
// open-ended query of all assets in the chaincode namespace.
resultsIterator, err := ctx.GetStub().GetStateByRange("", "")
if err != nil {
return nil, err
}
defer resultsIterator.Close()
var assets []*Asset
for resultsIterator.HasNext() {
queryResponse, err := resultsIterator.Next()
if err != nil {
return nil, err
}
var asset Asset
err = json.Unmarshal(queryResponse.Value, &asset)
if err != nil {
return nil, err
}
assets = append(assets, &asset)
}
return assets, nil
}

View file

@ -0,0 +1,184 @@
package chaincode_test
import (
"encoding/json"
"fmt"
"testing"
"github.com/hyperledger/fabric-chaincode-go/v2/shim"
"github.com/hyperledger/fabric-contract-api-go/v2/contractapi"
"github.com/hyperledger/fabric-protos-go-apiv2/ledger/queryresult"
"github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go/chaincode"
"github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go/chaincode/mocks"
"github.com/stretchr/testify/require"
)
//go:generate counterfeiter -o mocks/transaction.go -fake-name TransactionContext . transactionContext
type transactionContext interface {
contractapi.TransactionContextInterface
}
//go:generate counterfeiter -o mocks/chaincodestub.go -fake-name ChaincodeStub . chaincodeStub
type chaincodeStub interface {
shim.ChaincodeStubInterface
}
//go:generate counterfeiter -o mocks/statequeryiterator.go -fake-name StateQueryIterator . stateQueryIterator
type stateQueryIterator interface {
shim.StateQueryIteratorInterface
}
func TestInitLedger(t *testing.T) {
chaincodeStub := &mocks.ChaincodeStub{}
transactionContext := &mocks.TransactionContext{}
transactionContext.GetStubReturns(chaincodeStub)
assetTransfer := chaincode.SmartContract{}
err := assetTransfer.InitLedger(transactionContext)
require.NoError(t, err)
chaincodeStub.PutStateReturns(fmt.Errorf("failed inserting key"))
err = assetTransfer.InitLedger(transactionContext)
require.EqualError(t, err, "failed to put to world state. failed inserting key")
}
func TestCreateAsset(t *testing.T) {
chaincodeStub := &mocks.ChaincodeStub{}
transactionContext := &mocks.TransactionContext{}
transactionContext.GetStubReturns(chaincodeStub)
assetTransfer := chaincode.SmartContract{}
err := assetTransfer.CreateAsset(transactionContext, "", "", 0, "", 0)
require.NoError(t, err)
chaincodeStub.GetStateReturns([]byte{}, nil)
err = assetTransfer.CreateAsset(transactionContext, "asset1", "", 0, "", 0)
require.EqualError(t, err, "the asset asset1 already exists")
chaincodeStub.GetStateReturns(nil, fmt.Errorf("unable to retrieve asset"))
err = assetTransfer.CreateAsset(transactionContext, "asset1", "", 0, "", 0)
require.EqualError(t, err, "failed to read from world state: unable to retrieve asset")
}
func TestReadAsset(t *testing.T) {
chaincodeStub := &mocks.ChaincodeStub{}
transactionContext := &mocks.TransactionContext{}
transactionContext.GetStubReturns(chaincodeStub)
expectedAsset := &chaincode.Asset{ID: "asset1"}
bytes, err := json.Marshal(expectedAsset)
require.NoError(t, err)
chaincodeStub.GetStateReturns(bytes, nil)
assetTransfer := chaincode.SmartContract{}
asset, err := assetTransfer.ReadAsset(transactionContext, "")
require.NoError(t, err)
require.Equal(t, expectedAsset, asset)
chaincodeStub.GetStateReturns(nil, fmt.Errorf("unable to retrieve asset"))
_, err = assetTransfer.ReadAsset(transactionContext, "")
require.EqualError(t, err, "failed to read from world state: unable to retrieve asset")
chaincodeStub.GetStateReturns(nil, nil)
asset, err = assetTransfer.ReadAsset(transactionContext, "asset1")
require.EqualError(t, err, "the asset asset1 does not exist")
require.Nil(t, asset)
}
func TestUpdateAsset(t *testing.T) {
chaincodeStub := &mocks.ChaincodeStub{}
transactionContext := &mocks.TransactionContext{}
transactionContext.GetStubReturns(chaincodeStub)
expectedAsset := &chaincode.Asset{ID: "asset1"}
bytes, err := json.Marshal(expectedAsset)
require.NoError(t, err)
chaincodeStub.GetStateReturns(bytes, nil)
assetTransfer := chaincode.SmartContract{}
err = assetTransfer.UpdateAsset(transactionContext, "", "", 0, "", 0)
require.NoError(t, err)
chaincodeStub.GetStateReturns(nil, nil)
err = assetTransfer.UpdateAsset(transactionContext, "asset1", "", 0, "", 0)
require.EqualError(t, err, "the asset asset1 does not exist")
chaincodeStub.GetStateReturns(nil, fmt.Errorf("unable to retrieve asset"))
err = assetTransfer.UpdateAsset(transactionContext, "asset1", "", 0, "", 0)
require.EqualError(t, err, "failed to read from world state: unable to retrieve asset")
}
func TestDeleteAsset(t *testing.T) {
chaincodeStub := &mocks.ChaincodeStub{}
transactionContext := &mocks.TransactionContext{}
transactionContext.GetStubReturns(chaincodeStub)
asset := &chaincode.Asset{ID: "asset1"}
bytes, err := json.Marshal(asset)
require.NoError(t, err)
chaincodeStub.GetStateReturns(bytes, nil)
chaincodeStub.DelStateReturns(nil)
assetTransfer := chaincode.SmartContract{}
err = assetTransfer.DeleteAsset(transactionContext, "")
require.NoError(t, err)
chaincodeStub.GetStateReturns(nil, nil)
err = assetTransfer.DeleteAsset(transactionContext, "asset1")
require.EqualError(t, err, "the asset asset1 does not exist")
chaincodeStub.GetStateReturns(nil, fmt.Errorf("unable to retrieve asset"))
err = assetTransfer.DeleteAsset(transactionContext, "")
require.EqualError(t, err, "failed to read from world state: unable to retrieve asset")
}
func TestTransferAsset(t *testing.T) {
chaincodeStub := &mocks.ChaincodeStub{}
transactionContext := &mocks.TransactionContext{}
transactionContext.GetStubReturns(chaincodeStub)
asset := &chaincode.Asset{ID: "asset1"}
bytes, err := json.Marshal(asset)
require.NoError(t, err)
chaincodeStub.GetStateReturns(bytes, nil)
assetTransfer := chaincode.SmartContract{}
_, err = assetTransfer.TransferAsset(transactionContext, "", "")
require.NoError(t, err)
chaincodeStub.GetStateReturns(nil, fmt.Errorf("unable to retrieve asset"))
_, err = assetTransfer.TransferAsset(transactionContext, "", "")
require.EqualError(t, err, "failed to read from world state: unable to retrieve asset")
}
func TestGetAllAssets(t *testing.T) {
asset := &chaincode.Asset{ID: "asset1"}
bytes, err := json.Marshal(asset)
require.NoError(t, err)
iterator := &mocks.StateQueryIterator{}
iterator.HasNextReturnsOnCall(0, true)
iterator.HasNextReturnsOnCall(1, false)
iterator.NextReturns(&queryresult.KV{Value: bytes}, nil)
chaincodeStub := &mocks.ChaincodeStub{}
transactionContext := &mocks.TransactionContext{}
transactionContext.GetStubReturns(chaincodeStub)
chaincodeStub.GetStateByRangeReturns(iterator, nil)
assetTransfer := &chaincode.SmartContract{}
assets, err := assetTransfer.GetAllAssets(transactionContext)
require.NoError(t, err)
require.Equal(t, []*chaincode.Asset{asset}, assets)
iterator.HasNextReturns(true)
iterator.NextReturns(nil, fmt.Errorf("failed retrieving next item"))
assets, err = assetTransfer.GetAllAssets(transactionContext)
require.EqualError(t, err, "failed retrieving next item")
require.Nil(t, assets)
chaincodeStub.GetStateByRangeReturns(nil, fmt.Errorf("failed retrieving all assets"))
assets, err = assetTransfer.GetAllAssets(transactionContext)
require.EqualError(t, err, "failed retrieving all assets")
require.Nil(t, assets)
}

View file

@ -0,0 +1,31 @@
module github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go
go 1.23.0
require (
github.com/hyperledger/fabric-chaincode-go/v2 v2.0.0
github.com/hyperledger/fabric-contract-api-go/v2 v2.2.0
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.4
github.com/stretchr/testify v1.10.0
google.golang.org/protobuf v1.36.4
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/text v0.23.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.71.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

View file

@ -0,0 +1,81 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ=
github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4=
github.com/go-openapi/spec v0.21.0 h1:LTVzPc3p/RzRnkQqLRndbAzjY0d0BCL72A6j3CdL9ZY=
github.com/go-openapi/spec v0.21.0/go.mod h1:78u6VdPw81XU44qEWGhtr982gJ5BWg2c0I5XwVMotYk=
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hyperledger/fabric-chaincode-go/v2 v2.0.0 h1:IhkHfrl5X/fVnmB6pWeCYCdIJRi9bxj+WTnVN8DtW3c=
github.com/hyperledger/fabric-chaincode-go/v2 v2.0.0/go.mod h1:PHHaFffjw7p7n9bmCfcm7RqDqYdivNEsJdiNIKZo5Lk=
github.com/hyperledger/fabric-contract-api-go/v2 v2.2.0 h1:rmUoBmciB0GL/miqcbJmJbgp5QTWoJUrZo+CNxrNLF4=
github.com/hyperledger/fabric-contract-api-go/v2 v2.2.0/go.mod h1:FeWeO/jwGjiME7ak3GufqKIcwkejtzrDG4QxbfKydWs=
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.4 h1:YJrd+gMaeY0/vsN0aS0QkEKTivGoUnSRIXxGJ7KI+Pc=
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.4/go.mod h1:bau/6AJhvEcu9GKKYHlDXAxXKzYNfhP6xu2GXuxEcFk=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=
go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=
go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A=
go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU=
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A=
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU=
google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=
google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View file

@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

View file

@ -0,0 +1,2 @@
.idea/
.gradle/

View file

@ -0,0 +1,31 @@
# the first stage
FROM gradle:9-jdk25 AS gradle_build
# copy the build.gradle and src code to the container
COPY src/ src/
COPY build.gradle ./
# Build and package our code
RUN gradle --no-daemon build shadowJar -x checkstyleMain -x checkstyleTest
# the second stage of our build just needs the compiled files
FROM eclipse-temurin:25-jre
ARG CC_SERVER_PORT=9999
# Setup tini to work better handle signals
ENV TINI_VERSION=v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
RUN addgroup --system javauser && useradd -g javauser javauser
# copy only the artifacts we need from the first stage and discard the rest
COPY --chown=javauser:javauser --from=gradle_build /home/gradle/build/libs/chaincode.jar /chaincode.jar
COPY --chown=javauser:javauser docker/docker-entrypoint.sh /docker-entrypoint.sh
ENV PORT=$CC_SERVER_PORT
EXPOSE $CC_SERVER_PORT
USER javauser
ENTRYPOINT [ "/tini", "--", "/docker-entrypoint.sh" ]

View file

@ -0,0 +1,10 @@
## Basic Asset Transfer
This sample implements the basic asset transfer scenario, illustrating the use of the Java Contract SDKs to provide a
smart contract as a service.
To run this chaincode contract locally on a development network, see:
- [Debugging chaincode as a service](../../test-network-k8s/docs/CHAINCODE_AS_A_SERVICE.md) (Kube test network)
- [End-to-end with the test-network](../../test-network/CHAINCODE_AS_A_SERVICE_TUTORIAL.md#end-to-end-with-the-the-test-network) (Docker compose)

View file

@ -0,0 +1,91 @@
/*
* SPDX-License-Identifier: Apache-2.0
*/
plugins {
id 'com.gradleup.shadow' version '9.2.2'
id 'application'
id 'checkstyle'
id 'jacoco'
}
group 'org.hyperledger.fabric.samples'
version '1.0-SNAPSHOT'
dependencies {
implementation 'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.+'
implementation 'org.json:json:+'
implementation 'com.owlike:genson:1.6'
testImplementation platform('org.junit:junit-bom:5.14.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.assertj:assertj-core:3.27.6'
testImplementation 'org.mockito:mockito-core:5.20.0'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
repositories {
mavenCentral()
maven {
url 'https://jitpack.io'
}
}
compileJava {
options.release = 11
}
application {
mainClass = 'org.hyperledger.fabric.contract.ContractRouter'
}
checkstyle {
toolVersion '8.21'
configFile file("config/checkstyle/checkstyle.xml")
}
checkstyleMain {
source ='src/main/java'
}
checkstyleTest {
source ='src/test/java'
}
jacocoTestReport {
dependsOn test
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.9
}
}
}
finalizedBy jacocoTestReport
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
shadowJar {
archiveBaseName = 'chaincode'
archiveVersion = ''
archiveClassifier = ''
duplicatesStrategy = DuplicatesStrategy.INCLUDE
mergeServiceFiles()
manifest {
attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter'
}
}
check.dependsOn jacocoTestCoverageVerification
installDist.dependsOn check

View file

@ -0,0 +1,171 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that matches the Eclipse formatter
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sourceforge.net (or in your downloaded distribution).
Most Checks are configurable, be sure to consult the documentation.
To completely disable a check, just comment it out or delete it from the file.
Finally, it is worth reading the documentation.
-->
<module name="Checker">
<!--
If you set the basedir property below, then all reported file
names will be relative to the specified directory. See
https://checkstyle.org/5.x/config.html#Checker
<property name="basedir" value="${basedir}"/>
-->
<property name="fileExtensions" value="java, properties, xml"/>
<module name="SuppressionFilter">
<property name="file" value="${config_loc}/suppressions.xml"/>
<property name="optional" value="false"/>
</module>
<!-- Excludes all 'module-info.java' files -->
<!-- See https://checkstyle.org/config_filefilters.html -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
<!-- Checks that a package-info.java file exists for each package. -->
<!-- See http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage -->
<!-- <module name="JavadocPackage"/> -->
<!-- Checks whether files end with a new line. -->
<!-- See http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"/>
<!-- Checks that property files contain the same keys. -->
<!-- See http://checkstyle.sourceforge.net/config_misc.html#Translation -->
<module name="Translation"/>
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sourceforge.net/config_sizes.html -->
<module name="FileLength"/>
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sourceforge.net/config_whitespace.html -->
<module name="FileTabCharacter"/>
<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sourceforge.net/config_misc.html -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="minimum" value="0"/>
<property name="maximum" value="0"/>
<property name="message" value="Line has trailing spaces."/>
</module>
<!-- Checks for Headers -->
<!-- See http://checkstyle.sourceforge.net/config_header.html -->
<!-- <module name="Header"> -->
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
<!-- <property name="fileExtensions" value="java"/> -->
<!-- </module> -->
<module name="TreeWalker">
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sourceforge.net/config_javadoc.html -->
<!-- <module name="JavadocMethod"/> -->
<!-- <module name="JavadocType"/> -->
<!-- <module name="JavadocVariable"/> -->
<!-- <module name="JavadocStyle"/> -->
<!-- <module name="MissingJavadocMethod"/> -->
<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sourceforge.net/config_naming.html -->
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="PackageName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<!-- Checks for imports -->
<!-- See http://checkstyle.sourceforge.net/config_import.html -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="false"/>
</module>
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sourceforge.net/config_sizes.html -->
<module name="MethodLength"/>
<module name="ParameterNumber"/>
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sourceforge.net/config_whitespace.html -->
<module name="EmptyForIteratorPad"/>
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<!-- Modifier Checks -->
<!-- See http://checkstyle.sourceforge.net/config_modifiers.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sourceforge.net/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>
<!-- Checks for common coding problems -->
<!-- See http://checkstyle.sourceforge.net/config_coding.html -->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField">
<property name="ignoreConstructorParameter" value="true"/>
</module>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MissingSwitchDefault"/>
<module name="MultipleVariableDeclarations"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<!-- Checks for class design -->
<!-- See http://checkstyle.sourceforge.net/config_design.html -->
<module name="DesignForExtension"/>
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier">
<property name="allowPublicFinalFields" value="true"/>
</module>
<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sourceforge.net/config_misc.html -->
<module name="ArrayTypeStyle"/>
<module name="FinalParameters"/>
<module name="TodoComment"/>
<module name="UpperEll"/>
</module>
</module>

View file

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress files="ChaincodeTest.java" checks="ParameterNumber" />
</suppressions>

View file

@ -0,0 +1,16 @@
#!/usr/bin/env bash
#
# SPDX-License-Identifier: Apache-2.0
#
set -euo pipefail
: ${CORE_PEER_TLS_ENABLED:="false"}
: ${DEBUG:="false"}
if [ "${DEBUG,,}" = "true" ]; then
exec java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:8000 -jar /chaincode.jar
elif [ "${CORE_PEER_TLS_ENABLED,,}" = "true" ]; then
exec java -jar /chaincode.jar # todo
else
exec java -jar /chaincode.jar
fi

View file

@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

248
asset-transfer-basic/chaincode-java/gradlew vendored Executable file
View file

@ -0,0 +1,248 @@
#!/bin/sh
#
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View file

@ -0,0 +1,93 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View file

@ -0,0 +1,4 @@
/*
* SPDX-License-Identifier: Apache-2.0
*/
rootProject.name = System.getenv('CHAINCODE_NAME') ?: 'basic'

View file

@ -0,0 +1,93 @@
/*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.fabric.samples.assettransfer;
import java.util.Objects;
import org.hyperledger.fabric.contract.annotation.DataType;
import org.hyperledger.fabric.contract.annotation.Property;
import com.owlike.genson.annotation.JsonProperty;
@DataType()
public final class Asset {
@Property()
private final String assetID;
@Property()
private final String color;
@Property()
private final int size;
@Property()
private final String owner;
@Property()
private final int appraisedValue;
public String getAssetID() {
return assetID;
}
public String getColor() {
return color;
}
public int getSize() {
return size;
}
public String getOwner() {
return owner;
}
public int getAppraisedValue() {
return appraisedValue;
}
public Asset(@JsonProperty("assetID") final String assetID, @JsonProperty("color") final String color,
@JsonProperty("size") final int size, @JsonProperty("owner") final String owner,
@JsonProperty("appraisedValue") final int appraisedValue) {
this.assetID = assetID;
this.color = color;
this.size = size;
this.owner = owner;
this.appraisedValue = appraisedValue;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if ((obj == null) || (getClass() != obj.getClass())) {
return false;
}
Asset other = (Asset) obj;
return Objects.deepEquals(
new String[] {getAssetID(), getColor(), getOwner()},
new String[] {other.getAssetID(), other.getColor(), other.getOwner()})
&&
Objects.deepEquals(
new int[] {getSize(), getAppraisedValue()},
new int[] {other.getSize(), other.getAppraisedValue()});
}
@Override
public int hashCode() {
return Objects.hash(getAssetID(), getColor(), getSize(), getOwner(), getAppraisedValue());
}
@Override
public String toString() {
return this.getClass().getSimpleName() + "@" + Integer.toHexString(hashCode()) + " [assetID=" + assetID + ", color="
+ color + ", size=" + size + ", owner=" + owner + ", appraisedValue=" + appraisedValue + "]";
}
}

View file

@ -0,0 +1,223 @@
/*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.fabric.samples.assettransfer;
import java.util.ArrayList;
import java.util.List;
import org.hyperledger.fabric.contract.Context;
import org.hyperledger.fabric.contract.ContractInterface;
import org.hyperledger.fabric.contract.annotation.Contact;
import org.hyperledger.fabric.contract.annotation.Contract;
import org.hyperledger.fabric.contract.annotation.Default;
import org.hyperledger.fabric.contract.annotation.Info;
import org.hyperledger.fabric.contract.annotation.License;
import org.hyperledger.fabric.contract.annotation.Transaction;
import org.hyperledger.fabric.shim.ChaincodeException;
import org.hyperledger.fabric.shim.ChaincodeStub;
import org.hyperledger.fabric.shim.ledger.KeyValue;
import org.hyperledger.fabric.shim.ledger.QueryResultsIterator;
import com.owlike.genson.Genson;
@Contract(
name = "basic",
info = @Info(
title = "Asset Transfer",
description = "The hyperlegendary asset transfer",
version = "0.0.1-SNAPSHOT",
license = @License(
name = "Apache 2.0 License",
url = "http://www.apache.org/licenses/LICENSE-2.0.html"),
contact = @Contact(
email = "a.transfer@example.com",
name = "Adrian Transfer",
url = "https://hyperledger.example.com")))
@Default
public final class AssetTransfer implements ContractInterface {
private final Genson genson = new Genson();
private enum AssetTransferErrors {
ASSET_NOT_FOUND,
ASSET_ALREADY_EXISTS
}
/**
* Creates some initial assets on the ledger.
*
* @param ctx the transaction context
*/
@Transaction(intent = Transaction.TYPE.SUBMIT)
public void InitLedger(final Context ctx) {
putAsset(ctx, new Asset("asset1", "blue", 5, "Tomoko", 300));
putAsset(ctx, new Asset("asset2", "red", 5, "Brad", 400));
putAsset(ctx, new Asset("asset3", "green", 10, "Jin Soo", 500));
putAsset(ctx, new Asset("asset4", "yellow", 10, "Max", 600));
putAsset(ctx, new Asset("asset5", "black", 15, "Adrian", 700));
putAsset(ctx, new Asset("asset6", "white", 15, "Michel", 700));
}
/**
* Creates a new asset on the ledger.
*
* @param ctx the transaction context
* @param assetID the ID of the new asset
* @param color the color of the new asset
* @param size the size for the new asset
* @param owner the owner of the new asset
* @param appraisedValue the appraisedValue of the new asset
* @return the created asset
*/
@Transaction(intent = Transaction.TYPE.SUBMIT)
public Asset CreateAsset(final Context ctx, final String assetID, final String color, final int size,
final String owner, final int appraisedValue) {
if (AssetExists(ctx, assetID)) {
String errorMessage = String.format("Asset %s already exists", assetID);
System.out.println(errorMessage);
throw new ChaincodeException(errorMessage, AssetTransferErrors.ASSET_ALREADY_EXISTS.toString());
}
return putAsset(ctx, new Asset(assetID, color, size, owner, appraisedValue));
}
private Asset putAsset(final Context ctx, final Asset asset) {
// Use Genson to convert the Asset into string, sort it alphabetically and serialize it into a json string
String sortedJson = genson.serialize(asset);
ctx.getStub().putStringState(asset.getAssetID(), sortedJson);
return asset;
}
/**
* Retrieves an asset with the specified ID from the ledger.
*
* @param ctx the transaction context
* @param assetID the ID of the asset
* @return the asset found on the ledger if there was one
*/
@Transaction(intent = Transaction.TYPE.EVALUATE)
public Asset ReadAsset(final Context ctx, final String assetID) {
String assetJSON = ctx.getStub().getStringState(assetID);
if (assetJSON == null || assetJSON.isEmpty()) {
String errorMessage = String.format("Asset %s does not exist", assetID);
System.out.println(errorMessage);
throw new ChaincodeException(errorMessage, AssetTransferErrors.ASSET_NOT_FOUND.toString());
}
return genson.deserialize(assetJSON, Asset.class);
}
/**
* Updates the properties of an asset on the ledger.
*
* @param ctx the transaction context
* @param assetID the ID of the asset being updated
* @param color the color of the asset being updated
* @param size the size of the asset being updated
* @param owner the owner of the asset being updated
* @param appraisedValue the appraisedValue of the asset being updated
* @return the transferred asset
*/
@Transaction(intent = Transaction.TYPE.SUBMIT)
public Asset UpdateAsset(final Context ctx, final String assetID, final String color, final int size,
final String owner, final int appraisedValue) {
if (!AssetExists(ctx, assetID)) {
String errorMessage = String.format("Asset %s does not exist", assetID);
System.out.println(errorMessage);
throw new ChaincodeException(errorMessage, AssetTransferErrors.ASSET_NOT_FOUND.toString());
}
return putAsset(ctx, new Asset(assetID, color, size, owner, appraisedValue));
}
/**
* Deletes asset on the ledger.
*
* @param ctx the transaction context
* @param assetID the ID of the asset being deleted
*/
@Transaction(intent = Transaction.TYPE.SUBMIT)
public void DeleteAsset(final Context ctx, final String assetID) {
if (!AssetExists(ctx, assetID)) {
String errorMessage = String.format("Asset %s does not exist", assetID);
System.out.println(errorMessage);
throw new ChaincodeException(errorMessage, AssetTransferErrors.ASSET_NOT_FOUND.toString());
}
ctx.getStub().delState(assetID);
}
/**
* Checks the existence of the asset on the ledger
*
* @param ctx the transaction context
* @param assetID the ID of the asset
* @return boolean indicating the existence of the asset
*/
@Transaction(intent = Transaction.TYPE.EVALUATE)
public boolean AssetExists(final Context ctx, final String assetID) {
String assetJSON = ctx.getStub().getStringState(assetID);
return (assetJSON != null && !assetJSON.isEmpty());
}
/**
* Changes the owner of a asset on the ledger.
*
* @param ctx the transaction context
* @param assetID the ID of the asset being transferred
* @param newOwner the new owner
* @return the old owner
*/
@Transaction(intent = Transaction.TYPE.SUBMIT)
public String TransferAsset(final Context ctx, final String assetID, final String newOwner) {
String assetJSON = ctx.getStub().getStringState(assetID);
if (assetJSON == null || assetJSON.isEmpty()) {
String errorMessage = String.format("Asset %s does not exist", assetID);
System.out.println(errorMessage);
throw new ChaincodeException(errorMessage, AssetTransferErrors.ASSET_NOT_FOUND.toString());
}
Asset asset = genson.deserialize(assetJSON, Asset.class);
putAsset(ctx, new Asset(asset.getAssetID(), asset.getColor(), asset.getSize(), newOwner, asset.getAppraisedValue()));
return asset.getOwner();
}
/**
* Retrieves all assets from the ledger.
*
* @param ctx the transaction context
* @return array of assets found on the ledger
*/
@Transaction(intent = Transaction.TYPE.EVALUATE)
public String GetAllAssets(final Context ctx) {
ChaincodeStub stub = ctx.getStub();
List<Asset> queryResults = new ArrayList<>();
// To retrieve all assets from the ledger use getStateByRange with empty startKey & endKey.
// Giving empty startKey & endKey is interpreted as all the keys from beginning to end.
// As another example, if you use startKey = 'asset0', endKey = 'asset9' ,
// then getStateByRange will retrieve asset with keys between asset0 (inclusive) and asset9 (exclusive) in lexical order.
QueryResultsIterator<KeyValue> results = stub.getStateByRange("", "");
for (KeyValue result: results) {
Asset asset = genson.deserialize(result.getStringValue(), Asset.class);
System.out.println(asset);
queryResults.add(asset);
}
return genson.serialize(queryResults);
}
}

Some files were not shown because too many files have changed in this diff Show more