Skip to content

Add Zcash destination memo validation#470

Open
tzarebczan wants to merge 1 commit into
Near-One:mainfrom
tzarebczan:feat/zcash-destination-memo
Open

Add Zcash destination memo validation#470
tzarebczan wants to merge 1 commit into
Near-One:mainfrom
tzarebczan:feat/zcash-destination-memo

Conversation

@tzarebczan
Copy link
Copy Markdown

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 destinationMemo field 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

  • Adds destinationMemo?: string to TransferParams.
  • Adds INVALID_MEMO as a validation error code.
  • Validates the UTF-8 byte length with TextEncoder, not JavaScript character count.
  • Enforces the 512-byte Zcash memo limit with details containing both byteLength and maxByteLength.
  • Adds focused validation tests for:
    • exactly 512 bytes accepted
    • 513 bytes rejected
    • multi-byte UTF-8 counted as bytes
    • undefined memo accepted
  • Adds a patch changeset for @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

  • bun pre-commit hook passed:
    • biome check on changed files
    • tsc --build
  • node_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.md
  • node_modules\.bin\tsc.exe --build
  • node_modules\.bin\vitest.exe run packages --pool=threads

All package tests passed locally: 18 test files, 271 tests.

@tzarebczan tzarebczan requested review from a team as code owners May 11, 2026 14:41
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 11, 2026

🦋 Changeset detected

Latest commit: 2999fb4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@omni-bridge/core Patch
@omni-bridge/btc Patch
@omni-bridge/sdk Patch
@omni-bridge/solana Patch
@omni-bridge/starknet Patch
@omni-bridge/evm Patch
@omni-bridge/near Patch

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?: string to TransferParams and export a new validation error code INVALID_MEMO.
  • Enforce a 512-byte UTF-8 memo size limit during Bridge.validateTransfer.
  • Add focused vitest coverage 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.

Comment thread packages/core/src/bridge.ts Outdated
Comment thread packages/core/src/bridge.ts Outdated
Comment thread packages/core/tests/bridge.test.ts
@tzarebczan tzarebczan force-pushed the feat/zcash-destination-memo branch 2 times, most recently from 48a8aea to 89cab93 Compare May 22, 2026 20:29
@tzarebczan tzarebczan force-pushed the feat/zcash-destination-memo branch from 89cab93 to 2999fb4 Compare May 26, 2026 13:06
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