-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32b408b
commit c1a29e3
Showing
10 changed files
with
328 additions
and
19 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
14 changes: 14 additions & 0 deletions
14
packages/protocol-kit/src/utils/on-chain-tracking/formatTrackId.ts
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { keccak256, toHex } from 'viem' | ||
|
||
/** | ||
* Formats a trackId to convert it into an Ethereum address. This address can be used in | ||
* fields like `paymentReceiver` and `refundReceiver` to track Safe transactions and deployments. | ||
* | ||
* @param {string} trackId - The identifier provided by the user. | ||
* @returns {`0x${string}`} - The Ethereum address derived from the identifier. | ||
*/ | ||
function formatTrackId(trackId: string): `0x${string}` { | ||
return `0x${keccak256(toHex(trackId)).substring(2, 42)}` // only first 40 chars from the hash | ||
} | ||
|
||
export default formatTrackId |
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
Oops, something went wrong.