Merge pull request #717 from cosmos/648-rename-rpc-interface

Rename Stargate Rpc interface -> ProtobufRpcClient
This commit is contained in:
mergify[bot] 2021-03-18 12:56:21 +00:00 committed by GitHub
commit ac3d2b3e3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 19 additions and 17 deletions

View File

@ -27,6 +27,8 @@ and this project adheres to
`AuthExtension.unverified.account` return an account of type `Any`. This makes
the caller responsible for decoding the type.
- @cosmjs/stargate: Remove `accountFromProto` in favour of `accountFromAny`.
- @cosmjs/stargate: Rename `Rpc` interface to `ProtobufRpcClient` and
`createRpc` to `createProtobufRpcClient`.
- @cosmjs/tendermint-rpc: The fields `CommitSignature.validatorAddress`,
`.timestamp` and `.signature` are now optional. They are unset when
`blockIdFlag` is `BlockIdFlag.Absent`. The decoding into `CommitSignature` is

View File

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { JsonObject } from "@cosmjs/cosmwasm-launchpad";
import { fromUtf8, toAscii } from "@cosmjs/encoding";
import { createPagination, createRpc, QueryClient } from "@cosmjs/stargate";
import { createPagination, createProtobufRpcClient, QueryClient } from "@cosmjs/stargate";
import Long from "long";
import {
@ -63,7 +63,7 @@ export interface WasmExtension {
}
export function setupWasmExtension(base: QueryClient): WasmExtension {
const rpc = createRpc(base);
const rpc = createProtobufRpcClient(base);
// Use this service to get easy typed access to query methods
// This cannot be used for proof verification
const queryService = new QueryClientImpl(rpc);

View File

@ -5,11 +5,11 @@ export {
AuthExtension,
BankExtension,
createPagination,
createRpc,
createProtobufRpcClient,
DistributionExtension,
IbcExtension,
ProtobufRpcClient,
QueryClient,
Rpc,
setupAuthExtension,
setupBankExtension,
setupDistributionExtension,

View File

@ -1,7 +1,7 @@
import { QueryClientImpl } from "../codec/cosmos/auth/v1beta1/query";
import { Any } from "../codec/google/protobuf/any";
import { QueryClient } from "./queryclient";
import { createRpc, toAccAddress } from "./utils";
import { createProtobufRpcClient, toAccAddress } from "./utils";
export interface AuthExtension {
readonly auth: {
@ -27,7 +27,7 @@ export interface AuthExtension {
}
export function setupAuthExtension(base: QueryClient): AuthExtension {
const rpc = createRpc(base);
const rpc = createProtobufRpcClient(base);
// Use this service to get easy typed access to query methods
// This cannot be used for proof verification
const queryService = new QueryClientImpl(rpc);

View File

@ -5,7 +5,7 @@ import { assert } from "@cosmjs/utils";
import { QueryClientImpl } from "../codec/cosmos/bank/v1beta1/query";
import { Coin } from "../codec/cosmos/base/v1beta1/coin";
import { QueryClient } from "./queryclient";
import { createRpc, toAccAddress } from "./utils";
import { createProtobufRpcClient, toAccAddress } from "./utils";
export interface BankExtension {
readonly bank: {
@ -20,7 +20,7 @@ export interface BankExtension {
}
export function setupBankExtension(base: QueryClient): BankExtension {
const rpc = createRpc(base);
const rpc = createProtobufRpcClient(base);
// Use this service to get easy typed access to query methods
// This cannot be used for proof verification
const queryService = new QueryClientImpl(rpc);

View File

@ -14,7 +14,7 @@ import {
QueryValidatorSlashesResponse,
} from "../codec/cosmos/distribution/v1beta1/query";
import { QueryClient } from "./queryclient";
import { createPagination, createRpc } from "./utils";
import { createPagination, createProtobufRpcClient } from "./utils";
export interface DistributionExtension {
readonly distribution: {
@ -43,7 +43,7 @@ export interface DistributionExtension {
}
export function setupDistributionExtension(base: QueryClient): DistributionExtension {
const rpc = createRpc(base);
const rpc = createProtobufRpcClient(base);
// Use this service to get easy typed access to query methods
// This cannot be used for proof verification
const queryService = new QueryClientImpl(rpc);

View File

@ -24,7 +24,7 @@ import {
QueryConnectionsResponse,
} from "../codec/ibc/core/connection/v1/query";
import { QueryClient } from "./queryclient";
import { createPagination, createRpc } from "./utils";
import { createPagination, createProtobufRpcClient } from "./utils";
export interface IbcExtension {
readonly ibc: {
@ -89,7 +89,7 @@ export interface IbcExtension {
}
export function setupIbcExtension(base: QueryClient): IbcExtension {
const rpc = createRpc(base);
const rpc = createProtobufRpcClient(base);
// Use these services to get easy typed access to query methods
// These cannot be used for proof verification
const channelQueryService = new ChannelQuery(rpc);

View File

@ -9,4 +9,4 @@ export { BankExtension, setupBankExtension } from "./bank";
export { DistributionExtension, setupDistributionExtension } from "./distribution";
export { IbcExtension, setupIbcExtension } from "./ibc";
export { setupStakingExtension, StakingExtension } from "./staking";
export { createPagination, createRpc, Rpc } from "./utils";
export { createPagination, createProtobufRpcClient, ProtobufRpcClient } from "./utils";

View File

@ -20,7 +20,7 @@ import {
} from "../codec/cosmos/staking/v1beta1/query";
import { BondStatus } from "../codec/cosmos/staking/v1beta1/staking";
import { QueryClient } from "./queryclient";
import { createPagination, createRpc } from "./utils";
import { createPagination, createProtobufRpcClient } from "./utils";
export type BondStatusString = Exclude<keyof typeof BondStatus, "BOND_STATUS_UNSPECIFIED">;
@ -74,7 +74,7 @@ export interface StakingExtension {
export function setupStakingExtension(base: QueryClient): StakingExtension {
// Use this service to get easy typed access to query methods
// This cannot be used for proof verification
const rpc = createRpc(base);
const rpc = createProtobufRpcClient(base);
const queryService = new QueryClientImpl(rpc);
return {

View File

@ -24,11 +24,11 @@ export function createPagination(paginationKey?: Uint8Array): PageRequest | unde
: undefined;
}
export interface Rpc {
export interface ProtobufRpcClient {
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
}
export function createRpc(base: QueryClient): Rpc {
export function createProtobufRpcClient(base: QueryClient): ProtobufRpcClient {
return {
request: (service: string, method: string, data: Uint8Array): Promise<Uint8Array> => {
const path = `/${service}/${method}`;