Open
Conversation
5 tasks
|
Size Change: +13.7 kB (+0.38%) Total Size: 3.62 MB
|
There was a problem hiding this comment.
Pull request overview
This PR migrates scval utilities to TypeScript and reorganizes/expands unit test coverage around nativeToScVal, scValToNative, and scValToBigInt.
Changes:
- Migrates
src/scvalimplementation to TypeScript with new exported typings and a standalonescvSortedMapexport (while keeping thexdr.scvSortedMapmonkey-patch for compatibility). - Replaces the prior “numbers” test aggregator with isolated Vitest test files, adding substantial new coverage for ScVal/native conversion.
- Adds a dedicated
scValToBigInttest suite and removes the oldtest/unit/numbers/index.test.ts.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/scval.ts |
TypeScript migration of core ScVal <-> native conversions and scvSortedMap implementation. |
type_validation/scval.d.ts |
Generated declaration output for scval after TS migration. |
test/unit/scval.test.ts |
New isolated Vitest suite for nativeToScVal, scValToNative, and scvSortedMap. |
test/unit/numbers/scval_to_bigint.test.ts |
New isolated Vitest suite for scValToBigInt. |
test/unit/numbers/index.test.ts |
Removed since tests were migrated into isolated files. |
Comments suppressed due to low confidence (3)
src/scval.ts:418
- Same issue as above for
scvString: on decode failure,new Uint8Array((v as ArrayBufferView).buffer)can include bytes outside the view due tobyteOffset/byteLengthbeing ignored. Use a view that respects offsets/lengths (and copy if needed) so the raw-bytes fallback matches the actual XDR string payload only.
src/scval.ts:266 - In the
number | bigintbranch, theu32/i32cases castvaltonumberbut don't convert at runtime. Whenvalis a bigint (e.g.100n), this will pass a bigint intoxdr.ScVal.scvU32/scvI32, which are typed to acceptnumberand will likely throw at runtime. Convert explicitly (e.g.Number(val)) and consider range-checking to ensure the bigint fits in 32 bits before constructing the ScVal.
src/scval.ts:405 - The fallback path when TextDecoder fails uses
new Uint8Array((v as ArrayBufferView).buffer), which ignoresbyteOffset/byteLengthfor Buffer/TypedArray views. For pooled Buffers this can return extra unrelated bytes beyond the actual string contents. Construct the Uint8Array usingbuffer,byteOffset, andbyteLength(and copy if desired) so the returned bytes exactly match the original view.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
scValToNativeandnativeToScValtests fromtests/numbers/index.test.tsinto isolated test filescValToNativeandnativeToScValscValToBigInttests/numbers/index.test.tsas all tests were migrated out