Skip to content

Commit 135eaca

Browse files
authored
documentation update (#1314)
Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
1 parent b43754f commit 135eaca

11 files changed

Lines changed: 640 additions & 47 deletions

File tree

CONTRIBUTING.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Contributing to Fabric Token SDK
2+
3+
We welcome contributions to the Fabric Token SDK!
4+
5+
Note that we follow the [LFDT Charter](https://www.lfdecentralizedtrust.org/about/charter).
6+
All new inbound code contributions to the project shall be made under the Apache License, Version 2.0.
7+
All outbound code will be made available under the Apache License, Version 2.0.
8+
9+
## Code of Conduct
10+
11+
Please note that we have a [Code of Conduct](CODE_OF_CONDUCT.md). Please follow it in all your interactions with the project.
12+
13+
## How to Contribute
14+
15+
1. **Fork the repository** on GitHub.
16+
2. **Clone your fork** locally.
17+
3. **Create a new branch** for your feature or bugfix.
18+
4. **Make your changes**.
19+
5. **Run tests** (see [Testing Guide](docs/development/testing.md)) to ensure your changes don't break anything.
20+
6. **Commit your changes** using the sign-off flag (`-s`).
21+
7. **Push your branch** to your fork.
22+
8. **Submit a Pull Request** (PR) to the `main` branch of the upstream repository.
23+
24+
## Good first issues
25+
26+
We maintain a set of issues labeled "good first issue" to help new contributors find approachable tasks and get started quickly.
27+
If you're contributing for the first time, please consider picking one of these issues:
28+
29+
- Browse the current list here: https://github.com/hyperledger-labs/fabric-token-sdk/issues?q=is%3Aissue+state%3Aopen+label%3A%22good+first+issue%22
30+
- Leave a comment on the issue saying you'd like to work on it and ask to be assigned.
31+
- If you need clarification or guidance, ask on our Discord channel (`#fabric-token-sdk`) or comment on the issue — maintainers and community members are happy to help.
32+
- Keep your first PR small and focused. Follow the project guidelines: run tests, sign your commits (`-s`), and rebase to keep a linear history.
33+
34+
## Detailed Development Guidelines
35+
36+
Please refer to the [Development Guidelines](docs/development/development.md) for detailed information on:
37+
38+
* **Commit Sign-off**: All commits must be signed off (`git commit -s`).
39+
* **Linear History**: We use rebase workflow, not merge commits.
40+
* **Coding Standards**: See [docs/development/general.md](docs/development/general.md) and [docs/development/idiomatic.md](docs/development/idiomatic.md) for Go coding standards.
41+
42+
## Reporting Issues
43+
44+
If you find a bug or have a feature request, please search the [Issues](https://github.com/hyperledger-labs/fabric-token-sdk/issues) to see if it has already been reported. If not, please open a new issue.
45+
46+
## Community
47+
48+
Join us on [Discord](https://discord.gg/hyperledger) in the `#fabric-token-sdk` channel.

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,52 +27,62 @@ include $(TOP)/fungible.mk
2727
all: install-tools install-softhsm checks unit-tests #integration-tests
2828

2929
.PHONY: install-tools
30+
# install tools required for development and testing
3031
install-tools:
3132
# Thanks for great inspiration https://marcofranssen.nl/manage-go-tools-via-go-modules
3233
@echo Installing tools from tools/tools.go
3334
@cd tools; cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install %
3435
@$(MAKE) install-linter-tool
3536

3637
.PHONY: download-fabric
38+
# download fabric binaries
3739
download-fabric:
3840
./ci/scripts/download_fabric.sh $(FABRIC_BINARY_BASE) $(FABRIC_VERSION) $(FABRIC_CA_VERSION)
3941

4042
.PHONY: unit-tests
43+
# run standard unit tests
4144
unit-tests:
4245
@go test -cover $(shell go list ./... | grep -v '/integration/' | grep -v 'regression')
4346
cd integration/nwo/; go test -cover ./...
4447
cd token/services/storage/db/kvs/hashicorp/; go test -cover ./...
4548

4649
.PHONY: unit-tests-race
50+
# run unit tests with race detection
4751
unit-tests-race:
4852
@export GORACE=history_size=7; go test -race -cover $(shell go list ./... | grep -v '/integration/' | grep -v 'regression')
4953
cd integration/nwo/; go test -cover ./...
5054

5155
.PHONY: unit-tests-regression
56+
# run regression unit tests
5257
unit-tests-regression:
5358
@go test -race -timeout 0 -cover $(shell go list ./... | grep -v '/integration/' | grep 'regression')
5459

5560
.PHONY: install-softhsm
61+
# install softhsm for testing
5662
install-softhsm:
5763
./ci/scripts/install_softhsm.sh
5864

5965
.PHONY: docker-images
66+
# build/pull docker images needed for testing
6067
docker-images: fabric-docker-images monitoring-docker-images testing-docker-images
6168

6269
.PHONY: testing-docker-images
70+
# pull docker images for testing (postgres, vault)
6371
testing-docker-images:
6472
docker pull postgres:16.2-alpine
6573
docker tag postgres:16.2-alpine fsc.itests/postgres:latest
6674
docker pull hashicorp/vault
6775

6876
.PHONY: fabric-docker-images
77+
# pull fabric docker images
6978
fabric-docker-images:
7079
docker pull hyperledger/fabric-baseos:$(FABRIC_TWO_DIGIT_VERSION)
7180
docker image tag hyperledger/fabric-baseos:$(FABRIC_TWO_DIGIT_VERSION) hyperledger/fabric-baseos:latest
7281
docker pull hyperledger/fabric-ccenv:$(FABRIC_TWO_DIGIT_VERSION)
7382
docker image tag hyperledger/fabric-ccenv:$(FABRIC_TWO_DIGIT_VERSION) hyperledger/fabric-ccenv:latest
7483

7584
.PHONY: monitoring-docker-images
85+
# pull monitoring docker images (explorer, prometheus, grafana, jaeger)
7686
monitoring-docker-images:
7787
docker pull ghcr.io/hyperledger-labs/explorer-db:latest
7888
docker pull ghcr.io/hyperledger-labs/explorer:latest
@@ -81,29 +91,35 @@ monitoring-docker-images:
8191
docker pull cr.jaegertracing.io/jaegertracing/jaeger:2.12.0
8292

8393
.PHONY: integration-tests-nft-dlog
94+
# run nft integration tests with idemix
8495
integration-tests-nft-dlog:
8596
cd ./integration/token/nft/dlog; export FAB_BINS=$(FAB_BINS); ginkgo $(GINKGO_TEST_OPTS) .
8697

8798
.PHONY: integration-tests-nft-fabtoken
99+
# run nft integration tests with fabtoken
88100
integration-tests-nft-fabtoken:
89101
cd ./integration/token/nft/fabtoken; export FAB_BINS=$(FAB_BINS); ginkgo $(GINKGO_TEST_OPTS) .
90102

91103
.PHONY: integration-tests-dvp-fabtoken
104+
# run dvp integration tests with fabtoken
92105
integration-tests-dvp-fabtoken:
93106
cd ./integration/token/dvp/fabtoken; export FAB_BINS=$(FAB_BINS); ginkgo $(GINKGO_TEST_OPTS) .
94107

95108
.PHONY: integration-tests-dvp-dlog
109+
# run dvp integration tests with idemix
96110
integration-tests-dvp-dlog:
97111
cd ./integration/token/dvp/dlog; export FAB_BINS=$(FAB_BINS); ginkgo $(GINKGO_TEST_OPTS) .
98112

99113

100114
.PHONY: tidy
115+
# tidy up go modules
101116
tidy:
102117
@go mod tidy
103118
cd tools; go mod tidy
104119
cd token/services/storage/db/kvs/hashicorp; go mod tidy
105120

106121
.PHONY: clean
122+
# clean up docker artifacts and generated files
107123
clean:
108124
docker network prune -f
109125
docker container prune -f
@@ -132,41 +148,50 @@ clean:
132148
rm -rf ./integration/token/fungible/update/testdata/
133149

134150
.PHONY: clean-fabric-peer-images
151+
# clean up fabric peer images
135152
clean-fabric-peer-images:
136153
docker images -a | grep "_peer.org" | awk '{print $3}' | xargs docker rmi
137154
docker images -a | grep "_peer_" | awk '{print $3}' | xargs docker rmi
138155

139156
.PHONY: tokengen
157+
# install tokengen tool
140158
tokengen:
141159
@go install ./cmd/tokengen
142160

143161
.PHONY: traceinspector
162+
# install traceinspector tool
144163
traceinspector:
145164
@go install ./token/services/benchmark/cmd/traceinspector
146165

147166
.PHONY: memcheck
167+
# install memcheck tool
148168
memcheck:
149169
@go install ./token/services/benchmark/cmd/memcheck
150170

151171
.PHONY: idemixgen
172+
# install idemixgen/txgen tool
152173
txgen:
153174
@go install github.com/IBM/idemix/tools/idemixgen
154175

155176
.PHONY: clean-all-containers
177+
# clean up all docker containers
156178
clean-all-containers:
157179
@if [ -n "$$(docker ps -aq)" ]; then docker rm -f $$(docker ps -aq); else echo "No containers to remove"; fi
158180

159181
.PHONY: lint
182+
# run various linters
160183
lint:
161184
@echo "Running Go Linters..."
162185
golangci-lint run --color=always --timeout=4m
163186

164187
.PHONY: lint-auto-fix
188+
# run linters with auto-fix
165189
lint-auto-fix:
166190
@echo "Running Go Linters with auto-fix..."
167191
golangci-lint run --color=always --timeout=4m --fix
168192

169193
.PHONY: install-linter-tool
194+
# install golangci-lint
170195
install-linter-tool:
171196
@echo "Installing golangci Linter"
172197
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(HOME)/go/bin v2.8.0

README.md

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ The `Fabric Token SDK` provides a collection of APIs and services that streamlin
1212
The project will be subject to rapid changes to complete the open-sourcing process, and the list of features.
1313

1414
# Useful Links
15-
16-
- [`Documentation`](docs/tokensdk.md): The design principles of the Fabric Token SDK.
15+
16+
- [`Documentation`](docs/README.md): The entry point for the Fabric Token SDK documentation.
1717
- [`Development`](docs/development/development.md): All about the development guidelines.
18+
- [`Contributing`](CONTRIBUTING.md): How to contribute to the project.
1819
- [`Fabric Samples`](https://github.com/hyperledger/fabric-samples/tree/main/token-sdk) Token SDK sample application is the
1920
quickest way to get a full network running with a REST API to issue, transfer and redeem tokens right away.
2021
- [`Benchmarks`](./docs/benchmark/benchmark.md): Benchmark guidelines and reports.
@@ -26,44 +27,6 @@ The project will be subject to rapid changes to complete the open-sourcing proce
2627
- [`Fabric Smart Client`](https://github.com/hyperledger-labs/fabric-smart-client): The Token SDK leverages the
2728
`Fabric Smart Client` for transaction orchestration, storing tokens and wallets, and more. Check it out.
2829

29-
# Getting started
30-
31-
Clone the code and make sure it is on your `$GOPATH`.
32-
(Important: we assume in this documentation and default configuration that your `$GOPATH` has a single root-directory!).
33-
Sometimes, we use `$FTS_PATH` to refer to the Fabric Token SDK repository in your filesystem.
34-
35-
```bash
36-
export FTS_PATH=$GOPATH/src/github.com/hyperledger-labs/fabric-token-sdk
37-
git clone https://github.com/hyperledger-labs/fabric-token-sdk.git $FTS_PATH
38-
```
39-
40-
## Further information
41-
42-
Fabric Token SDK uses a system called `NWO` from Fabric Smart Client for its integration tests and samples to programmatically create a fabric network along with the fabric-smart-client nodes. The current version of fabric that is tested can be found in the project [Makefile](https://github.com/hyperledger-labs/fabric-smart-client/blob/main/Makefile) set in the `FABRIC_VERSION` variable.
43-
44-
In order for a fabric network to be able to be created you need to ensure you have downloaded the appropriate version of the hyperledger fabric binaries from [Fabric Releases](https://github.com/hyperledger/fabric/releases) and unpack the compressed file onto your file system. This will create a directory structure of /bin and /config. You will then need to set the environment variable `FAB_BINS` to the `bin` directory. For example if you unpacked the compressed file into `/home/name/fabric` then you would
45-
46-
```bash
47-
export FAB_BINS=/home/name/fabric/bin
48-
```
49-
50-
Do not store the fabric binaries within your fabric-token-sdk cloned repo as this will cause problems running the samples and integration tests as they will not be able to install chaincode.
51-
52-
Almost all the samples and integration tests require the fabric binaries to be downloaded and the environment variable `FAB_BINS` set to point to the directory where these binaries are stored. One way to ensure this is to execute the following in the root of the fabric-token-sdk project
53-
54-
```shell
55-
make download-fabric
56-
export FAB_BINS=$PWD/../fabric/bin
57-
```
58-
59-
You can also use this to download a different version of the fabric binaries for example
60-
61-
```shell
62-
FABRIC_VERSION=2.5 make download-fabric
63-
```
64-
65-
If you want to provide your own versions of the fabric binaries then just set `FAB_BINS` to the directory where all the fabric binaries are stored.
66-
6730
# Additional Resources
6831

6932
- (March 17, 2022) [`Hyperledger in-Depth: Tokens in Hyperledger Fabric: What’s possible today and what’s coming`](https://www.hyperledger.org/learn/webinars/hyperledger-in-depth-tokens-in-hyperledger-fabric-whats-possible-today-and-whats-coming):
@@ -102,13 +65,9 @@ The Fabric Token SDK has evolved beyond its initial focus on Hyperledger Fabric.
10265

10366
With a robust Fabric Token SDK, developing secure and efficient enterprise-grade tokenized applications becomes a reality, offering flexibility for developers to choose the platform that best suits their needs.
10467

105-
# Development
106-
107-
For additional information about the development of the Token SDK, visit this [`section`](./docs/development/development.md).
108-
10968
# License
11069

11170
This project is licensed under the Apache 2 License - see the [`LICENSE`](LICENSE) file for details
11271

11372
[`fabric-token-sdk` Issues]: https://github.com/hyperledger-labs/fabric-token-sdk/issues
114-
[GitHub discussions]: https://github.com/hyperledger-labs/fabric-token-sdk/discussions
73+
[#fabric-token-sdk in Discord]: https://discord.gg/hyperledger

ci/scripts/download_fabric.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ download() {
1818
}
1919

2020
pullBinaries() {
21-
ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m |sed 's/x86_64/amd64/g')" |sed 's/darwin-arm64/darwin-amd64/g')
21+
ARCH=$(echo "$(uname -s | tr '[:upper:]' '[:lower:]' | sed 's/mingw64_nt.*/windows/')-$(uname -m | tr '[:upper:]' '[:lower:]' | sed 's/x86_64/amd64/g; s/aarch64/arm64/g; s/^armv8.*$/arm64/g')" | sed 's/darwin-arm64/darwin-amd64/g')
2222
MARCH=$(uname -m)
2323
local VERSION=$1
2424
local CA_VERSION=$2

docs/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Fabric Token SDK Documentation
2+
3+
Welcome to the Fabric Token SDK documentation.
4+
5+
## Core Concepts
6+
7+
* [**Token SDK Overview**](tokensdk.md): Start here to understand the architecture, key concepts (Tokens, Wallets, Privacy), and layers of the SDK.
8+
* [**Token API**](tokenapi.md): The high-level API for interacting with tokens.
9+
* [**Token API Usage**](token_sdk_usage.md): API Usage Guide.
10+
* [**Driver API**](driverapi.md): The interface for building token drivers.
11+
* [**Core Token**](core-token.md): Core token definitions.
12+
* [**Services**](services.md): Additional services like transaction assembly.
13+
14+
## Development
15+
16+
If you are developing *using* the SDK or contributing *to* the SDK, check out the [Development](development/development.md) section.
17+
18+
* [General Guidelines](development/general.md)
19+
* [Idiomatic Go](development/idiomatic.md)
20+
* [Testing](development/testing.md)
21+
22+
## Guides & Tutorials
23+
24+
* [Fabric Smart Client](https://github.com/hyperledger-labs/fabric-smart-client): The underlying platform.
25+
* [Fabric Samples](https://github.com/hyperledger/fabric-samples/tree/main/token-sdk): Runnable examples.

docs/development/development.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This page contains link to the development guidelines and more.
1010
- [Monitoring](./monitoring.md)
1111
- [Mock Files Generation](./mock.md)
1212
- [Tools: tokengen](./tokengen.md)
13+
- [Makefile Guide](./makefile.md)
1314

1415
## Useful resources
1516

docs/development/makefile.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Makefile Guide
2+
3+
This document explains the targets available in the `Makefile` for the Fabric Token SDK. The Makefile allows you to automate common tasks such as installing tools, running tests, and managing Docker images.
4+
5+
## Setup & Installation
6+
7+
These targets help you set up your development environment.
8+
9+
| Target | Description |
10+
| :--- | :--- |
11+
| `make install-tools` | Installs necessary Go tools (linters, generators, etc.) defined in `tools/tools.go`. It also installs `golangci-lint`. |
12+
| `make download-fabric` | Downloads Hyperledger Fabric binaries. You can specify `FABRIC_VERSION` and `FABRIC_CA_VERSION` env vars to control the versions. |
13+
| `make install-softhsm` | Installs SoftHSM for testing hardware security module integration. |
14+
15+
## Testing
16+
17+
These targets run various test suites.
18+
19+
### Unit Tests
20+
21+
| Target | Description |
22+
| :--- | :--- |
23+
| `make unit-tests` | Runs standard unit tests for the SDK, excluding integration and regression tests. |
24+
| `make unit-tests-race` | Runs unit tests with the Go race detector enabled. |
25+
| `make unit-tests-regression` | Runs regression tests. |
26+
27+
### Integration Tests
28+
29+
The SDK has several integration test targets. Some common ones include:
30+
31+
| Target | Description |
32+
| :--- | :--- |
33+
| `make integration-tests-nft-dlog` | Runs NFT integration tests with Idemix driver. |
34+
| `make integration-tests-nft-fabtoken` | Runs NFT integration tests with FabToken driver. |
35+
| `make integration-tests-dvp-fabtoken` | Runs Delivery vs Payment (DvP) integration tests with FabToken. |
36+
| `make integration-tests-dvp-dlog` | Runs DvP integration tests with Idemix. |
37+
38+
(See the `Makefile` for the full list of integration test targets).
39+
40+
## Docker Images
41+
42+
These targets build or pull Docker images required for testing and development.
43+
44+
| Target | Description |
45+
| :--- | :--- |
46+
| `make docker-images` | Pulls all necessary images (Fabric, monitoring, testing). |
47+
| `make fabric-docker-images` | Pulls Hyperledger Fabric images. |
48+
| `make testing-docker-images` | Pulls images like Postgres and Vault for testing. |
49+
| `make monitoring-docker-images` | Pulls monitoring tools like Prometheus, Grafana, Jaeger, and Explorer. |
50+
51+
## Maintenance
52+
53+
These targets help keep your project clean and tidy.
54+
55+
| Target | Description |
56+
| :--- | :--- |
57+
| `make tidy` | Runs `go mod tidy` in all modules to ensure dependencies are clean. |
58+
| `make clean` | cleans up Docker artifacts (containers, volumes, networks) and removes generated test output directories. **Use with caution as it removes Docker volumes.** |
59+
| `make clean-all-containers` | Removes all running and stopped Docker containers. |
60+
| `make clean-fabric-peer-images` | Removes Docker images related to Fabric peers. |
61+
| `make lint` | Runs `golangci-lint` to check code quality. |
62+
| `make lint-auto-fix` | Runs `golangci-lint` and automatically fixes issues where possible. |
63+
64+
## Tools Generation
65+
66+
| Target | Description |
67+
| :--- | :--- |
68+
| `make tokengen` | Installs the `tokengen` tool. |
69+
| `make traceinspector` | Installs the `traceinspector` tool. |
70+
| `make memcheck` | Installs the `memcheck` tool. |

0 commit comments

Comments
 (0)