-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: add function to mask address #12
Conversation
return "", ErrInvalidNumVisibleChars | ||
} | ||
|
||
prefixLength := len("0x") + numVisibleChars/2 // The number of characters to keep at the start (0x + first some hex digits) |
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.
minor, numVisibleChars/2
vs numVisibleChars / 2
🤔
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.
hmm, sometimes go formating is weird https://go.screenpal.com/watch/cZifeCV8zdQ
// @param numVisibleChars: The number of visible characters to keep at the start and end of the address | ||
// @param maskedCharacter: The character to use for masking the middle part of the address | ||
// @return The masked address and error if any | ||
func MaskAddress(address string, numVisibleChars int, maskedCharacter rune) (string, error) { |
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.
with negative numVisibleChars, this method will throw panic
panic: runtime error: slice bounds out of range [44:42] [recovered]
panic: runtime error: slice bounds out of range [44:42]
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.
thanks, good catch
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.
I pushed a commit to fix this
Why did we need it?
Related Issue
Release Note
How Has This Been Tested?
Screenshots (if appropriate):