From 0abc42b6a2b4b6ad6c360ec6c36459eaadad2268 Mon Sep 17 00:00:00 2001 From: Christian Schmitz Date: Mon, 16 Oct 2023 18:59:42 -0600 Subject: [PATCH] * Documented Address to/from hex/bytes * Documented ByteArray parse * Noted how to use CHECK_CASTS in Automatic methods/from_data subsection --- package-lock.json | 8 ++-- package.json | 2 +- src/lang/builtins/address.md | 44 ++++++++++++++++--- src/lang/builtins/bytearray.md | 8 ++++ .../methods/automatic-methods.md | 2 + 5 files changed, 53 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 51e1af91..9e932a0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@hyperionbt/helios": "^0.15.12", + "@hyperionbt/helios": "^0.16.0", "@jsdoc/ast": "^0.2.1", "@jsdoc/parse": "^0.3.1", "typedoc": "^0.24.8", @@ -60,9 +60,9 @@ } }, "node_modules/@hyperionbt/helios": { - "version": "0.15.12", - "resolved": "https://registry.npmjs.org/@hyperionbt/helios/-/helios-0.15.12.tgz", - "integrity": "sha512-zXlTsgtNFp8OtBCDU15B7lzhvKEfSMrbU4yEOCmGpEK8byv9fE/2G+9TDHSwOqc8HfOnrCnTrvJGWP4iCeWDMw==" + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/@hyperionbt/helios/-/helios-0.16.0.tgz", + "integrity": "sha512-CcnuXw7XietfCfv83gTvttLgKwRNyGk85zYQJNUxrC4zCsJi2k4uttuGXMxDr6lgSPun/4WQ4yxcBYVMr+9pxQ==" }, "node_modules/@jsdoc/ast": { "version": "0.2.1", diff --git a/package.json b/package.json index 17747c59..62ff0dee 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "author": "", "license": "ISC", "dependencies": { - "@hyperionbt/helios": "^0.15.12", + "@hyperionbt/helios": "^0.16.0", "@jsdoc/ast": "^0.2.1", "@jsdoc/parse": "^0.3.1", "typedoc": "^0.24.8", diff --git a/src/lang/builtins/address.md b/src/lang/builtins/address.md index 87933928..33d16610 100644 --- a/src/lang/builtins/address.md +++ b/src/lang/builtins/address.md @@ -4,15 +4,12 @@ Represents a Cardano address. ## Associated functions -### `new` +### `from_bytes` -Construct a new `Address` from a [`Credential`](./credential.md) and an optional [`StakingCredential`](./stakingcredential.md): +Decodes raw address bytes. ```helios -Address::new( - credential: Credential, - staking_credential: Option[StakingCredential] -) -> Address +Address::from_bytes(bytes: ByteArray) -> Address ``` ### `from_data` @@ -21,6 +18,25 @@ Address::new( Address::from_data(data: Data) -> Address ``` +### `from_hex` + +Decodes the hexadecimal encoded bytes of a raw address. + +```helios +Address::from_hex(hex: String) -> Address +``` + +### `new` + +Construct a new `Address` from a [`Credential`](./credential.md) and an optional [`StakingCredential`](./stakingcredential.md): + +```helios +Address::new( + credential: Credential, + staking_credential: Option[StakingCredential] +) -> Address +``` + ## Getters ### `credential` @@ -60,3 +76,19 @@ Address != Address -> Bool ```helios address.serialize() -> ByteArray ``` + +### `to_bytes` + +Returns the raw address bytes. + +```helios +address.to_bytes() -> ByteArray +``` + +### `to_hex` + +Encodes the raw address bytes as a hexadecimal `String`. + +``` +address.to_hex() -> String +``` \ No newline at end of file diff --git a/src/lang/builtins/bytearray.md b/src/lang/builtins/bytearray.md index d1b800d7..7c3b41c0 100644 --- a/src/lang/builtins/bytearray.md +++ b/src/lang/builtins/bytearray.md @@ -16,6 +16,14 @@ byte_array = #213212; ... ByteArray::from_data(data: Data) -> ByteArray ``` +### `parse` + +Parses a hexadecimal encoded `ByteArray`. + +```helios +ByteArray::parse(hex: String) -> String +``` + ## Getters ### `length` diff --git a/src/lang/user-defined-types/methods/automatic-methods.md b/src/lang/user-defined-types/methods/automatic-methods.md index f3fe0441..a6bdfcf7 100644 --- a/src/lang/user-defined-types/methods/automatic-methods.md +++ b/src/lang/user-defined-types/methods/automatic-methods.md @@ -35,6 +35,8 @@ pair.copy(second: 3) // == Pair{1, 3} MyType::from_data(data: Data) -> MyType ``` +If you set [`CHECK_CASTS`](../../../api/reference/namespaces/config.md#check_casts) to `true`, a warning will be printed if the structure of `data` doesn't match the type. + ## `serialize` The `serialize` method is automatically defined on every user-type, and thus `serialize` is a reserved name that can't be used for other methods.