Skip to content

Commit

Permalink
added Data::as_strict which does a deep check of the validity of a da…
Browse files Browse the repository at this point in the history
…ta structure
  • Loading branch information
christianschmitz committed Sep 15, 2024
1 parent 61e7e30 commit f2c8151
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helios-lang/compiler",
"version": "0.17.0-82",
"version": "0.17.0-83",
"description": "Helios is a Domain Specific Language that compiles to Plutus-Core (i.e. Cardano on-chain validator scripts). Helios is a non-Haskell alternative to Plutus. With this library you can compile Helios scripts and build Cardano transactions, all you need to build 100% client-side dApps for Cardano.",
"main": "src/index.js",
"types": "types/index.d.ts",
Expand Down
18 changes: 17 additions & 1 deletion src/codegen/makeRawFuncs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8633,8 +8633,24 @@ export function makeRawFunctions(simplify, isTestnet) {
new RawFunc(
`__helios__data__as[${FTPP}0]`,
`(data) -> {
${FTPP}0__from_data(data)
}`
)
)
add(
new RawFunc(
`__helios__data__as_strict[${FTPP}0]`,
`(data) -> {
__core__ifThenElse(
${FTPP}0__is_valid_data(data),
() -> {
${FTPP}0__from_data(data)
}`
},
() -> {
__helios__error("invalid data structure")
}
)()
}`
)
)
add(
Expand Down
2 changes: 1 addition & 1 deletion src/program/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = "0.17.0-82"
export const VERSION = "0.17.0-83"
5 changes: 5 additions & 0 deletions src/typecheck/primitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ export const RawDataType = new GenericType({
as: (() => {
const a = new Parameter("a", `${FTPP}0`, new DefaultTypeClass())

return new ParametricData([a], a.ref)
})(),
as_strict: (() => {
const a = new Parameter("a", `${FTPP}0`, new DefaultTypeClass())

return new ParametricData([a], a.ref)
})()
}),
Expand Down

0 comments on commit f2c8151

Please sign in to comment.