From a12234a5493ddef6b9d8de9b1fc6349ed656ac87 Mon Sep 17 00:00:00 2001 From: satyakwok Date: Wed, 13 May 2026 20:18:15 +0200 Subject: [PATCH] =?UTF-8?q?docs(readme=20+=20barrel):=20polish=20to=20trut?= =?UTF-8?q?h=20=E2=80=94=20actual=20API=20+=20correct=20surface=20count?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three classes of stale claims in the README + main barrel comment: 1. **"Five independent surfaces"** but the package actually has six (evm, native, bft, wallet, grpc, grpc-web — confirmed via package.json exports + src/ subdirs). Status section also said "five-door". Updated both to "six". 2. **"Sign + broadcast" example used a fictional API**: - `wallet.buildAndSignTransfer(w, {...})` doesn't exist (only `SentrixWallet.fromPrivateKeyHex` / `.sign(tx)` are exported) - `sentrix.broadcast(tx)` doesn't exist (the actual method is `submitTx(tx)`) - `sentrix.nextNonce(addr)` doesn't exist (callers read `nonce` off `balance(addr)` which returns `{ address, balance_srx, nonce }`) Replaced with the real flow: import `buildTransfer` from `@sentrix/chain/native`, build the unsigned tx struct, call `wallet.sign()`, submit via `submitTx()`. Verified against src/native/tx.ts + src/wallet/index.ts. 3. **`src/index.ts` barrel comment claimed "three independent surfaces"** listing only evm + native + bft. The barrel actually re-exports four (evm + native + bft + SentrixWallet) and exposes six total via subpath. Updated to document all six + the rationale for keeping gRPC + gRPC-Web subpath-only (transport can't load in the other env). --- README.md | 25 +++++++++++++++---------- src/index.ts | 18 +++++++++++------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 81844a9..2ba0003 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Latest release](https://img.shields.io/github/v/release/Sentriscloud/sdk-ts?include_prereleases&sort=semver)](https://github.com/Sentriscloud/sdk-ts/releases/latest) -Official TypeScript SDK for **Sentrix Chain** (chain ID `7119` mainnet, `7120` testnet). Five independent surfaces under one package — pick the one you actually need; tree-shaking drops the rest: +Official TypeScript SDK for **Sentrix Chain** (chain ID `7119` mainnet, `7120` testnet). Six independent surfaces under one package — pick the one you actually need; tree-shaking drops the rest: - **`@sentrix/chain/evm`** — viem-based EVM client (standard EVM dApp door) - **`@sentrix/chain/native`** — typed REST client for Sentrix-shaped endpoints (validators, epochs, BFT justification, fork status) @@ -97,19 +97,24 @@ await mgr.subscribeTyped("newHeads", { ### Sign + broadcast a native Sentrix tx ```ts -import { wallet, native } from "@sentrix/chain"; +import { native, SentrixWallet } from "@sentrix/chain"; +import { buildTransfer } from "@sentrix/chain/native"; -const w = wallet.SentrixWallet.fromPrivateKeyHex(process.env.PRIVATE_KEY!); +const w = SentrixWallet.fromPrivateKeyHex(process.env.PRIVATE_KEY!); const sentrix = native.nativeClient("mainnet"); -const tx = await wallet.buildAndSignTransfer(w, { +const { nonce } = await sentrix.balance(w.address); + +const unsigned = buildTransfer({ + from: w.address, to: "0x0804a00f53fde72d46abd1db7ee3e97cbfd0a107", - amountSentri: 100_000_000n, // 1 SRX - feeSentri: 10_000n, // 0.0001 SRX - nonce: await sentrix.nextNonce(w.address), - chainId: 7119, + amount: 100_000_000n, // 1 SRX = 100M sentri + fee: 10_000n, // 0.0001 SRX + nonce, + chainId: 7119n, }); -const txid = await sentrix.broadcast(tx); +const signed = await w.sign(unsigned); +const { txid } = await sentrix.submitTx(signed); ``` The wallet uses the same secp256k1 derivation as Ethereum — your MetaMask private key is also a Sentrix native private key, same address on both rails. @@ -177,7 +182,7 @@ When you use `evm.httpClient(...).getBalance(...)` you get 18-decimal wei. When ## Status -`v0.3.0-rc.0` — five-door surface: EVM (read + write via viem), native REST (typed read + nonce), BFT WebSocket (multiplexed subs + keepalive + typed payloads), wallet (secp256k1 + native tx signing), gRPC (Node-side typed client over the chain's `sentrix.v1.Sentrix` service). +`v0.3.0-rc.0` — six-door surface: EVM (read + write via viem), native REST (typed read + tx submit + tx builders), BFT WebSocket (multiplexed subs + keepalive + typed payloads), wallet (secp256k1 + native tx signing), gRPC (Node-side typed client over the chain's `sentrix.v1.Sentrix` service), gRPC-Web (browser-side equivalent over `@protobuf-ts/grpcweb-transport`). ## License diff --git a/src/index.ts b/src/index.ts index 4f1b008..ae91141 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,13 +1,17 @@ // @sentrix/chain — official TypeScript SDK for Sentrix Chain. // -// One package, three independent surfaces: -// - `@sentrix/chain/evm` — viem-based EVM client (the standard EVM dApp door) -// - `@sentrix/chain/native` — native REST client (TokenOps, StakingOps, BFT-aware) -// - `@sentrix/chain/bft` — WebSocket subscription helpers (newHeads + sentrix_*) +// One package, six independent surfaces (subpath imports for tree-shaking): +// - `@sentrix/chain/evm` — viem-based EVM client (standard EVM dApp door) +// - `@sentrix/chain/native` — typed REST client + native tx builders +// - `@sentrix/chain/bft` — WebSocket subscription manager (newHeads + sentrix_*) +// - `@sentrix/chain/wallet` — secp256k1 keypair + Sentrix-native tx signing +// - `@sentrix/chain/grpc` — Node-side gRPC client (`@grpc/grpc-js`) +// - `@sentrix/chain/grpc-web` — browser-side gRPC client (`@protobuf-ts/grpcweb-transport`) // -// Importing the root re-exports everything at one path for the -// "I want it all" caller, but tree-shaking benefits from picking the -// surface you actually use. +// This barrel re-exports the four surfaces that load safely in any +// environment (evm / native / bft / wallet). gRPC + gRPC-Web stay +// subpath-only because their transports don't load in the other env +// (`@grpc/grpc-js` needs raw HTTP/2 sockets browsers don't expose). export * from "./network.js"; export * as evm from "./evm/index.js";