Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend CosmWasmSigningClient with options so we inject a custom AccountParser #377

Closed
Unique-Divine opened this issue Oct 4, 2024 · 1 comment · Fixed by #379
Closed
Assignees
Labels
released type: enhance New feature, feature request, or enhancement

Comments

@Unique-Divine
Copy link
Member

Unique-Divine commented Oct 4, 2024

Purpose

Description

The SigningCosmWasmClient from cosmjs has a constructor that takes options through SigningCosmWasmClientOptions, however these options do not any way to configure the account parse that's used for functions like SigningCosmWasmClient.getAccounts.

export interface SigningCosmWasmClientOptions {
  readonly registry?: Registry;
  readonly aminoTypes?: AminoTypes;
  readonly broadcastTimeoutMs?: number;
  readonly broadcastPollIntervalMs?: number;
  readonly gasPrice?: GasPrice;
}

@CalicoNino posted a comment in #371 (comment) with more details:

Outline of a similar issue with ethermint

Since the fix requires a change to the Account parser in cosmjs, and seems that isn't going to be worked on. We could potentially append their existing account parser to accept our eth account, outlined here.

A possible solution is that we can either extend or create a wrapper for the NibiruTxClient to accept ethaccounts. Found this script that allows signing and simulating Cosmos-EVM transactions using Keplr:

  • signEvmWithKeplr: It fetches account details, constructs a transaction, and signs it using Keplr for Cosmos-EVM chains like Sei Network and Evmos. The signed transaction is returned ready for broadcast.
  • simulateEvmWithKeplr: It simulates a transaction to estimate gas usage by creating and sending a mock transaction without broadcasting it.
[Click to expand constructor code block]
export class SigningCosmWasmClient extends CosmWasmClient {
  public readonly registry: Registry;
  public readonly broadcastTimeoutMs: number | undefined;
  public readonly broadcastPollIntervalMs: number | undefined;

  private readonly signer: OfflineSigner;
  private readonly aminoTypes: AminoTypes;
  private readonly gasPrice: GasPrice | undefined;

  /**
   * Creates an instance by connecting to the given CometBFT RPC endpoint.
   *
   * This uses auto-detection to decide between a CometBFT 0.38, Tendermint 0.37 and 0.34 client.
   * To set the Comet client explicitly, use `createWithSigner`.
   */
  public static async connectWithSigner(
    endpoint: string | HttpEndpoint,
    signer: OfflineSigner,
    options: SigningCosmWasmClientOptions = {},
  ): Promise<SigningCosmWasmClient> {
    const cometClient = await connectComet(endpoint);
    return SigningCosmWasmClient.createWithSigner(cometClient, signer, options);
  }

  /**
   * Creates an instance from a manually created Comet client.
   * Use this to use `Comet38Client` or `Tendermint37Client` instead of `Tendermint34Client`.
   */
  public static async createWithSigner(
    cometClient: CometClient,
    signer: OfflineSigner,
    options: SigningCosmWasmClientOptions = {},
  ): Promise<SigningCosmWasmClient> {
    return new SigningCosmWasmClient(cometClient, signer, options);
  }
@github-actions github-actions bot added the S-triage Status: This issue is waiting on initial triage. More Info: https://tinyurl.com/25uty9w5 label Oct 4, 2024
@Unique-Divine Unique-Divine removed the S-triage Status: This issue is waiting on initial triage. More Info: https://tinyurl.com/25uty9w5 label Oct 5, 2024
@CalicoNino CalicoNino self-assigned this Oct 8, 2024
@cgilbe27 cgilbe27 added the type: enhance New feature, feature request, or enhancement label Oct 9, 2024
@nibibot
Copy link

nibibot commented Oct 18, 2024

🎉 This issue has been resolved in version 5.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released type: enhance New feature, feature request, or enhancement
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants