@helios-lang/contract-utils 0.1.30 → 0.1.32

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cast/Cast.js +16 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helios-lang/contract-utils",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
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",
package/src/cast/Cast.js CHANGED
@@ -99,6 +99,8 @@ function schemaToUplc(schema, x) {
99
99
  return DatumHash.fromAlike(x).toUplcData()
100
100
  case "DCert":
101
101
  return x.toUplcData()
102
+ case "Int":
103
+ return new IntData(x)
102
104
  case "MintingPolicyHash":
103
105
  return MintingPolicyHash.fromAlike(x).toUplcData()
104
106
  case "PubKeyHash":
@@ -133,7 +135,9 @@ function schemaToUplc(schema, x) {
133
135
  case "Value":
134
136
  return Value.fromAlike(x).toUplcData()
135
137
  default:
136
- throw new Error("not yet implemented")
138
+ throw new Error(
139
+ `not yet implemented for ${schema.primitiveType}`
140
+ )
137
141
  }
138
142
  } else if ("listItemType" in schema) {
139
143
  return new ListData(x.map((x) => schemaToUplc(schema.listItemType, x)))
@@ -183,7 +187,9 @@ function schemaToUplc(schema, x) {
183
187
  )
184
188
  )
185
189
  } else {
186
- throw new Error("not yet implemented")
190
+ throw new Error(
191
+ `not yet implemented for ${JSON.stringify(schema, undefined, 4)}`
192
+ )
187
193
  }
188
194
  }
189
195
 
@@ -213,6 +219,8 @@ function uplcToSchema(schema, data) {
213
219
  throw new Error(
214
220
  "can't convert UplcData back into DCert (significant loss of information)"
215
221
  )
222
+ case "Int":
223
+ return IntData.expect(data).value
216
224
  case "MintingPolicyHash":
217
225
  return MintingPolicyHash.fromUplcData(data)
218
226
  case "PubKeyHash":
@@ -242,7 +250,9 @@ function uplcToSchema(schema, data) {
242
250
  case "Value":
243
251
  return Value.fromUplcData(data)
244
252
  default:
245
- throw new Error("not yet implemented")
253
+ throw new Error(
254
+ `not yet implemented for ${schema.primitiveType}`
255
+ )
246
256
  }
247
257
  } else if ("listItemType" in schema) {
248
258
  return ListData.expect(data).items.map((x) =>
@@ -312,6 +322,8 @@ function uplcToSchema(schema, data) {
312
322
  )
313
323
  }
314
324
  } else {
315
- throw new Error("not yet implemented")
325
+ throw new Error(
326
+ `not yet implemented for ${JSON.stringify(schema, undefined, 4)}`
327
+ )
316
328
  }
317
329
  }