diff --git a/deps.ts b/deps.ts index 04ac99b..0e0891b 100644 --- a/deps.ts +++ b/deps.ts @@ -14,12 +14,12 @@ export { sha256 } from "npm:@cosmjs/crypto@^0.32.2"; export { toUtf8 } from "npm:@cosmjs/encoding@^0.32.2"; export { Decimal, Uint53 } from "npm:@cosmjs/math@^0.32.2"; export { DirectSecp256k1HdWallet } from "npm:@cosmjs/proto-signing@^0.32.2"; -export { Tendermint34Client, Tendermint37Client } from "npm:@cosmjs/tendermint-rpc@^0.32.2"; +export { connectComet } from "npm:@cosmjs/tendermint-rpc@^0.32.2"; export { assert, isDefined, sleep } from "npm:@cosmjs/utils@^0.32.2"; export type { Coin } from "npm:@cosmjs/amino@^0.32.2"; export type { MsgExecuteContractEncodeObject } from "npm:@cosmjs/cosmwasm-stargate@^0.32.2"; export type { SignerData } from "npm:@cosmjs/stargate@^0.32.2"; -export type { TendermintClient } from "npm:@cosmjs/tendermint-rpc@^0.32.2"; +export type { CometClient } from "npm:@cosmjs/tendermint-rpc@^0.32.2"; // drand export type { ChainClient, ChainOptions, RandomnessBeacon } from "npm:drand-client@^1.2.0"; diff --git a/main.ts b/main.ts index 847bf27..4d2a355 100644 --- a/main.ts +++ b/main.ts @@ -11,6 +11,7 @@ import { calculateFee, ChainClient, Coin, + connectComet, CosmWasmClient, Decimal, DirectSecp256k1HdWallet, @@ -26,7 +27,6 @@ import { import { JobsObserver } from "./jobs.ts"; import { Submitter } from "./submitter.ts"; import { queryIsAllowlisted, queryIsIncentivized } from "./drand_contract.ts"; -import { connectTendermint } from "./tendermint.ts"; import { Config } from "./config.ts"; // Constants @@ -89,8 +89,8 @@ if (import.meta.main) { const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: config.prefix }); const [firstAccount] = await wallet.getAccounts(); - const tmClient = await connectTendermint(rpcEndpoint); - const client = await SigningCosmWasmClient.createWithSigner(tmClient, wallet, { + const cometClient = await connectComet(rpcEndpoint); + const client = await SigningCosmWasmClient.createWithSigner(cometClient, wallet, { gasPrice: GasPrice.fromString(config.gasPrice), }); @@ -174,7 +174,7 @@ if (import.meta.main) { const submitter = new Submitter({ client, - tmClient, + cometClient, broadcaster2, broadcaster3, getNextSignData, diff --git a/submitter.ts b/submitter.ts index b31aa14..46e8c4b 100644 --- a/submitter.ts +++ b/submitter.ts @@ -4,13 +4,13 @@ import { assertIsDeliverTxSuccess, calculateFee, ChainClient, + CometClient, CosmWasmClient, isDefined, logs, RandomnessBeacon, SignerData, SigningCosmWasmClient, - TendermintClient, } from "./deps.ts"; import { makeAddBeaconMessage, queryIsIncentivized } from "./drand_contract.ts"; import { ibcPacketsSent } from "./ibc.ts"; @@ -18,7 +18,7 @@ import { BeaconCache } from "./cache.ts"; interface Capture { client: SigningCosmWasmClient; - tmClient: TendermintClient; + cometClient: CometClient; broadcaster2: CosmWasmClient | null; broadcaster3: CosmWasmClient | null; botAddress: string; @@ -33,7 +33,7 @@ interface Capture { export class Submitter { private client: SigningCosmWasmClient; - private tmClient: TendermintClient; + private cometClient: CometClient; private broadcaster2: CosmWasmClient | null; private broadcaster3: CosmWasmClient | null; private botAddress: string; @@ -48,7 +48,7 @@ export class Submitter { constructor(capture: Capture) { this.client = capture.client; - this.tmClient = capture.tmClient; + this.cometClient = capture.cometClient; this.broadcaster2 = capture.broadcaster2; this.broadcaster3 = capture.broadcaster3; this.botAddress = capture.botAddress; @@ -165,7 +165,7 @@ export class Submitter { `✔ #${beacon.round} committed (Points: ${points}; Payout: ${payout}; Gas: ${result.gasUsed}/${result.gasWanted}; Jobs processed: ${jobs}; Transaction: ${result.transactionHash})`, ); const publishTime = timeOfRound(beacon.round) / 1000; - const { block } = await this.tmClient.block(result.height); + const { block } = await this.cometClient.block(result.height); const commitTime = block.header.time.getTime() / 1000; // seconds with fractional part const diff = commitTime - publishTime; console.info( diff --git a/tendermint.ts b/tendermint.ts deleted file mode 100644 index 980483a..0000000 --- a/tendermint.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Tendermint34Client, Tendermint37Client, TendermintClient } from "./deps.ts"; - -export async function connectTendermint(endpoint: string): Promise { - // Tendermint/CometBFT 0.34/0.37 auto-detection. Starting with 0.37 we seem to get reliable versions again 🎉 - // Using 0.34 as the fallback. - let tmClient: TendermintClient; - const tm37Client = await Tendermint37Client.connect(endpoint); - const version = (await tm37Client.status()).nodeInfo.version; - if (version.startsWith("0.37.")) { - tmClient = tm37Client; - } else { - tm37Client.disconnect(); - tmClient = await Tendermint34Client.connect(endpoint); - } - return tmClient; -}