Skip to content

fix(transaction): reject empty and whitespace-only memos by default (… - #884

Merged
Just-Bamford merged 1 commit into
Sorokit:mainfrom
DANTE-1903:feat/846-validate-memo-length
Oct 22, 2026
Merged

Just-Bamford merged 1 commit into
Sorokit:mainfrom
DANTE-1903:feat/846-validate-memo-length

Conversation

@DANTE-1903

Copy link
Copy Markdown

fix(transaction): reject empty and whitespace-only memos by default (#846)
──────
### Summary

Closes #846                                                                                      
                                                                                                 
This PR adds validation to reject empty and whitespace-only memos by default across              

TransactionBuilder, transaction builder functions, and compose(), while allowing callers to
explicitly opt-in to empty or whitespace memos when needed.

### Changes Made                                                                                 
                                                                                                 
- **TransactionBuilder**:                                                                        
  - Implemented `setMemo(memo: string, options?: SetMemoOptions)` and `getMemo()`.               
  - Added default validation to throw an error (`"Memo cannot be empty or whitespace-only"`) when

passed an empty or whitespace-only string, with { allowEmpty: true } opt-in support.
- Memo Policy Enforcement:
- Updated validateMemoPolicy() in src/transaction/buildTransaction.ts to reject empty or
whitespace-only memos by default with TX_BUILD_FAILED ("Memo cannot be empty or whitespace- only").
- Supported opt-in via allowEmptyMemo?: boolean or memoValidation: { allowEmpty: true }.
- Preserved backward compatibility for rule: "prohibit" where omitting or passing an empty
memo string represents no attached memo.
- Builders & Compose Integration:
- Updated resolveMemo in buildHelpers.ts and transactionContext.ts to respect
allowEmpty configurations.
- Added allowEmptyMemo?: boolean to ComposeOptions and { allowEmpty?: boolean } options
parameter to compose().addMemo().
- Types & Exports:
- Added allowEmpty?: boolean to MemoValidationConfig.
- Added allowEmptyMemo?: boolean to MemoParams.
- Exported SetMemoOptions from src/transaction/index.ts.
- Tests:
- Added comprehensive test coverage in src/tests/memo-validation-length.test.ts testing
createTransactionBuilder().setMemo(), validateMemoPolicy(), and compose().addMemo() edge
cases (zero-length strings, whitespace characters \t\n , and opt-ins).
- Updated existing builder tests in src/tests/transaction.test.ts.

### Verification

All checks have passed locally:
- `npm run typecheck`
- `npm run lint`
- `npm test` (3862 passing tests)
- `npm run build`

closes #846

@drips-wave

drips-wave Bot commented Oct 21, 2026

Copy link
Copy Markdown

@DANTE-1903 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! 🚀

Learn more about application limits

@Just-Bamford
Just-Bamford merged commit 6e4537f into Sorokit:main Oct 22, 2026
5 checks passed
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.

TransactionBuilder does not enforce minimum memo length — allows empty or whitespace-only memos

2 participants