Rename getTmClient -> getCometClient

This commit is contained in:
Simon Warta 2023-10-25 14:58:33 +02:00
parent 5eb7d8ba33
commit 6d763bd067
3 changed files with 20 additions and 16 deletions

View File

@ -22,12 +22,16 @@ and this project adheres to
`StargateClient.create` take a `CometClient` argument, adding support for
`Comet38Client`. The auto-detection in
`SigningStargateClient.connectWithSigner` and `StargateClient.connect` now
supports CometBFT 0.38.
supports CometBFT 0.38. Rename
`StargateClient.getTmClient`/`.forceGetTmClient` to
`.getCometClient`/`.forceGetCometClient`.
- @cosmjs/cosmwasm-stargate: Let `SigningCosmWasmClient.createWithSigner` and
`CosmWasmClient.create` take a `CometClient` argument, adding support for
`Comet38Client`. The auto-detection in
`SigningCosmWasmClient.connectWithSigner` and `CosmWasmClient.connect` now
supports CometBFT 0.38.
supports CometBFT 0.38. Rename
`CosmWasmClient.getTmClient`/`.forceGetTmClient` to
`.getCometClient`/`.forceGetCometClient`.
[#1421]: https://github.com/cosmos/cosmjs/issues/1421
[#1484]: https://github.com/cosmos/cosmjs/pull/1484

View File

@ -121,11 +121,11 @@ export class CosmWasmClient {
}
}
protected getTmClient(): CometClient | undefined {
protected getCometClient(): CometClient | undefined {
return this.cometClient;
}
protected forceGetTmClient(): CometClient {
protected forceGetCometClient(): CometClient {
if (!this.cometClient) {
throw new Error("Comet client not available. You cannot use online functionality in offline mode.");
}
@ -147,7 +147,7 @@ export class CosmWasmClient {
public async getChainId(): Promise<string> {
if (!this.chainId) {
const response = await this.forceGetTmClient().status();
const response = await this.forceGetCometClient().status();
const chainId = response.nodeInfo.network;
if (!chainId) throw new Error("Chain ID must not be empty");
this.chainId = chainId;
@ -157,7 +157,7 @@ export class CosmWasmClient {
}
public async getHeight(): Promise<number> {
const status = await this.forceGetTmClient().status();
const status = await this.forceGetCometClient().status();
return status.syncInfo.latestBlockHeight;
}
@ -187,7 +187,7 @@ export class CosmWasmClient {
}
public async getBlock(height?: number): Promise<Block> {
const response = await this.forceGetTmClient().block(height);
const response = await this.forceGetCometClient().block(height);
return {
id: toHex(response.blockId.hash).toUpperCase(),
header: {
@ -305,7 +305,7 @@ export class CosmWasmClient {
* @returns Returns the hash of the transaction
*/
public async broadcastTxSync(tx: Uint8Array): Promise<string> {
const broadcasted = await this.forceGetTmClient().broadcastTxSync({ tx });
const broadcasted = await this.forceGetCometClient().broadcastTxSync({ tx });
if (broadcasted.code) {
return Promise.reject(
@ -480,7 +480,7 @@ export class CosmWasmClient {
}
private async txsQuery(query: string): Promise<IndexedTx[]> {
const results = await this.forceGetTmClient().txSearchAll({ query: query });
const results = await this.forceGetCometClient().txSearchAll({ query: query });
return results.txs.map((tx): IndexedTx => {
const txMsgData = TxMsgData.decode(tx.result.data ?? new Uint8Array());
return {

View File

@ -237,11 +237,11 @@ export class StargateClient {
this.accountParser = accountParser;
}
protected getTmClient(): CometClient | undefined {
protected getCometClient(): CometClient | undefined {
return this.cometClient;
}
protected forceGetTmClient(): CometClient {
protected forceGetCometClient(): CometClient {
if (!this.cometClient) {
throw new Error("Comet client not available. You cannot use online functionality in offline mode.");
}
@ -267,7 +267,7 @@ export class StargateClient {
public async getChainId(): Promise<string> {
if (!this.chainId) {
const response = await this.forceGetTmClient().status();
const response = await this.forceGetCometClient().status();
const chainId = response.nodeInfo.network;
if (!chainId) throw new Error("Chain ID must not be empty");
this.chainId = chainId;
@ -277,7 +277,7 @@ export class StargateClient {
}
public async getHeight(): Promise<number> {
const status = await this.forceGetTmClient().status();
const status = await this.forceGetCometClient().status();
return status.syncInfo.latestBlockHeight;
}
@ -307,7 +307,7 @@ export class StargateClient {
}
public async getBlock(height?: number): Promise<Block> {
const response = await this.forceGetTmClient().block(height);
const response = await this.forceGetCometClient().block(height);
return {
id: toHex(response.blockId.hash).toUpperCase(),
header: {
@ -473,7 +473,7 @@ export class StargateClient {
* @returns Returns the hash of the transaction
*/
public async broadcastTxSync(tx: Uint8Array): Promise<string> {
const broadcasted = await this.forceGetTmClient().broadcastTxSync({ tx });
const broadcasted = await this.forceGetCometClient().broadcastTxSync({ tx });
if (broadcasted.code) {
return Promise.reject(
@ -487,7 +487,7 @@ export class StargateClient {
}
private async txsQuery(query: string): Promise<IndexedTx[]> {
const results = await this.forceGetTmClient().txSearchAll({ query: query });
const results = await this.forceGetCometClient().txSearchAll({ query: query });
return results.txs.map((tx): IndexedTx => {
const txMsgData = TxMsgData.decode(tx.result.data ?? new Uint8Array());
return {