Created
February 22, 2022 01:19
-
-
Save tgmarinho/d6d034173dd882172eed03d2c1f79814 to your computer and use it in GitHub Desktop.
address format eth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const reduceAddress = (address: string) => { | |
// it's an ens | |
if (address.includes('.')) return address | |
const start = address.substring(0, 6) | |
const middle = '...' | |
const end = address.substring(address.length - 4) | |
return `${start}${middle}${end}` | |
} | |
export const addressWithYou = (address: string, currentUserAddress: string) => { | |
return address?.toLowerCase() === currentUserAddress?.toLowerCase() | |
? `You (${reduceAddress(address)})` | |
: reduceAddress(address) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment