Repository navigation
feat(stellar): accept client-supplied memo in confirmSend - #597
ulissesferreira wants to merge 1 commit into
Conversation
2960321 to
318d846
Compare
|
overall looks good, but just to make sure if we still need that or not |
318d846 to
bae8656
Compare
bae8656 to
cb94ac9
Compare
confirmSend
cb94ac9 to
29dd627
Compare
stanleyyconsensys
left a comment
There was a problem hiding this comment.
some enhancement comment
| /** | ||
| * Validation struct for {@link StellarMemoType}. | ||
| */ | ||
| export const StellarMemoTypeStruct = enums([ |
There was a problem hiding this comment.
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'), |
There was a problem hiding this comment.
nit:
| (value) => (value.length <= 64 ? true : 'Memo is too long'), | |
| (value: string) => { | |
| try { | |
| resolveStellarMemo(value) | |
| return true | |
| } catch (err) { | |
| return err.message | |
| } | |
| } |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
| memo: hasClientMemo ? memo : dialogResult.memo, | |
| memo: memo?.trim() || dialogResult.memo?.trim() || undefined |
There was a problem hiding this comment.
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,
29dd627 to
c5eb4fc
Compare
c5eb4fc to
ee35093
Compare
|



Explanation
Summary
Adds optional client-supplied
memo/memoTypeto the Stellar SnapconfirmSendclient request so off-ramp providers can pass their deposit memo through the send flow.Changes
ConfirmSendParamsStructaccepts optionalmemo(≤ 64 chars on the wire) andmemoType(MEMO_TEXT|MEMO_ID).resolveStellarMemonow honors an explicit type, so numeric text stays text; without a type it keeps inferringMEMO_IDfor all-digit uint64 values andMEMO_TEXTotherwise.memoTypethroughTransactionBuilder/TransactionServiceon the draft and post-confirm rebuild.RequiresMemoguard is retained. If the client supplied a memo but the draft still does not satisfy a memo-required destination (e.g. blank/whitespace),confirmSendrejects withRequiresMemoExceptioninstead of opening interactive memo recovery.confirmSenduse-case doc.Tests
yarn workspace @metamask/stellar-wallet-snap exec vitest run— 95 files, 1525 tests pass.yarn eslinton changed files, packagetsc --noEmit,oxfmt --check, andchangelog: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