Skip to content

feat(grpc-web): browser client at @sentrix/chain/grpc-web#18

Merged
satyakwok merged 1 commit into
mainfrom
feat/grpc-web-browser
May 10, 2026
Merged

feat(grpc-web): browser client at @sentrix/chain/grpc-web#18
satyakwok merged 1 commit into
mainfrom
feat/grpc-web-browser

Conversation

@satyakwok
Copy link
Copy Markdown
Member

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

  • `@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
  • Regenerate via:
    ```
    npx protoc --ts_out=src/grpc-web --proto_path=src/grpc-proto src/grpc-proto/sentrix.proto
    ```

Available calls (chain v0.4+)

Method Returns
`getLatestBlock()` / `getBlockByHeight(h)` `Block`
`getBalance(address)` `Account` (20-byte hex or Uint8Array)
`getValidatorSet({ atHeight? })` `ValidatorSet`
`getSupply({ atHeight? })` `Supply`
`getMempool({ limit })` `Mempool`
`streamEvents([filters])` async iterable of `ChainEvent`

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:

Surface Node Browser
EVM `/evm` (viem) `/evm` (viem)
REST `/native` `/native`
WebSocket `/bft` `/bft` (works in browser via native WebSocket)
gRPC `/grpc` (@grpc/grpc-js) `/grpc-web` (@protobuf-ts/grpcweb-transport)
Wallet `/wallet` `/wallet`

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).
@satyakwok satyakwok enabled auto-merge (squash) May 10, 2026 22:40
@satyakwok satyakwok merged commit 41370b8 into main May 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant