@helios-lang/contract-utils 0.1.35 → 0.1.37

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.35",
3
+ "version": "0.1.37",
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,7 +38,7 @@
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.33",
41
+ "@helios-lang/ledger": "^0.1.43",
42
42
  "@helios-lang/type-utils": "^0.1.8",
43
43
  "@helios-lang/uplc": "^0.1.24"
44
44
  }
package/src/cast/Cast.js CHANGED
@@ -81,39 +81,39 @@ function schemaToUplc(schema, x) {
81
81
  if ("primitiveType" in schema) {
82
82
  switch (schema.primitiveType) {
83
83
  case "Address":
84
- return Address.fromAlike(x).toUplcData()
84
+ return Address.new(x).toUplcData()
85
85
  case "Any":
86
86
  return new IntData(0n)
87
87
  case "AssetClass":
88
- return AssetClass.fromAlike(x).toUplcData()
88
+ return AssetClass.new(x).toUplcData()
89
89
  case "Bool":
90
90
  return encodeBoolData(x)
91
91
  case "ByteArray":
92
92
  return new ByteArrayData(x)
93
93
  case "Credential":
94
94
  case "PaymentCredential":
95
- return SpendingCredential.fromAlike(x).toUplcData()
95
+ return SpendingCredential.new(x).toUplcData()
96
96
  case "Data":
97
97
  return x
98
98
  case "DatumHash":
99
- return DatumHash.fromAlike(x).toUplcData()
99
+ return DatumHash.new(x).toUplcData()
100
100
  case "DCert":
101
101
  return x.toUplcData()
102
102
  case "Duration":
103
103
  case "Int":
104
104
  return new IntData(x)
105
105
  case "MintingPolicyHash":
106
- return MintingPolicyHash.fromAlike(x).toUplcData()
106
+ return MintingPolicyHash.new(x).toUplcData()
107
107
  case "PubKeyHash":
108
- return PubKeyHash.fromAlike(x).toUplcData()
108
+ return PubKeyHash.new(x).toUplcData()
109
109
  case "Real":
110
110
  return encodeRealData(x)
111
111
  case "ScriptHash":
112
- return ScriptHash.fromAlike(x).toUplcData()
112
+ return ScriptHash.new(x).toUplcData()
113
113
  case "StakingCredential":
114
- return StakingCredential.fromAlike(x).toUplcData()
114
+ return StakingCredential.new(x).toUplcData()
115
115
  case "StakingHash":
116
- return StakingHash.fromAlike(x).toUplcData()
116
+ return StakingHash.new(x).toUplcData()
117
117
  case "String":
118
118
  return new ByteArrayData(encodeUtf8(x))
119
119
  case "Time":
@@ -121,20 +121,20 @@ function schemaToUplc(schema, x) {
121
121
  const ms = x instanceof Date ? x.getTime() : x
122
122
  return new IntData(ms)
123
123
  case "TimeRange":
124
- return TimeRange.fromAlike(x).toUplcData()
124
+ return TimeRange.new(x).toUplcData()
125
125
  case "TxId":
126
- return TxId.fromAlike(x).toUplcData()
126
+ return TxId.new(x).toUplcData()
127
127
  case "TxOutputDatum":
128
128
  return x
129
- ? TxOutputDatum.fromAlike(x)?.toUplcData() ??
129
+ ? TxOutputDatum.new(x)?.toUplcData() ??
130
130
  new ConstrData(0, [])
131
131
  : new ConstrData(0, [])
132
132
  case "TxOutputId":
133
- return TxOutputId.fromAlike(x).toUplcData()
133
+ return TxOutputId.new(x).toUplcData()
134
134
  case "ValidatorHash":
135
- return ValidatorHash.fromAlike(x).toUplcData()
135
+ return ValidatorHash.new(x).toUplcData()
136
136
  case "Value":
137
- return Value.fromAlike(x).toUplcData()
137
+ return Value.new(x).toUplcData()
138
138
  default:
139
139
  throw new Error(
140
140
  `not yet implemented for ${schema.primitiveType}`
@@ -177,16 +177,16 @@ export class LoadedScriptsWriter {
177
177
 
178
178
  this.declaration.write(
179
179
  `export const ${m.name}: {
180
- $name: string
181
- $purpose: string
180
+ $name: "${m.name}"
181
+ $purpose: "${m.purpose}"
182
182
  $sourceCode: string
183
183
  $dependencies: [${m.moduleDepedencies.map((d) => `typeof ${d}`).join(", ")}],\n`
184
184
  )
185
185
 
186
186
  this.combined.write(
187
187
  `export const ${m.name} = {
188
- $name: "${m.name}" as "${m.name}",
189
- $purpose: "${m.purpose}" as "${m.purpose}",
188
+ $name: "${m.name}" as const,
189
+ $purpose: "${m.purpose}" as const,
190
190
  $sourceCode: ${JSON.stringify(m.sourceCode)} as string,
191
191
  $dependencies: [${m.moduleDepedencies.join(", ")}],\n`
192
192
  )
@@ -235,8 +235,8 @@ ${datumTypes ? ` $Datum: Cast<${datumTypes[0]}, ${datumTypes[1]}>,\n` : ""}`
235
235
 
236
236
  this.combined.write(
237
237
  `export const ${v.name} = {
238
- $name: "${v.name}" as "${v.name}",
239
- $purpose: "${v.purpose}" as "${v.purpose}",
238
+ $name: "${v.name}" as const,
239
+ $purpose: "${v.purpose}" as const,
240
240
  $sourceCode: ${JSON.stringify(v.sourceCode)} as string,
241
241
  $dependencies: [${v.moduleDepedencies.join(", ")}],
242
242
  $hashDependencies: [${v.hashDependencies.filter((d) => d != v.name).join(", ")}],
@@ -63,7 +63,7 @@ import { Cast } from "../cast/index.js"
63
63
  * PermissiveType<V["$Redeemer"]>
64
64
  * >
65
65
  * > :
66
- * V extends {"$purpose": ("certifying" | "rewarding")} ? StakingValidatorHash<
66
+ * V extends {"$purpose": ("certifying" | "rewarding" | "staking")} ? StakingValidatorHash<
67
67
  * StakingContext<
68
68
  * StrictType<V["$Redeemer"]>,
69
69
  * PermissiveType<V["$Redeemer"]>
@@ -11,7 +11,7 @@ export type ContractValidatorHash<V extends import("../codegen/LoadedValidator.j
11
11
  } ? ValidatorHash<SpendingContext<StrictType<V["$Datum"]>, PermissiveType<V["$Datum"]>, StrictType<V["$Redeemer"]>, PermissiveType<V["$Redeemer"]>>> : V extends {
12
12
  "$purpose": "minting";
13
13
  } ? MintingPolicyHash<MintingContext<StrictType<V["$Redeemer"]>, PermissiveType<V["$Redeemer"]>>> : V extends {
14
- "$purpose": ("certifying" | "rewarding");
14
+ "$purpose": ("certifying" | "rewarding" | "staking");
15
15
  } ? StakingValidatorHash<StakingContext<StrictType<V["$Redeemer"]>, PermissiveType<V["$Redeemer"]>>> : never;
16
16
  export type ContractContext<T extends {
17
17
  [name: string]: import("../codegen/LoadedValidator.js").LoadedValidator;
@@ -1 +1 @@
1
- {"version":3,"file":"ContractContext.d.ts","sourceRoot":"","sources":["../../src/context/ContractContext.js"],"names":[],"mappings":"8BAQa,OAAO,qBAAqB,EAAE,eAAe;mEAM7C,OAAO,qBAAqB,EAAE,cAAc,CAAC,eAAe,EAAE,mBAAmB,CAAC;oGAQlF,OAAO,qBAAqB,EAAE,eAAe,CAAC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,CAAC;mEAMnH,OAAO,qBAAqB,EAAE,cAAc,CAAC,eAAe,EAAE,mBAAmB,CAAC;uDAKlF,OAAO,kBAAkB,EAAE,cAAc,CAAC,CAAC,CAAC;mDAK5C,OAAO,kBAAkB,EAAE,UAAU,CAAC,CAAC,CAAC;uCAIxC,CACZ,cAAkB,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,GACtD,kBAAsB,eAAe,GAAG,EAAE,GAAG,CAAC,CAAC,GAC/C,qBAAyB,eAAe,GAAG,EAAE,GAAG,CAAC,CAAC,CAC/C;uGAKS,CAAC,SAAS;IAAC,UAAU,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,IAAI,CAAA;CAAC,GAAG,cACjE,gBACA,WAAqB,CAAC,CAAC,QAAQ,CAAC,CAAC,EACjC,eAAyB,CAAC,CAAC,QAAQ,CAAC,CAAC,EACrC,WAAqB,CAAC,CAAC,WAAW,CAAC,CAAC,EACpC,eAAyB,CAAC,CAAC,WAAW,CAAC,CAAC,CAC/B,CACF,GACP,CAAO,SAAS;IAAC,UAAU,EAAE,SAAS,CAAA;CAAC,GAAG,kBAC1C,eACA,WAAqB,CAAC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