diff --git a/package-lock.json b/package-lock.json index c95b2102..d00105ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "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", @@ -60,9 +60,9 @@ } }, "node_modules/@hyperionbt/helios": { - "version": "0.15.4", - "resolved": "https://registry.npmjs.org/@hyperionbt/helios/-/helios-0.15.4.tgz", - "integrity": "sha512-pVXlFbjDi5vRf47u/+d1Ok1EmWNZJBCsMp4c6BBQpE6pUoZ/NWNC3ugF0EXUK8W3bjY6c1H+cmRvVIcloQrWZA==" + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/@hyperionbt/helios/-/helios-0.15.7.tgz", + "integrity": "sha512-N9I5llxxn627zyFaj5Lap105GCxfE1uCWF8qqafhFu171Ens3KkVUHa23CGTatCkBzA7O6GMR1J2F+IPOO12oA==" }, "node_modules/@jsdoc/ast": { "version": "0.2.1", diff --git a/package.json b/package.json index 0fb596e0..4abe5f6e 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/lang/structs.md b/src/lang/structs.md index 9b6332d1..652a602d 100644 --- a/src/lang/structs.md +++ b/src/lang/structs.md @@ -24,4 +24,30 @@ The fields can also be named: ```helios const x = Rational { bottom: 3, top: 1 } -``` \ No newline at end of file +``` + +## 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. \ No newline at end of file