@helios-lang/contract-utils 0.1.36 → 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 +2 -2
- package/src/cast/Cast.js +15 -15
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.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.
|
|
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.
|
|
84
|
+
return Address.new(x).toUplcData()
|
|
85
85
|
case "Any":
|
|
86
86
|
return new IntData(0n)
|
|
87
87
|
case "AssetClass":
|
|
88
|
-
return AssetClass.
|
|
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.
|
|
95
|
+
return SpendingCredential.new(x).toUplcData()
|
|
96
96
|
case "Data":
|
|
97
97
|
return x
|
|
98
98
|
case "DatumHash":
|
|
99
|
-
return DatumHash.
|
|
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.
|
|
106
|
+
return MintingPolicyHash.new(x).toUplcData()
|
|
107
107
|
case "PubKeyHash":
|
|
108
|
-
return PubKeyHash.
|
|
108
|
+
return PubKeyHash.new(x).toUplcData()
|
|
109
109
|
case "Real":
|
|
110
110
|
return encodeRealData(x)
|
|
111
111
|
case "ScriptHash":
|
|
112
|
-
return ScriptHash.
|
|
112
|
+
return ScriptHash.new(x).toUplcData()
|
|
113
113
|
case "StakingCredential":
|
|
114
|
-
return StakingCredential.
|
|
114
|
+
return StakingCredential.new(x).toUplcData()
|
|
115
115
|
case "StakingHash":
|
|
116
|
-
return StakingHash.
|
|
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.
|
|
124
|
+
return TimeRange.new(x).toUplcData()
|
|
125
125
|
case "TxId":
|
|
126
|
-
return TxId.
|
|
126
|
+
return TxId.new(x).toUplcData()
|
|
127
127
|
case "TxOutputDatum":
|
|
128
128
|
return x
|
|
129
|
-
? TxOutputDatum.
|
|
129
|
+
? TxOutputDatum.new(x)?.toUplcData() ??
|
|
130
130
|
new ConstrData(0, [])
|
|
131
131
|
: new ConstrData(0, [])
|
|
132
132
|
case "TxOutputId":
|
|
133
|
-
return TxOutputId.
|
|
133
|
+
return TxOutputId.new(x).toUplcData()
|
|
134
134
|
case "ValidatorHash":
|
|
135
|
-
return ValidatorHash.
|
|
135
|
+
return ValidatorHash.new(x).toUplcData()
|
|
136
136
|
case "Value":
|
|
137
|
-
return Value.
|
|
137
|
+
return Value.new(x).toUplcData()
|
|
138
138
|
default:
|
|
139
139
|
throw new Error(
|
|
140
140
|
`not yet implemented for ${schema.primitiveType}`
|