Skip to content

feat(stellar): accept client-supplied memo in confirmSend - #597

Open
ulissesferreira wants to merge 1 commit into
mainfrom
WPN-2386-stellar-client-supplied-memo
Open

ulissesferreira wants to merge 1 commit into
mainfrom
WPN-2386-stellar-client-supplied-memo

Conversation

@ulissesferreira

@ulissesferreira ulissesferreira commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

Summary

Adds optional client-supplied memo / memoType to the Stellar Snap confirmSend client request so off-ramp providers can pass their deposit memo through the send flow.

Changes

  • ConfirmSendParamsStruct accepts optional memo (≤ 64 chars on the wire) and memoType (MEMO_TEXT | MEMO_ID).
  • resolveStellarMemo now honors an explicit type, so numeric text stays text; without a type it keeps inferring MEMO_ID for all-digit uint64 values and MEMO_TEXT otherwise.
  • Threaded memoType through TransactionBuilder / TransactionService on the draft and post-confirm rebuild.
  • The client memo is used on both builds. The dialog memo remains a fallback only when the client sent no memo.
  • The SEP-29 / SEP-37 RequiresMemo guard is retained. If the client supplied a memo but the draft still does not satisfy a memo-required destination (e.g. blank/whitespace), confirmSend rejects with RequiresMemoException instead of opening interactive memo recovery.
  • Unit tests cover text memos, ID memos, missing memos, dialog fallback, client-memo precedence, and the conflict case.
  • Updated the confirmSend use-case doc.

Tests

  • yarn workspace @metamask/stellar-wallet-snap exec vitest run — 95 files, 1525 tests pass.
  • yarn eslint on changed files, package tsc --noEmit, oxfmt --check, and changelog:validate.
  • yarn workspace @metamask/stellar-wallet-snap run build (after building @metamask/snap-networks-utils).

References

Ticket: WPN-2386
Spec: WPN-2368
Stacked on: #594

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

@ulissesferreira
ulissesferreira force-pushed the WPN-2386-stellar-client-supplied-memo branch 2 times, most recently from 2960321 to 318d846 Compare November 10, 2026 15:55
@ulissesferreira
ulissesferreira marked this pull request as ready for review November 10, 2026 16:04
@ulissesferreira
ulissesferreira requested review from a team as code owners November 10, 2026 16:04
@stanleyyconsensys

Copy link
Copy Markdown
Contributor

overall looks good, but just to make sure if we still need that or not

@ulissesferreira
ulissesferreira force-pushed the WPN-2386-stellar-client-supplied-memo branch from 318d846 to bae8656 Compare November 11, 2026 10:19
Base automatically changed from WPN-2383-stellar-off-ramp to main November 12, 2026 09:37
@ulissesferreira
ulissesferreira force-pushed the WPN-2386-stellar-client-supplied-memo branch from bae8656 to cb94ac9 Compare November 12, 2026 10:03
@ulissesferreira ulissesferreira changed the title feat(stellar): accept client-supplied memo in confirmSend feat(stellar): accept client-supplied memo in confirmSend Nov 12, 2026
@ulissesferreira
ulissesferreira force-pushed the WPN-2386-stellar-client-supplied-memo branch from cb94ac9 to 29dd627 Compare November 12, 2026 10:36
khanti42
khanti42 previously approved these changes Nov 12, 2026

@stanleyyconsensys stanleyyconsensys left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

some enhancement comment

/**
* Validation struct for {@link StellarMemoType}.
*/
export const StellarMemoTypeStruct = enums([

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question:

from the snap path
it detect the memo type by value (packages/stellar-wallet-snap/src/services/transaction/memo.ts)
shall we align?

if this is the case , then we dont need to update the change of resolveStellarMemo

export const StellarMemoValueStruct = refine(
string(),
'stellar-memo-value',
(value) => (value.length <= 64 ? true : 'Memo is too long'),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
(value) => (value.length <= 64 ? true : 'Memo is too long'),
(value: string) => {
try {
resolveStellarMemo(value)
return true
} catch (err) {
return err.message
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I tried this, but importing resolveStellarMemo into src/api/string.ts creates a dependency cycle (api/string → services/transaction/memo → exceptions → utils/errors → logger → config → api) and the Snap build fails in SES with ReferenceError: Cannot access 'Vi' before initialization.

I kept the loose 64-char wire check and strict type/length validation in resolveStellarMemo at build time. If you'd prefer wire-level validation, I can move the memo parsing into a dependency-free module and import it from both places

confirmedTransaction: transaction,
amount: amountInSmallestUnit,
memo: dialogResult.memo ?? undefined,
memo: hasClientMemo ? memo : dialogResult.memo,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
memo: hasClientMemo ? memo : dialogResult.memo,
memo: memo?.trim() || dialogResult.memo?.trim() || undefined

@ulissesferreira ulissesferreira Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the same behavior in a lint-safe form. The one-liner uses ||, but Oxlint's prefer-nullish-coalescing rule rejects it, and ?? would change behavior for empty/whitespace memos (it would stop falling back to the dialog memo).

I kept the explicit equivalent:

const hasClientMemo = memo !== undefined && memo.trim() !== '';
...
memo: hasClientMemo ? memo : dialogResult.memo,

@ulissesferreira
ulissesferreira force-pushed the WPN-2386-stellar-client-supplied-memo branch from c5eb4fc to ee35093 Compare November 17, 2026 16:01
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

3 participants