fix(builder): encode ScVals with ABI-correct integer types - #583
Merged
Jaydbrown merged 2 commits intoAug 31, 2026
Merged
Conversation
…rotocol#497) paramToScVal() forced every integer number to i64 and every bigint to i128, so u64 contract parameters — create_stream's start_time/end_time and stream IDs — arrived with the wrong ScVal type and were rejected contract-side. Untyped positive integers now encode as u64 (negatives as i64), explicit ScVal type hints are supported, already-encoded xdr.ScVals pass through untouched, and BatchOperation.types supplies per-field type information for the params map. ConduitBatcher.execute()'s create_stream path now builds ABI-exact positional args (i128 amounts, u64 times, bool clawback) and honors startTime/endTime/clawbackEnabled. Also removes a duplicate `let consecutiveFailures` in src/events.ts that made the module a SyntaxError, breaking the build and every event-subscription test. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@p4uld4vid016-code Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #497
Problem
paramToScVal()insrc/batch-tx.tsforced every integernumbertoi64and everybiginttoi128.create_stream'sstart_time/end_timeareu64and stream IDs areu64, so passing these through the params path produced the wrong ScVal type and a contract-side type error. The map path had no way to carry per-field type information.Changes
paramToScVal(value, type?)— no longer blanket-encodes integers:u64, negatives asi64(the natural SDK encoding, which matches the u64-heavy ABI).typehint ('u64','i128', ...) forces a specific width.xdr.ScVals pass through untouched.BatchOperation.types(andBuildableOperation.types) supplies per-field ScVal type hints forparamsmap entries, e.g.{ method: 'withdraw', params: { streamId: 1n }, types: { streamId: 'u64' } }.ScValTypeis exported from the package entry point.ConduitBatcher.execute()create_stream path — now builds ABI-exact positional args:deposit_amount/rate_per_secasi128,start_time/end_timeasu64(honoringstartTime/endTime/clawbackEnabledwhen present),clawback_enabledasbool.let consecutiveFailuresdeclaration insrc/events.ts(introduced onmainin fix(sdk): dedupe progress calc, unify NonceManager, harden event polling (#482, #483, #484, #485) #499) that made the module aSyntaxError, breakingnpm run typecheck, thenpm cibuild, and every event-subscription test; fixed the stalestartLedgerassertion inevents-subscribe.test.tsthat could never run before.Tests
src/tests/builder-param-encoding.test.tscovering the ABI-exactexecute()create_stream args (decoded from real XDR), per-fieldtypesfor u64 stream IDs, bigint amounts stayingi128, and pre-encoded ScVal passthrough.batch-real-xdr.test.tsparameter-encoding tests for the new defaults + type hints + ScVal passthrough.npm run typecheck,npm run lint,npm run build, and the full vitest suite (853 passed, 2 skipped) are green.