Skip to content

Commit

Permalink
Merge pull request #541 from cosmology-tech/test-connect-comet
Browse files Browse the repository at this point in the history
test useConnectComet and debug
  • Loading branch information
Zetazzz authored Dec 13, 2023
2 parents 44144f1 + d5740af commit a4d8c65
Show file tree
Hide file tree
Showing 41 changed files with 120 additions and 78 deletions.
2 changes: 1 addition & 1 deletion __fixtures__/misc/output-impl-interfaces-gen/extern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/misc/output-proto-amino/no-amino/extern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/misc/output-proto-amino/proto-only/extern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/misc/output/extern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/output1/extern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/v-next/outputinstantrpc/extern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/v-next/outputosmojs/extern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/v-next/outputsign/extern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/v-next/outputv2/extern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/v-next/outputv4/akash/rpc.query.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Rpc } from "../helpers";
import { Tendermint34Client, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { QueryClient } from "@cosmjs/stargate";
export const createRPCQueryClient = async ({
rpcEndpoint
}: {
rpcEndpoint: string | HttpEndpoint;
}) => {
const tmClient = await Tendermint34Client.connect(rpcEndpoint);
const tmClient = await connectComet(rpcEndpoint);
const client = new QueryClient(tmClient);
return {
akash: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Rpc } from "../helpers";
import { Tendermint34Client, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { QueryClient } from "@cosmjs/stargate";
export const createCosmicRPCQueryClient = async ({
rpcEndpoint
}: {
rpcEndpoint: string | HttpEndpoint;
}) => {
const tmClient = await Tendermint34Client.connect(rpcEndpoint);
const tmClient = await connectComet(rpcEndpoint);
const client = new QueryClient(tmClient);
return {
cosmos: {
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/v-next/outputv4/cosmos/rpc.query.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Rpc } from "../helpers";
import { Tendermint34Client, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { QueryClient } from "@cosmjs/stargate";
export const createRPCQueryClient = async ({
rpcEndpoint
}: {
rpcEndpoint: string | HttpEndpoint;
}) => {
const tmClient = await Tendermint34Client.connect(rpcEndpoint);
const tmClient = await connectComet(rpcEndpoint);
const client = new QueryClient(tmClient);
return {
cosmos: {
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/v-next/outputv4/cosmwasm/rpc.query.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Rpc } from "../helpers";
import { Tendermint34Client, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { QueryClient } from "@cosmjs/stargate";
export const createRPCQueryClient = async ({
rpcEndpoint
}: {
rpcEndpoint: string | HttpEndpoint;
}) => {
const tmClient = await Tendermint34Client.connect(rpcEndpoint);
const tmClient = await connectComet(rpcEndpoint);
const client = new QueryClient(tmClient);
return {
cosmos: {
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/v-next/outputv4/evmos/evmos-rpc-client.query.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Rpc } from "../helpers";
import { Tendermint34Client, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { QueryClient } from "@cosmjs/stargate";
export const createEvmosRPCQueryClient = async ({
rpcEndpoint
}: {
rpcEndpoint: string | HttpEndpoint;
}) => {
const tmClient = await Tendermint34Client.connect(rpcEndpoint);
const tmClient = await connectComet(rpcEndpoint);
const client = new QueryClient(tmClient);
return {
cosmos: {
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/v-next/outputv4/evmos/rpc.query.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Rpc } from "../helpers";
import { Tendermint34Client, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { QueryClient } from "@cosmjs/stargate";
export const createRPCQueryClient = async ({
rpcEndpoint
}: {
rpcEndpoint: string | HttpEndpoint;
}) => {
const tmClient = await Tendermint34Client.connect(rpcEndpoint);
const tmClient = await connectComet(rpcEndpoint);
const client = new QueryClient(tmClient);
return {
cosmos: {
Expand Down
8 changes: 4 additions & 4 deletions __fixtures__/v-next/outputv4/extern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
*/

import { QueryClient, createProtobufRpcClient, ProtobufRpcClient } from '@cosmjs/stargate'
import { Tendermint34Client, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc";

const _rpcClients: Record<string, ProtobufRpcClient> = {};

export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
//@ts-ignore
return rpcEndpoint.url;
}
}
Expand All @@ -24,9 +24,9 @@ export const getRpcClient = async (rpcEndpoint: string | HttpEndpoint) => {
if (_rpcClients.hasOwnProperty(key)) {
return _rpcClients[key];
}
const tmClient = await Tendermint34Client.connect(rpcEndpoint);
const cometClient = await connectComet(rpcEndpoint);
//@ts-ignore
const client = new QueryClient(tmClient);
const client = new QueryClient(cometClient);
const rpc = createProtobufRpcClient(client);
_rpcClients[key] = rpc;
return rpc;
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/v-next/outputv4/ibc/rpc.query.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Rpc } from "../helpers";
import { Tendermint34Client, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { QueryClient } from "@cosmjs/stargate";
export const createRPCQueryClient = async ({
rpcEndpoint
}: {
rpcEndpoint: string | HttpEndpoint;
}) => {
const tmClient = await Tendermint34Client.connect(rpcEndpoint);
const tmClient = await connectComet(rpcEndpoint);
const client = new QueryClient(tmClient);
return {
cosmos: {
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/v-next/outputv4/osmosis/rpc.query.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Rpc } from "../helpers";
import { Tendermint34Client, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { QueryClient } from "@cosmjs/stargate";
export const createRPCQueryClient = async ({
rpcEndpoint
}: {
rpcEndpoint: string | HttpEndpoint;
}) => {
const tmClient = await Tendermint34Client.connect(rpcEndpoint);
const tmClient = await connectComet(rpcEndpoint);
const client = new QueryClient(tmClient);
return {
cosmos: {
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/v-next/outputv4/tendermint/rpc.query.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Rpc } from "../helpers";
import { Tendermint34Client, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc";
import { QueryClient } from "@cosmjs/stargate";
export const createRPCQueryClient = async ({
rpcEndpoint
}: {
rpcEndpoint: string | HttpEndpoint;
}) => {
const tmClient = await Tendermint34Client.connect(rpcEndpoint);
const tmClient = await connectComet(rpcEndpoint);
const client = new QueryClient(tmClient);
return {
cosmos: {
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
"jest": "29.5.0",
"lerna": "7.0.2",
"esprima": "4.0.1",
"prettier": "2.8.7"
"prettier": "2.8.7",
"@cosmjs/amino": "^0.32.0",
"@cosmjs/proto-signing": "^0.32.0",
"@cosmjs/stargate": "^0.32.0",
"@cosmjs/tendermint-rpc": "^0.32.0"
},
"workspaces": [
"packages/*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,24 @@ exports[`createScopedRpcFactory 1`] = `

exports[`createScopedRpcFactoryWithComet 1`] = `
"export const createRpcFactorizzleWithComet = async ({
rpc
rpcEndpoint
}: {
rpc: Rpc;
rpcEndpoint: string | HttpEndpoint;
}) => {
const tmClient = await connectComet(rpcEndpoint);
const client = new QueryClient(tmClient);
return {
cosmos: {
bank: {
v1beta1: (await import("./proto/cosmos/bank/v1beta1/query.lcd")).createClientImpl(rpc)
v1beta1: (await import("./proto/cosmos/bank/v1beta1/query.lcd")).createRpcQueryExtension(client)
},
gov: {
v1beta1: (await import("./proto/cosmos/bank/v1beta1/query.lcd")).createClientImpl(rpc)
v1beta1: (await import("./proto/cosmos/bank/v1beta1/query.lcd")).createRpcQueryExtension(client)
}
},
osmosis: {
gamm: {
v1beta1: (await import("./proto/cosmos/bank/v1beta1/query.lcd")).createClientImpl(rpc)
v1beta1: (await import("./proto/cosmos/bank/v1beta1/query.lcd")).createRpcQueryExtension(client)
}
}
};
Expand Down
1 change: 1 addition & 0 deletions packages/ast/src/clients/rpc/scoped/rpc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ it('createScopedRpcFactoryWithoutTm', async () => {

it('createScopedRpcFactoryWithComet', async () => {
const context = getGenericParseContext();
context.options!.rpcClients!.extensions = true;
context.options!.rpcClients!.useConnectComet = true;
expectCode(createScopedRpcTmFactory(context, {
cosmos: {
Expand Down
Loading

0 comments on commit a4d8c65

Please sign in to comment.