This repo is an example of how to use bufbuild libraries to query penumbra nodes. Run example via:
npm install
npm run develop
# View code implementation in src/
npm install --save @connectrpc/connect-web @connectrpc/connect @penumbra-zone/protobuf
It's quite likely you'll want to use a GrpcWebTransport
if you are issuing http requests.
import { createGrpcWebTransport } from "@connectrpc/connect-web";
const transport = createGrpcWebTransport({
baseUrl: GRPC_ENDPOINT, // Your grpc endpoint you'd like to issue requests to
});
If so, you can import them from @penumbra-zone/protobuf
. This removes the need to add the buf custom registry. Example:
import { TendermintProxyService } from "@penumbra-zone/protobuf";
# Set your registry
npm config set @buf:registry https://buf.build/gen/npm/v1/
# Install the generated sdk. Example from cosmos/interchain-security.
# The npm link can be found in the sdk tab of buf build: https://buf.build/cosmos/interchain-security/sdks
npm install @buf/cosmos_interchain-security.connectrpc_es@latest
With the transport & service, you can construct a client and make rpc requests:
import { createGrpcWebTransport } from "@connectrpc/connect-web";
import { createPromiseClient } from "@connectrpc/connect";
import { TendermintProxyService } from "@penumbra-zone/protobuf";
const GRPC_ENDPOINT = "https://penumbra.stakewith.binary.builders";
const transport = createGrpcWebTransport({
baseUrl: GRPC_ENDPOINT,
});
export const tendermintClient = createPromiseClient(
TendermintProxyService,
transport,
);
const statusResponse = await tendermintClient.getStatus({});
Example from a service not in @penumbra-zone/protobuf
:
import { Query } from "@buf/cosmos_interchain-security.connectrpc_es/interchain_security/ccv/consumer/v1/query_connect";
const GRPC_ENDPOINT = "https://penumbra.stakewith.binary.builders";
const transport = createGrpcWebTransport({
baseUrl: GRPC_ENDPOINT,
});
const icsClient = createPromiseClient(Query, transport);
const paramsResponse = await icsClient.queryParams({});
Interested in writing a frontend that interacts with Prax?
Use the @penumbra-zone/client npm package.