Skip to content

Scope facilitator memo to V2 in 2.0.2#12

Open
tony1908 wants to merge 7 commits into
mainfrom
feat/v2-facilitator-memo-2-0-2
Open

Scope facilitator memo to V2 in 2.0.2#12
tony1908 wants to merge 7 commits into
mainfrom
feat/v2-facilitator-memo-2-0-2

Conversation

@tony1908
Copy link
Copy Markdown
Owner

Summary

  • restore legacy V1 memo behavior while keeping the compact facilitator memo convention scoped to the default V2 signing path
  • add facilitator memo helpers plus Jest regression coverage for V2 signing and helper parsing behavior
  • bump the package to 2.0.2 and document the memo convention as V2-only

Test Plan

  • npm test
  • npm run build

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new Facilitator Memo Convention (V2) for transaction attribution in the x402-stacks SDK. Key changes include the addition of utility functions for creating, normalizing, and parsing facilitator memos, as well as updating the V2 interceptor to adopt this new format. The PR also includes a version bump to 2.0.2, new Jest configuration, and comprehensive test suites for the memo logic. One performance improvement was suggested regarding the implementation of the memo validation utility.

Comment thread src/utils.ts
Comment on lines +45 to +47
export function isFacilitatorMemo(memo: string): boolean {
return new RegExp(`^${FACILITATOR_MEMO_PREFIX}[A-Za-z0-9_-]{24}$`).test(memo);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The isFacilitatorMemo function creates a new RegExp object on every invocation. Since the prefix is a constant and the nonce pattern is already defined as a constant (FACILITATOR_NONCE_PATTERN), it is more efficient to reuse the existing pattern or perform a string prefix check followed by the nonce validation. This avoids unnecessary object allocation and compilation overhead, which is beneficial if this utility is used in performance-sensitive areas like transaction scanning.

Suggested change
export function isFacilitatorMemo(memo: string): boolean {
return new RegExp(`^${FACILITATOR_MEMO_PREFIX}[A-Za-z0-9_-]{24}$`).test(memo);
}
export function isFacilitatorMemo(memo: string): boolean {
return memo.startsWith(FACILITATOR_MEMO_PREFIX) && FACILITATOR_NONCE_PATTERN.test(memo.substring(FACILITATOR_MEMO_PREFIX.length));
}

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.

1 participant