@verana-labs/verana-types
v0.10.2
Published
Generated TypeScript protobuf codecs for the Verana blockchain.
Readme
@verana-labs/verana-types
TypeScript protobuf codecs generated from the Verana blockchain protobufs with ts-proto.
Overview
This package contains TypeScript type definitions and codecs generated from Verana's protobuf definitions. All files in src/codec/ are auto-generated and should not be edited manually.
Generated Files Location
- Source: Proto definitions in
proto/verana/**/*.proto - Generated Output:
ts-proto/src/codec/**/*.ts - Generator:
bufwithts-protoplugin (v1.181.2)
All generated files include this header:
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.Generating TypeScript Files
Quick Start (Recommended)
From the repository root:
make proto-tsThis command:
- Generates TypeScript files from
.protodefinitions - Outputs to
ts-proto/src/codec/ - Builds the TypeScript package
Manual Generation
If you prefer to run the steps manually:
# From repository root
cd proto
buf generate --template buf.gen.ts.yaml # Generates to ../ts-proto/src/codec
cd ../ts-proto
npm install # Install dependencies if needed
npm run build # Build the package (emits dist/)What Gets Generated
The generator creates TypeScript files for:
- Verana modules:
tr,cs,dd,perm,td,de(Trust Registry, Credential Schema, DID Directory, Permission, Trust Deposit, Delegation Engine) - Cosmos SDK types: Base types, queries, messages
- Google protobuf types: Timestamps, durations, etc.
Each module includes:
tx.ts- Transaction messagesquery.ts- Query messages and responsestypes.ts- Type definitionsparams.ts- Parameter typesgenesis.ts- Genesis state types
When to Regenerate
Always regenerate TypeScript files after:
- ✅ Modifying any
.protofiles inproto/verana/ - ✅ Adding new message types
- ✅ Changing field types or names
- ✅ Adding new modules
- ✅ Updating proto dependencies
Example workflow:
# 1. Make changes to proto files
vim proto/verana/tr/v1/tx.proto
# 2. Regenerate TypeScript files
make proto-ts
# 3. Verify the changes
cd ts-proto
npm run build
# 4. Test with the test harness
cd test
npm run test:create-trConfiguration
The generation is configured in proto/buf.gen.ts.yaml:
plugins:
- plugin: buf.build/community/stephenh-ts-proto:v1.181.2
out: ../ts-proto/src/codec
opt:
- ts_proto_opt=esModuleInterop=true
- ts_proto_opt=forceLong=long
- ts_proto_opt=useOptionals=messages
- ts_proto_opt=snakeToCamel=trueOptions explained:
esModuleInterop=true- Enables ES module interopforceLong=long- Useslonglibrary for 64-bit integersuseOptionals=messages- Makes message fields optionalsnakeToCamel=true- Converts snake_case to camelCase
Using Generated Types
In Tests
The test harness in ts-proto/test/ demonstrates how to use the generated types:
import { MsgCreateTrustRegistry } from "../../../src/codec/verana/tr/v1/tx";
import { typeUrls } from "../helpers/registry";
const msg = {
typeUrl: typeUrls.MsgCreateTrustRegistry,
value: MsgCreateTrustRegistry.fromPartial({
creator: address,
did: "did:verana:example",
// ...
}),
};In Frontend Applications
import { MsgCreateTrustRegistry } from "@verana-labs/verana-types/codec/verana/tr/v1/tx";See ts-proto/test/README.md for complete examples.
Publish
- Bump the version in
package.jsonto match the chain tag you are releasing (e.g.v0.7.0->0.7.0). - Regenerate and build as above.
npm publish(ornpm packand upload the tarball to the GitHub release assets).
Consume
npm install @verana-labs/verana-typesImport directly from the codec paths:
import { MsgAddDID } from "@verana-labs/verana-types/codec/verana/dd/v1/tx";