Add Zcash destination memo validation#470
Open
tzarebczan wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: 2999fb4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
b80f172 to
78c49ee
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a typed destinationMemo field to core transfer params and introduces SDK-boundary validation for Zcash memo size (UTF-8 byte length), with accompanying unit tests and a patch changeset for @omni-bridge/core.
Changes:
- Add
destinationMemo?: stringtoTransferParamsand export a new validation error codeINVALID_MEMO. - Enforce a 512-byte UTF-8 memo size limit during
Bridge.validateTransfer. - Add focused
vitestcoverage for accepted/rejected memo lengths (including multi-byte UTF-8).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/bridge.ts | Adds Zcash memo byte-length validation in validateTransfer. |
| packages/core/src/types.ts | Extends TransferParams with an optional destinationMemo field and doc comment. |
| packages/core/src/errors.ts | Adds INVALID_MEMO to ValidationErrorCode. |
| packages/core/tests/bridge.test.ts | Adds unit tests for memo validation behavior. |
| .changeset/zcash-memo-validation.md | Patch changeset entry for @omni-bridge/core. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
48a8aea to
89cab93
Compare
89cab93 to
2999fb4
Compare
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.
Package: Zcash memo support
This is the JS SDK half of a coordinated two-repo package for Zcash memo support.
Companion PR: Near-One/bridge-sdk-rs#276
Summary
Adds a typed
destinationMemofield to the core transfer params and validates the Zcash memo size limit at the SDK boundary before downstream services forward the memo into the Rust bridge SDK / CLI path.This keeps frontend / API callers able to pass the memo field uniformly while the Rust companion PR is responsible for embedding it in the destination Orchard output.
Details
destinationMemo?: stringtoTransferParams.INVALID_MEMOas a validation error code.TextEncoder, not JavaScript character count.byteLengthandmaxByteLength.@omni-bridge/core.Relationship to Rust PR
The Rust PR adds the actual memo-aware Zcash SDK / CLI paths and embeds the memo in Orchard shielded outputs. This JS PR provides the consumer-facing type and validation layer expected by callers before handing the memo off to that backend path.
Together, the two PRs make Zcash memo support available end-to-end while keeping existing BTC and shared BTC/Zcash paths unchanged.
Validation
bunpre-commit hook passed:biome checkon changed filestsc --buildnode_modules\.bin\biome.exe check packages/core/src/bridge.ts packages/core/src/types.ts packages/core/src/errors.ts packages/core/tests/bridge.test.ts .changeset/zcash-memo-validation.mdnode_modules\.bin\tsc.exe --buildnode_modules\.bin\vitest.exe run packages --pool=threadsAll package tests passed locally: 18 test files, 271 tests.