-
Notifications
You must be signed in to change notification settings - Fork 295
feat: added custom tx builder for sol #6606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -147,6 +147,29 @@ export function isValidMemo(memo: string): boolean { | |||||
return Buffer.from(memo).length <= MAX_MEMO_LENGTH; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Checks if a string is valid base64 encoded data | ||||||
* @param str - The string to validate | ||||||
* @returns True if the string is valid base64, false otherwise | ||||||
*/ | ||||||
export function isValidBase64(str: string): boolean { | ||||||
try { | ||||||
const decoded = Buffer.from(str, 'base64').toString('base64'); | ||||||
return decoded === str; | ||||||
} catch { | ||||||
return false; | ||||||
} | ||||||
} | ||||||
|
||||||
/** | ||||||
* Checks if a string is valid hexadecimal data | ||||||
* @param str - The string to validate | ||||||
* @returns True if the string is valid hex, false otherwise | ||||||
*/ | ||||||
export function isValidHex(str: string): boolean { | ||||||
return /^[0-9A-Fa-f]*$/.test(str) && str.length % 2 === 0; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The regex allows empty strings to be considered valid hex, but an empty string has length 0 which satisfies the even length condition. This could lead to unexpected behavior when processing empty data strings.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||||||
} | ||||||
|
||||||
/** | ||||||
* Checks if raw transaction can be deserialized | ||||||
* | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data conversion logic tries base64 first, then hex, then UTF-8. However, some valid hex strings might also be valid base64, leading to incorrect interpretation. Consider adding explicit format indicators or more strict validation.
Copilot uses AI. Check for mistakes.