@helios-lang/contract-utils 0.1.37 → 0.1.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helios-lang/contract-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.39",
|
|
4
4
|
"description": "Convenience and type-safety utilities for using Helios validators from within Typescript",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"@helios-lang/compiler": "*"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@helios-lang/cli-utils": "^0.1.
|
|
39
|
-
"@helios-lang/codec-utils": "^0.1.
|
|
38
|
+
"@helios-lang/cli-utils": "^0.1.3",
|
|
39
|
+
"@helios-lang/codec-utils": "^0.1.29",
|
|
40
40
|
"@helios-lang/compiler-utils": "^0.1.21",
|
|
41
|
-
"@helios-lang/ledger": "^0.1.
|
|
41
|
+
"@helios-lang/ledger": "^0.1.44",
|
|
42
42
|
"@helios-lang/type-utils": "^0.1.8",
|
|
43
|
-
"@helios-lang/uplc": "^0.1.
|
|
43
|
+
"@helios-lang/uplc": "^0.1.26"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/src/cast/Cast.js
CHANGED
|
@@ -117,9 +117,7 @@ function schemaToUplc(schema, x) {
|
|
|
117
117
|
case "String":
|
|
118
118
|
return new ByteArrayData(encodeUtf8(x))
|
|
119
119
|
case "Time":
|
|
120
|
-
|
|
121
|
-
const ms = x instanceof Date ? x.getTime() : x
|
|
122
|
-
return new IntData(ms)
|
|
120
|
+
return new IntData(x)
|
|
123
121
|
case "TimeRange":
|
|
124
122
|
return TimeRange.new(x).toUplcData()
|
|
125
123
|
case "TxId":
|
|
@@ -241,7 +239,7 @@ function uplcToSchema(schema, data) {
|
|
|
241
239
|
case "String":
|
|
242
240
|
return decodeUtf8(ByteArrayData.expect(data).bytes)
|
|
243
241
|
case "Time":
|
|
244
|
-
return
|
|
242
|
+
return Number(IntData.expect(data).value) // a number has enough precision to represent ms since 1970 for another 142000 years
|
|
245
243
|
case "TimeRange":
|
|
246
244
|
return TimeRange.fromUplcData(data)
|
|
247
245
|
case "TxId":
|
|
@@ -135,11 +135,16 @@ export class LoadedScriptsWriter {
|
|
|
135
135
|
'import { Cast } from "@helios-lang/contract-utils";'
|
|
136
136
|
)
|
|
137
137
|
;[this.declaration, this.combined].forEach((w) => {
|
|
138
|
-
w.writeLine('import type {UplcData} from "@helios-lang/ledger";')
|
|
139
138
|
w.writeLine(
|
|
140
|
-
'import {
|
|
139
|
+
'import type { IntLike } from "@helios-lang/codec-utils";'
|
|
141
140
|
)
|
|
142
141
|
w.writeLine('import { Cast } from "@helios-lang/contract-utils";')
|
|
142
|
+
w.writeLine(
|
|
143
|
+
'import type { TimeLike, UplcData } from "@helios-lang/ledger";'
|
|
144
|
+
)
|
|
145
|
+
w.writeLine(
|
|
146
|
+
'import { Address, AssetClass, DatumHash, MintingPolicyHash, PubKey, PubKeyHash, SpendingCredential, StakingCredential, StakingHash, StakingValidatorHash, TimeRange, TxId, TxOutputDatum, ValidatorHash, Value } from "@helios-lang/ledger";'
|
|
147
|
+
)
|
|
143
148
|
})
|
|
144
149
|
}
|
|
145
150
|
|
|
@@ -56,9 +56,9 @@ export function genTypes(schema) {
|
|
|
56
56
|
case "Data":
|
|
57
57
|
return ["UplcData", "UplcData"]
|
|
58
58
|
case "Duration":
|
|
59
|
-
return ["bigint", "
|
|
59
|
+
return ["bigint", "IntLike"]
|
|
60
60
|
case "Int":
|
|
61
|
-
return ["bigint", "
|
|
61
|
+
return ["bigint", "IntLike"]
|
|
62
62
|
case "MintingPolicyHash":
|
|
63
63
|
return [
|
|
64
64
|
"MintingPolicyHash",
|
|
@@ -88,11 +88,11 @@ export function genTypes(schema) {
|
|
|
88
88
|
case "String":
|
|
89
89
|
return ["string", "string"]
|
|
90
90
|
case "Time":
|
|
91
|
-
return ["
|
|
91
|
+
return ["number", "TimeLike"]
|
|
92
92
|
case "TimeRange":
|
|
93
93
|
return [
|
|
94
94
|
"TimeRange",
|
|
95
|
-
"TimeRange | [
|
|
95
|
+
"TimeRange | [TimeLike, TimeLike] | {start?: TimeLike, excludeStart?: boolean, end?: TimeLike, excludeEnd?: boolean}"
|
|
96
96
|
]
|
|
97
97
|
case "TxId":
|
|
98
98
|
return ["TxId", "TxId | string | number[]"]
|
|
@@ -108,7 +108,7 @@ export function genTypes(schema) {
|
|
|
108
108
|
case "Value":
|
|
109
109
|
return [
|
|
110
110
|
"Value",
|
|
111
|
-
"Value | [MintingPolicyHash | string | number[], [number[] | string,
|
|
111
|
+
"Value | [MintingPolicyHash | string | number[], [number[] | string, IntLike][]][] | {mph: MintingPolicyHash | string | number[], tokens: {name: number[] | string, qty: IntLike}[]}[]"
|
|
112
112
|
]
|
|
113
113
|
default:
|
|
114
114
|
throw new Error(
|
package/src/hl2ts.js
CHANGED
|
@@ -32,8 +32,10 @@ import { None } from "@helios-lang/type-utils"
|
|
|
32
32
|
* @typedef {"javascript" | "typescript"} FormatKind
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
|
+
const NAME = "hl2ts"
|
|
36
|
+
|
|
35
37
|
async function main() {
|
|
36
|
-
const cli = new Cli({
|
|
38
|
+
const cli = new Cli(NAME, {
|
|
37
39
|
minArgs: 0,
|
|
38
40
|
maxArgs: 0,
|
|
39
41
|
options: {
|
|
@@ -80,7 +82,7 @@ async function mainInternal(_args, { outDir, format }) {
|
|
|
80
82
|
const filePaths = await listFiles(process.cwd(), ".hl")
|
|
81
83
|
const files = readFiles(filePaths)
|
|
82
84
|
|
|
83
|
-
console.log(
|
|
85
|
+
console.log(`${NAME} using Helios compiler v${lib.version}`)
|
|
84
86
|
console.log(` Transpiling ${Object.keys(files).length} inputs:`)
|
|
85
87
|
filePaths.forEach((p) => console.log(` ${p}`))
|
|
86
88
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadedScriptsWriter.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedScriptsWriter.js"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH;IAUI;;;OAGG;IACH,gBAFa,mBAAmB,CAQ/B;IAfG,yBAAoC;IACpC,0BAAqC;IACrC,uBAAkC;IAetC;;;OAGG;IACH;;QAFa,mBAAmB,CAgC/B;IAED;;;OAGG;IACH;;QAFa,mBAAmB,CAkC/B;IAED;;OAEG;IACH,YAFa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAQpC;IAED;;;;;OAKG;IACH,cAKC;IAED;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"LoadedScriptsWriter.d.ts","sourceRoot":"","sources":["../../src/codegen/LoadedScriptsWriter.js"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH;IAUI;;;OAGG;IACH,gBAFa,mBAAmB,CAQ/B;IAfG,yBAAoC;IACpC,0BAAqC;IACrC,uBAAkC;IAetC;;;OAGG;IACH;;QAFa,mBAAmB,CAgC/B;IAED;;;OAGG;IACH;;QAFa,mBAAmB,CAkC/B;IAED;;OAEG;IACH,YAFa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAQpC;IAED;;;;;OAKG;IACH,cAKC;IAED;;OAEG;IACH,qBAgBC;IAED;;;OAGG;IACH,kBAFW,OAAO,MAAM,EAAE,UAAU,CAAC,QAiBpC;IAED;;;OAGG;IACH,oBA4BC;IAED;;;OAGG;IACH,uBAgDC;CACJ;gCA9PY,OAAO,wBAAwB,EAAE,iBAAiB;mCAClD,OAAO,2BAA2B,EAAE,oBAAoB;yBACxD,OAAO,iBAAiB,EAAE,UAAU;6BANpB,0BAA0B"}
|