@meshsdk/core 1.5.11-beta.3 → 1.5.11-beta.5
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/core/CPS-009.d.ts +2 -0
- package/dist/core.cjs +1 -1
- package/dist/core.js +964 -820
- package/dist/transaction/meshTxBuilder/meshTxBuilder.service.d.ts +3 -0
- package/dist/transaction/meshTxBuilder/meshTxBuilderCore.d.ts +30 -21
- package/dist/transaction/meshTxBuilder/type.d.ts +8 -3
- package/package.json +3 -3
package/dist/core.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { customAlphabet as Ce } from "nanoid";
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
2
|
+
import * as i from "@emurgo/cardano-serialization-lib-nodejs";
|
|
3
|
+
import G from "axios";
|
|
4
4
|
import { mnemonicToEntropy as we, generateMnemonic as ze } from "bip39";
|
|
5
|
-
import { COSEKey as Be, COSESign1 as
|
|
5
|
+
import { COSEKey as Be, COSESign1 as Je, Label as X, Int as wt, BigNum as Kt, KeyType as We, AlgorithmId as Se, CBORValue as Mt, HeaderMap as Xt, Headers as je, ProtectedHeaderMap as Xe, COSESign1Builder as Ze } from "@emurgo/cardano-message-signing-nodejs";
|
|
6
6
|
const ts = ["testnet", "preview", "preprod", "mainnet"], es = (r) => ts.includes(r), at = {
|
|
7
7
|
mem: 7e6,
|
|
8
8
|
steps: 3e9
|
|
9
|
-
},
|
|
9
|
+
}, k = {
|
|
10
10
|
epoch: 0,
|
|
11
11
|
coinsPerUTxOSize: "4310",
|
|
12
12
|
priceMem: 0.0577,
|
|
@@ -28,22 +28,22 @@ const ts = ["testnet", "preview", "preprod", "mainnet"], es = (r) => ts.includes
|
|
|
28
28
|
maxBlockExMem: "80000000",
|
|
29
29
|
maxBlockExSteps: "40000000000"
|
|
30
30
|
}, Pt = 2147483648, R = {
|
|
31
|
-
V1:
|
|
32
|
-
V2:
|
|
33
|
-
},
|
|
34
|
-
CERT:
|
|
35
|
-
MINT:
|
|
36
|
-
REWARD:
|
|
37
|
-
SPEND:
|
|
38
|
-
},
|
|
31
|
+
V1: i.Language.new_plutus_v1(),
|
|
32
|
+
V2: i.Language.new_plutus_v2()
|
|
33
|
+
}, O = 56, ss = {
|
|
34
|
+
CERT: i.RedeemerTag.new_cert(),
|
|
35
|
+
MINT: i.RedeemerTag.new_mint(),
|
|
36
|
+
REWARD: i.RedeemerTag.new_reward(),
|
|
37
|
+
SPEND: i.RedeemerTag.new_spend()
|
|
38
|
+
}, bt = {
|
|
39
39
|
testnet: ["74", "1598400", "1595967616", "432000"],
|
|
40
40
|
preview: ["183", "15811222", "1682467200", "86400"],
|
|
41
41
|
preprod: ["65", "26438400", "1682121600", "432000"],
|
|
42
42
|
mainnet: ["208", "4492800", "1596059091", "432000"]
|
|
43
43
|
}, Zt = {
|
|
44
|
-
ALONZO:
|
|
44
|
+
ALONZO: i.TxBuilderConstants.plutus_alonzo_cost_models(),
|
|
45
45
|
BABBAGE: (() => {
|
|
46
|
-
const r =
|
|
46
|
+
const r = i.Costmdls.new(), e = i.CostModel.new();
|
|
47
47
|
Object.values({
|
|
48
48
|
"addInteger-cpu-arguments-intercept": 205665,
|
|
49
49
|
"addInteger-cpu-arguments-slope": 812,
|
|
@@ -211,8 +211,8 @@ const ts = ["testnet", "preview", "preprod", "mainnet"], es = (r) => ts.includes
|
|
|
211
211
|
"verifyEd25519Signature-cpu-arguments-intercept": 57996947,
|
|
212
212
|
"verifyEd25519Signature-cpu-arguments-slope": 18975,
|
|
213
213
|
"verifyEd25519Signature-memory-arguments": 10
|
|
214
|
-
}).forEach((s, n) => e.set(n,
|
|
215
|
-
const t =
|
|
214
|
+
}).forEach((s, n) => e.set(n, i.Int.new_i32(s)));
|
|
215
|
+
const t = i.CostModel.new();
|
|
216
216
|
return Object.values({
|
|
217
217
|
"addInteger-cpu-arguments-intercept": 205665,
|
|
218
218
|
"addInteger-cpu-arguments-slope": 812,
|
|
@@ -389,7 +389,7 @@ const ts = ["testnet", "preview", "preprod", "mainnet"], es = (r) => ts.includes
|
|
|
389
389
|
"verifySchnorrSecp256k1Signature-cpu-arguments-intercept": 38887044,
|
|
390
390
|
"verifySchnorrSecp256k1Signature-cpu-arguments-slope": 32947,
|
|
391
391
|
"verifySchnorrSecp256k1Signature-memory-arguments": 10
|
|
392
|
-
}).forEach((s, n) => t.set(n,
|
|
392
|
+
}).forEach((s, n) => t.set(n, i.Int.new_i32(s))), r.insert(i.Language.new_plutus_v1(), e), r.insert(i.Language.new_plutus_v2(), t), r;
|
|
393
393
|
})()
|
|
394
394
|
}, rs = {
|
|
395
395
|
ALONZO: {
|
|
@@ -400,8 +400,8 @@ const ts = ["testnet", "preview", "preprod", "mainnet"], es = (r) => ts.includes
|
|
|
400
400
|
V2: "a20198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c80041005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff"
|
|
401
401
|
}
|
|
402
402
|
}, Vt = {
|
|
403
|
-
[
|
|
404
|
-
[
|
|
403
|
+
[i.NetworkInfo.testnet().network_id()]: "8d18d786e92776c824607fd8e193ec535c79dc61ea2405ddf3b09fe3",
|
|
404
|
+
[i.NetworkInfo.mainnet().network_id()]: "f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a"
|
|
405
405
|
}, ns = {
|
|
406
406
|
mainnet: "wss://ogmios-api.mainnet.dandelion.link",
|
|
407
407
|
preprod: "wss://ogmios-api.iohk-preprod.dandelion.link",
|
|
@@ -448,123 +448,123 @@ const ts = ["testnet", "preview", "preprod", "mainnet"], es = (r) => ts.includes
|
|
|
448
448
|
"vespr",
|
|
449
449
|
"yoroi"
|
|
450
450
|
], is = (r, e, t = "5000000") => {
|
|
451
|
-
const s =
|
|
451
|
+
const s = i.BigNum.from_str(r.get("lovelace") ?? "0").checked_add(i.BigNum.from_str(t)), n = e.filter((c) => c.output.amount.filter((u) => u.unit !== "lovelace").some((u) => r.has(u.unit))), a = ds(n);
|
|
452
452
|
return [
|
|
453
|
-
...
|
|
453
|
+
...a.less_than(s) ? hs(s.clamped_sub(a).to_str(), e.filter((c) => !n.some((u) => u.input.txHash === c.input.txHash && u.input.outputIndex === c.input.outputIndex))) : [],
|
|
454
454
|
...n
|
|
455
455
|
];
|
|
456
|
-
},
|
|
457
|
-
const o = e.filter((
|
|
456
|
+
}, ur = (r, e, t = !1, { maxTxSize: s, minFeeA: n, minFeeB: a } = k) => {
|
|
457
|
+
const o = e.filter((g) => Ee(g) === !1).sort(qt), c = i.BigNum.from_str(Le(s, n, a)), u = t ? i.BigNum.from_str(r).checked_add(c).to_str() : r;
|
|
458
458
|
return It(o, /* @__PURE__ */ new Map([
|
|
459
459
|
["lovelace", u]
|
|
460
460
|
]));
|
|
461
|
-
}, os = (r, e, t = !1, s =
|
|
462
|
-
const n = e.filter(Ee).sort(
|
|
461
|
+
}, os = (r, e, t = !1, s = k) => {
|
|
462
|
+
const n = e.filter(Ee).sort(qt), a = us(s), o = r.get("lovelace") ?? "0", c = t ? i.BigNum.from_str(o).checked_add(a).to_str() : o;
|
|
463
463
|
return r.set("lovelace", c), It(n, r);
|
|
464
|
-
}, cs = (r, e) => Array.from(e, (t) => ({ unit: t[0], quantity:
|
|
465
|
-
const
|
|
466
|
-
return s.checked_add(
|
|
467
|
-
},
|
|
468
|
-
var n,
|
|
469
|
-
const t =
|
|
470
|
-
return
|
|
464
|
+
}, cs = (r, e) => Array.from(e, (t) => ({ unit: t[0], quantity: i.BigNum.from_str(t[1]) })).every((t) => r.filter((s) => s.output.amount.find((n) => n.unit === t.unit) !== void 0).reduce((s, n) => {
|
|
465
|
+
const a = n.output.amount.reduce((o, c) => o.checked_add(i.BigNum.from_str(t.unit === c.unit ? c.quantity : "0")), i.BigNum.from_str("0"));
|
|
466
|
+
return s.checked_add(a);
|
|
467
|
+
}, i.BigNum.from_str("0")).less_than(t.quantity) === !1), qt = (r, e) => {
|
|
468
|
+
var n, a;
|
|
469
|
+
const t = i.BigNum.from_str(((n = r.output.amount.find((o) => o.unit === "lovelace")) == null ? void 0 : n.quantity) ?? "0");
|
|
470
|
+
return i.BigNum.from_str(((a = e.output.amount.find((o) => o.unit === "lovelace")) == null ? void 0 : a.quantity) ?? "0").compare(t);
|
|
471
471
|
}, us = (r) => {
|
|
472
472
|
const { maxTxSize: e, minFeeA: t, minFeeB: s } = r;
|
|
473
|
-
return
|
|
473
|
+
return i.BigNum.from_str(Le(e, t, s));
|
|
474
474
|
}, Ee = (r) => r.output.amount.length > 1, ds = (r) => r.reduce((e, t) => {
|
|
475
475
|
var n;
|
|
476
|
-
const s = ((n = t.output.amount.find((
|
|
477
|
-
return e.checked_add(
|
|
478
|
-
},
|
|
479
|
-
const t = e.sort(
|
|
476
|
+
const s = ((n = t.output.amount.find((a) => a.unit === "lovelace")) == null ? void 0 : n.quantity) ?? "0";
|
|
477
|
+
return e.checked_add(i.BigNum.from_str(s));
|
|
478
|
+
}, i.BigNum.from_str("0")), hs = (r, e) => {
|
|
479
|
+
const t = e.sort(qt);
|
|
480
480
|
return It(t, /* @__PURE__ */ new Map([
|
|
481
481
|
["lovelace", r]
|
|
482
482
|
]));
|
|
483
|
-
}, It = (r, e, t = []) => r.length === 0 || cs(t, e) ? t : ls(r[0], e) ? It(r.slice(1), e, [...t, r[0]]) : It(r.slice(1), e, t), ls = (r, e) => Array.from(e.keys()).some((t) => r.output.amount.find((s) => s.unit === t) !== void 0),
|
|
483
|
+
}, It = (r, e, t = []) => r.length === 0 || cs(t, e) ? t : ls(r[0], e) ? It(r.slice(1), e, [...t, r[0]]) : It(r.slice(1), e, t), ls = (r, e) => Array.from(e.keys()).some((t) => r.output.amount.find((s) => s.unit === t) !== void 0), gs = (r, e) => {
|
|
484
484
|
const t = ms(e), s = Is(r, e);
|
|
485
485
|
return {
|
|
486
|
-
coseKey:
|
|
487
|
-
coseSign1:
|
|
486
|
+
coseKey: D(t.to_bytes()),
|
|
487
|
+
coseSign1: D(s.to_bytes())
|
|
488
488
|
};
|
|
489
|
-
},
|
|
489
|
+
}, dr = (r, e, { key: t, signature: s }) => {
|
|
490
490
|
var o, c;
|
|
491
|
-
const n = Be.from_bytes(
|
|
491
|
+
const n = Be.from_bytes(_(t)), a = Je.from_bytes(_(s));
|
|
492
492
|
if ((r == null ? void 0 : r.length) > 0) {
|
|
493
|
-
const u =
|
|
494
|
-
if (
|
|
493
|
+
const u = D(a.payload() ?? new Uint8Array());
|
|
494
|
+
if (Q(r) !== u)
|
|
495
495
|
return !1;
|
|
496
496
|
}
|
|
497
497
|
if ((e == null ? void 0 : e.length) > 0) {
|
|
498
|
-
const d = (o =
|
|
498
|
+
const d = (o = a.headers().protected().deserialized_headers().header(X.new_text("address"))) == null ? void 0 : o.as_bytes();
|
|
499
499
|
if (d === void 0)
|
|
500
500
|
throw new Error("Couldn't find a signer address in signature");
|
|
501
|
-
const
|
|
502
|
-
if (
|
|
501
|
+
const l = (c = n.header(X.new_int(wt.new_negative(Kt.from_str("2"))))) == null ? void 0 : c.as_bytes();
|
|
502
|
+
if (l === void 0)
|
|
503
503
|
throw new Error("Couldn't find a signer key in signature");
|
|
504
|
-
const
|
|
505
|
-
if (
|
|
504
|
+
const g = nt(D(d)), A = qs(D(l));
|
|
505
|
+
if (As(e, g, A) === !1)
|
|
506
506
|
throw new Error("Couldn't check signature because of address mismatch");
|
|
507
|
-
const
|
|
508
|
-
return
|
|
507
|
+
const m = Vs(D(a.signature())), p = a.signed_data().to_bytes();
|
|
508
|
+
return A.verify(p, m);
|
|
509
509
|
}
|
|
510
510
|
return !1;
|
|
511
|
-
},
|
|
511
|
+
}, As = (r, e, t) => {
|
|
512
512
|
if (r !== e.to_bech32())
|
|
513
513
|
return !1;
|
|
514
514
|
try {
|
|
515
|
-
return
|
|
515
|
+
return At(r) === t.hash().to_hex();
|
|
516
516
|
} catch {
|
|
517
517
|
return !1;
|
|
518
518
|
}
|
|
519
519
|
}, ms = (r) => {
|
|
520
|
-
const e = Be.new(X.from_key_type(
|
|
521
|
-
return e.set_algorithm_id(X.from_algorithm_id(Se.EdDSA)), e.set_header(X.new_int(wt.new_negative(
|
|
520
|
+
const e = Be.new(X.from_key_type(We.OKP));
|
|
521
|
+
return e.set_algorithm_id(X.from_algorithm_id(Se.EdDSA)), e.set_header(X.new_int(wt.new_negative(Kt.from_str("1"))), Mt.new_int(wt.new_i32(6))), e.set_header(X.new_int(wt.new_negative(Kt.from_str("2"))), Mt.new_bytes(r.key.to_public().as_bytes())), e;
|
|
522
522
|
}, Is = (r, e) => {
|
|
523
523
|
const t = Xt.new(), s = Xt.new();
|
|
524
524
|
t.set_algorithm_id(X.from_algorithm_id(Se.EdDSA)), t.set_header(X.new_text("address"), Mt.new_bytes(e.address.to_bytes()));
|
|
525
|
-
const n = je.new(Xe.new(t), s),
|
|
526
|
-
r.externalAAD !== void 0 &&
|
|
527
|
-
const o =
|
|
528
|
-
return
|
|
525
|
+
const n = je.new(Xe.new(t), s), a = Ze.new(n, _(r.payload), !1);
|
|
526
|
+
r.externalAAD !== void 0 && a.set_external_aad(_(r.externalAAD));
|
|
527
|
+
const o = a.make_data_to_sign(), c = e.key.sign(o.to_bytes());
|
|
528
|
+
return a.build(c.to_bytes());
|
|
529
529
|
};
|
|
530
|
-
var ee = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {},
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
var
|
|
530
|
+
var ee = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, be = {}, v = { exports: {} };
|
|
531
|
+
$.notEqual = fs;
|
|
532
|
+
$.notOk = _s;
|
|
533
|
+
$.equal = ps;
|
|
534
|
+
$.ok = $;
|
|
535
|
+
var Qe = $;
|
|
536
536
|
function ps(r, e, t) {
|
|
537
|
-
|
|
537
|
+
$(r == e, t);
|
|
538
538
|
}
|
|
539
539
|
function fs(r, e, t) {
|
|
540
|
-
|
|
540
|
+
$(r != e, t);
|
|
541
541
|
}
|
|
542
542
|
function _s(r, e) {
|
|
543
|
-
|
|
543
|
+
$(!r, e);
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function $(r, e) {
|
|
546
546
|
if (!r)
|
|
547
547
|
throw new Error(e || "AssertionError");
|
|
548
548
|
}
|
|
549
|
-
var
|
|
549
|
+
var V = { exports: {} };
|
|
550
550
|
function ys(r) {
|
|
551
551
|
throw new Error('Could not dynamically require "' + r + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
552
552
|
}
|
|
553
|
-
var xs =
|
|
554
|
-
|
|
555
|
-
function
|
|
556
|
-
if (!
|
|
553
|
+
var xs = Rt;
|
|
554
|
+
Rt.supported = typeof WebAssembly < "u";
|
|
555
|
+
function Rt(r) {
|
|
556
|
+
if (!Rt.supported)
|
|
557
557
|
return null;
|
|
558
558
|
var e = r && r.imports, t = Cs("AGFzbQEAAAABEANgAn9/AGADf39/AGABfwADBQQAAQICBQUBAQroBwdNBQZtZW1vcnkCAAxibGFrZTJiX2luaXQAAA5ibGFrZTJiX3VwZGF0ZQABDWJsYWtlMmJfZmluYWwAAhBibGFrZTJiX2NvbXByZXNzAAMK00AElgMAIABCADcDACAAQQhqQgA3AwAgAEEQakIANwMAIABBGGpCADcDACAAQSBqQgA3AwAgAEEoakIANwMAIABBMGpCADcDACAAQThqQgA3AwAgAEHAAGpCADcDACAAQcgAakIANwMAIABB0ABqQgA3AwAgAEHYAGpCADcDACAAQeAAakIANwMAIABB6ABqQgA3AwAgAEHwAGpCADcDACAAQfgAakIANwMAIABBgAFqQoiS853/zPmE6gBBACkDAIU3AwAgAEGIAWpCu86qptjQ67O7f0EIKQMAhTcDACAAQZABakKr8NP0r+68tzxBECkDAIU3AwAgAEGYAWpC8e30+KWn/aelf0EYKQMAhTcDACAAQaABakLRhZrv+s+Uh9EAQSApAwCFNwMAIABBqAFqQp/Y+dnCkdqCm39BKCkDAIU3AwAgAEGwAWpC6/qG2r+19sEfQTApAwCFNwMAIABBuAFqQvnC+JuRo7Pw2wBBOCkDAIU3AwAgAEHAAWpCADcDACAAQcgBakIANwMAIABB0AFqQgA3AwALbQEDfyAAQcABaiEDIABByAFqIQQgBCkDAKchBQJAA0AgASACRg0BIAVBgAFGBEAgAyADKQMAIAWtfDcDAEEAIQUgABADCyAAIAVqIAEtAAA6AAAgBUEBaiEFIAFBAWohAQwACwsgBCAFrTcDAAtkAQN/IABBwAFqIQEgAEHIAWohAiABIAEpAwAgAikDAHw3AwAgAEHQAWpCfzcDACACKQMApyEDAkADQCADQYABRg0BIAAgA2pBADoAACADQQFqIQMMAAsLIAIgA603AwAgABADC+U7AiB+CX8gAEGAAWohISAAQYgBaiEiIABBkAFqISMgAEGYAWohJCAAQaABaiElIABBqAFqISYgAEGwAWohJyAAQbgBaiEoICEpAwAhASAiKQMAIQIgIykDACEDICQpAwAhBCAlKQMAIQUgJikDACEGICcpAwAhByAoKQMAIQhCiJLznf/M+YTqACEJQrvOqqbY0Ouzu38hCkKr8NP0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"), s = null, n = {
|
|
559
559
|
buffer: t,
|
|
560
560
|
memory: null,
|
|
561
561
|
exports: null,
|
|
562
|
-
realloc:
|
|
562
|
+
realloc: a,
|
|
563
563
|
onload: o
|
|
564
564
|
};
|
|
565
565
|
return o(function() {
|
|
566
566
|
}), n;
|
|
567
|
-
function
|
|
567
|
+
function a(u) {
|
|
568
568
|
n.exports.memory.grow(Math.ceil(Math.abs(u - n.memory.length) / 65536)), n.memory = new Uint8Array(n.exports.memory.buffer);
|
|
569
569
|
}
|
|
570
570
|
function o(u) {
|
|
@@ -593,47 +593,47 @@ function Cs(r) {
|
|
|
593
593
|
function ws(r) {
|
|
594
594
|
return r.charCodeAt(0);
|
|
595
595
|
}
|
|
596
|
-
var
|
|
597
|
-
|
|
598
|
-
var se =
|
|
599
|
-
|
|
600
|
-
var ne =
|
|
601
|
-
|
|
602
|
-
var ie =
|
|
603
|
-
function
|
|
604
|
-
if (!(this instanceof
|
|
605
|
-
return new
|
|
606
|
-
if (!(
|
|
596
|
+
var M = Qe, y = xs(), Y = 64, Bt = [];
|
|
597
|
+
V.exports = T;
|
|
598
|
+
var se = V.exports.BYTES_MIN = 16, re = V.exports.BYTES_MAX = 64;
|
|
599
|
+
V.exports.BYTES = 32;
|
|
600
|
+
var ne = V.exports.KEYBYTES_MIN = 16, ae = V.exports.KEYBYTES_MAX = 64;
|
|
601
|
+
V.exports.KEYBYTES = 32;
|
|
602
|
+
var ie = V.exports.SALTBYTES = 16, oe = V.exports.PERSONALBYTES = 16;
|
|
603
|
+
function T(r, e, t, s, n) {
|
|
604
|
+
if (!(this instanceof T))
|
|
605
|
+
return new T(r, e, t, s, n);
|
|
606
|
+
if (!(y && y.exports))
|
|
607
607
|
throw new Error("WASM not loaded. Wait for Blake2b.ready(cb)");
|
|
608
|
-
r || (r = 32), n !== !0 && (
|
|
608
|
+
r || (r = 32), n !== !0 && (M(r >= se, "digestLength must be at least " + se + ", was given " + r), M(r <= re, "digestLength must be at most " + re + ", was given " + r), e != null && M(e.length >= ne, "key must be at least " + ne + ", was given " + e.length), e != null && M(e.length <= ae, "key must be at least " + ae + ", was given " + e.length), t != null && M(t.length === ie, "salt must be exactly " + ie + ", was given " + t.length), s != null && M(s.length === oe, "personal must be exactly " + oe + ", was given " + s.length)), Bt.length || (Bt.push(Y), Y += 216), this.digestLength = r, this.finalized = !1, this.pointer = Bt.pop(), y.memory.fill(0, 0, 64), y.memory[0] = this.digestLength, y.memory[1] = e ? e.length : 0, y.memory[2] = 1, y.memory[3] = 1, t && y.memory.set(t, 32), s && y.memory.set(s, 48), this.pointer + 216 > y.memory.length && y.realloc(this.pointer + 216), y.exports.blake2b_init(this.pointer, this.digestLength), e && (this.update(e), y.memory.fill(0, Y, Y + e.length), y.memory[this.pointer + 200] = 128);
|
|
609
609
|
}
|
|
610
|
-
|
|
611
|
-
return
|
|
610
|
+
T.prototype.update = function(r) {
|
|
611
|
+
return M(this.finalized === !1, "Hash instance finalized"), M(r, "input must be TypedArray or Buffer"), Y + r.length > y.memory.length && y.realloc(Y + r.length), y.memory.set(r, Y), y.exports.blake2b_update(this.pointer, Y, Y + r.length), this;
|
|
612
612
|
};
|
|
613
|
-
|
|
614
|
-
if (
|
|
615
|
-
return
|
|
613
|
+
T.prototype.digest = function(r) {
|
|
614
|
+
if (M(this.finalized === !1, "Hash instance finalized"), this.finalized = !0, Bt.push(this.pointer), y.exports.blake2b_final(this.pointer), !r || r === "binary")
|
|
615
|
+
return y.memory.slice(this.pointer + 128, this.pointer + 128 + this.digestLength);
|
|
616
616
|
if (r === "hex")
|
|
617
|
-
return Ss(
|
|
618
|
-
|
|
617
|
+
return Ss(y.memory, this.pointer + 128, this.digestLength);
|
|
618
|
+
M(r.length >= this.digestLength, "input must be TypedArray or Buffer");
|
|
619
619
|
for (var e = 0; e < this.digestLength; e++)
|
|
620
|
-
r[e] =
|
|
620
|
+
r[e] = y.memory[this.pointer + 128 + e];
|
|
621
621
|
return r;
|
|
622
622
|
};
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
if (r || (r = Bs), !
|
|
623
|
+
T.prototype.final = T.prototype.digest;
|
|
624
|
+
T.WASM = y && y.buffer;
|
|
625
|
+
T.SUPPORTED = typeof WebAssembly < "u";
|
|
626
|
+
T.ready = function(r) {
|
|
627
|
+
if (r || (r = Bs), !y)
|
|
628
628
|
return r(new Error("WebAssembly not supported"));
|
|
629
629
|
var e = new Promise(function(t, s) {
|
|
630
|
-
|
|
630
|
+
y.onload(function(n) {
|
|
631
631
|
n ? s() : t(), r(n);
|
|
632
632
|
});
|
|
633
633
|
});
|
|
634
634
|
return e;
|
|
635
635
|
};
|
|
636
|
-
|
|
636
|
+
T.prototype.ready = T.ready;
|
|
637
637
|
function Bs() {
|
|
638
638
|
}
|
|
639
639
|
function Ss(r, e, t) {
|
|
@@ -644,7 +644,7 @@ function Ss(r, e, t) {
|
|
|
644
644
|
function Es(r) {
|
|
645
645
|
return r < 16 ? "0" + r.toString(16) : r.toString(16);
|
|
646
646
|
}
|
|
647
|
-
var j =
|
|
647
|
+
var j = Qe, pt = V.exports;
|
|
648
648
|
function _t(r, e, t) {
|
|
649
649
|
var s = r[e] + r[t], n = r[e + 1] + r[t + 1];
|
|
650
650
|
s >= 4294967296 && n++, r[e] = s, r[e + 1] = n;
|
|
@@ -652,17 +652,17 @@ function _t(r, e, t) {
|
|
|
652
652
|
function ce(r, e, t, s) {
|
|
653
653
|
var n = r[e] + t;
|
|
654
654
|
t < 0 && (n += 4294967296);
|
|
655
|
-
var
|
|
656
|
-
n >= 4294967296 &&
|
|
655
|
+
var a = r[e + 1] + s;
|
|
656
|
+
n >= 4294967296 && a++, r[e] = n, r[e + 1] = a;
|
|
657
657
|
}
|
|
658
658
|
function ve(r, e) {
|
|
659
659
|
return r[e] ^ r[e + 1] << 8 ^ r[e + 2] << 16 ^ r[e + 3] << 24;
|
|
660
660
|
}
|
|
661
|
-
function
|
|
662
|
-
var o =
|
|
663
|
-
_t(
|
|
664
|
-
var
|
|
665
|
-
|
|
661
|
+
function J(r, e, t, s, n, a) {
|
|
662
|
+
var o = gt[n], c = gt[n + 1], u = gt[a], d = gt[a + 1];
|
|
663
|
+
_t(I, r, e), ce(I, r, o, c);
|
|
664
|
+
var l = I[s] ^ I[r], g = I[s + 1] ^ I[r + 1];
|
|
665
|
+
I[s] = g, I[s + 1] = l, _t(I, t, s), l = I[e] ^ I[t], g = I[e + 1] ^ I[t + 1], I[e] = l >>> 24 ^ g << 8, I[e + 1] = g >>> 24 ^ l << 8, _t(I, r, e), ce(I, r, u, d), l = I[s] ^ I[r], g = I[s + 1] ^ I[r + 1], I[s] = l >>> 16 ^ g << 16, I[s + 1] = g >>> 16 ^ l << 16, _t(I, t, s), l = I[e] ^ I[t], g = I[e + 1] ^ I[t + 1], I[e] = g >>> 31 ^ l << 1, I[e + 1] = l >>> 31 ^ g << 1;
|
|
666
666
|
}
|
|
667
667
|
var De = new Uint32Array([
|
|
668
668
|
4089235720,
|
|
@@ -681,7 +681,7 @@ var De = new Uint32Array([
|
|
|
681
681
|
528734635,
|
|
682
682
|
327033209,
|
|
683
683
|
1541459225
|
|
684
|
-
]),
|
|
684
|
+
]), bs = [
|
|
685
685
|
0,
|
|
686
686
|
1,
|
|
687
687
|
2,
|
|
@@ -874,21 +874,21 @@ var De = new Uint32Array([
|
|
|
874
874
|
7,
|
|
875
875
|
5,
|
|
876
876
|
3
|
|
877
|
-
],
|
|
877
|
+
], b = new Uint8Array(bs.map(function(r) {
|
|
878
878
|
return r * 2;
|
|
879
|
-
})),
|
|
879
|
+
})), I = new Uint32Array(32), gt = new Uint32Array(32);
|
|
880
880
|
function ke(r, e) {
|
|
881
881
|
var t = 0;
|
|
882
882
|
for (t = 0; t < 16; t++)
|
|
883
|
-
|
|
884
|
-
for (
|
|
885
|
-
|
|
883
|
+
I[t] = r.h[t], I[t + 16] = De[t];
|
|
884
|
+
for (I[24] = I[24] ^ r.t, I[25] = I[25] ^ r.t / 4294967296, e && (I[28] = ~I[28], I[29] = ~I[29]), t = 0; t < 32; t++)
|
|
885
|
+
gt[t] = ve(r.b, 4 * t);
|
|
886
886
|
for (t = 0; t < 12; t++)
|
|
887
|
-
|
|
887
|
+
J(0, 8, 16, 24, b[t * 16 + 0], b[t * 16 + 1]), J(2, 10, 18, 26, b[t * 16 + 2], b[t * 16 + 3]), J(4, 12, 20, 28, b[t * 16 + 4], b[t * 16 + 5]), J(6, 14, 22, 30, b[t * 16 + 6], b[t * 16 + 7]), J(0, 10, 20, 30, b[t * 16 + 8], b[t * 16 + 9]), J(2, 12, 22, 24, b[t * 16 + 10], b[t * 16 + 11]), J(4, 14, 16, 26, b[t * 16 + 12], b[t * 16 + 13]), J(6, 8, 18, 28, b[t * 16 + 14], b[t * 16 + 15]);
|
|
888
888
|
for (t = 0; t < 16; t++)
|
|
889
|
-
r.h[t] = r.h[t] ^
|
|
889
|
+
r.h[t] = r.h[t] ^ I[t] ^ I[t + 16];
|
|
890
890
|
}
|
|
891
|
-
var
|
|
891
|
+
var W = new Uint8Array([
|
|
892
892
|
0,
|
|
893
893
|
0,
|
|
894
894
|
0,
|
|
@@ -955,9 +955,9 @@ var J = new Uint8Array([
|
|
|
955
955
|
0
|
|
956
956
|
]);
|
|
957
957
|
function ct(r, e, t, s) {
|
|
958
|
-
|
|
958
|
+
W.fill(0), this.b = new Uint8Array(128), this.h = new Uint32Array(16), this.t = 0, this.c = 0, this.outlen = r, W[0] = r, e && (W[1] = e.length), W[2] = 1, W[3] = 1, t && W.set(t, 32), s && W.set(s, 48);
|
|
959
959
|
for (var n = 0; n < 16; n++)
|
|
960
|
-
this.h[n] = De[n] ^ ve(
|
|
960
|
+
this.h[n] = De[n] ^ ve(W, n * 4);
|
|
961
961
|
e && (Te(this, e), this.c = 128);
|
|
962
962
|
}
|
|
963
963
|
ct.prototype.update = function(r) {
|
|
@@ -965,7 +965,7 @@ ct.prototype.update = function(r) {
|
|
|
965
965
|
};
|
|
966
966
|
ct.prototype.digest = function(r) {
|
|
967
967
|
var e = !r || r === "binary" || r === "hex" ? new Uint8Array(this.outlen) : r;
|
|
968
|
-
return j(e.length >= this.outlen, "out must have at least outlen bytes of space"),
|
|
968
|
+
return j(e.length >= this.outlen, "out must have at least outlen bytes of space"), Qs(this, e), r === "hex" ? vs(e) : e;
|
|
969
969
|
};
|
|
970
970
|
ct.prototype.final = ct.prototype.digest;
|
|
971
971
|
ct.ready = function(r) {
|
|
@@ -977,7 +977,7 @@ function Te(r, e) {
|
|
|
977
977
|
for (var t = 0; t < e.length; t++)
|
|
978
978
|
r.c === 128 && (r.t += r.c, ke(r, !1), r.c = 0), r.b[r.c++] = e[t];
|
|
979
979
|
}
|
|
980
|
-
function
|
|
980
|
+
function Qs(r, e) {
|
|
981
981
|
for (r.t += r.c; r.c < 128; )
|
|
982
982
|
r.b[r.c++] = 0;
|
|
983
983
|
ke(r, !0);
|
|
@@ -994,30 +994,30 @@ function Ds(r) {
|
|
|
994
994
|
return r < 16 ? "0" + r.toString(16) : r.toString(16);
|
|
995
995
|
}
|
|
996
996
|
var Ue = ct;
|
|
997
|
-
|
|
998
|
-
return
|
|
997
|
+
v.exports = function(e, t, s, n, a) {
|
|
998
|
+
return a !== !0 && (j(e >= ue, "outlen must be at least " + ue + ", was given " + e), j(e <= de, "outlen must be at most " + de + ", was given " + e), t != null && j(t.length >= he, "key must be at least " + he + ", was given " + t.length), t != null && j(t.length <= le, "key must be at most " + le + ", was given " + t.length), s != null && j(s.length === ge, "salt must be exactly " + ge + ", was given " + s.length), n != null && j(n.length === Ae, "personal must be exactly " + Ae + ", was given " + n.length)), new Ue(e, t, s, n);
|
|
999
999
|
};
|
|
1000
|
-
|
|
1000
|
+
v.exports.ready = function(r) {
|
|
1001
1001
|
pt.ready(function() {
|
|
1002
1002
|
r();
|
|
1003
1003
|
});
|
|
1004
1004
|
};
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
var ue =
|
|
1008
|
-
|
|
1009
|
-
var he =
|
|
1010
|
-
|
|
1011
|
-
var
|
|
1005
|
+
v.exports.WASM_SUPPORTED = pt.SUPPORTED;
|
|
1006
|
+
v.exports.WASM_LOADED = !1;
|
|
1007
|
+
var ue = v.exports.BYTES_MIN = 16, de = v.exports.BYTES_MAX = 64;
|
|
1008
|
+
v.exports.BYTES = 32;
|
|
1009
|
+
var he = v.exports.KEYBYTES_MIN = 16, le = v.exports.KEYBYTES_MAX = 64;
|
|
1010
|
+
v.exports.KEYBYTES = 32;
|
|
1011
|
+
var ge = v.exports.SALTBYTES = 16, Ae = v.exports.PERSONALBYTES = 16;
|
|
1012
1012
|
pt.ready(function(r) {
|
|
1013
|
-
r || (
|
|
1013
|
+
r || (v.exports.WASM_LOADED = !0, Ue = pt);
|
|
1014
1014
|
});
|
|
1015
1015
|
var ut = {};
|
|
1016
1016
|
Object.defineProperty(ut, "__esModule", { value: !0 });
|
|
1017
1017
|
ut.bech32m = ut.bech32 = void 0;
|
|
1018
|
-
const
|
|
1019
|
-
for (let r = 0; r <
|
|
1020
|
-
const e =
|
|
1018
|
+
const Qt = "qpzry9x8gf2tvdw0s3jn54khce6mua7l", Pe = {};
|
|
1019
|
+
for (let r = 0; r < Qt.length; r++) {
|
|
1020
|
+
const e = Qt.charAt(r);
|
|
1021
1021
|
Pe[e] = r;
|
|
1022
1022
|
}
|
|
1023
1023
|
function ot(r) {
|
|
@@ -1040,17 +1040,17 @@ function me(r) {
|
|
|
1040
1040
|
return e;
|
|
1041
1041
|
}
|
|
1042
1042
|
function Yt(r, e, t, s) {
|
|
1043
|
-
let n = 0,
|
|
1043
|
+
let n = 0, a = 0;
|
|
1044
1044
|
const o = (1 << t) - 1, c = [];
|
|
1045
1045
|
for (let u = 0; u < r.length; ++u)
|
|
1046
|
-
for (n = n << e | r[u],
|
|
1047
|
-
|
|
1046
|
+
for (n = n << e | r[u], a += e; a >= t; )
|
|
1047
|
+
a -= t, c.push(n >> a & o);
|
|
1048
1048
|
if (s)
|
|
1049
|
-
|
|
1049
|
+
a > 0 && c.push(n << t - a & o);
|
|
1050
1050
|
else {
|
|
1051
|
-
if (
|
|
1051
|
+
if (a >= e)
|
|
1052
1052
|
return "Excess padding";
|
|
1053
|
-
if (n << t -
|
|
1053
|
+
if (n << t - a & o)
|
|
1054
1054
|
return "Non-zero padding";
|
|
1055
1055
|
}
|
|
1056
1056
|
return c;
|
|
@@ -1069,7 +1069,7 @@ function Us(r) {
|
|
|
1069
1069
|
return e;
|
|
1070
1070
|
throw new Error(e);
|
|
1071
1071
|
}
|
|
1072
|
-
function
|
|
1072
|
+
function Ne(r) {
|
|
1073
1073
|
let e;
|
|
1074
1074
|
r === "bech32" ? e = 1 : e = 734539939;
|
|
1075
1075
|
function t(o, c, u) {
|
|
@@ -1079,21 +1079,21 @@ function Ke(r) {
|
|
|
1079
1079
|
let d = me(o);
|
|
1080
1080
|
if (typeof d == "string")
|
|
1081
1081
|
throw new Error(d);
|
|
1082
|
-
let
|
|
1083
|
-
for (let
|
|
1084
|
-
const
|
|
1085
|
-
if (
|
|
1082
|
+
let l = o + "1";
|
|
1083
|
+
for (let g = 0; g < c.length; ++g) {
|
|
1084
|
+
const A = c[g];
|
|
1085
|
+
if (A >> 5 !== 0)
|
|
1086
1086
|
throw new Error("Non 5-bit word");
|
|
1087
|
-
d = ot(d) ^
|
|
1087
|
+
d = ot(d) ^ A, l += Qt.charAt(A);
|
|
1088
1088
|
}
|
|
1089
|
-
for (let
|
|
1089
|
+
for (let g = 0; g < 6; ++g)
|
|
1090
1090
|
d = ot(d);
|
|
1091
1091
|
d ^= e;
|
|
1092
|
-
for (let
|
|
1093
|
-
const
|
|
1094
|
-
|
|
1092
|
+
for (let g = 0; g < 6; ++g) {
|
|
1093
|
+
const A = d >> (5 - g) * 5 & 31;
|
|
1094
|
+
l += Qt.charAt(A);
|
|
1095
1095
|
}
|
|
1096
|
-
return
|
|
1096
|
+
return l;
|
|
1097
1097
|
}
|
|
1098
1098
|
function s(o, c) {
|
|
1099
1099
|
if (c = c || 90, o.length < 8)
|
|
@@ -1104,32 +1104,32 @@ function Ke(r) {
|
|
|
1104
1104
|
if (o !== u && o !== d)
|
|
1105
1105
|
return "Mixed-case string " + o;
|
|
1106
1106
|
o = u;
|
|
1107
|
-
const
|
|
1108
|
-
if (
|
|
1107
|
+
const l = o.lastIndexOf("1");
|
|
1108
|
+
if (l === -1)
|
|
1109
1109
|
return "No separator character for " + o;
|
|
1110
|
-
if (
|
|
1110
|
+
if (l === 0)
|
|
1111
1111
|
return "Missing prefix for " + o;
|
|
1112
|
-
const
|
|
1113
|
-
if (
|
|
1112
|
+
const g = o.slice(0, l), A = o.slice(l + 1);
|
|
1113
|
+
if (A.length < 6)
|
|
1114
1114
|
return "Data too short";
|
|
1115
|
-
let
|
|
1116
|
-
if (typeof
|
|
1117
|
-
return
|
|
1118
|
-
const
|
|
1119
|
-
for (let
|
|
1120
|
-
const
|
|
1115
|
+
let m = me(g);
|
|
1116
|
+
if (typeof m == "string")
|
|
1117
|
+
return m;
|
|
1118
|
+
const p = [];
|
|
1119
|
+
for (let S = 0; S < A.length; ++S) {
|
|
1120
|
+
const E = A.charAt(S), f = Pe[E];
|
|
1121
1121
|
if (f === void 0)
|
|
1122
|
-
return "Unknown character " +
|
|
1123
|
-
|
|
1122
|
+
return "Unknown character " + E;
|
|
1123
|
+
m = ot(m) ^ f, !(S + 6 >= A.length) && p.push(f);
|
|
1124
1124
|
}
|
|
1125
|
-
return
|
|
1125
|
+
return m !== e ? "Invalid checksum for " + o : { prefix: g, words: p };
|
|
1126
1126
|
}
|
|
1127
1127
|
function n(o, c) {
|
|
1128
1128
|
const u = s(o, c);
|
|
1129
1129
|
if (typeof u == "object")
|
|
1130
1130
|
return u;
|
|
1131
1131
|
}
|
|
1132
|
-
function
|
|
1132
|
+
function a(o, c) {
|
|
1133
1133
|
const u = s(o, c);
|
|
1134
1134
|
if (typeof u == "object")
|
|
1135
1135
|
return u;
|
|
@@ -1137,20 +1137,20 @@ function Ke(r) {
|
|
|
1137
1137
|
}
|
|
1138
1138
|
return {
|
|
1139
1139
|
decodeUnsafe: n,
|
|
1140
|
-
decode:
|
|
1140
|
+
decode: a,
|
|
1141
1141
|
encode: t,
|
|
1142
1142
|
toWords: ks,
|
|
1143
1143
|
fromWordsUnsafe: Ts,
|
|
1144
1144
|
fromWords: Us
|
|
1145
1145
|
};
|
|
1146
1146
|
}
|
|
1147
|
-
ut.bech32 =
|
|
1148
|
-
ut.bech32m =
|
|
1147
|
+
ut.bech32 = Ne("bech32");
|
|
1148
|
+
ut.bech32m = Ne("bech32m");
|
|
1149
1149
|
var Ps = ee && ee.__importDefault || function(r) {
|
|
1150
1150
|
return r && r.__esModule ? r : { default: r };
|
|
1151
1151
|
};
|
|
1152
|
-
Object.defineProperty(
|
|
1153
|
-
const
|
|
1152
|
+
Object.defineProperty(be, "__esModule", { value: !0 });
|
|
1153
|
+
const Ns = Ps(v.exports), yt = ut, Nt = "asset";
|
|
1154
1154
|
class mt {
|
|
1155
1155
|
constructor(e) {
|
|
1156
1156
|
this.hashBuf = e;
|
|
@@ -1159,35 +1159,35 @@ class mt {
|
|
|
1159
1159
|
return new mt(e);
|
|
1160
1160
|
}
|
|
1161
1161
|
static fromParts(e, t) {
|
|
1162
|
-
const s = (0,
|
|
1162
|
+
const s = (0, Ns.default)(20).update(new Uint8Array([...e, ...t])).digest("binary");
|
|
1163
1163
|
return mt.fromHash(s);
|
|
1164
1164
|
}
|
|
1165
1165
|
static fromBech32(e) {
|
|
1166
1166
|
const { prefix: t, words: s } = yt.bech32.decode(e);
|
|
1167
|
-
if (t !==
|
|
1167
|
+
if (t !== Nt)
|
|
1168
1168
|
throw new Error("Invalid asset fingerprint");
|
|
1169
1169
|
const n = Buffer.from(yt.bech32.fromWords(s));
|
|
1170
1170
|
return mt.fromHash(n);
|
|
1171
1171
|
}
|
|
1172
1172
|
fingerprint() {
|
|
1173
1173
|
const e = yt.bech32.toWords(this.hashBuf);
|
|
1174
|
-
return yt.bech32.encode(
|
|
1174
|
+
return yt.bech32.encode(Nt, e);
|
|
1175
1175
|
}
|
|
1176
1176
|
hash() {
|
|
1177
1177
|
return Buffer.from(this.hashBuf).toString("hex");
|
|
1178
1178
|
}
|
|
1179
1179
|
prefix() {
|
|
1180
|
-
return
|
|
1180
|
+
return Nt;
|
|
1181
1181
|
}
|
|
1182
1182
|
checksum() {
|
|
1183
1183
|
return this.fingerprint().slice(-6);
|
|
1184
1184
|
}
|
|
1185
1185
|
}
|
|
1186
|
-
var
|
|
1187
|
-
const Ms =
|
|
1188
|
-
const t = Fs(r), s = t.derive(Pt + 1852).derive(Pt + 1815).derive(Pt + e), n = s.derive(0).derive(0).to_raw_key(),
|
|
1189
|
-
return s.free(), t.free(), { paymentKey: n, stakeKey:
|
|
1190
|
-
}, nt = (r) =>
|
|
1186
|
+
var Ks = be.default = mt;
|
|
1187
|
+
const Ms = Ks, Hs = (r, e) => {
|
|
1188
|
+
const t = Fs(r), s = t.derive(Pt + 1852).derive(Pt + 1815).derive(Pt + e), n = s.derive(0).derive(0).to_raw_key(), a = s.derive(2).derive(0).to_raw_key();
|
|
1189
|
+
return s.free(), t.free(), { paymentKey: n, stakeKey: a };
|
|
1190
|
+
}, nt = (r) => i.Address.from_bytes(_(r)), Fs = (r) => i.Bip32PrivateKey.from_bytes(_(r)), Os = (r) => i.DataHash.from_bytes(_(r)), F = (r) => i.Ed25519KeyHash.from_bytes(_(r)), Vs = (r) => i.Ed25519Signature.from_bytes(_(r)), Dt = (r) => i.NativeScript.from_bytes(_(r)), qs = (r) => i.PublicKey.from_bytes(_(r)), Ke = (r) => i.PlutusData.from_bytes(_(r)), dt = (r, e) => i.PlutusScript.from_bytes_with_version(_(r), R[e]), Rs = (r) => i.ScriptRef.from_bytes(_(r)), Ys = (r) => i.ScriptHash.from_bytes(_(r)), L = (r) => i.Transaction.from_bytes(_(r)), Me = (r) => i.TransactionHash.from_bytes(_(r)), Ie = (r) => i.TransactionUnspentOutput.from_bytes(_(r)), Ls = (r) => i.TransactionWitnessSet.from_bytes(_(r)), Gs = (r) => i.Value.from_bytes(_(r)), K = (r) => i.Address.from_bech32(r), Lt = (r) => i.BaseAddress.from_address(K(r)), He = (r) => i.EnterpriseAddress.from_address(K(r)), Fe = (r) => i.RewardAddress.from_address(K(r)), D = (r) => Buffer.from(r).toString("hex"), _ = (r) => r.length % 2 === 0 && /^[0-9A-F]*$/i.test(r) ? Buffer.from(r, "hex") : Buffer.from(r, "utf-8"), kt = (r) => {
|
|
1191
1191
|
const e = (t) => {
|
|
1192
1192
|
const s = new Array();
|
|
1193
1193
|
for (let n = 0; n < t.len(); n += 1)
|
|
@@ -1195,21 +1195,21 @@ const Ms = Ns, Hs = (r, e) => {
|
|
|
1195
1195
|
return s;
|
|
1196
1196
|
};
|
|
1197
1197
|
switch (r.kind()) {
|
|
1198
|
-
case
|
|
1198
|
+
case i.NativeScriptKind.ScriptAll: {
|
|
1199
1199
|
const t = r.as_script_all();
|
|
1200
1200
|
return {
|
|
1201
1201
|
type: "all",
|
|
1202
1202
|
scripts: e(t.native_scripts())
|
|
1203
1203
|
};
|
|
1204
1204
|
}
|
|
1205
|
-
case
|
|
1205
|
+
case i.NativeScriptKind.ScriptAny: {
|
|
1206
1206
|
const t = r.as_script_any();
|
|
1207
1207
|
return {
|
|
1208
1208
|
type: "any",
|
|
1209
1209
|
scripts: e(t.native_scripts())
|
|
1210
1210
|
};
|
|
1211
1211
|
}
|
|
1212
|
-
case
|
|
1212
|
+
case i.NativeScriptKind.ScriptNOfK: {
|
|
1213
1213
|
const t = r.as_script_n_of_k();
|
|
1214
1214
|
return {
|
|
1215
1215
|
type: "atLeast",
|
|
@@ -1217,21 +1217,21 @@ const Ms = Ns, Hs = (r, e) => {
|
|
|
1217
1217
|
scripts: e(t.native_scripts())
|
|
1218
1218
|
};
|
|
1219
1219
|
}
|
|
1220
|
-
case
|
|
1220
|
+
case i.NativeScriptKind.TimelockStart: {
|
|
1221
1221
|
const t = r.as_timelock_start();
|
|
1222
1222
|
return {
|
|
1223
1223
|
type: "after",
|
|
1224
1224
|
slot: t.slot_bignum().to_str()
|
|
1225
1225
|
};
|
|
1226
1226
|
}
|
|
1227
|
-
case
|
|
1227
|
+
case i.NativeScriptKind.TimelockExpiry: {
|
|
1228
1228
|
const t = r.as_timelock_expiry();
|
|
1229
1229
|
return {
|
|
1230
1230
|
type: "before",
|
|
1231
1231
|
slot: t.slot_bignum().to_str()
|
|
1232
1232
|
};
|
|
1233
1233
|
}
|
|
1234
|
-
case
|
|
1234
|
+
case i.NativeScriptKind.ScriptPubkey: {
|
|
1235
1235
|
const t = r.as_script_pubkey();
|
|
1236
1236
|
return {
|
|
1237
1237
|
type: "sig",
|
|
@@ -1243,27 +1243,27 @@ const Ms = Ns, Hs = (r, e) => {
|
|
|
1243
1243
|
}
|
|
1244
1244
|
}, Tt = (r) => {
|
|
1245
1245
|
const e = (t) => {
|
|
1246
|
-
const s =
|
|
1246
|
+
const s = i.NativeScripts.new();
|
|
1247
1247
|
return t.forEach((n) => {
|
|
1248
1248
|
s.add(Tt(n));
|
|
1249
1249
|
}), s;
|
|
1250
1250
|
};
|
|
1251
1251
|
switch (r.type) {
|
|
1252
1252
|
case "all":
|
|
1253
|
-
return
|
|
1253
|
+
return i.NativeScript.new_script_all(i.ScriptAll.new(e(r.scripts)));
|
|
1254
1254
|
case "any":
|
|
1255
|
-
return
|
|
1255
|
+
return i.NativeScript.new_script_any(i.ScriptAny.new(e(r.scripts)));
|
|
1256
1256
|
case "atLeast":
|
|
1257
|
-
return
|
|
1257
|
+
return i.NativeScript.new_script_n_of_k(i.ScriptNOfK.new(r.required, e(r.scripts)));
|
|
1258
1258
|
case "after":
|
|
1259
|
-
return
|
|
1259
|
+
return i.NativeScript.new_timelock_start(i.TimelockStart.new_timelockstart(i.BigNum.from_str(r.slot)));
|
|
1260
1260
|
case "before":
|
|
1261
|
-
return
|
|
1261
|
+
return i.NativeScript.new_timelock_expiry(i.TimelockExpiry.new_timelockexpiry(i.BigNum.from_str(r.slot)));
|
|
1262
1262
|
case "sig":
|
|
1263
|
-
return
|
|
1263
|
+
return i.NativeScript.new_script_pubkey(i.ScriptPubkey.new(F(r.keyHash)));
|
|
1264
1264
|
}
|
|
1265
1265
|
}, St = (r) => {
|
|
1266
|
-
var s, n,
|
|
1266
|
+
var s, n, a;
|
|
1267
1267
|
const e = (o) => {
|
|
1268
1268
|
const c = [];
|
|
1269
1269
|
for (let u = 0; u < o.len(); u += 1)
|
|
@@ -1272,70 +1272,70 @@ const Ms = Ns, Hs = (r, e) => {
|
|
|
1272
1272
|
}, t = (o) => {
|
|
1273
1273
|
const c = /* @__PURE__ */ new Map();
|
|
1274
1274
|
for (let u = 0; u < o.len(); u += 1) {
|
|
1275
|
-
const d = o.keys().get(u),
|
|
1276
|
-
c.set(St(d), St(
|
|
1275
|
+
const d = o.keys().get(u), l = o.get(d) ?? i.PlutusData.from_hex(Q("NO_ITEM_FOUND_INSIDE_GOLD_ROOM"));
|
|
1276
|
+
c.set(St(d), St(l));
|
|
1277
1277
|
}
|
|
1278
1278
|
return c;
|
|
1279
1279
|
};
|
|
1280
1280
|
switch (r.kind()) {
|
|
1281
|
-
case
|
|
1282
|
-
return
|
|
1283
|
-
case
|
|
1281
|
+
case i.PlutusDataKind.Bytes:
|
|
1282
|
+
return D(r.as_bytes() ?? new Uint8Array());
|
|
1283
|
+
case i.PlutusDataKind.Integer:
|
|
1284
1284
|
return parseInt(((s = r.as_integer()) == null ? void 0 : s.to_str()) ?? "0", 10);
|
|
1285
|
-
case
|
|
1286
|
-
return e(r.as_list() ??
|
|
1287
|
-
case
|
|
1288
|
-
return t(r.as_map() ??
|
|
1289
|
-
case
|
|
1285
|
+
case i.PlutusDataKind.List:
|
|
1286
|
+
return e(r.as_list() ?? i.PlutusList.new());
|
|
1287
|
+
case i.PlutusDataKind.Map:
|
|
1288
|
+
return t(r.as_map() ?? i.PlutusMap.new());
|
|
1289
|
+
case i.PlutusDataKind.ConstrPlutusData:
|
|
1290
1290
|
return {
|
|
1291
1291
|
alternative: parseInt(((n = r.as_constr_plutus_data()) == null ? void 0 : n.alternative().to_str()) ?? "0", 10),
|
|
1292
|
-
fields: e(((
|
|
1292
|
+
fields: e(((a = r.as_constr_plutus_data()) == null ? void 0 : a.data()) ?? i.PlutusList.new())
|
|
1293
1293
|
};
|
|
1294
1294
|
default:
|
|
1295
1295
|
throw new Error(`PlutusData Kind: ${r.kind()}, is not supported`);
|
|
1296
1296
|
}
|
|
1297
1297
|
}, tt = (r) => {
|
|
1298
1298
|
const e = (t) => {
|
|
1299
|
-
const s =
|
|
1299
|
+
const s = i.PlutusList.new();
|
|
1300
1300
|
return t.forEach((n) => {
|
|
1301
1301
|
s.add(tt(n));
|
|
1302
1302
|
}), s;
|
|
1303
1303
|
};
|
|
1304
1304
|
switch (typeof r) {
|
|
1305
1305
|
case "string":
|
|
1306
|
-
return
|
|
1306
|
+
return i.PlutusData.new_bytes(_(r));
|
|
1307
1307
|
case "number":
|
|
1308
|
-
return
|
|
1308
|
+
return i.PlutusData.new_integer(i.BigInt.from_str(r.toString()));
|
|
1309
1309
|
case "object":
|
|
1310
1310
|
if (r instanceof Array) {
|
|
1311
1311
|
const t = e(r);
|
|
1312
|
-
return
|
|
1312
|
+
return i.PlutusData.new_list(t);
|
|
1313
1313
|
} else if (r instanceof Map) {
|
|
1314
|
-
const t =
|
|
1314
|
+
const t = i.PlutusMap.new();
|
|
1315
1315
|
return r.forEach((s, n) => {
|
|
1316
1316
|
t.insert(tt(n), tt(s));
|
|
1317
|
-
}),
|
|
1317
|
+
}), i.PlutusData.new_map(t);
|
|
1318
1318
|
} else
|
|
1319
|
-
return
|
|
1319
|
+
return i.PlutusData.new_constr_plutus_data(i.ConstrPlutusData.new(i.BigNum.from_str(r.alternative.toString()), e(r.fields)));
|
|
1320
1320
|
}
|
|
1321
1321
|
}, $s = (r) => {
|
|
1322
|
-
const e =
|
|
1322
|
+
const e = i.Relays.new();
|
|
1323
1323
|
throw r.relays.forEach((t) => {
|
|
1324
1324
|
e.add(zs(t));
|
|
1325
1325
|
}), new Error("toPoolParams not implemented.");
|
|
1326
1326
|
}, Oe = (r) => {
|
|
1327
1327
|
const e = (t) => ss[t];
|
|
1328
|
-
return
|
|
1328
|
+
return i.Redeemer.new(e(r.tag), i.BigNum.from_str(r.index.toString()), tt(r.data), i.ExUnits.new(i.BigNum.from_str(r.budget.mem.toString()), i.BigNum.from_str(r.budget.steps.toString())));
|
|
1329
1329
|
}, zs = (r) => {
|
|
1330
1330
|
switch (r.type) {
|
|
1331
1331
|
case "SingleHostAddr": {
|
|
1332
|
-
const e = r.IPV4 ?
|
|
1333
|
-
return
|
|
1332
|
+
const e = r.IPV4 ? i.Ipv4.new(new Uint8Array(r.IPV4.split(".").map((s) => parseInt(s)))) : void 0, t = r.IPV6 ? i.Ipv6.new(_(r.IPV6.replaceAll(":", ""))) : void 0;
|
|
1333
|
+
return i.Relay.new_single_host_addr(i.SingleHostAddr.new(r.port, e, t));
|
|
1334
1334
|
}
|
|
1335
1335
|
case "SingleHostName":
|
|
1336
|
-
return
|
|
1336
|
+
return i.Relay.new_single_host_name(i.SingleHostName.new(r.port, i.DNSRecordAorAAAA.new(r.domainName)));
|
|
1337
1337
|
case "MultiHostName":
|
|
1338
|
-
return
|
|
1338
|
+
return i.Relay.new_multi_host_name(i.MultiHostName.new(i.DNSRecordSRV.new(r.domainName)));
|
|
1339
1339
|
}
|
|
1340
1340
|
}, Ve = (r) => {
|
|
1341
1341
|
if (r.is_plutus_script()) {
|
|
@@ -1350,12 +1350,12 @@ const Ms = Ns, Hs = (r, e) => {
|
|
|
1350
1350
|
}, ht = (r) => {
|
|
1351
1351
|
if ("code" in r) {
|
|
1352
1352
|
const e = dt(r.code, r.version);
|
|
1353
|
-
return
|
|
1353
|
+
return i.ScriptRef.new_plutus_script(e);
|
|
1354
1354
|
}
|
|
1355
|
-
return
|
|
1355
|
+
return i.ScriptRef.new_native_script(Tt(r));
|
|
1356
1356
|
}, vt = (r) => {
|
|
1357
|
-
var n,
|
|
1358
|
-
const e = r.output().has_data_hash() ? (n = r.output().data_hash()) == null ? void 0 : n.to_hex() : void 0, t = r.output().has_plutus_data() ? (
|
|
1357
|
+
var n, a, o;
|
|
1358
|
+
const e = r.output().has_data_hash() ? (n = r.output().data_hash()) == null ? void 0 : n.to_hex() : void 0, t = r.output().has_plutus_data() ? (a = r.output().plutus_data()) == null ? void 0 : a.to_hex() : void 0, s = r.output().has_script_ref() ? (o = r.output().script_ref()) == null ? void 0 : o.to_hex() : void 0;
|
|
1359
1359
|
return {
|
|
1360
1360
|
input: {
|
|
1361
1361
|
outputIndex: r.input().index(),
|
|
@@ -1363,61 +1363,61 @@ const Ms = Ns, Hs = (r, e) => {
|
|
|
1363
1363
|
},
|
|
1364
1364
|
output: {
|
|
1365
1365
|
address: r.output().address().to_bech32(),
|
|
1366
|
-
amount:
|
|
1366
|
+
amount: qe(r.output().amount()),
|
|
1367
1367
|
dataHash: e,
|
|
1368
1368
|
plutusData: t,
|
|
1369
1369
|
scriptRef: s
|
|
1370
1370
|
}
|
|
1371
1371
|
};
|
|
1372
|
-
},
|
|
1373
|
-
const e =
|
|
1374
|
-
return r.output.dataHash !== void 0 && t.set_data_hash(Os(r.output.dataHash)), r.output.plutusData !== void 0 && t.set_plutus_data(
|
|
1372
|
+
}, H = (r) => {
|
|
1373
|
+
const e = i.TransactionInput.new(Me(r.input.txHash), r.input.outputIndex), t = i.TransactionOutput.new(K(r.output.address), Z(r.output.amount));
|
|
1374
|
+
return r.output.dataHash !== void 0 && t.set_data_hash(Os(r.output.dataHash)), r.output.plutusData !== void 0 && t.set_plutus_data(Ke(r.output.plutusData)), r.output.scriptRef !== void 0 && t.set_script_ref(Rs(r.output.scriptRef)), i.TransactionUnspentOutput.new(e, t);
|
|
1375
1375
|
}, pe = (r) => {
|
|
1376
1376
|
const e = r.split(".")[1] ?? "0", t = `${parseInt(e, 10)}`, s = "1" + "0".repeat(e.length);
|
|
1377
|
-
return
|
|
1378
|
-
},
|
|
1377
|
+
return i.UnitInterval.new(i.BigNum.from_str(t), i.BigNum.from_str(s));
|
|
1378
|
+
}, Q = (r) => r.length % 2 === 0 && /^[0-9A-F]*$/i.test(r) ? r : D(Buffer.from(r, "utf-8")), Gt = (r) => Buffer.from(r, "hex").toString("utf-8"), qe = (r) => {
|
|
1379
1379
|
const e = [
|
|
1380
1380
|
{ unit: "lovelace", quantity: r.coin().to_str() }
|
|
1381
1381
|
], t = r.multiasset();
|
|
1382
1382
|
if (t !== void 0) {
|
|
1383
1383
|
const s = t.keys();
|
|
1384
1384
|
for (let n = 0; n < s.len(); n += 1) {
|
|
1385
|
-
const
|
|
1385
|
+
const a = s.get(n), o = t.get(a);
|
|
1386
1386
|
if (o !== void 0) {
|
|
1387
1387
|
const c = o.keys();
|
|
1388
1388
|
for (let u = 0; u < c.len(); u += 1) {
|
|
1389
|
-
const d = c.get(u),
|
|
1390
|
-
e.push({ unit:
|
|
1389
|
+
const d = c.get(u), l = o.get(d) ?? i.BigNum.from_str("0"), g = a.to_hex() + D(d.name());
|
|
1390
|
+
e.push({ unit: g, quantity: l.to_str() });
|
|
1391
1391
|
}
|
|
1392
1392
|
}
|
|
1393
1393
|
}
|
|
1394
1394
|
}
|
|
1395
1395
|
return e;
|
|
1396
1396
|
}, Z = (r) => {
|
|
1397
|
-
const e = r.find((
|
|
1398
|
-
t.forEach((
|
|
1399
|
-
const o =
|
|
1400
|
-
r.filter((c) => c.unit.slice(0,
|
|
1401
|
-
o.insert(
|
|
1402
|
-
}), s.insert(Ys(
|
|
1397
|
+
const e = r.find((a) => a.unit === "lovelace"), t = Array.from(new Set(r.filter((a) => a.unit !== "lovelace").map((a) => a.unit.slice(0, O)))), s = i.MultiAsset.new();
|
|
1398
|
+
t.forEach((a) => {
|
|
1399
|
+
const o = i.Assets.new();
|
|
1400
|
+
r.filter((c) => c.unit.slice(0, O) === a).forEach((c) => {
|
|
1401
|
+
o.insert(i.AssetName.new(_(c.unit.slice(O))), i.BigNum.from_str(c.quantity));
|
|
1402
|
+
}), s.insert(Ys(a), o);
|
|
1403
1403
|
});
|
|
1404
|
-
const n =
|
|
1404
|
+
const n = i.Value.new(i.BigNum.from_str(e ? e.quantity : "0"));
|
|
1405
1405
|
return (r.length > 1 || !e) && n.set_multiasset(s), n;
|
|
1406
|
-
}, fe = (r, e, t) =>
|
|
1406
|
+
}, fe = (r, e, t) => i.BaseAddress.new(r, i.StakeCredential.from_keyhash(e), i.StakeCredential.from_keyhash(t)), Re = (r, e = "") => i.Bip32PrivateKey.from_bip39_entropy(_(r), _(Q(e))), Ht = (r) => i.DataCost.new_coins_per_byte(i.BigNum.from_str(r)), Js = (r) => {
|
|
1407
1407
|
if (typeof r != "object" || !("input" in r))
|
|
1408
|
-
return
|
|
1409
|
-
const e =
|
|
1408
|
+
return i.DatumSource.new(tt(r));
|
|
1409
|
+
const e = H(r);
|
|
1410
1410
|
if (e.output().has_plutus_data())
|
|
1411
|
-
return
|
|
1411
|
+
return i.DatumSource.new_ref_input(e.input());
|
|
1412
1412
|
throw new Error(`No inline datum found in UTxO: ${e.input().transaction_id().to_hex()}`);
|
|
1413
|
-
}, _e = (r, e) =>
|
|
1413
|
+
}, _e = (r, e) => i.EnterpriseAddress.new(r, i.StakeCredential.from_keyhash(e)), ye = (r, e) => {
|
|
1414
1414
|
if (typeof r == "string")
|
|
1415
|
-
return
|
|
1415
|
+
return i.MintWitness.new_native_script(Dt(r));
|
|
1416
1416
|
if (e === void 0)
|
|
1417
1417
|
throw new Error("Minting with plutus requires a redeemer to be defined");
|
|
1418
1418
|
if (e.tag !== "MINT")
|
|
1419
1419
|
throw new Error("Minting redeemer's tag must be defined as 'MINT'");
|
|
1420
|
-
return
|
|
1420
|
+
return i.MintWitness.new_plutus_script(Ye(r), Oe({
|
|
1421
1421
|
tag: "MINT",
|
|
1422
1422
|
index: 0,
|
|
1423
1423
|
budget: at,
|
|
@@ -1427,36 +1427,36 @@ const Ms = Ns, Hs = (r, e) => {
|
|
|
1427
1427
|
},
|
|
1428
1428
|
...e
|
|
1429
1429
|
}));
|
|
1430
|
-
}, Ft = (r, e) =>
|
|
1430
|
+
}, Ft = (r, e) => i.RewardAddress.new(r, i.StakeCredential.from_keyhash(e)), Ye = (r) => {
|
|
1431
1431
|
if ("code" in r)
|
|
1432
|
-
return
|
|
1433
|
-
const e =
|
|
1432
|
+
return i.PlutusScriptSource.new(dt(r.code, r.version));
|
|
1433
|
+
const e = H(r);
|
|
1434
1434
|
if (e.output().has_script_ref()) {
|
|
1435
1435
|
const t = e.output().script_ref();
|
|
1436
1436
|
if (t.is_plutus_script()) {
|
|
1437
1437
|
const s = Ve(t), n = dt(s.code, s.version).hash();
|
|
1438
|
-
return
|
|
1438
|
+
return i.PlutusScriptSource.new_ref_input_with_lang_ver(n, e.input(), R[s.version]);
|
|
1439
1439
|
}
|
|
1440
1440
|
}
|
|
1441
1441
|
throw new Error(`No plutus script reference found in UTxO: ${e.input().transaction_id().to_hex()}`);
|
|
1442
1442
|
}, xt = (r) => {
|
|
1443
|
-
const e =
|
|
1444
|
-
return
|
|
1445
|
-
}, Et = (r =
|
|
1446
|
-
const e =
|
|
1447
|
-
return
|
|
1443
|
+
const e = i.ScriptPubkey.new(r);
|
|
1444
|
+
return i.NativeScript.new_script_pubkey(e);
|
|
1445
|
+
}, Et = (r = k) => {
|
|
1446
|
+
const e = i.TransactionBuilderConfigBuilder.new().coins_per_utxo_byte(i.BigNum.from_str(r.coinsPerUTxOSize)).ex_unit_prices(i.ExUnitPrices.new(pe(r.priceMem.toString()), pe(r.priceStep.toString()))).fee_algo(i.LinearFee.new(i.BigNum.from_str(r.minFeeA.toString()), i.BigNum.from_str(r.minFeeB.toString()))).key_deposit(i.BigNum.from_str(r.keyDeposit)).max_tx_size(r.maxTxSize).max_value_size(parseInt(r.maxValSize, 10)).pool_deposit(i.BigNum.from_str(r.poolDeposit)).build();
|
|
1447
|
+
return i.TransactionBuilder.new(e);
|
|
1448
1448
|
}, xe = (r) => {
|
|
1449
|
-
const e =
|
|
1450
|
-
return r.map((t) => t instanceof
|
|
1449
|
+
const e = i.TxInputsBuilder.new();
|
|
1450
|
+
return r.map((t) => t instanceof i.TransactionUnspentOutput ? t : H(t)).forEach((t) => {
|
|
1451
1451
|
e.add_input(t.output().address(), t.input(), t.output().amount());
|
|
1452
1452
|
}), e;
|
|
1453
1453
|
}, Ct = (r) => {
|
|
1454
1454
|
if (typeof r == "string")
|
|
1455
|
-
return
|
|
1456
|
-
let e =
|
|
1455
|
+
return i.TransactionOutputBuilder.new().with_address(K(r));
|
|
1456
|
+
let e = i.TransactionOutputBuilder.new().with_address(K(r.address));
|
|
1457
1457
|
if (r.datum) {
|
|
1458
1458
|
const { value: t, inline: s } = r.datum, n = tt(t);
|
|
1459
|
-
e = e.with_data_hash(
|
|
1459
|
+
e = e.with_data_hash(i.hash_plutus_data(n)), s && (e = e.with_plutus_data(n));
|
|
1460
1460
|
}
|
|
1461
1461
|
if (r.script) {
|
|
1462
1462
|
const t = ht(r.script);
|
|
@@ -1464,22 +1464,22 @@ const Ms = Ns, Hs = (r, e) => {
|
|
|
1464
1464
|
}
|
|
1465
1465
|
return e;
|
|
1466
1466
|
}, et = (r) => {
|
|
1467
|
-
const e = r.slice(0,
|
|
1467
|
+
const e = r.slice(0, O), t = r.includes(".") ? Q(r.split(".")[1]) : r.slice(O);
|
|
1468
1468
|
return { policyId: e, assetName: t };
|
|
1469
|
-
}, h = (r) =>
|
|
1469
|
+
}, h = (r) => G.isAxiosError(r) ? r.response ? JSON.stringify({
|
|
1470
1470
|
data: r.response.data,
|
|
1471
1471
|
headers: r.response.headers,
|
|
1472
1472
|
status: r.response.status
|
|
1473
|
-
}) : r.request ? JSON.stringify(r.request) : r.message : JSON.stringify(r),
|
|
1473
|
+
}) : r.request ? JSON.stringify(r.request) : r.message : JSON.stringify(r), hr = (r) => {
|
|
1474
1474
|
const e = tt(r);
|
|
1475
|
-
return
|
|
1476
|
-
},
|
|
1477
|
-
if (
|
|
1478
|
-
const [t, s, n,
|
|
1479
|
-
return parseInt(
|
|
1475
|
+
return i.hash_plutus_data(e).to_hex();
|
|
1476
|
+
}, lr = (r, e = Date.now()) => {
|
|
1477
|
+
if (bt[r]) {
|
|
1478
|
+
const [t, s, n, a] = bt[r];
|
|
1479
|
+
return parseInt(i.BigNum.from_str(e.toString()).div_floor(i.BigNum.from_str("1000")).checked_sub(i.BigNum.from_str(n)).div_floor(i.BigNum.from_str(a)).checked_add(i.BigNum.from_str(t)).to_str(), 10);
|
|
1480
1480
|
}
|
|
1481
1481
|
throw new Error(`Couldn't resolve EpochNo for network: ${r}`);
|
|
1482
|
-
},
|
|
1482
|
+
}, Ws = (r, e) => Ms.fromParts(_(r), _(e)).fingerprint(), gr = (r, e) => rs[r][e], Ar = (r) => Tt(r).hash().to_hex(), it = (r) => {
|
|
1483
1483
|
var e, t;
|
|
1484
1484
|
try {
|
|
1485
1485
|
const s = [
|
|
@@ -1492,10 +1492,10 @@ const Ms = Ns, Hs = (r, e) => {
|
|
|
1492
1492
|
} catch (s) {
|
|
1493
1493
|
throw new Error(`An error occurred during resolvePaymentKeyHash: ${s}.`);
|
|
1494
1494
|
}
|
|
1495
|
-
},
|
|
1495
|
+
}, mr = (r, e = 0) => {
|
|
1496
1496
|
const t = dt(r.code, r.version);
|
|
1497
|
-
return
|
|
1498
|
-
},
|
|
1497
|
+
return i.EnterpriseAddress.new(e, i.StakeCredential.from_scripthash(t.hash())).to_address().to_bech32();
|
|
1498
|
+
}, Ir = (r) => {
|
|
1499
1499
|
try {
|
|
1500
1500
|
const e = He(r), t = e == null ? void 0 : e.payment_cred().to_scripthash();
|
|
1501
1501
|
if (t !== void 0)
|
|
@@ -1504,13 +1504,13 @@ const Ms = Ns, Hs = (r, e) => {
|
|
|
1504
1504
|
} catch (e) {
|
|
1505
1505
|
throw new Error(`An error occurred during resolveScriptHash: ${e}.`);
|
|
1506
1506
|
}
|
|
1507
|
-
},
|
|
1508
|
-
const e = we(r.join(" ")), t =
|
|
1507
|
+
}, pr = (r) => i.Ed25519KeyHash.from_hex(r).to_bech32("pool1"), fr = (r) => {
|
|
1508
|
+
const e = we(r.join(" ")), t = Re(e), s = t.to_bech32();
|
|
1509
1509
|
return t.free(), s;
|
|
1510
|
-
},
|
|
1511
|
-
if (
|
|
1512
|
-
const [t, s, n] =
|
|
1513
|
-
return
|
|
1510
|
+
}, _r = (r) => ht(r).to_hex(), yr = (r, e = Date.now()) => {
|
|
1511
|
+
if (bt[r]) {
|
|
1512
|
+
const [t, s, n] = bt[r];
|
|
1513
|
+
return i.BigNum.from_str(e.toString()).div_floor(i.BigNum.from_str("1000")).checked_sub(i.BigNum.from_str(n)).checked_add(i.BigNum.from_str(s)).to_str();
|
|
1514
1514
|
}
|
|
1515
1515
|
throw new Error(`Couldn't resolve SlotNo for network: ${r}`);
|
|
1516
1516
|
}, Ut = (r) => {
|
|
@@ -1522,7 +1522,7 @@ const Ms = Ns, Hs = (r, e) => {
|
|
|
1522
1522
|
} catch (e) {
|
|
1523
1523
|
throw new Error(`An error occurred during resolveRewardAddress: ${e}.`);
|
|
1524
1524
|
}
|
|
1525
|
-
},
|
|
1525
|
+
}, At = (r) => {
|
|
1526
1526
|
var e, t;
|
|
1527
1527
|
try {
|
|
1528
1528
|
const s = [
|
|
@@ -1535,37 +1535,37 @@ const Ms = Ns, Hs = (r, e) => {
|
|
|
1535
1535
|
} catch (s) {
|
|
1536
1536
|
throw new Error(`An error occurred during resolveStakeKeyHash: ${s}.`);
|
|
1537
1537
|
}
|
|
1538
|
-
}, Le = (r, e =
|
|
1539
|
-
const e =
|
|
1540
|
-
return
|
|
1541
|
-
},
|
|
1538
|
+
}, Le = (r, e = k.minFeeA, t = k.minFeeB) => (BigInt(e) * BigInt(r) + BigInt(t)).toString(), js = (r) => {
|
|
1539
|
+
const e = L(r).body();
|
|
1540
|
+
return i.hash_transaction(e).to_hex();
|
|
1541
|
+
}, xr = (r = "", e = 32) => {
|
|
1542
1542
|
if (e <= 0 || e > 2048)
|
|
1543
1543
|
throw new Error("Length must be bewteen 1 and 2048");
|
|
1544
1544
|
const s = Ce("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")(e);
|
|
1545
|
-
return
|
|
1545
|
+
return Q(`${r}${s}`);
|
|
1546
1546
|
}, Ge = (r, e) => {
|
|
1547
1547
|
const t = r.vkeys();
|
|
1548
1548
|
if (t !== void 0) {
|
|
1549
1549
|
const s = /* @__PURE__ */ new Set();
|
|
1550
|
-
for (let
|
|
1551
|
-
s.add(t.get(
|
|
1552
|
-
for (let
|
|
1553
|
-
s.add(e.get(
|
|
1554
|
-
const n =
|
|
1555
|
-
return s.forEach((
|
|
1556
|
-
n.add(
|
|
1550
|
+
for (let a = 0; a < t.len(); a += 1)
|
|
1551
|
+
s.add(t.get(a).to_hex());
|
|
1552
|
+
for (let a = 0; a < e.len(); a += 1)
|
|
1553
|
+
s.add(e.get(a).to_hex());
|
|
1554
|
+
const n = i.Vkeywitnesses.new();
|
|
1555
|
+
return s.forEach((a) => {
|
|
1556
|
+
n.add(i.Vkeywitness.from_hex(a));
|
|
1557
1557
|
}), n;
|
|
1558
1558
|
}
|
|
1559
1559
|
return e;
|
|
1560
|
-
},
|
|
1561
|
-
class
|
|
1560
|
+
}, Cr = (r) => St(Ke(r)), wr = (r) => L(r).to_js_value();
|
|
1561
|
+
class Br {
|
|
1562
1562
|
_axiosInstance;
|
|
1563
1563
|
constructor(...e) {
|
|
1564
1564
|
if (typeof e[0] == "string" && e[0].startsWith("http"))
|
|
1565
|
-
this._axiosInstance =
|
|
1565
|
+
this._axiosInstance = G.create({ baseURL: e[0] });
|
|
1566
1566
|
else {
|
|
1567
1567
|
const t = e[0], s = t.slice(0, 7);
|
|
1568
|
-
this._axiosInstance =
|
|
1568
|
+
this._axiosInstance = G.create({
|
|
1569
1569
|
baseURL: `https://cardano-${s}.blockfrost.io/api/v${e[1] ?? 0}`,
|
|
1570
1570
|
headers: { project_id: t }
|
|
1571
1571
|
});
|
|
@@ -1616,24 +1616,24 @@ class Cr {
|
|
|
1616
1616
|
}
|
|
1617
1617
|
});
|
|
1618
1618
|
async fetchAddressUTxOs(e, t) {
|
|
1619
|
-
const s = t !== void 0 ? `/${t}` : "", n = `addresses/${e}/utxos` + s,
|
|
1619
|
+
const s = t !== void 0 ? `/${t}` : "", n = `addresses/${e}/utxos` + s, a = async (o = 1, c = []) => {
|
|
1620
1620
|
const { data: u, status: d } = await this._axiosInstance.get(`${n}?page=${o}`);
|
|
1621
1621
|
if (d === 200)
|
|
1622
|
-
return u.length > 0 ?
|
|
1622
|
+
return u.length > 0 ? a(o + 1, [
|
|
1623
1623
|
...c,
|
|
1624
|
-
...await Promise.all(u.map((
|
|
1624
|
+
...await Promise.all(u.map((l) => this.toUTxO(l, l.tx_hash)))
|
|
1625
1625
|
]) : c;
|
|
1626
1626
|
throw h(u);
|
|
1627
1627
|
};
|
|
1628
1628
|
try {
|
|
1629
|
-
return await
|
|
1629
|
+
return await a();
|
|
1630
1630
|
} catch {
|
|
1631
1631
|
return [];
|
|
1632
1632
|
}
|
|
1633
1633
|
}
|
|
1634
1634
|
async fetchAssetAddresses(e) {
|
|
1635
1635
|
const t = async (s = 1, n = []) => {
|
|
1636
|
-
const { policyId:
|
|
1636
|
+
const { policyId: a, assetName: o } = et(e), { data: c, status: u } = await this._axiosInstance.get(`assets/${a}${o}/addresses?page=${s}`);
|
|
1637
1637
|
if (u === 200)
|
|
1638
1638
|
return c.length > 0 ? t(s + 1, [...n, ...c]) : n;
|
|
1639
1639
|
throw h(c);
|
|
@@ -1646,8 +1646,8 @@ class Cr {
|
|
|
1646
1646
|
}
|
|
1647
1647
|
async fetchAssetMetadata(e) {
|
|
1648
1648
|
try {
|
|
1649
|
-
const { policyId: t, assetName: s } = et(e), { data: n, status:
|
|
1650
|
-
if (
|
|
1649
|
+
const { policyId: t, assetName: s } = et(e), { data: n, status: a } = await this._axiosInstance.get(`assets/${t}${s}`);
|
|
1650
|
+
if (a === 200)
|
|
1651
1651
|
return {
|
|
1652
1652
|
...n.onchain_metadata
|
|
1653
1653
|
};
|
|
@@ -1687,9 +1687,9 @@ class Cr {
|
|
|
1687
1687
|
const { data: s, status: n } = await this._axiosInstance.get(`assets/policy/${e}?page=${t}`);
|
|
1688
1688
|
if (n === 200)
|
|
1689
1689
|
return {
|
|
1690
|
-
assets: s.map((
|
|
1691
|
-
unit:
|
|
1692
|
-
quantity:
|
|
1690
|
+
assets: s.map((a) => ({
|
|
1691
|
+
unit: a.asset,
|
|
1692
|
+
quantity: a.quantity
|
|
1693
1693
|
})),
|
|
1694
1694
|
next: s.length === 100 ? t + 1 : null
|
|
1695
1695
|
};
|
|
@@ -1700,7 +1700,7 @@ class Cr {
|
|
|
1700
1700
|
}
|
|
1701
1701
|
async fetchHandleAddress(e) {
|
|
1702
1702
|
try {
|
|
1703
|
-
const t =
|
|
1703
|
+
const t = Q(e.replace("$", "")), { data: s, status: n } = await this._axiosInstance.get(`assets/${Vt[1]}${t}/addresses`);
|
|
1704
1704
|
if (n === 200)
|
|
1705
1705
|
return s[0].address;
|
|
1706
1706
|
throw h(s);
|
|
@@ -1763,10 +1763,10 @@ class Cr {
|
|
|
1763
1763
|
try {
|
|
1764
1764
|
const { data: t, status: s } = await this._axiosInstance.get(`txs/${e}/utxos`);
|
|
1765
1765
|
if (s === 200) {
|
|
1766
|
-
const n = t.outputs,
|
|
1766
|
+
const n = t.outputs, a = [];
|
|
1767
1767
|
return n.forEach((c) => {
|
|
1768
|
-
|
|
1769
|
-
}), await Promise.all(
|
|
1768
|
+
a.push(this.toUTxO(c, e));
|
|
1769
|
+
}), await Promise.all(a);
|
|
1770
1770
|
}
|
|
1771
1771
|
throw h(t);
|
|
1772
1772
|
} catch (t) {
|
|
@@ -1775,10 +1775,10 @@ class Cr {
|
|
|
1775
1775
|
}
|
|
1776
1776
|
onTxConfirmed(e, t, s = 100) {
|
|
1777
1777
|
let n = 0;
|
|
1778
|
-
const
|
|
1779
|
-
n >= s && clearInterval(
|
|
1778
|
+
const a = setInterval(() => {
|
|
1779
|
+
n >= s && clearInterval(a), this.fetchTxInfo(e).then((o) => {
|
|
1780
1780
|
this.fetchBlockInfo(o.block).then((c) => {
|
|
1781
|
-
(c == null ? void 0 : c.confirmations) > 0 && (clearInterval(
|
|
1781
|
+
(c == null ? void 0 : c.confirmations) > 0 && (clearInterval(a), t());
|
|
1782
1782
|
}).catch(() => {
|
|
1783
1783
|
n += 1;
|
|
1784
1784
|
});
|
|
@@ -1789,7 +1789,7 @@ class Cr {
|
|
|
1789
1789
|
}
|
|
1790
1790
|
async submitTx(e) {
|
|
1791
1791
|
try {
|
|
1792
|
-
const t = { "Content-Type": "application/cbor" }, { data: s, status: n } = await this._axiosInstance.post("tx/submit",
|
|
1792
|
+
const t = { "Content-Type": "application/cbor" }, { data: s, status: n } = await this._axiosInstance.post("tx/submit", _(e), { headers: t });
|
|
1793
1793
|
if (n === 200)
|
|
1794
1794
|
return s;
|
|
1795
1795
|
throw h(s);
|
|
@@ -1810,19 +1810,19 @@ class Cr {
|
|
|
1810
1810
|
throw h(t);
|
|
1811
1811
|
}
|
|
1812
1812
|
}
|
|
1813
|
-
class
|
|
1813
|
+
class Sr {
|
|
1814
1814
|
_axiosInstance;
|
|
1815
1815
|
constructor(e, t, s) {
|
|
1816
|
-
const n = s.host ?? "ipfs.infura.io",
|
|
1817
|
-
this._axiosInstance =
|
|
1818
|
-
baseURL: `https://${n}:${
|
|
1816
|
+
const n = s.host ?? "ipfs.infura.io", a = s.port ?? 5001, o = s.version ?? 0;
|
|
1817
|
+
this._axiosInstance = G.create({
|
|
1818
|
+
baseURL: `https://${n}:${a}/api/v${o}`,
|
|
1819
1819
|
auth: { username: e, password: t }
|
|
1820
1820
|
});
|
|
1821
1821
|
}
|
|
1822
1822
|
async uploadContent(e, t = !1) {
|
|
1823
1823
|
try {
|
|
1824
|
-
const s = { "Content-Type": "multipart/form-data" }, { data: n, status:
|
|
1825
|
-
if (
|
|
1824
|
+
const s = { "Content-Type": "multipart/form-data" }, { data: n, status: a } = await this._axiosInstance.post(`add?recursive=${t}`, e, { headers: s });
|
|
1825
|
+
if (a === 200)
|
|
1826
1826
|
return n;
|
|
1827
1827
|
throw h(n);
|
|
1828
1828
|
} catch (s) {
|
|
@@ -1830,15 +1830,15 @@ class wr {
|
|
|
1830
1830
|
}
|
|
1831
1831
|
}
|
|
1832
1832
|
}
|
|
1833
|
-
class
|
|
1833
|
+
class Er {
|
|
1834
1834
|
_axiosInstance;
|
|
1835
1835
|
constructor(...e) {
|
|
1836
|
-
typeof e[0] == "string" && e[0].startsWith("http") ? this._axiosInstance =
|
|
1836
|
+
typeof e[0] == "string" && e[0].startsWith("http") ? this._axiosInstance = G.create({
|
|
1837
1837
|
baseURL: e[0],
|
|
1838
1838
|
headers: {
|
|
1839
1839
|
Authorization: `Bearer ${e[1]}`
|
|
1840
1840
|
}
|
|
1841
|
-
}) : this._axiosInstance =
|
|
1841
|
+
}) : this._axiosInstance = G.create({
|
|
1842
1842
|
baseURL: `https://${e[0]}.koios.rest/api/v${e[2] ?? 0}`,
|
|
1843
1843
|
headers: {
|
|
1844
1844
|
Authorization: `Bearer ${e[1]}`
|
|
@@ -1869,8 +1869,8 @@ class Br {
|
|
|
1869
1869
|
_addresses: [e]
|
|
1870
1870
|
});
|
|
1871
1871
|
if (n === 200) {
|
|
1872
|
-
const
|
|
1873
|
-
return t !== void 0 ?
|
|
1872
|
+
const a = s.flatMap((o) => o.utxo_set).map((o) => this.toUTxO(o, e));
|
|
1873
|
+
return t !== void 0 ? a.filter((o) => o.output.amount.find((c) => c.unit === t) !== void 0) : a;
|
|
1874
1874
|
}
|
|
1875
1875
|
throw h(s);
|
|
1876
1876
|
} catch {
|
|
@@ -1879,8 +1879,8 @@ class Br {
|
|
|
1879
1879
|
}
|
|
1880
1880
|
async fetchAssetAddresses(e) {
|
|
1881
1881
|
try {
|
|
1882
|
-
const { policyId: t, assetName: s } = et(e), { data: n, status:
|
|
1883
|
-
if (
|
|
1882
|
+
const { policyId: t, assetName: s } = et(e), { data: n, status: a } = await this._axiosInstance.get(`asset_address_list?_asset_policy=${t}&_asset_name=${s}`);
|
|
1883
|
+
if (a === 200)
|
|
1884
1884
|
return n.map((o) => ({
|
|
1885
1885
|
address: o.payment_address,
|
|
1886
1886
|
quantity: o.quantity
|
|
@@ -1892,8 +1892,8 @@ class Br {
|
|
|
1892
1892
|
}
|
|
1893
1893
|
async fetchAssetMetadata(e) {
|
|
1894
1894
|
try {
|
|
1895
|
-
const { policyId: t, assetName: s } = et(e), { data: n, status:
|
|
1896
|
-
if (
|
|
1895
|
+
const { policyId: t, assetName: s } = et(e), { data: n, status: a } = await this._axiosInstance.get(`asset_info?_asset_policy=${t}&_asset_name=${s}`);
|
|
1896
|
+
if (a === 200)
|
|
1897
1897
|
return {
|
|
1898
1898
|
...n[0].minting_tx_metadata[721][t][Gt(s)]
|
|
1899
1899
|
};
|
|
@@ -1935,9 +1935,9 @@ class Br {
|
|
|
1935
1935
|
const { data: s, status: n } = await this._axiosInstance.get(`asset_policy_info?_asset_policy=${e}&limit=100&offset=${t}`);
|
|
1936
1936
|
if (n === 200)
|
|
1937
1937
|
return {
|
|
1938
|
-
assets: s.map((
|
|
1939
|
-
unit: `${e}${
|
|
1940
|
-
quantity:
|
|
1938
|
+
assets: s.map((a) => ({
|
|
1939
|
+
unit: `${e}${a.asset_name}`,
|
|
1940
|
+
quantity: a.total_supply
|
|
1941
1941
|
})),
|
|
1942
1942
|
next: s.length === 100 ? t + 100 : null
|
|
1943
1943
|
};
|
|
@@ -1948,7 +1948,7 @@ class Br {
|
|
|
1948
1948
|
}
|
|
1949
1949
|
async fetchHandleAddress(e) {
|
|
1950
1950
|
try {
|
|
1951
|
-
const t =
|
|
1951
|
+
const t = Q(e.replace("$", "")), { data: s, status: n } = await this._axiosInstance.get(`asset_address_list?_asset_policy=${Vt[1]}&_asset_name=${t}`);
|
|
1952
1952
|
if (n === 200)
|
|
1953
1953
|
return s[0].payment_address;
|
|
1954
1954
|
throw h(s);
|
|
@@ -1990,10 +1990,10 @@ class Br {
|
|
|
1990
1990
|
async fetchTxInfo(e) {
|
|
1991
1991
|
var t, s;
|
|
1992
1992
|
try {
|
|
1993
|
-
const { data: n, status:
|
|
1993
|
+
const { data: n, status: a } = await this._axiosInstance.post("tx_info", {
|
|
1994
1994
|
_tx_hashes: [e]
|
|
1995
1995
|
});
|
|
1996
|
-
if (
|
|
1996
|
+
if (a === 200)
|
|
1997
1997
|
return {
|
|
1998
1998
|
block: n[0].block_hash,
|
|
1999
1999
|
deposit: n[0].deposit,
|
|
@@ -2017,7 +2017,7 @@ class Br {
|
|
|
2017
2017
|
_tx_hashes: [e]
|
|
2018
2018
|
});
|
|
2019
2019
|
if (s === 200)
|
|
2020
|
-
return console.log(t[0]), t[0].outputs.map((
|
|
2020
|
+
return console.log(t[0]), t[0].outputs.map((a) => this.toUTxO(a, a.payment_addr.bech32));
|
|
2021
2021
|
throw h(t);
|
|
2022
2022
|
} catch (t) {
|
|
2023
2023
|
throw h(t);
|
|
@@ -2025,10 +2025,10 @@ class Br {
|
|
|
2025
2025
|
}
|
|
2026
2026
|
onTxConfirmed(e, t, s = 100) {
|
|
2027
2027
|
let n = 0;
|
|
2028
|
-
const
|
|
2029
|
-
n >= s && clearInterval(
|
|
2028
|
+
const a = setInterval(() => {
|
|
2029
|
+
n >= s && clearInterval(a), this.fetchTxInfo(e).then((o) => {
|
|
2030
2030
|
this.fetchBlockInfo(o.block).then((c) => {
|
|
2031
|
-
(c == null ? void 0 : c.confirmations) > 0 && (clearInterval(
|
|
2031
|
+
(c == null ? void 0 : c.confirmations) > 0 && (clearInterval(a), t());
|
|
2032
2032
|
}).catch(() => {
|
|
2033
2033
|
n += 1;
|
|
2034
2034
|
});
|
|
@@ -2039,7 +2039,7 @@ class Br {
|
|
|
2039
2039
|
}
|
|
2040
2040
|
async submitTx(e) {
|
|
2041
2041
|
try {
|
|
2042
|
-
const t = { "Content-Type": "application/cbor" }, { data: s, status: n } = await this._axiosInstance.post("submittx",
|
|
2042
|
+
const t = { "Content-Type": "application/cbor" }, { data: s, status: n } = await this._axiosInstance.post("submittx", _(e), { headers: t });
|
|
2043
2043
|
if (n === 202)
|
|
2044
2044
|
return s;
|
|
2045
2045
|
throw h(s);
|
|
@@ -2058,9 +2058,9 @@ class Br {
|
|
|
2058
2058
|
address: t,
|
|
2059
2059
|
amount: [
|
|
2060
2060
|
{ unit: "lovelace", quantity: e.value },
|
|
2061
|
-
...e.asset_list.map((
|
|
2062
|
-
unit: `${
|
|
2063
|
-
quantity: `${
|
|
2061
|
+
...e.asset_list.map((a) => ({
|
|
2062
|
+
unit: `${a.policy_id}${a.asset_name}`,
|
|
2063
|
+
quantity: `${a.quantity}`
|
|
2064
2064
|
}))
|
|
2065
2065
|
],
|
|
2066
2066
|
dataHash: e.datum_hash ?? void 0,
|
|
@@ -2080,7 +2080,7 @@ class Br {
|
|
|
2080
2080
|
}
|
|
2081
2081
|
};
|
|
2082
2082
|
}
|
|
2083
|
-
class
|
|
2083
|
+
class br {
|
|
2084
2084
|
_baseUrl;
|
|
2085
2085
|
constructor(...e) {
|
|
2086
2086
|
this._baseUrl = es(e[0]) ? ns[e[0]] : e[0];
|
|
@@ -2090,9 +2090,9 @@ class Sr {
|
|
|
2090
2090
|
return this.send(t, "EvaluateTx", {
|
|
2091
2091
|
evaluate: e
|
|
2092
2092
|
}), new Promise((s, n) => {
|
|
2093
|
-
t.addEventListener("message", (
|
|
2093
|
+
t.addEventListener("message", (a) => {
|
|
2094
2094
|
try {
|
|
2095
|
-
const { result: o } = JSON.parse(
|
|
2095
|
+
const { result: o } = JSON.parse(a.data);
|
|
2096
2096
|
o.EvaluationResult ? s(Object.keys(o.EvaluationResult).map((c) => ({
|
|
2097
2097
|
index: parseInt(c.split(":")[1], 10),
|
|
2098
2098
|
tag: c.split(":")[0].toUpperCase(),
|
|
@@ -2121,9 +2121,9 @@ class Sr {
|
|
|
2121
2121
|
return this.send(t, "SubmitTx", {
|
|
2122
2122
|
submit: e
|
|
2123
2123
|
}), new Promise((s, n) => {
|
|
2124
|
-
t.addEventListener("message", (
|
|
2124
|
+
t.addEventListener("message", (a) => {
|
|
2125
2125
|
try {
|
|
2126
|
-
const { result: o } = JSON.parse(
|
|
2126
|
+
const { result: o } = JSON.parse(a.data);
|
|
2127
2127
|
o.SubmitSuccess ? s(o.SubmitSuccess.txId) : n(o.SubmitFail), t.close();
|
|
2128
2128
|
} catch (o) {
|
|
2129
2129
|
n(o);
|
|
@@ -2147,10 +2147,10 @@ class Sr {
|
|
|
2147
2147
|
}));
|
|
2148
2148
|
}
|
|
2149
2149
|
}
|
|
2150
|
-
class
|
|
2150
|
+
class Qr {
|
|
2151
2151
|
_axiosInstance;
|
|
2152
2152
|
constructor(e, t, s, n = 1) {
|
|
2153
|
-
this._axiosInstance =
|
|
2153
|
+
this._axiosInstance = G.create({
|
|
2154
2154
|
baseURL: `https://cardano-${e}.tangocrypto.com/${t}/v${n}`,
|
|
2155
2155
|
headers: { "x-api-key": s }
|
|
2156
2156
|
});
|
|
@@ -2189,36 +2189,36 @@ class Er {
|
|
|
2189
2189
|
}
|
|
2190
2190
|
}
|
|
2191
2191
|
async fetchAddressUTxOs(e, t) {
|
|
2192
|
-
const s = t !== void 0 ? `/assets/${t}` : "", n = `addresses/${e}${s}/utxos?size=50`,
|
|
2193
|
-
var
|
|
2194
|
-
const { data:
|
|
2195
|
-
if (
|
|
2196
|
-
return
|
|
2197
|
-
throw h(
|
|
2198
|
-
}, o = (d,
|
|
2199
|
-
const
|
|
2192
|
+
const s = t !== void 0 ? `/assets/${t}` : "", n = `addresses/${e}${s}/utxos?size=50`, a = async (d = "", l = []) => {
|
|
2193
|
+
var m;
|
|
2194
|
+
const { data: g, status: A } = await this._axiosInstance.get(`${n}&cursor=${d}`);
|
|
2195
|
+
if (A === 200)
|
|
2196
|
+
return g.cursor !== null && ((m = g.cursor) == null ? void 0 : m.length) > 0 ? a(g.cursor, [...l, ...g.data.map(u)]) : g.data.map(u);
|
|
2197
|
+
throw h(g);
|
|
2198
|
+
}, o = (d, l) => {
|
|
2199
|
+
const g = [
|
|
2200
2200
|
{
|
|
2201
2201
|
unit: "lovelace",
|
|
2202
2202
|
quantity: d.toString()
|
|
2203
2203
|
}
|
|
2204
2204
|
];
|
|
2205
|
-
return
|
|
2206
|
-
const
|
|
2207
|
-
|
|
2208
|
-
unit: `${
|
|
2209
|
-
quantity:
|
|
2205
|
+
return l.forEach((A) => {
|
|
2206
|
+
const m = Q(A.asset_name);
|
|
2207
|
+
g.push({
|
|
2208
|
+
unit: `${A.policy_id}${m}`,
|
|
2209
|
+
quantity: A.quantity.toString()
|
|
2210
2210
|
});
|
|
2211
|
-
}),
|
|
2211
|
+
}), g;
|
|
2212
2212
|
}, c = (d) => {
|
|
2213
2213
|
if (d) {
|
|
2214
|
-
const
|
|
2214
|
+
const l = d.type.startsWith("plutus") ? {
|
|
2215
2215
|
code: d.code,
|
|
2216
2216
|
version: d.type.replace("plutus", "")
|
|
2217
2217
|
} : kt(Dt(d.json));
|
|
2218
|
-
return ht(
|
|
2218
|
+
return ht(l).to_hex();
|
|
2219
2219
|
}
|
|
2220
2220
|
}, u = (d) => {
|
|
2221
|
-
var
|
|
2221
|
+
var l;
|
|
2222
2222
|
return {
|
|
2223
2223
|
input: {
|
|
2224
2224
|
outputIndex: d.index,
|
|
@@ -2228,13 +2228,13 @@ class Er {
|
|
|
2228
2228
|
address: e,
|
|
2229
2229
|
amount: o(d.value, d.assets),
|
|
2230
2230
|
dataHash: void 0,
|
|
2231
|
-
plutusData: ((
|
|
2231
|
+
plutusData: ((l = d.inline_datum) == null ? void 0 : l.value_raw) ?? void 0,
|
|
2232
2232
|
scriptRef: c(d.reference_script)
|
|
2233
2233
|
}
|
|
2234
2234
|
};
|
|
2235
2235
|
};
|
|
2236
2236
|
try {
|
|
2237
|
-
return await
|
|
2237
|
+
return await a();
|
|
2238
2238
|
} catch {
|
|
2239
2239
|
return [];
|
|
2240
2240
|
}
|
|
@@ -2243,12 +2243,12 @@ class Er {
|
|
|
2243
2243
|
const t = (n) => ({
|
|
2244
2244
|
address: n.address,
|
|
2245
2245
|
quantity: n.quantity.toString()
|
|
2246
|
-
}), s = async (n = "",
|
|
2247
|
-
var
|
|
2246
|
+
}), s = async (n = "", a = []) => {
|
|
2247
|
+
var l;
|
|
2248
2248
|
const { policyId: o, assetName: c } = et(e), { data: u, status: d } = await this._axiosInstance.get(`assets/${o}${c}/addresses?size=100&cursor=${n}`);
|
|
2249
2249
|
if (d === 200)
|
|
2250
|
-
return u.cursor !== null && ((
|
|
2251
|
-
...
|
|
2250
|
+
return u.cursor !== null && ((l = u.cursor) == null ? void 0 : l.length) > 0 ? s(u.cursor, [
|
|
2251
|
+
...a,
|
|
2252
2252
|
...u.data.map(t)
|
|
2253
2253
|
]) : u.data.map(t);
|
|
2254
2254
|
throw h(u);
|
|
@@ -2262,12 +2262,12 @@ class Er {
|
|
|
2262
2262
|
async fetchAssetMetadata(e) {
|
|
2263
2263
|
var t;
|
|
2264
2264
|
try {
|
|
2265
|
-
const { policyId: s, assetName: n } = et(e), { data:
|
|
2265
|
+
const { policyId: s, assetName: n } = et(e), { data: a, status: o } = await this._axiosInstance.get(`assets/${s}${n}`);
|
|
2266
2266
|
if (o === 200)
|
|
2267
2267
|
return {
|
|
2268
|
-
...(t =
|
|
2268
|
+
...(t = a.metadata.find((c) => c.label === 721)) == null ? void 0 : t.json[s][Gt(n)]
|
|
2269
2269
|
};
|
|
2270
|
-
throw h(
|
|
2270
|
+
throw h(a);
|
|
2271
2271
|
} catch (s) {
|
|
2272
2272
|
throw h(s);
|
|
2273
2273
|
}
|
|
@@ -2303,9 +2303,9 @@ class Er {
|
|
|
2303
2303
|
const { data: s, status: n } = await this._axiosInstance.get(`policies/${e}/assets?size=100&cursor=${t}`);
|
|
2304
2304
|
if (n === 200)
|
|
2305
2305
|
return {
|
|
2306
|
-
assets: s.data.map((
|
|
2307
|
-
unit: `${
|
|
2308
|
-
quantity:
|
|
2306
|
+
assets: s.data.map((a) => ({
|
|
2307
|
+
unit: `${a.policy_id}${a.asset_name}`,
|
|
2308
|
+
quantity: a.quantity
|
|
2309
2309
|
})),
|
|
2310
2310
|
next: s.cursor
|
|
2311
2311
|
};
|
|
@@ -2316,7 +2316,7 @@ class Er {
|
|
|
2316
2316
|
}
|
|
2317
2317
|
async fetchHandleAddress(e) {
|
|
2318
2318
|
try {
|
|
2319
|
-
const t =
|
|
2319
|
+
const t = Q(e.replace("$", "")), { data: s, status: n } = await this._axiosInstance.get(`assets/${Vt[1]}${t}/addresses`);
|
|
2320
2320
|
if (n === 200)
|
|
2321
2321
|
return s.data[0].address;
|
|
2322
2322
|
throw h(s);
|
|
@@ -2384,10 +2384,10 @@ class Er {
|
|
|
2384
2384
|
}
|
|
2385
2385
|
onTxConfirmed(e, t, s = 100) {
|
|
2386
2386
|
let n = 0;
|
|
2387
|
-
const
|
|
2388
|
-
n >= s && clearInterval(
|
|
2387
|
+
const a = setInterval(() => {
|
|
2388
|
+
n >= s && clearInterval(a), this.fetchTxInfo(e).then((o) => {
|
|
2389
2389
|
this.fetchBlockInfo(o.block).then((c) => {
|
|
2390
|
-
(c == null ? void 0 : c.confirmations) > 0 && (clearInterval(
|
|
2390
|
+
(c == null ? void 0 : c.confirmations) > 0 && (clearInterval(a), t());
|
|
2391
2391
|
}).catch(() => {
|
|
2392
2392
|
n += 1;
|
|
2393
2393
|
});
|
|
@@ -2407,7 +2407,7 @@ class Er {
|
|
|
2407
2407
|
}
|
|
2408
2408
|
}
|
|
2409
2409
|
}
|
|
2410
|
-
class
|
|
2410
|
+
class vr {
|
|
2411
2411
|
_axiosInstance;
|
|
2412
2412
|
_amountsAsStrings = {
|
|
2413
2413
|
headers: {
|
|
@@ -2416,7 +2416,7 @@ class Qr {
|
|
|
2416
2416
|
};
|
|
2417
2417
|
submitUrl;
|
|
2418
2418
|
constructor({ network: e, apiKey: t, turboSubmit: s = !1 }) {
|
|
2419
|
-
this._axiosInstance =
|
|
2419
|
+
this._axiosInstance = G.create({
|
|
2420
2420
|
baseURL: `https://${e}.gomaestro-api.org/v1`,
|
|
2421
2421
|
headers: { "api-key": t }
|
|
2422
2422
|
}), this.submitUrl = s ? "txmanager/turbosubmit" : "txmanager";
|
|
@@ -2446,13 +2446,13 @@ class Qr {
|
|
|
2446
2446
|
try {
|
|
2447
2447
|
const { data: s, status: n } = await this._axiosInstance.get(`accounts/${t}`, this._amountsAsStrings);
|
|
2448
2448
|
if (n === 200) {
|
|
2449
|
-
const
|
|
2449
|
+
const a = s.data;
|
|
2450
2450
|
return {
|
|
2451
|
-
poolId:
|
|
2452
|
-
active:
|
|
2453
|
-
balance:
|
|
2454
|
-
rewards:
|
|
2455
|
-
withdrawals:
|
|
2451
|
+
poolId: a.delegated_pool,
|
|
2452
|
+
active: a.registered,
|
|
2453
|
+
balance: a.total_balance,
|
|
2454
|
+
rewards: a.rewards_available,
|
|
2455
|
+
withdrawals: a.total_withdrawn
|
|
2456
2456
|
};
|
|
2457
2457
|
}
|
|
2458
2458
|
throw h(s);
|
|
@@ -2461,29 +2461,29 @@ class Qr {
|
|
|
2461
2461
|
}
|
|
2462
2462
|
}
|
|
2463
2463
|
async fetchAddressUTxOs(e, t) {
|
|
2464
|
-
const s = (() => e.startsWith("addr_vkh") || e.startsWith("addr_shared_vkh") ? `addresses/cred/${e}` : `addresses/${e}`)(), n = t ? `&asset=${t}` : "",
|
|
2465
|
-
const u = o === null ? "" : `&cursor=${o}`, { data: d, status:
|
|
2466
|
-
if (
|
|
2467
|
-
const
|
|
2468
|
-
return
|
|
2464
|
+
const s = (() => e.startsWith("addr_vkh") || e.startsWith("addr_shared_vkh") ? `addresses/cred/${e}` : `addresses/${e}`)(), n = t ? `&asset=${t}` : "", a = async (o = null, c = []) => {
|
|
2465
|
+
const u = o === null ? "" : `&cursor=${o}`, { data: d, status: l } = await this._axiosInstance.get(`${s}/utxos?count=100${n}${u}`, this._amountsAsStrings);
|
|
2466
|
+
if (l === 200) {
|
|
2467
|
+
const A = d.data.map(this.toUTxO), m = [...c, ...A], p = d.next_cursor;
|
|
2468
|
+
return p == null ? m : a(p, m);
|
|
2469
2469
|
}
|
|
2470
2470
|
throw h(d);
|
|
2471
2471
|
};
|
|
2472
2472
|
try {
|
|
2473
|
-
return await
|
|
2473
|
+
return await a();
|
|
2474
2474
|
} catch {
|
|
2475
2475
|
return [];
|
|
2476
2476
|
}
|
|
2477
2477
|
}
|
|
2478
2478
|
async fetchAssetAddresses(e) {
|
|
2479
|
-
const { policyId: t, assetName: s } = et(e), n = async (
|
|
2480
|
-
const c =
|
|
2479
|
+
const { policyId: t, assetName: s } = et(e), n = async (a = null, o = []) => {
|
|
2480
|
+
const c = a === null ? "" : `&cursor=${a}`, { data: u, status: d } = await this._axiosInstance.get(`assets/${t}${s}/addresses?count=100${c}`, this._amountsAsStrings);
|
|
2481
2481
|
if (d === 200) {
|
|
2482
|
-
const
|
|
2482
|
+
const g = u.data.map((p) => ({ address: p.address, quantity: p.amount })), A = u.next_cursor, m = [
|
|
2483
2483
|
...o,
|
|
2484
|
-
...
|
|
2484
|
+
...g
|
|
2485
2485
|
];
|
|
2486
|
-
return
|
|
2486
|
+
return A == null ? m : n(A, m);
|
|
2487
2487
|
}
|
|
2488
2488
|
throw h(u);
|
|
2489
2489
|
};
|
|
@@ -2495,8 +2495,8 @@ class Qr {
|
|
|
2495
2495
|
}
|
|
2496
2496
|
async fetchAssetMetadata(e) {
|
|
2497
2497
|
try {
|
|
2498
|
-
const { policyId: t, assetName: s } = et(e), { data: n, status:
|
|
2499
|
-
if (
|
|
2498
|
+
const { policyId: t, assetName: s } = et(e), { data: n, status: a } = await this._axiosInstance.get(`assets/${t}${s}`);
|
|
2499
|
+
if (a === 200) {
|
|
2500
2500
|
const o = n.data;
|
|
2501
2501
|
return {
|
|
2502
2502
|
...o.asset_standards.cip25_metadata,
|
|
@@ -2513,23 +2513,23 @@ class Qr {
|
|
|
2513
2513
|
try {
|
|
2514
2514
|
const { data: s, status: n } = await this._axiosInstance.get(`blocks/${e}`, this._amountsAsStrings);
|
|
2515
2515
|
if (n === 200) {
|
|
2516
|
-
const
|
|
2516
|
+
const a = s.data;
|
|
2517
2517
|
return {
|
|
2518
|
-
confirmations:
|
|
2519
|
-
epoch:
|
|
2520
|
-
epochSlot:
|
|
2521
|
-
fees:
|
|
2522
|
-
hash:
|
|
2523
|
-
nextBlock:
|
|
2524
|
-
operationalCertificate: (t =
|
|
2525
|
-
output:
|
|
2526
|
-
previousBlock:
|
|
2527
|
-
size:
|
|
2528
|
-
slot:
|
|
2529
|
-
slotLeader:
|
|
2530
|
-
time: Date.parse(
|
|
2531
|
-
txCount:
|
|
2532
|
-
VRFKey:
|
|
2518
|
+
confirmations: a.confirmations,
|
|
2519
|
+
epoch: a.epoch,
|
|
2520
|
+
epochSlot: a.epoch_slot.toString(),
|
|
2521
|
+
fees: a.total_fees,
|
|
2522
|
+
hash: a.hash,
|
|
2523
|
+
nextBlock: a.next_block ?? "",
|
|
2524
|
+
operationalCertificate: (t = a.operational_certificate) == null ? void 0 : t.hot_vkey,
|
|
2525
|
+
output: a.total_output_lovelace ?? "0",
|
|
2526
|
+
previousBlock: a.previous_block,
|
|
2527
|
+
size: a.size,
|
|
2528
|
+
slot: a.absolute_slot.toString(),
|
|
2529
|
+
slotLeader: a.block_producer ?? "",
|
|
2530
|
+
time: Date.parse(a.timestamp) / 1e3,
|
|
2531
|
+
txCount: a.tx_hashes.length,
|
|
2532
|
+
VRFKey: i.VRFVKey.from_hex(a.vrf_key).to_bech32("vrf_vk")
|
|
2533
2533
|
};
|
|
2534
2534
|
}
|
|
2535
2535
|
throw h(s);
|
|
@@ -2573,32 +2573,32 @@ class Qr {
|
|
|
2573
2573
|
try {
|
|
2574
2574
|
const { data: s, status: n } = await this._axiosInstance.get("protocol-params");
|
|
2575
2575
|
if (n === 200) {
|
|
2576
|
-
const
|
|
2576
|
+
const a = s.data;
|
|
2577
2577
|
try {
|
|
2578
2578
|
const { data: o, status: c } = await this._axiosInstance.get("epochs/current");
|
|
2579
2579
|
if (c === 200) {
|
|
2580
2580
|
const u = o.data;
|
|
2581
2581
|
return {
|
|
2582
|
-
coinsPerUTxOSize:
|
|
2583
|
-
collateralPercent: parseInt(
|
|
2582
|
+
coinsPerUTxOSize: a.coins_per_utxo_byte.toString(),
|
|
2583
|
+
collateralPercent: parseInt(a.collateral_percentage),
|
|
2584
2584
|
decentralisation: 0,
|
|
2585
2585
|
epoch: parseInt(u.epoch_no),
|
|
2586
|
-
keyDeposit:
|
|
2587
|
-
maxBlockExMem:
|
|
2588
|
-
maxBlockExSteps:
|
|
2589
|
-
maxBlockHeaderSize: parseInt(
|
|
2590
|
-
maxBlockSize: parseInt(
|
|
2591
|
-
maxCollateralInputs: parseInt(
|
|
2592
|
-
maxTxExMem:
|
|
2593
|
-
maxTxExSteps:
|
|
2594
|
-
maxTxSize: parseInt(
|
|
2595
|
-
maxValSize:
|
|
2596
|
-
minFeeA:
|
|
2597
|
-
minFeeB:
|
|
2598
|
-
minPoolCost:
|
|
2599
|
-
poolDeposit:
|
|
2600
|
-
priceMem: t(
|
|
2601
|
-
priceStep: t(
|
|
2586
|
+
keyDeposit: a.stake_key_deposit.toString(),
|
|
2587
|
+
maxBlockExMem: a.max_execution_units_per_block.memory.toString(),
|
|
2588
|
+
maxBlockExSteps: a.max_execution_units_per_block.steps.toString(),
|
|
2589
|
+
maxBlockHeaderSize: parseInt(a.max_block_header_size),
|
|
2590
|
+
maxBlockSize: parseInt(a.max_block_body_size),
|
|
2591
|
+
maxCollateralInputs: parseInt(a.max_collateral_inputs),
|
|
2592
|
+
maxTxExMem: a.max_execution_units_per_transaction.memory.toString(),
|
|
2593
|
+
maxTxExSteps: a.max_execution_units_per_transaction.steps.toString(),
|
|
2594
|
+
maxTxSize: parseInt(a.max_tx_size),
|
|
2595
|
+
maxValSize: a.max_value_size.toString(),
|
|
2596
|
+
minFeeA: a.min_fee_coefficient,
|
|
2597
|
+
minFeeB: a.min_fee_constant,
|
|
2598
|
+
minPoolCost: a.min_pool_cost.toString(),
|
|
2599
|
+
poolDeposit: a.pool_deposit.toString(),
|
|
2600
|
+
priceMem: t(a.prices.memory),
|
|
2601
|
+
priceStep: t(a.prices.steps)
|
|
2602
2602
|
};
|
|
2603
2603
|
}
|
|
2604
2604
|
throw h(o);
|
|
@@ -2645,10 +2645,10 @@ class Qr {
|
|
|
2645
2645
|
}
|
|
2646
2646
|
onTxConfirmed(e, t, s = 100) {
|
|
2647
2647
|
let n = 0;
|
|
2648
|
-
const
|
|
2649
|
-
n >= s && clearInterval(
|
|
2648
|
+
const a = setInterval(() => {
|
|
2649
|
+
n >= s && clearInterval(a), this.fetchTxInfo(e).then((o) => {
|
|
2650
2650
|
this.fetchBlockInfo(o.block).then((c) => {
|
|
2651
|
-
(c == null ? void 0 : c.confirmations) > 0 && (clearInterval(
|
|
2651
|
+
(c == null ? void 0 : c.confirmations) > 0 && (clearInterval(a), t());
|
|
2652
2652
|
}).catch(() => {
|
|
2653
2653
|
n += 1;
|
|
2654
2654
|
});
|
|
@@ -2659,7 +2659,7 @@ class Qr {
|
|
|
2659
2659
|
}
|
|
2660
2660
|
async submitTx(e) {
|
|
2661
2661
|
try {
|
|
2662
|
-
const t = { "Content-Type": "application/cbor" }, { data: s, status: n } = await this._axiosInstance.post(this.submitUrl,
|
|
2662
|
+
const t = { "Content-Type": "application/cbor" }, { data: s, status: n } = await this._axiosInstance.post(this.submitUrl, _(e), { headers: t });
|
|
2663
2663
|
if (n === 202)
|
|
2664
2664
|
return s;
|
|
2665
2665
|
throw h(s);
|
|
@@ -2676,9 +2676,9 @@ class Qr {
|
|
|
2676
2676
|
},
|
|
2677
2677
|
output: {
|
|
2678
2678
|
address: e.address,
|
|
2679
|
-
amount: e.assets.map((
|
|
2680
|
-
unit:
|
|
2681
|
-
quantity:
|
|
2679
|
+
amount: e.assets.map((a) => ({
|
|
2680
|
+
unit: a.unit,
|
|
2681
|
+
quantity: a.amount
|
|
2682
2682
|
})),
|
|
2683
2683
|
dataHash: (t = e.datum) == null ? void 0 : t.hash,
|
|
2684
2684
|
plutusData: (s = e.datum) == null ? void 0 : s.bytes,
|
|
@@ -2698,61 +2698,61 @@ class Qr {
|
|
|
2698
2698
|
return;
|
|
2699
2699
|
};
|
|
2700
2700
|
}
|
|
2701
|
-
class
|
|
2701
|
+
class Dr {
|
|
2702
2702
|
static withOneSignature(e) {
|
|
2703
|
-
const t =
|
|
2703
|
+
const t = F(it(e));
|
|
2704
2704
|
return xt(t).to_hex();
|
|
2705
2705
|
}
|
|
2706
2706
|
static withAtLeastNSignatures(e, t) {
|
|
2707
|
-
const s =
|
|
2708
|
-
e.forEach((
|
|
2709
|
-
const o =
|
|
2707
|
+
const s = i.NativeScripts.new();
|
|
2708
|
+
e.forEach((a) => {
|
|
2709
|
+
const o = F(it(a));
|
|
2710
2710
|
s.add(xt(o));
|
|
2711
2711
|
});
|
|
2712
|
-
const n =
|
|
2713
|
-
return
|
|
2712
|
+
const n = i.ScriptNOfK.new(t, s);
|
|
2713
|
+
return i.NativeScript.new_script_any(n).to_hex();
|
|
2714
2714
|
}
|
|
2715
2715
|
static withAnySignature(e) {
|
|
2716
|
-
const t =
|
|
2716
|
+
const t = i.NativeScripts.new();
|
|
2717
2717
|
e.forEach((n) => {
|
|
2718
|
-
const
|
|
2719
|
-
t.add(xt(
|
|
2718
|
+
const a = F(it(n));
|
|
2719
|
+
t.add(xt(a));
|
|
2720
2720
|
});
|
|
2721
|
-
const s =
|
|
2722
|
-
return
|
|
2721
|
+
const s = i.ScriptAny.new(t);
|
|
2722
|
+
return i.NativeScript.new_script_any(s).to_hex();
|
|
2723
2723
|
}
|
|
2724
2724
|
static withAllSignatures(e) {
|
|
2725
|
-
const t =
|
|
2725
|
+
const t = i.NativeScripts.new();
|
|
2726
2726
|
e.forEach((n) => {
|
|
2727
|
-
const
|
|
2728
|
-
t.add(xt(
|
|
2727
|
+
const a = F(it(n));
|
|
2728
|
+
t.add(xt(a));
|
|
2729
2729
|
});
|
|
2730
|
-
const s =
|
|
2731
|
-
return
|
|
2730
|
+
const s = i.ScriptAll.new(t);
|
|
2731
|
+
return i.NativeScript.new_script_any(s).to_hex();
|
|
2732
2732
|
}
|
|
2733
2733
|
static fromNativeScript(e) {
|
|
2734
2734
|
return Tt(e).to_hex();
|
|
2735
2735
|
}
|
|
2736
2736
|
}
|
|
2737
2737
|
function st(r, e, t, s) {
|
|
2738
|
-
var n = arguments.length,
|
|
2738
|
+
var n = arguments.length, a = n < 3 ? e : s === null ? s = Object.getOwnPropertyDescriptor(e, t) : s, o;
|
|
2739
2739
|
if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
|
|
2740
|
-
|
|
2740
|
+
a = Reflect.decorate(r, e, t, s);
|
|
2741
2741
|
else
|
|
2742
2742
|
for (var c = r.length - 1; c >= 0; c--)
|
|
2743
|
-
(o = r[c]) && (
|
|
2744
|
-
return n > 3 &&
|
|
2743
|
+
(o = r[c]) && (a = (n < 3 ? o(a) : n > 3 ? o(e, t, a) : o(e, t)) || a);
|
|
2744
|
+
return n > 3 && a && Object.defineProperty(e, t, a), a;
|
|
2745
2745
|
}
|
|
2746
2746
|
const Xs = (r) => class extends r {
|
|
2747
2747
|
__visits = [];
|
|
2748
2748
|
}, rt = () => function(r, e, t) {
|
|
2749
2749
|
const s = t.value;
|
|
2750
2750
|
t.value = function(...n) {
|
|
2751
|
-
const
|
|
2752
|
-
return this.__visits && this.__visits.push(e),
|
|
2751
|
+
const a = s.call(this, ...n);
|
|
2752
|
+
return this.__visits && this.__visits.push(e), a;
|
|
2753
2753
|
};
|
|
2754
2754
|
};
|
|
2755
|
-
let
|
|
2755
|
+
let z = class {
|
|
2756
2756
|
_changeAddress;
|
|
2757
2757
|
_txOutputs = /* @__PURE__ */ new Map();
|
|
2758
2758
|
_recipients = /* @__PURE__ */ new Map();
|
|
@@ -2767,29 +2767,29 @@ let $ = class {
|
|
|
2767
2767
|
_txInputsBuilder;
|
|
2768
2768
|
_txWithdrawals;
|
|
2769
2769
|
constructor(e = {}) {
|
|
2770
|
-
this._era = e.era, this._initiator = e.initiator, this._mintBuilder =
|
|
2770
|
+
this._era = e.era, this._initiator = e.initiator, this._mintBuilder = i.MintBuilder.new(), this._protocolParameters = e.parameters ?? k, this._txBuilder = Et(e.parameters), this._txCertificates = i.Certificates.new(), this._txInputsBuilder = i.TxInputsBuilder.new(), this._txWithdrawals = i.Withdrawals.new();
|
|
2771
2771
|
}
|
|
2772
2772
|
static maskMetadata(e, t = "BABBAGE") {
|
|
2773
|
-
var
|
|
2774
|
-
const s =
|
|
2773
|
+
var a;
|
|
2774
|
+
const s = L(e), n = (a = s.auxiliary_data()) == null ? void 0 : a.metadata();
|
|
2775
2775
|
if (n !== void 0) {
|
|
2776
|
-
const o =
|
|
2776
|
+
const o = i.GeneralTransactionMetadata.new();
|
|
2777
2777
|
for (let u = 0; u < n.len(); u += 1) {
|
|
2778
|
-
const d = n.keys().get(u),
|
|
2779
|
-
o.insert(d,
|
|
2778
|
+
const d = n.keys().get(u), l = n.get(d);
|
|
2779
|
+
o.insert(d, i.TransactionMetadatum.from_hex("0".repeat(((l == null ? void 0 : l.to_hex()) ?? "").length)));
|
|
2780
2780
|
}
|
|
2781
2781
|
const c = s.auxiliary_data();
|
|
2782
|
-
return c !== void 0 && (c.set_metadata(o), c.set_prefer_alonzo_format(t === "ALONZO")),
|
|
2782
|
+
return c !== void 0 && (c.set_metadata(o), c.set_prefer_alonzo_format(t === "ALONZO")), i.Transaction.new(s.body(), s.witness_set(), c).to_hex();
|
|
2783
2783
|
}
|
|
2784
2784
|
return e;
|
|
2785
2785
|
}
|
|
2786
2786
|
static readMetadata(e) {
|
|
2787
2787
|
var s, n;
|
|
2788
|
-
return ((n = (s =
|
|
2788
|
+
return ((n = (s = L(e).auxiliary_data()) == null ? void 0 : s.metadata()) == null ? void 0 : n.to_hex()) ?? "";
|
|
2789
2789
|
}
|
|
2790
2790
|
static writeMetadata(e, t, s = "BABBAGE") {
|
|
2791
|
-
const n =
|
|
2792
|
-
return
|
|
2791
|
+
const n = L(e), a = n.auxiliary_data() ?? i.AuxiliaryData.new();
|
|
2792
|
+
return a.set_metadata(i.GeneralTransactionMetadata.from_hex(t)), a.set_prefer_alonzo_format(s === "ALONZO"), i.Transaction.new(n.body(), n.witness_set(), a).to_hex();
|
|
2793
2793
|
}
|
|
2794
2794
|
get size() {
|
|
2795
2795
|
return this._txBuilder.full_size();
|
|
@@ -2802,39 +2802,39 @@ let $ = class {
|
|
|
2802
2802
|
}
|
|
2803
2803
|
}
|
|
2804
2804
|
burnAsset(e, t, s) {
|
|
2805
|
-
const n = this._totalBurns.has(t.unit) ?
|
|
2806
|
-
return this._mintBuilder.add_asset(ye(e, s),
|
|
2805
|
+
const n = this._totalBurns.has(t.unit) ? i.BigNum.from_str(this._totalBurns.get(t.unit) ?? "0").checked_add(i.BigNum.from_str(t.quantity)).to_str() : t.quantity;
|
|
2806
|
+
return this._mintBuilder.add_asset(ye(e, s), i.AssetName.new(_(t.unit.slice(O))), i.Int.new_negative(i.BigNum.from_str(t.quantity))), this._totalBurns.set(t.unit, n), this;
|
|
2807
2807
|
}
|
|
2808
2808
|
delegateStake(e, t) {
|
|
2809
|
-
const s =
|
|
2809
|
+
const s = i.Certificate.new_stake_delegation(i.StakeDelegation.new(i.StakeCredential.from_keyhash(F(At(e))), i.Ed25519KeyHash.from_bech32(t)));
|
|
2810
2810
|
return this._txCertificates.add(s), this;
|
|
2811
2811
|
}
|
|
2812
2812
|
deregisterStake(e) {
|
|
2813
|
-
const t =
|
|
2813
|
+
const t = i.Certificate.new_stake_deregistration(i.StakeDeregistration.new(i.StakeCredential.from_keyhash(F(At(e)))));
|
|
2814
2814
|
return this._txCertificates.add(t), this;
|
|
2815
2815
|
}
|
|
2816
2816
|
mintAsset(e, t, s) {
|
|
2817
|
-
var d,
|
|
2818
|
-
const n = (
|
|
2819
|
-
const
|
|
2817
|
+
var d, l;
|
|
2818
|
+
const n = (g, A) => {
|
|
2819
|
+
const m = typeof g == "string" ? Dt(g).hash().to_hex() : a(g).hash().to_hex(), p = Q(A.assetName);
|
|
2820
2820
|
return {
|
|
2821
|
-
unit: `${
|
|
2822
|
-
quantity:
|
|
2821
|
+
unit: `${m}${p}`,
|
|
2822
|
+
quantity: A.assetQuantity
|
|
2823
2823
|
};
|
|
2824
|
-
},
|
|
2825
|
-
if ("code" in
|
|
2826
|
-
return dt(
|
|
2827
|
-
const
|
|
2828
|
-
if (
|
|
2829
|
-
const
|
|
2830
|
-
if (
|
|
2831
|
-
const
|
|
2832
|
-
return dt(
|
|
2824
|
+
}, a = (g) => {
|
|
2825
|
+
if ("code" in g)
|
|
2826
|
+
return dt(g.code, g.version);
|
|
2827
|
+
const A = H(g);
|
|
2828
|
+
if (A.output().has_script_ref()) {
|
|
2829
|
+
const m = A.output().script_ref();
|
|
2830
|
+
if (m.is_plutus_script()) {
|
|
2831
|
+
const p = Ve(m);
|
|
2832
|
+
return dt(p.code, p.version);
|
|
2833
2833
|
}
|
|
2834
2834
|
}
|
|
2835
|
-
throw new Error(`No plutus script reference found in UTxO: ${
|
|
2836
|
-
}, o = n(e, t), u =
|
|
2837
|
-
return this._mintBuilder.add_asset(ye(e, s),
|
|
2835
|
+
throw new Error(`No plutus script reference found in UTxO: ${A.input().transaction_id().to_hex()}`);
|
|
2836
|
+
}, o = n(e, t), u = i.BigNum.from_str(((d = this._totalMints.get(o.unit)) == null ? void 0 : d.assetQuantity) ?? "0").checked_add(i.BigNum.from_str(o.quantity));
|
|
2837
|
+
return this._mintBuilder.add_asset(ye(e, s), i.AssetName.new(_(Q(t.assetName))), i.Int.new(i.BigNum.from_str(o.quantity))), this._recipients.has(t.recipient) ? (l = this._recipients.get(t.recipient)) == null || l.push(o) : this._recipients.set(t.recipient, [o]), this._totalMints.set(o.unit, {
|
|
2838
2838
|
...t,
|
|
2839
2839
|
assetQuantity: u.to_str()
|
|
2840
2840
|
}), this;
|
|
@@ -2849,32 +2849,32 @@ let $ = class {
|
|
|
2849
2849
|
fields: []
|
|
2850
2850
|
},
|
|
2851
2851
|
...e.redeemer
|
|
2852
|
-
}, s =
|
|
2852
|
+
}, s = H(e.value), n = i.PlutusWitness.new_with_ref(Ye(e.script), Js(e.datum), Oe(t));
|
|
2853
2853
|
return this._txInputsBuilder.add_plutus_script_input(n, s.input(), s.output().amount()), this;
|
|
2854
2854
|
}
|
|
2855
2855
|
registerStake(e) {
|
|
2856
|
-
const t =
|
|
2856
|
+
const t = i.Certificate.new_stake_registration(i.StakeRegistration.new(i.StakeCredential.from_keyhash(F(At(e)))));
|
|
2857
2857
|
return this._txCertificates.add(t), this;
|
|
2858
2858
|
}
|
|
2859
2859
|
registerPool(e) {
|
|
2860
|
-
const t =
|
|
2860
|
+
const t = i.Certificate.new_pool_registration(i.PoolRegistration.new($s(e)));
|
|
2861
2861
|
return this._txCertificates.add(t), this;
|
|
2862
2862
|
}
|
|
2863
2863
|
retirePool(e, t) {
|
|
2864
|
-
const s =
|
|
2864
|
+
const s = i.Certificate.new_pool_retirement(i.PoolRetirement.new(i.Ed25519KeyHash.from_bech32(e), t));
|
|
2865
2865
|
return this._txCertificates.add(s), this;
|
|
2866
2866
|
}
|
|
2867
2867
|
sendAssets(e, t) {
|
|
2868
2868
|
const s = Z(t), n = s.multiasset();
|
|
2869
2869
|
if (s.is_zero() || n === void 0)
|
|
2870
2870
|
return this;
|
|
2871
|
-
const
|
|
2871
|
+
const a = Ct(e).next(), o = s.coin().is_zero() ? a.with_asset_and_min_required_coin_by_utxo_cost(n, Ht(this._protocolParameters.coinsPerUTxOSize)).build() : a.with_coin_and_asset(s.coin(), n).build();
|
|
2872
2872
|
return t.forEach((c) => {
|
|
2873
2873
|
this.setTxOutput(c);
|
|
2874
2874
|
}), this._txBuilder.add_output(o), this;
|
|
2875
2875
|
}
|
|
2876
2876
|
sendLovelace(e, t) {
|
|
2877
|
-
const n = Ct(e).next().with_coin(
|
|
2877
|
+
const n = Ct(e).next().with_coin(i.BigNum.from_str(t)).build();
|
|
2878
2878
|
return this.setTxOutput({
|
|
2879
2879
|
unit: "lovelace",
|
|
2880
2880
|
quantity: t
|
|
@@ -2887,10 +2887,10 @@ let $ = class {
|
|
|
2887
2887
|
}]), this;
|
|
2888
2888
|
}
|
|
2889
2889
|
sendValue(e, t) {
|
|
2890
|
-
const s = Z(t.output.amount),
|
|
2890
|
+
const s = Z(t.output.amount), a = Ct(e).next().with_value(s).build();
|
|
2891
2891
|
return t.output.amount.forEach((o) => {
|
|
2892
2892
|
this.setTxOutput(o);
|
|
2893
|
-
}), this._txBuilder.add_output(
|
|
2893
|
+
}), this._txBuilder.add_output(a), this;
|
|
2894
2894
|
}
|
|
2895
2895
|
setChangeAddress(e) {
|
|
2896
2896
|
return this._changeAddress = K(e), this;
|
|
@@ -2900,37 +2900,37 @@ let $ = class {
|
|
|
2900
2900
|
return this._txBuilder.set_collateral(t), this;
|
|
2901
2901
|
}
|
|
2902
2902
|
setMetadata(e, t) {
|
|
2903
|
-
return this._txBuilder.add_json_metadatum_with_schema(
|
|
2903
|
+
return this._txBuilder.add_json_metadatum_with_schema(i.BigNum.from_str(e.toString()), JSON.stringify(t), i.MetadataJsonSchema.NoConversions), this;
|
|
2904
2904
|
}
|
|
2905
2905
|
setRequiredSigners(e) {
|
|
2906
|
-
return Array.from(new Set(e.map((s) => s.startsWith("addr") ? it(s) :
|
|
2906
|
+
return Array.from(new Set(e.map((s) => s.startsWith("addr") ? it(s) : At(s)).map((s) => F(s)))).forEach((s) => {
|
|
2907
2907
|
this._txBuilder.add_required_signer(s);
|
|
2908
2908
|
}), this;
|
|
2909
2909
|
}
|
|
2910
2910
|
setTimeToStart(e) {
|
|
2911
|
-
return this._txBuilder.set_validity_start_interval_bignum(
|
|
2911
|
+
return this._txBuilder.set_validity_start_interval_bignum(i.BigNum.from_str(e)), this;
|
|
2912
2912
|
}
|
|
2913
2913
|
setTimeToExpire(e) {
|
|
2914
|
-
return this._txBuilder.set_ttl_bignum(
|
|
2914
|
+
return this._txBuilder.set_ttl_bignum(i.BigNum.from_str(e)), this;
|
|
2915
2915
|
}
|
|
2916
2916
|
setTxInputs(e) {
|
|
2917
|
-
return e.map((t) =>
|
|
2917
|
+
return e.map((t) => H(t)).forEach((t) => {
|
|
2918
2918
|
this._txInputsBuilder.add_input(t.output().address(), t.input(), t.output().amount());
|
|
2919
2919
|
}), this;
|
|
2920
2920
|
}
|
|
2921
2921
|
setTxRefInputs(e) {
|
|
2922
|
-
return e.map((t) =>
|
|
2922
|
+
return e.map((t) => H(t)).forEach((t) => {
|
|
2923
2923
|
this._txBuilder.add_reference_input(t.input());
|
|
2924
2924
|
}), this;
|
|
2925
2925
|
}
|
|
2926
2926
|
withdrawRewards(e, t) {
|
|
2927
2927
|
const s = Fe(e);
|
|
2928
|
-
return s !== void 0 && this._txWithdrawals.insert(s,
|
|
2928
|
+
return s !== void 0 && this._txWithdrawals.insert(s, i.BigNum.from_str(t)), this;
|
|
2929
2929
|
}
|
|
2930
2930
|
async addBurnInputsIfNeeded() {
|
|
2931
2931
|
if (this._initiator && this._totalBurns.size > 0 && this.notVisited("setTxInputs")) {
|
|
2932
2932
|
const e = await this._initiator.getUsedUTxOs();
|
|
2933
|
-
os(this._totalBurns, e.map((s) => vt(s))).map((s) =>
|
|
2933
|
+
os(this._totalBurns, e.map((s) => vt(s))).map((s) => H(s)).forEach((s) => {
|
|
2934
2934
|
this._txInputsBuilder.add_input(s.output().address(), s.input(), s.output().amount());
|
|
2935
2935
|
});
|
|
2936
2936
|
}
|
|
@@ -2951,13 +2951,13 @@ let $ = class {
|
|
|
2951
2951
|
async addRequiredSignersIfNeeded() {
|
|
2952
2952
|
if (this._initiator && this.notVisited("setRequiredSigners")) {
|
|
2953
2953
|
const e = await this._initiator.getUsedAddress(), t = it(e.to_bech32());
|
|
2954
|
-
this._txBuilder.add_required_signer(
|
|
2954
|
+
this._txBuilder.add_required_signer(F(t));
|
|
2955
2955
|
}
|
|
2956
2956
|
}
|
|
2957
2957
|
async addTxInputsAsNeeded() {
|
|
2958
2958
|
if (this.notVisited("setTxInputs")) {
|
|
2959
2959
|
const e = await this.filterAvailableUTxOs();
|
|
2960
|
-
is(this._txOutputs, e.map((s) => vt(s))).map((s) =>
|
|
2960
|
+
is(this._txOutputs, e.map((s) => vt(s))).map((s) => H(s)).forEach((s) => {
|
|
2961
2961
|
this._txInputsBuilder.add_input(s.output().address(), s.input(), s.output().amount());
|
|
2962
2962
|
});
|
|
2963
2963
|
}
|
|
@@ -2968,12 +2968,12 @@ let $ = class {
|
|
|
2968
2968
|
}
|
|
2969
2969
|
async forgeAssetsIfNeeded() {
|
|
2970
2970
|
const e = (t, s) => {
|
|
2971
|
-
const n = t.data.assetName,
|
|
2971
|
+
const n = t.data.assetName, a = t.data.metadata, o = t.unit.slice(0, O);
|
|
2972
2972
|
if (t.data.label === "777")
|
|
2973
|
-
return
|
|
2973
|
+
return a;
|
|
2974
2974
|
if (s && s[o]) {
|
|
2975
2975
|
const { [o]: c, ...u } = s, d = {
|
|
2976
|
-
[n]:
|
|
2976
|
+
[n]: a,
|
|
2977
2977
|
...c
|
|
2978
2978
|
};
|
|
2979
2979
|
return {
|
|
@@ -2985,18 +2985,18 @@ let $ = class {
|
|
|
2985
2985
|
}
|
|
2986
2986
|
return s !== void 0 ? {
|
|
2987
2987
|
[o]: {
|
|
2988
|
-
[n]:
|
|
2988
|
+
[n]: a
|
|
2989
2989
|
},
|
|
2990
2990
|
...s
|
|
2991
2991
|
} : {
|
|
2992
|
-
[o]: { [n]:
|
|
2992
|
+
[o]: { [n]: a }
|
|
2993
2993
|
};
|
|
2994
2994
|
};
|
|
2995
2995
|
await this.addBurnInputsIfNeeded(), Array.from(this._totalMints, (t) => ({
|
|
2996
2996
|
unit: t[0],
|
|
2997
2997
|
data: t[1]
|
|
2998
2998
|
})).reduce((t, s) => t.set(s.data.label, e(s, t.get(s.data.label))), /* @__PURE__ */ new Map()).forEach((t, s) => {
|
|
2999
|
-
this._txBuilder.add_json_metadatum(
|
|
2999
|
+
this._txBuilder.add_json_metadatum(i.BigNum.from_str(s), JSON.stringify(t));
|
|
3000
3000
|
}), this.addMintOutputs();
|
|
3001
3001
|
}
|
|
3002
3002
|
async filterAvailableUTxOs(e = []) {
|
|
@@ -3015,39 +3015,136 @@ let $ = class {
|
|
|
3015
3015
|
return this.__visits.includes(e) === !1;
|
|
3016
3016
|
}
|
|
3017
3017
|
setTxOutput(e) {
|
|
3018
|
-
const s =
|
|
3018
|
+
const s = i.BigNum.from_str(this._txOutputs.get(e.unit) ?? "0").checked_add(i.BigNum.from_str(e.quantity)).to_str();
|
|
3019
3019
|
this._txOutputs.set(e.unit, s);
|
|
3020
3020
|
}
|
|
3021
3021
|
};
|
|
3022
3022
|
st([
|
|
3023
3023
|
rt()
|
|
3024
|
-
],
|
|
3024
|
+
], z.prototype, "mintAsset", null);
|
|
3025
3025
|
st([
|
|
3026
3026
|
rt()
|
|
3027
|
-
],
|
|
3027
|
+
], z.prototype, "redeemValue", null);
|
|
3028
3028
|
st([
|
|
3029
3029
|
rt()
|
|
3030
|
-
],
|
|
3030
|
+
], z.prototype, "sendAssets", null);
|
|
3031
3031
|
st([
|
|
3032
3032
|
rt()
|
|
3033
|
-
],
|
|
3033
|
+
], z.prototype, "sendValue", null);
|
|
3034
3034
|
st([
|
|
3035
3035
|
rt()
|
|
3036
|
-
],
|
|
3036
|
+
], z.prototype, "setCollateral", null);
|
|
3037
3037
|
st([
|
|
3038
3038
|
rt()
|
|
3039
|
-
],
|
|
3039
|
+
], z.prototype, "setRequiredSigners", null);
|
|
3040
3040
|
st([
|
|
3041
3041
|
rt()
|
|
3042
|
-
],
|
|
3043
|
-
|
|
3042
|
+
], z.prototype, "setTxInputs", null);
|
|
3043
|
+
z = st([
|
|
3044
3044
|
Xs
|
|
3045
|
-
],
|
|
3046
|
-
|
|
3045
|
+
], z);
|
|
3046
|
+
const Zs = (r, e, t) => {
|
|
3047
|
+
const s = new Map(e);
|
|
3048
|
+
s.set("lovelace", String(Number(s.get("lovelace")) + Number(t)));
|
|
3049
|
+
const n = /* @__PURE__ */ new Map();
|
|
3050
|
+
for (let A = 0; A < r.length; A++)
|
|
3051
|
+
n.set(A, r[A]);
|
|
3052
|
+
const a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
|
|
3053
|
+
for (let A = 0; A < r.length; A++)
|
|
3054
|
+
switch (r[A].output.amount.length) {
|
|
3055
|
+
case 1: {
|
|
3056
|
+
o.add(A);
|
|
3057
|
+
break;
|
|
3058
|
+
}
|
|
3059
|
+
case 2: {
|
|
3060
|
+
c.add(A);
|
|
3061
|
+
break;
|
|
3062
|
+
}
|
|
3063
|
+
case 3: {
|
|
3064
|
+
u.add(A);
|
|
3065
|
+
break;
|
|
3066
|
+
}
|
|
3067
|
+
default: {
|
|
3068
|
+
d.add(A);
|
|
3069
|
+
break;
|
|
3070
|
+
}
|
|
3071
|
+
}
|
|
3072
|
+
const l = (A, m, p) => {
|
|
3073
|
+
const S = n.get(A);
|
|
3074
|
+
if (!S)
|
|
3075
|
+
return;
|
|
3076
|
+
const E = tr(S, m);
|
|
3077
|
+
if (Number(E) > 0) {
|
|
3078
|
+
a.add(A), p.delete(A);
|
|
3079
|
+
for (const f of S.output.amount)
|
|
3080
|
+
s.set(f.unit, String(Number(s.get(f.unit)) - Number(f.quantity)));
|
|
3081
|
+
}
|
|
3082
|
+
};
|
|
3083
|
+
for (const A of s.keys())
|
|
3084
|
+
if (A != "lovelace") {
|
|
3085
|
+
for (const m of c) {
|
|
3086
|
+
const p = s.get(A);
|
|
3087
|
+
if (!p || Number(p) <= 0)
|
|
3088
|
+
break;
|
|
3089
|
+
l(m, A, c);
|
|
3090
|
+
}
|
|
3091
|
+
for (const m of u) {
|
|
3092
|
+
const p = s.get(A);
|
|
3093
|
+
if (!p || Number(p) <= 0)
|
|
3094
|
+
break;
|
|
3095
|
+
l(m, A, u);
|
|
3096
|
+
}
|
|
3097
|
+
for (const m of d) {
|
|
3098
|
+
const p = s.get(A);
|
|
3099
|
+
if (!p || Number(p) <= 0)
|
|
3100
|
+
break;
|
|
3101
|
+
l(m, A, d);
|
|
3102
|
+
}
|
|
3103
|
+
}
|
|
3104
|
+
for (const A of o) {
|
|
3105
|
+
const m = s.get("lovelace");
|
|
3106
|
+
if (!m || Number(m) <= 0)
|
|
3107
|
+
break;
|
|
3108
|
+
l(A, "lovelace", o);
|
|
3109
|
+
}
|
|
3110
|
+
for (const A of c) {
|
|
3111
|
+
const m = s.get("lovelace");
|
|
3112
|
+
if (!m || Number(m) <= 0)
|
|
3113
|
+
break;
|
|
3114
|
+
l(A, "lovelace", c);
|
|
3115
|
+
}
|
|
3116
|
+
for (const A of u) {
|
|
3117
|
+
const m = s.get("lovelace");
|
|
3118
|
+
if (!m || Number(m) <= 0)
|
|
3119
|
+
break;
|
|
3120
|
+
l(A, "lovelace", u);
|
|
3121
|
+
}
|
|
3122
|
+
for (const A of d) {
|
|
3123
|
+
const m = s.get("lovelace");
|
|
3124
|
+
if (!m || Number(m) <= 0)
|
|
3125
|
+
break;
|
|
3126
|
+
l(A, "lovelace", d);
|
|
3127
|
+
}
|
|
3128
|
+
for (const A of s.keys())
|
|
3129
|
+
if (Number(s.get(A)) > 0)
|
|
3130
|
+
return [];
|
|
3131
|
+
const g = [];
|
|
3132
|
+
for (const A of a) {
|
|
3133
|
+
const m = n.get(A);
|
|
3134
|
+
m && g.push(m);
|
|
3135
|
+
}
|
|
3136
|
+
return g;
|
|
3137
|
+
}, tr = (r, e) => {
|
|
3138
|
+
for (const t of r.output.amount)
|
|
3139
|
+
if (t.unit == e)
|
|
3140
|
+
return t.quantity;
|
|
3141
|
+
return "0";
|
|
3142
|
+
};
|
|
3143
|
+
class er {
|
|
3047
3144
|
txHex = "";
|
|
3048
3145
|
txBuilder = Et();
|
|
3049
3146
|
txEvaluationMultiplier = 1.1;
|
|
3050
|
-
_protocolParams =
|
|
3147
|
+
_protocolParams = k;
|
|
3051
3148
|
txOutput;
|
|
3052
3149
|
addingScriptInput = !1;
|
|
3053
3150
|
addingPlutusMint = !1;
|
|
@@ -3057,10 +3154,12 @@ class Zs {
|
|
|
3057
3154
|
txInQueueItem;
|
|
3058
3155
|
collateralQueueItem;
|
|
3059
3156
|
refScriptTxInQueueItem;
|
|
3060
|
-
reset = () => (this.txHex = "", this.txBuilder = Et(), this.txEvaluationMultiplier = 1.1, this._protocolParams =
|
|
3157
|
+
reset = () => (this.txHex = "", this.txBuilder = Et(), this.txEvaluationMultiplier = 1.1, this._protocolParams = k, this.txOutput = void 0, this.addingScriptInput = !1, this.addingPlutusMint = !1, this.mintItem = void 0, this.txInQueueItem = void 0, this.collateralQueueItem = void 0, this.refScriptTxInQueueItem = void 0, this.meshTxBuilderBody = this.emptyTxBuilderBody(), this);
|
|
3061
3158
|
emptyTxBuilderBody = () => ({
|
|
3062
3159
|
inputs: [],
|
|
3063
3160
|
outputs: [],
|
|
3161
|
+
extraInputs: [],
|
|
3162
|
+
selectionThreshold: 0,
|
|
3064
3163
|
collaterals: [],
|
|
3065
3164
|
requiredSignatures: [],
|
|
3066
3165
|
referenceInputs: [],
|
|
@@ -3073,13 +3172,13 @@ class Zs {
|
|
|
3073
3172
|
constructor() {
|
|
3074
3173
|
this.meshTxBuilderBody = this.emptyTxBuilderBody();
|
|
3075
3174
|
}
|
|
3076
|
-
completeSync = (e) => (e
|
|
3175
|
+
completeSync = (e) => (e ? this.meshTxBuilderBody = e : this.queueAllLastItem(), this.serializeTxBody(this.meshTxBuilderBody));
|
|
3077
3176
|
completeSigning = () => {
|
|
3078
3177
|
const { signingKey: e } = this.meshTxBuilderBody;
|
|
3079
3178
|
return e.length > 0 && this.addAllSigningKeys(e), this.txHex;
|
|
3080
3179
|
};
|
|
3081
3180
|
serializeTxBody = (e) => {
|
|
3082
|
-
const { inputs: t, outputs: s,
|
|
3181
|
+
const { inputs: t, outputs: s, extraInputs: n, selectionThreshold: a, collaterals: o, referenceInputs: c, mints: u, changeAddress: d, validityRange: l, requiredSignatures: g, metadata: A } = e;
|
|
3083
3182
|
if (this.isHydra ? this.protocolParams({
|
|
3084
3183
|
minFeeA: 0,
|
|
3085
3184
|
minFeeB: 0,
|
|
@@ -3087,12 +3186,17 @@ class Zs {
|
|
|
3087
3186
|
priceStep: 0,
|
|
3088
3187
|
collateralPercent: 0,
|
|
3089
3188
|
coinsPerUTxOSize: "0"
|
|
3090
|
-
}) : this.protocolParams({}), this.meshTxBuilderBody.mints.sort((
|
|
3091
|
-
const
|
|
3092
|
-
var
|
|
3093
|
-
return ((
|
|
3094
|
-
}).reduce((
|
|
3095
|
-
|
|
3189
|
+
}) : this.protocolParams({}), n.length > 0 && this.addUtxosFrom(n, String(a)), this.meshTxBuilderBody.mints.sort((m, p) => m.policyId.localeCompare(p.policyId)), this.removeDuplicateInputs(), this.meshTxBuilderBody.inputs.sort((m, p) => m.txIn.txHash === p.txIn.txHash ? m.txIn.txIndex - p.txIn.txIndex : m.txIn.txHash.localeCompare(p.txIn.txHash)), this.addAllInputs(t), this.addAllOutputs(s), this.addAllCollaterals(o), this.addAllReferenceInputs(c), this.addAllMints(u), this.addValidityRange(l), this.addAllRequiredSignatures(g), this.addAllMetadata(A), this.addCostModels(), d) {
|
|
3190
|
+
const m = this.meshTxBuilderBody.collaterals.map((E) => {
|
|
3191
|
+
var f, x;
|
|
3192
|
+
return ((x = (f = E.txIn.amount) == null ? void 0 : f.find((C) => C.unit === "lovelace")) == null ? void 0 : x.quantity) || "0";
|
|
3193
|
+
}).reduce((E, f) => E + parseInt(f), 0), p = Math.ceil(this._protocolParams.collateralPercent * Number(Number(this.txBuilder.min_fee().checked_add(i.BigNum.from_str("10000")).to_js_value())) / 100);
|
|
3194
|
+
let S = !1;
|
|
3195
|
+
if (m - p > 0) {
|
|
3196
|
+
const E = i.TransactionOutput.new(i.Address.from_bech32(d), i.Value.new(i.BigNum.from_str(String(p))));
|
|
3197
|
+
m - p > Number(i.min_ada_for_output(E, i.DataCost.new_coins_per_byte(i.BigNum.from_str(this._protocolParams.coinsPerUTxOSize))).to_js_value()) && (this.txBuilder.set_collateral_return(i.TransactionOutput.new(i.Address.from_bech32(d), i.Value.new(i.BigNum.from_str(String(m))))), this.txBuilder.set_total_collateral(i.BigNum.from_str(String(m))), S = !0);
|
|
3198
|
+
}
|
|
3199
|
+
this.addChange(d), S && this.addCollateralReturn(d);
|
|
3096
3200
|
}
|
|
3097
3201
|
return this.buildTx(), this;
|
|
3098
3202
|
};
|
|
@@ -3132,22 +3236,20 @@ class Zs {
|
|
|
3132
3236
|
throw Error("Undefined input");
|
|
3133
3237
|
if (this.txInQueueItem.type === "PubKey")
|
|
3134
3238
|
throw Error("Datum value attempted to be called a non script input");
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
const s = this.castRawDataToJsonString(e);
|
|
3144
|
-
return this.txInQueueItem.scriptTxIn.datumSource = {
|
|
3239
|
+
let s = e;
|
|
3240
|
+
return t === "JSON" && (s = this.castRawDataToJsonString(e)), t === "Mesh" ? (this.txInQueueItem.scriptTxIn.datumSource = {
|
|
3241
|
+
type: "Provided",
|
|
3242
|
+
data: {
|
|
3243
|
+
type: t,
|
|
3244
|
+
content: e
|
|
3245
|
+
}
|
|
3246
|
+
}, this) : (this.txInQueueItem.scriptTxIn.datumSource = {
|
|
3145
3247
|
type: "Provided",
|
|
3146
3248
|
data: {
|
|
3147
3249
|
type: t,
|
|
3148
3250
|
content: s
|
|
3149
3251
|
}
|
|
3150
|
-
}, this;
|
|
3252
|
+
}, this);
|
|
3151
3253
|
};
|
|
3152
3254
|
txInInlineDatumPresent = () => {
|
|
3153
3255
|
if (!this.txInQueueItem)
|
|
@@ -3166,39 +3268,37 @@ class Zs {
|
|
|
3166
3268
|
throw Error("Undefined input");
|
|
3167
3269
|
if (this.txInQueueItem.type === "PubKey")
|
|
3168
3270
|
throw Error("Spending tx in reference redeemer attempted to be called a non script input");
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
const n = this.castRawDataToJsonString(e);
|
|
3178
|
-
return this.txInQueueItem.scriptTxIn.redeemer = {
|
|
3271
|
+
let n = e;
|
|
3272
|
+
return s === "Mesh" ? (this.txInQueueItem.scriptTxIn.redeemer = {
|
|
3273
|
+
data: {
|
|
3274
|
+
type: s,
|
|
3275
|
+
content: e
|
|
3276
|
+
},
|
|
3277
|
+
exUnits: t
|
|
3278
|
+
}, this) : (s === "JSON" && (n = this.castRawDataToJsonString(e)), this.txInQueueItem.scriptTxIn.redeemer = {
|
|
3179
3279
|
data: {
|
|
3180
3280
|
type: s,
|
|
3181
3281
|
content: n
|
|
3182
3282
|
},
|
|
3183
3283
|
exUnits: t
|
|
3184
|
-
}, this;
|
|
3284
|
+
}, this);
|
|
3185
3285
|
};
|
|
3186
3286
|
txOut = (e, t) => (this.txOutput && (this.meshTxBuilderBody.outputs.push(this.txOutput), this.txOutput = void 0), this.txOutput = {
|
|
3187
3287
|
address: e,
|
|
3188
3288
|
amount: t
|
|
3189
3289
|
}, this);
|
|
3190
3290
|
txOutDatumHashValue = (e, t = "Mesh") => {
|
|
3291
|
+
let s = e;
|
|
3191
3292
|
if (this.txOutput) {
|
|
3192
3293
|
if (t === "Mesh")
|
|
3193
3294
|
return this.txOutput.datum = {
|
|
3194
3295
|
type: "Hash",
|
|
3195
3296
|
data: {
|
|
3196
3297
|
type: t,
|
|
3197
|
-
content:
|
|
3298
|
+
content: s
|
|
3198
3299
|
}
|
|
3199
3300
|
}, this;
|
|
3200
|
-
|
|
3201
|
-
this.txOutput.datum = {
|
|
3301
|
+
t === "JSON" && (s = this.castRawDataToJsonString(e)), this.txOutput.datum = {
|
|
3202
3302
|
type: "Hash",
|
|
3203
3303
|
data: {
|
|
3204
3304
|
type: t,
|
|
@@ -3209,17 +3309,17 @@ class Zs {
|
|
|
3209
3309
|
return this;
|
|
3210
3310
|
};
|
|
3211
3311
|
txOutInlineDatumValue = (e, t = "Mesh") => {
|
|
3312
|
+
let s = e;
|
|
3212
3313
|
if (this.txOutput) {
|
|
3213
3314
|
if (t === "Mesh")
|
|
3214
3315
|
return this.txOutput.datum = {
|
|
3215
3316
|
type: "Inline",
|
|
3216
3317
|
data: {
|
|
3217
3318
|
type: t,
|
|
3218
|
-
content:
|
|
3319
|
+
content: s
|
|
3219
3320
|
}
|
|
3220
3321
|
}, this;
|
|
3221
|
-
|
|
3222
|
-
this.txOutput.datum = {
|
|
3322
|
+
t === "JSON" && (s = this.castRawDataToJsonString(e)), this.txOutput.datum = {
|
|
3223
3323
|
type: "Inline",
|
|
3224
3324
|
data: {
|
|
3225
3325
|
type: t,
|
|
@@ -3290,16 +3390,16 @@ class Zs {
|
|
|
3290
3390
|
if (this.mintItem.type == "Plutus") {
|
|
3291
3391
|
if (!this.mintItem.policyId)
|
|
3292
3392
|
throw Error("PolicyId information missing from mint asset");
|
|
3393
|
+
let n = e;
|
|
3293
3394
|
if (s === "Mesh")
|
|
3294
3395
|
return this.mintItem.redeemer = {
|
|
3295
3396
|
data: {
|
|
3296
3397
|
type: s,
|
|
3297
|
-
content:
|
|
3398
|
+
content: n
|
|
3298
3399
|
},
|
|
3299
3400
|
exUnits: t
|
|
3300
3401
|
}, this;
|
|
3301
|
-
|
|
3302
|
-
this.mintItem.redeemer = {
|
|
3402
|
+
s === "JSON" && (n = this.castRawDataToJsonString(e)), this.mintItem.redeemer = {
|
|
3303
3403
|
data: {
|
|
3304
3404
|
type: s,
|
|
3305
3405
|
content: n
|
|
@@ -3325,20 +3425,50 @@ class Zs {
|
|
|
3325
3425
|
invalidHereafter = (e) => (this.meshTxBuilderBody.validityRange.invalidHereafter = e, this);
|
|
3326
3426
|
metadataValue = (e, t) => (this.meshTxBuilderBody.metadata.push({ tag: e, metadata: t }), this);
|
|
3327
3427
|
protocolParams = (e) => {
|
|
3328
|
-
const t = { ...
|
|
3428
|
+
const t = { ...k, ...e };
|
|
3329
3429
|
return this._protocolParams = t, this.txBuilder = Et(t), this;
|
|
3330
3430
|
};
|
|
3331
3431
|
signingKey = (e) => (this.meshTxBuilderBody.signingKey.push(e), this);
|
|
3432
|
+
selectUtxosFrom = (e, t = 5e6) => (this.meshTxBuilderBody.extraInputs = e, this.meshTxBuilderBody.selectionThreshold = t, this);
|
|
3433
|
+
addUtxosFrom = (e, t) => {
|
|
3434
|
+
const s = this.meshTxBuilderBody.outputs.reduce((a, o) => (o.amount.forEach((u) => {
|
|
3435
|
+
const { unit: d, quantity: l } = u, g = Number(a.get(d)) || 0;
|
|
3436
|
+
a.set(d, String(g + Number(l)));
|
|
3437
|
+
}), a), /* @__PURE__ */ new Map());
|
|
3438
|
+
this.meshTxBuilderBody.inputs.reduce((a, o) => {
|
|
3439
|
+
const c = o.txIn.amount;
|
|
3440
|
+
return c == null || c.forEach((u) => {
|
|
3441
|
+
const { unit: d, quantity: l } = u, g = Number(a.get(d)) || 0;
|
|
3442
|
+
a.set(d, String(g - Number(l)));
|
|
3443
|
+
}), a;
|
|
3444
|
+
}, s), this.meshTxBuilderBody.mints.reduce((a, o) => {
|
|
3445
|
+
const c = {
|
|
3446
|
+
unit: o.policyId + o.assetName,
|
|
3447
|
+
quantity: String(o.amount)
|
|
3448
|
+
}, u = Number(a.get(c.unit)) || 0;
|
|
3449
|
+
return a.set(c.unit, String(u - Number(c.quantity))), a;
|
|
3450
|
+
}, s), Zs(e, s, t).forEach((a) => {
|
|
3451
|
+
this.addTxIn({
|
|
3452
|
+
type: "PubKey",
|
|
3453
|
+
txIn: {
|
|
3454
|
+
txHash: a.input.txHash,
|
|
3455
|
+
txIndex: a.input.outputIndex,
|
|
3456
|
+
amount: a.output.amount,
|
|
3457
|
+
address: a.output.address
|
|
3458
|
+
}
|
|
3459
|
+
});
|
|
3460
|
+
});
|
|
3461
|
+
};
|
|
3332
3462
|
addAllSigningKeys = (e) => {
|
|
3333
3463
|
if (e.length > 0) {
|
|
3334
|
-
const t =
|
|
3464
|
+
const t = i.Vkeywitnesses.new(), s = i.Transaction.from_hex(this.txHex), n = s.body();
|
|
3335
3465
|
e.forEach((c) => {
|
|
3336
|
-
const u = c.slice(0, 4) === "5820" ? c.slice(4) : c, d =
|
|
3337
|
-
t.add(
|
|
3466
|
+
const u = c.slice(0, 4) === "5820" ? c.slice(4) : c, d = i.PrivateKey.from_hex(u), l = i.make_vkey_witness(i.hash_transaction(n), d);
|
|
3467
|
+
t.add(l);
|
|
3338
3468
|
});
|
|
3339
|
-
const
|
|
3340
|
-
|
|
3341
|
-
const o =
|
|
3469
|
+
const a = s.witness_set();
|
|
3470
|
+
a.set_vkeys(t);
|
|
3471
|
+
const o = i.Transaction.new(n, a, s.auxiliary_data());
|
|
3342
3472
|
this.txHex = o.to_hex();
|
|
3343
3473
|
}
|
|
3344
3474
|
};
|
|
@@ -3369,8 +3499,15 @@ class Zs {
|
|
|
3369
3499
|
this.meshTxBuilderBody.mints.push(this.mintItem), this.mintItem = void 0;
|
|
3370
3500
|
};
|
|
3371
3501
|
makePlutusScriptSource = (e) => {
|
|
3372
|
-
const t =
|
|
3373
|
-
return
|
|
3502
|
+
const t = i.ScriptHash.from_hex(e.spendingScriptHash), s = i.TransactionInput.new(i.TransactionHash.from_hex(e.txHash), e.txIndex);
|
|
3503
|
+
return i.PlutusScriptSource.new_ref_input_with_lang_ver(t, s, R[e.version]);
|
|
3504
|
+
};
|
|
3505
|
+
removeDuplicateInputs = () => {
|
|
3506
|
+
const e = this.meshTxBuilderBody.inputs, t = (n) => `${n.txHash}#${n.txIndex}`, s = [];
|
|
3507
|
+
for (let n = 0; n < e.length; n++) {
|
|
3508
|
+
const a = t(e[n].txIn);
|
|
3509
|
+
s.includes(a) ? (e.splice(n, 1), n--) : s.push(a);
|
|
3510
|
+
}
|
|
3374
3511
|
};
|
|
3375
3512
|
addAllInputs = (e) => {
|
|
3376
3513
|
for (let t = 0; t < e.length; t++) {
|
|
@@ -3386,21 +3523,21 @@ class Zs {
|
|
|
3386
3523
|
}
|
|
3387
3524
|
};
|
|
3388
3525
|
addTxIn = (e) => {
|
|
3389
|
-
this.txBuilder.add_input(
|
|
3526
|
+
this.txBuilder.add_input(i.Address.from_bech32(e.txIn.address), i.TransactionInput.new(i.TransactionHash.from_hex(e.txIn.txHash), e.txIn.txIndex), Z(e.txIn.amount));
|
|
3390
3527
|
};
|
|
3391
3528
|
addScriptTxIn = ({ scriptTxIn: e, txIn: t }) => {
|
|
3392
3529
|
let s;
|
|
3393
|
-
const { datumSource: n, scriptSource:
|
|
3530
|
+
const { datumSource: n, scriptSource: a, redeemer: o } = e;
|
|
3394
3531
|
if (n.type === "Provided")
|
|
3395
|
-
s =
|
|
3532
|
+
s = i.DatumSource.new(this.castDataToPlutusData(n.data));
|
|
3396
3533
|
else {
|
|
3397
|
-
const d =
|
|
3398
|
-
s =
|
|
3534
|
+
const d = i.TransactionInput.new(i.TransactionHash.from_hex(n.txHash), n.txIndex);
|
|
3535
|
+
s = i.DatumSource.new_ref_input(d);
|
|
3399
3536
|
}
|
|
3400
3537
|
let c;
|
|
3401
|
-
|
|
3402
|
-
const u =
|
|
3403
|
-
this.txBuilder.add_plutus_script_input(
|
|
3538
|
+
a.type == "Inline" ? c = this.makePlutusScriptSource(a.txInInfo) : c = i.PlutusScriptSource.new(i.PlutusScript.from_hex_with_version(a.script.code, R[a.script.version]));
|
|
3539
|
+
const u = i.Redeemer.new(i.RedeemerTag.new_spend(), i.BigNum.from_str("0"), this.castDataToPlutusData(o.data), i.ExUnits.new(i.BigNum.from_str(String(o.exUnits.mem)), i.BigNum.from_str(String(o.exUnits.steps))));
|
|
3540
|
+
this.txBuilder.add_plutus_script_input(i.PlutusWitness.new_with_ref(c, s, u), i.TransactionInput.new(i.TransactionHash.from_hex(t.txHash), t.txIndex), Z(t.amount));
|
|
3404
3541
|
};
|
|
3405
3542
|
addAllOutputs = (e) => {
|
|
3406
3543
|
for (let t = 0; t < e.length; t++) {
|
|
@@ -3409,22 +3546,22 @@ class Zs {
|
|
|
3409
3546
|
}
|
|
3410
3547
|
};
|
|
3411
3548
|
addOutput = ({ amount: e, address: t, datum: s, referenceScript: n }) => {
|
|
3412
|
-
const
|
|
3413
|
-
if (
|
|
3549
|
+
const a = Z(e), o = a.multiasset();
|
|
3550
|
+
if (a.is_zero() && o === void 0)
|
|
3414
3551
|
throw Error("Invalid output amount");
|
|
3415
|
-
let c =
|
|
3416
|
-
s && s.type === "Hash" && (c = c.with_data_hash(
|
|
3552
|
+
let c = i.TransactionOutputBuilder.new().with_address(K(t));
|
|
3553
|
+
s && s.type === "Hash" && (c = c.with_data_hash(i.hash_plutus_data(this.castDataToPlutusData(s.data)))), s && s.type === "Inline" && (c = c.with_plutus_data(this.castDataToPlutusData(s.data))), n && (c = c.with_script_ref(i.ScriptRef.new_plutus_script(i.PlutusScript.from_hex_with_version(n.code, R[n.version]))));
|
|
3417
3554
|
const u = c.next();
|
|
3418
3555
|
if (o) {
|
|
3419
|
-
const d =
|
|
3556
|
+
const d = a.coin().is_zero() ? u.with_asset_and_min_required_coin_by_utxo_cost(o, Ht(this._protocolParams.coinsPerUTxOSize)).build() : u.with_coin_and_asset(a.coin(), o).build();
|
|
3420
3557
|
this.txBuilder.add_output(d);
|
|
3421
3558
|
} else {
|
|
3422
|
-
const d = u.with_coin(
|
|
3559
|
+
const d = u.with_coin(a.coin()).build();
|
|
3423
3560
|
this.txBuilder.add_output(d);
|
|
3424
3561
|
}
|
|
3425
3562
|
};
|
|
3426
3563
|
addAllCollaterals = (e) => {
|
|
3427
|
-
const t =
|
|
3564
|
+
const t = i.TxInputsBuilder.new();
|
|
3428
3565
|
for (let s = 0; s < e.length; s++) {
|
|
3429
3566
|
const n = e[s];
|
|
3430
3567
|
this.addCollateral(t, n);
|
|
@@ -3432,14 +3569,14 @@ class Zs {
|
|
|
3432
3569
|
this.txBuilder.set_collateral(t);
|
|
3433
3570
|
};
|
|
3434
3571
|
addCollateral = (e, t) => {
|
|
3435
|
-
e.add_input(
|
|
3572
|
+
e.add_input(i.Address.from_bech32(t.txIn.address), i.TransactionInput.new(i.TransactionHash.from_hex(t.txIn.txHash), t.txIn.txIndex), Z(t.txIn.amount));
|
|
3436
3573
|
};
|
|
3437
3574
|
addCollateralReturn = (e) => {
|
|
3438
3575
|
var s;
|
|
3439
3576
|
const t = (s = this.txBuilder.get_fee_if_set()) == null ? void 0 : s.to_js_value();
|
|
3440
3577
|
if (t) {
|
|
3441
3578
|
const n = Math.ceil(this._protocolParams.collateralPercent * Number(t) / 100);
|
|
3442
|
-
this.txBuilder.set_total_collateral_and_return(
|
|
3579
|
+
this.txBuilder.set_total_collateral_and_return(i.BigNum.from_str(String(n)), i.Address.from_bech32(e));
|
|
3443
3580
|
}
|
|
3444
3581
|
};
|
|
3445
3582
|
addAllReferenceInputs = (e) => {
|
|
@@ -3448,54 +3585,54 @@ class Zs {
|
|
|
3448
3585
|
});
|
|
3449
3586
|
};
|
|
3450
3587
|
addReferenceInput = ({ txHash: e, txIndex: t }) => {
|
|
3451
|
-
const s =
|
|
3588
|
+
const s = i.TransactionInput.new(i.TransactionHash.from_hex(e), t);
|
|
3452
3589
|
this.txBuilder.add_reference_input(s);
|
|
3453
3590
|
};
|
|
3454
3591
|
addAllMints = (e) => {
|
|
3455
|
-
const t =
|
|
3592
|
+
const t = i.MintBuilder.new();
|
|
3456
3593
|
let s = 0;
|
|
3457
3594
|
for (let n = 0; n < e.length; n++) {
|
|
3458
|
-
const
|
|
3459
|
-
if (!
|
|
3595
|
+
const a = e[n];
|
|
3596
|
+
if (!a.scriptSource)
|
|
3460
3597
|
throw Error("Mint script is expected to be provided");
|
|
3461
|
-
if (
|
|
3462
|
-
if (!
|
|
3598
|
+
if (a.type === "Plutus") {
|
|
3599
|
+
if (!a.redeemer)
|
|
3463
3600
|
throw Error("Missing mint redeemer information");
|
|
3464
|
-
this.addPlutusMint(t,
|
|
3601
|
+
this.addPlutusMint(t, a, s), s++;
|
|
3465
3602
|
} else
|
|
3466
|
-
|
|
3603
|
+
a.type === "Native" && this.addNativeMint(t, a);
|
|
3467
3604
|
}
|
|
3468
3605
|
this.txBuilder.set_mint_builder(t);
|
|
3469
3606
|
};
|
|
3470
|
-
addPlutusMint = (e, { redeemer: t, policyId: s, scriptSource: n, assetName:
|
|
3471
|
-
const u =
|
|
3472
|
-
e.add_asset(
|
|
3607
|
+
addPlutusMint = (e, { redeemer: t, policyId: s, scriptSource: n, assetName: a, amount: o }, c) => {
|
|
3608
|
+
const u = i.Redeemer.new(i.RedeemerTag.new_mint(), i.BigNum.from_str(String(c)), this.castDataToPlutusData(t.data), i.ExUnits.new(i.BigNum.from_str(String(t.exUnits.mem)), i.BigNum.from_str(String(t.exUnits.steps)))), d = n.type === "Reference Script" ? i.PlutusScriptSource.new_ref_input_with_lang_ver(i.ScriptHash.from_hex(s), i.TransactionInput.new(i.TransactionHash.from_hex(n.txHash), n.txIndex), R[n.version]) : i.PlutusScriptSource.new(i.PlutusScript.from_hex_with_version(n.script.code, R[n.script.version]));
|
|
3609
|
+
e.add_asset(i.MintWitness.new_plutus_script(d, u), i.AssetName.new(Buffer.from(a, "hex")), i.Int.new_i32(o));
|
|
3473
3610
|
};
|
|
3474
3611
|
addNativeMint = (e, { scriptSource: t, assetName: s, amount: n }) => {
|
|
3475
3612
|
if (t.type === "Reference Script")
|
|
3476
3613
|
throw Error("Native mint cannot have reference script");
|
|
3477
|
-
e.add_asset(
|
|
3614
|
+
e.add_asset(i.MintWitness.new_native_script(i.NativeScript.from_hex(t.script.code)), i.AssetName.new(Buffer.from(s, "hex")), i.Int.new_i32(n));
|
|
3478
3615
|
};
|
|
3479
3616
|
queueAllLastItem = () => {
|
|
3480
|
-
this.txOutput && (this.meshTxBuilderBody.outputs.push(this.txOutput), this.txOutput = void 0), this.txInQueueItem && this.queueInput(), this.collateralQueueItem && this.meshTxBuilderBody.collaterals.push(this.collateralQueueItem), this.mintItem && this.queueMint();
|
|
3617
|
+
this.txOutput && (this.meshTxBuilderBody.outputs.push(this.txOutput), this.txOutput = void 0), this.txInQueueItem && this.queueInput(), this.collateralQueueItem && (this.meshTxBuilderBody.collaterals.push(this.collateralQueueItem), this.collateralQueueItem = void 0), this.mintItem && this.queueMint();
|
|
3481
3618
|
};
|
|
3482
3619
|
addCostModels = () => {
|
|
3483
|
-
this.txBuilder.calc_script_data_hash(
|
|
3620
|
+
this.txBuilder.calc_script_data_hash(i.TxBuilderConstants.plutus_vasil_cost_models());
|
|
3484
3621
|
};
|
|
3485
3622
|
addChange = (e) => {
|
|
3486
|
-
this.txBuilder.add_change_if_needed(
|
|
3623
|
+
this.txBuilder.add_change_if_needed(i.Address.from_bech32(e));
|
|
3487
3624
|
};
|
|
3488
3625
|
addValidityRange = ({ invalidBefore: e, invalidHereafter: t }) => {
|
|
3489
|
-
e && this.txBuilder.set_validity_start_interval_bignum(
|
|
3626
|
+
e && this.txBuilder.set_validity_start_interval_bignum(i.BigNum.from_str(e.toString())), t && this.txBuilder.set_ttl_bignum(i.BigNum.from_str(t.toString()));
|
|
3490
3627
|
};
|
|
3491
3628
|
addAllRequiredSignatures = (e) => {
|
|
3492
3629
|
e.forEach((t) => {
|
|
3493
|
-
this.txBuilder.add_required_signer(
|
|
3630
|
+
this.txBuilder.add_required_signer(i.Ed25519KeyHash.from_hex(t));
|
|
3494
3631
|
});
|
|
3495
3632
|
};
|
|
3496
3633
|
addAllMetadata = (e) => {
|
|
3497
3634
|
e.forEach(({ tag: t, metadata: s }) => {
|
|
3498
|
-
this.txBuilder.add_json_metadatum(
|
|
3635
|
+
this.txBuilder.add_json_metadatum(i.BigNum.from_str(t), JSON.stringify(s));
|
|
3499
3636
|
});
|
|
3500
3637
|
};
|
|
3501
3638
|
updateRedeemer = (e, t) => {
|
|
@@ -3515,9 +3652,9 @@ class Zs {
|
|
|
3515
3652
|
});
|
|
3516
3653
|
};
|
|
3517
3654
|
castRawDataToJsonString = (e) => typeof e == "object" ? JSON.stringify(e) : e;
|
|
3518
|
-
castDataToPlutusData = ({ type: e, content: t }) => e === "Mesh" ? tt(t) :
|
|
3655
|
+
castDataToPlutusData = ({ type: e, content: t }) => e === "Mesh" ? tt(t) : e === "CBOR" ? i.PlutusData.from_hex(t) : i.PlutusData.from_json(t, i.PlutusDatumSchema.DetailedSchema);
|
|
3519
3656
|
}
|
|
3520
|
-
class
|
|
3657
|
+
class Tr extends er {
|
|
3521
3658
|
_fetcher;
|
|
3522
3659
|
_submitter;
|
|
3523
3660
|
_evaluator;
|
|
@@ -3527,13 +3664,13 @@ class Dr extends Zs {
|
|
|
3527
3664
|
super(), e && (this._fetcher = e), t && (this._submitter = t), s && (this._evaluator = s), n && (this.isHydra = !0);
|
|
3528
3665
|
}
|
|
3529
3666
|
complete = async (e) => {
|
|
3530
|
-
e ? this.meshTxBuilderBody = e : this.queueAllLastItem()
|
|
3531
|
-
const { inputs: t, collaterals: s } = this.meshTxBuilderBody;
|
|
3532
|
-
if (
|
|
3533
|
-
this.completeTxInformation(
|
|
3667
|
+
e ? this.meshTxBuilderBody = e : this.queueAllLastItem();
|
|
3668
|
+
const { inputs: t, collaterals: s } = this.meshTxBuilderBody, n = [...t, ...s].filter((a) => !this.isInputComplete(a));
|
|
3669
|
+
if (console.log("Incomplete UTxO", n), await this.queryAllTxInfo(n), console.log("Incomplete UTxO", n), n.forEach((a) => {
|
|
3670
|
+
this.completeTxInformation(a);
|
|
3534
3671
|
}), this.completeSync(e), this._evaluator) {
|
|
3535
|
-
const
|
|
3536
|
-
this.updateRedeemer(this.meshTxBuilderBody,
|
|
3672
|
+
const a = await this._evaluator.evaluateTx(this.txHex);
|
|
3673
|
+
this.updateRedeemer(this.meshTxBuilderBody, a), this.completeSync(e);
|
|
3537
3674
|
}
|
|
3538
3675
|
return this;
|
|
3539
3676
|
};
|
|
@@ -3544,43 +3681,50 @@ class Dr extends Zs {
|
|
|
3544
3681
|
getUTxOInfo = async (e) => {
|
|
3545
3682
|
var s;
|
|
3546
3683
|
let t = [];
|
|
3547
|
-
this.queriedTxHashes.has(e) || (this.queriedTxHashes.add(e), t = await ((s = this._fetcher) == null ? void 0 : s.fetchUTxOs(e)) || [], this.queriedUTxOs[e] = t);
|
|
3684
|
+
this.queriedTxHashes.has(e) || (console.log("Query", e), this.queriedTxHashes.add(e), t = await ((s = this._fetcher) == null ? void 0 : s.fetchUTxOs(e)) || [], this.queriedUTxOs[e] = t);
|
|
3548
3685
|
};
|
|
3549
|
-
queryAllTxInfo = () => {
|
|
3550
|
-
var
|
|
3551
|
-
const
|
|
3552
|
-
if (
|
|
3686
|
+
queryAllTxInfo = (e) => {
|
|
3687
|
+
var s;
|
|
3688
|
+
const t = [];
|
|
3689
|
+
if (e.length > 0 && !this._fetcher)
|
|
3553
3690
|
throw Error("Transaction information is incomplete while no fetcher instance is provided");
|
|
3554
|
-
for (let
|
|
3555
|
-
const
|
|
3556
|
-
|
|
3557
|
-
const u = c.scriptTxIn.scriptSource.txInInfo.txHash;
|
|
3558
|
-
e.push(this.getUTxOInfo(u));
|
|
3559
|
-
}
|
|
3560
|
-
}
|
|
3561
|
-
for (let o = 0; o < s.length; o++) {
|
|
3562
|
-
const c = s[o];
|
|
3563
|
-
(!c.txIn.amount || !c.txIn.address) && e.push(this.getUTxOInfo(c.txIn.txHash));
|
|
3691
|
+
for (let n = 0; n < e.length; n++) {
|
|
3692
|
+
const a = e[n];
|
|
3693
|
+
this.isInputInfoComplete(a) || t.push(this.getUTxOInfo(a.txIn.txHash)), a.type === "Script" && ((s = a.scriptTxIn.scriptSource) == null ? void 0 : s.type) === "Inline" && !this.isRefScriptInfoComplete(a) && t.push(this.getUTxOInfo(a.scriptTxIn.scriptSource.txInInfo.txHash));
|
|
3564
3694
|
}
|
|
3565
|
-
return Promise.all(
|
|
3695
|
+
return Promise.all(t);
|
|
3566
3696
|
};
|
|
3567
3697
|
completeTxInformation = (e) => {
|
|
3568
|
-
var
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
throw Error(`Couldn't find script reference utxo for ${c.txHash}#${c.txIndex}`);
|
|
3578
|
-
c.spendingScriptHash = d == null ? void 0 : d.output.scriptHash;
|
|
3698
|
+
var t;
|
|
3699
|
+
if (!this.isInputInfoComplete(e)) {
|
|
3700
|
+
const s = this.queriedUTxOs[e.txIn.txHash], n = s == null ? void 0 : s.find((c) => c.input.outputIndex === e.txIn.txIndex), a = n == null ? void 0 : n.output.amount, o = n == null ? void 0 : n.output.address;
|
|
3701
|
+
if (!a || a.length === 0)
|
|
3702
|
+
throw Error(`Couldn't find value information for ${e.txIn.txHash}#${e.txIn.txIndex}`);
|
|
3703
|
+
if (e.txIn.amount = a, e.type === "PubKey") {
|
|
3704
|
+
if (!o || o === "")
|
|
3705
|
+
throw Error(`Couldn't find address information for ${e.txIn.txHash}#${e.txIn.txIndex}`);
|
|
3706
|
+
e.txIn.address = o;
|
|
3579
3707
|
}
|
|
3580
3708
|
}
|
|
3709
|
+
if (e.type === "Script" && ((t = e.scriptTxIn.scriptSource) == null ? void 0 : t.type) == "Inline" && !this.isRefScriptInfoComplete(e)) {
|
|
3710
|
+
const s = e.scriptTxIn.scriptSource.txInInfo, a = this.queriedUTxOs[s.txHash].find((o) => o.input.outputIndex === s.txIndex);
|
|
3711
|
+
if (!a)
|
|
3712
|
+
throw Error(`Couldn't find script reference utxo for ${s.txHash}#${s.txIndex}`);
|
|
3713
|
+
s.spendingScriptHash = a == null ? void 0 : a.output.scriptHash;
|
|
3714
|
+
}
|
|
3715
|
+
};
|
|
3716
|
+
isInputComplete = (e) => e.type === "PubKey" ? this.isInputInfoComplete(e) : e.type === "Script" ? this.isInputInfoComplete(e) && this.isRefScriptInfoComplete(e) : !0;
|
|
3717
|
+
isInputInfoComplete = (e) => {
|
|
3718
|
+
const { amount: t, address: s } = e.txIn;
|
|
3719
|
+
return !(e.type === "PubKey" && (!t || !s) || e.type === "Script" && !t);
|
|
3720
|
+
};
|
|
3721
|
+
isRefScriptInfoComplete = (e) => {
|
|
3722
|
+
var s;
|
|
3723
|
+
const { scriptSource: t } = e.scriptTxIn;
|
|
3724
|
+
return !((t == null ? void 0 : t.type) === "Inline" && !((s = t.txInInfo) != null && s.spendingScriptHash));
|
|
3581
3725
|
};
|
|
3582
3726
|
}
|
|
3583
|
-
class
|
|
3727
|
+
class B {
|
|
3584
3728
|
_networkId;
|
|
3585
3729
|
_encryptedSecret;
|
|
3586
3730
|
constructor(e, t) {
|
|
@@ -3588,9 +3732,9 @@ class C {
|
|
|
3588
3732
|
}
|
|
3589
3733
|
getAccount(e, t) {
|
|
3590
3734
|
return this.accountContext(e, t, (s, n) => {
|
|
3591
|
-
const
|
|
3735
|
+
const a = fe(this._networkId, s.to_public().hash(), n.to_public().hash()).to_address().to_bech32(), o = _e(this._networkId, s.to_public().hash()).to_address().to_bech32(), c = Ft(this._networkId, n.to_public().hash()).to_address().to_bech32();
|
|
3592
3736
|
return {
|
|
3593
|
-
baseAddress:
|
|
3737
|
+
baseAddress: a,
|
|
3594
3738
|
enterpriseAddress: o,
|
|
3595
3739
|
rewardAddress: c
|
|
3596
3740
|
};
|
|
@@ -3598,29 +3742,29 @@ class C {
|
|
|
3598
3742
|
}
|
|
3599
3743
|
signData(e, t, s, n) {
|
|
3600
3744
|
try {
|
|
3601
|
-
return this.accountContext(e, t, (
|
|
3745
|
+
return this.accountContext(e, t, (a, o) => {
|
|
3602
3746
|
const c = { payload: n }, u = {
|
|
3603
|
-
address:
|
|
3604
|
-
key: s.startsWith("stake") ? o :
|
|
3605
|
-
}, { coseSign1: d, coseKey:
|
|
3606
|
-
return { signature: d, key:
|
|
3747
|
+
address: B.resolveAddress(this._networkId, s, a, o),
|
|
3748
|
+
key: s.startsWith("stake") ? o : a
|
|
3749
|
+
}, { coseSign1: d, coseKey: l } = gs(c, u);
|
|
3750
|
+
return { signature: d, key: l };
|
|
3607
3751
|
});
|
|
3608
|
-
} catch (
|
|
3609
|
-
throw new Error(`An error occurred during signData: ${
|
|
3752
|
+
} catch (a) {
|
|
3753
|
+
throw new Error(`An error occurred during signData: ${a}.`);
|
|
3610
3754
|
}
|
|
3611
3755
|
}
|
|
3612
|
-
signTx(e, t, s, n,
|
|
3756
|
+
signTx(e, t, s, n, a) {
|
|
3613
3757
|
try {
|
|
3614
3758
|
const o = Me(js(n));
|
|
3615
3759
|
return this.accountContext(e, t, (c, u) => {
|
|
3616
|
-
const d =
|
|
3617
|
-
return
|
|
3618
|
-
if (
|
|
3619
|
-
d.add(
|
|
3620
|
-
else if (
|
|
3621
|
-
d.add(
|
|
3622
|
-
else if (
|
|
3623
|
-
throw new Error(`Missing key witness for: ${
|
|
3760
|
+
const d = i.Vkeywitnesses.new();
|
|
3761
|
+
return B.resolveSigners(n, s, c.to_public().hash().to_hex()).forEach((g) => {
|
|
3762
|
+
if (g === c.to_public().hash().to_hex())
|
|
3763
|
+
d.add(i.make_vkey_witness(o, c));
|
|
3764
|
+
else if (g === u.to_public().hash().to_hex())
|
|
3765
|
+
d.add(i.make_vkey_witness(o, u));
|
|
3766
|
+
else if (a === !1)
|
|
3767
|
+
throw new Error(`Missing key witness for: ${g}`);
|
|
3624
3768
|
}), d;
|
|
3625
3769
|
});
|
|
3626
3770
|
} catch (o) {
|
|
@@ -3628,192 +3772,192 @@ class C {
|
|
|
3628
3772
|
}
|
|
3629
3773
|
}
|
|
3630
3774
|
static encryptMnemonic(e, t) {
|
|
3631
|
-
const s = we(e.join(" ")), n =
|
|
3632
|
-
return n.free(),
|
|
3775
|
+
const s = we(e.join(" ")), n = Re(s), a = D(n.as_bytes());
|
|
3776
|
+
return n.free(), B.encrypt(a, t);
|
|
3633
3777
|
}
|
|
3634
3778
|
static encryptPrivateKey(e, t) {
|
|
3635
|
-
const s =
|
|
3636
|
-
return s.free(),
|
|
3779
|
+
const s = i.Bip32PrivateKey.from_bech32(e), n = D(s.as_bytes());
|
|
3780
|
+
return s.free(), B.encrypt(n, t);
|
|
3637
3781
|
}
|
|
3638
3782
|
static encryptSigningKeys(e, t, s) {
|
|
3639
|
-
const n =
|
|
3640
|
-
return [n,
|
|
3783
|
+
const n = B.encrypt(e.slice(4), s), a = B.encrypt(t.slice(4), s);
|
|
3784
|
+
return [n, a];
|
|
3641
3785
|
}
|
|
3642
3786
|
static generateMnemonic(e = 256) {
|
|
3643
3787
|
return ze(e).split(" ");
|
|
3644
3788
|
}
|
|
3645
3789
|
accountContext(e, t, s) {
|
|
3646
|
-
const { paymentKey: n, stakeKey:
|
|
3647
|
-
return n.free(),
|
|
3790
|
+
const { paymentKey: n, stakeKey: a } = B.resolveKeys(e, t, this._encryptedSecret), o = s(n, a);
|
|
3791
|
+
return n.free(), a.free(), o;
|
|
3648
3792
|
}
|
|
3649
3793
|
static decrypt(e, t) {
|
|
3650
3794
|
try {
|
|
3651
|
-
return
|
|
3795
|
+
return i.decrypt_with_password(Q(t), e);
|
|
3652
3796
|
} catch {
|
|
3653
3797
|
throw new Error("The password is incorrect.");
|
|
3654
3798
|
}
|
|
3655
3799
|
}
|
|
3656
3800
|
static encrypt(e, t) {
|
|
3657
|
-
const s = Ce("0123456789abcdef"), n = s(64),
|
|
3658
|
-
return
|
|
3801
|
+
const s = Ce("0123456789abcdef"), n = s(64), a = s(24);
|
|
3802
|
+
return i.encrypt_with_password(Q(t), n, a, e);
|
|
3659
3803
|
}
|
|
3660
3804
|
static resolveAddress(e, t, s, n) {
|
|
3661
|
-
const
|
|
3805
|
+
const a = [
|
|
3662
3806
|
fe(e, s.to_public().hash(), n.to_public().hash()),
|
|
3663
3807
|
_e(e, s.to_public().hash()),
|
|
3664
3808
|
Ft(e, n.to_public().hash())
|
|
3665
3809
|
].find((o) => o.to_address().to_bech32() === t);
|
|
3666
|
-
if (
|
|
3667
|
-
return
|
|
3810
|
+
if (a !== void 0)
|
|
3811
|
+
return a.to_address();
|
|
3668
3812
|
throw new Error(`Address: ${t} doesn't belong to this account.`);
|
|
3669
3813
|
}
|
|
3670
3814
|
static resolveKeys(e, t, s) {
|
|
3671
3815
|
if (typeof s == "string") {
|
|
3672
|
-
const o =
|
|
3816
|
+
const o = B.decrypt(s, t);
|
|
3673
3817
|
return Hs(o, e);
|
|
3674
3818
|
}
|
|
3675
|
-
const n =
|
|
3819
|
+
const n = B.decrypt(s[0], t), a = B.decrypt(s[1], t);
|
|
3676
3820
|
return {
|
|
3677
|
-
paymentKey:
|
|
3678
|
-
stakeKey:
|
|
3821
|
+
paymentKey: i.PrivateKey.from_hex(n),
|
|
3822
|
+
stakeKey: i.PrivateKey.from_hex(a)
|
|
3679
3823
|
};
|
|
3680
3824
|
}
|
|
3681
3825
|
static resolveSigners(e, t, s) {
|
|
3682
3826
|
const n = (c) => {
|
|
3683
|
-
const u = (f,
|
|
3684
|
-
var ft, lt, $t, zt,
|
|
3685
|
-
if (f === void 0 ||
|
|
3686
|
-
return
|
|
3687
|
-
const
|
|
3688
|
-
switch (
|
|
3689
|
-
case
|
|
3690
|
-
const
|
|
3691
|
-
|
|
3827
|
+
const u = (f, x = [], C = 0) => {
|
|
3828
|
+
var ft, lt, $t, zt, Jt;
|
|
3829
|
+
if (f === void 0 || C >= f.len())
|
|
3830
|
+
return x;
|
|
3831
|
+
const U = f.get(C), P = new Array();
|
|
3832
|
+
switch (U.kind()) {
|
|
3833
|
+
case i.CertificateKind.StakeDeregistration: {
|
|
3834
|
+
const w = (ft = U.as_stake_deregistration()) == null ? void 0 : ft.stake_credential(), q = (w == null ? void 0 : w.kind()) === i.StakeCredKind.Key ? w.to_keyhash() : void 0;
|
|
3835
|
+
q && P.push(q.to_hex());
|
|
3692
3836
|
break;
|
|
3693
3837
|
}
|
|
3694
|
-
case
|
|
3695
|
-
const
|
|
3696
|
-
|
|
3838
|
+
case i.CertificateKind.StakeDelegation: {
|
|
3839
|
+
const w = (lt = U.as_stake_delegation()) == null ? void 0 : lt.stake_credential(), q = (w == null ? void 0 : w.kind()) === i.StakeCredKind.Key ? w.to_keyhash() : void 0;
|
|
3840
|
+
q && P.push(q.to_hex());
|
|
3697
3841
|
break;
|
|
3698
3842
|
}
|
|
3699
|
-
case
|
|
3700
|
-
const
|
|
3701
|
-
|
|
3843
|
+
case i.CertificateKind.PoolRegistration: {
|
|
3844
|
+
const w = ($t = U.as_pool_registration()) == null ? void 0 : $t.pool_params().pool_owners();
|
|
3845
|
+
P.push(...l(w));
|
|
3702
3846
|
break;
|
|
3703
3847
|
}
|
|
3704
|
-
case
|
|
3705
|
-
const
|
|
3706
|
-
|
|
3848
|
+
case i.CertificateKind.PoolRetirement: {
|
|
3849
|
+
const w = (zt = U.as_pool_retirement()) == null ? void 0 : zt.pool_keyhash();
|
|
3850
|
+
w && P.push(w.to_hex());
|
|
3707
3851
|
break;
|
|
3708
3852
|
}
|
|
3709
|
-
case
|
|
3710
|
-
const
|
|
3711
|
-
if (
|
|
3712
|
-
for (let
|
|
3713
|
-
const
|
|
3714
|
-
jt &&
|
|
3853
|
+
case i.CertificateKind.MoveInstantaneousRewardsCert: {
|
|
3854
|
+
const w = (Jt = U.as_move_instantaneous_rewards_cert()) == null ? void 0 : Jt.move_instantaneous_reward().as_to_stake_creds();
|
|
3855
|
+
if (w)
|
|
3856
|
+
for (let q = 0; q < w.len(); q += 1) {
|
|
3857
|
+
const Wt = w.keys().get(q), jt = Wt.kind() === i.StakeCredKind.Key ? Wt.to_keyhash() : void 0;
|
|
3858
|
+
jt && P.push(jt.to_hex());
|
|
3715
3859
|
}
|
|
3716
3860
|
break;
|
|
3717
3861
|
}
|
|
3718
3862
|
}
|
|
3719
|
-
return u(f, [...
|
|
3720
|
-
}, d = (f,
|
|
3721
|
-
if (f === void 0 ||
|
|
3722
|
-
return
|
|
3723
|
-
const
|
|
3724
|
-
return d(f, [...
|
|
3725
|
-
},
|
|
3726
|
-
if (f === void 0 ||
|
|
3727
|
-
return
|
|
3728
|
-
const
|
|
3729
|
-
return
|
|
3730
|
-
},
|
|
3863
|
+
return u(f, [...x, ...P], C + 1);
|
|
3864
|
+
}, d = (f, x = [], C = 0) => {
|
|
3865
|
+
if (f === void 0 || C >= f.len())
|
|
3866
|
+
return x;
|
|
3867
|
+
const U = f.get(C).index(), P = f.get(C).transaction_id(), ft = t.find((lt) => lt.input.outputIndex === U && lt.input.txHash === P.to_hex()) !== void 0 ? s : "OUR_PRINCESS_IS_IN_ANOTHER_CASTLE";
|
|
3868
|
+
return d(f, [...x, ft], C + 1);
|
|
3869
|
+
}, l = (f, x = [], C = 0) => f === void 0 || C >= f.len() ? x : l(f, [...x, f.get(C).to_hex()], C + 1), g = (f, x = [], C = 0) => {
|
|
3870
|
+
if (f === void 0 || C >= f.len())
|
|
3871
|
+
return x;
|
|
3872
|
+
const U = f.keys().get(C).payment_cred(), P = U.kind() === i.StakeCredKind.Key ? U.to_keyhash() : void 0;
|
|
3873
|
+
return g(f, P ? [...x, P.to_hex()] : x, C + 1);
|
|
3874
|
+
}, A = c.certs(), m = c.collateral(), p = c.inputs(), S = c.required_signers(), E = c.withdrawals();
|
|
3731
3875
|
return [
|
|
3732
|
-
...u(
|
|
3733
|
-
...d(
|
|
3734
|
-
...d(
|
|
3735
|
-
...
|
|
3736
|
-
...
|
|
3876
|
+
...u(A),
|
|
3877
|
+
...d(m),
|
|
3878
|
+
...d(p),
|
|
3879
|
+
...l(S),
|
|
3880
|
+
...g(E)
|
|
3737
3881
|
];
|
|
3738
|
-
},
|
|
3739
|
-
const u = (
|
|
3740
|
-
var
|
|
3741
|
-
if (
|
|
3742
|
-
for (let
|
|
3743
|
-
const f =
|
|
3882
|
+
}, a = (c) => {
|
|
3883
|
+
const u = (l, g = []) => {
|
|
3884
|
+
var A, m, p, S;
|
|
3885
|
+
if (l)
|
|
3886
|
+
for (let E = 0; E < l.len(); E += 1) {
|
|
3887
|
+
const f = l.get(E);
|
|
3744
3888
|
switch (f.kind()) {
|
|
3745
|
-
case
|
|
3746
|
-
const
|
|
3747
|
-
return
|
|
3889
|
+
case i.NativeScriptKind.ScriptPubkey: {
|
|
3890
|
+
const x = (A = f.as_script_pubkey()) == null ? void 0 : A.addr_keyhash().to_hex();
|
|
3891
|
+
return x ? [...g, x] : g;
|
|
3748
3892
|
}
|
|
3749
|
-
case
|
|
3750
|
-
return u((
|
|
3751
|
-
case
|
|
3752
|
-
return u((
|
|
3753
|
-
case
|
|
3754
|
-
return u((
|
|
3893
|
+
case i.NativeScriptKind.ScriptAll:
|
|
3894
|
+
return u((m = f.as_script_all()) == null ? void 0 : m.native_scripts(), g);
|
|
3895
|
+
case i.NativeScriptKind.ScriptAny:
|
|
3896
|
+
return u((p = f.as_script_any()) == null ? void 0 : p.native_scripts(), g);
|
|
3897
|
+
case i.NativeScriptKind.ScriptNOfK:
|
|
3898
|
+
return u((S = f.as_script_n_of_k()) == null ? void 0 : S.native_scripts(), g);
|
|
3755
3899
|
}
|
|
3756
3900
|
}
|
|
3757
|
-
return
|
|
3901
|
+
return g;
|
|
3758
3902
|
}, d = c.native_scripts();
|
|
3759
3903
|
return [
|
|
3760
3904
|
...u(d)
|
|
3761
3905
|
];
|
|
3762
|
-
}, o =
|
|
3906
|
+
}, o = L(e);
|
|
3763
3907
|
return /* @__PURE__ */ new Set([
|
|
3764
3908
|
...n(o.body()),
|
|
3765
|
-
...
|
|
3909
|
+
...a(o.witness_set())
|
|
3766
3910
|
]);
|
|
3767
3911
|
}
|
|
3768
3912
|
}
|
|
3769
|
-
const
|
|
3770
|
-
class
|
|
3913
|
+
const N = "MARI0TIME";
|
|
3914
|
+
class Ur {
|
|
3771
3915
|
_fetcher;
|
|
3772
3916
|
_submitter;
|
|
3773
3917
|
_wallet;
|
|
3774
3918
|
constructor(e) {
|
|
3775
3919
|
switch (this._fetcher = e.fetcher, this._submitter = e.submitter, e.key.type) {
|
|
3776
3920
|
case "mnemonic":
|
|
3777
|
-
this._wallet = new
|
|
3921
|
+
this._wallet = new B(e.networkId, B.encryptMnemonic(e.key.words, N));
|
|
3778
3922
|
break;
|
|
3779
3923
|
case "root":
|
|
3780
|
-
this._wallet = new
|
|
3924
|
+
this._wallet = new B(e.networkId, B.encryptPrivateKey(e.key.bech32, N));
|
|
3781
3925
|
break;
|
|
3782
3926
|
case "cli":
|
|
3783
|
-
this._wallet = new
|
|
3927
|
+
this._wallet = new B(e.networkId, B.encryptSigningKeys(e.key.payment, e.key.stake ?? "f0".repeat(34), N));
|
|
3784
3928
|
}
|
|
3785
3929
|
}
|
|
3786
3930
|
getBaseAddress(e = 0) {
|
|
3787
|
-
return this._wallet.getAccount(e,
|
|
3931
|
+
return this._wallet.getAccount(e, N).baseAddress;
|
|
3788
3932
|
}
|
|
3789
3933
|
getPaymentAddress(e = 0) {
|
|
3790
|
-
return this._wallet.getAccount(e,
|
|
3934
|
+
return this._wallet.getAccount(e, N).enterpriseAddress;
|
|
3791
3935
|
}
|
|
3792
3936
|
getRewardAddress(e = 0) {
|
|
3793
|
-
return this._wallet.getAccount(e,
|
|
3937
|
+
return this._wallet.getAccount(e, N).rewardAddress;
|
|
3794
3938
|
}
|
|
3795
3939
|
getUsedAddress(e = 0) {
|
|
3796
|
-
const t = this._wallet.getAccount(e,
|
|
3940
|
+
const t = this._wallet.getAccount(e, N);
|
|
3797
3941
|
return K(t.enterpriseAddress);
|
|
3798
3942
|
}
|
|
3799
|
-
getUsedCollateral(e =
|
|
3943
|
+
getUsedCollateral(e = k.maxCollateralInputs) {
|
|
3800
3944
|
throw new Error("getUsedCollateral not implemented.");
|
|
3801
3945
|
}
|
|
3802
3946
|
async getUsedUTxOs(e = 0) {
|
|
3803
|
-
const t = this._wallet.getAccount(e,
|
|
3804
|
-
return (await this._fetcher.fetchAddressUTxOs(t.enterpriseAddress)).map((n) =>
|
|
3947
|
+
const t = this._wallet.getAccount(e, N);
|
|
3948
|
+
return (await this._fetcher.fetchAddressUTxOs(t.enterpriseAddress)).map((n) => H(n));
|
|
3805
3949
|
}
|
|
3806
3950
|
signData(e, t, s = 0) {
|
|
3807
3951
|
try {
|
|
3808
|
-
return this._wallet.signData(s,
|
|
3952
|
+
return this._wallet.signData(s, N, e, t);
|
|
3809
3953
|
} catch (n) {
|
|
3810
3954
|
throw new Error(`[AppWallet] An error occurred during signData: ${n}.`);
|
|
3811
3955
|
}
|
|
3812
3956
|
}
|
|
3813
3957
|
async signTx(e, t = !1, s = 0) {
|
|
3814
3958
|
try {
|
|
3815
|
-
const n = this._wallet.getAccount(s,
|
|
3816
|
-
return u.set_vkeys(d),
|
|
3959
|
+
const n = this._wallet.getAccount(s, N), a = await this._fetcher.fetchAddressUTxOs(n.enterpriseAddress), o = this._wallet.signTx(s, N, a, e, t), c = L(e), u = c.witness_set(), d = Ge(u, o);
|
|
3960
|
+
return u.set_vkeys(d), i.Transaction.new(c.body(), u, c.auxiliary_data()).to_hex();
|
|
3817
3961
|
} catch (n) {
|
|
3818
3962
|
throw new Error(`[AppWallet] An error occurred during signTx: ${n}.`);
|
|
3819
3963
|
}
|
|
@@ -3822,7 +3966,7 @@ class kr {
|
|
|
3822
3966
|
return this._submitter.submitTx(e);
|
|
3823
3967
|
}
|
|
3824
3968
|
static brew(e = 256) {
|
|
3825
|
-
return
|
|
3969
|
+
return B.generateMnemonic(e);
|
|
3826
3970
|
}
|
|
3827
3971
|
}
|
|
3828
3972
|
class Ot {
|
|
@@ -3844,18 +3988,18 @@ class Ot {
|
|
|
3844
3988
|
return new Ot(t);
|
|
3845
3989
|
throw new Error(`Couldn't create an instance of wallet: ${e}`);
|
|
3846
3990
|
} catch (t) {
|
|
3847
|
-
throw new Error(`[BrowserWallet] An error occurred during enable: ${t}.`);
|
|
3991
|
+
throw new Error(`[BrowserWallet] An error occurred during enable: ${JSON.stringify(t)}.`);
|
|
3848
3992
|
}
|
|
3849
3993
|
}
|
|
3850
3994
|
async getBalance() {
|
|
3851
3995
|
const e = await this._walletInstance.getBalance();
|
|
3852
|
-
return
|
|
3996
|
+
return qe(Gs(e));
|
|
3853
3997
|
}
|
|
3854
3998
|
async getChangeAddress() {
|
|
3855
3999
|
const e = await this._walletInstance.getChangeAddress();
|
|
3856
4000
|
return nt(e).to_bech32();
|
|
3857
4001
|
}
|
|
3858
|
-
async getCollateral(e =
|
|
4002
|
+
async getCollateral(e = k.maxCollateralInputs) {
|
|
3859
4003
|
return (await this.getUsedCollateral(e)).map((s) => vt(s));
|
|
3860
4004
|
}
|
|
3861
4005
|
getNetworkId() {
|
|
@@ -3875,12 +4019,12 @@ class Ot {
|
|
|
3875
4019
|
}
|
|
3876
4020
|
signData(e, t) {
|
|
3877
4021
|
const s = K(e).to_hex();
|
|
3878
|
-
return this._walletInstance.signData(s,
|
|
4022
|
+
return this._walletInstance.signData(s, Q(t));
|
|
3879
4023
|
}
|
|
3880
4024
|
async signTx(e, t = !1) {
|
|
3881
4025
|
try {
|
|
3882
|
-
const s =
|
|
3883
|
-
return n.set_vkeys(c),
|
|
4026
|
+
const s = L(e), n = s.witness_set(), a = await this._walletInstance.signTx(e, t), o = Ls(a).vkeys() ?? i.Vkeywitnesses.new(), c = Ge(n, o);
|
|
4027
|
+
return n.set_vkeys(c), D(i.Transaction.new(s.body(), n, s.auxiliary_data()).to_bytes());
|
|
3884
4028
|
} catch (s) {
|
|
3885
4029
|
throw new Error(`[BrowserWallet] An error occurred during signTx: ${JSON.stringify(s)}.`);
|
|
3886
4030
|
}
|
|
@@ -3892,7 +4036,7 @@ class Ot {
|
|
|
3892
4036
|
const e = await this._walletInstance.getUsedAddresses();
|
|
3893
4037
|
return nt(e[0]);
|
|
3894
4038
|
}
|
|
3895
|
-
async getUsedCollateral(e =
|
|
4039
|
+
async getUsedCollateral(e = k.maxCollateralInputs) {
|
|
3896
4040
|
return (await this._walletInstance.experimental.getCollateral() ?? []).map((s) => Ie(s)).slice(0, e);
|
|
3897
4041
|
}
|
|
3898
4042
|
async getUsedUTxOs() {
|
|
@@ -3900,12 +4044,12 @@ class Ot {
|
|
|
3900
4044
|
}
|
|
3901
4045
|
async getAssets() {
|
|
3902
4046
|
return (await this.getBalance()).filter((t) => t.unit !== "lovelace").map((t) => {
|
|
3903
|
-
const s = t.unit.slice(0,
|
|
4047
|
+
const s = t.unit.slice(0, O), n = t.unit.slice(O), a = Ws(s, n);
|
|
3904
4048
|
return {
|
|
3905
4049
|
unit: t.unit,
|
|
3906
4050
|
policyId: s,
|
|
3907
4051
|
assetName: Gt(n),
|
|
3908
|
-
fingerprint:
|
|
4052
|
+
fingerprint: a,
|
|
3909
4053
|
quantity: t.quantity
|
|
3910
4054
|
};
|
|
3911
4055
|
});
|
|
@@ -3919,7 +4063,7 @@ class Ot {
|
|
|
3919
4063
|
}
|
|
3920
4064
|
async getPolicyIds() {
|
|
3921
4065
|
const e = await this.getBalance();
|
|
3922
|
-
return Array.from(new Set(e.map((t) => t.unit.slice(0,
|
|
4066
|
+
return Array.from(new Set(e.map((t) => t.unit.slice(0, O)))).filter((t) => t !== "lovelace");
|
|
3923
4067
|
}
|
|
3924
4068
|
static resolveInstance(e) {
|
|
3925
4069
|
if (window.cardano === void 0)
|
|
@@ -3928,11 +4072,11 @@ class Ot {
|
|
|
3928
4072
|
return t == null ? void 0 : t.enable();
|
|
3929
4073
|
}
|
|
3930
4074
|
}
|
|
3931
|
-
const $e = "http://localhost:4000/",
|
|
3932
|
-
class
|
|
4075
|
+
const $e = "http://localhost:4000/", sr = "http://localhost:5000/", rr = `${$e}access`, nr = `${$e}transaction/signtx`;
|
|
4076
|
+
class Pr {
|
|
3933
4077
|
static getAxiosInstance() {
|
|
3934
|
-
return
|
|
3935
|
-
baseURL:
|
|
4078
|
+
return G.create({
|
|
4079
|
+
baseURL: sr,
|
|
3936
4080
|
withCredentials: !0
|
|
3937
4081
|
});
|
|
3938
4082
|
}
|
|
@@ -3943,9 +4087,9 @@ class Tr {
|
|
|
3943
4087
|
const t = this.getAppId();
|
|
3944
4088
|
e.includes("?") ? e = `${e}&appId=${t}` : e = `${e}?appId=${t}`;
|
|
3945
4089
|
const s = "left=100,top=100,width=540,height=540", n = window.open(e, "meshWindow", s);
|
|
3946
|
-
return n || console.error("the window did not open", n), await (async () => new Promise((
|
|
4090
|
+
return n || console.error("the window did not open", n), await (async () => new Promise((a) => {
|
|
3947
4091
|
window.addEventListener("message", async (o) => {
|
|
3948
|
-
o.data.target == "minaWallet" &&
|
|
4092
|
+
o.data.target == "minaWallet" && a(o.data);
|
|
3949
4093
|
});
|
|
3950
4094
|
}))();
|
|
3951
4095
|
}
|
|
@@ -3965,7 +4109,7 @@ class Tr {
|
|
|
3965
4109
|
}
|
|
3966
4110
|
}
|
|
3967
4111
|
static async enable() {
|
|
3968
|
-
return await this.get("wallet/getuserwalletsmeta") === void 0 ? await this.openMinaFrontend(
|
|
4112
|
+
return await this.get("wallet/getuserwalletsmeta") === void 0 ? await this.openMinaFrontend(rr) : !0;
|
|
3969
4113
|
}
|
|
3970
4114
|
static async getChangeAddress(e = void 0, t = void 0) {
|
|
3971
4115
|
return await this.get("wallet/getchangeaddress", {
|
|
@@ -3982,11 +4126,11 @@ class Tr {
|
|
|
3982
4126
|
static async signTx(e, t = !1) {
|
|
3983
4127
|
const s = await this.get("wallet/getuserwalletsmeta");
|
|
3984
4128
|
if (console.log("userWalletsMeta", s), s) {
|
|
3985
|
-
const n = await this.openMinaFrontend(`${
|
|
3986
|
-
if (n instanceof
|
|
3987
|
-
const
|
|
4129
|
+
const n = await this.openMinaFrontend(`${nr}?unsignedTx=${e}&partialSign=${t}`);
|
|
4130
|
+
if (n instanceof i.Vkeywitnesses) {
|
|
4131
|
+
const a = L(e), o = a.witness_set();
|
|
3988
4132
|
o.set_vkeys(n);
|
|
3989
|
-
const c =
|
|
4133
|
+
const c = i.Transaction.new(a.body(), o, a.auxiliary_data()).to_hex();
|
|
3990
4134
|
return console.log("signedTx", c), c;
|
|
3991
4135
|
}
|
|
3992
4136
|
} else
|
|
@@ -3994,43 +4138,43 @@ class Tr {
|
|
|
3994
4138
|
}
|
|
3995
4139
|
}
|
|
3996
4140
|
export {
|
|
3997
|
-
|
|
3998
|
-
|
|
4141
|
+
Ur as AppWallet,
|
|
4142
|
+
Br as BlockfrostProvider,
|
|
3999
4143
|
Ot as BrowserWallet,
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4144
|
+
B as EmbeddedWallet,
|
|
4145
|
+
Dr as ForgeScript,
|
|
4146
|
+
Sr as InfuraProvider,
|
|
4147
|
+
Er as KoiosProvider,
|
|
4148
|
+
vr as MaestroProvider,
|
|
4149
|
+
Tr as MeshTxBuilder,
|
|
4150
|
+
Pr as MinaWallet,
|
|
4151
|
+
br as OgmiosProvider,
|
|
4152
|
+
Qr as TangoProvider,
|
|
4153
|
+
z as Transaction,
|
|
4154
|
+
dr as checkSignature,
|
|
4155
|
+
xr as generateNonce,
|
|
4012
4156
|
es as isNetwork,
|
|
4013
4157
|
is as keepRelevant,
|
|
4014
|
-
|
|
4158
|
+
ur as largestFirst,
|
|
4015
4159
|
os as largestFirstMultiAsset,
|
|
4016
4160
|
et as parseAssetUnit,
|
|
4017
4161
|
h as parseHttpError,
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4162
|
+
Cr as readPlutusData,
|
|
4163
|
+
wr as readTransaction,
|
|
4164
|
+
hr as resolveDataHash,
|
|
4165
|
+
lr as resolveEpochNo,
|
|
4166
|
+
Ws as resolveFingerprint,
|
|
4167
|
+
gr as resolveLanguageView,
|
|
4168
|
+
Ar as resolveNativeScriptHash,
|
|
4025
4169
|
it as resolvePaymentKeyHash,
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4170
|
+
mr as resolvePlutusScriptAddress,
|
|
4171
|
+
Ir as resolvePlutusScriptHash,
|
|
4172
|
+
pr as resolvePoolId,
|
|
4173
|
+
fr as resolvePrivateKey,
|
|
4030
4174
|
Ut as resolveRewardAddress,
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4175
|
+
_r as resolveScriptRef,
|
|
4176
|
+
yr as resolveSlotNo,
|
|
4177
|
+
At as resolveStakeKeyHash,
|
|
4034
4178
|
Le as resolveTxFees,
|
|
4035
4179
|
js as resolveTxHash
|
|
4036
4180
|
};
|