bdledger-apis/grpc
2022-11-14 09:23:46 +08:00
..
pb fix: Block.witness_signatures 2022-11-14 03:17:23 +08:00
scripts docs: update 2021-07-20 10:30:31 +08:00
package-lock.json feat: add ts-proto for new TypeScript SDK 2021-07-22 16:21:15 +08:00
package.json feat: add ts-proto for new TypeScript SDK 2021-07-22 16:21:15 +08:00
README.md fix: fix gRPC-Gateway to v2.2.0 for now 2022-11-14 09:23:46 +08:00
tasks.py fix: ts-proto: --ts_proto_opt=env=node 2021-07-22 18:54:54 +08:00

BDLedger API

Documentation

See API documentation

Development

Generating gRPC code in languages

Installling tools

Download the Protocol Buffers compiler (protoc-3.21.9-*)+ for your platform and add protoc to PATH environment variable

For generating Go code, install protoc-gen-go (v1.28.1+):

GIT_TAG="v1.28.1"
go get -d -u google.golang.org/protobuf/cmd/protoc-gen-go
git -C "$(go env GOPATH)"/src/google.golang.org/protobuf checkout $GIT_TAG
go install google.golang.org/protobuf/cmd/protoc-gen-go

Also install protoc-gen-go-grpc v1.2.0+:

go get -u google.golang.org/grpc/cmd/protoc-gen-go-grpc

Or install using gobin:

gobin google.golang.org/protobuf/cmd/protoc-gen-go
gobin google.golang.org/grpc/cmd/protoc-gen-go-grpc

For generating HTTP JSON APIs with grpc-gateway v2.2.0, follow the documentation.

For generating validators install go-proto-validators:

go get github.com/mwitkow/go-proto-validators/protoc-gen-govalidators

For generating Java code: From bdledger-sdk-java run gradle generateProto

For generating Node.js code and/or TypeScript definitions), install Node.js then run:

npm install

For frontend JavaScript:

git clone https://github.com/grpc/grpc-web
cd grpc-web
sudo make install-plugin

References:

TODO: Look into protobuf.js for Nodes.js and frontend TODO: Look into Kroto+ for Kotlin

Generating code

Run:

For generating TypeScript client code with ts-proto, run:

invoke gen -t ts

For generating TypeScript definitions to be used with @grpc/proto-loader, run:

invoke gen -t types

Others:

./scripts/gen [-a, --async] [go] [gohttp] [nodejs] [docs]

nodejs: For generating static Node.js code and TypeScript definitions

Use -a or --async to speed up generation by asynchronously and concurrently generating all code and documentation ( script will exit without waiting for completion)

Generateing documentation

Install Go then run:

go get -u github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
./scripts/gen [-a, --async] docs