@helios-lang/contract-utils 0.1.29 → 0.1.31
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 +3 -3
- package/src/cast/Cast.js +15 -7
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.31",
|
|
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",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@helios-lang/cli-utils": "^0.1.2",
|
|
39
39
|
"@helios-lang/codec-utils": "^0.1.27",
|
|
40
40
|
"@helios-lang/compiler-utils": "^0.1.21",
|
|
41
|
-
"@helios-lang/ledger": "^0.1.
|
|
41
|
+
"@helios-lang/ledger": "^0.1.33",
|
|
42
42
|
"@helios-lang/type-utils": "^0.1.8",
|
|
43
|
-
"@helios-lang/uplc": "^0.1.
|
|
43
|
+
"@helios-lang/uplc": "^0.1.24"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/src/cast/Cast.js
CHANGED
|
@@ -2,11 +2,11 @@ import { decodeUtf8, encodeUtf8 } from "@helios-lang/codec-utils"
|
|
|
2
2
|
import {
|
|
3
3
|
Address,
|
|
4
4
|
AssetClass,
|
|
5
|
-
Credential,
|
|
6
5
|
DatumHash,
|
|
7
6
|
MintingPolicyHash,
|
|
8
7
|
PubKeyHash,
|
|
9
8
|
ScriptHash,
|
|
9
|
+
SpendingCredential,
|
|
10
10
|
StakingCredential,
|
|
11
11
|
StakingHash,
|
|
12
12
|
StakingValidatorHash,
|
|
@@ -92,7 +92,7 @@ function schemaToUplc(schema, x) {
|
|
|
92
92
|
return new ByteArrayData(x)
|
|
93
93
|
case "Credential":
|
|
94
94
|
case "PaymentCredential":
|
|
95
|
-
return
|
|
95
|
+
return SpendingCredential.fromAlike(x).toUplcData()
|
|
96
96
|
case "Data":
|
|
97
97
|
return x
|
|
98
98
|
case "DatumHash":
|
|
@@ -133,7 +133,9 @@ function schemaToUplc(schema, x) {
|
|
|
133
133
|
case "Value":
|
|
134
134
|
return Value.fromAlike(x).toUplcData()
|
|
135
135
|
default:
|
|
136
|
-
throw new Error(
|
|
136
|
+
throw new Error(
|
|
137
|
+
`not yet implemented for ${schema.primitiveType}`
|
|
138
|
+
)
|
|
137
139
|
}
|
|
138
140
|
} else if ("listItemType" in schema) {
|
|
139
141
|
return new ListData(x.map((x) => schemaToUplc(schema.listItemType, x)))
|
|
@@ -183,7 +185,9 @@ function schemaToUplc(schema, x) {
|
|
|
183
185
|
)
|
|
184
186
|
)
|
|
185
187
|
} else {
|
|
186
|
-
throw new Error(
|
|
188
|
+
throw new Error(
|
|
189
|
+
`not yet implemented for ${JSON.stringify(schema, undefined, 4)}`
|
|
190
|
+
)
|
|
187
191
|
}
|
|
188
192
|
}
|
|
189
193
|
|
|
@@ -206,7 +210,7 @@ function uplcToSchema(schema, data) {
|
|
|
206
210
|
case "ByteArray":
|
|
207
211
|
return ByteArrayData.expect(data).bytes
|
|
208
212
|
case "Credential":
|
|
209
|
-
return
|
|
213
|
+
return SpendingCredential.fromUplcData(data)
|
|
210
214
|
case "Data":
|
|
211
215
|
return data
|
|
212
216
|
case "DCert":
|
|
@@ -242,7 +246,9 @@ function uplcToSchema(schema, data) {
|
|
|
242
246
|
case "Value":
|
|
243
247
|
return Value.fromUplcData(data)
|
|
244
248
|
default:
|
|
245
|
-
throw new Error(
|
|
249
|
+
throw new Error(
|
|
250
|
+
`not yet implemented for ${schema.primitiveType}`
|
|
251
|
+
)
|
|
246
252
|
}
|
|
247
253
|
} else if ("listItemType" in schema) {
|
|
248
254
|
return ListData.expect(data).items.map((x) =>
|
|
@@ -312,6 +318,8 @@ function uplcToSchema(schema, data) {
|
|
|
312
318
|
)
|
|
313
319
|
}
|
|
314
320
|
} else {
|
|
315
|
-
throw new Error(
|
|
321
|
+
throw new Error(
|
|
322
|
+
`not yet implemented for ${JSON.stringify(schema, undefined, 4)}`
|
|
323
|
+
)
|
|
316
324
|
}
|
|
317
325
|
}
|