@lucid-evolution/utils 0.1.21 → 0.1.23

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/dist/index.cjs CHANGED
@@ -56,19 +56,19 @@ __export(src_exports, {
56
56
  isEqualUTxO: () => isEqualUTxO,
57
57
  keyHashToCredential: () => keyHashToCredential,
58
58
  mintingPolicyToId: () => mintingPolicyToId,
59
- nativeFromJson: () => nativeFromJson,
60
- nativeJSFromJson: () => nativeJSFromJson,
61
- nativeScriptFromJson: () => nativeScriptFromJson,
62
59
  networkToId: () => networkToId,
60
+ parseCMLNative: () => parseCMLNative,
63
61
  paymentCredentialOf: () => paymentCredentialOf,
62
+ scriptFromCMLNative: () => scriptFromCMLNative,
63
+ scriptFromNative: () => scriptFromNative,
64
64
  scriptHashToCredential: () => scriptHashToCredential,
65
65
  selectUTxOs: () => selectUTxOs,
66
66
  slotToUnixTime: () => slotToUnixTime,
67
67
  sortUTxOs: () => sortUTxOs,
68
68
  stakeCredentialOf: () => stakeCredentialOf,
69
69
  stringify: () => stringify,
70
+ toCMLNativeScript: () => toCMLNativeScript,
70
71
  toLabel: () => toLabel,
71
- toNativeScript: () => toNativeScript,
72
72
  toPublicKey: () => toPublicKey,
73
73
  toScriptRef: () => toScriptRef,
74
74
  toUnit: () => toUnit,
@@ -84,11 +84,14 @@ __export(src_exports, {
84
84
  });
85
85
  module.exports = __toCommonJS(src_exports);
86
86
 
87
+ // src/native.ts
88
+ var S = __toESM(require("@effect/schema/Schema"), 1);
89
+
87
90
  // src/core.ts
88
91
  var CML = __toESM(require("@anastasia-labs/cardano-multiplatform-lib-nodejs"), 1);
89
92
 
90
93
  // src/native.ts
91
- var toNativeScript = (native) => {
94
+ var toCMLNativeScript = (native) => {
92
95
  switch (native.type) {
93
96
  case "sig":
94
97
  return CML.NativeScript.new_script_pubkey(
@@ -100,17 +103,17 @@ var toNativeScript = (native) => {
100
103
  return CML.NativeScript.new_script_invalid_before(BigInt(native.slot));
101
104
  case "all": {
102
105
  const nativeList = CML.NativeScriptList.new();
103
- native.scripts.map((script) => nativeList.add(toNativeScript(script)));
106
+ native.scripts.map((script) => nativeList.add(toCMLNativeScript(script)));
104
107
  return CML.NativeScript.new_script_all(nativeList);
105
108
  }
106
109
  case "any": {
107
110
  const nativeList = CML.NativeScriptList.new();
108
- native.scripts.map((script) => nativeList.add(toNativeScript(script)));
111
+ native.scripts.map((script) => nativeList.add(toCMLNativeScript(script)));
109
112
  return CML.NativeScript.new_script_any(nativeList);
110
113
  }
111
114
  case "atLeast": {
112
115
  const nativeList = CML.NativeScriptList.new();
113
- native.scripts.map((script) => nativeList.add(toNativeScript(script)));
116
+ native.scripts.map((script) => nativeList.add(toCMLNativeScript(script)));
114
117
  return CML.NativeScript.new_script_n_of_k(
115
118
  BigInt(native.required),
116
119
  nativeList
@@ -118,10 +121,50 @@ var toNativeScript = (native) => {
118
121
  }
119
122
  }
120
123
  };
121
- var nativeJSFromJson = (native) => {
124
+ var scriptFromNative = (native) => {
125
+ return {
126
+ type: "Native",
127
+ script: toCMLNativeScript(native).to_cbor_hex()
128
+ };
129
+ };
130
+ var CMLNativeSchema = S.Union(
131
+ S.Struct({
132
+ ScriptPubkey: S.Struct({
133
+ ed25519_key_hash: S.String
134
+ })
135
+ }),
136
+ S.Struct({
137
+ ScriptInvalidBefore: S.Struct({
138
+ before: S.Number
139
+ })
140
+ }),
141
+ S.Struct({
142
+ ScriptInvalidHereafter: S.Struct({
143
+ after: S.Number
144
+ })
145
+ }),
146
+ S.Struct({
147
+ ScriptAll: S.Struct({
148
+ native_scripts: S.Array(S.suspend(() => CMLNativeSchema))
149
+ })
150
+ }),
151
+ S.Struct({
152
+ ScriptAny: S.Struct({
153
+ native_scripts: S.Array(S.suspend(() => CMLNativeSchema))
154
+ })
155
+ }),
156
+ S.Struct({
157
+ ScriptNOfK: S.Struct({
158
+ n: S.Number,
159
+ native_scripts: S.Array(S.suspend(() => CMLNativeSchema))
160
+ })
161
+ })
162
+ );
163
+ var parseCMLNative = S.decodeUnknownSync(CMLNativeSchema);
164
+ var scriptFromCMLNative = (cmlNative) => {
122
165
  return {
123
166
  type: "Native",
124
- script: toNativeScript(native).to_cbor_hex()
167
+ script: CML.NativeScript.from_json(JSON.stringify(cmlNative)).to_cbor_hex()
125
168
  };
126
169
  };
127
170
 
@@ -243,17 +286,6 @@ function fromScriptRef(scriptRef) {
243
286
  function mintingPolicyToId(mintingPolicy) {
244
287
  return validatorToScriptHash(mintingPolicy);
245
288
  }
246
- function nativeFromJson(nativeScript) {
247
- return nativeJSFromJson(nativeScript);
248
- }
249
- function nativeScriptFromJson(nativeScript) {
250
- return {
251
- type: "Native",
252
- script: CML.NativeScript.from_json(
253
- JSON.stringify(nativeScript)
254
- ).to_cbor_hex()
255
- };
256
- }
257
289
  function applyParamsToScript(plutusScript, params, type) {
258
290
  const p = type ? import_plutus.Data.castTo(params, type) : params;
259
291
  return (0, import_core_utils2.toHex)(
@@ -1190,19 +1222,19 @@ var stringify = (data) => JSON.stringify(
1190
1222
  isEqualUTxO,
1191
1223
  keyHashToCredential,
1192
1224
  mintingPolicyToId,
1193
- nativeFromJson,
1194
- nativeJSFromJson,
1195
- nativeScriptFromJson,
1196
1225
  networkToId,
1226
+ parseCMLNative,
1197
1227
  paymentCredentialOf,
1228
+ scriptFromCMLNative,
1229
+ scriptFromNative,
1198
1230
  scriptHashToCredential,
1199
1231
  selectUTxOs,
1200
1232
  slotToUnixTime,
1201
1233
  sortUTxOs,
1202
1234
  stakeCredentialOf,
1203
1235
  stringify,
1236
+ toCMLNativeScript,
1204
1237
  toLabel,
1205
- toNativeScript,
1206
1238
  toPublicKey,
1207
1239
  toScriptRef,
1208
1240
  toUnit,
package/dist/index.d.cts CHANGED
@@ -1,9 +1,63 @@
1
- import { Native, Script, Network, Credential, RewardAddress, CertificateValidator, WithdrawalValidator, AddressDetails, CostModels, ProtocolParameters, Address, ScriptHash, KeyHash, Datum, DatumHash, PrivateKey, PublicKey, SpendingValidator, Validator, MintingPolicy, PolicyId, NativeScript, Exact, UnixTime, Slot, UTxO, OutRef, TxOutput, Assets, Unit } from '@lucid-evolution/core-types';
1
+ import * as _effect_schema_AST from '@effect/schema/AST';
2
+ import { Native, Script, Network, Credential, RewardAddress, CertificateValidator, WithdrawalValidator, AddressDetails, CostModels, ProtocolParameters, Address, ScriptHash, KeyHash, Datum, DatumHash, PrivateKey, PublicKey, SpendingValidator, Validator, MintingPolicy, PolicyId, Exact, UnixTime, Slot, UTxO, OutRef, TxOutput, Assets, Unit } from '@lucid-evolution/core-types';
2
3
  import * as CML from '@anastasia-labs/cardano-multiplatform-lib-nodejs';
3
4
  import { Data } from '@lucid-evolution/plutus';
4
5
 
5
- declare const toNativeScript: (native: Native) => CML.NativeScript;
6
- declare const nativeJSFromJson: (native: Native) => Script;
6
+ /**
7
+ * Converts a Native type (cardano-cli JSON script syntax) to CML.NativeScript.
8
+ *
9
+ * Native type follows the standard described in the
10
+ * {@link https://github.com/IntersectMBO/cardano-node/blob/1.26.1-with-cardano-cli/doc/reference/simple-scripts.md#json-script-syntax JSON script syntax documentation}.
11
+ */
12
+ declare const toCMLNativeScript: (native: Native) => CML.NativeScript;
13
+ /**
14
+ * Builds a Script from Native type (cardano-cli JSON script syntax).
15
+ *
16
+ * Native type follows the standard described in the
17
+ * {@link https://github.com/IntersectMBO/cardano-node/blob/1.26.1-with-cardano-cli/doc/reference/simple-scripts.md#json-script-syntax JSON script syntax documentation}.
18
+ */
19
+ declare const scriptFromNative: (native: Native) => Script;
20
+ /**
21
+ * Represents a CML JSON script syntax
22
+ */
23
+ type CMLNative = {
24
+ ScriptPubkey: {
25
+ ed25519_key_hash: string;
26
+ };
27
+ } | {
28
+ ScriptInvalidBefore: {
29
+ before: number;
30
+ };
31
+ } | {
32
+ ScriptInvalidHereafter: {
33
+ after: number;
34
+ };
35
+ } | {
36
+ ScriptAll: {
37
+ native_scripts: ReadonlyArray<CMLNative>;
38
+ };
39
+ } | {
40
+ ScriptAny: {
41
+ native_scripts: ReadonlyArray<CMLNative>;
42
+ };
43
+ } | {
44
+ ScriptNOfK: {
45
+ n: number;
46
+ native_scripts: ReadonlyArray<CMLNative>;
47
+ };
48
+ };
49
+ /**
50
+ * Parses a CMLNative type from an unknown input using effect schema.
51
+ * This function is useful for decoding unknown data to CMLNative from a file or an API.
52
+ *
53
+ * @throws {ParseError} - Throws a ParseError if the input does not conform to the schema.
54
+ */
55
+ declare const parseCMLNative: (u: unknown, overrideOptions?: _effect_schema_AST.ParseOptions) => CMLNative;
56
+ /**
57
+ * Builds a Script from CMLNative script type.
58
+ *
59
+ */
60
+ declare const scriptFromCMLNative: (cmlNative: CMLNative) => Script;
7
61
 
8
62
  declare function addressFromHexOrBech32(address: string): CML.Address;
9
63
  declare function credentialToRewardAddress(network: Network, stakeCredential: Credential): RewardAddress;
@@ -38,12 +92,6 @@ declare function validatorToScriptHash(validator: Validator): ScriptHash;
38
92
  declare function toScriptRef(script: Script): CML.Script;
39
93
  declare function fromScriptRef(scriptRef: CML.Script): Script;
40
94
  declare function mintingPolicyToId(mintingPolicy: MintingPolicy): PolicyId;
41
- declare function nativeFromJson(nativeScript: Native): Script;
42
- /**
43
- * Convert a native script from Json to the Hex representation.
44
- * It follows this Json format: https://github.com/input-output-hk/cardano-node/blob/master/doc/reference/simple-scripts.md
45
- */
46
- declare function nativeScriptFromJson(nativeScript: NativeScript): Script;
47
95
  declare function applyParamsToScript<T extends unknown[] = Data[]>(plutusScript: string, params: Exact<[...T]>, type?: T): string;
48
96
 
49
97
  declare function unixTimeToSlot(network: Network, unixTime: UnixTime): Slot;
@@ -108,4 +156,4 @@ declare function getUniqueTokenName(utxo: UTxO): Promise<string>;
108
156
 
109
157
  declare const stringify: (data: any) => string;
110
158
 
111
- export { PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, assetsToValue, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumToHash, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, nativeFromJson, nativeJSFromJson, nativeScriptFromJson, networkToId, paymentCredentialOf, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortUTxOs, stakeCredentialOf, stringify, toLabel, toNativeScript, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
159
+ export { type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, assetsToValue, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumToHash, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,63 @@
1
- import { Native, Script, Network, Credential, RewardAddress, CertificateValidator, WithdrawalValidator, AddressDetails, CostModels, ProtocolParameters, Address, ScriptHash, KeyHash, Datum, DatumHash, PrivateKey, PublicKey, SpendingValidator, Validator, MintingPolicy, PolicyId, NativeScript, Exact, UnixTime, Slot, UTxO, OutRef, TxOutput, Assets, Unit } from '@lucid-evolution/core-types';
1
+ import * as _effect_schema_AST from '@effect/schema/AST';
2
+ import { Native, Script, Network, Credential, RewardAddress, CertificateValidator, WithdrawalValidator, AddressDetails, CostModels, ProtocolParameters, Address, ScriptHash, KeyHash, Datum, DatumHash, PrivateKey, PublicKey, SpendingValidator, Validator, MintingPolicy, PolicyId, Exact, UnixTime, Slot, UTxO, OutRef, TxOutput, Assets, Unit } from '@lucid-evolution/core-types';
2
3
  import * as CML from '@anastasia-labs/cardano-multiplatform-lib-nodejs';
3
4
  import { Data } from '@lucid-evolution/plutus';
4
5
 
5
- declare const toNativeScript: (native: Native) => CML.NativeScript;
6
- declare const nativeJSFromJson: (native: Native) => Script;
6
+ /**
7
+ * Converts a Native type (cardano-cli JSON script syntax) to CML.NativeScript.
8
+ *
9
+ * Native type follows the standard described in the
10
+ * {@link https://github.com/IntersectMBO/cardano-node/blob/1.26.1-with-cardano-cli/doc/reference/simple-scripts.md#json-script-syntax JSON script syntax documentation}.
11
+ */
12
+ declare const toCMLNativeScript: (native: Native) => CML.NativeScript;
13
+ /**
14
+ * Builds a Script from Native type (cardano-cli JSON script syntax).
15
+ *
16
+ * Native type follows the standard described in the
17
+ * {@link https://github.com/IntersectMBO/cardano-node/blob/1.26.1-with-cardano-cli/doc/reference/simple-scripts.md#json-script-syntax JSON script syntax documentation}.
18
+ */
19
+ declare const scriptFromNative: (native: Native) => Script;
20
+ /**
21
+ * Represents a CML JSON script syntax
22
+ */
23
+ type CMLNative = {
24
+ ScriptPubkey: {
25
+ ed25519_key_hash: string;
26
+ };
27
+ } | {
28
+ ScriptInvalidBefore: {
29
+ before: number;
30
+ };
31
+ } | {
32
+ ScriptInvalidHereafter: {
33
+ after: number;
34
+ };
35
+ } | {
36
+ ScriptAll: {
37
+ native_scripts: ReadonlyArray<CMLNative>;
38
+ };
39
+ } | {
40
+ ScriptAny: {
41
+ native_scripts: ReadonlyArray<CMLNative>;
42
+ };
43
+ } | {
44
+ ScriptNOfK: {
45
+ n: number;
46
+ native_scripts: ReadonlyArray<CMLNative>;
47
+ };
48
+ };
49
+ /**
50
+ * Parses a CMLNative type from an unknown input using effect schema.
51
+ * This function is useful for decoding unknown data to CMLNative from a file or an API.
52
+ *
53
+ * @throws {ParseError} - Throws a ParseError if the input does not conform to the schema.
54
+ */
55
+ declare const parseCMLNative: (u: unknown, overrideOptions?: _effect_schema_AST.ParseOptions) => CMLNative;
56
+ /**
57
+ * Builds a Script from CMLNative script type.
58
+ *
59
+ */
60
+ declare const scriptFromCMLNative: (cmlNative: CMLNative) => Script;
7
61
 
8
62
  declare function addressFromHexOrBech32(address: string): CML.Address;
9
63
  declare function credentialToRewardAddress(network: Network, stakeCredential: Credential): RewardAddress;
@@ -38,12 +92,6 @@ declare function validatorToScriptHash(validator: Validator): ScriptHash;
38
92
  declare function toScriptRef(script: Script): CML.Script;
39
93
  declare function fromScriptRef(scriptRef: CML.Script): Script;
40
94
  declare function mintingPolicyToId(mintingPolicy: MintingPolicy): PolicyId;
41
- declare function nativeFromJson(nativeScript: Native): Script;
42
- /**
43
- * Convert a native script from Json to the Hex representation.
44
- * It follows this Json format: https://github.com/input-output-hk/cardano-node/blob/master/doc/reference/simple-scripts.md
45
- */
46
- declare function nativeScriptFromJson(nativeScript: NativeScript): Script;
47
95
  declare function applyParamsToScript<T extends unknown[] = Data[]>(plutusScript: string, params: Exact<[...T]>, type?: T): string;
48
96
 
49
97
  declare function unixTimeToSlot(network: Network, unixTime: UnixTime): Slot;
@@ -108,4 +156,4 @@ declare function getUniqueTokenName(utxo: UTxO): Promise<string>;
108
156
 
109
157
  declare const stringify: (data: any) => string;
110
158
 
111
- export { PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, assetsToValue, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumToHash, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, nativeFromJson, nativeJSFromJson, nativeScriptFromJson, networkToId, paymentCredentialOf, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortUTxOs, stakeCredentialOf, stringify, toLabel, toNativeScript, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
159
+ export { type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, assetsToValue, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumToHash, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
package/dist/index.js CHANGED
@@ -1,8 +1,11 @@
1
+ // src/native.ts
2
+ import * as S from "@effect/schema/Schema";
3
+
1
4
  // src/core.ts
2
5
  import * as CML from "@anastasia-labs/cardano-multiplatform-lib-nodejs";
3
6
 
4
7
  // src/native.ts
5
- var toNativeScript = (native) => {
8
+ var toCMLNativeScript = (native) => {
6
9
  switch (native.type) {
7
10
  case "sig":
8
11
  return CML.NativeScript.new_script_pubkey(
@@ -14,17 +17,17 @@ var toNativeScript = (native) => {
14
17
  return CML.NativeScript.new_script_invalid_before(BigInt(native.slot));
15
18
  case "all": {
16
19
  const nativeList = CML.NativeScriptList.new();
17
- native.scripts.map((script) => nativeList.add(toNativeScript(script)));
20
+ native.scripts.map((script) => nativeList.add(toCMLNativeScript(script)));
18
21
  return CML.NativeScript.new_script_all(nativeList);
19
22
  }
20
23
  case "any": {
21
24
  const nativeList = CML.NativeScriptList.new();
22
- native.scripts.map((script) => nativeList.add(toNativeScript(script)));
25
+ native.scripts.map((script) => nativeList.add(toCMLNativeScript(script)));
23
26
  return CML.NativeScript.new_script_any(nativeList);
24
27
  }
25
28
  case "atLeast": {
26
29
  const nativeList = CML.NativeScriptList.new();
27
- native.scripts.map((script) => nativeList.add(toNativeScript(script)));
30
+ native.scripts.map((script) => nativeList.add(toCMLNativeScript(script)));
28
31
  return CML.NativeScript.new_script_n_of_k(
29
32
  BigInt(native.required),
30
33
  nativeList
@@ -32,10 +35,50 @@ var toNativeScript = (native) => {
32
35
  }
33
36
  }
34
37
  };
35
- var nativeJSFromJson = (native) => {
38
+ var scriptFromNative = (native) => {
39
+ return {
40
+ type: "Native",
41
+ script: toCMLNativeScript(native).to_cbor_hex()
42
+ };
43
+ };
44
+ var CMLNativeSchema = S.Union(
45
+ S.Struct({
46
+ ScriptPubkey: S.Struct({
47
+ ed25519_key_hash: S.String
48
+ })
49
+ }),
50
+ S.Struct({
51
+ ScriptInvalidBefore: S.Struct({
52
+ before: S.Number
53
+ })
54
+ }),
55
+ S.Struct({
56
+ ScriptInvalidHereafter: S.Struct({
57
+ after: S.Number
58
+ })
59
+ }),
60
+ S.Struct({
61
+ ScriptAll: S.Struct({
62
+ native_scripts: S.Array(S.suspend(() => CMLNativeSchema))
63
+ })
64
+ }),
65
+ S.Struct({
66
+ ScriptAny: S.Struct({
67
+ native_scripts: S.Array(S.suspend(() => CMLNativeSchema))
68
+ })
69
+ }),
70
+ S.Struct({
71
+ ScriptNOfK: S.Struct({
72
+ n: S.Number,
73
+ native_scripts: S.Array(S.suspend(() => CMLNativeSchema))
74
+ })
75
+ })
76
+ );
77
+ var parseCMLNative = S.decodeUnknownSync(CMLNativeSchema);
78
+ var scriptFromCMLNative = (cmlNative) => {
36
79
  return {
37
80
  type: "Native",
38
- script: toNativeScript(native).to_cbor_hex()
81
+ script: CML.NativeScript.from_json(JSON.stringify(cmlNative)).to_cbor_hex()
39
82
  };
40
83
  };
41
84
 
@@ -157,17 +200,6 @@ function fromScriptRef(scriptRef) {
157
200
  function mintingPolicyToId(mintingPolicy) {
158
201
  return validatorToScriptHash(mintingPolicy);
159
202
  }
160
- function nativeFromJson(nativeScript) {
161
- return nativeJSFromJson(nativeScript);
162
- }
163
- function nativeScriptFromJson(nativeScript) {
164
- return {
165
- type: "Native",
166
- script: CML.NativeScript.from_json(
167
- JSON.stringify(nativeScript)
168
- ).to_cbor_hex()
169
- };
170
- }
171
203
  function applyParamsToScript(plutusScript, params, type) {
172
204
  const p = type ? Data.castTo(params, type) : params;
173
205
  return toHex2(
@@ -1107,19 +1139,19 @@ export {
1107
1139
  isEqualUTxO,
1108
1140
  keyHashToCredential,
1109
1141
  mintingPolicyToId,
1110
- nativeFromJson,
1111
- nativeJSFromJson,
1112
- nativeScriptFromJson,
1113
1142
  networkToId,
1143
+ parseCMLNative,
1114
1144
  paymentCredentialOf,
1145
+ scriptFromCMLNative,
1146
+ scriptFromNative,
1115
1147
  scriptHashToCredential,
1116
1148
  selectUTxOs,
1117
1149
  slotToUnixTime,
1118
1150
  sortUTxOs,
1119
1151
  stakeCredentialOf,
1120
1152
  stringify,
1153
+ toCMLNativeScript,
1121
1154
  toLabel,
1122
- toNativeScript,
1123
1155
  toPublicKey,
1124
1156
  toScriptRef,
1125
1157
  toUnit,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucid-evolution/utils",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -28,15 +28,17 @@
28
28
  "dependencies": {
29
29
  "@anastasia-labs/cardano-multiplatform-lib-browser": "^5.3.1-2",
30
30
  "@anastasia-labs/cardano-multiplatform-lib-nodejs": "^5.3.1-2",
31
+ "@effect/schema": "^0.68.16",
31
32
  "@emurgo/cardano-serialization-lib-browser": "^11.5.0",
32
33
  "@emurgo/cardano-serialization-lib-nodejs": "^11.5.0",
33
34
  "cborg": "^4.2.0",
35
+ "effect": "^3.1.2",
34
36
  "@lucid-evolution/bip39": "0.2.8",
35
- "@lucid-evolution/core-types": "0.1.8",
37
+ "@lucid-evolution/core-types": "0.1.9",
36
38
  "@lucid-evolution/core-utils": "0.1.7",
37
39
  "@lucid-evolution/crc8": "0.1.7",
38
- "@lucid-evolution/plutus": "0.1.11",
39
- "@lucid-evolution/uplc": "0.2.7"
40
+ "@lucid-evolution/plutus": "0.1.12",
41
+ "@lucid-evolution/uplc": "0.2.8"
40
42
  },
41
43
  "devDependencies": {
42
44
  "@types/node": "^20.12.8",