Skip to content

Commit

Permalink
* cip68 struct tagging documented
Browse files Browse the repository at this point in the history
  • Loading branch information
christianschmitz committed Aug 22, 2023
1 parent cb073e0 commit 81cf0b0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 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.4",
"@hyperionbt/helios": "^0.15.7",
"@jsdoc/ast": "^0.2.1",
"@jsdoc/parse": "^0.3.1",
"typedoc": "^0.24.8",
Expand Down
28 changes: 27 additions & 1 deletion src/lang/structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,30 @@ The fields can also be named:

```helios
const x = Rational { bottom: 3, top: 1 }
```
```

## CIP 68 tags

Regular Helios structs are internally implemented as data-lists.

This internal data-list format isn't convenient for datums that are intended for public reading/writing. For such applications it is recommended to use the [CIP 68](https://cips.cardano.org/cips/cip68/) data-map format.

Helios will automatically use the [CIP 68](https://cips.cardano.org/cips/cip68/) format internally if any `struct` field is tagged. The tags are internally converted into the data-map keys.

```helios
struct TaggedRational {
top: Int "@top" // the tag can be any valid utf-8 string
bottom: Int "@bottom"
}
```

Any missing tags default to the field name:

```helios
struct TaggedRational {
top: Int "@top"
bottom: Int // data-map key will be "bottom"
}
```

Field tagging isn't available for enum variants.

0 comments on commit 81cf0b0

Please sign in to comment.