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

Allow simulation of messages without private key access #1568

Open
jmrossy opened this issue Mar 6, 2024 · 0 comments
Open

Allow simulation of messages without private key access #1568

jmrossy opened this issue Mar 6, 2024 · 0 comments

Comments

@jmrossy
Copy link

jmrossy commented Mar 6, 2024

Currently, the simulate function isn't available on the StargateClient, only the SigningStargateClient. But signing clients require access to the key, which isn't always practical or possible.

I've been able to hack together a key-less version based on the signing client's simulate method but official support in the StargateClient would be preferable.

  const registry = new Registry([...defaultRegistryTypes, ...wasmTypes]);
  const encodedMsg = registry.encodeAsAny(message);
  const encodedPubkey = encodeSecp256k1Pubkey(Buffer.from(senderPubKey, 'hex'));
  const { sequence } = await stargateClient.getSequence(sender);
  const { gasInfo } = await stargateClient
    // @ts-ignore force access to protected method
    .forceGetQueryClient()
    .tx.simulate([encodedMsg], memo, encodedPubkey, sequence);
  const gasUnits = Uint53.fromString(gasInfo.gasUsed.toString()).toNumber();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant