From efc9a902f64420a5641938b5cdc32dc64992d3e2 Mon Sep 17 00:00:00 2001 From: satyakwok <119509589+satyakwok@users.noreply.github.com> Date: Mon, 11 May 2026 00:40:45 +0200 Subject: [PATCH] feat(grpc-web): browser client at @sentrix/chain/grpc-web MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- README.md | 18 +- package.json | 19 +- pnpm-lock.yaml | 98 ++ src/grpc-web/index.ts | 153 +++ src/grpc-web/sentrix.client.ts | 197 +++ src/grpc-web/sentrix.ts | 2286 ++++++++++++++++++++++++++++++++ 6 files changed, 2765 insertions(+), 6 deletions(-) create mode 100644 src/grpc-web/index.ts create mode 100644 src/grpc-web/sentrix.client.ts create mode 100644 src/grpc-web/sentrix.ts diff --git a/README.md b/README.md index 753def9..81844a9 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Official TypeScript SDK for **Sentrix Chain** (chain ID `7119` mainnet, `7120` t - **`@sentrix/chain/bft`** — WebSocket subscription manager for all 9 channels (newHeads, logs, sentrix_finalized, sentrix_jail, …) with keepalive ping + automatic reconnect + typed payloads - **`@sentrix/chain/wallet`** — secp256k1 keypair + Sentrix-native tx signing (same address as your MetaMask key — Sentrix derives addresses identically to Ethereum) - **`@sentrix/chain/grpc`** — Node-side gRPC client over `@grpc/grpc-js` for the chain's `sentrix.v1.Sentrix` service (getBlock, getBalance, getValidatorSet, getSupply, getMempool, streamEvents). Bundled `.proto` so version drift can't bite you. +- **`@sentrix/chain/grpc-web`** — browser-side equivalent over `@protobuf-ts/grpcweb-transport`. Same surface, same chain endpoint (`grpc.sentrixchain.com` — Caddy transcodes gRPC-Web ↔ native gRPC). ## Install @@ -132,7 +133,22 @@ c.close(); The chain's `sentrix.v1.Sentrix` service mirrors the JSON-RPC + REST shape. v0.4+ adds `getValidatorSet` / `getSupply` / `getMempool` and a server-streaming `streamEvents` for push-style consumption without the WebSocket overhead. Older chain hosts return `Status::unimplemented` for the newer methods; the SDK forwards the error verbatim so callers can fall back to JSON-RPC / REST. -> Browser consumers: `/grpc` is **Node-only** because `@grpc/grpc-js` needs raw HTTP/2. For browser dApps that want gRPC, the [sentrix-explorer-v2](https://github.com/Sentriscloud/sentrix-explorer-v2) repo has the working Rust + WASM + tonic-web pattern; or wire `grpc-web` npm directly against the same `grpc.sentrixchain.com:443` endpoint (Caddy transcodes between gRPC-Web ↔ gRPC). +> Browser consumers: use `@sentrix/chain/grpc-web` instead. Same surface, same chain endpoint — only the transport changes (`@protobuf-ts/grpcweb-transport` instead of `@grpc/grpc-js`). The `/grpc` subpath stays Node-only because `@grpc/grpc-js` needs raw HTTP/2 sockets browsers don't expose. + +### Read via gRPC-Web (browser) + +```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); +} +``` + +Same chain endpoint as the Node `/grpc` subpath (`grpc.sentrixchain.com`) — Caddy at the edge transcodes gRPC-Web ↔ native gRPC via `tonic-web` so server code is identical. ## Network identity helpers diff --git a/package.json b/package.json index 9c4b184..2b52fb2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@sentrix/chain", "version": "0.3.0-rc.0", - "description": "Official TypeScript SDK for Sentrix Chain \u2014 typed wrappers around EVM JSON-RPC + native REST + WebSocket subscriptions.", + "description": "Official TypeScript SDK for Sentrix Chain — typed wrappers around EVM JSON-RPC + native REST + WebSocket subscriptions.", "type": "module", "main": "./dist/index.js", "module": "./dist/index.js", @@ -30,6 +30,10 @@ "./grpc": { "types": "./dist/grpc/index.d.ts", "import": "./dist/grpc/index.js" + }, + "./grpc-web": { + "types": "./dist/grpc-web/index.d.ts", + "import": "./dist/grpc-web/index.js" } }, "files": [ @@ -66,13 +70,18 @@ "viem": "^2.48.8" }, "dependencies": { - "ws": "^8.18.0", - "@noble/secp256k1": "^2.2.0", - "@noble/hashes": "^1.6.0", "@grpc/grpc-js": "^1.12.0", - "@grpc/proto-loader": "^0.7.13" + "@grpc/proto-loader": "^0.7.13", + "@noble/hashes": "^1.6.0", + "@noble/secp256k1": "^2.2.0", + "@protobuf-ts/grpcweb-transport": "^2.11.1", + "@protobuf-ts/runtime": "^2.11.1", + "@protobuf-ts/runtime-rpc": "^2.11.1", + "ws": "^8.18.0" }, "devDependencies": { + "@protobuf-ts/plugin": "^2.11.1", + "@protobuf-ts/protoc": "^2.11.1", "@types/node": "^22.10.0", "@types/ws": "^8.5.13", "typescript": "^5.7.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2a95d21..f1daa11 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,10 +20,25 @@ importers: '@noble/secp256k1': specifier: ^2.2.0 version: 2.3.0 + '@protobuf-ts/grpcweb-transport': + specifier: ^2.11.1 + version: 2.11.1 + '@protobuf-ts/runtime': + specifier: ^2.11.1 + version: 2.11.1 + '@protobuf-ts/runtime-rpc': + specifier: ^2.11.1 + version: 2.11.1 ws: specifier: ^8.18.0 version: 8.20.0 devDependencies: + '@protobuf-ts/plugin': + specifier: ^2.11.1 + version: 2.11.1 + '@protobuf-ts/protoc': + specifier: ^2.11.1 + version: 2.11.1 '@types/node': specifier: ^22.10.0 version: 22.19.17 @@ -45,6 +60,12 @@ packages: '@adraffy/ens-normalize@1.11.1': resolution: {integrity: sha512-nhCBV3quEgesuf7c7KYfperqSS14T8bYuvJ8PcLJp6znkZpFc0AuW4qBtr8eKVyPPe/8RSr7sglCWPU5eaxwKQ==} + '@bufbuild/protobuf@2.12.0': + resolution: {integrity: sha512-B/XlCaFIP8LOwzo+bz5uFzATYokcwCKQcghqnlfwSmM5eX/qTkvDBnDPs+gXtX/RyjxJ4DRikECcPJbyALA8FA==} + + '@bufbuild/protoplugin@2.12.0': + resolution: {integrity: sha512-ORlDITp8AFUXzIhLRoMCG+ud+D3MPKWb5HQXBoskMMnjeyEjE1H1qLonVNPyOr8lkx3xSfYUo8a0dvOZJVAzow==} + '@esbuild/aix-ppc64@0.21.5': resolution: {integrity: sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==} engines: {node: '>=12'} @@ -218,6 +239,23 @@ packages: '@noble/secp256k1@2.3.0': resolution: {integrity: sha512-0TQed2gcBbIrh7Ccyw+y/uZQvbJwm7Ao4scBUxqpBCcsOlZG0O4KGfjtNAy/li4W8n1xt3dxrwJ0beZ2h2G6Kw==} + '@protobuf-ts/grpcweb-transport@2.11.1': + resolution: {integrity: sha512-1W4utDdvOB+RHMFQ0soL4JdnxjXV+ddeGIUg08DvZrA8Ms6k5NN6GBFU2oHZdTOcJVpPrDJ02RJlqtaoCMNBtw==} + + '@protobuf-ts/plugin@2.11.1': + resolution: {integrity: sha512-HyuprDcw0bEEJqkOWe1rnXUP0gwYLij8YhPuZyZk6cJbIgc/Q0IFgoHQxOXNIXAcXM4Sbehh6kjVnCzasElw1A==} + hasBin: true + + '@protobuf-ts/protoc@2.11.1': + resolution: {integrity: sha512-mUZJaV0daGO6HUX90o/atzQ6A7bbN2RSuHtdwo8SSF2Qoe3zHwa4IHyCN1evftTeHfLmdz+45qo47sL+5P8nyg==} + hasBin: true + + '@protobuf-ts/runtime-rpc@2.11.1': + resolution: {integrity: sha512-4CqqUmNA+/uMz00+d3CYKgElXO9VrEbucjnBFEjqI4GuDrEQ32MaI3q+9qPBvIGOlL4PmHXrzM32vBPWRhQKWQ==} + + '@protobuf-ts/runtime@2.11.1': + resolution: {integrity: sha512-KuDaT1IfHkugM2pyz+FwiY80ejWrkH1pAtOBOZFuR6SXEFTsnb/jiQWQ1rCIrcKx2BtyxnxW6BWwsVSA/Ie+WQ==} + '@protobufjs/aspromise@1.1.2': resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==} @@ -404,6 +442,11 @@ packages: '@types/ws@8.18.1': resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==} + '@typescript/vfs@1.6.4': + resolution: {integrity: sha512-PJFXFS4ZJKiJ9Qiuix6Dz/OwEIqHD7Dme1UwZhTK11vR+5dqW2ACbdndWQexBzCx+CPuMe5WBYQWCsFyGlQLlQ==} + peerDependencies: + typescript: '*' + '@vitest/expect@2.1.9': resolution: {integrity: sha512-UJCIkTBenHeKT1TTlKMJWy1laZewsRIzYighyYiJKZreqtdxSos/S1t+ktRMQWu2CKqaarrkeszJx1cgC5tGZw==} @@ -629,6 +672,16 @@ packages: resolution: {integrity: sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==} engines: {node: '>=14.0.0'} + typescript@3.9.10: + resolution: {integrity: sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==} + engines: {node: '>=4.2.0'} + hasBin: true + + typescript@5.4.5: + resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==} + engines: {node: '>=14.17'} + hasBin: true + typescript@5.9.3: resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} engines: {node: '>=14.17'} @@ -755,6 +808,16 @@ snapshots: '@adraffy/ens-normalize@1.11.1': {} + '@bufbuild/protobuf@2.12.0': {} + + '@bufbuild/protoplugin@2.12.0': + dependencies: + '@bufbuild/protobuf': 2.12.0 + '@typescript/vfs': 1.6.4(typescript@5.4.5) + typescript: 5.4.5 + transitivePeerDependencies: + - supports-color + '@esbuild/aix-ppc64@0.21.5': optional: true @@ -857,6 +920,30 @@ snapshots: '@noble/secp256k1@2.3.0': {} + '@protobuf-ts/grpcweb-transport@2.11.1': + dependencies: + '@protobuf-ts/runtime': 2.11.1 + '@protobuf-ts/runtime-rpc': 2.11.1 + + '@protobuf-ts/plugin@2.11.1': + dependencies: + '@bufbuild/protobuf': 2.12.0 + '@bufbuild/protoplugin': 2.12.0 + '@protobuf-ts/protoc': 2.11.1 + '@protobuf-ts/runtime': 2.11.1 + '@protobuf-ts/runtime-rpc': 2.11.1 + typescript: 3.9.10 + transitivePeerDependencies: + - supports-color + + '@protobuf-ts/protoc@2.11.1': {} + + '@protobuf-ts/runtime-rpc@2.11.1': + dependencies: + '@protobuf-ts/runtime': 2.11.1 + + '@protobuf-ts/runtime@2.11.1': {} + '@protobufjs/aspromise@1.1.2': {} '@protobufjs/base64@1.1.2': {} @@ -978,6 +1065,13 @@ snapshots: dependencies: '@types/node': 22.19.17 + '@typescript/vfs@1.6.4(typescript@5.4.5)': + dependencies: + debug: 4.4.3 + typescript: 5.4.5 + transitivePeerDependencies: + - supports-color + '@vitest/expect@2.1.9': dependencies: '@vitest/spy': 2.1.9 @@ -1228,6 +1322,10 @@ snapshots: tinyspy@3.0.2: {} + typescript@3.9.10: {} + + typescript@5.4.5: {} + typescript@5.9.3: {} undici-types@6.21.0: {} diff --git a/src/grpc-web/index.ts b/src/grpc-web/index.ts new file mode 100644 index 0000000..75d288f --- /dev/null +++ b/src/grpc-web/index.ts @@ -0,0 +1,153 @@ +// gRPC-Web door — browser-side client for the chain's `sentrix.v1.Sentrix` +// service. Mirror of the Node-side `@sentrix/chain/grpc` API but over +// `@protobuf-ts/grpcweb-transport` instead of `@grpc/grpc-js`, so it +// works in the browser bundle without HTTP/2 raw socket access. +// +// The chain accepts gRPC-Web at the same endpoint as native gRPC — +// Caddy at the edge runs `tonic-web` to transcode between the two. So +// browser dApps connect to the same `grpc.sentrixchain.com:443` +// hostname; only the transport changes. +// +// Why a thin wrapper instead of asking callers to wire the transport +// themselves: hide endpoint resolution, package the generated stubs +// behind a stable surface, and keep the API shape identical to the +// Node `/grpc` subpath so dApp code that reads from both rails (eg an +// Electron app or a desktop CLI sharing a UI lib) doesn't need to +// branch per environment. + +import { GrpcWebFetchTransport } from "@protobuf-ts/grpcweb-transport"; +import { SentrixClient as InnerClient } from "./sentrix.client.js"; +import { + GetBlockRequest, + GetBalanceRequest, + GetValidatorSetRequest, + GetSupplyRequest, + GetMempoolRequest, + StreamEventsRequest, +} from "./sentrix.js"; +import type { + Block, + Account, + ValidatorSet, + Supply, + Mempool, + ChainEvent, + EventFilter, +} from "./sentrix.js"; +import type { SentrixNetwork } from "../network.js"; + +export interface GrpcWebClientOptions { + /** Override the gRPC-Web endpoint host. Defaults to the network's + * public endpoint (`https://grpc.sentrixchain.com` mainnet, + * `https://grpc-testnet.sentrixchain.com` testnet). Must include the + * scheme — gRPC-Web speaks plain HTTP framing on top of TLS, so the + * URL is `https://...` not `grpc://...`. */ + endpoint?: string; + /** Pass through to fetch — useful for credentials / cookies in + * authenticated proxy setups. */ + fetchInit?: Partial; +} + +/** Browser-friendly gRPC-Web client. Same surface as the Node-side + * `@sentrix/chain/grpc` client; pick the subpath that fits your + * runtime. */ +export class GrpcWebClient { + private readonly inner: InnerClient; + + constructor(network: SentrixNetwork, opts: GrpcWebClientOptions = {}) { + const endpoint = opts.endpoint ?? defaultEndpoint(network); + const transport = new GrpcWebFetchTransport({ + baseUrl: endpoint, + fetchInit: opts.fetchInit, + }); + this.inner = new InnerClient(transport); + } + + /** GetBlock { latest: true } — latest finalised block. */ + async getLatestBlock(): Promise { + const req = GetBlockRequest.create({ selector: { oneofKind: "latest", latest: true } }); + return (await this.inner.getBlock(req)).response; + } + + /** GetBlock { height } — block at a specific height. Throws if the + * chain pruned it. */ + async getBlockByHeight(height: bigint | number): Promise { + const req = GetBlockRequest.create({ + selector: { + oneofKind: "height", + height: { value: BigInt(height) }, + }, + }); + return (await this.inner.getBlock(req)).response; + } + + /** GetBalance — current balance for a 20-byte address. */ + async getBalance(address: string | Uint8Array): Promise { + const bytes = + typeof address === "string" ? hexToBytes(address) : address; + if (bytes.length !== 20) { + throw new Error( + `@sentrix/chain/grpc-web: address must be 20 bytes (got ${bytes.length})`, + ); + } + const req = GetBalanceRequest.create({ address: { value: bytes } }); + return (await this.inner.getBalance(req)).response; + } + + /** v0.4+ — ValidatorSet snapshot. */ + async getValidatorSet(atHeight?: bigint | number): Promise { + const req = GetValidatorSetRequest.create( + atHeight !== undefined + ? { atHeight: { value: BigInt(atHeight) } } + : {}, + ); + return (await this.inner.getValidatorSet(req)).response; + } + + /** v0.4+ — Supply snapshot. */ + async getSupply(atHeight?: bigint | number): Promise { + const req = GetSupplyRequest.create( + atHeight !== undefined + ? { atHeight: { value: BigInt(atHeight) } } + : {}, + ); + return (await this.inner.getSupply(req)).response; + } + + /** v0.4+ — Mempool snapshot. `limit = 0` ⇒ server default (100). */ + async getMempool(limit = 100): Promise { + const req = GetMempoolRequest.create({ limit }); + return (await this.inner.getMempool(req)).response; + } + + /** v0.4+ — server-streaming chain events. Drain with for-await: + * + * for await (const ev of client.streamEvents([])) { … } + * + * Empty filter list = subscribe-all. */ + async *streamEvents(filters: EventFilter[] = []): AsyncIterable { + const req = StreamEventsRequest.create({ filters, fromSequence: 0n }); + const call = this.inner.streamEvents(req); + for await (const ev of call.responses) { + yield ev; + } + } +} + +function defaultEndpoint(network: SentrixNetwork): string { + return network === "mainnet" + ? "https://grpc.sentrixchain.com" + : "https://grpc-testnet.sentrixchain.com"; +} + +function hexToBytes(hex: string): Uint8Array { + const stripped = hex.startsWith("0x") ? hex.slice(2) : hex; + if (stripped.length % 2 !== 0) { + throw new Error(`@sentrix/chain/grpc-web: hex address has odd length: ${stripped.length}`); + } + const out = new Uint8Array(stripped.length / 2); + for (let i = 0; i < out.length; i++) { + out[i] = parseInt(stripped.slice(i * 2, i * 2 + 2), 16); + } + return out; +} diff --git a/src/grpc-web/sentrix.client.ts b/src/grpc-web/sentrix.client.ts new file mode 100644 index 0000000..7a50b39 --- /dev/null +++ b/src/grpc-web/sentrix.client.ts @@ -0,0 +1,197 @@ +// @generated by protobuf-ts 2.11.1 +// @generated from protobuf file "sentrix.proto" (package "sentrix.v1", syntax proto3) +// tslint:disable +// +// Sentrix gRPC service v0.1 — package sentrix.v1. +// +// Parallel transport to JSON-RPC at port 8545. Same backend, same state, +// different wire format. Methods here mirror the most common JSON-RPC paths +// plus add a server-streaming variant for events that JSON-RPC + WebSocket +// can express but at a higher per-subscriber cost. +// +// Versioning: "sentrix.v1" is a hard contract. Breaking changes go to +// "sentrix.v2" with v1 retained for ≥ 2 minor releases overlap. +// +// Status: v0.1 skeleton. Handlers in crates/sentrix-grpc/src/lib.rs return +// tonic::Status::unimplemented until main.rs integration lands. Reference +// design doc: founder-private/audits/2026-05-05-grpc-service-proto-draft.md. +// +import type { RpcTransport } from "@protobuf-ts/runtime-rpc"; +import type { ServiceInfo } from "@protobuf-ts/runtime-rpc"; +import { Sentrix } from "./sentrix.js"; +import type { ChainEvent } from "./sentrix.js"; +import type { StreamEventsRequest } from "./sentrix.js"; +import type { ServerStreamingCall } from "@protobuf-ts/runtime-rpc"; +import type { Mempool } from "./sentrix.js"; +import type { GetMempoolRequest } from "./sentrix.js"; +import type { Supply } from "./sentrix.js"; +import type { GetSupplyRequest } from "./sentrix.js"; +import type { ValidatorSet } from "./sentrix.js"; +import type { GetValidatorSetRequest } from "./sentrix.js"; +import type { Account } from "./sentrix.js"; +import type { GetBalanceRequest } from "./sentrix.js"; +import type { Block } from "./sentrix.js"; +import type { GetBlockRequest } from "./sentrix.js"; +import { stackIntercept } from "@protobuf-ts/runtime-rpc"; +import type { BroadcastTxResponse } from "./sentrix.js"; +import type { BroadcastTxRequest } from "./sentrix.js"; +import type { UnaryCall } from "@protobuf-ts/runtime-rpc"; +import type { RpcOptions } from "@protobuf-ts/runtime-rpc"; +/** + * ──────────────────────────────────────────────────────────── + * Service definition + * ──────────────────────────────────────────────────────────── + * + * @generated from protobuf service sentrix.v1.Sentrix + */ +export interface ISentrixClient { + /** + * Submit a signed transaction to the local mempool. Same semantics as + * JSON-RPC eth_sendRawTransaction for EVM txs, with native fields exposed + * for staking-ops and other native variants. + * + * @generated from protobuf rpc: BroadcastTx + */ + broadcastTx(input: BroadcastTxRequest, options?: RpcOptions): UnaryCall; + /** + * Fetch a block by height OR by hash. Returns NOT_FOUND if outside the + * local chain window (currently 1000 blocks; older blocks need indexer). + * + * @generated from protobuf rpc: GetBlock + */ + getBlock(input: GetBlockRequest, options?: RpcOptions): UnaryCall; + /** + * Fetch account balance + nonce. Mirrors eth_getBalance + + * eth_getTransactionCount in a single round-trip. Includes mempool-pending + * nonce so wallets build correct next-tx without an extra call (matches + * the pending-aware nonce behaviour from chain v2.1.57). + * + * @generated from protobuf rpc: GetBalance + */ + getBalance(input: GetBalanceRequest, options?: RpcOptions): UnaryCall; + /** + * v0.4 read-only state queries — drop the REST `/sentrix_status_extended` + * bridge from the explorer's stats hot path. All three are pure reads + * off `state.read()` snapshots; same lock contention profile as + * GetBlock/GetBalance. + * + * Active validator set + per-validator stake/active/jailed flags. + * + * @generated from protobuf rpc: GetValidatorSet + */ + getValidatorSet(input: GetValidatorSetRequest, options?: RpcOptions): UnaryCall; + /** + * Native-token supply snapshot (minted, burned, circulating). + * + * @generated from protobuf rpc: GetSupply + */ + getSupply(input: GetSupplyRequest, options?: RpcOptions): UnaryCall; + /** + * Pending-tx count + a capped header window for UI display. + * + * @generated from protobuf rpc: GetMempool + */ + getMempool(input: GetMempoolRequest, options?: RpcOptions): UnaryCall; + /** + * Server-streaming chain events. Subscribe once, receive every event type + * until cancel or server restart. Replaces N separate eth_subscribe calls. + * Backpressure: server bounded channel per stream (capacity 4096 — same as + * event_tx in chain). On slow client, server drops OLDEST events and emits + * a StreamLagged sentinel. Client should resync state from RPC. + * + * @generated from protobuf rpc: StreamEvents + */ + streamEvents(input: StreamEventsRequest, options?: RpcOptions): ServerStreamingCall; +} +/** + * ──────────────────────────────────────────────────────────── + * Service definition + * ──────────────────────────────────────────────────────────── + * + * @generated from protobuf service sentrix.v1.Sentrix + */ +export class SentrixClient implements ISentrixClient, ServiceInfo { + typeName = Sentrix.typeName; + methods = Sentrix.methods; + options = Sentrix.options; + constructor(private readonly _transport: RpcTransport) { + } + /** + * Submit a signed transaction to the local mempool. Same semantics as + * JSON-RPC eth_sendRawTransaction for EVM txs, with native fields exposed + * for staking-ops and other native variants. + * + * @generated from protobuf rpc: BroadcastTx + */ + broadcastTx(input: BroadcastTxRequest, options?: RpcOptions): UnaryCall { + const method = this.methods[0], opt = this._transport.mergeOptions(options); + return stackIntercept("unary", this._transport, method, opt, input); + } + /** + * Fetch a block by height OR by hash. Returns NOT_FOUND if outside the + * local chain window (currently 1000 blocks; older blocks need indexer). + * + * @generated from protobuf rpc: GetBlock + */ + getBlock(input: GetBlockRequest, options?: RpcOptions): UnaryCall { + const method = this.methods[1], opt = this._transport.mergeOptions(options); + return stackIntercept("unary", this._transport, method, opt, input); + } + /** + * Fetch account balance + nonce. Mirrors eth_getBalance + + * eth_getTransactionCount in a single round-trip. Includes mempool-pending + * nonce so wallets build correct next-tx without an extra call (matches + * the pending-aware nonce behaviour from chain v2.1.57). + * + * @generated from protobuf rpc: GetBalance + */ + getBalance(input: GetBalanceRequest, options?: RpcOptions): UnaryCall { + const method = this.methods[2], opt = this._transport.mergeOptions(options); + return stackIntercept("unary", this._transport, method, opt, input); + } + /** + * v0.4 read-only state queries — drop the REST `/sentrix_status_extended` + * bridge from the explorer's stats hot path. All three are pure reads + * off `state.read()` snapshots; same lock contention profile as + * GetBlock/GetBalance. + * + * Active validator set + per-validator stake/active/jailed flags. + * + * @generated from protobuf rpc: GetValidatorSet + */ + getValidatorSet(input: GetValidatorSetRequest, options?: RpcOptions): UnaryCall { + const method = this.methods[3], opt = this._transport.mergeOptions(options); + return stackIntercept("unary", this._transport, method, opt, input); + } + /** + * Native-token supply snapshot (minted, burned, circulating). + * + * @generated from protobuf rpc: GetSupply + */ + getSupply(input: GetSupplyRequest, options?: RpcOptions): UnaryCall { + const method = this.methods[4], opt = this._transport.mergeOptions(options); + return stackIntercept("unary", this._transport, method, opt, input); + } + /** + * Pending-tx count + a capped header window for UI display. + * + * @generated from protobuf rpc: GetMempool + */ + getMempool(input: GetMempoolRequest, options?: RpcOptions): UnaryCall { + const method = this.methods[5], opt = this._transport.mergeOptions(options); + return stackIntercept("unary", this._transport, method, opt, input); + } + /** + * Server-streaming chain events. Subscribe once, receive every event type + * until cancel or server restart. Replaces N separate eth_subscribe calls. + * Backpressure: server bounded channel per stream (capacity 4096 — same as + * event_tx in chain). On slow client, server drops OLDEST events and emits + * a StreamLagged sentinel. Client should resync state from RPC. + * + * @generated from protobuf rpc: StreamEvents + */ + streamEvents(input: StreamEventsRequest, options?: RpcOptions): ServerStreamingCall { + const method = this.methods[6], opt = this._transport.mergeOptions(options); + return stackIntercept("serverStreaming", this._transport, method, opt, input); + } +} diff --git a/src/grpc-web/sentrix.ts b/src/grpc-web/sentrix.ts new file mode 100644 index 0000000..551c9e0 --- /dev/null +++ b/src/grpc-web/sentrix.ts @@ -0,0 +1,2286 @@ +// @generated by protobuf-ts 2.11.1 +// @generated from protobuf file "sentrix.proto" (package "sentrix.v1", syntax proto3) +// tslint:disable +// +// Sentrix gRPC service v0.1 — package sentrix.v1. +// +// Parallel transport to JSON-RPC at port 8545. Same backend, same state, +// different wire format. Methods here mirror the most common JSON-RPC paths +// plus add a server-streaming variant for events that JSON-RPC + WebSocket +// can express but at a higher per-subscriber cost. +// +// Versioning: "sentrix.v1" is a hard contract. Breaking changes go to +// "sentrix.v2" with v1 retained for ≥ 2 minor releases overlap. +// +// Status: v0.1 skeleton. Handlers in crates/sentrix-grpc/src/lib.rs return +// tonic::Status::unimplemented until main.rs integration lands. Reference +// design doc: founder-private/audits/2026-05-05-grpc-service-proto-draft.md. +// +import { ServiceType } from "@protobuf-ts/runtime-rpc"; +import type { BinaryWriteOptions } from "@protobuf-ts/runtime"; +import type { IBinaryWriter } from "@protobuf-ts/runtime"; +import { WireType } from "@protobuf-ts/runtime"; +import type { BinaryReadOptions } from "@protobuf-ts/runtime"; +import type { IBinaryReader } from "@protobuf-ts/runtime"; +import { UnknownFieldHandler } from "@protobuf-ts/runtime"; +import type { PartialMessage } from "@protobuf-ts/runtime"; +import { reflectionMergePartial } from "@protobuf-ts/runtime"; +import { MessageType } from "@protobuf-ts/runtime"; +/** + * 20-byte EVM-compatible address. Mirror of sentrix-primitives::Address. + * Wire = bytes (NOT hex string) for binary efficiency. + * + * @generated from protobuf message sentrix.v1.Address + */ +export interface Address { + /** + * @generated from protobuf field: bytes value = 1 + */ + value: Uint8Array; // exactly 20 bytes +} +/** + * 32-byte hash — block hash, tx hash, state root. + * + * @generated from protobuf message sentrix.v1.Hash + */ +export interface Hash { + /** + * @generated from protobuf field: bytes value = 1 + */ + value: Uint8Array; // exactly 32 bytes +} +/** + * Native amount — sentri (10^-8 SRX). u64 wire to match Sentrix internal. + * + * @generated from protobuf message sentrix.v1.Amount + */ +export interface Amount { + /** + * @generated from protobuf field: uint64 sentri = 1 + */ + sentri: bigint; +} +/** + * Block height — u64 starting at 0 (genesis). + * + * @generated from protobuf message sentrix.v1.BlockHeight + */ +export interface BlockHeight { + /** + * @generated from protobuf field: uint64 value = 1 + */ + value: bigint; +} +/** + * Mirror of sentrix-primitives::Transaction. Identical wire format to chain + * MDBX serialisation (modulo prost-encoding). Field numbers match the + * canonical struct order; do NOT renumber on changes. + * + * @generated from protobuf message sentrix.v1.Transaction + */ +export interface Transaction { + /** + * @generated from protobuf field: sentrix.v1.Hash txid = 1 + */ + txid?: Hash; + /** + * @generated from protobuf field: sentrix.v1.Address from_address = 2 + */ + fromAddress?: Address; + /** + * @generated from protobuf field: sentrix.v1.Address to_address = 3 + */ + toAddress?: Address; + /** + * @generated from protobuf field: sentrix.v1.Amount amount = 4 + */ + amount?: Amount; + /** + * @generated from protobuf field: sentrix.v1.Amount fee = 5 + */ + fee?: Amount; + /** + * @generated from protobuf field: uint64 nonce = 6 + */ + nonce: bigint; + /** + * @generated from protobuf field: uint64 timestamp = 7 + */ + timestamp: bigint; + /** + * @generated from protobuf field: bytes signature = 8 + */ + signature: Uint8Array; // 64-byte ed25519 OR 65-byte secp256k1 + /** + * @generated from protobuf field: bytes payload = 9 + */ + payload: Uint8Array; // contract calldata (EVM) or staking-op blob + /** + * @generated from protobuf field: uint32 chain_id = 10 + */ + chainId: number; + /** + * @generated from protobuf field: uint32 tx_type = 11 + */ + txType: number; // 0 = transfer, 1 = contract, 2 = staking-op +} +/** + * @generated from protobuf message sentrix.v1.Block + */ +export interface Block { + /** + * @generated from protobuf field: uint64 index = 1 + */ + index: bigint; + /** + * @generated from protobuf field: sentrix.v1.Hash hash = 2 + */ + hash?: Hash; + /** + * @generated from protobuf field: sentrix.v1.Hash parent_hash = 3 + */ + parentHash?: Hash; + /** + * @generated from protobuf field: sentrix.v1.Hash state_root = 4 + */ + stateRoot?: Hash; + /** + * @generated from protobuf field: uint64 timestamp = 5 + */ + timestamp: bigint; + /** + * @generated from protobuf field: sentrix.v1.Address proposer = 6 + */ + proposer?: Address; + /** + * @generated from protobuf field: uint32 round = 7 + */ + round: number; + /** + * @generated from protobuf field: repeated sentrix.v1.Transaction transactions = 8 + */ + transactions: Transaction[]; + /** + * BFT justification carried from validator-side; included for audit. + * Empty for blocks at h<100_000 (pre state-root-fork). + * + * @generated from protobuf field: bytes justification = 9 + */ + justification: Uint8Array; +} +/** + * @generated from protobuf message sentrix.v1.Account + */ +export interface Account { + /** + * @generated from protobuf field: sentrix.v1.Address address = 1 + */ + address?: Address; + /** + * @generated from protobuf field: sentrix.v1.Amount balance = 2 + */ + balance?: Amount; + /** + * @generated from protobuf field: uint64 nonce = 3 + */ + nonce: bigint; + /** + * For contract accounts: 32-byte storage root + non-empty code_hash. + * + * @generated from protobuf field: sentrix.v1.Hash storage_root = 4 + */ + storageRoot?: Hash; + /** + * @generated from protobuf field: sentrix.v1.Hash code_hash = 5 + */ + codeHash?: Hash; +} +/** + * Server-streaming event types. + * + * @generated from protobuf message sentrix.v1.ChainEvent + */ +export interface ChainEvent { + /** + * @generated from protobuf oneof: event + */ + event: { + oneofKind: "blockFinalized"; + /** + * @generated from protobuf field: sentrix.v1.BlockFinalized block_finalized = 1 + */ + blockFinalized: BlockFinalized; + } | { + oneofKind: "pendingTx"; + /** + * @generated from protobuf field: sentrix.v1.PendingTx pending_tx = 2 + */ + pendingTx: PendingTx; + } | { + oneofKind: "validatorSetChange"; + /** + * @generated from protobuf field: sentrix.v1.ValidatorSetChange validator_set_change = 3 + */ + validatorSetChange: ValidatorSetChange; + } | { + oneofKind: "log"; + /** + * @generated from protobuf field: sentrix.v1.LogEmitted log = 4 + */ + log: LogEmitted; + } | { + oneofKind: "lagged"; + /** + * Synthetic Lagged sentinel — emitted when the per-subscriber broadcast + * channel drops oldest events (slow consumer). Mirrors tokio broadcast + * RecvError::Lagged semantics. Consumer should resync state from RPC. + * + * @generated from protobuf field: sentrix.v1.StreamLagged lagged = 5 + */ + lagged: StreamLagged; + } | { + oneofKind: undefined; + }; + /** + * @generated from protobuf field: uint64 sequence = 100 + */ + sequence: bigint; // monotonic across all events on this stream + /** + * @generated from protobuf field: uint64 timestamp = 101 + */ + timestamp: bigint; // server-wall-clock unix seconds +} +/** + * @generated from protobuf message sentrix.v1.BlockFinalized + */ +export interface BlockFinalized { + /** + * @generated from protobuf field: sentrix.v1.Block block = 1 + */ + block?: Block; +} +/** + * @generated from protobuf message sentrix.v1.PendingTx + */ +export interface PendingTx { + /** + * @generated from protobuf field: sentrix.v1.Transaction tx = 1 + */ + tx?: Transaction; +} +/** + * @generated from protobuf message sentrix.v1.ValidatorSetChange + */ +export interface ValidatorSetChange { + /** + * @generated from protobuf field: uint32 epoch = 1 + */ + epoch: number; + /** + * @generated from protobuf field: repeated sentrix.v1.Address active = 2 + */ + active: Address[]; + /** + * @generated from protobuf field: repeated sentrix.v1.Address jailed = 3 + */ + jailed: Address[]; +} +/** + * @generated from protobuf message sentrix.v1.LogEmitted + */ +export interface LogEmitted { + /** + * @generated from protobuf field: sentrix.v1.Address contract = 1 + */ + contract?: Address; + /** + * @generated from protobuf field: repeated sentrix.v1.Hash topics = 2 + */ + topics: Hash[]; // 0..4 topics per EVM convention + /** + * @generated from protobuf field: bytes data = 3 + */ + data: Uint8Array; + /** + * @generated from protobuf field: sentrix.v1.Hash tx_hash = 4 + */ + txHash?: Hash; + /** + * @generated from protobuf field: uint64 block_height = 5 + */ + blockHeight: bigint; + /** + * @generated from protobuf field: uint32 log_index = 6 + */ + logIndex: number; +} +/** + * @generated from protobuf message sentrix.v1.StreamLagged + */ +export interface StreamLagged { + /** + * @generated from protobuf field: uint64 skipped_count = 1 + */ + skippedCount: bigint; // events dropped since last delivery +} +/** + * @generated from protobuf message sentrix.v1.BroadcastTxRequest + */ +export interface BroadcastTxRequest { + /** + * @generated from protobuf field: sentrix.v1.Transaction tx = 1 + */ + tx?: Transaction; +} +/** + * @generated from protobuf message sentrix.v1.BroadcastTxResponse + */ +export interface BroadcastTxResponse { + /** + * @generated from protobuf field: sentrix.v1.Hash txid = 1 + */ + txid?: Hash; + /** + * @generated from protobuf field: uint64 mempool_position = 2 + */ + mempoolPosition: bigint; // 0-indexed; FIFO ordering UX +} +/** + * @generated from protobuf message sentrix.v1.GetBlockRequest + */ +export interface GetBlockRequest { + /** + * @generated from protobuf oneof: selector + */ + selector: { + oneofKind: "height"; + /** + * @generated from protobuf field: sentrix.v1.BlockHeight height = 1 + */ + height: BlockHeight; + } | { + oneofKind: "hash"; + /** + * @generated from protobuf field: sentrix.v1.Hash hash = 2 + */ + hash: Hash; + } | { + oneofKind: "latest"; + /** + * @generated from protobuf field: bool latest = 3 + */ + latest: boolean; // selector == "latest" shorthand + } | { + oneofKind: "finalized"; + /** + * @generated from protobuf field: bool finalized = 4 + */ + finalized: boolean; // selector == "finalized" (BFT-finalized head) + } | { + oneofKind: undefined; + }; +} +/** + * @generated from protobuf message sentrix.v1.GetBalanceRequest + */ +export interface GetBalanceRequest { + /** + * @generated from protobuf field: sentrix.v1.Address address = 1 + */ + address?: Address; + /** + * Snapshot height — read state as-of this block. Default = latest. + * Returns FAILED_PRECONDITION if outside chain window. + * + * @generated from protobuf field: optional sentrix.v1.BlockHeight at_height = 2 + */ + atHeight?: BlockHeight; +} +/** + * @generated from protobuf message sentrix.v1.StreamEventsRequest + */ +export interface StreamEventsRequest { + /** + * Filter set — empty = subscribe to all event types. Backend filters + * server-side so the wire only carries matched events. + * + * @generated from protobuf field: repeated sentrix.v1.EventFilter filters = 1 + */ + filters: EventFilter[]; + /** + * Resume from a sequence number (0 = current head). Backend keeps last + * 4096 events in a ring buffer — beyond that, sequence is not resumable + * and the server returns FAILED_PRECONDITION. + * + * @generated from protobuf field: uint64 from_sequence = 2 + */ + fromSequence: bigint; +} +// ──────────────────────────────────────────────────────────── +// v0.4 read-only state-query messages +// ──────────────────────────────────────────────────────────── + +/** + * @generated from protobuf message sentrix.v1.GetValidatorSetRequest + */ +export interface GetValidatorSetRequest { + /** + * Reserved for at_height historical reads — gated on MDBX snapshot + * isolation (Refactor 5). v0.4 returns the latest finalized set. + * + * @generated from protobuf field: optional sentrix.v1.BlockHeight at_height = 1 + */ + atHeight?: BlockHeight; +} +/** + * @generated from protobuf message sentrix.v1.ValidatorSet + */ +export interface ValidatorSet { + /** + * @generated from protobuf field: uint32 epoch = 1 + */ + epoch: number; + /** + * @generated from protobuf field: uint32 active_count = 2 + */ + activeCount: number; + /** + * @generated from protobuf field: uint32 total_count = 3 + */ + totalCount: number; + /** + * Total stake across the active set, in sentri (10^-8 SRX). + * + * @generated from protobuf field: uint64 total_active_stake_sentri = 4 + */ + totalActiveStakeSentri: bigint; + /** + * @generated from protobuf field: repeated sentrix.v1.ValidatorEntry validators = 5 + */ + validators: ValidatorEntry[]; +} +/** + * @generated from protobuf message sentrix.v1.ValidatorEntry + */ +export interface ValidatorEntry { + /** + * @generated from protobuf field: sentrix.v1.Address address = 1 + */ + address?: Address; + /** + * @generated from protobuf field: uint64 stake_sentri = 2 + */ + stakeSentri: bigint; + /** + * @generated from protobuf field: bool active = 3 + */ + active: boolean; + /** + * @generated from protobuf field: bool jailed = 4 + */ + jailed: boolean; +} +/** + * @generated from protobuf message sentrix.v1.GetSupplyRequest + */ +export interface GetSupplyRequest { + /** + * @generated from protobuf field: optional sentrix.v1.BlockHeight at_height = 1 + */ + atHeight?: BlockHeight; +} +/** + * @generated from protobuf message sentrix.v1.Supply + */ +export interface Supply { + /** + * sentri = 10^-8 SRX. Cap is fork-gated (210M pre-fork, 315M post- + * tokenomics-v2 at h=640800); leave conversion to display layer. + * + * @generated from protobuf field: uint64 minted_sentri = 1 + */ + mintedSentri: bigint; + /** + * @generated from protobuf field: uint64 burned_sentri = 2 + */ + burnedSentri: bigint; + /** + * @generated from protobuf field: uint64 circulating_sentri = 3 + */ + circulatingSentri: bigint; // = minted − burned +} +/** + * @generated from protobuf message sentrix.v1.GetMempoolRequest + */ +export interface GetMempoolRequest { + /** + * Cap returned tx headers; default 100, max 500. Larger windows need + * pagination (deferred). 0 = use server default (100). + * + * @generated from protobuf field: uint32 limit = 1 + */ + limit: number; +} +/** + * @generated from protobuf message sentrix.v1.Mempool + */ +export interface Mempool { + /** + * Authoritative pending-tx count. `entries` is capped by `limit`; + * size always reflects the full mempool depth. + * + * @generated from protobuf field: uint32 size = 1 + */ + size: number; + /** + * @generated from protobuf field: repeated sentrix.v1.MempoolEntry entries = 2 + */ + entries: MempoolEntry[]; +} +/** + * @generated from protobuf message sentrix.v1.MempoolEntry + */ +export interface MempoolEntry { + /** + * @generated from protobuf field: sentrix.v1.Hash txid = 1 + */ + txid?: Hash; + /** + * @generated from protobuf field: sentrix.v1.Address from_address = 2 + */ + fromAddress?: Address; + /** + * @generated from protobuf field: sentrix.v1.Address to_address = 3 + */ + toAddress?: Address; + /** + * @generated from protobuf field: sentrix.v1.Amount amount = 4 + */ + amount?: Amount; + /** + * @generated from protobuf field: sentrix.v1.Amount fee = 5 + */ + fee?: Amount; + /** + * @generated from protobuf field: uint64 nonce = 6 + */ + nonce: bigint; + /** + * @generated from protobuf field: uint32 tx_type = 7 + */ + txType: number; +} +/** + * @generated from protobuf enum sentrix.v1.EventFilter + */ +export enum EventFilter { + /** + * @generated from protobuf enum value: EVENT_FILTER_UNSPECIFIED = 0; + */ + UNSPECIFIED = 0, + /** + * @generated from protobuf enum value: EVENT_FILTER_BLOCK_FINALIZED = 1; + */ + BLOCK_FINALIZED = 1, + /** + * @generated from protobuf enum value: EVENT_FILTER_PENDING_TX = 2; + */ + PENDING_TX = 2, + /** + * @generated from protobuf enum value: EVENT_FILTER_VALIDATOR_SET = 3; + */ + VALIDATOR_SET = 3, + /** + * @generated from protobuf enum value: EVENT_FILTER_LOG = 4; + */ + LOG = 4 +} +// @generated message type with reflection information, may provide speed optimized methods +class Address$Type extends MessageType
{ + constructor() { + super("sentrix.v1.Address", [ + { no: 1, name: "value", kind: "scalar", T: 12 /*ScalarType.BYTES*/ } + ]); + } + create(value?: PartialMessage
): Address { + const message = globalThis.Object.create((this.messagePrototype!)); + message.value = new Uint8Array(0); + if (value !== undefined) + reflectionMergePartial
(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Address): Address { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* bytes value */ 1: + message.value = reader.bytes(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: Address, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* bytes value = 1; */ + if (message.value.length) + writer.tag(1, WireType.LengthDelimited).bytes(message.value); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.Address + */ +export const Address = new Address$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class Hash$Type extends MessageType { + constructor() { + super("sentrix.v1.Hash", [ + { no: 1, name: "value", kind: "scalar", T: 12 /*ScalarType.BYTES*/ } + ]); + } + create(value?: PartialMessage): Hash { + const message = globalThis.Object.create((this.messagePrototype!)); + message.value = new Uint8Array(0); + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Hash): Hash { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* bytes value */ 1: + message.value = reader.bytes(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: Hash, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* bytes value = 1; */ + if (message.value.length) + writer.tag(1, WireType.LengthDelimited).bytes(message.value); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.Hash + */ +export const Hash = new Hash$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class Amount$Type extends MessageType { + constructor() { + super("sentrix.v1.Amount", [ + { no: 1, name: "sentri", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ } + ]); + } + create(value?: PartialMessage): Amount { + const message = globalThis.Object.create((this.messagePrototype!)); + message.sentri = 0n; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Amount): Amount { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* uint64 sentri */ 1: + message.sentri = reader.uint64().toBigInt(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: Amount, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* uint64 sentri = 1; */ + if (message.sentri !== 0n) + writer.tag(1, WireType.Varint).uint64(message.sentri); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.Amount + */ +export const Amount = new Amount$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class BlockHeight$Type extends MessageType { + constructor() { + super("sentrix.v1.BlockHeight", [ + { no: 1, name: "value", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ } + ]); + } + create(value?: PartialMessage): BlockHeight { + const message = globalThis.Object.create((this.messagePrototype!)); + message.value = 0n; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: BlockHeight): BlockHeight { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* uint64 value */ 1: + message.value = reader.uint64().toBigInt(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: BlockHeight, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* uint64 value = 1; */ + if (message.value !== 0n) + writer.tag(1, WireType.Varint).uint64(message.value); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.BlockHeight + */ +export const BlockHeight = new BlockHeight$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class Transaction$Type extends MessageType { + constructor() { + super("sentrix.v1.Transaction", [ + { no: 1, name: "txid", kind: "message", T: () => Hash }, + { no: 2, name: "from_address", kind: "message", T: () => Address }, + { no: 3, name: "to_address", kind: "message", T: () => Address }, + { no: 4, name: "amount", kind: "message", T: () => Amount }, + { no: 5, name: "fee", kind: "message", T: () => Amount }, + { no: 6, name: "nonce", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }, + { no: 7, name: "timestamp", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }, + { no: 8, name: "signature", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, + { no: 9, name: "payload", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, + { no: 10, name: "chain_id", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, + { no: 11, name: "tx_type", kind: "scalar", T: 13 /*ScalarType.UINT32*/ } + ]); + } + create(value?: PartialMessage): Transaction { + const message = globalThis.Object.create((this.messagePrototype!)); + message.nonce = 0n; + message.timestamp = 0n; + message.signature = new Uint8Array(0); + message.payload = new Uint8Array(0); + message.chainId = 0; + message.txType = 0; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Transaction): Transaction { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* sentrix.v1.Hash txid */ 1: + message.txid = Hash.internalBinaryRead(reader, reader.uint32(), options, message.txid); + break; + case /* sentrix.v1.Address from_address */ 2: + message.fromAddress = Address.internalBinaryRead(reader, reader.uint32(), options, message.fromAddress); + break; + case /* sentrix.v1.Address to_address */ 3: + message.toAddress = Address.internalBinaryRead(reader, reader.uint32(), options, message.toAddress); + break; + case /* sentrix.v1.Amount amount */ 4: + message.amount = Amount.internalBinaryRead(reader, reader.uint32(), options, message.amount); + break; + case /* sentrix.v1.Amount fee */ 5: + message.fee = Amount.internalBinaryRead(reader, reader.uint32(), options, message.fee); + break; + case /* uint64 nonce */ 6: + message.nonce = reader.uint64().toBigInt(); + break; + case /* uint64 timestamp */ 7: + message.timestamp = reader.uint64().toBigInt(); + break; + case /* bytes signature */ 8: + message.signature = reader.bytes(); + break; + case /* bytes payload */ 9: + message.payload = reader.bytes(); + break; + case /* uint32 chain_id */ 10: + message.chainId = reader.uint32(); + break; + case /* uint32 tx_type */ 11: + message.txType = reader.uint32(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: Transaction, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* sentrix.v1.Hash txid = 1; */ + if (message.txid) + Hash.internalBinaryWrite(message.txid, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.Address from_address = 2; */ + if (message.fromAddress) + Address.internalBinaryWrite(message.fromAddress, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.Address to_address = 3; */ + if (message.toAddress) + Address.internalBinaryWrite(message.toAddress, writer.tag(3, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.Amount amount = 4; */ + if (message.amount) + Amount.internalBinaryWrite(message.amount, writer.tag(4, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.Amount fee = 5; */ + if (message.fee) + Amount.internalBinaryWrite(message.fee, writer.tag(5, WireType.LengthDelimited).fork(), options).join(); + /* uint64 nonce = 6; */ + if (message.nonce !== 0n) + writer.tag(6, WireType.Varint).uint64(message.nonce); + /* uint64 timestamp = 7; */ + if (message.timestamp !== 0n) + writer.tag(7, WireType.Varint).uint64(message.timestamp); + /* bytes signature = 8; */ + if (message.signature.length) + writer.tag(8, WireType.LengthDelimited).bytes(message.signature); + /* bytes payload = 9; */ + if (message.payload.length) + writer.tag(9, WireType.LengthDelimited).bytes(message.payload); + /* uint32 chain_id = 10; */ + if (message.chainId !== 0) + writer.tag(10, WireType.Varint).uint32(message.chainId); + /* uint32 tx_type = 11; */ + if (message.txType !== 0) + writer.tag(11, WireType.Varint).uint32(message.txType); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.Transaction + */ +export const Transaction = new Transaction$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class Block$Type extends MessageType { + constructor() { + super("sentrix.v1.Block", [ + { no: 1, name: "index", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }, + { no: 2, name: "hash", kind: "message", T: () => Hash }, + { no: 3, name: "parent_hash", kind: "message", T: () => Hash }, + { no: 4, name: "state_root", kind: "message", T: () => Hash }, + { no: 5, name: "timestamp", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }, + { no: 6, name: "proposer", kind: "message", T: () => Address }, + { no: 7, name: "round", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, + { no: 8, name: "transactions", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => Transaction }, + { no: 9, name: "justification", kind: "scalar", T: 12 /*ScalarType.BYTES*/ } + ]); + } + create(value?: PartialMessage): Block { + const message = globalThis.Object.create((this.messagePrototype!)); + message.index = 0n; + message.timestamp = 0n; + message.round = 0; + message.transactions = []; + message.justification = new Uint8Array(0); + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Block): Block { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* uint64 index */ 1: + message.index = reader.uint64().toBigInt(); + break; + case /* sentrix.v1.Hash hash */ 2: + message.hash = Hash.internalBinaryRead(reader, reader.uint32(), options, message.hash); + break; + case /* sentrix.v1.Hash parent_hash */ 3: + message.parentHash = Hash.internalBinaryRead(reader, reader.uint32(), options, message.parentHash); + break; + case /* sentrix.v1.Hash state_root */ 4: + message.stateRoot = Hash.internalBinaryRead(reader, reader.uint32(), options, message.stateRoot); + break; + case /* uint64 timestamp */ 5: + message.timestamp = reader.uint64().toBigInt(); + break; + case /* sentrix.v1.Address proposer */ 6: + message.proposer = Address.internalBinaryRead(reader, reader.uint32(), options, message.proposer); + break; + case /* uint32 round */ 7: + message.round = reader.uint32(); + break; + case /* repeated sentrix.v1.Transaction transactions */ 8: + message.transactions.push(Transaction.internalBinaryRead(reader, reader.uint32(), options)); + break; + case /* bytes justification */ 9: + message.justification = reader.bytes(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: Block, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* uint64 index = 1; */ + if (message.index !== 0n) + writer.tag(1, WireType.Varint).uint64(message.index); + /* sentrix.v1.Hash hash = 2; */ + if (message.hash) + Hash.internalBinaryWrite(message.hash, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.Hash parent_hash = 3; */ + if (message.parentHash) + Hash.internalBinaryWrite(message.parentHash, writer.tag(3, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.Hash state_root = 4; */ + if (message.stateRoot) + Hash.internalBinaryWrite(message.stateRoot, writer.tag(4, WireType.LengthDelimited).fork(), options).join(); + /* uint64 timestamp = 5; */ + if (message.timestamp !== 0n) + writer.tag(5, WireType.Varint).uint64(message.timestamp); + /* sentrix.v1.Address proposer = 6; */ + if (message.proposer) + Address.internalBinaryWrite(message.proposer, writer.tag(6, WireType.LengthDelimited).fork(), options).join(); + /* uint32 round = 7; */ + if (message.round !== 0) + writer.tag(7, WireType.Varint).uint32(message.round); + /* repeated sentrix.v1.Transaction transactions = 8; */ + for (let i = 0; i < message.transactions.length; i++) + Transaction.internalBinaryWrite(message.transactions[i], writer.tag(8, WireType.LengthDelimited).fork(), options).join(); + /* bytes justification = 9; */ + if (message.justification.length) + writer.tag(9, WireType.LengthDelimited).bytes(message.justification); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.Block + */ +export const Block = new Block$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class Account$Type extends MessageType { + constructor() { + super("sentrix.v1.Account", [ + { no: 1, name: "address", kind: "message", T: () => Address }, + { no: 2, name: "balance", kind: "message", T: () => Amount }, + { no: 3, name: "nonce", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }, + { no: 4, name: "storage_root", kind: "message", T: () => Hash }, + { no: 5, name: "code_hash", kind: "message", T: () => Hash } + ]); + } + create(value?: PartialMessage): Account { + const message = globalThis.Object.create((this.messagePrototype!)); + message.nonce = 0n; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Account): Account { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* sentrix.v1.Address address */ 1: + message.address = Address.internalBinaryRead(reader, reader.uint32(), options, message.address); + break; + case /* sentrix.v1.Amount balance */ 2: + message.balance = Amount.internalBinaryRead(reader, reader.uint32(), options, message.balance); + break; + case /* uint64 nonce */ 3: + message.nonce = reader.uint64().toBigInt(); + break; + case /* sentrix.v1.Hash storage_root */ 4: + message.storageRoot = Hash.internalBinaryRead(reader, reader.uint32(), options, message.storageRoot); + break; + case /* sentrix.v1.Hash code_hash */ 5: + message.codeHash = Hash.internalBinaryRead(reader, reader.uint32(), options, message.codeHash); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: Account, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* sentrix.v1.Address address = 1; */ + if (message.address) + Address.internalBinaryWrite(message.address, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.Amount balance = 2; */ + if (message.balance) + Amount.internalBinaryWrite(message.balance, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + /* uint64 nonce = 3; */ + if (message.nonce !== 0n) + writer.tag(3, WireType.Varint).uint64(message.nonce); + /* sentrix.v1.Hash storage_root = 4; */ + if (message.storageRoot) + Hash.internalBinaryWrite(message.storageRoot, writer.tag(4, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.Hash code_hash = 5; */ + if (message.codeHash) + Hash.internalBinaryWrite(message.codeHash, writer.tag(5, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.Account + */ +export const Account = new Account$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class ChainEvent$Type extends MessageType { + constructor() { + super("sentrix.v1.ChainEvent", [ + { no: 1, name: "block_finalized", kind: "message", oneof: "event", T: () => BlockFinalized }, + { no: 2, name: "pending_tx", kind: "message", oneof: "event", T: () => PendingTx }, + { no: 3, name: "validator_set_change", kind: "message", oneof: "event", T: () => ValidatorSetChange }, + { no: 4, name: "log", kind: "message", oneof: "event", T: () => LogEmitted }, + { no: 5, name: "lagged", kind: "message", oneof: "event", T: () => StreamLagged }, + { no: 100, name: "sequence", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }, + { no: 101, name: "timestamp", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ } + ]); + } + create(value?: PartialMessage): ChainEvent { + const message = globalThis.Object.create((this.messagePrototype!)); + message.event = { oneofKind: undefined }; + message.sequence = 0n; + message.timestamp = 0n; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: ChainEvent): ChainEvent { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* sentrix.v1.BlockFinalized block_finalized */ 1: + message.event = { + oneofKind: "blockFinalized", + blockFinalized: BlockFinalized.internalBinaryRead(reader, reader.uint32(), options, (message.event as any).blockFinalized) + }; + break; + case /* sentrix.v1.PendingTx pending_tx */ 2: + message.event = { + oneofKind: "pendingTx", + pendingTx: PendingTx.internalBinaryRead(reader, reader.uint32(), options, (message.event as any).pendingTx) + }; + break; + case /* sentrix.v1.ValidatorSetChange validator_set_change */ 3: + message.event = { + oneofKind: "validatorSetChange", + validatorSetChange: ValidatorSetChange.internalBinaryRead(reader, reader.uint32(), options, (message.event as any).validatorSetChange) + }; + break; + case /* sentrix.v1.LogEmitted log */ 4: + message.event = { + oneofKind: "log", + log: LogEmitted.internalBinaryRead(reader, reader.uint32(), options, (message.event as any).log) + }; + break; + case /* sentrix.v1.StreamLagged lagged */ 5: + message.event = { + oneofKind: "lagged", + lagged: StreamLagged.internalBinaryRead(reader, reader.uint32(), options, (message.event as any).lagged) + }; + break; + case /* uint64 sequence */ 100: + message.sequence = reader.uint64().toBigInt(); + break; + case /* uint64 timestamp */ 101: + message.timestamp = reader.uint64().toBigInt(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: ChainEvent, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* sentrix.v1.BlockFinalized block_finalized = 1; */ + if (message.event.oneofKind === "blockFinalized") + BlockFinalized.internalBinaryWrite(message.event.blockFinalized, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.PendingTx pending_tx = 2; */ + if (message.event.oneofKind === "pendingTx") + PendingTx.internalBinaryWrite(message.event.pendingTx, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.ValidatorSetChange validator_set_change = 3; */ + if (message.event.oneofKind === "validatorSetChange") + ValidatorSetChange.internalBinaryWrite(message.event.validatorSetChange, writer.tag(3, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.LogEmitted log = 4; */ + if (message.event.oneofKind === "log") + LogEmitted.internalBinaryWrite(message.event.log, writer.tag(4, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.StreamLagged lagged = 5; */ + if (message.event.oneofKind === "lagged") + StreamLagged.internalBinaryWrite(message.event.lagged, writer.tag(5, WireType.LengthDelimited).fork(), options).join(); + /* uint64 sequence = 100; */ + if (message.sequence !== 0n) + writer.tag(100, WireType.Varint).uint64(message.sequence); + /* uint64 timestamp = 101; */ + if (message.timestamp !== 0n) + writer.tag(101, WireType.Varint).uint64(message.timestamp); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.ChainEvent + */ +export const ChainEvent = new ChainEvent$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class BlockFinalized$Type extends MessageType { + constructor() { + super("sentrix.v1.BlockFinalized", [ + { no: 1, name: "block", kind: "message", T: () => Block } + ]); + } + create(value?: PartialMessage): BlockFinalized { + const message = globalThis.Object.create((this.messagePrototype!)); + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: BlockFinalized): BlockFinalized { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* sentrix.v1.Block block */ 1: + message.block = Block.internalBinaryRead(reader, reader.uint32(), options, message.block); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: BlockFinalized, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* sentrix.v1.Block block = 1; */ + if (message.block) + Block.internalBinaryWrite(message.block, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.BlockFinalized + */ +export const BlockFinalized = new BlockFinalized$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class PendingTx$Type extends MessageType { + constructor() { + super("sentrix.v1.PendingTx", [ + { no: 1, name: "tx", kind: "message", T: () => Transaction } + ]); + } + create(value?: PartialMessage): PendingTx { + const message = globalThis.Object.create((this.messagePrototype!)); + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: PendingTx): PendingTx { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* sentrix.v1.Transaction tx */ 1: + message.tx = Transaction.internalBinaryRead(reader, reader.uint32(), options, message.tx); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: PendingTx, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* sentrix.v1.Transaction tx = 1; */ + if (message.tx) + Transaction.internalBinaryWrite(message.tx, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.PendingTx + */ +export const PendingTx = new PendingTx$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class ValidatorSetChange$Type extends MessageType { + constructor() { + super("sentrix.v1.ValidatorSetChange", [ + { no: 1, name: "epoch", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, + { no: 2, name: "active", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => Address }, + { no: 3, name: "jailed", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => Address } + ]); + } + create(value?: PartialMessage): ValidatorSetChange { + const message = globalThis.Object.create((this.messagePrototype!)); + message.epoch = 0; + message.active = []; + message.jailed = []; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: ValidatorSetChange): ValidatorSetChange { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* uint32 epoch */ 1: + message.epoch = reader.uint32(); + break; + case /* repeated sentrix.v1.Address active */ 2: + message.active.push(Address.internalBinaryRead(reader, reader.uint32(), options)); + break; + case /* repeated sentrix.v1.Address jailed */ 3: + message.jailed.push(Address.internalBinaryRead(reader, reader.uint32(), options)); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: ValidatorSetChange, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* uint32 epoch = 1; */ + if (message.epoch !== 0) + writer.tag(1, WireType.Varint).uint32(message.epoch); + /* repeated sentrix.v1.Address active = 2; */ + for (let i = 0; i < message.active.length; i++) + Address.internalBinaryWrite(message.active[i], writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + /* repeated sentrix.v1.Address jailed = 3; */ + for (let i = 0; i < message.jailed.length; i++) + Address.internalBinaryWrite(message.jailed[i], writer.tag(3, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.ValidatorSetChange + */ +export const ValidatorSetChange = new ValidatorSetChange$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class LogEmitted$Type extends MessageType { + constructor() { + super("sentrix.v1.LogEmitted", [ + { no: 1, name: "contract", kind: "message", T: () => Address }, + { no: 2, name: "topics", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => Hash }, + { no: 3, name: "data", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, + { no: 4, name: "tx_hash", kind: "message", T: () => Hash }, + { no: 5, name: "block_height", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }, + { no: 6, name: "log_index", kind: "scalar", T: 13 /*ScalarType.UINT32*/ } + ]); + } + create(value?: PartialMessage): LogEmitted { + const message = globalThis.Object.create((this.messagePrototype!)); + message.topics = []; + message.data = new Uint8Array(0); + message.blockHeight = 0n; + message.logIndex = 0; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: LogEmitted): LogEmitted { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* sentrix.v1.Address contract */ 1: + message.contract = Address.internalBinaryRead(reader, reader.uint32(), options, message.contract); + break; + case /* repeated sentrix.v1.Hash topics */ 2: + message.topics.push(Hash.internalBinaryRead(reader, reader.uint32(), options)); + break; + case /* bytes data */ 3: + message.data = reader.bytes(); + break; + case /* sentrix.v1.Hash tx_hash */ 4: + message.txHash = Hash.internalBinaryRead(reader, reader.uint32(), options, message.txHash); + break; + case /* uint64 block_height */ 5: + message.blockHeight = reader.uint64().toBigInt(); + break; + case /* uint32 log_index */ 6: + message.logIndex = reader.uint32(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: LogEmitted, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* sentrix.v1.Address contract = 1; */ + if (message.contract) + Address.internalBinaryWrite(message.contract, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + /* repeated sentrix.v1.Hash topics = 2; */ + for (let i = 0; i < message.topics.length; i++) + Hash.internalBinaryWrite(message.topics[i], writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + /* bytes data = 3; */ + if (message.data.length) + writer.tag(3, WireType.LengthDelimited).bytes(message.data); + /* sentrix.v1.Hash tx_hash = 4; */ + if (message.txHash) + Hash.internalBinaryWrite(message.txHash, writer.tag(4, WireType.LengthDelimited).fork(), options).join(); + /* uint64 block_height = 5; */ + if (message.blockHeight !== 0n) + writer.tag(5, WireType.Varint).uint64(message.blockHeight); + /* uint32 log_index = 6; */ + if (message.logIndex !== 0) + writer.tag(6, WireType.Varint).uint32(message.logIndex); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.LogEmitted + */ +export const LogEmitted = new LogEmitted$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class StreamLagged$Type extends MessageType { + constructor() { + super("sentrix.v1.StreamLagged", [ + { no: 1, name: "skipped_count", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ } + ]); + } + create(value?: PartialMessage): StreamLagged { + const message = globalThis.Object.create((this.messagePrototype!)); + message.skippedCount = 0n; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: StreamLagged): StreamLagged { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* uint64 skipped_count */ 1: + message.skippedCount = reader.uint64().toBigInt(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: StreamLagged, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* uint64 skipped_count = 1; */ + if (message.skippedCount !== 0n) + writer.tag(1, WireType.Varint).uint64(message.skippedCount); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.StreamLagged + */ +export const StreamLagged = new StreamLagged$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class BroadcastTxRequest$Type extends MessageType { + constructor() { + super("sentrix.v1.BroadcastTxRequest", [ + { no: 1, name: "tx", kind: "message", T: () => Transaction } + ]); + } + create(value?: PartialMessage): BroadcastTxRequest { + const message = globalThis.Object.create((this.messagePrototype!)); + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: BroadcastTxRequest): BroadcastTxRequest { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* sentrix.v1.Transaction tx */ 1: + message.tx = Transaction.internalBinaryRead(reader, reader.uint32(), options, message.tx); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: BroadcastTxRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* sentrix.v1.Transaction tx = 1; */ + if (message.tx) + Transaction.internalBinaryWrite(message.tx, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.BroadcastTxRequest + */ +export const BroadcastTxRequest = new BroadcastTxRequest$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class BroadcastTxResponse$Type extends MessageType { + constructor() { + super("sentrix.v1.BroadcastTxResponse", [ + { no: 1, name: "txid", kind: "message", T: () => Hash }, + { no: 2, name: "mempool_position", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ } + ]); + } + create(value?: PartialMessage): BroadcastTxResponse { + const message = globalThis.Object.create((this.messagePrototype!)); + message.mempoolPosition = 0n; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: BroadcastTxResponse): BroadcastTxResponse { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* sentrix.v1.Hash txid */ 1: + message.txid = Hash.internalBinaryRead(reader, reader.uint32(), options, message.txid); + break; + case /* uint64 mempool_position */ 2: + message.mempoolPosition = reader.uint64().toBigInt(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: BroadcastTxResponse, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* sentrix.v1.Hash txid = 1; */ + if (message.txid) + Hash.internalBinaryWrite(message.txid, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + /* uint64 mempool_position = 2; */ + if (message.mempoolPosition !== 0n) + writer.tag(2, WireType.Varint).uint64(message.mempoolPosition); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.BroadcastTxResponse + */ +export const BroadcastTxResponse = new BroadcastTxResponse$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class GetBlockRequest$Type extends MessageType { + constructor() { + super("sentrix.v1.GetBlockRequest", [ + { no: 1, name: "height", kind: "message", oneof: "selector", T: () => BlockHeight }, + { no: 2, name: "hash", kind: "message", oneof: "selector", T: () => Hash }, + { no: 3, name: "latest", kind: "scalar", oneof: "selector", T: 8 /*ScalarType.BOOL*/ }, + { no: 4, name: "finalized", kind: "scalar", oneof: "selector", T: 8 /*ScalarType.BOOL*/ } + ]); + } + create(value?: PartialMessage): GetBlockRequest { + const message = globalThis.Object.create((this.messagePrototype!)); + message.selector = { oneofKind: undefined }; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: GetBlockRequest): GetBlockRequest { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* sentrix.v1.BlockHeight height */ 1: + message.selector = { + oneofKind: "height", + height: BlockHeight.internalBinaryRead(reader, reader.uint32(), options, (message.selector as any).height) + }; + break; + case /* sentrix.v1.Hash hash */ 2: + message.selector = { + oneofKind: "hash", + hash: Hash.internalBinaryRead(reader, reader.uint32(), options, (message.selector as any).hash) + }; + break; + case /* bool latest */ 3: + message.selector = { + oneofKind: "latest", + latest: reader.bool() + }; + break; + case /* bool finalized */ 4: + message.selector = { + oneofKind: "finalized", + finalized: reader.bool() + }; + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: GetBlockRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* sentrix.v1.BlockHeight height = 1; */ + if (message.selector.oneofKind === "height") + BlockHeight.internalBinaryWrite(message.selector.height, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.Hash hash = 2; */ + if (message.selector.oneofKind === "hash") + Hash.internalBinaryWrite(message.selector.hash, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + /* bool latest = 3; */ + if (message.selector.oneofKind === "latest") + writer.tag(3, WireType.Varint).bool(message.selector.latest); + /* bool finalized = 4; */ + if (message.selector.oneofKind === "finalized") + writer.tag(4, WireType.Varint).bool(message.selector.finalized); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.GetBlockRequest + */ +export const GetBlockRequest = new GetBlockRequest$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class GetBalanceRequest$Type extends MessageType { + constructor() { + super("sentrix.v1.GetBalanceRequest", [ + { no: 1, name: "address", kind: "message", T: () => Address }, + { no: 2, name: "at_height", kind: "message", T: () => BlockHeight } + ]); + } + create(value?: PartialMessage): GetBalanceRequest { + const message = globalThis.Object.create((this.messagePrototype!)); + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: GetBalanceRequest): GetBalanceRequest { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* sentrix.v1.Address address */ 1: + message.address = Address.internalBinaryRead(reader, reader.uint32(), options, message.address); + break; + case /* optional sentrix.v1.BlockHeight at_height */ 2: + message.atHeight = BlockHeight.internalBinaryRead(reader, reader.uint32(), options, message.atHeight); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: GetBalanceRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* sentrix.v1.Address address = 1; */ + if (message.address) + Address.internalBinaryWrite(message.address, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + /* optional sentrix.v1.BlockHeight at_height = 2; */ + if (message.atHeight) + BlockHeight.internalBinaryWrite(message.atHeight, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.GetBalanceRequest + */ +export const GetBalanceRequest = new GetBalanceRequest$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class StreamEventsRequest$Type extends MessageType { + constructor() { + super("sentrix.v1.StreamEventsRequest", [ + { no: 1, name: "filters", kind: "enum", repeat: 1 /*RepeatType.PACKED*/, T: () => ["sentrix.v1.EventFilter", EventFilter, "EVENT_FILTER_"] }, + { no: 2, name: "from_sequence", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ } + ]); + } + create(value?: PartialMessage): StreamEventsRequest { + const message = globalThis.Object.create((this.messagePrototype!)); + message.filters = []; + message.fromSequence = 0n; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: StreamEventsRequest): StreamEventsRequest { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* repeated sentrix.v1.EventFilter filters */ 1: + if (wireType === WireType.LengthDelimited) + for (let e = reader.int32() + reader.pos; reader.pos < e;) + message.filters.push(reader.int32()); + else + message.filters.push(reader.int32()); + break; + case /* uint64 from_sequence */ 2: + message.fromSequence = reader.uint64().toBigInt(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: StreamEventsRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* repeated sentrix.v1.EventFilter filters = 1; */ + if (message.filters.length) { + writer.tag(1, WireType.LengthDelimited).fork(); + for (let i = 0; i < message.filters.length; i++) + writer.int32(message.filters[i]); + writer.join(); + } + /* uint64 from_sequence = 2; */ + if (message.fromSequence !== 0n) + writer.tag(2, WireType.Varint).uint64(message.fromSequence); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.StreamEventsRequest + */ +export const StreamEventsRequest = new StreamEventsRequest$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class GetValidatorSetRequest$Type extends MessageType { + constructor() { + super("sentrix.v1.GetValidatorSetRequest", [ + { no: 1, name: "at_height", kind: "message", T: () => BlockHeight } + ]); + } + create(value?: PartialMessage): GetValidatorSetRequest { + const message = globalThis.Object.create((this.messagePrototype!)); + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: GetValidatorSetRequest): GetValidatorSetRequest { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* optional sentrix.v1.BlockHeight at_height */ 1: + message.atHeight = BlockHeight.internalBinaryRead(reader, reader.uint32(), options, message.atHeight); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: GetValidatorSetRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* optional sentrix.v1.BlockHeight at_height = 1; */ + if (message.atHeight) + BlockHeight.internalBinaryWrite(message.atHeight, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.GetValidatorSetRequest + */ +export const GetValidatorSetRequest = new GetValidatorSetRequest$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class ValidatorSet$Type extends MessageType { + constructor() { + super("sentrix.v1.ValidatorSet", [ + { no: 1, name: "epoch", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, + { no: 2, name: "active_count", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, + { no: 3, name: "total_count", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, + { no: 4, name: "total_active_stake_sentri", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }, + { no: 5, name: "validators", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => ValidatorEntry } + ]); + } + create(value?: PartialMessage): ValidatorSet { + const message = globalThis.Object.create((this.messagePrototype!)); + message.epoch = 0; + message.activeCount = 0; + message.totalCount = 0; + message.totalActiveStakeSentri = 0n; + message.validators = []; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: ValidatorSet): ValidatorSet { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* uint32 epoch */ 1: + message.epoch = reader.uint32(); + break; + case /* uint32 active_count */ 2: + message.activeCount = reader.uint32(); + break; + case /* uint32 total_count */ 3: + message.totalCount = reader.uint32(); + break; + case /* uint64 total_active_stake_sentri */ 4: + message.totalActiveStakeSentri = reader.uint64().toBigInt(); + break; + case /* repeated sentrix.v1.ValidatorEntry validators */ 5: + message.validators.push(ValidatorEntry.internalBinaryRead(reader, reader.uint32(), options)); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: ValidatorSet, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* uint32 epoch = 1; */ + if (message.epoch !== 0) + writer.tag(1, WireType.Varint).uint32(message.epoch); + /* uint32 active_count = 2; */ + if (message.activeCount !== 0) + writer.tag(2, WireType.Varint).uint32(message.activeCount); + /* uint32 total_count = 3; */ + if (message.totalCount !== 0) + writer.tag(3, WireType.Varint).uint32(message.totalCount); + /* uint64 total_active_stake_sentri = 4; */ + if (message.totalActiveStakeSentri !== 0n) + writer.tag(4, WireType.Varint).uint64(message.totalActiveStakeSentri); + /* repeated sentrix.v1.ValidatorEntry validators = 5; */ + for (let i = 0; i < message.validators.length; i++) + ValidatorEntry.internalBinaryWrite(message.validators[i], writer.tag(5, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.ValidatorSet + */ +export const ValidatorSet = new ValidatorSet$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class ValidatorEntry$Type extends MessageType { + constructor() { + super("sentrix.v1.ValidatorEntry", [ + { no: 1, name: "address", kind: "message", T: () => Address }, + { no: 2, name: "stake_sentri", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }, + { no: 3, name: "active", kind: "scalar", T: 8 /*ScalarType.BOOL*/ }, + { no: 4, name: "jailed", kind: "scalar", T: 8 /*ScalarType.BOOL*/ } + ]); + } + create(value?: PartialMessage): ValidatorEntry { + const message = globalThis.Object.create((this.messagePrototype!)); + message.stakeSentri = 0n; + message.active = false; + message.jailed = false; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: ValidatorEntry): ValidatorEntry { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* sentrix.v1.Address address */ 1: + message.address = Address.internalBinaryRead(reader, reader.uint32(), options, message.address); + break; + case /* uint64 stake_sentri */ 2: + message.stakeSentri = reader.uint64().toBigInt(); + break; + case /* bool active */ 3: + message.active = reader.bool(); + break; + case /* bool jailed */ 4: + message.jailed = reader.bool(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: ValidatorEntry, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* sentrix.v1.Address address = 1; */ + if (message.address) + Address.internalBinaryWrite(message.address, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + /* uint64 stake_sentri = 2; */ + if (message.stakeSentri !== 0n) + writer.tag(2, WireType.Varint).uint64(message.stakeSentri); + /* bool active = 3; */ + if (message.active !== false) + writer.tag(3, WireType.Varint).bool(message.active); + /* bool jailed = 4; */ + if (message.jailed !== false) + writer.tag(4, WireType.Varint).bool(message.jailed); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.ValidatorEntry + */ +export const ValidatorEntry = new ValidatorEntry$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class GetSupplyRequest$Type extends MessageType { + constructor() { + super("sentrix.v1.GetSupplyRequest", [ + { no: 1, name: "at_height", kind: "message", T: () => BlockHeight } + ]); + } + create(value?: PartialMessage): GetSupplyRequest { + const message = globalThis.Object.create((this.messagePrototype!)); + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: GetSupplyRequest): GetSupplyRequest { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* optional sentrix.v1.BlockHeight at_height */ 1: + message.atHeight = BlockHeight.internalBinaryRead(reader, reader.uint32(), options, message.atHeight); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: GetSupplyRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* optional sentrix.v1.BlockHeight at_height = 1; */ + if (message.atHeight) + BlockHeight.internalBinaryWrite(message.atHeight, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.GetSupplyRequest + */ +export const GetSupplyRequest = new GetSupplyRequest$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class Supply$Type extends MessageType { + constructor() { + super("sentrix.v1.Supply", [ + { no: 1, name: "minted_sentri", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }, + { no: 2, name: "burned_sentri", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }, + { no: 3, name: "circulating_sentri", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ } + ]); + } + create(value?: PartialMessage): Supply { + const message = globalThis.Object.create((this.messagePrototype!)); + message.mintedSentri = 0n; + message.burnedSentri = 0n; + message.circulatingSentri = 0n; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Supply): Supply { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* uint64 minted_sentri */ 1: + message.mintedSentri = reader.uint64().toBigInt(); + break; + case /* uint64 burned_sentri */ 2: + message.burnedSentri = reader.uint64().toBigInt(); + break; + case /* uint64 circulating_sentri */ 3: + message.circulatingSentri = reader.uint64().toBigInt(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: Supply, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* uint64 minted_sentri = 1; */ + if (message.mintedSentri !== 0n) + writer.tag(1, WireType.Varint).uint64(message.mintedSentri); + /* uint64 burned_sentri = 2; */ + if (message.burnedSentri !== 0n) + writer.tag(2, WireType.Varint).uint64(message.burnedSentri); + /* uint64 circulating_sentri = 3; */ + if (message.circulatingSentri !== 0n) + writer.tag(3, WireType.Varint).uint64(message.circulatingSentri); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.Supply + */ +export const Supply = new Supply$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class GetMempoolRequest$Type extends MessageType { + constructor() { + super("sentrix.v1.GetMempoolRequest", [ + { no: 1, name: "limit", kind: "scalar", T: 13 /*ScalarType.UINT32*/ } + ]); + } + create(value?: PartialMessage): GetMempoolRequest { + const message = globalThis.Object.create((this.messagePrototype!)); + message.limit = 0; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: GetMempoolRequest): GetMempoolRequest { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* uint32 limit */ 1: + message.limit = reader.uint32(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: GetMempoolRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* uint32 limit = 1; */ + if (message.limit !== 0) + writer.tag(1, WireType.Varint).uint32(message.limit); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.GetMempoolRequest + */ +export const GetMempoolRequest = new GetMempoolRequest$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class Mempool$Type extends MessageType { + constructor() { + super("sentrix.v1.Mempool", [ + { no: 1, name: "size", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, + { no: 2, name: "entries", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => MempoolEntry } + ]); + } + create(value?: PartialMessage): Mempool { + const message = globalThis.Object.create((this.messagePrototype!)); + message.size = 0; + message.entries = []; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Mempool): Mempool { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* uint32 size */ 1: + message.size = reader.uint32(); + break; + case /* repeated sentrix.v1.MempoolEntry entries */ 2: + message.entries.push(MempoolEntry.internalBinaryRead(reader, reader.uint32(), options)); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: Mempool, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* uint32 size = 1; */ + if (message.size !== 0) + writer.tag(1, WireType.Varint).uint32(message.size); + /* repeated sentrix.v1.MempoolEntry entries = 2; */ + for (let i = 0; i < message.entries.length; i++) + MempoolEntry.internalBinaryWrite(message.entries[i], writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.Mempool + */ +export const Mempool = new Mempool$Type(); +// @generated message type with reflection information, may provide speed optimized methods +class MempoolEntry$Type extends MessageType { + constructor() { + super("sentrix.v1.MempoolEntry", [ + { no: 1, name: "txid", kind: "message", T: () => Hash }, + { no: 2, name: "from_address", kind: "message", T: () => Address }, + { no: 3, name: "to_address", kind: "message", T: () => Address }, + { no: 4, name: "amount", kind: "message", T: () => Amount }, + { no: 5, name: "fee", kind: "message", T: () => Amount }, + { no: 6, name: "nonce", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }, + { no: 7, name: "tx_type", kind: "scalar", T: 13 /*ScalarType.UINT32*/ } + ]); + } + create(value?: PartialMessage): MempoolEntry { + const message = globalThis.Object.create((this.messagePrototype!)); + message.nonce = 0n; + message.txType = 0; + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: MempoolEntry): MempoolEntry { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* sentrix.v1.Hash txid */ 1: + message.txid = Hash.internalBinaryRead(reader, reader.uint32(), options, message.txid); + break; + case /* sentrix.v1.Address from_address */ 2: + message.fromAddress = Address.internalBinaryRead(reader, reader.uint32(), options, message.fromAddress); + break; + case /* sentrix.v1.Address to_address */ 3: + message.toAddress = Address.internalBinaryRead(reader, reader.uint32(), options, message.toAddress); + break; + case /* sentrix.v1.Amount amount */ 4: + message.amount = Amount.internalBinaryRead(reader, reader.uint32(), options, message.amount); + break; + case /* sentrix.v1.Amount fee */ 5: + message.fee = Amount.internalBinaryRead(reader, reader.uint32(), options, message.fee); + break; + case /* uint64 nonce */ 6: + message.nonce = reader.uint64().toBigInt(); + break; + case /* uint32 tx_type */ 7: + message.txType = reader.uint32(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: MempoolEntry, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* sentrix.v1.Hash txid = 1; */ + if (message.txid) + Hash.internalBinaryWrite(message.txid, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.Address from_address = 2; */ + if (message.fromAddress) + Address.internalBinaryWrite(message.fromAddress, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.Address to_address = 3; */ + if (message.toAddress) + Address.internalBinaryWrite(message.toAddress, writer.tag(3, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.Amount amount = 4; */ + if (message.amount) + Amount.internalBinaryWrite(message.amount, writer.tag(4, WireType.LengthDelimited).fork(), options).join(); + /* sentrix.v1.Amount fee = 5; */ + if (message.fee) + Amount.internalBinaryWrite(message.fee, writer.tag(5, WireType.LengthDelimited).fork(), options).join(); + /* uint64 nonce = 6; */ + if (message.nonce !== 0n) + writer.tag(6, WireType.Varint).uint64(message.nonce); + /* uint32 tx_type = 7; */ + if (message.txType !== 0) + writer.tag(7, WireType.Varint).uint32(message.txType); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message sentrix.v1.MempoolEntry + */ +export const MempoolEntry = new MempoolEntry$Type(); +/** + * @generated ServiceType for protobuf service sentrix.v1.Sentrix + */ +export const Sentrix = new ServiceType("sentrix.v1.Sentrix", [ + { name: "BroadcastTx", options: {}, I: BroadcastTxRequest, O: BroadcastTxResponse }, + { name: "GetBlock", options: {}, I: GetBlockRequest, O: Block }, + { name: "GetBalance", options: {}, I: GetBalanceRequest, O: Account }, + { name: "GetValidatorSet", options: {}, I: GetValidatorSetRequest, O: ValidatorSet }, + { name: "GetSupply", options: {}, I: GetSupplyRequest, O: Supply }, + { name: "GetMempool", options: {}, I: GetMempoolRequest, O: Mempool }, + { name: "StreamEvents", serverStreaming: true, options: {}, I: StreamEventsRequest, O: ChainEvent } +]);