Skip to content

Commit

Permalink
rename to formatPubkeyShort
Browse files Browse the repository at this point in the history
  • Loading branch information
macalinao committed Oct 7, 2022
1 parent 9704b89 commit 6b21f01
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/solana-contrib/src/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ export const valueAsPromise = async <T>(
* @param pubkey
* @returns
*/
export const shortenPubkey = (pubkey: PublicKey): string => {
export const formatPubkeyShort = (
pubkey: PublicKey,
leading = 7,
trailing = 7
): string => {
const str = pubkey.toString();
return str.length > 20
? `${str.substring(0, 7)}.....${str.substring(str.length - 7, str.length)}`
? `${str.substring(0, leading)}.....${str.substring(
str.length - trailing,
str.length
)}`
: str;
};

0 comments on commit 6b21f01

Please sign in to comment.