Skip to content

Conversation

@theforager
Copy link
Contributor

Fixes #183

Issue

When simulation fails, abciQuery wasn't checking the ABCI response code. If fromBase64() happened to succeed on empty/garbage data, the error got swallowed entirely. Users end up seeing gasWanted: 0, gasUsed: 1000 with no idea why.

Fix

Check response['code'] !== 0 before trying to decode. If it's non-zero, throw an AbciError with the code and log message so callers can actually see what went wrong.

Added a new AbciError type to @interchainjs/types that includes the raw ABCI code and log:

try {
  await client.simulate(tx);
} catch (e) {
  if (e instanceof AbciError) {
    console.log(`code ${e.abciCode}: ${e.log}`);
  }
}

Changes

- packages/types/src/errors.ts - new AbciError class
- packages/utils/src/rpc.ts - check response code, use typed errors
- packages/utils/src/rpc.spec.ts - tests for error handling

Backward compatible since AbciError still extends Error.

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

Successfully merging this pull request may close these issues.

simulateByTxBody seems broken. ABCI errors are swallowed

1 participant