@lucid-evolution/utils 0.0.1
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 +1157 -0
- package/dist/index.d.cts +78 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +1080 -0
- package/package.json +34 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
PROTOCOL_PARAMETERS_DEFAULT: () => PROTOCOL_PARAMETERS_DEFAULT,
|
|
34
|
+
addAssets: () => addAssets,
|
|
35
|
+
addressFromHexOrBech32: () => addressFromHexOrBech32,
|
|
36
|
+
applyDoubleCborEncoding: () => import_lucid_cardano.applyDoubleCborEncoding,
|
|
37
|
+
assetsToValue: () => assetsToValue,
|
|
38
|
+
coreToOutRef: () => coreToOutRef,
|
|
39
|
+
coreToTxOutput: () => coreToTxOutput,
|
|
40
|
+
coreToUtxo: () => coreToUtxo,
|
|
41
|
+
coresToOutRefs: () => coresToOutRefs,
|
|
42
|
+
coresToTxOutputs: () => coresToTxOutputs,
|
|
43
|
+
coresToUtxos: () => coresToUtxos,
|
|
44
|
+
createCostModels: () => createCostModels,
|
|
45
|
+
credentialToAddress: () => credentialToAddress,
|
|
46
|
+
credentialToRewardAddress: () => credentialToRewardAddress,
|
|
47
|
+
datumToHash: () => datumToHash,
|
|
48
|
+
fromLabel: () => fromLabel,
|
|
49
|
+
fromScriptRef: () => fromScriptRef,
|
|
50
|
+
fromUnit: () => fromUnit,
|
|
51
|
+
generatePrivateKey: () => generatePrivateKey,
|
|
52
|
+
generateSeedPhrase: () => generateSeedPhrase,
|
|
53
|
+
getAddressDetails: () => getAddressDetails,
|
|
54
|
+
keyHashToCredential: () => keyHashToCredential,
|
|
55
|
+
mintingPolicyToId: () => mintingPolicyToId,
|
|
56
|
+
nativeFromJson: () => nativeFromJson,
|
|
57
|
+
nativeJSFromJson: () => nativeJSFromJson,
|
|
58
|
+
nativeScriptFromJson: () => nativeScriptFromJson,
|
|
59
|
+
networkToId: () => networkToId,
|
|
60
|
+
paymentCredentialOf: () => paymentCredentialOf,
|
|
61
|
+
scriptHashToCredential: () => scriptHashToCredential,
|
|
62
|
+
slotToUnixTime: () => slotToUnixTime,
|
|
63
|
+
stakeCredentialOf: () => stakeCredentialOf,
|
|
64
|
+
toLabel: () => toLabel,
|
|
65
|
+
toNativeScript: () => toNativeScript,
|
|
66
|
+
toPublicKey: () => toPublicKey,
|
|
67
|
+
toScriptRef: () => toScriptRef,
|
|
68
|
+
toUnit: () => toUnit,
|
|
69
|
+
unixTimeToSlot: () => unixTimeToSlot,
|
|
70
|
+
utxoToCore: () => utxoToCore,
|
|
71
|
+
utxoToTransactionInput: () => utxoToTransactionInput,
|
|
72
|
+
utxoToTransactionOutput: () => utxoToTransactionOutput,
|
|
73
|
+
utxosToCores: () => utxosToCores,
|
|
74
|
+
validatorToAddress: () => validatorToAddress,
|
|
75
|
+
validatorToRewardAddress: () => validatorToRewardAddress,
|
|
76
|
+
validatorToScriptHash: () => validatorToScriptHash,
|
|
77
|
+
valueToAssets: () => valueToAssets
|
|
78
|
+
});
|
|
79
|
+
module.exports = __toCommonJS(src_exports);
|
|
80
|
+
|
|
81
|
+
// src/native.ts
|
|
82
|
+
var CML = __toESM(require("@dcspark/cardano-multiplatform-lib-nodejs"), 1);
|
|
83
|
+
var toNativeScript = (native) => {
|
|
84
|
+
switch (native.type) {
|
|
85
|
+
case "sig":
|
|
86
|
+
return CML.NativeScript.new_script_pubkey(
|
|
87
|
+
CML.Ed25519KeyHash.from_hex(native.keyHash)
|
|
88
|
+
);
|
|
89
|
+
case "before":
|
|
90
|
+
return CML.NativeScript.new_script_invalid_hereafter(BigInt(native.slot));
|
|
91
|
+
case "after":
|
|
92
|
+
return CML.NativeScript.new_script_invalid_before(BigInt(native.slot));
|
|
93
|
+
case "all": {
|
|
94
|
+
const nativeList = CML.NativeScriptList.new();
|
|
95
|
+
native.scripts.map((script) => nativeList.add(toNativeScript(script)));
|
|
96
|
+
return CML.NativeScript.new_script_all(nativeList);
|
|
97
|
+
}
|
|
98
|
+
case "any": {
|
|
99
|
+
const nativeList = CML.NativeScriptList.new();
|
|
100
|
+
native.scripts.map((script) => nativeList.add(toNativeScript(script)));
|
|
101
|
+
return CML.NativeScript.new_script_any(nativeList);
|
|
102
|
+
}
|
|
103
|
+
case "atLeast": {
|
|
104
|
+
const nativeList = CML.NativeScriptList.new();
|
|
105
|
+
native.scripts.map((script) => nativeList.add(toNativeScript(script)));
|
|
106
|
+
return CML.NativeScript.new_script_n_of_k(
|
|
107
|
+
BigInt(native.required),
|
|
108
|
+
nativeList
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var nativeJSFromJson = (native) => {
|
|
114
|
+
return {
|
|
115
|
+
type: "Native",
|
|
116
|
+
script: toNativeScript(native).to_cbor_hex()
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// src/address.ts
|
|
121
|
+
var CML3 = __toESM(require("@dcspark/cardano-multiplatform-lib-nodejs"), 1);
|
|
122
|
+
|
|
123
|
+
// src/network.ts
|
|
124
|
+
function networkToId(network) {
|
|
125
|
+
switch (network) {
|
|
126
|
+
case "Preview":
|
|
127
|
+
return 0;
|
|
128
|
+
case "Preprod":
|
|
129
|
+
return 0;
|
|
130
|
+
case "Custom":
|
|
131
|
+
return 0;
|
|
132
|
+
case "Mainnet":
|
|
133
|
+
return 1;
|
|
134
|
+
default:
|
|
135
|
+
throw new Error("Network not found");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/scripts.ts
|
|
140
|
+
var CML2 = __toESM(require("@dcspark/cardano-multiplatform-lib-nodejs"), 1);
|
|
141
|
+
|
|
142
|
+
// src/cbor.ts
|
|
143
|
+
var import_lucid_cardano = require("lucid-cardano");
|
|
144
|
+
|
|
145
|
+
// src/scripts.ts
|
|
146
|
+
function validatorToAddress(network, validator, stakeCredential) {
|
|
147
|
+
const validatorHash = validatorToScriptHash(validator);
|
|
148
|
+
if (stakeCredential) {
|
|
149
|
+
return CML2.BaseAddress.new(
|
|
150
|
+
networkToId(network),
|
|
151
|
+
CML2.Credential.new_script(CML2.ScriptHash.from_hex(validatorHash)),
|
|
152
|
+
stakeCredential.type === "Key" ? CML2.Credential.new_pub_key(
|
|
153
|
+
CML2.Ed25519KeyHash.from_hex(stakeCredential.hash)
|
|
154
|
+
) : CML2.Credential.new_script(
|
|
155
|
+
CML2.ScriptHash.from_hex(stakeCredential.hash)
|
|
156
|
+
)
|
|
157
|
+
).to_address().to_bech32(void 0);
|
|
158
|
+
} else {
|
|
159
|
+
return CML2.EnterpriseAddress.new(
|
|
160
|
+
networkToId(network),
|
|
161
|
+
CML2.Credential.new_script(CML2.ScriptHash.from_hex(validatorHash))
|
|
162
|
+
).to_address().to_bech32(void 0);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function validatorToScriptHash(validator) {
|
|
166
|
+
switch (validator.type) {
|
|
167
|
+
case "Native":
|
|
168
|
+
return CML2.NativeScript.from_cbor_hex(validator.script).hash().to_hex();
|
|
169
|
+
case "PlutusV1":
|
|
170
|
+
return CML2.PlutusScript.from_v1(
|
|
171
|
+
CML2.PlutusV1Script.from_cbor_hex(
|
|
172
|
+
(0, import_lucid_cardano.applyDoubleCborEncoding)(validator.script)
|
|
173
|
+
)
|
|
174
|
+
).hash().to_hex();
|
|
175
|
+
case "PlutusV2":
|
|
176
|
+
return CML2.PlutusScript.from_v2(
|
|
177
|
+
CML2.PlutusV2Script.from_cbor_hex(
|
|
178
|
+
(0, import_lucid_cardano.applyDoubleCborEncoding)(validator.script)
|
|
179
|
+
)
|
|
180
|
+
).hash().to_hex();
|
|
181
|
+
default:
|
|
182
|
+
throw new Error("No variant matched");
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function toScriptRef(script) {
|
|
186
|
+
switch (script.type) {
|
|
187
|
+
case "Native":
|
|
188
|
+
return CML2.Script.new_native(
|
|
189
|
+
CML2.NativeScript.from_cbor_hex(script.script)
|
|
190
|
+
);
|
|
191
|
+
case "PlutusV1":
|
|
192
|
+
return CML2.Script.new_plutus_v1(
|
|
193
|
+
CML2.PlutusV1Script.from_cbor_hex(
|
|
194
|
+
(0, import_lucid_cardano.applyDoubleCborEncoding)(script.script)
|
|
195
|
+
)
|
|
196
|
+
);
|
|
197
|
+
case "PlutusV2":
|
|
198
|
+
return CML2.Script.new_plutus_v2(
|
|
199
|
+
CML2.PlutusV2Script.from_cbor_hex(
|
|
200
|
+
(0, import_lucid_cardano.applyDoubleCborEncoding)(script.script)
|
|
201
|
+
)
|
|
202
|
+
);
|
|
203
|
+
default:
|
|
204
|
+
throw new Error("No variant matched.");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function fromScriptRef(scriptRef) {
|
|
208
|
+
const kind = scriptRef.kind();
|
|
209
|
+
switch (kind) {
|
|
210
|
+
case 0:
|
|
211
|
+
return {
|
|
212
|
+
type: "Native",
|
|
213
|
+
script: scriptRef.as_native().to_cbor_hex()
|
|
214
|
+
};
|
|
215
|
+
case 1:
|
|
216
|
+
return {
|
|
217
|
+
type: "PlutusV1",
|
|
218
|
+
script: scriptRef.as_plutus_v1().to_cbor_hex()
|
|
219
|
+
};
|
|
220
|
+
case 2:
|
|
221
|
+
return {
|
|
222
|
+
type: "PlutusV2",
|
|
223
|
+
script: scriptRef.as_plutus_v2().to_cbor_hex()
|
|
224
|
+
};
|
|
225
|
+
default:
|
|
226
|
+
throw new Error("No variant matched.");
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function mintingPolicyToId(mintingPolicy) {
|
|
230
|
+
return validatorToScriptHash(mintingPolicy);
|
|
231
|
+
}
|
|
232
|
+
function nativeFromJson(nativeScript) {
|
|
233
|
+
return nativeJSFromJson(nativeScript);
|
|
234
|
+
}
|
|
235
|
+
function nativeScriptFromJson(nativeScript) {
|
|
236
|
+
return {
|
|
237
|
+
type: "Native",
|
|
238
|
+
script: CML2.NativeScript.from_json(
|
|
239
|
+
JSON.stringify(nativeScript)
|
|
240
|
+
).to_cbor_hex()
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// src/address.ts
|
|
245
|
+
function addressFromHexOrBech32(address) {
|
|
246
|
+
try {
|
|
247
|
+
return CML3.Address.from_hex(address);
|
|
248
|
+
} catch (_e) {
|
|
249
|
+
try {
|
|
250
|
+
return CML3.Address.from_bech32(address);
|
|
251
|
+
} catch (_e2) {
|
|
252
|
+
throw new Error("Could not deserialize address.");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function credentialToRewardAddress(network, stakeCredential) {
|
|
257
|
+
return CML3.RewardAddress.new(
|
|
258
|
+
networkToId(network),
|
|
259
|
+
stakeCredential.type === "Key" ? CML3.Credential.new_pub_key(
|
|
260
|
+
CML3.Ed25519KeyHash.from_hex(stakeCredential.hash)
|
|
261
|
+
) : CML3.Credential.new_script(
|
|
262
|
+
CML3.ScriptHash.from_hex(stakeCredential.hash)
|
|
263
|
+
)
|
|
264
|
+
).to_address().to_bech32(void 0);
|
|
265
|
+
}
|
|
266
|
+
function validatorToRewardAddress(network, validator) {
|
|
267
|
+
const validatorHash = validatorToScriptHash(validator);
|
|
268
|
+
return CML3.RewardAddress.new(
|
|
269
|
+
networkToId(network),
|
|
270
|
+
CML3.Credential.new_script(CML3.ScriptHash.from_hex(validatorHash))
|
|
271
|
+
).to_address().to_bech32(void 0);
|
|
272
|
+
}
|
|
273
|
+
function getAddressDetails(address) {
|
|
274
|
+
try {
|
|
275
|
+
const parsedAddress = CML3.BaseAddress.from_address(
|
|
276
|
+
CML3.Address.from_bech32(address)
|
|
277
|
+
);
|
|
278
|
+
const paymentCredential = parsedAddress.payment().kind() === 0 ? {
|
|
279
|
+
type: "Key",
|
|
280
|
+
// hash: toHex(
|
|
281
|
+
// parsedAddress.payment_cred().to_keyhash()!.to_bytes(),
|
|
282
|
+
// ),
|
|
283
|
+
hash: parsedAddress.payment().as_pub_key().to_hex()
|
|
284
|
+
} : {
|
|
285
|
+
type: "Script",
|
|
286
|
+
// hash: toHex(
|
|
287
|
+
// parsedAddress.payment_cred().to_scripthash()!.to_bytes(),
|
|
288
|
+
// ),
|
|
289
|
+
hash: parsedAddress.payment().as_script().to_hex()
|
|
290
|
+
};
|
|
291
|
+
const stakeCredential = parsedAddress.stake().kind() === 0 ? (
|
|
292
|
+
// parsedAddress.stake_cred().kind() === 0
|
|
293
|
+
{
|
|
294
|
+
type: "Key",
|
|
295
|
+
hash: parsedAddress.stake().as_pub_key().to_hex()
|
|
296
|
+
// hash: toHex(parsedAddress.stake_cred().to_keyhash()!.to_bytes()),
|
|
297
|
+
}
|
|
298
|
+
) : {
|
|
299
|
+
type: "Script",
|
|
300
|
+
// hash: toHex(parsedAddress.stake_cred().to_scripthash()!.to_bytes()),
|
|
301
|
+
hash: parsedAddress.stake().as_script().to_hex()
|
|
302
|
+
};
|
|
303
|
+
return {
|
|
304
|
+
type: "Base",
|
|
305
|
+
networkId: parsedAddress.to_address().network_id(),
|
|
306
|
+
address: {
|
|
307
|
+
bech32: parsedAddress.to_address().to_bech32(void 0),
|
|
308
|
+
// hex: toHex(parsedAddress.to_address().to_bytes()),
|
|
309
|
+
hex: parsedAddress.to_address().to_hex()
|
|
310
|
+
},
|
|
311
|
+
paymentCredential,
|
|
312
|
+
stakeCredential
|
|
313
|
+
};
|
|
314
|
+
} catch (_e) {
|
|
315
|
+
}
|
|
316
|
+
try {
|
|
317
|
+
const parsedAddress = CML3.EnterpriseAddress.from_address(
|
|
318
|
+
CML3.Address.from_bech32(address)
|
|
319
|
+
);
|
|
320
|
+
const paymentCredential = parsedAddress.payment().kind() === 0 ? {
|
|
321
|
+
type: "Key",
|
|
322
|
+
// hash: toHex(parsedAddress.payment_cred().to_keyhash()!.to_bytes()),
|
|
323
|
+
hash: parsedAddress.payment().as_pub_key().to_hex()
|
|
324
|
+
} : {
|
|
325
|
+
type: "Script",
|
|
326
|
+
hash: (
|
|
327
|
+
// parsedAddress.payment_cred().to_scripthash()!.to_bytes()
|
|
328
|
+
parsedAddress.payment().as_script().to_hex()
|
|
329
|
+
)
|
|
330
|
+
};
|
|
331
|
+
return {
|
|
332
|
+
type: "Enterprise",
|
|
333
|
+
networkId: parsedAddress.to_address().network_id(),
|
|
334
|
+
address: {
|
|
335
|
+
bech32: parsedAddress.to_address().to_bech32(void 0),
|
|
336
|
+
hex: parsedAddress.to_address().to_hex()
|
|
337
|
+
},
|
|
338
|
+
paymentCredential
|
|
339
|
+
};
|
|
340
|
+
} catch (_e) {
|
|
341
|
+
}
|
|
342
|
+
try {
|
|
343
|
+
const parsedAddress = CML3.PointerAddress.from_address(
|
|
344
|
+
CML3.Address.from_bech32(address)
|
|
345
|
+
);
|
|
346
|
+
const paymentCredential = parsedAddress?.payment().kind() === 0 ? {
|
|
347
|
+
type: "Key",
|
|
348
|
+
// hash: toHex(parsedAddress.payment_cred().to_keyhash()!.to_bytes()),
|
|
349
|
+
hash: parsedAddress.payment().as_pub_key().to_hex()
|
|
350
|
+
} : {
|
|
351
|
+
type: "Script",
|
|
352
|
+
// hash: toHex( parsedAddress.payment_cred().to_scripthash()!.to_bytes()),
|
|
353
|
+
hash: parsedAddress.payment().as_script().to_hex()
|
|
354
|
+
};
|
|
355
|
+
return {
|
|
356
|
+
type: "Pointer",
|
|
357
|
+
networkId: parsedAddress.to_address().network_id(),
|
|
358
|
+
address: {
|
|
359
|
+
bech32: parsedAddress.to_address().to_bech32(void 0),
|
|
360
|
+
// hex: toHex(parsedAddress.to_address().to_bytes()),
|
|
361
|
+
hex: parsedAddress.to_address().to_hex()
|
|
362
|
+
},
|
|
363
|
+
paymentCredential
|
|
364
|
+
};
|
|
365
|
+
} catch (_e) {
|
|
366
|
+
}
|
|
367
|
+
try {
|
|
368
|
+
const parsedAddress = CML3.RewardAddress.from_address(
|
|
369
|
+
CML3.Address.from_bech32(address)
|
|
370
|
+
);
|
|
371
|
+
const stakeCredential = parsedAddress.payment().kind() === 0 ? {
|
|
372
|
+
type: "Key",
|
|
373
|
+
hash: parsedAddress.payment().as_pub_key().to_hex()
|
|
374
|
+
} : {
|
|
375
|
+
type: "Script",
|
|
376
|
+
hash: parsedAddress.payment().as_script().to_hex()
|
|
377
|
+
};
|
|
378
|
+
return {
|
|
379
|
+
type: "Reward",
|
|
380
|
+
networkId: parsedAddress.to_address().network_id(),
|
|
381
|
+
address: {
|
|
382
|
+
bech32: parsedAddress.to_address().to_bech32(void 0),
|
|
383
|
+
// hex: toHex(parsedAddress.to_address().to_bytes()),
|
|
384
|
+
hex: parsedAddress.to_address().to_hex()
|
|
385
|
+
},
|
|
386
|
+
stakeCredential
|
|
387
|
+
};
|
|
388
|
+
} catch (_e) {
|
|
389
|
+
}
|
|
390
|
+
try {
|
|
391
|
+
const parsedAddress = ((address2) => {
|
|
392
|
+
try {
|
|
393
|
+
return CML3.ByronAddress.from_cbor_hex(address2);
|
|
394
|
+
} catch (_e) {
|
|
395
|
+
try {
|
|
396
|
+
return CML3.ByronAddress.from_base58(address2);
|
|
397
|
+
} catch (_e2) {
|
|
398
|
+
throw new Error("Could not deserialize address.");
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
})(address);
|
|
402
|
+
return {
|
|
403
|
+
type: "Byron",
|
|
404
|
+
networkId: parsedAddress.content().network_id(),
|
|
405
|
+
address: {
|
|
406
|
+
bech32: "",
|
|
407
|
+
// hex: toHex(parsedAddress.to_address().to_bytes()),
|
|
408
|
+
hex: parsedAddress.to_address().to_hex()
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
} catch (_e) {
|
|
412
|
+
}
|
|
413
|
+
throw new Error("No address type matched for: " + address);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// src/cost_model.ts
|
|
417
|
+
var CML4 = __toESM(require("@dcspark/cardano-multiplatform-lib-nodejs"), 1);
|
|
418
|
+
function createCostModels(costModels) {
|
|
419
|
+
const costmdls = CML4.CostModels.new();
|
|
420
|
+
const costmdlV1 = CML4.IntList.new();
|
|
421
|
+
Object.values(costModels.PlutusV2).forEach((cost) => {
|
|
422
|
+
costmdlV1.add(CML4.Int.new(BigInt(cost)));
|
|
423
|
+
});
|
|
424
|
+
costmdls.set_plutus_v1(costmdlV1);
|
|
425
|
+
const costmdlV2 = CML4.IntList.new();
|
|
426
|
+
Object.values(costModels.PlutusV2).forEach((cost) => {
|
|
427
|
+
costmdlV2.add(CML4.Int.new(BigInt(cost)));
|
|
428
|
+
});
|
|
429
|
+
costmdls.set_plutus_v2(costmdlV2);
|
|
430
|
+
return costmdls;
|
|
431
|
+
}
|
|
432
|
+
var PROTOCOL_PARAMETERS_DEFAULT = {
|
|
433
|
+
minFeeA: 44,
|
|
434
|
+
minFeeB: 155381,
|
|
435
|
+
maxTxSize: 16384,
|
|
436
|
+
maxValSize: 5e3,
|
|
437
|
+
keyDeposit: 2000000n,
|
|
438
|
+
poolDeposit: 500000000n,
|
|
439
|
+
priceMem: 0.0577,
|
|
440
|
+
priceStep: 721e-7,
|
|
441
|
+
maxTxExMem: 14000000n,
|
|
442
|
+
maxTxExSteps: 10000000000n,
|
|
443
|
+
coinsPerUtxoByte: 4310n,
|
|
444
|
+
collateralPercentage: 150,
|
|
445
|
+
maxCollateralInputs: 3,
|
|
446
|
+
costModels: {
|
|
447
|
+
PlutusV1: {
|
|
448
|
+
"addInteger-cpu-arguments-intercept": 205665,
|
|
449
|
+
"addInteger-cpu-arguments-slope": 812,
|
|
450
|
+
"addInteger-memory-arguments-intercept": 1,
|
|
451
|
+
"addInteger-memory-arguments-slope": 1,
|
|
452
|
+
"appendByteString-cpu-arguments-intercept": 1e3,
|
|
453
|
+
"appendByteString-cpu-arguments-slope": 571,
|
|
454
|
+
"appendByteString-memory-arguments-intercept": 0,
|
|
455
|
+
"appendByteString-memory-arguments-slope": 1,
|
|
456
|
+
"appendString-cpu-arguments-intercept": 1e3,
|
|
457
|
+
"appendString-cpu-arguments-slope": 24177,
|
|
458
|
+
"appendString-memory-arguments-intercept": 4,
|
|
459
|
+
"appendString-memory-arguments-slope": 1,
|
|
460
|
+
"bData-cpu-arguments": 1e3,
|
|
461
|
+
"bData-memory-arguments": 32,
|
|
462
|
+
"blake2b_256-cpu-arguments-intercept": 117366,
|
|
463
|
+
"blake2b_256-cpu-arguments-slope": 10475,
|
|
464
|
+
"blake2b_256-memory-arguments": 4,
|
|
465
|
+
"cekApplyCost-exBudgetCPU": 23e3,
|
|
466
|
+
"cekApplyCost-exBudgetMemory": 100,
|
|
467
|
+
"cekBuiltinCost-exBudgetCPU": 23e3,
|
|
468
|
+
"cekBuiltinCost-exBudgetMemory": 100,
|
|
469
|
+
"cekConstCost-exBudgetCPU": 23e3,
|
|
470
|
+
"cekConstCost-exBudgetMemory": 100,
|
|
471
|
+
"cekDelayCost-exBudgetCPU": 23e3,
|
|
472
|
+
"cekDelayCost-exBudgetMemory": 100,
|
|
473
|
+
"cekForceCost-exBudgetCPU": 23e3,
|
|
474
|
+
"cekForceCost-exBudgetMemory": 100,
|
|
475
|
+
"cekLamCost-exBudgetCPU": 23e3,
|
|
476
|
+
"cekLamCost-exBudgetMemory": 100,
|
|
477
|
+
"cekStartupCost-exBudgetCPU": 100,
|
|
478
|
+
"cekStartupCost-exBudgetMemory": 100,
|
|
479
|
+
"cekVarCost-exBudgetCPU": 23e3,
|
|
480
|
+
"cekVarCost-exBudgetMemory": 100,
|
|
481
|
+
"chooseData-cpu-arguments": 19537,
|
|
482
|
+
"chooseData-memory-arguments": 32,
|
|
483
|
+
"chooseList-cpu-arguments": 175354,
|
|
484
|
+
"chooseList-memory-arguments": 32,
|
|
485
|
+
"chooseUnit-cpu-arguments": 46417,
|
|
486
|
+
"chooseUnit-memory-arguments": 4,
|
|
487
|
+
"consByteString-cpu-arguments-intercept": 221973,
|
|
488
|
+
"consByteString-cpu-arguments-slope": 511,
|
|
489
|
+
"consByteString-memory-arguments-intercept": 0,
|
|
490
|
+
"consByteString-memory-arguments-slope": 1,
|
|
491
|
+
"constrData-cpu-arguments": 89141,
|
|
492
|
+
"constrData-memory-arguments": 32,
|
|
493
|
+
"decodeUtf8-cpu-arguments-intercept": 497525,
|
|
494
|
+
"decodeUtf8-cpu-arguments-slope": 14068,
|
|
495
|
+
"decodeUtf8-memory-arguments-intercept": 4,
|
|
496
|
+
"decodeUtf8-memory-arguments-slope": 2,
|
|
497
|
+
"divideInteger-cpu-arguments-constant": 196500,
|
|
498
|
+
"divideInteger-cpu-arguments-model-arguments-intercept": 453240,
|
|
499
|
+
"divideInteger-cpu-arguments-model-arguments-slope": 220,
|
|
500
|
+
"divideInteger-memory-arguments-intercept": 0,
|
|
501
|
+
"divideInteger-memory-arguments-minimum": 1,
|
|
502
|
+
"divideInteger-memory-arguments-slope": 1,
|
|
503
|
+
"encodeUtf8-cpu-arguments-intercept": 1e3,
|
|
504
|
+
"encodeUtf8-cpu-arguments-slope": 28662,
|
|
505
|
+
"encodeUtf8-memory-arguments-intercept": 4,
|
|
506
|
+
"encodeUtf8-memory-arguments-slope": 2,
|
|
507
|
+
"equalsByteString-cpu-arguments-constant": 245e3,
|
|
508
|
+
"equalsByteString-cpu-arguments-intercept": 216773,
|
|
509
|
+
"equalsByteString-cpu-arguments-slope": 62,
|
|
510
|
+
"equalsByteString-memory-arguments": 1,
|
|
511
|
+
"equalsData-cpu-arguments-intercept": 1060367,
|
|
512
|
+
"equalsData-cpu-arguments-slope": 12586,
|
|
513
|
+
"equalsData-memory-arguments": 1,
|
|
514
|
+
"equalsInteger-cpu-arguments-intercept": 208512,
|
|
515
|
+
"equalsInteger-cpu-arguments-slope": 421,
|
|
516
|
+
"equalsInteger-memory-arguments": 1,
|
|
517
|
+
"equalsString-cpu-arguments-constant": 187e3,
|
|
518
|
+
"equalsString-cpu-arguments-intercept": 1e3,
|
|
519
|
+
"equalsString-cpu-arguments-slope": 52998,
|
|
520
|
+
"equalsString-memory-arguments": 1,
|
|
521
|
+
"fstPair-cpu-arguments": 80436,
|
|
522
|
+
"fstPair-memory-arguments": 32,
|
|
523
|
+
"headList-cpu-arguments": 43249,
|
|
524
|
+
"headList-memory-arguments": 32,
|
|
525
|
+
"iData-cpu-arguments": 1e3,
|
|
526
|
+
"iData-memory-arguments": 32,
|
|
527
|
+
"ifThenElse-cpu-arguments": 80556,
|
|
528
|
+
"ifThenElse-memory-arguments": 1,
|
|
529
|
+
"indexByteString-cpu-arguments": 57667,
|
|
530
|
+
"indexByteString-memory-arguments": 4,
|
|
531
|
+
"lengthOfByteString-cpu-arguments": 1e3,
|
|
532
|
+
"lengthOfByteString-memory-arguments": 10,
|
|
533
|
+
"lessThanByteString-cpu-arguments-intercept": 197145,
|
|
534
|
+
"lessThanByteString-cpu-arguments-slope": 156,
|
|
535
|
+
"lessThanByteString-memory-arguments": 1,
|
|
536
|
+
"lessThanEqualsByteString-cpu-arguments-intercept": 197145,
|
|
537
|
+
"lessThanEqualsByteString-cpu-arguments-slope": 156,
|
|
538
|
+
"lessThanEqualsByteString-memory-arguments": 1,
|
|
539
|
+
"lessThanEqualsInteger-cpu-arguments-intercept": 204924,
|
|
540
|
+
"lessThanEqualsInteger-cpu-arguments-slope": 473,
|
|
541
|
+
"lessThanEqualsInteger-memory-arguments": 1,
|
|
542
|
+
"lessThanInteger-cpu-arguments-intercept": 208896,
|
|
543
|
+
"lessThanInteger-cpu-arguments-slope": 511,
|
|
544
|
+
"lessThanInteger-memory-arguments": 1,
|
|
545
|
+
"listData-cpu-arguments": 52467,
|
|
546
|
+
"listData-memory-arguments": 32,
|
|
547
|
+
"mapData-cpu-arguments": 64832,
|
|
548
|
+
"mapData-memory-arguments": 32,
|
|
549
|
+
"mkCons-cpu-arguments": 65493,
|
|
550
|
+
"mkCons-memory-arguments": 32,
|
|
551
|
+
"mkNilData-cpu-arguments": 22558,
|
|
552
|
+
"mkNilData-memory-arguments": 32,
|
|
553
|
+
"mkNilPairData-cpu-arguments": 16563,
|
|
554
|
+
"mkNilPairData-memory-arguments": 32,
|
|
555
|
+
"mkPairData-cpu-arguments": 76511,
|
|
556
|
+
"mkPairData-memory-arguments": 32,
|
|
557
|
+
"modInteger-cpu-arguments-constant": 196500,
|
|
558
|
+
"modInteger-cpu-arguments-model-arguments-intercept": 453240,
|
|
559
|
+
"modInteger-cpu-arguments-model-arguments-slope": 220,
|
|
560
|
+
"modInteger-memory-arguments-intercept": 0,
|
|
561
|
+
"modInteger-memory-arguments-minimum": 1,
|
|
562
|
+
"modInteger-memory-arguments-slope": 1,
|
|
563
|
+
"multiplyInteger-cpu-arguments-intercept": 69522,
|
|
564
|
+
"multiplyInteger-cpu-arguments-slope": 11687,
|
|
565
|
+
"multiplyInteger-memory-arguments-intercept": 0,
|
|
566
|
+
"multiplyInteger-memory-arguments-slope": 1,
|
|
567
|
+
"nullList-cpu-arguments": 60091,
|
|
568
|
+
"nullList-memory-arguments": 32,
|
|
569
|
+
"quotientInteger-cpu-arguments-constant": 196500,
|
|
570
|
+
"quotientInteger-cpu-arguments-model-arguments-intercept": 453240,
|
|
571
|
+
"quotientInteger-cpu-arguments-model-arguments-slope": 220,
|
|
572
|
+
"quotientInteger-memory-arguments-intercept": 0,
|
|
573
|
+
"quotientInteger-memory-arguments-minimum": 1,
|
|
574
|
+
"quotientInteger-memory-arguments-slope": 1,
|
|
575
|
+
"remainderInteger-cpu-arguments-constant": 196500,
|
|
576
|
+
"remainderInteger-cpu-arguments-model-arguments-intercept": 453240,
|
|
577
|
+
"remainderInteger-cpu-arguments-model-arguments-slope": 220,
|
|
578
|
+
"remainderInteger-memory-arguments-intercept": 0,
|
|
579
|
+
"remainderInteger-memory-arguments-minimum": 1,
|
|
580
|
+
"remainderInteger-memory-arguments-slope": 1,
|
|
581
|
+
"sha2_256-cpu-arguments-intercept": 806990,
|
|
582
|
+
"sha2_256-cpu-arguments-slope": 30482,
|
|
583
|
+
"sha2_256-memory-arguments": 4,
|
|
584
|
+
"sha3_256-cpu-arguments-intercept": 1927926,
|
|
585
|
+
"sha3_256-cpu-arguments-slope": 82523,
|
|
586
|
+
"sha3_256-memory-arguments": 4,
|
|
587
|
+
"sliceByteString-cpu-arguments-intercept": 265318,
|
|
588
|
+
"sliceByteString-cpu-arguments-slope": 0,
|
|
589
|
+
"sliceByteString-memory-arguments-intercept": 4,
|
|
590
|
+
"sliceByteString-memory-arguments-slope": 0,
|
|
591
|
+
"sndPair-cpu-arguments": 85931,
|
|
592
|
+
"sndPair-memory-arguments": 32,
|
|
593
|
+
"subtractInteger-cpu-arguments-intercept": 205665,
|
|
594
|
+
"subtractInteger-cpu-arguments-slope": 812,
|
|
595
|
+
"subtractInteger-memory-arguments-intercept": 1,
|
|
596
|
+
"subtractInteger-memory-arguments-slope": 1,
|
|
597
|
+
"tailList-cpu-arguments": 41182,
|
|
598
|
+
"tailList-memory-arguments": 32,
|
|
599
|
+
"trace-cpu-arguments": 212342,
|
|
600
|
+
"trace-memory-arguments": 32,
|
|
601
|
+
"unBData-cpu-arguments": 31220,
|
|
602
|
+
"unBData-memory-arguments": 32,
|
|
603
|
+
"unConstrData-cpu-arguments": 32696,
|
|
604
|
+
"unConstrData-memory-arguments": 32,
|
|
605
|
+
"unIData-cpu-arguments": 43357,
|
|
606
|
+
"unIData-memory-arguments": 32,
|
|
607
|
+
"unListData-cpu-arguments": 32247,
|
|
608
|
+
"unListData-memory-arguments": 32,
|
|
609
|
+
"unMapData-cpu-arguments": 38314,
|
|
610
|
+
"unMapData-memory-arguments": 32,
|
|
611
|
+
"verifyEd25519Signature-cpu-arguments-intercept": 9462713,
|
|
612
|
+
"verifyEd25519Signature-cpu-arguments-slope": 1021,
|
|
613
|
+
"verifyEd25519Signature-memory-arguments": 10
|
|
614
|
+
},
|
|
615
|
+
PlutusV2: {
|
|
616
|
+
"addInteger-cpu-arguments-intercept": 205665,
|
|
617
|
+
"addInteger-cpu-arguments-slope": 812,
|
|
618
|
+
"addInteger-memory-arguments-intercept": 1,
|
|
619
|
+
"addInteger-memory-arguments-slope": 1,
|
|
620
|
+
"appendByteString-cpu-arguments-intercept": 1e3,
|
|
621
|
+
"appendByteString-cpu-arguments-slope": 571,
|
|
622
|
+
"appendByteString-memory-arguments-intercept": 0,
|
|
623
|
+
"appendByteString-memory-arguments-slope": 1,
|
|
624
|
+
"appendString-cpu-arguments-intercept": 1e3,
|
|
625
|
+
"appendString-cpu-arguments-slope": 24177,
|
|
626
|
+
"appendString-memory-arguments-intercept": 4,
|
|
627
|
+
"appendString-memory-arguments-slope": 1,
|
|
628
|
+
"bData-cpu-arguments": 1e3,
|
|
629
|
+
"bData-memory-arguments": 32,
|
|
630
|
+
"blake2b_256-cpu-arguments-intercept": 117366,
|
|
631
|
+
"blake2b_256-cpu-arguments-slope": 10475,
|
|
632
|
+
"blake2b_256-memory-arguments": 4,
|
|
633
|
+
"cekApplyCost-exBudgetCPU": 23e3,
|
|
634
|
+
"cekApplyCost-exBudgetMemory": 100,
|
|
635
|
+
"cekBuiltinCost-exBudgetCPU": 23e3,
|
|
636
|
+
"cekBuiltinCost-exBudgetMemory": 100,
|
|
637
|
+
"cekConstCost-exBudgetCPU": 23e3,
|
|
638
|
+
"cekConstCost-exBudgetMemory": 100,
|
|
639
|
+
"cekDelayCost-exBudgetCPU": 23e3,
|
|
640
|
+
"cekDelayCost-exBudgetMemory": 100,
|
|
641
|
+
"cekForceCost-exBudgetCPU": 23e3,
|
|
642
|
+
"cekForceCost-exBudgetMemory": 100,
|
|
643
|
+
"cekLamCost-exBudgetCPU": 23e3,
|
|
644
|
+
"cekLamCost-exBudgetMemory": 100,
|
|
645
|
+
"cekStartupCost-exBudgetCPU": 100,
|
|
646
|
+
"cekStartupCost-exBudgetMemory": 100,
|
|
647
|
+
"cekVarCost-exBudgetCPU": 23e3,
|
|
648
|
+
"cekVarCost-exBudgetMemory": 100,
|
|
649
|
+
"chooseData-cpu-arguments": 19537,
|
|
650
|
+
"chooseData-memory-arguments": 32,
|
|
651
|
+
"chooseList-cpu-arguments": 175354,
|
|
652
|
+
"chooseList-memory-arguments": 32,
|
|
653
|
+
"chooseUnit-cpu-arguments": 46417,
|
|
654
|
+
"chooseUnit-memory-arguments": 4,
|
|
655
|
+
"consByteString-cpu-arguments-intercept": 221973,
|
|
656
|
+
"consByteString-cpu-arguments-slope": 511,
|
|
657
|
+
"consByteString-memory-arguments-intercept": 0,
|
|
658
|
+
"consByteString-memory-arguments-slope": 1,
|
|
659
|
+
"constrData-cpu-arguments": 89141,
|
|
660
|
+
"constrData-memory-arguments": 32,
|
|
661
|
+
"decodeUtf8-cpu-arguments-intercept": 497525,
|
|
662
|
+
"decodeUtf8-cpu-arguments-slope": 14068,
|
|
663
|
+
"decodeUtf8-memory-arguments-intercept": 4,
|
|
664
|
+
"decodeUtf8-memory-arguments-slope": 2,
|
|
665
|
+
"divideInteger-cpu-arguments-constant": 196500,
|
|
666
|
+
"divideInteger-cpu-arguments-model-arguments-intercept": 453240,
|
|
667
|
+
"divideInteger-cpu-arguments-model-arguments-slope": 220,
|
|
668
|
+
"divideInteger-memory-arguments-intercept": 0,
|
|
669
|
+
"divideInteger-memory-arguments-minimum": 1,
|
|
670
|
+
"divideInteger-memory-arguments-slope": 1,
|
|
671
|
+
"encodeUtf8-cpu-arguments-intercept": 1e3,
|
|
672
|
+
"encodeUtf8-cpu-arguments-slope": 28662,
|
|
673
|
+
"encodeUtf8-memory-arguments-intercept": 4,
|
|
674
|
+
"encodeUtf8-memory-arguments-slope": 2,
|
|
675
|
+
"equalsByteString-cpu-arguments-constant": 245e3,
|
|
676
|
+
"equalsByteString-cpu-arguments-intercept": 216773,
|
|
677
|
+
"equalsByteString-cpu-arguments-slope": 62,
|
|
678
|
+
"equalsByteString-memory-arguments": 1,
|
|
679
|
+
"equalsData-cpu-arguments-intercept": 1060367,
|
|
680
|
+
"equalsData-cpu-arguments-slope": 12586,
|
|
681
|
+
"equalsData-memory-arguments": 1,
|
|
682
|
+
"equalsInteger-cpu-arguments-intercept": 208512,
|
|
683
|
+
"equalsInteger-cpu-arguments-slope": 421,
|
|
684
|
+
"equalsInteger-memory-arguments": 1,
|
|
685
|
+
"equalsString-cpu-arguments-constant": 187e3,
|
|
686
|
+
"equalsString-cpu-arguments-intercept": 1e3,
|
|
687
|
+
"equalsString-cpu-arguments-slope": 52998,
|
|
688
|
+
"equalsString-memory-arguments": 1,
|
|
689
|
+
"fstPair-cpu-arguments": 80436,
|
|
690
|
+
"fstPair-memory-arguments": 32,
|
|
691
|
+
"headList-cpu-arguments": 43249,
|
|
692
|
+
"headList-memory-arguments": 32,
|
|
693
|
+
"iData-cpu-arguments": 1e3,
|
|
694
|
+
"iData-memory-arguments": 32,
|
|
695
|
+
"ifThenElse-cpu-arguments": 80556,
|
|
696
|
+
"ifThenElse-memory-arguments": 1,
|
|
697
|
+
"indexByteString-cpu-arguments": 57667,
|
|
698
|
+
"indexByteString-memory-arguments": 4,
|
|
699
|
+
"lengthOfByteString-cpu-arguments": 1e3,
|
|
700
|
+
"lengthOfByteString-memory-arguments": 10,
|
|
701
|
+
"lessThanByteString-cpu-arguments-intercept": 197145,
|
|
702
|
+
"lessThanByteString-cpu-arguments-slope": 156,
|
|
703
|
+
"lessThanByteString-memory-arguments": 1,
|
|
704
|
+
"lessThanEqualsByteString-cpu-arguments-intercept": 197145,
|
|
705
|
+
"lessThanEqualsByteString-cpu-arguments-slope": 156,
|
|
706
|
+
"lessThanEqualsByteString-memory-arguments": 1,
|
|
707
|
+
"lessThanEqualsInteger-cpu-arguments-intercept": 204924,
|
|
708
|
+
"lessThanEqualsInteger-cpu-arguments-slope": 473,
|
|
709
|
+
"lessThanEqualsInteger-memory-arguments": 1,
|
|
710
|
+
"lessThanInteger-cpu-arguments-intercept": 208896,
|
|
711
|
+
"lessThanInteger-cpu-arguments-slope": 511,
|
|
712
|
+
"lessThanInteger-memory-arguments": 1,
|
|
713
|
+
"listData-cpu-arguments": 52467,
|
|
714
|
+
"listData-memory-arguments": 32,
|
|
715
|
+
"mapData-cpu-arguments": 64832,
|
|
716
|
+
"mapData-memory-arguments": 32,
|
|
717
|
+
"mkCons-cpu-arguments": 65493,
|
|
718
|
+
"mkCons-memory-arguments": 32,
|
|
719
|
+
"mkNilData-cpu-arguments": 22558,
|
|
720
|
+
"mkNilData-memory-arguments": 32,
|
|
721
|
+
"mkNilPairData-cpu-arguments": 16563,
|
|
722
|
+
"mkNilPairData-memory-arguments": 32,
|
|
723
|
+
"mkPairData-cpu-arguments": 76511,
|
|
724
|
+
"mkPairData-memory-arguments": 32,
|
|
725
|
+
"modInteger-cpu-arguments-constant": 196500,
|
|
726
|
+
"modInteger-cpu-arguments-model-arguments-intercept": 453240,
|
|
727
|
+
"modInteger-cpu-arguments-model-arguments-slope": 220,
|
|
728
|
+
"modInteger-memory-arguments-intercept": 0,
|
|
729
|
+
"modInteger-memory-arguments-minimum": 1,
|
|
730
|
+
"modInteger-memory-arguments-slope": 1,
|
|
731
|
+
"multiplyInteger-cpu-arguments-intercept": 69522,
|
|
732
|
+
"multiplyInteger-cpu-arguments-slope": 11687,
|
|
733
|
+
"multiplyInteger-memory-arguments-intercept": 0,
|
|
734
|
+
"multiplyInteger-memory-arguments-slope": 1,
|
|
735
|
+
"nullList-cpu-arguments": 60091,
|
|
736
|
+
"nullList-memory-arguments": 32,
|
|
737
|
+
"quotientInteger-cpu-arguments-constant": 196500,
|
|
738
|
+
"quotientInteger-cpu-arguments-model-arguments-intercept": 453240,
|
|
739
|
+
"quotientInteger-cpu-arguments-model-arguments-slope": 220,
|
|
740
|
+
"quotientInteger-memory-arguments-intercept": 0,
|
|
741
|
+
"quotientInteger-memory-arguments-minimum": 1,
|
|
742
|
+
"quotientInteger-memory-arguments-slope": 1,
|
|
743
|
+
"remainderInteger-cpu-arguments-constant": 196500,
|
|
744
|
+
"remainderInteger-cpu-arguments-model-arguments-intercept": 453240,
|
|
745
|
+
"remainderInteger-cpu-arguments-model-arguments-slope": 220,
|
|
746
|
+
"remainderInteger-memory-arguments-intercept": 0,
|
|
747
|
+
"remainderInteger-memory-arguments-minimum": 1,
|
|
748
|
+
"remainderInteger-memory-arguments-slope": 1,
|
|
749
|
+
"serialiseData-cpu-arguments-intercept": 1159724,
|
|
750
|
+
"serialiseData-cpu-arguments-slope": 392670,
|
|
751
|
+
"serialiseData-memory-arguments-intercept": 0,
|
|
752
|
+
"serialiseData-memory-arguments-slope": 2,
|
|
753
|
+
"sha2_256-cpu-arguments-intercept": 806990,
|
|
754
|
+
"sha2_256-cpu-arguments-slope": 30482,
|
|
755
|
+
"sha2_256-memory-arguments": 4,
|
|
756
|
+
"sha3_256-cpu-arguments-intercept": 1927926,
|
|
757
|
+
"sha3_256-cpu-arguments-slope": 82523,
|
|
758
|
+
"sha3_256-memory-arguments": 4,
|
|
759
|
+
"sliceByteString-cpu-arguments-intercept": 265318,
|
|
760
|
+
"sliceByteString-cpu-arguments-slope": 0,
|
|
761
|
+
"sliceByteString-memory-arguments-intercept": 4,
|
|
762
|
+
"sliceByteString-memory-arguments-slope": 0,
|
|
763
|
+
"sndPair-cpu-arguments": 85931,
|
|
764
|
+
"sndPair-memory-arguments": 32,
|
|
765
|
+
"subtractInteger-cpu-arguments-intercept": 205665,
|
|
766
|
+
"subtractInteger-cpu-arguments-slope": 812,
|
|
767
|
+
"subtractInteger-memory-arguments-intercept": 1,
|
|
768
|
+
"subtractInteger-memory-arguments-slope": 1,
|
|
769
|
+
"tailList-cpu-arguments": 41182,
|
|
770
|
+
"tailList-memory-arguments": 32,
|
|
771
|
+
"trace-cpu-arguments": 212342,
|
|
772
|
+
"trace-memory-arguments": 32,
|
|
773
|
+
"unBData-cpu-arguments": 31220,
|
|
774
|
+
"unBData-memory-arguments": 32,
|
|
775
|
+
"unConstrData-cpu-arguments": 32696,
|
|
776
|
+
"unConstrData-memory-arguments": 32,
|
|
777
|
+
"unIData-cpu-arguments": 43357,
|
|
778
|
+
"unIData-memory-arguments": 32,
|
|
779
|
+
"unListData-cpu-arguments": 32247,
|
|
780
|
+
"unListData-memory-arguments": 32,
|
|
781
|
+
"unMapData-cpu-arguments": 38314,
|
|
782
|
+
"unMapData-memory-arguments": 32,
|
|
783
|
+
"verifyEcdsaSecp256k1Signature-cpu-arguments": 35892428,
|
|
784
|
+
"verifyEcdsaSecp256k1Signature-memory-arguments": 10,
|
|
785
|
+
"verifyEd25519Signature-cpu-arguments-intercept": 57996947,
|
|
786
|
+
"verifyEd25519Signature-cpu-arguments-slope": 18975,
|
|
787
|
+
"verifyEd25519Signature-memory-arguments": 10,
|
|
788
|
+
"verifySchnorrSecp256k1Signature-cpu-arguments-intercept": 38887044,
|
|
789
|
+
"verifySchnorrSecp256k1Signature-cpu-arguments-slope": 32947,
|
|
790
|
+
"verifySchnorrSecp256k1Signature-memory-arguments": 10
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
// src/credential.ts
|
|
796
|
+
var CML5 = __toESM(require("@dcspark/cardano-multiplatform-lib-nodejs"), 1);
|
|
797
|
+
function credentialToAddress(network, paymentCredential, stakeCredential) {
|
|
798
|
+
if (stakeCredential) {
|
|
799
|
+
return CML5.BaseAddress.new(
|
|
800
|
+
networkToId(network),
|
|
801
|
+
paymentCredential.type === "Key" ? CML5.Credential.new_pub_key(
|
|
802
|
+
CML5.Ed25519KeyHash.from_hex(paymentCredential.hash)
|
|
803
|
+
) : CML5.Credential.new_script(
|
|
804
|
+
CML5.ScriptHash.from_hex(paymentCredential.hash)
|
|
805
|
+
),
|
|
806
|
+
stakeCredential.type === "Key" ? CML5.Credential.new_pub_key(
|
|
807
|
+
CML5.Ed25519KeyHash.from_hex(stakeCredential.hash)
|
|
808
|
+
) : CML5.Credential.new_script(
|
|
809
|
+
CML5.ScriptHash.from_hex(stakeCredential.hash)
|
|
810
|
+
)
|
|
811
|
+
).to_address().to_bech32(void 0);
|
|
812
|
+
} else {
|
|
813
|
+
return CML5.EnterpriseAddress.new(
|
|
814
|
+
networkToId(network),
|
|
815
|
+
paymentCredential.type === "Key" ? CML5.Credential.new_pub_key(
|
|
816
|
+
CML5.Ed25519KeyHash.from_hex(paymentCredential.hash)
|
|
817
|
+
) : CML5.Credential.new_script(
|
|
818
|
+
CML5.ScriptHash.from_hex(paymentCredential.hash)
|
|
819
|
+
)
|
|
820
|
+
).to_address().to_bech32(void 0);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
function scriptHashToCredential(scriptHash) {
|
|
824
|
+
return {
|
|
825
|
+
type: "Script",
|
|
826
|
+
hash: scriptHash
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
function keyHashToCredential(keyHash) {
|
|
830
|
+
return {
|
|
831
|
+
type: "Key",
|
|
832
|
+
hash: keyHash
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
function paymentCredentialOf(address) {
|
|
836
|
+
const { paymentCredential } = getAddressDetails(address);
|
|
837
|
+
if (!paymentCredential) {
|
|
838
|
+
throw new Error(
|
|
839
|
+
"The specified address does not contain a payment credential."
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
return paymentCredential;
|
|
843
|
+
}
|
|
844
|
+
function stakeCredentialOf(rewardAddress) {
|
|
845
|
+
const { stakeCredential } = getAddressDetails(rewardAddress);
|
|
846
|
+
if (!stakeCredential) {
|
|
847
|
+
throw new Error(
|
|
848
|
+
"The specified address does not contain a stake credential."
|
|
849
|
+
);
|
|
850
|
+
}
|
|
851
|
+
return stakeCredential;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
// src/datum.ts
|
|
855
|
+
var CML6 = __toESM(require("@dcspark/cardano-multiplatform-lib-nodejs"), 1);
|
|
856
|
+
function datumToHash(datum) {
|
|
857
|
+
return CML6.hash_plutus_data(CML6.PlutusData.from_cbor_hex(datum)).to_hex();
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
// src/keys.ts
|
|
861
|
+
var import_bip39 = require("@lucid-evolution/bip39");
|
|
862
|
+
var CML7 = __toESM(require("@dcspark/cardano-multiplatform-lib-nodejs"), 1);
|
|
863
|
+
function generatePrivateKey() {
|
|
864
|
+
return CML7.PrivateKey.generate_ed25519().to_bech32();
|
|
865
|
+
}
|
|
866
|
+
function generateSeedPhrase() {
|
|
867
|
+
return (0, import_bip39.generateMnemonic)(256);
|
|
868
|
+
}
|
|
869
|
+
function toPublicKey(privateKey) {
|
|
870
|
+
return CML7.PrivateKey.from_bech32(privateKey).to_public().to_bech32();
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
// src/label.ts
|
|
874
|
+
var import_core_utils = require("@lucid-evolution/core-utils");
|
|
875
|
+
var import_crc8 = require("@lucid-evolution/crc8");
|
|
876
|
+
function toLabel(num) {
|
|
877
|
+
if (num < 0 || num > 65535) {
|
|
878
|
+
throw new Error(
|
|
879
|
+
`Label ${num} out of range: min label 1 - max label 65535.`
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
const numHex = num.toString(16).padStart(4, "0");
|
|
883
|
+
return "0" + numHex + checksum(numHex) + "0";
|
|
884
|
+
}
|
|
885
|
+
function fromLabel(label) {
|
|
886
|
+
if (label.length !== 8 || !(label[0] === "0" && label[7] === "0")) {
|
|
887
|
+
return null;
|
|
888
|
+
}
|
|
889
|
+
const numHex = label.slice(1, 5);
|
|
890
|
+
const num = parseInt(numHex, 16);
|
|
891
|
+
const check = label.slice(5, 7);
|
|
892
|
+
return check === checksum(numHex) ? num : null;
|
|
893
|
+
}
|
|
894
|
+
function checksum(num) {
|
|
895
|
+
return (0, import_crc8.crc8)((0, import_core_utils.fromHex)(num)).toString(16).padStart(2, "0");
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// src/time.ts
|
|
899
|
+
var import_plutus = require("@lucid-evolution/plutus");
|
|
900
|
+
function unixTimeToSlot(network, unixTime) {
|
|
901
|
+
return (0, import_plutus.unixTimeToEnclosingSlot)(unixTime, import_plutus.SLOT_CONFIG_NETWORK[network]);
|
|
902
|
+
}
|
|
903
|
+
function slotToUnixTime(network, slot) {
|
|
904
|
+
return (0, import_plutus.slotToBeginUnixTime)(slot, import_plutus.SLOT_CONFIG_NETWORK[network]);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// src/utxo.ts
|
|
908
|
+
var CML9 = __toESM(require("@dcspark/cardano-multiplatform-lib-nodejs"), 1);
|
|
909
|
+
|
|
910
|
+
// src/value.ts
|
|
911
|
+
var import_core_utils2 = require("@lucid-evolution/core-utils");
|
|
912
|
+
var CML8 = __toESM(require("@dcspark/cardano-multiplatform-lib-nodejs"), 1);
|
|
913
|
+
function valueToAssets(value) {
|
|
914
|
+
const assets = {};
|
|
915
|
+
assets["lovelace"] = value.coin();
|
|
916
|
+
const ma = value.multi_asset();
|
|
917
|
+
if (ma) {
|
|
918
|
+
const multiAssets = ma.keys();
|
|
919
|
+
for (let j = 0; j < multiAssets.len(); j++) {
|
|
920
|
+
const policy = multiAssets.get(j);
|
|
921
|
+
const policyAssets = ma.get_assets(policy);
|
|
922
|
+
const assetNames = policyAssets.keys();
|
|
923
|
+
for (let k = 0; k < assetNames.len(); k++) {
|
|
924
|
+
const policyAsset = assetNames.get(k);
|
|
925
|
+
const quantity = policyAssets.get(policyAsset);
|
|
926
|
+
const unit = policy.to_hex() + policyAsset.to_cbor_hex();
|
|
927
|
+
assets[unit] = quantity;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
return assets;
|
|
932
|
+
}
|
|
933
|
+
function assetsToValue(assets) {
|
|
934
|
+
const multiAsset = CML8.MultiAsset.new();
|
|
935
|
+
const lovelace = assets["lovelace"];
|
|
936
|
+
const units = Object.keys(assets);
|
|
937
|
+
const policies = Array.from(
|
|
938
|
+
new Set(
|
|
939
|
+
units.filter((unit) => unit !== "lovelace").map((unit) => unit.slice(0, 56))
|
|
940
|
+
)
|
|
941
|
+
);
|
|
942
|
+
policies.forEach((policy) => {
|
|
943
|
+
const policyUnits = units.filter((unit) => unit.slice(0, 56) === policy);
|
|
944
|
+
const assetsValue = CML8.MapAssetNameToCoin.new();
|
|
945
|
+
policyUnits.forEach((unit) => {
|
|
946
|
+
assetsValue.insert(
|
|
947
|
+
CML8.AssetName.from_str((0, import_core_utils2.toText)(unit.slice(56))),
|
|
948
|
+
BigInt(assets[unit])
|
|
949
|
+
);
|
|
950
|
+
});
|
|
951
|
+
multiAsset.insert_assets(CML8.ScriptHash.from_hex(policy), assetsValue);
|
|
952
|
+
});
|
|
953
|
+
return CML8.Value.new(lovelace, multiAsset);
|
|
954
|
+
}
|
|
955
|
+
function fromUnit(unit) {
|
|
956
|
+
const policyId = unit.slice(0, 56);
|
|
957
|
+
const assetName = unit.slice(56) || null;
|
|
958
|
+
const label = fromLabel(unit.slice(56, 64));
|
|
959
|
+
const name = (() => {
|
|
960
|
+
const hexName = Number.isInteger(label) ? unit.slice(64) : unit.slice(56);
|
|
961
|
+
return hexName || null;
|
|
962
|
+
})();
|
|
963
|
+
return { policyId, assetName, name, label };
|
|
964
|
+
}
|
|
965
|
+
function toUnit(policyId, name, label) {
|
|
966
|
+
const hexLabel = Number.isInteger(label) ? toLabel(label) : "";
|
|
967
|
+
const n = name ? name : "";
|
|
968
|
+
if ((n + hexLabel).length > 64) {
|
|
969
|
+
throw new Error("Asset name size exceeds 32 bytes.");
|
|
970
|
+
}
|
|
971
|
+
if (policyId.length !== 56) {
|
|
972
|
+
throw new Error(`Policy id invalid: ${policyId}.`);
|
|
973
|
+
}
|
|
974
|
+
return policyId + hexLabel + n;
|
|
975
|
+
}
|
|
976
|
+
function addAssets(...assets) {
|
|
977
|
+
return assets.reduce((a, b) => {
|
|
978
|
+
for (const k in b) {
|
|
979
|
+
if (Object.hasOwn(b, k)) {
|
|
980
|
+
a[k] = (a[k] || 0n) + b[k];
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
return a;
|
|
984
|
+
}, {});
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
// src/utxo.ts
|
|
988
|
+
var utxoToTransactionOutput = (utxo) => {
|
|
989
|
+
const address = (() => {
|
|
990
|
+
try {
|
|
991
|
+
return CML9.Address.from_bech32(utxo.address);
|
|
992
|
+
} catch (_e) {
|
|
993
|
+
return CML9.ByronAddress.from_base58(utxo.address).to_address();
|
|
994
|
+
}
|
|
995
|
+
})();
|
|
996
|
+
const datumOption = (() => {
|
|
997
|
+
if (utxo.datumHash) {
|
|
998
|
+
return CML9.DatumOption.new_hash(CML9.DatumHash.from_hex(utxo.datumHash));
|
|
999
|
+
}
|
|
1000
|
+
if (!utxo.datumHash && utxo.datum) {
|
|
1001
|
+
return CML9.DatumOption.new_datum(
|
|
1002
|
+
CML9.PlutusData.from_cbor_hex(utxo.datum)
|
|
1003
|
+
);
|
|
1004
|
+
}
|
|
1005
|
+
})();
|
|
1006
|
+
const scriptRef = (() => {
|
|
1007
|
+
if (utxo.scriptRef) {
|
|
1008
|
+
return toScriptRef(utxo.scriptRef);
|
|
1009
|
+
}
|
|
1010
|
+
})();
|
|
1011
|
+
return CML9.TransactionOutput.new(
|
|
1012
|
+
address,
|
|
1013
|
+
assetsToValue(utxo.assets),
|
|
1014
|
+
datumOption,
|
|
1015
|
+
scriptRef
|
|
1016
|
+
);
|
|
1017
|
+
};
|
|
1018
|
+
var utxoToTransactionInput = (utxo) => {
|
|
1019
|
+
return CML9.TransactionInput.new(
|
|
1020
|
+
CML9.TransactionHash.from_hex(utxo.txHash),
|
|
1021
|
+
BigInt(utxo.outputIndex)
|
|
1022
|
+
);
|
|
1023
|
+
};
|
|
1024
|
+
function utxoToCore(utxo) {
|
|
1025
|
+
const address = (() => {
|
|
1026
|
+
try {
|
|
1027
|
+
return CML9.Address.from_bech32(utxo.address);
|
|
1028
|
+
} catch (_e) {
|
|
1029
|
+
return CML9.ByronAddress.from_base58(utxo.address).to_address();
|
|
1030
|
+
}
|
|
1031
|
+
})();
|
|
1032
|
+
const datumOption = (() => {
|
|
1033
|
+
if (utxo.datumHash) {
|
|
1034
|
+
return CML9.DatumOption.new_hash(CML9.DatumHash.from_hex(utxo.datumHash));
|
|
1035
|
+
}
|
|
1036
|
+
if (!utxo.datumHash && utxo.datum) {
|
|
1037
|
+
return CML9.DatumOption.new_datum(
|
|
1038
|
+
CML9.PlutusData.from_cbor_hex(utxo.datum)
|
|
1039
|
+
);
|
|
1040
|
+
}
|
|
1041
|
+
})();
|
|
1042
|
+
const scriptRef = (() => {
|
|
1043
|
+
if (utxo.scriptRef) {
|
|
1044
|
+
return toScriptRef(utxo.scriptRef);
|
|
1045
|
+
}
|
|
1046
|
+
})();
|
|
1047
|
+
const output = CML9.TransactionOutput.new(
|
|
1048
|
+
address,
|
|
1049
|
+
assetsToValue(utxo.assets),
|
|
1050
|
+
datumOption,
|
|
1051
|
+
scriptRef
|
|
1052
|
+
);
|
|
1053
|
+
return CML9.TransactionUnspentOutput.new(
|
|
1054
|
+
CML9.TransactionInput.new(
|
|
1055
|
+
CML9.TransactionHash.from_hex(utxo.txHash),
|
|
1056
|
+
BigInt(utxo.outputIndex)
|
|
1057
|
+
),
|
|
1058
|
+
output
|
|
1059
|
+
);
|
|
1060
|
+
}
|
|
1061
|
+
function utxosToCores(utxos) {
|
|
1062
|
+
const result = [];
|
|
1063
|
+
utxos.map(utxoToCore).forEach((utxo) => result.push(utxo));
|
|
1064
|
+
return result;
|
|
1065
|
+
}
|
|
1066
|
+
function coreToUtxo(coreUtxo) {
|
|
1067
|
+
return {
|
|
1068
|
+
...coreToOutRef(CML9.TransactionInput.from_cbor_hex(coreUtxo.to_cbor_hex())),
|
|
1069
|
+
...coreToTxOutput(
|
|
1070
|
+
CML9.TransactionOutput.from_cbor_hex(coreUtxo.to_cbor_hex())
|
|
1071
|
+
)
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
function coresToUtxos(utxos) {
|
|
1075
|
+
const result = [];
|
|
1076
|
+
for (let i = 0; i < utxos.length; i++) {
|
|
1077
|
+
result.push(coreToUtxo(utxos[i]));
|
|
1078
|
+
}
|
|
1079
|
+
return result;
|
|
1080
|
+
}
|
|
1081
|
+
function coreToOutRef(input) {
|
|
1082
|
+
return {
|
|
1083
|
+
txHash: input.transaction_id().to_hex(),
|
|
1084
|
+
outputIndex: parseInt(input.index().toString())
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
function coresToOutRefs(inputs) {
|
|
1088
|
+
const result = [];
|
|
1089
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
1090
|
+
result.push(coreToOutRef(inputs[i]));
|
|
1091
|
+
}
|
|
1092
|
+
return result;
|
|
1093
|
+
}
|
|
1094
|
+
function coreToTxOutput(output) {
|
|
1095
|
+
return {
|
|
1096
|
+
assets: valueToAssets(output.amount()),
|
|
1097
|
+
address: output.address().to_bech32(void 0),
|
|
1098
|
+
datumHash: output.datum()?.as_hash()?.to_hex(),
|
|
1099
|
+
datum: output.datum()?.as_datum()?.to_cbor_hex(),
|
|
1100
|
+
scriptRef: output.script_ref() && fromScriptRef(output.script_ref())
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
function coresToTxOutputs(outputs) {
|
|
1104
|
+
const result = [];
|
|
1105
|
+
for (let i = 0; i < outputs.length; i++) {
|
|
1106
|
+
result.push(coreToTxOutput(outputs[i]));
|
|
1107
|
+
}
|
|
1108
|
+
return result;
|
|
1109
|
+
}
|
|
1110
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1111
|
+
0 && (module.exports = {
|
|
1112
|
+
PROTOCOL_PARAMETERS_DEFAULT,
|
|
1113
|
+
addAssets,
|
|
1114
|
+
addressFromHexOrBech32,
|
|
1115
|
+
applyDoubleCborEncoding,
|
|
1116
|
+
assetsToValue,
|
|
1117
|
+
coreToOutRef,
|
|
1118
|
+
coreToTxOutput,
|
|
1119
|
+
coreToUtxo,
|
|
1120
|
+
coresToOutRefs,
|
|
1121
|
+
coresToTxOutputs,
|
|
1122
|
+
coresToUtxos,
|
|
1123
|
+
createCostModels,
|
|
1124
|
+
credentialToAddress,
|
|
1125
|
+
credentialToRewardAddress,
|
|
1126
|
+
datumToHash,
|
|
1127
|
+
fromLabel,
|
|
1128
|
+
fromScriptRef,
|
|
1129
|
+
fromUnit,
|
|
1130
|
+
generatePrivateKey,
|
|
1131
|
+
generateSeedPhrase,
|
|
1132
|
+
getAddressDetails,
|
|
1133
|
+
keyHashToCredential,
|
|
1134
|
+
mintingPolicyToId,
|
|
1135
|
+
nativeFromJson,
|
|
1136
|
+
nativeJSFromJson,
|
|
1137
|
+
nativeScriptFromJson,
|
|
1138
|
+
networkToId,
|
|
1139
|
+
paymentCredentialOf,
|
|
1140
|
+
scriptHashToCredential,
|
|
1141
|
+
slotToUnixTime,
|
|
1142
|
+
stakeCredentialOf,
|
|
1143
|
+
toLabel,
|
|
1144
|
+
toNativeScript,
|
|
1145
|
+
toPublicKey,
|
|
1146
|
+
toScriptRef,
|
|
1147
|
+
toUnit,
|
|
1148
|
+
unixTimeToSlot,
|
|
1149
|
+
utxoToCore,
|
|
1150
|
+
utxoToTransactionInput,
|
|
1151
|
+
utxoToTransactionOutput,
|
|
1152
|
+
utxosToCores,
|
|
1153
|
+
validatorToAddress,
|
|
1154
|
+
validatorToRewardAddress,
|
|
1155
|
+
validatorToScriptHash,
|
|
1156
|
+
valueToAssets
|
|
1157
|
+
});
|