-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(secret): token id conversion after lock and before claim
- Loading branch information
1 parent
8c2dbad
commit c56ca0c
Showing
3 changed files
with
30 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const convertStringToHexToNumb = (str: string) => { | ||
const hex = Array.from(str) | ||
.map((char) => char.charCodeAt(0).toString(16).padStart(2, "0")) | ||
.join(""); | ||
const numb = BigInt(`0x${hex}`); | ||
return numb.toString(); | ||
}; | ||
export const convertNumbToHexToString = (num: string) => { | ||
const numberToBigInt = BigInt(num); | ||
const hex = numberToBigInt.toString(16) as string; | ||
const string = (hex.match(/.{1,2}/g) || []) | ||
.map((byte) => String.fromCharCode(Number.parseInt(byte, 16))) | ||
.join(""); | ||
return string; | ||
}; |