@wireio/protoc-gen-solana 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # protoc-gen-solana
1
+ # @wireio/protoc-gen-solana
2
+
3
+ [![npm](https://img.shields.io/npm/v/@wireio/protoc-gen-solana)](https://www.npmjs.com/package/@wireio/protoc-gen-solana)
2
4
 
3
5
  A `protoc` plugin that generates Rust protobuf encode/decode modules from proto3 definitions, optimized for Solana programs.
4
6
 
@@ -9,18 +11,20 @@ Given a `.proto` file, the plugin outputs:
9
11
 
10
12
  Generated code targets minimal allocations and efficient compute, suitable for Solana's on-chain constraints.
11
13
 
14
+ > Part of the [`wire-libraries-ts`](../../README.md) monorepo.
15
+
12
16
  ## Install
13
17
 
14
18
  ```bash
15
19
  npm install @wireio/protoc-gen-solana
16
20
  ```
17
21
 
18
- Requires Node >= 24 on your PATH.
22
+ Requires Node >= 24.
19
23
 
20
24
  ## Usage
21
25
 
22
26
  ```bash
23
- [npx] protoc \
27
+ npx protoc \
24
28
  --plugin=protoc-gen-solana=./node_modules/.bin/protoc-gen-solana \
25
29
  --solana_out=./generated \
26
30
  path/to/your.proto
@@ -31,11 +35,11 @@ Requires Node >= 24 on your PATH.
31
35
  Pass parameters via `--solana_opt`:
32
36
 
33
37
  ```bash
34
- [npx] protoc --solana_opt=log_level=debug ...
38
+ npx protoc --solana_opt=log_level=debug ...
35
39
  ```
36
40
 
37
- | Parameter | Values | Default |
38
- |-------------|-------------------------------------------------|---------|
41
+ | Parameter | Values | Default |
42
+ |-------------|--------------------------------------------------|---------|
39
43
  | `log_level` | `log`, `trace`, `debug`, `info`, `warn`, `error` | `info` |
40
44
 
41
45
  ## Example
@@ -78,19 +82,23 @@ impl SolanaAccount {
78
82
  }
79
83
  ```
80
84
 
81
- ## Supported Proto3 Features
82
-
83
- | Feature | Rust Representation |
84
- |---|---|
85
- | Scalar types (int32, uint64, bool, string, bytes, float, double, etc.) | Native Rust types (`i32`, `u64`, `bool`, `String`, `Vec<u8>`, `f32`, `f64`) |
86
- | Nested messages | Struct with `encode()`/`decode()` |
87
- | Repeated fields | `Vec<T>` |
88
- | Map fields | Parallel `Vec<K>` + `Vec<V>` (keys and values) |
89
- | Enums | `i32` |
90
- | sint32 / sint64 | ZigZag-encoded `i32` / `i64` |
91
- | fixed32 / fixed64 / sfixed32 / sfixed64 | Fixed-width encoding |
92
- | Unknown fields | Silently skipped during decode |
93
- | Borsh serialization | Opt-in via `feature = "borsh"` on the generated crate |
85
+ ## Type Mapping
86
+
87
+ | Proto | Rust | Wire Type |
88
+ |-------|------|-----------|
89
+ | `int32` / `int64` | `i32` / `i64` | Varint |
90
+ | `uint32` / `uint64` | `u32` / `u64` | Varint |
91
+ | `sint32` / `sint64` | `i32` / `i64` | Varint (ZigZag) |
92
+ | `bool` | `bool` | Varint |
93
+ | `string` | `String` | Length-delimited |
94
+ | `bytes` | `Vec<u8>` | Length-delimited |
95
+ | `float` / `double` | `f32` / `f64` | Fixed |
96
+ | `fixed32` / `fixed64` | `u32` / `u64` | Fixed |
97
+ | `sfixed32` / `sfixed64` | `i32` / `i64` | Fixed |
98
+ | `enum` | `i32` | Varint |
99
+ | `message` | struct | Length-delimited |
100
+ | `repeated T` | `Vec<T>` | Sequential tags |
101
+ | `map<K,V>` | `Vec<K>` + `Vec<V>` | Length-delimited |
94
102
 
95
103
  ### Map Field Convention
96
104
 
@@ -113,7 +121,7 @@ For a proto file `path/to/service.proto` with `package example.nested`:
113
121
 
114
122
  ```
115
123
  <output_dir>/
116
- protobuf_runtime.rs # Always emitted — shared wire format primitives
124
+ protobuf_runtime.rs # Always emitted — shared wire format primitives
117
125
  example/nested/service.rs # Per-proto generated structs
118
126
  ```
119
127
 
@@ -123,21 +131,24 @@ The generated code imports the runtime via `use crate::protobuf_runtime::*;`, so
123
131
 
124
132
  ```bash
125
133
  pnpm install
126
- pnpm dev # Watch mode (TypeScript compile + esbuild bundle)
127
- pnpm dist # Full production build (compile + bundle + pkg binary)
128
- pnpm format # Format source with prettier
134
+ pnpm build # Compile TypeScript + esbuild bundle
135
+ pnpm dev # Watch mode (compile + bundle)
136
+ pnpm dist # Full production build (compile + bundle + pkg binary)
137
+ pnpm test # Run unit tests
138
+ pnpm format # Format source with prettier
139
+ pnpm clean # Remove build artifacts
129
140
  ```
130
141
 
131
- ### Testing
142
+ ### Integration Testing
132
143
 
133
144
  ```bash
134
145
  pnpm generate:test
135
146
  ```
136
147
 
137
- This builds the plugin binary and runs `protoc` against the proto files in `tests/protos/`, writing generated Rust output to `dist/tests/generated/`.
148
+ Builds the plugin binary and runs `protoc` against the proto files in `tests/protos/`, writing generated Rust output to `dist/tests/generated/`.
138
149
 
139
150
  The Rust runtime (`rs/protobuf_runtime.rs`) contains `#[cfg(test)]` unit tests covering all wire format primitives.
140
151
 
141
152
  ## License
142
153
 
143
- See [LICENSE](LICENSE) for details.
154
+ MIT
Binary file