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:
Mayukha Vadari
2022-04-04 17:11:08 -04:00
committed by GitHub
parent 53d01d8a6a
commit d25905987a
7 changed files with 286 additions and 26 deletions

View 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 }