feat(grpc-web): browser client at @sentrix/chain/grpc-web#18
Merged
Conversation
Adds the grpc-web subpath — browser-side equivalent of the Node-only
/grpc client. Same surface (GrpcWebClient mirrors GrpcClient method
names), same chain endpoint (grpc.sentrixchain.com:443). Caddy at the
edge transcodes gRPC-Web ↔ native gRPC via tonic-web, so server code
is identical and dApp code that reads from both rails (eg an Electron
app + a CLI sharing a UI lib) doesn't need to branch per environment.
Implementation: @protobuf-ts/grpcweb-transport for the wire layer;
generated TS stubs (sentrix.ts + sentrix.client.ts) committed under
src/grpc-web/ via @protobuf-ts/plugin so consumers don't need protoc
installed. Generated by:
npx protoc --ts_out=src/grpc-web --proto_path=src/grpc-proto src/grpc-proto/sentrix.proto
Available calls (chain v0.4+):
- getLatestBlock() / getBlockByHeight(h)
- getBalance(address) — 20-byte hex or Uint8Array
- getValidatorSet({ atHeight? })
- getSupply({ atHeight? })
- getMempool({ limit })
- streamEvents([filters]) — async iterable
Verified end-to-end via Node fetch (same transport as browser):
mainnet latest: { index: '1679486', txs: 0 }
Closes the cross-rail symmetry. SDK now has a node + browser door
for every read surface (evm via viem, native via REST, bft via WS,
grpc via @grpc/grpc-js, grpc-web via @protobuf-ts/grpcweb-transport).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the grpc-web subpath — browser-side equivalent of the Node-only `/grpc` client. Same surface (`GrpcWebClient` mirrors `GrpcClient` method names), same chain endpoint (`grpc.sentrixchain.com:443`). Caddy at the edge transcodes gRPC-Web ↔ native gRPC via `tonic-web`, so server code is identical and dApp code that reads from both rails (eg an Electron app + a CLI sharing a UI lib) doesn't need to branch per environment.
Implementation
```
npx protoc --ts_out=src/grpc-web --proto_path=src/grpc-proto src/grpc-proto/sentrix.proto
```
Available calls (chain v0.4+)
Usage
```ts
import { GrpcWebClient } from "@sentrix/chain/grpc-web";
const c = new GrpcWebClient("mainnet");
const block = await c.getLatestBlock();
for await (const ev of c.streamEvents([])) {
console.log(ev);
}
```
Verification
End-to-end via Node fetch (same transport as browser):
`mainnet latest: { index: '1679486', txs: 0 }`
Cross-rail symmetry
SDK now has a node + browser door for every read surface: