-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(bex): uppercase ownership string + default to the lowest fee
- Loading branch information
1 parent
46dfd91
commit 44ec51a
Showing
5 changed files
with
34 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
/** | ||
* Truncate a transaction or address hash | ||
* Truncate a transaction or address hash and optionally format with uppercase letters and a lowercase 'x'. | ||
*/ | ||
export const truncateHash = ( | ||
address: `0x${string}` | string, | ||
startLength = 4, | ||
endLength = 4, | ||
formatUppercase = false, | ||
) => { | ||
if (!address) return ""; | ||
|
||
return `${address.substring(0, startLength)}...${address.substring( | ||
address.length - endLength, | ||
)}`; | ||
const formattedAddress = formatUppercase | ||
? address.toUpperCase().replace(/^0X/, "0x") | ||
: address; | ||
|
||
return `${formattedAddress.substring( | ||
0, | ||
startLength, | ||
)}...${formattedAddress.substring(formattedAddress.length - endLength)}`; | ||
}; |