Waves protobuf schemas repository
Add dependency to your pom.xml
<dependency>
<groupId>com.wavesplatform</groupId>
<artifactId>protobuf-schemas</artifactId>
<version>{version}</version>
</dependency>
- Add dependency to your
build.sbt
:
libraryDependencies += ("com.wavesplatform" % "protobuf-schemas" % "{version}" classifier "proto") % "protobuf"
- Configure ScalaPB to compile external schemas with:
inConfig(Compile)(Seq(
PB.protoSources in Compile := Seq(PB.externalIncludePath.value),
includeFilter in PB.generate := new SimpleFileFilter((f: File) => f.getName.endsWith(".proto") && f.getParent.endsWith("waves")),
PB.targets += scalapb.gen(flatPackage = true) -> sourceManaged.value
))
- If you use SNAPSHOT version, add this line
resolvers += Resolver.sonatypeRepo("snapshots")
Npm package: @waves/protobuf-serialization
.
It contains generated JavaScript classes, TypeScript definitions as well as raw proto files. The default build uses CommonJS and includes all of the proto files. We used pbjs
to build JavaScript and pbts
to build TypeScript definitions.
You could also make your own custom build from raw .proto
files, for example, if you want to use only a subset of proto schemas or gRPC services. They can be found in @waves/protobuf-serialization/proto
directory.
long.js
is used for 64-bit integers: int64
, uint64
, etc.
Example:
npm install --save @waves/protobuf-serialization
- Default build usage
import { waves } from '@waves/protobuf-serialization';
const block = new waves.Block();
block.header = // ... set necessary fields
const buffer = waves.Block.encode(block);
const blockDecoded = waves.Block.decode(buffer);
- Add
App.config
,packages.config
to your C# solution - Add
<ItemGroup>
<Protobuf Include="proto\waves\*.proto" OutputDir="waves\%(RelativePath)" GrpcServices="None" />
<Protobuf Include="proto\waves\events\*.proto" OutputDir="waves\events\%(RelativePath)" GrpcServices="None" />
<Protobuf Include="proto\waves\node\grpc\*.proto" OutputDir="waves\node\grpc\%(RelativePath)" GrpcServices="Both" />
</ItemGroup>
to your .csproj
file. After this just build your project.
or as alternative you can use util protoc, for example:
protoc --csharp_out=RelativePath --proto_path=RelativePathToProtoDir RelativePathToProtoFile
Also there is a NuGet package WavesPlatform.ProtobufSchema with this project.
Add dependency to your Cargo.toml
[dependencies]
waves-protobuf-schemas = { git = "https://github.com/wavesplatform/protobuf-schemas" }
Use mvn package
to create JAR artifacts:
protobuf-schemas-{version}-proto.jar
- raw .proto filesprotobuf-schemas-{version}.jar
- protoc-generated Java classes