@hyperionbt/helios
Advanced tools
Comparing version 0.13.14 to 0.13.15
This Changelog only applies to notable changes of language related features in `helios.js` on the main branch. | ||
# 2023/04/10 | ||
* `Duration::SECOND`, `MINUTE`, `HOUR`, `DAY`, `WEEK` | ||
# 2023/04/03 | ||
@@ -4,0 +7,0 @@ * `AssetClass.mph` and `AssetClass.token_name` |
@@ -31,4 +31,8 @@ # Overview | ||
NameTypePair ::= (Identifier [':' TypeExpr]) | '_' | ||
LhsExpr ::= NameTypePair | SinkExpr | ||
NameTypePair ::= Identifier [':' TypeExpr] | ||
SinkExpr ::= '_' | ||
EnumStatement ::= 'enum' Identifier '{' EnumMember (EnumMember)* [ImplDefinition] '}' | ||
@@ -46,3 +50,3 @@ | ||
FuncArg ::= NameTypePair | ||
FuncArg ::= NameTypePair | SinkExpr | ||
@@ -55,4 +59,6 @@ TypeExpr ::= NonFuncTypeExpr | FuncTypeExpr | ||
FuncTypeExpr ::= '(' [TypeExpr (',' TypeExpr)*] ')' '->' RetTypeExpr | ||
FuncTypeExpr ::= '(' [FuncArgTypeExpr (',' FuncArgTypeExpr)*] ')' '->' RetTypeExpr | ||
FuncArgTypeExpr ::= [Identifier ':'] ['?'] TypeExpr | ||
TypeRefExpr ::= Identifier | ||
@@ -104,7 +110,7 @@ | ||
AssignExpr ::= (Identifier [':' TypeExpr] '=' ValueExpr ';' ValueExpr | ||
AssignExpr ::= Identifier [':' TypeExpr] '=' ValueExpr ';' ValueExpr | ||
MultiAssignExpr ::= '(' NameTypePair ',' NameTypePair (',' NameTypePair)* ')' '=' ValueExpr ';' ValueExpr | ||
PrintExpr ::= 'print' '(' ValueExpr ')' ';' ValueExpr | ||
PrintExpr ::= 'print' '(' ValueExpr ')' | ||
@@ -604,3 +610,3 @@ ErrorExpr ::= [ValueExpr ';'] 'error' '(' ValueExpr ')' | ||
``` | ||
associated: new, from_data | ||
associated: new, from_data, SECOND, MINUTE, HOUR, DAY, WEEK | ||
operators: __eq, __neq, __add, __sub, __mul, __div, __div_alt, __mod, __geq, __gt, __leq, __lt | ||
@@ -607,0 +613,0 @@ methods: serialize |
{ | ||
"name": "@hyperionbt/helios", | ||
"type": "module", | ||
"version": "0.13.14", | ||
"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.", | ||
"version": "0.13.15", | ||
"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": "helios.js", | ||
@@ -7,0 +7,0 @@ "types": "helios.d.ts", |
@@ -7,3 +7,3 @@ # Helios Lang | ||
The Helios library is written in Javascript, and lets you compile Helios scripts and create Cardano transactions. This library is all you need to build 100% client-side DApps for Cardano. | ||
The Helios library is written in Javascript, and lets you compile Helios scripts and create Cardano transactions. This library is all you need to build 100% client-side dApps for Cardano. | ||
@@ -10,0 +10,0 @@ ## Example: time-lock |
@@ -1884,2 +1884,6 @@ //@ts-check | ||
if (bracesPos == 0) { | ||
throw ts[bracesPos].syntaxError("expected struct type before braces"); | ||
} | ||
const typeExpr = buildTypeExpr(ts.splice(0, bracesPos)); | ||
@@ -1886,0 +1890,0 @@ |
@@ -495,7 +495,11 @@ //@ts-check | ||
/** | ||
* @param {number[]} bytes | ||
* @param {number[] | string} bytes | ||
* @returns {UplcProgram} | ||
*/ | ||
static fromCbor(bytes) { | ||
return deserializeUplcBytes(CborData.decodeBytes(CborData.decodeBytes(bytes))); | ||
if (typeof bytes == "string") { | ||
return UplcProgram.fromCbor(hexToBytes(bytes)) | ||
} else { | ||
return deserializeUplcBytes(CborData.decodeBytes(CborData.decodeBytes(bytes))); | ||
} | ||
} | ||
@@ -502,0 +506,0 @@ } |
@@ -5,3 +5,3 @@ #!/usr/bin/env node | ||
import * as helios from "../helios.js"; | ||
import { runIfEntryPoint } from "./util.js"; | ||
import { assert, runIfEntryPoint } from "./util.js"; | ||
@@ -567,2 +567,25 @@ async function test1() { | ||
async function test21() { | ||
const src = `testing bad_constructor | ||
struct MyStruct { | ||
a: Int | ||
b: Int | ||
c: Int | ||
} | ||
func main() -> Bool { | ||
my_struct: MyStruct = {a: 1, b: 2, c: 3}; | ||
my_struct.a == my_struct.b | ||
} | ||
` | ||
try { | ||
helios.Program.new(src) | ||
} catch (e) { | ||
assert(e.message.includes("expected struct type before braces")) | ||
} | ||
} | ||
export default async function main() { | ||
@@ -608,4 +631,6 @@ await test1(); | ||
await test20(); | ||
await test21(); | ||
} | ||
runIfEntryPoint(main, "syntax.js"); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
4840195
91254