mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-04 21:15:47 +00:00
feat: add sidechain-specific RPCs/sugar (#1940)
* federator_info responses/requests * edit docstring * make strings narrower * export federator_info * implement createXchainPayment * add tests * fix dependency cycle * fix linter errors * rename xchain -> crosschain * rename more * edit HISTORY * fix docstrings * add another test
This commit is contained in:
27
packages/xrpl/src/utils/stringConversion.ts
Normal file
27
packages/xrpl/src/utils/stringConversion.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Converts a string to its hex equivalent. Useful for Memos.
|
||||
*
|
||||
* @param string - The string to convert to Hex.
|
||||
* @returns The Hex equivalent of the string.
|
||||
* @category Utilities
|
||||
*/
|
||||
function convertStringToHex(string: string): string {
|
||||
return Buffer.from(string, 'utf8').toString('hex').toUpperCase()
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts hex to its string equivalent. Useful to read the Domain field and some Memos.
|
||||
*
|
||||
* @param hex - The hex to convert to a string.
|
||||
* @param encoding - The encoding to use. Defaults to 'utf8' (UTF-8). 'ascii' is also allowed.
|
||||
* @returns The converted string.
|
||||
* @category Utilities
|
||||
*/
|
||||
function convertHexToString(
|
||||
hex: string,
|
||||
encoding: BufferEncoding = 'utf8',
|
||||
): string {
|
||||
return Buffer.from(hex, 'hex').toString(encoding)
|
||||
}
|
||||
|
||||
export { convertHexToString, convertStringToHex }
|
||||
Reference in New Issue
Block a user