Functions
- bytesToHex
- bytesToText
- deserializeUplc
- deserializeUplcBytes
- extractScriptPurposeAndName
- hexToBytes
- highlight
- hl
- textToBytes
bytesToHex
▸ bytesToHex(bytes
): string
Converts a list of uint8 bytes into its hexadecimal string representation.
Parameters
Name | Type |
---|---|
bytes | number [] |
Returns
string
Example
bytesToHex([0, 255, 52]) == "00ff34"
bytesToText
▸ bytesToText(bytes
): string
Decodes a list of uint8 bytes into a string using UTF-8 encoding.
Parameters
Name | Type |
---|---|
bytes | number [] |
Returns
string
Example
bytesToText([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]) == "hello world"
deserializeUplc
▸ deserializeUplc(json
): UplcProgram
Parses a plutus core program. Returns a UplcProgram
instance.
Parameters
Name | Type | Description |
---|---|---|
json | string | { cborHex : string } | a raw JSON string or a parsed JSON object |
Returns
deserializeUplcBytes
▸ deserializeUplcBytes(bytes
, properties?
): UplcProgram
Deserializes a flat encoded UplcProgram
.
Parameters
Name | Type |
---|---|
bytes | number [] |
properties? | ProgramProperties |
Returns
extractScriptPurposeAndName
▸ extractScriptPurposeAndName(rawSrc
): null
| [ScriptPurpose
, string
]
Quickly extract the script purpose header of a script source, by parsing only the minimally necessary characters.
Parameters
Name | Type |
---|---|
rawSrc | string |
Returns
null
| [ScriptPurpose
, string
]
Returns null
if the script header is missing or syntactically incorrect. The first string returned is the script purpose, the second value returned is the script name.
hexToBytes
▸ hexToBytes(hex
): number
[]
Converts a hexadecimal string into a list of bytes.
Parameters
Name | Type |
---|---|
hex | string |
Returns
number
[]
Example
hexToBytes("00ff34") == [0, 255, 52]
highlight
▸ highlight(src
): Uint8Array
Returns Uint8Array with the same length as the number of chars in the script. Each resulting byte respresents a different syntax category. This approach should be faster than a RegExp based a approach.
Parameters
Name | Type |
---|---|
src | string |
Returns
Uint8Array
hl
▸ hl(a
, ...b
): string
Template string tag function that doesn't do anything and just returns the template string as a string. Can be used as a marker of Helios sources so that syntax highlighting can work inside JS/TS files.
Parameters
Name | Type |
---|---|
a | string [] |
...b | any [] |
Returns
string
Example
hl`hello ${"world"}!` == "hello world!"
textToBytes
▸ textToBytes(str
): number
[]
Encodes a string into a list of uint8 bytes using UTF-8 encoding.
Parameters
Name | Type |
---|---|
str | string |
Returns
number
[]
Example
textToBytes("hello world") == [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]