Skip to content

Commit

Permalink
* Documented Address to/from hex/bytes
Browse files Browse the repository at this point in the history
* Documented ByteArray parse
* Noted how to use CHECK_CASTS in Automatic methods/from_data subsection
  • Loading branch information
christianschmitz committed Oct 17, 2023
1 parent abb1bca commit 0abc42b
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 11 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
44 changes: 38 additions & 6 deletions src/lang/builtins/address.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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`
Expand Down Expand Up @@ -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
```
8 changes: 8 additions & 0 deletions src/lang/builtins/bytearray.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 2 additions & 0 deletions src/lang/user-defined-types/methods/automatic-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0abc42b

Please sign in to comment.