Skip to content

fix(schema): accept proto-JSON Any in tx body extension_options#113

Merged
evilpeach merged 2 commits into
mainfrom
fix/extension-options-proto-json
Jun 12, 2026
Merged

fix(schema): accept proto-JSON Any in tx body extension_options#113
evilpeach merged 2 commits into
mainfrom
fix/extension-options-proto-json

Conversation

@evilpeach

@evilpeach evilpeach commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

What

Fixes decodeCosmosTransaction rejecting any transaction whose body carries a non-empty extension_options array, e.g. queued txs with {"@type": "/initia.tx.v1.ExtensionOptionQueuedTx"} on initiation-2.

Why

zTxBody validated extension_options and non_critical_extension_options with zAny, the protobuf runtime shape ({ typeUrl: string, value: number[] }). But REST/indexer APIs return the proto-JSON encoding of google.protobuf.Any ({ "@type": string, ...fields }). The wrong element schema was never exercised because these arrays were always empty — until queued txs appeared:

Invalid txResponse: ... tx.body.extension_options.0.typeUrl Required

Repro: tx 5126CB517545FE819676F16656D5944C2F53ABDD180A1EE4A326EC5EC7F0CBE4 on initiation-2.

Changes

  • Validate both fields with z.array(zMessage) — the proto-JSON Any schema ({ "@type": z.string() }.passthrough()) already used for messages.
  • Remove zAny from src/schema/common.ts: those two fields were its only usages (verified by grep), and it is not part of the package's public API.
  • Add a regression test using the real tx_response payload of the failing tx; it asserts the tx parses and the MsgSend decodes end-to-end. Verified the test fails with the exact reported error before the fix.

Notes for reviewers

  • All 66 suites / 114 tests pass; tsc --noEmit, eslint, and prettier are clean.
  • celatone-frontend fixed its own copy of this bug separately (src/lib/services/types/tx.ts); after this is released, celatone-frontend needs a version bump of @initia/tx-decoder to pick up the fix.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores

    • Updated package manager to pnpm 11.0.8
    • Upgraded CI/CD tooling and refined workspace build configuration
    • Simplified internal schema definitions for improved maintainability
  • Tests

    • Added comprehensive test coverage for transaction extension options to ensure proper handling of complex transaction structures

evilpeach and others added 2 commits June 11, 2026 23:22
extension_options and non_critical_extension_options were validated
with the protobuf runtime Any shape ({ typeUrl, value }), but REST and
indexer APIs return the proto-JSON encoding ({ "@type", ...fields }).
The wrong element schema was never exercised because these arrays were
always empty, until queued txs carrying
/initia.tx.v1.ExtensionOptionQueuedTx appeared on initiation-2 and
decodeCosmosTransaction started rejecting them.

Validate both fields with zMessage (the proto-JSON Any schema already
used for messages), drop the now-unused zAny, and add a regression test
with the real failing tx payload.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
CI uses pnpm/action-setup with version: latest, which now resolves to
pnpm 11. pnpm 11 replaced onlyBuiltDependencies with an allowBuilds map
and hard-fails install when dependency build scripts are unapproved
(ERR_PNPM_IGNORED_BUILDS), breaking the install step before tests run.

Declare explicit allowBuilds decisions, pin the package manager via the
packageManager field, and let pnpm/action-setup@v4 pick up the pinned
version so CI no longer drifts with pnpm releases. Same setup as the
initia multisig repo.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The PR updates transaction extension options validation from generic zAny schemas to typed zMessage arrays, updates pnpm tooling to v4 with version pinning, and adds comprehensive test coverage for decoding transactions containing queued extension options.

Changes

Extension Options Schema & Test Support

Layer / File(s) Summary
Tooling and Dependency Updates
.github/workflows/ci-tests.yml, package.json, pnpm-workspace.yaml
CI workflow upgrades pnpm action to v4, package.json pins pnpm@11.0.8, and workspace config transitions from onlyBuiltDependencies to allowBuilds with build restrictions for esbuild and simple-git-hooks.
Extension Options Schema Validation
src/schema/common.ts, src/schema/cosmos/transaction.ts
Removes the exported zAny schema definition and updates zTxBody.extension_options from zAny.array() to z.array(zMessage) to model extension options as proto-JSON encoded Any messages.
Test Fixtures and Test Suite
src/tests/common/extension-options.fixture.ts, src/tests/common/extension-options.test.ts
Adds mockMsgSendWithQueuedTxExtension fixture with a complete queued transaction structure and extension options, along with API mock responses, plus a Jest test suite that decodes the transaction and validates the decoded message payload.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A schema made clear, once fuzzy and vague,
Extension options now wear a typed badge,
With fixtures and tests in a queued transaction's place,
The decoder hops forward at a faster pace! 🏃‍♂️✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main fix: updating the schema to accept proto-JSON Any in tx body extension_options, which aligns with the core change across multiple schema files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/extension-options-proto-json

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Comment @coderabbitai help to get the list of available commands and usage tips.

@evilpeach
evilpeach requested a review from songwongtp June 11, 2026 16:34

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci-tests.yml:
- Line 22: Replace the floating tag usage of the GitHub Action used in the
workflow (the step referencing "uses: pnpm/action-setup@v4") with a pinned
commit SHA; locate the step that currently uses pnpm/action-setup@v4 and change
it to pnpm/action-setup@<full-commit-hash> (use the full 40-char commit from the
pnpm/action-setup repo release you want) so the workflow is pinned to a specific
commit for supply-chain security.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4e06979f-aa71-4644-a2e3-f3048b6acae8

📥 Commits

Reviewing files that changed from the base of the PR and between 0546258 and 948a0fc.

📒 Files selected for processing (7)
  • .github/workflows/ci-tests.yml
  • package.json
  • pnpm-workspace.yaml
  • src/schema/common.ts
  • src/schema/cosmos/transaction.ts
  • src/tests/common/extension-options.fixture.ts
  • src/tests/common/extension-options.test.ts
💤 Files with no reviewable changes (1)
  • src/schema/common.ts

Comment thread .github/workflows/ci-tests.yml
@evilpeach
evilpeach merged commit a0b8ae9 into main Jun 12, 2026
5 checks passed
@evilpeach
evilpeach deleted the fix/extension-options-proto-json branch June 12, 2026 03:07
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.

2 participants