Skip to content

Fix weight_limit auto-fill encoding error after gas estimation#43

Merged
itsyogesh merged 1 commit intomasterfrom
fix/weight-autofill-encoding
Mar 23, 2026
Merged

Fix weight_limit auto-fill encoding error after gas estimation#43
itsyogesh merged 1 commit intomasterfrom
fix/weight-autofill-encoding

Conversation

@itsyogesh
Copy link
Copy Markdown
Owner

Summary

Fixes the "Cannot mix BigInt and other types" error in the Information Pane when gas estimation auto-fills the weight_limit field for revive.instantiateWithCode.

Root Cause

The auto-fill code was reading struct field names from metadata, which returns snake_case (ref_time, proof_size). But Dedot's SCALE codec normalizes field access to camelCase (refTime, proofSize). When the codec tried to encode { ref_time: BigInt(117234441), proof_size: BigInt(0) }, it didn't match the expected struct shape and threw a BigInt type mixing error.

Fix

Simplified the auto-fill to always use camelCase keys matching Dedot's convention. Removed the metadata field name resolution that was producing the wrong casing.

Test plan

  • Builder > Revive > instantiate_with_code > Compile > Estimate Gas
  • weight_limit Hex field shows valid hex (not 0x with error)
  • storageDepositLimit Hex field shows valid hex
  • yarn test passes

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
relaycode Ready Ready Preview, Comment Mar 23, 2026 9:36pm

Request Review

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 23, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 56.25000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.84%. Comparing base (ee246d9) to head (8024ee1).

Files with missing lines Patch % Lines
components/builder/extrinsic-builder.tsx 0.00% 5 Missing ⚠️
lib/codec.ts 81.81% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #43      +/-   ##
==========================================
+ Coverage   48.79%   48.84%   +0.05%     
==========================================
  Files         181      181              
  Lines       23014    23004      -10     
  Branches     1237     1235       -2     
==========================================
+ Hits        11229    11236       +7     
+ Misses      11737    11720      -17     
  Partials       48       48              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Dedot's SCALE codec normalizes struct field names to camelCase via
stringCamelCase (ref_time -> refTime, proof_size -> proofSize). Our
codec and auto-fill code was using raw metadata names (snake_case),
causing 'Cannot mix BigInt and other types' encoding errors in the
Information Pane after gas estimation.

Fix at the shared layer:
- Add normalizeFieldName() to lib/codec.ts matching Dedot's convention
- Use it in decomposeArgHex for struct and enum field value lookups
- Simplify gas estimation auto-fill to use camelCase directly
- Add regression tests: normalizeFieldName unit tests (4), snake_case
  struct decomposition with camelCase values (1), already-camelCase
  struct decomposition (1)
@itsyogesh itsyogesh force-pushed the fix/weight-autofill-encoding branch from fcc286c to 8024ee1 Compare March 23, 2026 21:34
@itsyogesh itsyogesh merged commit 22a90b8 into master Mar 23, 2026
5 checks passed
@itsyogesh itsyogesh deleted the fix/weight-autofill-encoding branch March 23, 2026 21:38
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