Repository navigation
feat(frontend): add memo byte-size estimator module (#374) - #473
Open
jdjioe5-cpu wants to merge 1 commit into
Open
jdjioe5-cpu wants to merge 1 commit into
jdjioe5-cpu wants to merge 1 commit into
Conversation
- Implement frontend/src/memoSizeEstimate.js to estimate encoded memo byte size against Stellar protocol limits - Support text (28 bytes UTF-8), id (uint64, 8 bytes), hash/return (32 bytes), and none (0 bytes) - Export constants MEMO_LIMITS, MAX_MEMO_ID, and MEMO_TYPES - Handle multi-byte UTF-8, integer overflow checks, hex verification, and options object invocation - Add 9 single-behavior Vitest test files covering happy path, UTF-8, overflow, hex validation, constants, and error cases - Add documentation under docs/features/memoSizeEstimate.md Closes Kitewell-lab#374
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.
Summary
Implements the memo byte-size estimator in
frontend/src/memoSizeEstimate.jsto estimate encoded byte size against Stellar's protocol limits per #374.Changes
frontend/src/memoSizeEstimate.jsexportingestimateMemoSize(andmemoSizeEstimatealias) andgetUtf8ByteLengthtext(up to 28 bytes UTF-8),id(64-bit unsigned integer, 8 bytes),hash/return(32 bytes), andnone(0 bytes)TextEncoder18446744073709551615nfor memo IDsfrontend/src/memoSizeEstimateConstants.js(MEMO_LIMITS,MAX_MEMO_ID,MEMO_TYPES)frontend/src/:memoSizeEstimate-text-happy.test.js(valid ASCII and UTF-8 text within 28 bytes)memoSizeEstimate-text-overflow.test.js(text exceeding 28 UTF-8 bytes)memoSizeEstimate-id-valid.test.js(valid ID numbers, strings, and bigints)memoSizeEstimate-id-overflow.test.js(IDs exceeding 64-bit uint limits or negative numbers)memoSizeEstimate-hash.test.js(valid and invalid 32-byte hash and return memos)memoSizeEstimate-none.test.js(none memo type with 0 bytes)memoSizeEstimate-options-object.test.js(options object interface)memoSizeEstimate-invalid-type.test.js(unknown memo type rejection)memoSizeEstimate-constants.test.js(constant immutability verification)docs/features/memoSizeEstimate.mdVerification
npm test -- --runrun fromfrontend/passes 190/190 test files and 432/432 tests cleanCloses #374