@meshsdk/core 1.5.11-beta.1 → 1.5.11-beta.3
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.js
CHANGED
|
@@ -2,11 +2,11 @@ import { customAlphabet as Ce } from "nanoid";
|
|
|
2
2
|
import * as a from "@emurgo/cardano-serialization-lib-nodejs";
|
|
3
3
|
import L from "axios";
|
|
4
4
|
import { mnemonicToEntropy as we, generateMnemonic as ze } from "bip39";
|
|
5
|
-
import { COSEKey as Be, COSESign1 as We, Label as X, Int as
|
|
6
|
-
const ts = ["testnet", "preview", "preprod", "mainnet"], es = (r) => ts.includes(r),
|
|
5
|
+
import { COSEKey as Be, COSESign1 as We, Label as X, Int as wt, BigNum as Nt, KeyType as Je, 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
|
+
const ts = ["testnet", "preview", "preprod", "mainnet"], es = (r) => ts.includes(r), at = {
|
|
7
7
|
mem: 7e6,
|
|
8
8
|
steps: 3e9
|
|
9
|
-
},
|
|
9
|
+
}, v = {
|
|
10
10
|
epoch: 0,
|
|
11
11
|
coinsPerUTxOSize: "4310",
|
|
12
12
|
priceMem: 0.0577,
|
|
@@ -27,7 +27,7 @@ const ts = ["testnet", "preview", "preprod", "mainnet"], es = (r) => ts.includes
|
|
|
27
27
|
maxTxExSteps: "10000000000",
|
|
28
28
|
maxBlockExMem: "80000000",
|
|
29
29
|
maxBlockExSteps: "40000000000"
|
|
30
|
-
},
|
|
30
|
+
}, Pt = 2147483648, R = {
|
|
31
31
|
V1: a.Language.new_plutus_v1(),
|
|
32
32
|
V2: a.Language.new_plutus_v2()
|
|
33
33
|
}, F = 56, ss = {
|
|
@@ -35,7 +35,7 @@ const ts = ["testnet", "preview", "preprod", "mainnet"], es = (r) => ts.includes
|
|
|
35
35
|
MINT: a.RedeemerTag.new_mint(),
|
|
36
36
|
REWARD: a.RedeemerTag.new_reward(),
|
|
37
37
|
SPEND: a.RedeemerTag.new_spend()
|
|
38
|
-
},
|
|
38
|
+
}, Qt = {
|
|
39
39
|
testnet: ["74", "1598400", "1595967616", "432000"],
|
|
40
40
|
preview: ["183", "15811222", "1682467200", "86400"],
|
|
41
41
|
preprod: ["65", "26438400", "1682121600", "432000"],
|
|
@@ -453,77 +453,77 @@ const ts = ["testnet", "preview", "preprod", "mainnet"], es = (r) => ts.includes
|
|
|
453
453
|
...i.less_than(s) ? hs(s.clamped_sub(i).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
|
-
}, or = (r, e, t = !1, { maxTxSize: s, minFeeA: n, minFeeB: i } =
|
|
457
|
-
const o = e.filter((l) =>
|
|
458
|
-
return
|
|
456
|
+
}, or = (r, e, t = !1, { maxTxSize: s, minFeeA: n, minFeeB: i } = v) => {
|
|
457
|
+
const o = e.filter((l) => Ee(l) === !1).sort(Rt), c = a.BigNum.from_str(Le(s, n, i)), u = t ? a.BigNum.from_str(r).checked_add(c).to_str() : r;
|
|
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(
|
|
463
|
-
return r.set("lovelace", c),
|
|
461
|
+
}, os = (r, e, t = !1, s = v) => {
|
|
462
|
+
const n = e.filter(Ee).sort(Rt), i = us(s), o = r.get("lovelace") ?? "0", c = t ? a.BigNum.from_str(o).checked_add(i).to_str() : o;
|
|
463
|
+
return r.set("lovelace", c), It(n, r);
|
|
464
464
|
}, cs = (r, e) => Array.from(e, (t) => ({ unit: t[0], quantity: a.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
465
|
const i = n.output.amount.reduce((o, c) => o.checked_add(a.BigNum.from_str(t.unit === c.unit ? c.quantity : "0")), a.BigNum.from_str("0"));
|
|
466
466
|
return s.checked_add(i);
|
|
467
|
-
}, a.BigNum.from_str("0")).less_than(t.quantity) === !1),
|
|
467
|
+
}, a.BigNum.from_str("0")).less_than(t.quantity) === !1), Rt = (r, e) => {
|
|
468
468
|
var n, i;
|
|
469
469
|
const t = a.BigNum.from_str(((n = r.output.amount.find((o) => o.unit === "lovelace")) == null ? void 0 : n.quantity) ?? "0");
|
|
470
470
|
return a.BigNum.from_str(((i = e.output.amount.find((o) => o.unit === "lovelace")) == null ? void 0 : i.quantity) ?? "0").compare(t);
|
|
471
471
|
}, us = (r) => {
|
|
472
472
|
const { maxTxSize: e, minFeeA: t, minFeeB: s } = r;
|
|
473
473
|
return a.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
476
|
const s = ((n = t.output.amount.find((i) => i.unit === "lovelace")) == null ? void 0 : n.quantity) ?? "0";
|
|
477
477
|
return e.checked_add(a.BigNum.from_str(s));
|
|
478
478
|
}, a.BigNum.from_str("0")), hs = (r, e) => {
|
|
479
|
-
const t = e.sort(
|
|
480
|
-
return
|
|
479
|
+
const t = e.sort(Rt);
|
|
480
|
+
return It(t, /* @__PURE__ */ new Map([
|
|
481
481
|
["lovelace", r]
|
|
482
482
|
]));
|
|
483
|
-
},
|
|
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), As = (r, e) => {
|
|
484
484
|
const t = ms(e), s = Is(r, e);
|
|
485
485
|
return {
|
|
486
|
-
coseKey:
|
|
487
|
-
coseSign1:
|
|
486
|
+
coseKey: b(t.to_bytes()),
|
|
487
|
+
coseSign1: b(s.to_bytes())
|
|
488
488
|
};
|
|
489
489
|
}, cr = (r, e, { key: t, signature: s }) => {
|
|
490
490
|
var o, c;
|
|
491
|
-
const n = Be.from_bytes(
|
|
491
|
+
const n = Be.from_bytes(p(t)), i = We.from_bytes(p(s));
|
|
492
492
|
if ((r == null ? void 0 : r.length) > 0) {
|
|
493
|
-
const u =
|
|
494
|
-
if (
|
|
493
|
+
const u = b(i.payload() ?? new Uint8Array());
|
|
494
|
+
if (E(r) !== u)
|
|
495
495
|
return !1;
|
|
496
496
|
}
|
|
497
497
|
if ((e == null ? void 0 : e.length) > 0) {
|
|
498
498
|
const d = (o = i.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 A = (c = n.header(X.new_int(
|
|
501
|
+
const A = (c = n.header(X.new_int(wt.new_negative(Nt.from_str("2"))))) == null ? void 0 : c.as_bytes();
|
|
502
502
|
if (A === void 0)
|
|
503
503
|
throw new Error("Couldn't find a signer key in signature");
|
|
504
|
-
const l =
|
|
504
|
+
const l = nt(b(d)), g = Rs(b(A));
|
|
505
505
|
if (gs(e, l, g) === !1)
|
|
506
506
|
throw new Error("Couldn't check signature because of address mismatch");
|
|
507
|
-
const
|
|
508
|
-
return g.verify(y,
|
|
507
|
+
const I = Vs(b(i.signature())), y = i.signed_data().to_bytes();
|
|
508
|
+
return g.verify(y, I);
|
|
509
509
|
}
|
|
510
510
|
return !1;
|
|
511
511
|
}, gs = (r, e, t) => {
|
|
512
512
|
if (r !== e.to_bech32())
|
|
513
513
|
return !1;
|
|
514
514
|
try {
|
|
515
|
-
return
|
|
515
|
+
return gt(r) === t.hash().to_hex();
|
|
516
516
|
} catch {
|
|
517
517
|
return !1;
|
|
518
518
|
}
|
|
519
519
|
}, ms = (r) => {
|
|
520
520
|
const e = Be.new(X.from_key_type(Je.OKP));
|
|
521
|
-
return e.set_algorithm_id(X.from_algorithm_id(
|
|
521
|
+
return e.set_algorithm_id(X.from_algorithm_id(Se.EdDSA)), e.set_header(X.new_int(wt.new_negative(Nt.from_str("1"))), Mt.new_int(wt.new_i32(6))), e.set_header(X.new_int(wt.new_negative(Nt.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
|
-
t.set_algorithm_id(X.from_algorithm_id(
|
|
525
|
-
const n = je.new(Xe.new(t), s), i = Ze.new(n,
|
|
526
|
-
r.externalAAD !== void 0 && i.set_external_aad(
|
|
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), i = Ze.new(n, p(r.payload), !1);
|
|
526
|
+
r.externalAAD !== void 0 && i.set_external_aad(p(r.externalAAD));
|
|
527
527
|
const o = i.make_data_to_sign(), c = e.key.sign(o.to_bytes());
|
|
528
528
|
return i.build(c.to_bytes());
|
|
529
529
|
};
|
|
@@ -550,10 +550,10 @@ var O = { 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 = qt;
|
|
554
|
+
qt.supported = typeof WebAssembly < "u";
|
|
555
|
+
function qt(r) {
|
|
556
|
+
if (!qt.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+YTqACEJQrvOqqbY0Ouzu38hCkKr8NP0r+68tzwhC0Lx7fT4paf9p6V/IQxC0YWa7/rPlI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AKhYU3AwAgIyAjKQMAIAMgC4WFNwMAICQgJCkDACAEIAyFhTcDACAlICUpAwAgBSANhYU3AwAgJiAmKQMAIAYgDoWFNwMAICcgJykDACAHIA+FhTcDACAoICgpAwAgCCAQhYU3AwAL"), s = null, n = {
|
|
559
559
|
buffer: t,
|
|
@@ -593,7 +593,7 @@ function Cs(r) {
|
|
|
593
593
|
function ws(r) {
|
|
594
594
|
return r.charCodeAt(0);
|
|
595
595
|
}
|
|
596
|
-
var N = be, _ = xs(),
|
|
596
|
+
var N = be, _ = xs(), q = 64, Bt = [];
|
|
597
597
|
O.exports = D;
|
|
598
598
|
var se = O.exports.BYTES_MIN = 16, re = O.exports.BYTES_MAX = 64;
|
|
599
599
|
O.exports.BYTES = 32;
|
|
@@ -605,16 +605,16 @@ function D(r, e, t, s, n) {
|
|
|
605
605
|
return new D(r, e, t, s, n);
|
|
606
606
|
if (!(_ && _.exports))
|
|
607
607
|
throw new Error("WASM not loaded. Wait for Blake2b.ready(cb)");
|
|
608
|
-
r || (r = 32), n !== !0 && (N(r >= se, "digestLength must be at least " + se + ", was given " + r), N(r <= re, "digestLength must be at most " + re + ", was given " + r), e != null && N(e.length >= ne, "key must be at least " + ne + ", was given " + e.length), e != null && N(e.length <= ae, "key must be at least " + ae + ", was given " + e.length), t != null && N(t.length === ie, "salt must be exactly " + ie + ", was given " + t.length), s != null && N(s.length === oe, "personal must be exactly " + oe + ", was given " + s.length)),
|
|
608
|
+
r || (r = 32), n !== !0 && (N(r >= se, "digestLength must be at least " + se + ", was given " + r), N(r <= re, "digestLength must be at most " + re + ", was given " + r), e != null && N(e.length >= ne, "key must be at least " + ne + ", was given " + e.length), e != null && N(e.length <= ae, "key must be at least " + ae + ", was given " + e.length), t != null && N(t.length === ie, "salt must be exactly " + ie + ", was given " + t.length), s != null && N(s.length === oe, "personal must be exactly " + oe + ", was given " + s.length)), Bt.length || (Bt.push(q), q += 216), this.digestLength = r, this.finalized = !1, this.pointer = Bt.pop(), _.memory.fill(0, 0, 64), _.memory[0] = this.digestLength, _.memory[1] = e ? e.length : 0, _.memory[2] = 1, _.memory[3] = 1, t && _.memory.set(t, 32), s && _.memory.set(s, 48), this.pointer + 216 > _.memory.length && _.realloc(this.pointer + 216), _.exports.blake2b_init(this.pointer, this.digestLength), e && (this.update(e), _.memory.fill(0, q, q + e.length), _.memory[this.pointer + 200] = 128);
|
|
609
609
|
}
|
|
610
610
|
D.prototype.update = function(r) {
|
|
611
|
-
return N(this.finalized === !1, "Hash instance finalized"), N(r, "input must be TypedArray or Buffer"),
|
|
611
|
+
return N(this.finalized === !1, "Hash instance finalized"), N(r, "input must be TypedArray or Buffer"), q + r.length > _.memory.length && _.realloc(q + r.length), _.memory.set(r, q), _.exports.blake2b_update(this.pointer, q, q + r.length), this;
|
|
612
612
|
};
|
|
613
613
|
D.prototype.digest = function(r) {
|
|
614
|
-
if (N(this.finalized === !1, "Hash instance finalized"), this.finalized = !0,
|
|
614
|
+
if (N(this.finalized === !1, "Hash instance finalized"), this.finalized = !0, Bt.push(this.pointer), _.exports.blake2b_final(this.pointer), !r || r === "binary")
|
|
615
615
|
return _.memory.slice(this.pointer + 128, this.pointer + 128 + this.digestLength);
|
|
616
616
|
if (r === "hex")
|
|
617
|
-
return
|
|
617
|
+
return Ss(_.memory, this.pointer + 128, this.digestLength);
|
|
618
618
|
N(r.length >= this.digestLength, "input must be TypedArray or Buffer");
|
|
619
619
|
for (var e = 0; e < this.digestLength; e++)
|
|
620
620
|
r[e] = _.memory[this.pointer + 128 + e];
|
|
@@ -636,16 +636,16 @@ D.ready = function(r) {
|
|
|
636
636
|
D.prototype.ready = D.ready;
|
|
637
637
|
function Bs() {
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function Ss(r, e, t) {
|
|
640
640
|
for (var s = "", n = 0; n < t; n++)
|
|
641
|
-
s +=
|
|
641
|
+
s += Es(r[e + n]);
|
|
642
642
|
return s;
|
|
643
643
|
}
|
|
644
|
-
function
|
|
644
|
+
function Es(r) {
|
|
645
645
|
return r < 16 ? "0" + r.toString(16) : r.toString(16);
|
|
646
646
|
}
|
|
647
|
-
var j = be,
|
|
648
|
-
function
|
|
647
|
+
var j = be, pt = O.exports;
|
|
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;
|
|
651
651
|
}
|
|
@@ -659,10 +659,10 @@ function ve(r, e) {
|
|
|
659
659
|
return r[e] ^ r[e + 1] << 8 ^ r[e + 2] << 16 ^ r[e + 3] << 24;
|
|
660
660
|
}
|
|
661
661
|
function W(r, e, t, s, n, i) {
|
|
662
|
-
var o =
|
|
663
|
-
|
|
662
|
+
var o = At[n], c = At[n + 1], u = At[i], d = At[i + 1];
|
|
663
|
+
_t(m, r, e), ce(m, r, o, c);
|
|
664
664
|
var A = m[s] ^ m[r], l = m[s + 1] ^ m[r + 1];
|
|
665
|
-
m[s] = l, m[s + 1] = A,
|
|
665
|
+
m[s] = l, m[s + 1] = A, _t(m, t, s), A = m[e] ^ m[t], l = m[e + 1] ^ m[t + 1], m[e] = A >>> 24 ^ l << 8, m[e + 1] = l >>> 24 ^ A << 8, _t(m, r, e), ce(m, r, u, d), A = m[s] ^ m[r], l = m[s + 1] ^ m[r + 1], m[s] = A >>> 16 ^ l << 16, m[s + 1] = l >>> 16 ^ A << 16, _t(m, t, s), A = m[e] ^ m[t], l = m[e + 1] ^ m[t + 1], m[e] = l >>> 31 ^ A << 1, m[e + 1] = A >>> 31 ^ l << 1;
|
|
666
666
|
}
|
|
667
667
|
var De = new Uint32Array([
|
|
668
668
|
4089235720,
|
|
@@ -876,13 +876,13 @@ var De = new Uint32Array([
|
|
|
876
876
|
3
|
|
877
877
|
], B = new Uint8Array(Qs.map(function(r) {
|
|
878
878
|
return r * 2;
|
|
879
|
-
})), m = new Uint32Array(32),
|
|
879
|
+
})), m = new Uint32Array(32), At = new Uint32Array(32);
|
|
880
880
|
function ke(r, e) {
|
|
881
881
|
var t = 0;
|
|
882
882
|
for (t = 0; t < 16; t++)
|
|
883
883
|
m[t] = r.h[t], m[t + 16] = De[t];
|
|
884
884
|
for (m[24] = m[24] ^ r.t, m[25] = m[25] ^ r.t / 4294967296, e && (m[28] = ~m[28], m[29] = ~m[29]), t = 0; t < 32; t++)
|
|
885
|
-
|
|
885
|
+
At[t] = ve(r.b, 4 * t);
|
|
886
886
|
for (t = 0; t < 12; t++)
|
|
887
887
|
W(0, 8, 16, 24, B[t * 16 + 0], B[t * 16 + 1]), W(2, 10, 18, 26, B[t * 16 + 2], B[t * 16 + 3]), W(4, 12, 20, 28, B[t * 16 + 4], B[t * 16 + 5]), W(6, 14, 22, 30, B[t * 16 + 6], B[t * 16 + 7]), W(0, 10, 20, 30, B[t * 16 + 8], B[t * 16 + 9]), W(2, 12, 22, 24, B[t * 16 + 10], B[t * 16 + 11]), W(4, 14, 16, 26, B[t * 16 + 12], B[t * 16 + 13]), W(6, 8, 18, 28, B[t * 16 + 14], B[t * 16 + 15]);
|
|
888
888
|
for (t = 0; t < 16; t++)
|
|
@@ -954,22 +954,22 @@ var J = new Uint8Array([
|
|
|
954
954
|
0,
|
|
955
955
|
0
|
|
956
956
|
]);
|
|
957
|
-
function
|
|
957
|
+
function ct(r, e, t, s) {
|
|
958
958
|
J.fill(0), this.b = new Uint8Array(128), this.h = new Uint32Array(16), this.t = 0, this.c = 0, this.outlen = r, J[0] = r, e && (J[1] = e.length), J[2] = 1, J[3] = 1, t && J.set(t, 32), s && J.set(s, 48);
|
|
959
959
|
for (var n = 0; n < 16; n++)
|
|
960
960
|
this.h[n] = De[n] ^ ve(J, n * 4);
|
|
961
961
|
e && (Te(this, e), this.c = 128);
|
|
962
962
|
}
|
|
963
|
-
|
|
963
|
+
ct.prototype.update = function(r) {
|
|
964
964
|
return j(r != null, "input must be Uint8Array or Buffer"), Te(this, r), this;
|
|
965
965
|
};
|
|
966
|
-
|
|
966
|
+
ct.prototype.digest = function(r) {
|
|
967
967
|
var e = !r || r === "binary" || r === "hex" ? new Uint8Array(this.outlen) : r;
|
|
968
968
|
return j(e.length >= this.outlen, "out must have at least outlen bytes of space"), bs(this, e), r === "hex" ? vs(e) : e;
|
|
969
969
|
};
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
970
|
+
ct.prototype.final = ct.prototype.digest;
|
|
971
|
+
ct.ready = function(r) {
|
|
972
|
+
pt.ready(function() {
|
|
973
973
|
r();
|
|
974
974
|
});
|
|
975
975
|
};
|
|
@@ -993,34 +993,34 @@ function vs(r) {
|
|
|
993
993
|
function Ds(r) {
|
|
994
994
|
return r < 16 ? "0" + r.toString(16) : r.toString(16);
|
|
995
995
|
}
|
|
996
|
-
var Ue =
|
|
996
|
+
var Ue = ct;
|
|
997
997
|
Q.exports = function(e, t, s, n, i) {
|
|
998
998
|
return i !== !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 === Ae, "salt must be exactly " + Ae + ", was given " + s.length), n != null && j(n.length === ge, "personal must be exactly " + ge + ", was given " + n.length)), new Ue(e, t, s, n);
|
|
999
999
|
};
|
|
1000
1000
|
Q.exports.ready = function(r) {
|
|
1001
|
-
|
|
1001
|
+
pt.ready(function() {
|
|
1002
1002
|
r();
|
|
1003
1003
|
});
|
|
1004
1004
|
};
|
|
1005
|
-
Q.exports.WASM_SUPPORTED =
|
|
1005
|
+
Q.exports.WASM_SUPPORTED = pt.SUPPORTED;
|
|
1006
1006
|
Q.exports.WASM_LOADED = !1;
|
|
1007
1007
|
var ue = Q.exports.BYTES_MIN = 16, de = Q.exports.BYTES_MAX = 64;
|
|
1008
1008
|
Q.exports.BYTES = 32;
|
|
1009
1009
|
var he = Q.exports.KEYBYTES_MIN = 16, le = Q.exports.KEYBYTES_MAX = 64;
|
|
1010
1010
|
Q.exports.KEYBYTES = 32;
|
|
1011
1011
|
var Ae = Q.exports.SALTBYTES = 16, ge = Q.exports.PERSONALBYTES = 16;
|
|
1012
|
-
|
|
1013
|
-
r || (Q.exports.WASM_LOADED = !0, Ue =
|
|
1012
|
+
pt.ready(function(r) {
|
|
1013
|
+
r || (Q.exports.WASM_LOADED = !0, Ue = pt);
|
|
1014
1014
|
});
|
|
1015
|
-
var
|
|
1016
|
-
Object.defineProperty(
|
|
1017
|
-
|
|
1018
|
-
const
|
|
1019
|
-
for (let r = 0; r <
|
|
1020
|
-
const e =
|
|
1015
|
+
var ut = {};
|
|
1016
|
+
Object.defineProperty(ut, "__esModule", { value: !0 });
|
|
1017
|
+
ut.bech32m = ut.bech32 = void 0;
|
|
1018
|
+
const bt = "qpzry9x8gf2tvdw0s3jn54khce6mua7l", Pe = {};
|
|
1019
|
+
for (let r = 0; r < bt.length; r++) {
|
|
1020
|
+
const e = bt.charAt(r);
|
|
1021
1021
|
Pe[e] = r;
|
|
1022
1022
|
}
|
|
1023
|
-
function
|
|
1023
|
+
function ot(r) {
|
|
1024
1024
|
const e = r >> 25;
|
|
1025
1025
|
return (r & 33554431) << 5 ^ -(e >> 0 & 1) & 996825010 ^ -(e >> 1 & 1) & 642813549 ^ -(e >> 2 & 1) & 513874426 ^ -(e >> 3 & 1) & 1027748829 ^ -(e >> 4 & 1) & 705979059;
|
|
1026
1026
|
}
|
|
@@ -1030,12 +1030,12 @@ function me(r) {
|
|
|
1030
1030
|
const s = r.charCodeAt(t);
|
|
1031
1031
|
if (s < 33 || s > 126)
|
|
1032
1032
|
return "Invalid prefix (" + r + ")";
|
|
1033
|
-
e =
|
|
1033
|
+
e = ot(e) ^ s >> 5;
|
|
1034
1034
|
}
|
|
1035
|
-
e =
|
|
1035
|
+
e = ot(e);
|
|
1036
1036
|
for (let t = 0; t < r.length; ++t) {
|
|
1037
1037
|
const s = r.charCodeAt(t);
|
|
1038
|
-
e =
|
|
1038
|
+
e = ot(e) ^ s & 31;
|
|
1039
1039
|
}
|
|
1040
1040
|
return e;
|
|
1041
1041
|
}
|
|
@@ -1084,14 +1084,14 @@ function Ke(r) {
|
|
|
1084
1084
|
const g = c[l];
|
|
1085
1085
|
if (g >> 5 !== 0)
|
|
1086
1086
|
throw new Error("Non 5-bit word");
|
|
1087
|
-
d =
|
|
1087
|
+
d = ot(d) ^ g, A += bt.charAt(g);
|
|
1088
1088
|
}
|
|
1089
1089
|
for (let l = 0; l < 6; ++l)
|
|
1090
|
-
d =
|
|
1090
|
+
d = ot(d);
|
|
1091
1091
|
d ^= e;
|
|
1092
1092
|
for (let l = 0; l < 6; ++l) {
|
|
1093
1093
|
const g = d >> (5 - l) * 5 & 31;
|
|
1094
|
-
A +=
|
|
1094
|
+
A += bt.charAt(g);
|
|
1095
1095
|
}
|
|
1096
1096
|
return A;
|
|
1097
1097
|
}
|
|
@@ -1112,17 +1112,17 @@ function Ke(r) {
|
|
|
1112
1112
|
const l = o.slice(0, A), g = o.slice(A + 1);
|
|
1113
1113
|
if (g.length < 6)
|
|
1114
1114
|
return "Data too short";
|
|
1115
|
-
let
|
|
1116
|
-
if (typeof
|
|
1117
|
-
return
|
|
1115
|
+
let I = me(l);
|
|
1116
|
+
if (typeof I == "string")
|
|
1117
|
+
return I;
|
|
1118
1118
|
const y = [];
|
|
1119
|
-
for (let
|
|
1120
|
-
const z = g.charAt(
|
|
1121
|
-
if (
|
|
1119
|
+
for (let k = 0; k < g.length; ++k) {
|
|
1120
|
+
const z = g.charAt(k), f = Pe[z];
|
|
1121
|
+
if (f === void 0)
|
|
1122
1122
|
return "Unknown character " + z;
|
|
1123
|
-
|
|
1123
|
+
I = ot(I) ^ f, !(k + 6 >= g.length) && y.push(f);
|
|
1124
1124
|
}
|
|
1125
|
-
return
|
|
1125
|
+
return I !== e ? "Invalid checksum for " + o : { prefix: l, words: y };
|
|
1126
1126
|
}
|
|
1127
1127
|
function n(o, c) {
|
|
1128
1128
|
const u = s(o, c);
|
|
@@ -1144,54 +1144,54 @@ function Ke(r) {
|
|
|
1144
1144
|
fromWords: Us
|
|
1145
1145
|
};
|
|
1146
1146
|
}
|
|
1147
|
-
|
|
1148
|
-
|
|
1147
|
+
ut.bech32 = Ke("bech32");
|
|
1148
|
+
ut.bech32m = Ke("bech32m");
|
|
1149
1149
|
var Ps = ee && ee.__importDefault || function(r) {
|
|
1150
1150
|
return r && r.__esModule ? r : { default: r };
|
|
1151
1151
|
};
|
|
1152
1152
|
Object.defineProperty(Qe, "__esModule", { value: !0 });
|
|
1153
|
-
const Ks = Ps(Q.exports),
|
|
1154
|
-
class
|
|
1153
|
+
const Ks = Ps(Q.exports), yt = ut, Kt = "asset";
|
|
1154
|
+
class mt {
|
|
1155
1155
|
constructor(e) {
|
|
1156
1156
|
this.hashBuf = e;
|
|
1157
1157
|
}
|
|
1158
1158
|
static fromHash(e) {
|
|
1159
|
-
return new
|
|
1159
|
+
return new mt(e);
|
|
1160
1160
|
}
|
|
1161
1161
|
static fromParts(e, t) {
|
|
1162
1162
|
const s = (0, Ks.default)(20).update(new Uint8Array([...e, ...t])).digest("binary");
|
|
1163
|
-
return
|
|
1163
|
+
return mt.fromHash(s);
|
|
1164
1164
|
}
|
|
1165
1165
|
static fromBech32(e) {
|
|
1166
|
-
const { prefix: t, words: s } =
|
|
1167
|
-
if (t !==
|
|
1166
|
+
const { prefix: t, words: s } = yt.bech32.decode(e);
|
|
1167
|
+
if (t !== Kt)
|
|
1168
1168
|
throw new Error("Invalid asset fingerprint");
|
|
1169
|
-
const n = Buffer.from(
|
|
1170
|
-
return
|
|
1169
|
+
const n = Buffer.from(yt.bech32.fromWords(s));
|
|
1170
|
+
return mt.fromHash(n);
|
|
1171
1171
|
}
|
|
1172
1172
|
fingerprint() {
|
|
1173
|
-
const e =
|
|
1174
|
-
return
|
|
1173
|
+
const e = yt.bech32.toWords(this.hashBuf);
|
|
1174
|
+
return yt.bech32.encode(Kt, e);
|
|
1175
1175
|
}
|
|
1176
1176
|
hash() {
|
|
1177
1177
|
return Buffer.from(this.hashBuf).toString("hex");
|
|
1178
1178
|
}
|
|
1179
1179
|
prefix() {
|
|
1180
|
-
return
|
|
1180
|
+
return Kt;
|
|
1181
1181
|
}
|
|
1182
1182
|
checksum() {
|
|
1183
1183
|
return this.fingerprint().slice(-6);
|
|
1184
1184
|
}
|
|
1185
1185
|
}
|
|
1186
|
-
var Ns = Qe.default =
|
|
1187
|
-
const
|
|
1188
|
-
const t = Fs(r), s = t.derive(
|
|
1186
|
+
var Ns = Qe.default = mt;
|
|
1187
|
+
const Ms = Ns, 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(), i = s.derive(2).derive(0).to_raw_key();
|
|
1189
1189
|
return s.free(), t.free(), { paymentKey: n, stakeKey: i };
|
|
1190
|
-
},
|
|
1190
|
+
}, nt = (r) => a.Address.from_bytes(p(r)), Fs = (r) => a.Bip32PrivateKey.from_bytes(p(r)), Os = (r) => a.DataHash.from_bytes(p(r)), H = (r) => a.Ed25519KeyHash.from_bytes(p(r)), Vs = (r) => a.Ed25519Signature.from_bytes(p(r)), Dt = (r) => a.NativeScript.from_bytes(p(r)), Rs = (r) => a.PublicKey.from_bytes(p(r)), Ne = (r) => a.PlutusData.from_bytes(p(r)), dt = (r, e) => a.PlutusScript.from_bytes_with_version(p(r), R[e]), qs = (r) => a.ScriptRef.from_bytes(p(r)), Ys = (r) => a.ScriptHash.from_bytes(p(r)), Y = (r) => a.Transaction.from_bytes(p(r)), Me = (r) => a.TransactionHash.from_bytes(p(r)), Ie = (r) => a.TransactionUnspentOutput.from_bytes(p(r)), Ls = (r) => a.TransactionWitnessSet.from_bytes(p(r)), Gs = (r) => a.Value.from_bytes(p(r)), K = (r) => a.Address.from_bech32(r), Lt = (r) => a.BaseAddress.from_address(K(r)), He = (r) => a.EnterpriseAddress.from_address(K(r)), Fe = (r) => a.RewardAddress.from_address(K(r)), b = (r) => Buffer.from(r).toString("hex"), p = (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)
|
|
1194
|
-
s.push(
|
|
1194
|
+
s.push(kt(t.get(n)));
|
|
1195
1195
|
return s;
|
|
1196
1196
|
};
|
|
1197
1197
|
switch (r.kind()) {
|
|
@@ -1241,11 +1241,11 @@ const Hs = Ns, Ms = (r, e) => {
|
|
|
1241
1241
|
default:
|
|
1242
1242
|
throw new Error(`Script Kind: ${r.kind()}, is not supported`);
|
|
1243
1243
|
}
|
|
1244
|
-
},
|
|
1244
|
+
}, Tt = (r) => {
|
|
1245
1245
|
const e = (t) => {
|
|
1246
1246
|
const s = a.NativeScripts.new();
|
|
1247
1247
|
return t.forEach((n) => {
|
|
1248
|
-
s.add(
|
|
1248
|
+
s.add(Tt(n));
|
|
1249
1249
|
}), s;
|
|
1250
1250
|
};
|
|
1251
1251
|
switch (r.type) {
|
|
@@ -1260,26 +1260,26 @@ const Hs = Ns, Ms = (r, e) => {
|
|
|
1260
1260
|
case "before":
|
|
1261
1261
|
return a.NativeScript.new_timelock_expiry(a.TimelockExpiry.new_timelockexpiry(a.BigNum.from_str(r.slot)));
|
|
1262
1262
|
case "sig":
|
|
1263
|
-
return a.NativeScript.new_script_pubkey(a.ScriptPubkey.new(
|
|
1263
|
+
return a.NativeScript.new_script_pubkey(a.ScriptPubkey.new(H(r.keyHash)));
|
|
1264
1264
|
}
|
|
1265
|
-
},
|
|
1265
|
+
}, St = (r) => {
|
|
1266
1266
|
var s, n, i;
|
|
1267
1267
|
const e = (o) => {
|
|
1268
1268
|
const c = [];
|
|
1269
1269
|
for (let u = 0; u < o.len(); u += 1)
|
|
1270
|
-
c.push(
|
|
1270
|
+
c.push(St(o.get(u)));
|
|
1271
1271
|
return c;
|
|
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), A = o.get(d) ?? a.PlutusData.from_hex(
|
|
1276
|
-
c.set(
|
|
1275
|
+
const d = o.keys().get(u), A = o.get(d) ?? a.PlutusData.from_hex(E("NO_ITEM_FOUND_INSIDE_GOLD_ROOM"));
|
|
1276
|
+
c.set(St(d), St(A));
|
|
1277
1277
|
}
|
|
1278
1278
|
return c;
|
|
1279
1279
|
};
|
|
1280
1280
|
switch (r.kind()) {
|
|
1281
1281
|
case a.PlutusDataKind.Bytes:
|
|
1282
|
-
return
|
|
1282
|
+
return b(r.as_bytes() ?? new Uint8Array());
|
|
1283
1283
|
case a.PlutusDataKind.Integer:
|
|
1284
1284
|
return parseInt(((s = r.as_integer()) == null ? void 0 : s.to_str()) ?? "0", 10);
|
|
1285
1285
|
case a.PlutusDataKind.List:
|
|
@@ -1294,16 +1294,16 @@ const Hs = Ns, Ms = (r, e) => {
|
|
|
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
1299
|
const s = a.PlutusList.new();
|
|
1300
1300
|
return t.forEach((n) => {
|
|
1301
|
-
s.add(
|
|
1301
|
+
s.add(tt(n));
|
|
1302
1302
|
}), s;
|
|
1303
1303
|
};
|
|
1304
1304
|
switch (typeof r) {
|
|
1305
1305
|
case "string":
|
|
1306
|
-
return a.PlutusData.new_bytes(
|
|
1306
|
+
return a.PlutusData.new_bytes(p(r));
|
|
1307
1307
|
case "number":
|
|
1308
1308
|
return a.PlutusData.new_integer(a.BigInt.from_str(r.toString()));
|
|
1309
1309
|
case "object":
|
|
@@ -1313,7 +1313,7 @@ const Hs = Ns, Ms = (r, e) => {
|
|
|
1313
1313
|
} else if (r instanceof Map) {
|
|
1314
1314
|
const t = a.PlutusMap.new();
|
|
1315
1315
|
return r.forEach((s, n) => {
|
|
1316
|
-
t.insert(
|
|
1316
|
+
t.insert(tt(n), tt(s));
|
|
1317
1317
|
}), a.PlutusData.new_map(t);
|
|
1318
1318
|
} else
|
|
1319
1319
|
return a.PlutusData.new_constr_plutus_data(a.ConstrPlutusData.new(a.BigNum.from_str(r.alternative.toString()), e(r.fields)));
|
|
@@ -1325,11 +1325,11 @@ const Hs = Ns, Ms = (r, e) => {
|
|
|
1325
1325
|
}), new Error("toPoolParams not implemented.");
|
|
1326
1326
|
}, Oe = (r) => {
|
|
1327
1327
|
const e = (t) => ss[t];
|
|
1328
|
-
return a.Redeemer.new(e(r.tag), a.BigNum.from_str(r.index.toString()),
|
|
1328
|
+
return a.Redeemer.new(e(r.tag), a.BigNum.from_str(r.index.toString()), tt(r.data), a.ExUnits.new(a.BigNum.from_str(r.budget.mem.toString()), a.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 ? a.Ipv4.new(new Uint8Array(r.IPV4.split(".").map((s) => parseInt(s)))) : void 0, t = r.IPV6 ? a.Ipv6.new(
|
|
1332
|
+
const e = r.IPV4 ? a.Ipv4.new(new Uint8Array(r.IPV4.split(".").map((s) => parseInt(s)))) : void 0, t = r.IPV6 ? a.Ipv6.new(p(r.IPV6.replaceAll(":", ""))) : void 0;
|
|
1333
1333
|
return a.Relay.new_single_host_addr(a.SingleHostAddr.new(r.port, e, t));
|
|
1334
1334
|
}
|
|
1335
1335
|
case "SingleHostName":
|
|
@@ -1342,18 +1342,18 @@ const Hs = Ns, Ms = (r, e) => {
|
|
|
1342
1342
|
const t = r.plutus_script();
|
|
1343
1343
|
return {
|
|
1344
1344
|
code: t.to_hex(),
|
|
1345
|
-
version: Object.keys(
|
|
1345
|
+
version: Object.keys(R).find((s) => R[s].to_hex() === t.language_version().to_hex())
|
|
1346
1346
|
};
|
|
1347
1347
|
}
|
|
1348
1348
|
const e = r.native_script();
|
|
1349
|
-
return
|
|
1350
|
-
},
|
|
1349
|
+
return kt(e);
|
|
1350
|
+
}, ht = (r) => {
|
|
1351
1351
|
if ("code" in r) {
|
|
1352
|
-
const e =
|
|
1352
|
+
const e = dt(r.code, r.version);
|
|
1353
1353
|
return a.ScriptRef.new_plutus_script(e);
|
|
1354
1354
|
}
|
|
1355
|
-
return a.ScriptRef.new_native_script(
|
|
1356
|
-
},
|
|
1355
|
+
return a.ScriptRef.new_native_script(Tt(r));
|
|
1356
|
+
}, vt = (r) => {
|
|
1357
1357
|
var n, i, o;
|
|
1358
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() ? (i = r.output().plutus_data()) == null ? void 0 : i.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 {
|
|
@@ -1363,19 +1363,19 @@ const Hs = Ns, Ms = (r, e) => {
|
|
|
1363
1363
|
},
|
|
1364
1364
|
output: {
|
|
1365
1365
|
address: r.output().address().to_bech32(),
|
|
1366
|
-
amount:
|
|
1366
|
+
amount: Re(r.output().amount()),
|
|
1367
1367
|
dataHash: e,
|
|
1368
1368
|
plutusData: t,
|
|
1369
1369
|
scriptRef: s
|
|
1370
1370
|
}
|
|
1371
1371
|
};
|
|
1372
|
-
},
|
|
1373
|
-
const e = a.TransactionInput.new(
|
|
1374
|
-
return r.output.dataHash !== void 0 && t.set_data_hash(Os(r.output.dataHash)), r.output.plutusData !== void 0 && t.set_plutus_data(Ne(r.output.plutusData)), r.output.scriptRef !== void 0 && t.set_script_ref(
|
|
1372
|
+
}, M = (r) => {
|
|
1373
|
+
const e = a.TransactionInput.new(Me(r.input.txHash), r.input.outputIndex), t = a.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(Ne(r.output.plutusData)), r.output.scriptRef !== void 0 && t.set_script_ref(qs(r.output.scriptRef)), a.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
1377
|
return a.UnitInterval.new(a.BigNum.from_str(t), a.BigNum.from_str(s));
|
|
1378
|
-
},
|
|
1378
|
+
}, E = (r) => r.length % 2 === 0 && /^[0-9A-F]*$/i.test(r) ? r : b(Buffer.from(r, "utf-8")), Gt = (r) => Buffer.from(r, "hex").toString("utf-8"), Re = (r) => {
|
|
1379
1379
|
const e = [
|
|
1380
1380
|
{ unit: "lovelace", quantity: r.coin().to_str() }
|
|
1381
1381
|
], t = r.multiasset();
|
|
@@ -1386,7 +1386,7 @@ const Hs = Ns, Ms = (r, e) => {
|
|
|
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), A = o.get(d) ?? a.BigNum.from_str("0"), l = i.to_hex() +
|
|
1389
|
+
const d = c.get(u), A = o.get(d) ?? a.BigNum.from_str("0"), l = i.to_hex() + b(d.name());
|
|
1390
1390
|
e.push({ unit: l, quantity: A.to_str() });
|
|
1391
1391
|
}
|
|
1392
1392
|
}
|
|
@@ -1398,21 +1398,21 @@ const Hs = Ns, Ms = (r, e) => {
|
|
|
1398
1398
|
t.forEach((i) => {
|
|
1399
1399
|
const o = a.Assets.new();
|
|
1400
1400
|
r.filter((c) => c.unit.slice(0, F) === i).forEach((c) => {
|
|
1401
|
-
o.insert(a.AssetName.new(
|
|
1401
|
+
o.insert(a.AssetName.new(p(c.unit.slice(F))), a.BigNum.from_str(c.quantity));
|
|
1402
1402
|
}), s.insert(Ys(i), o);
|
|
1403
1403
|
});
|
|
1404
1404
|
const n = a.Value.new(a.BigNum.from_str(e ? e.quantity : "0"));
|
|
1405
1405
|
return (r.length > 1 || !e) && n.set_multiasset(s), n;
|
|
1406
|
-
}, fe = (r, e, t) => a.BaseAddress.new(r, a.StakeCredential.from_keyhash(e), a.StakeCredential.from_keyhash(t)),
|
|
1406
|
+
}, fe = (r, e, t) => a.BaseAddress.new(r, a.StakeCredential.from_keyhash(e), a.StakeCredential.from_keyhash(t)), qe = (r, e = "") => a.Bip32PrivateKey.from_bip39_entropy(p(r), p(E(e))), Ht = (r) => a.DataCost.new_coins_per_byte(a.BigNum.from_str(r)), Ws = (r) => {
|
|
1407
1407
|
if (typeof r != "object" || !("input" in r))
|
|
1408
|
-
return a.DatumSource.new(
|
|
1409
|
-
const e =
|
|
1408
|
+
return a.DatumSource.new(tt(r));
|
|
1409
|
+
const e = M(r);
|
|
1410
1410
|
if (e.output().has_plutus_data())
|
|
1411
1411
|
return a.DatumSource.new_ref_input(e.input());
|
|
1412
1412
|
throw new Error(`No inline datum found in UTxO: ${e.input().transaction_id().to_hex()}`);
|
|
1413
1413
|
}, _e = (r, e) => a.EnterpriseAddress.new(r, a.StakeCredential.from_keyhash(e)), ye = (r, e) => {
|
|
1414
1414
|
if (typeof r == "string")
|
|
1415
|
-
return a.MintWitness.new_native_script(
|
|
1415
|
+
return a.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")
|
|
@@ -1420,71 +1420,71 @@ const Hs = Ns, Ms = (r, e) => {
|
|
|
1420
1420
|
return a.MintWitness.new_plutus_script(Ye(r), Oe({
|
|
1421
1421
|
tag: "MINT",
|
|
1422
1422
|
index: 0,
|
|
1423
|
-
budget:
|
|
1423
|
+
budget: at,
|
|
1424
1424
|
data: {
|
|
1425
1425
|
alternative: 0,
|
|
1426
1426
|
fields: []
|
|
1427
1427
|
},
|
|
1428
1428
|
...e
|
|
1429
1429
|
}));
|
|
1430
|
-
},
|
|
1430
|
+
}, Ft = (r, e) => a.RewardAddress.new(r, a.StakeCredential.from_keyhash(e)), Ye = (r) => {
|
|
1431
1431
|
if ("code" in r)
|
|
1432
|
-
return a.PlutusScriptSource.new(
|
|
1433
|
-
const e =
|
|
1432
|
+
return a.PlutusScriptSource.new(dt(r.code, r.version));
|
|
1433
|
+
const e = M(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
|
-
const s = Ve(t), n =
|
|
1438
|
-
return a.PlutusScriptSource.new_ref_input_with_lang_ver(n, e.input(),
|
|
1437
|
+
const s = Ve(t), n = dt(s.code, s.version).hash();
|
|
1438
|
+
return a.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
1443
|
const e = a.ScriptPubkey.new(r);
|
|
1444
1444
|
return a.NativeScript.new_script_pubkey(e);
|
|
1445
|
-
},
|
|
1445
|
+
}, Et = (r = v) => {
|
|
1446
1446
|
const e = a.TransactionBuilderConfigBuilder.new().coins_per_utxo_byte(a.BigNum.from_str(r.coinsPerUTxOSize)).ex_unit_prices(a.ExUnitPrices.new(pe(r.priceMem.toString()), pe(r.priceStep.toString()))).fee_algo(a.LinearFee.new(a.BigNum.from_str(r.minFeeA.toString()), a.BigNum.from_str(r.minFeeB.toString()))).key_deposit(a.BigNum.from_str(r.keyDeposit)).max_tx_size(r.maxTxSize).max_value_size(parseInt(r.maxValSize, 10)).pool_deposit(a.BigNum.from_str(r.poolDeposit)).build();
|
|
1447
1447
|
return a.TransactionBuilder.new(e);
|
|
1448
1448
|
}, xe = (r) => {
|
|
1449
1449
|
const e = a.TxInputsBuilder.new();
|
|
1450
|
-
return r.map((t) => t instanceof a.TransactionUnspentOutput ? t :
|
|
1450
|
+
return r.map((t) => t instanceof a.TransactionUnspentOutput ? t : M(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
1455
|
return a.TransactionOutputBuilder.new().with_address(K(r));
|
|
1456
1456
|
let e = a.TransactionOutputBuilder.new().with_address(K(r.address));
|
|
1457
1457
|
if (r.datum) {
|
|
1458
|
-
const { value: t, inline: s } = r.datum, n =
|
|
1458
|
+
const { value: t, inline: s } = r.datum, n = tt(t);
|
|
1459
1459
|
e = e.with_data_hash(a.hash_plutus_data(n)), s && (e = e.with_plutus_data(n));
|
|
1460
1460
|
}
|
|
1461
1461
|
if (r.script) {
|
|
1462
|
-
const t =
|
|
1462
|
+
const t = ht(r.script);
|
|
1463
1463
|
e = e.with_script_ref(t);
|
|
1464
1464
|
}
|
|
1465
1465
|
return e;
|
|
1466
|
-
},
|
|
1467
|
-
const e = r.slice(0, F), t = r.includes(".") ?
|
|
1466
|
+
}, et = (r) => {
|
|
1467
|
+
const e = r.slice(0, F), t = r.includes(".") ? E(r.split(".")[1]) : r.slice(F);
|
|
1468
1468
|
return { policyId: e, assetName: t };
|
|
1469
1469
|
}, h = (r) => L.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
1473
|
}) : r.request ? JSON.stringify(r.request) : r.message : JSON.stringify(r), ur = (r) => {
|
|
1474
|
-
const e =
|
|
1474
|
+
const e = tt(r);
|
|
1475
1475
|
return a.hash_plutus_data(e).to_hex();
|
|
1476
1476
|
}, dr = (r, e = Date.now()) => {
|
|
1477
|
-
if (
|
|
1478
|
-
const [t, s, n, i] =
|
|
1477
|
+
if (Qt[r]) {
|
|
1478
|
+
const [t, s, n, i] = Qt[r];
|
|
1479
1479
|
return parseInt(a.BigNum.from_str(e.toString()).div_floor(a.BigNum.from_str("1000")).checked_sub(a.BigNum.from_str(n)).div_floor(a.BigNum.from_str(i)).checked_add(a.BigNum.from_str(t)).to_str(), 10);
|
|
1480
1480
|
}
|
|
1481
1481
|
throw new Error(`Couldn't resolve EpochNo for network: ${r}`);
|
|
1482
|
-
}, Js = (r, e) =>
|
|
1482
|
+
}, Js = (r, e) => Ms.fromParts(p(r), p(e)).fingerprint(), hr = (r, e) => rs[r][e], lr = (r) => Tt(r).hash().to_hex(), it = (r) => {
|
|
1483
1483
|
var e, t;
|
|
1484
1484
|
try {
|
|
1485
1485
|
const s = [
|
|
1486
1486
|
(e = Lt(r)) == null ? void 0 : e.payment_cred().to_keyhash(),
|
|
1487
|
-
(t =
|
|
1487
|
+
(t = He(r)) == null ? void 0 : t.payment_cred().to_keyhash()
|
|
1488
1488
|
].find((n) => n !== void 0);
|
|
1489
1489
|
if (s !== void 0)
|
|
1490
1490
|
return s.to_hex();
|
|
@@ -1493,11 +1493,11 @@ const Hs = Ns, Ms = (r, e) => {
|
|
|
1493
1493
|
throw new Error(`An error occurred during resolvePaymentKeyHash: ${s}.`);
|
|
1494
1494
|
}
|
|
1495
1495
|
}, Ar = (r, e = 0) => {
|
|
1496
|
-
const t =
|
|
1496
|
+
const t = dt(r.code, r.version);
|
|
1497
1497
|
return a.EnterpriseAddress.new(e, a.StakeCredential.from_scripthash(t.hash())).to_address().to_bech32();
|
|
1498
1498
|
}, gr = (r) => {
|
|
1499
1499
|
try {
|
|
1500
|
-
const e =
|
|
1500
|
+
const e = He(r), t = e == null ? void 0 : e.payment_cred().to_scripthash();
|
|
1501
1501
|
if (t !== void 0)
|
|
1502
1502
|
return t.to_hex();
|
|
1503
1503
|
throw new Error(`Couldn't resolve script hash from address: ${r}`);
|
|
@@ -1505,24 +1505,24 @@ const Hs = Ns, Ms = (r, e) => {
|
|
|
1505
1505
|
throw new Error(`An error occurred during resolveScriptHash: ${e}.`);
|
|
1506
1506
|
}
|
|
1507
1507
|
}, mr = (r) => a.Ed25519KeyHash.from_hex(r).to_bech32("pool1"), Ir = (r) => {
|
|
1508
|
-
const e = we(r.join(" ")), t =
|
|
1508
|
+
const e = we(r.join(" ")), t = qe(e), s = t.to_bech32();
|
|
1509
1509
|
return t.free(), s;
|
|
1510
|
-
}, pr = (r) =>
|
|
1511
|
-
if (
|
|
1512
|
-
const [t, s, n] =
|
|
1510
|
+
}, pr = (r) => ht(r).to_hex(), fr = (r, e = Date.now()) => {
|
|
1511
|
+
if (Qt[r]) {
|
|
1512
|
+
const [t, s, n] = Qt[r];
|
|
1513
1513
|
return a.BigNum.from_str(e.toString()).div_floor(a.BigNum.from_str("1000")).checked_sub(a.BigNum.from_str(n)).checked_add(a.BigNum.from_str(s)).to_str();
|
|
1514
1514
|
}
|
|
1515
1515
|
throw new Error(`Couldn't resolve SlotNo for network: ${r}`);
|
|
1516
|
-
},
|
|
1516
|
+
}, Ut = (r) => {
|
|
1517
1517
|
try {
|
|
1518
1518
|
const e = K(r), t = Lt(r), s = t == null ? void 0 : t.stake_cred().to_keyhash();
|
|
1519
1519
|
if (s !== void 0)
|
|
1520
|
-
return
|
|
1520
|
+
return Ft(e.network_id(), s).to_address().to_bech32();
|
|
1521
1521
|
throw new Error(`Couldn't resolve reward address from address: ${r}`);
|
|
1522
1522
|
} catch (e) {
|
|
1523
1523
|
throw new Error(`An error occurred during resolveRewardAddress: ${e}.`);
|
|
1524
1524
|
}
|
|
1525
|
-
},
|
|
1525
|
+
}, gt = (r) => {
|
|
1526
1526
|
var e, t;
|
|
1527
1527
|
try {
|
|
1528
1528
|
const s = [
|
|
@@ -1535,14 +1535,14 @@ const Hs = Ns, Ms = (r, e) => {
|
|
|
1535
1535
|
} catch (s) {
|
|
1536
1536
|
throw new Error(`An error occurred during resolveStakeKeyHash: ${s}.`);
|
|
1537
1537
|
}
|
|
1538
|
-
}, Le = (r, e =
|
|
1538
|
+
}, Le = (r, e = v.minFeeA, t = v.minFeeB) => (BigInt(e) * BigInt(r) + BigInt(t)).toString(), js = (r) => {
|
|
1539
1539
|
const e = Y(r).body();
|
|
1540
1540
|
return a.hash_transaction(e).to_hex();
|
|
1541
1541
|
}, _r = (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 E(`${r}${s}`);
|
|
1546
1546
|
}, Ge = (r, e) => {
|
|
1547
1547
|
const t = r.vkeys();
|
|
1548
1548
|
if (t !== void 0) {
|
|
@@ -1557,7 +1557,7 @@ const Hs = Ns, Ms = (r, e) => {
|
|
|
1557
1557
|
}), n;
|
|
1558
1558
|
}
|
|
1559
1559
|
return e;
|
|
1560
|
-
}, yr = (r) =>
|
|
1560
|
+
}, yr = (r) => St(Ne(r)), xr = (r) => Y(r).to_js_value();
|
|
1561
1561
|
class Cr {
|
|
1562
1562
|
_axiosInstance;
|
|
1563
1563
|
constructor(...e) {
|
|
@@ -1572,7 +1572,7 @@ class Cr {
|
|
|
1572
1572
|
}
|
|
1573
1573
|
}
|
|
1574
1574
|
async fetchAccountInfo(e) {
|
|
1575
|
-
const t = e.startsWith("addr") ?
|
|
1575
|
+
const t = e.startsWith("addr") ? Ut(e) : e;
|
|
1576
1576
|
try {
|
|
1577
1577
|
const { data: s, status: n } = await this._axiosInstance.get(`accounts/${t}`);
|
|
1578
1578
|
if (n === 200)
|
|
@@ -1596,7 +1596,7 @@ class Cr {
|
|
|
1596
1596
|
code: await this.fetchPlutusScriptCBOR(e),
|
|
1597
1597
|
version: t.type.replace("plutus", "")
|
|
1598
1598
|
} : await this.fetchNativeScriptJSON(e);
|
|
1599
|
-
return
|
|
1599
|
+
return ht(n).to_hex();
|
|
1600
1600
|
}
|
|
1601
1601
|
throw h(t);
|
|
1602
1602
|
}
|
|
@@ -1633,7 +1633,7 @@ class Cr {
|
|
|
1633
1633
|
}
|
|
1634
1634
|
async fetchAssetAddresses(e) {
|
|
1635
1635
|
const t = async (s = 1, n = []) => {
|
|
1636
|
-
const { policyId: i, assetName: o } =
|
|
1636
|
+
const { policyId: i, assetName: o } = et(e), { data: c, status: u } = await this._axiosInstance.get(`assets/${i}${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,7 +1646,7 @@ class Cr {
|
|
|
1646
1646
|
}
|
|
1647
1647
|
async fetchAssetMetadata(e) {
|
|
1648
1648
|
try {
|
|
1649
|
-
const { policyId: t, assetName: s } =
|
|
1649
|
+
const { policyId: t, assetName: s } = et(e), { data: n, status: i } = await this._axiosInstance.get(`assets/${t}${s}`);
|
|
1650
1650
|
if (i === 200)
|
|
1651
1651
|
return {
|
|
1652
1652
|
...n.onchain_metadata
|
|
@@ -1700,7 +1700,7 @@ class Cr {
|
|
|
1700
1700
|
}
|
|
1701
1701
|
async fetchHandleAddress(e) {
|
|
1702
1702
|
try {
|
|
1703
|
-
const t =
|
|
1703
|
+
const t = E(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);
|
|
@@ -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", p(e), { headers: t });
|
|
1793
1793
|
if (n === 200)
|
|
1794
1794
|
return s;
|
|
1795
1795
|
throw h(s);
|
|
@@ -1847,7 +1847,7 @@ class Br {
|
|
|
1847
1847
|
}
|
|
1848
1848
|
async fetchAccountInfo(e) {
|
|
1849
1849
|
try {
|
|
1850
|
-
const t = e.startsWith("addr") ?
|
|
1850
|
+
const t = e.startsWith("addr") ? Ut(e) : e, { data: s, status: n } = await this._axiosInstance.post("account_info", {
|
|
1851
1851
|
_stake_addresses: [t]
|
|
1852
1852
|
});
|
|
1853
1853
|
if (n === 200)
|
|
@@ -1879,7 +1879,7 @@ class Br {
|
|
|
1879
1879
|
}
|
|
1880
1880
|
async fetchAssetAddresses(e) {
|
|
1881
1881
|
try {
|
|
1882
|
-
const { policyId: t, assetName: s } =
|
|
1882
|
+
const { policyId: t, assetName: s } = et(e), { data: n, status: i } = await this._axiosInstance.get(`asset_address_list?_asset_policy=${t}&_asset_name=${s}`);
|
|
1883
1883
|
if (i === 200)
|
|
1884
1884
|
return n.map((o) => ({
|
|
1885
1885
|
address: o.payment_address,
|
|
@@ -1892,7 +1892,7 @@ class Br {
|
|
|
1892
1892
|
}
|
|
1893
1893
|
async fetchAssetMetadata(e) {
|
|
1894
1894
|
try {
|
|
1895
|
-
const { policyId: t, assetName: s } =
|
|
1895
|
+
const { policyId: t, assetName: s } = et(e), { data: n, status: i } = await this._axiosInstance.get(`asset_info?_asset_policy=${t}&_asset_name=${s}`);
|
|
1896
1896
|
if (i === 200)
|
|
1897
1897
|
return {
|
|
1898
1898
|
...n[0].minting_tx_metadata[721][t][Gt(s)]
|
|
@@ -1948,7 +1948,7 @@ class Br {
|
|
|
1948
1948
|
}
|
|
1949
1949
|
async fetchHandleAddress(e) {
|
|
1950
1950
|
try {
|
|
1951
|
-
const t =
|
|
1951
|
+
const t = E(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);
|
|
@@ -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", p(e), { headers: t });
|
|
2043
2043
|
if (n === 202)
|
|
2044
2044
|
return s;
|
|
2045
2045
|
throw h(s);
|
|
@@ -2075,12 +2075,12 @@ class Br {
|
|
|
2075
2075
|
const t = e.type.startsWith("plutus") ? {
|
|
2076
2076
|
code: e.bytes,
|
|
2077
2077
|
version: e.type.replace("plutus", "")
|
|
2078
|
-
} : Dt(
|
|
2079
|
-
return
|
|
2078
|
+
} : kt(Dt(e.bytes));
|
|
2079
|
+
return ht(t).to_hex();
|
|
2080
2080
|
}
|
|
2081
2081
|
};
|
|
2082
2082
|
}
|
|
2083
|
-
class
|
|
2083
|
+
class Sr {
|
|
2084
2084
|
_baseUrl;
|
|
2085
2085
|
constructor(...e) {
|
|
2086
2086
|
this._baseUrl = es(e[0]) ? ns[e[0]] : e[0];
|
|
@@ -2147,7 +2147,7 @@ class Er {
|
|
|
2147
2147
|
}));
|
|
2148
2148
|
}
|
|
2149
2149
|
}
|
|
2150
|
-
class
|
|
2150
|
+
class Er {
|
|
2151
2151
|
_axiosInstance;
|
|
2152
2152
|
constructor(e, t, s, n = 1) {
|
|
2153
2153
|
this._axiosInstance = L.create({
|
|
@@ -2174,7 +2174,7 @@ class Sr {
|
|
|
2174
2174
|
}
|
|
2175
2175
|
async fetchAccountInfo(e) {
|
|
2176
2176
|
try {
|
|
2177
|
-
const t = e.startsWith("addr") ?
|
|
2177
|
+
const t = e.startsWith("addr") ? Ut(e) : e, { data: s, status: n } = await this._axiosInstance.get(`wallets/${t}`);
|
|
2178
2178
|
if (n === 200)
|
|
2179
2179
|
return {
|
|
2180
2180
|
poolId: s.pool_id,
|
|
@@ -2190,10 +2190,10 @@ class Sr {
|
|
|
2190
2190
|
}
|
|
2191
2191
|
async fetchAddressUTxOs(e, t) {
|
|
2192
2192
|
const s = t !== void 0 ? `/assets/${t}` : "", n = `addresses/${e}${s}/utxos?size=50`, i = async (d = "", A = []) => {
|
|
2193
|
-
var
|
|
2193
|
+
var I;
|
|
2194
2194
|
const { data: l, status: g } = await this._axiosInstance.get(`${n}&cursor=${d}`);
|
|
2195
2195
|
if (g === 200)
|
|
2196
|
-
return l.cursor !== null && ((
|
|
2196
|
+
return l.cursor !== null && ((I = l.cursor) == null ? void 0 : I.length) > 0 ? i(l.cursor, [...A, ...l.data.map(u)]) : l.data.map(u);
|
|
2197
2197
|
throw h(l);
|
|
2198
2198
|
}, o = (d, A) => {
|
|
2199
2199
|
const l = [
|
|
@@ -2203,9 +2203,9 @@ class Sr {
|
|
|
2203
2203
|
}
|
|
2204
2204
|
];
|
|
2205
2205
|
return A.forEach((g) => {
|
|
2206
|
-
const
|
|
2206
|
+
const I = E(g.asset_name);
|
|
2207
2207
|
l.push({
|
|
2208
|
-
unit: `${g.policy_id}${
|
|
2208
|
+
unit: `${g.policy_id}${I}`,
|
|
2209
2209
|
quantity: g.quantity.toString()
|
|
2210
2210
|
});
|
|
2211
2211
|
}), l;
|
|
@@ -2214,8 +2214,8 @@ class Sr {
|
|
|
2214
2214
|
const A = d.type.startsWith("plutus") ? {
|
|
2215
2215
|
code: d.code,
|
|
2216
2216
|
version: d.type.replace("plutus", "")
|
|
2217
|
-
} : Dt(
|
|
2218
|
-
return
|
|
2217
|
+
} : kt(Dt(d.json));
|
|
2218
|
+
return ht(A).to_hex();
|
|
2219
2219
|
}
|
|
2220
2220
|
}, u = (d) => {
|
|
2221
2221
|
var A;
|
|
@@ -2245,7 +2245,7 @@ class Sr {
|
|
|
2245
2245
|
quantity: n.quantity.toString()
|
|
2246
2246
|
}), s = async (n = "", i = []) => {
|
|
2247
2247
|
var A;
|
|
2248
|
-
const { policyId: o, assetName: c } =
|
|
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
2250
|
return u.cursor !== null && ((A = u.cursor) == null ? void 0 : A.length) > 0 ? s(u.cursor, [
|
|
2251
2251
|
...i,
|
|
@@ -2262,7 +2262,7 @@ class Sr {
|
|
|
2262
2262
|
async fetchAssetMetadata(e) {
|
|
2263
2263
|
var t;
|
|
2264
2264
|
try {
|
|
2265
|
-
const { policyId: s, assetName: n } =
|
|
2265
|
+
const { policyId: s, assetName: n } = et(e), { data: i, status: o } = await this._axiosInstance.get(`assets/${s}${n}`);
|
|
2266
2266
|
if (o === 200)
|
|
2267
2267
|
return {
|
|
2268
2268
|
...(t = i.metadata.find((c) => c.label === 721)) == null ? void 0 : t.json[s][Gt(n)]
|
|
@@ -2316,7 +2316,7 @@ class Sr {
|
|
|
2316
2316
|
}
|
|
2317
2317
|
async fetchHandleAddress(e) {
|
|
2318
2318
|
try {
|
|
2319
|
-
const t =
|
|
2319
|
+
const t = E(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);
|
|
@@ -2442,7 +2442,7 @@ class Qr {
|
|
|
2442
2442
|
}
|
|
2443
2443
|
}
|
|
2444
2444
|
async fetchAccountInfo(e) {
|
|
2445
|
-
const t = e.startsWith("addr") ?
|
|
2445
|
+
const t = e.startsWith("addr") ? Ut(e) : e;
|
|
2446
2446
|
try {
|
|
2447
2447
|
const { data: s, status: n } = await this._axiosInstance.get(`accounts/${t}`, this._amountsAsStrings);
|
|
2448
2448
|
if (n === 200) {
|
|
@@ -2464,8 +2464,8 @@ class Qr {
|
|
|
2464
2464
|
const s = (() => e.startsWith("addr_vkh") || e.startsWith("addr_shared_vkh") ? `addresses/cred/${e}` : `addresses/${e}`)(), n = t ? `&asset=${t}` : "", i = async (o = null, c = []) => {
|
|
2465
2465
|
const u = o === null ? "" : `&cursor=${o}`, { data: d, status: A } = await this._axiosInstance.get(`${s}/utxos?count=100${n}${u}`, this._amountsAsStrings);
|
|
2466
2466
|
if (A === 200) {
|
|
2467
|
-
const g = d.data.map(this.toUTxO),
|
|
2468
|
-
return y == null ?
|
|
2467
|
+
const g = d.data.map(this.toUTxO), I = [...c, ...g], y = d.next_cursor;
|
|
2468
|
+
return y == null ? I : i(y, I);
|
|
2469
2469
|
}
|
|
2470
2470
|
throw h(d);
|
|
2471
2471
|
};
|
|
@@ -2476,14 +2476,14 @@ class Qr {
|
|
|
2476
2476
|
}
|
|
2477
2477
|
}
|
|
2478
2478
|
async fetchAssetAddresses(e) {
|
|
2479
|
-
const { policyId: t, assetName: s } =
|
|
2479
|
+
const { policyId: t, assetName: s } = et(e), n = async (i = null, o = []) => {
|
|
2480
2480
|
const c = i === null ? "" : `&cursor=${i}`, { data: u, status: d } = await this._axiosInstance.get(`assets/${t}${s}/addresses?count=100${c}`, this._amountsAsStrings);
|
|
2481
2481
|
if (d === 200) {
|
|
2482
|
-
const l = u.data.map((y) => ({ address: y.address, quantity: y.amount })), g = u.next_cursor,
|
|
2482
|
+
const l = u.data.map((y) => ({ address: y.address, quantity: y.amount })), g = u.next_cursor, I = [
|
|
2483
2483
|
...o,
|
|
2484
2484
|
...l
|
|
2485
2485
|
];
|
|
2486
|
-
return g == null ?
|
|
2486
|
+
return g == null ? I : n(g, I);
|
|
2487
2487
|
}
|
|
2488
2488
|
throw h(u);
|
|
2489
2489
|
};
|
|
@@ -2495,7 +2495,7 @@ class Qr {
|
|
|
2495
2495
|
}
|
|
2496
2496
|
async fetchAssetMetadata(e) {
|
|
2497
2497
|
try {
|
|
2498
|
-
const { policyId: t, assetName: s } =
|
|
2498
|
+
const { policyId: t, assetName: s } = et(e), { data: n, status: i } = await this._axiosInstance.get(`assets/${t}${s}`);
|
|
2499
2499
|
if (i === 200) {
|
|
2500
2500
|
const o = n.data;
|
|
2501
2501
|
return {
|
|
@@ -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, p(e), { headers: t });
|
|
2663
2663
|
if (n === 202)
|
|
2664
2664
|
return s;
|
|
2665
2665
|
throw h(s);
|
|
@@ -2693,21 +2693,21 @@ class Qr {
|
|
|
2693
2693
|
code: e.reference_script.bytes,
|
|
2694
2694
|
version: e.reference_script.type.replace("plutusv", "V")
|
|
2695
2695
|
};
|
|
2696
|
-
return
|
|
2696
|
+
return ht(t).to_hex();
|
|
2697
2697
|
} else
|
|
2698
2698
|
return;
|
|
2699
2699
|
};
|
|
2700
2700
|
}
|
|
2701
2701
|
class br {
|
|
2702
2702
|
static withOneSignature(e) {
|
|
2703
|
-
const t =
|
|
2704
|
-
return
|
|
2703
|
+
const t = H(it(e));
|
|
2704
|
+
return xt(t).to_hex();
|
|
2705
2705
|
}
|
|
2706
2706
|
static withAtLeastNSignatures(e, t) {
|
|
2707
2707
|
const s = a.NativeScripts.new();
|
|
2708
2708
|
e.forEach((i) => {
|
|
2709
|
-
const o =
|
|
2710
|
-
s.add(
|
|
2709
|
+
const o = H(it(i));
|
|
2710
|
+
s.add(xt(o));
|
|
2711
2711
|
});
|
|
2712
2712
|
const n = a.ScriptNOfK.new(t, s);
|
|
2713
2713
|
return a.NativeScript.new_script_any(n).to_hex();
|
|
@@ -2715,8 +2715,8 @@ class br {
|
|
|
2715
2715
|
static withAnySignature(e) {
|
|
2716
2716
|
const t = a.NativeScripts.new();
|
|
2717
2717
|
e.forEach((n) => {
|
|
2718
|
-
const i =
|
|
2719
|
-
t.add(
|
|
2718
|
+
const i = H(it(n));
|
|
2719
|
+
t.add(xt(i));
|
|
2720
2720
|
});
|
|
2721
2721
|
const s = a.ScriptAny.new(t);
|
|
2722
2722
|
return a.NativeScript.new_script_any(s).to_hex();
|
|
@@ -2724,17 +2724,17 @@ class br {
|
|
|
2724
2724
|
static withAllSignatures(e) {
|
|
2725
2725
|
const t = a.NativeScripts.new();
|
|
2726
2726
|
e.forEach((n) => {
|
|
2727
|
-
const i =
|
|
2728
|
-
t.add(
|
|
2727
|
+
const i = H(it(n));
|
|
2728
|
+
t.add(xt(i));
|
|
2729
2729
|
});
|
|
2730
2730
|
const s = a.ScriptAll.new(t);
|
|
2731
2731
|
return a.NativeScript.new_script_any(s).to_hex();
|
|
2732
2732
|
}
|
|
2733
2733
|
static fromNativeScript(e) {
|
|
2734
|
-
return
|
|
2734
|
+
return Tt(e).to_hex();
|
|
2735
2735
|
}
|
|
2736
2736
|
}
|
|
2737
|
-
function
|
|
2737
|
+
function st(r, e, t, s) {
|
|
2738
2738
|
var n = arguments.length, i = n < 3 ? e : s === null ? s = Object.getOwnPropertyDescriptor(e, t) : s, o;
|
|
2739
2739
|
if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
|
|
2740
2740
|
i = Reflect.decorate(r, e, t, s);
|
|
@@ -2745,7 +2745,7 @@ function et(r, e, t, s) {
|
|
|
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
2751
|
const i = s.call(this, ...n);
|
|
@@ -2767,7 +2767,7 @@ let $ = class {
|
|
|
2767
2767
|
_txInputsBuilder;
|
|
2768
2768
|
_txWithdrawals;
|
|
2769
2769
|
constructor(e = {}) {
|
|
2770
|
-
this._era = e.era, this._initiator = e.initiator, this._mintBuilder = a.MintBuilder.new(), this._protocolParameters = e.parameters ??
|
|
2770
|
+
this._era = e.era, this._initiator = e.initiator, this._mintBuilder = a.MintBuilder.new(), this._protocolParameters = e.parameters ?? v, this._txBuilder = Et(e.parameters), this._txCertificates = a.Certificates.new(), this._txInputsBuilder = a.TxInputsBuilder.new(), this._txWithdrawals = a.Withdrawals.new();
|
|
2771
2771
|
}
|
|
2772
2772
|
static maskMetadata(e, t = "BABBAGE") {
|
|
2773
2773
|
var i;
|
|
@@ -2803,38 +2803,38 @@ let $ = class {
|
|
|
2803
2803
|
}
|
|
2804
2804
|
burnAsset(e, t, s) {
|
|
2805
2805
|
const n = this._totalBurns.has(t.unit) ? a.BigNum.from_str(this._totalBurns.get(t.unit) ?? "0").checked_add(a.BigNum.from_str(t.quantity)).to_str() : t.quantity;
|
|
2806
|
-
return this._mintBuilder.add_asset(ye(e, s), a.AssetName.new(
|
|
2806
|
+
return this._mintBuilder.add_asset(ye(e, s), a.AssetName.new(p(t.unit.slice(F))), a.Int.new_negative(a.BigNum.from_str(t.quantity))), this._totalBurns.set(t.unit, n), this;
|
|
2807
2807
|
}
|
|
2808
2808
|
delegateStake(e, t) {
|
|
2809
|
-
const s = a.Certificate.new_stake_delegation(a.StakeDelegation.new(a.StakeCredential.from_keyhash(
|
|
2809
|
+
const s = a.Certificate.new_stake_delegation(a.StakeDelegation.new(a.StakeCredential.from_keyhash(H(gt(e))), a.Ed25519KeyHash.from_bech32(t)));
|
|
2810
2810
|
return this._txCertificates.add(s), this;
|
|
2811
2811
|
}
|
|
2812
2812
|
deregisterStake(e) {
|
|
2813
|
-
const t = a.Certificate.new_stake_deregistration(a.StakeDeregistration.new(a.StakeCredential.from_keyhash(
|
|
2813
|
+
const t = a.Certificate.new_stake_deregistration(a.StakeDeregistration.new(a.StakeCredential.from_keyhash(H(gt(e)))));
|
|
2814
2814
|
return this._txCertificates.add(t), this;
|
|
2815
2815
|
}
|
|
2816
2816
|
mintAsset(e, t, s) {
|
|
2817
2817
|
var d, A;
|
|
2818
2818
|
const n = (l, g) => {
|
|
2819
|
-
const
|
|
2819
|
+
const I = typeof l == "string" ? Dt(l).hash().to_hex() : i(l).hash().to_hex(), y = E(g.assetName);
|
|
2820
2820
|
return {
|
|
2821
|
-
unit: `${
|
|
2821
|
+
unit: `${I}${y}`,
|
|
2822
2822
|
quantity: g.assetQuantity
|
|
2823
2823
|
};
|
|
2824
2824
|
}, i = (l) => {
|
|
2825
2825
|
if ("code" in l)
|
|
2826
|
-
return
|
|
2827
|
-
const g =
|
|
2826
|
+
return dt(l.code, l.version);
|
|
2827
|
+
const g = M(l);
|
|
2828
2828
|
if (g.output().has_script_ref()) {
|
|
2829
|
-
const
|
|
2830
|
-
if (
|
|
2831
|
-
const y = Ve(
|
|
2832
|
-
return
|
|
2829
|
+
const I = g.output().script_ref();
|
|
2830
|
+
if (I.is_plutus_script()) {
|
|
2831
|
+
const y = Ve(I);
|
|
2832
|
+
return dt(y.code, y.version);
|
|
2833
2833
|
}
|
|
2834
2834
|
}
|
|
2835
2835
|
throw new Error(`No plutus script reference found in UTxO: ${g.input().transaction_id().to_hex()}`);
|
|
2836
2836
|
}, o = n(e, t), u = a.BigNum.from_str(((d = this._totalMints.get(o.unit)) == null ? void 0 : d.assetQuantity) ?? "0").checked_add(a.BigNum.from_str(o.quantity));
|
|
2837
|
-
return this._mintBuilder.add_asset(ye(e, s), a.AssetName.new(
|
|
2837
|
+
return this._mintBuilder.add_asset(ye(e, s), a.AssetName.new(p(E(t.assetName))), a.Int.new(a.BigNum.from_str(o.quantity))), this._recipients.has(t.recipient) ? (A = this._recipients.get(t.recipient)) == null || A.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;
|
|
@@ -2842,18 +2842,18 @@ let $ = class {
|
|
|
2842
2842
|
redeemValue(e) {
|
|
2843
2843
|
const t = {
|
|
2844
2844
|
tag: "SPEND",
|
|
2845
|
-
budget:
|
|
2845
|
+
budget: at,
|
|
2846
2846
|
index: this._txInputsBuilder.inputs().len(),
|
|
2847
2847
|
data: {
|
|
2848
2848
|
alternative: 0,
|
|
2849
2849
|
fields: []
|
|
2850
2850
|
},
|
|
2851
2851
|
...e.redeemer
|
|
2852
|
-
}, s =
|
|
2852
|
+
}, s = M(e.value), n = a.PlutusWitness.new_with_ref(Ye(e.script), Ws(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 = a.Certificate.new_stake_registration(a.StakeRegistration.new(a.StakeCredential.from_keyhash(
|
|
2856
|
+
const t = a.Certificate.new_stake_registration(a.StakeRegistration.new(a.StakeCredential.from_keyhash(H(gt(e)))));
|
|
2857
2857
|
return this._txCertificates.add(t), this;
|
|
2858
2858
|
}
|
|
2859
2859
|
registerPool(e) {
|
|
@@ -2868,13 +2868,13 @@ let $ = class {
|
|
|
2868
2868
|
const s = Z(t), n = s.multiasset();
|
|
2869
2869
|
if (s.is_zero() || n === void 0)
|
|
2870
2870
|
return this;
|
|
2871
|
-
const i =
|
|
2871
|
+
const i = Ct(e).next(), o = s.coin().is_zero() ? i.with_asset_and_min_required_coin_by_utxo_cost(n, Ht(this._protocolParameters.coinsPerUTxOSize)).build() : i.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 =
|
|
2877
|
+
const n = Ct(e).next().with_coin(a.BigNum.from_str(t)).build();
|
|
2878
2878
|
return this.setTxOutput({
|
|
2879
2879
|
unit: "lovelace",
|
|
2880
2880
|
quantity: t
|
|
@@ -2887,7 +2887,7 @@ let $ = class {
|
|
|
2887
2887
|
}]), this;
|
|
2888
2888
|
}
|
|
2889
2889
|
sendValue(e, t) {
|
|
2890
|
-
const s = Z(t.output.amount), i =
|
|
2890
|
+
const s = Z(t.output.amount), i = Ct(e).next().with_value(s).build();
|
|
2891
2891
|
return t.output.amount.forEach((o) => {
|
|
2892
2892
|
this.setTxOutput(o);
|
|
2893
2893
|
}), this._txBuilder.add_output(i), this;
|
|
@@ -2903,7 +2903,7 @@ let $ = class {
|
|
|
2903
2903
|
return this._txBuilder.add_json_metadatum_with_schema(a.BigNum.from_str(e.toString()), JSON.stringify(t), a.MetadataJsonSchema.NoConversions), this;
|
|
2904
2904
|
}
|
|
2905
2905
|
setRequiredSigners(e) {
|
|
2906
|
-
return Array.from(new Set(e.map((s) => s.startsWith("addr") ?
|
|
2906
|
+
return Array.from(new Set(e.map((s) => s.startsWith("addr") ? it(s) : gt(s)).map((s) => H(s)))).forEach((s) => {
|
|
2907
2907
|
this._txBuilder.add_required_signer(s);
|
|
2908
2908
|
}), this;
|
|
2909
2909
|
}
|
|
@@ -2914,12 +2914,12 @@ let $ = class {
|
|
|
2914
2914
|
return this._txBuilder.set_ttl_bignum(a.BigNum.from_str(e)), this;
|
|
2915
2915
|
}
|
|
2916
2916
|
setTxInputs(e) {
|
|
2917
|
-
return e.map((t) =>
|
|
2917
|
+
return e.map((t) => M(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) => M(t)).forEach((t) => {
|
|
2923
2923
|
this._txBuilder.add_reference_input(t.input());
|
|
2924
2924
|
}), this;
|
|
2925
2925
|
}
|
|
@@ -2930,7 +2930,7 @@ let $ = class {
|
|
|
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) =>
|
|
2933
|
+
os(this._totalBurns, e.map((s) => vt(s))).map((s) => M(s)).forEach((s) => {
|
|
2934
2934
|
this._txInputsBuilder.add_input(s.output().address(), s.input(), s.output().amount());
|
|
2935
2935
|
});
|
|
2936
2936
|
}
|
|
@@ -2950,14 +2950,14 @@ let $ = class {
|
|
|
2950
2950
|
}
|
|
2951
2951
|
async addRequiredSignersIfNeeded() {
|
|
2952
2952
|
if (this._initiator && this.notVisited("setRequiredSigners")) {
|
|
2953
|
-
const e = await this._initiator.getUsedAddress(), t =
|
|
2954
|
-
this._txBuilder.add_required_signer(
|
|
2953
|
+
const e = await this._initiator.getUsedAddress(), t = it(e.to_bech32());
|
|
2954
|
+
this._txBuilder.add_required_signer(H(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) =>
|
|
2960
|
+
is(this._txOutputs, e.map((s) => vt(s))).map((s) => M(s)).forEach((s) => {
|
|
2961
2961
|
this._txInputsBuilder.add_input(s.output().address(), s.input(), s.output().amount());
|
|
2962
2962
|
});
|
|
2963
2963
|
}
|
|
@@ -3006,7 +3006,7 @@ let $ = class {
|
|
|
3006
3006
|
this._recipients.forEach((e, t) => {
|
|
3007
3007
|
const n = Z(e).multiasset();
|
|
3008
3008
|
if (n !== void 0) {
|
|
3009
|
-
const o =
|
|
3009
|
+
const o = Ct(t).next().with_asset_and_min_required_coin_by_utxo_cost(n, Ht(this._protocolParameters.coinsPerUTxOSize)).build();
|
|
3010
3010
|
this._txBuilder.add_output(o);
|
|
3011
3011
|
}
|
|
3012
3012
|
});
|
|
@@ -3019,39 +3019,46 @@ let $ = class {
|
|
|
3019
3019
|
this._txOutputs.set(e.unit, s);
|
|
3020
3020
|
}
|
|
3021
3021
|
};
|
|
3022
|
-
|
|
3023
|
-
|
|
3022
|
+
st([
|
|
3023
|
+
rt()
|
|
3024
3024
|
], $.prototype, "mintAsset", null);
|
|
3025
|
-
|
|
3026
|
-
|
|
3025
|
+
st([
|
|
3026
|
+
rt()
|
|
3027
3027
|
], $.prototype, "redeemValue", null);
|
|
3028
|
-
|
|
3029
|
-
|
|
3028
|
+
st([
|
|
3029
|
+
rt()
|
|
3030
3030
|
], $.prototype, "sendAssets", null);
|
|
3031
|
-
|
|
3032
|
-
|
|
3031
|
+
st([
|
|
3032
|
+
rt()
|
|
3033
3033
|
], $.prototype, "sendValue", null);
|
|
3034
|
-
|
|
3035
|
-
|
|
3034
|
+
st([
|
|
3035
|
+
rt()
|
|
3036
3036
|
], $.prototype, "setCollateral", null);
|
|
3037
|
-
|
|
3038
|
-
|
|
3037
|
+
st([
|
|
3038
|
+
rt()
|
|
3039
3039
|
], $.prototype, "setRequiredSigners", null);
|
|
3040
|
-
|
|
3041
|
-
|
|
3040
|
+
st([
|
|
3041
|
+
rt()
|
|
3042
3042
|
], $.prototype, "setTxInputs", null);
|
|
3043
|
-
$ =
|
|
3043
|
+
$ = st([
|
|
3044
3044
|
Xs
|
|
3045
3045
|
], $);
|
|
3046
3046
|
class Zs {
|
|
3047
3047
|
txHex = "";
|
|
3048
|
-
txBuilder =
|
|
3049
|
-
|
|
3048
|
+
txBuilder = Et();
|
|
3049
|
+
txEvaluationMultiplier = 1.1;
|
|
3050
|
+
_protocolParams = v;
|
|
3050
3051
|
txOutput;
|
|
3051
3052
|
addingScriptInput = !1;
|
|
3052
3053
|
addingPlutusMint = !1;
|
|
3053
3054
|
isHydra = !1;
|
|
3054
|
-
meshTxBuilderBody
|
|
3055
|
+
meshTxBuilderBody;
|
|
3056
|
+
mintItem;
|
|
3057
|
+
txInQueueItem;
|
|
3058
|
+
collateralQueueItem;
|
|
3059
|
+
refScriptTxInQueueItem;
|
|
3060
|
+
reset = () => (this.txHex = "", this.txBuilder = Et(), this.txEvaluationMultiplier = 1.1, this._protocolParams = v, 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
|
+
emptyTxBuilderBody = () => ({
|
|
3055
3062
|
inputs: [],
|
|
3056
3063
|
outputs: [],
|
|
3057
3064
|
collaterals: [],
|
|
@@ -3062,11 +3069,10 @@ class Zs {
|
|
|
3062
3069
|
metadata: [],
|
|
3063
3070
|
validityRange: {},
|
|
3064
3071
|
signingKey: []
|
|
3065
|
-
};
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
refScriptTxInQueueItem;
|
|
3072
|
+
});
|
|
3073
|
+
constructor() {
|
|
3074
|
+
this.meshTxBuilderBody = this.emptyTxBuilderBody();
|
|
3075
|
+
}
|
|
3070
3076
|
completeSync = (e) => (e && (this.meshTxBuilderBody = e), this.serializeTxBody(this.meshTxBuilderBody));
|
|
3071
3077
|
completeSigning = () => {
|
|
3072
3078
|
const { signingKey: e } = this.meshTxBuilderBody;
|
|
@@ -3074,14 +3080,21 @@ class Zs {
|
|
|
3074
3080
|
};
|
|
3075
3081
|
serializeTxBody = (e) => {
|
|
3076
3082
|
const { inputs: t, outputs: s, collaterals: n, referenceInputs: i, mints: o, changeAddress: c, validityRange: u, requiredSignatures: d, metadata: A } = e;
|
|
3077
|
-
|
|
3083
|
+
if (this.isHydra ? this.protocolParams({
|
|
3078
3084
|
minFeeA: 0,
|
|
3079
3085
|
minFeeB: 0,
|
|
3080
3086
|
priceMem: 0,
|
|
3081
3087
|
priceStep: 0,
|
|
3082
3088
|
collateralPercent: 0,
|
|
3083
3089
|
coinsPerUTxOSize: "0"
|
|
3084
|
-
}) : this.protocolParams({}), this.meshTxBuilderBody.mints.sort((l, g) => l.policyId.localeCompare(g.policyId)), this.meshTxBuilderBody.inputs.sort((l, g) => l.txIn.txHash === g.txIn.txHash ? l.txIn.txIndex - g.txIn.txIndex : l.txIn.txHash.localeCompare(g.txIn.txHash)), this.addAllInputs(t), this.addAllOutputs(s), this.addAllCollaterals(n), this.addAllReferenceInputs(i), this.addAllMints(o), this.addValidityRange(u), this.addAllRequiredSignatures(d), this.addAllMetadata(A), this.addCostModels(), c
|
|
3090
|
+
}) : this.protocolParams({}), this.meshTxBuilderBody.mints.sort((l, g) => l.policyId.localeCompare(g.policyId)), this.meshTxBuilderBody.inputs.sort((l, g) => l.txIn.txHash === g.txIn.txHash ? l.txIn.txIndex - g.txIn.txIndex : l.txIn.txHash.localeCompare(g.txIn.txHash)), this.addAllInputs(t), this.addAllOutputs(s), this.addAllCollaterals(n), this.addAllReferenceInputs(i), this.addAllMints(o), this.addValidityRange(u), this.addAllRequiredSignatures(d), this.addAllMetadata(A), this.addCostModels(), c) {
|
|
3091
|
+
const l = this.meshTxBuilderBody.collaterals.map((g) => {
|
|
3092
|
+
var I, y;
|
|
3093
|
+
return ((y = (I = g.txIn.amount) == null ? void 0 : I.find((k) => k.unit === "lovelace")) == null ? void 0 : y.quantity) || "0";
|
|
3094
|
+
}).reduce((g, I) => g + parseInt(I), 0);
|
|
3095
|
+
l > 0 && (this.txBuilder.set_collateral_return(a.TransactionOutput.new(a.Address.from_bech32(c), a.Value.new(a.BigNum.from_str(String(l))))), this.txBuilder.set_total_collateral(a.BigNum.from_str(String(l)))), this.addChange(c), this.addCollateralReturn(c);
|
|
3096
|
+
}
|
|
3097
|
+
return this.buildTx(), this;
|
|
3085
3098
|
};
|
|
3086
3099
|
txIn = (e, t, s, n) => (this.txInQueueItem && this.queueInput(), this.addingScriptInput ? this.txInQueueItem = {
|
|
3087
3100
|
type: "Script",
|
|
@@ -3101,24 +3114,39 @@ class Zs {
|
|
|
3101
3114
|
address: n
|
|
3102
3115
|
}
|
|
3103
3116
|
}, this.addingScriptInput = !1, this);
|
|
3104
|
-
txInScript = (e) => {
|
|
3117
|
+
txInScript = (e, t = "V2") => {
|
|
3105
3118
|
if (!this.txInQueueItem)
|
|
3106
3119
|
throw Error("Undefined input");
|
|
3107
3120
|
if (this.txInQueueItem.type === "PubKey")
|
|
3108
3121
|
throw Error("Datum value attempted to be called a non script input");
|
|
3109
3122
|
return this.txInQueueItem.scriptTxIn.scriptSource = {
|
|
3110
3123
|
type: "Provided",
|
|
3111
|
-
|
|
3124
|
+
script: {
|
|
3125
|
+
code: e,
|
|
3126
|
+
version: t
|
|
3127
|
+
}
|
|
3112
3128
|
}, this;
|
|
3113
3129
|
};
|
|
3114
|
-
txInDatumValue = (e) => {
|
|
3130
|
+
txInDatumValue = (e, t = "Mesh") => {
|
|
3115
3131
|
if (!this.txInQueueItem)
|
|
3116
3132
|
throw Error("Undefined input");
|
|
3117
3133
|
if (this.txInQueueItem.type === "PubKey")
|
|
3118
3134
|
throw Error("Datum value attempted to be called a non script input");
|
|
3135
|
+
if (t === "Mesh")
|
|
3136
|
+
return this.txInQueueItem.scriptTxIn.datumSource = {
|
|
3137
|
+
type: "Provided",
|
|
3138
|
+
data: {
|
|
3139
|
+
type: t,
|
|
3140
|
+
content: e
|
|
3141
|
+
}
|
|
3142
|
+
}, this;
|
|
3143
|
+
const s = this.castRawDataToJsonString(e);
|
|
3119
3144
|
return this.txInQueueItem.scriptTxIn.datumSource = {
|
|
3120
3145
|
type: "Provided",
|
|
3121
|
-
data:
|
|
3146
|
+
data: {
|
|
3147
|
+
type: t,
|
|
3148
|
+
content: s
|
|
3149
|
+
}
|
|
3122
3150
|
}, this;
|
|
3123
3151
|
};
|
|
3124
3152
|
txInInlineDatumPresent = () => {
|
|
@@ -3133,13 +3161,25 @@ class Zs {
|
|
|
3133
3161
|
txIndex: t
|
|
3134
3162
|
}), this;
|
|
3135
3163
|
};
|
|
3136
|
-
txInRedeemerValue = (e, t =
|
|
3164
|
+
txInRedeemerValue = (e, t = { ...at }, s = "Mesh") => {
|
|
3137
3165
|
if (!this.txInQueueItem)
|
|
3138
3166
|
throw Error("Undefined input");
|
|
3139
3167
|
if (this.txInQueueItem.type === "PubKey")
|
|
3140
3168
|
throw Error("Spending tx in reference redeemer attempted to be called a non script input");
|
|
3169
|
+
if (s === "Mesh")
|
|
3170
|
+
return this.txInQueueItem.scriptTxIn.redeemer = {
|
|
3171
|
+
data: {
|
|
3172
|
+
type: s,
|
|
3173
|
+
content: e
|
|
3174
|
+
},
|
|
3175
|
+
exUnits: t
|
|
3176
|
+
}, this;
|
|
3177
|
+
const n = this.castRawDataToJsonString(e);
|
|
3141
3178
|
return this.txInQueueItem.scriptTxIn.redeemer = {
|
|
3142
|
-
data:
|
|
3179
|
+
data: {
|
|
3180
|
+
type: s,
|
|
3181
|
+
content: n
|
|
3182
|
+
},
|
|
3143
3183
|
exUnits: t
|
|
3144
3184
|
}, this;
|
|
3145
3185
|
};
|
|
@@ -3147,17 +3187,51 @@ class Zs {
|
|
|
3147
3187
|
address: e,
|
|
3148
3188
|
amount: t
|
|
3149
3189
|
}, this);
|
|
3150
|
-
txOutDatumHashValue = (e
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3190
|
+
txOutDatumHashValue = (e, t = "Mesh") => {
|
|
3191
|
+
if (this.txOutput) {
|
|
3192
|
+
if (t === "Mesh")
|
|
3193
|
+
return this.txOutput.datum = {
|
|
3194
|
+
type: "Hash",
|
|
3195
|
+
data: {
|
|
3196
|
+
type: t,
|
|
3197
|
+
content: e
|
|
3198
|
+
}
|
|
3199
|
+
}, this;
|
|
3200
|
+
const s = this.castRawDataToJsonString(e);
|
|
3201
|
+
this.txOutput.datum = {
|
|
3202
|
+
type: "Hash",
|
|
3203
|
+
data: {
|
|
3204
|
+
type: t,
|
|
3205
|
+
content: s
|
|
3206
|
+
}
|
|
3207
|
+
};
|
|
3208
|
+
}
|
|
3209
|
+
return this;
|
|
3210
|
+
};
|
|
3211
|
+
txOutInlineDatumValue = (e, t = "Mesh") => {
|
|
3212
|
+
if (this.txOutput) {
|
|
3213
|
+
if (t === "Mesh")
|
|
3214
|
+
return this.txOutput.datum = {
|
|
3215
|
+
type: "Inline",
|
|
3216
|
+
data: {
|
|
3217
|
+
type: t,
|
|
3218
|
+
content: e
|
|
3219
|
+
}
|
|
3220
|
+
}, this;
|
|
3221
|
+
const s = this.castRawDataToJsonString(e);
|
|
3222
|
+
this.txOutput.datum = {
|
|
3223
|
+
type: "Inline",
|
|
3224
|
+
data: {
|
|
3225
|
+
type: t,
|
|
3226
|
+
content: s
|
|
3227
|
+
}
|
|
3228
|
+
};
|
|
3229
|
+
}
|
|
3230
|
+
return this;
|
|
3231
|
+
};
|
|
3232
|
+
txOutReferenceScript = (e, t = "V2") => (this.txOutput && (this.txOutput.referenceScript = { code: e, version: t }), this);
|
|
3159
3233
|
spendingPlutusScriptV2 = () => (this.addingScriptInput = !0, this);
|
|
3160
|
-
spendingTxInReference = (e, t, s) => {
|
|
3234
|
+
spendingTxInReference = (e, t, s, n = "V2") => {
|
|
3161
3235
|
if (!this.txInQueueItem)
|
|
3162
3236
|
throw Error("Undefined input");
|
|
3163
3237
|
if (this.txInQueueItem.type === "PubKey")
|
|
@@ -3167,12 +3241,13 @@ class Zs {
|
|
|
3167
3241
|
txInInfo: {
|
|
3168
3242
|
txHash: e,
|
|
3169
3243
|
txIndex: t,
|
|
3170
|
-
spendingScriptHash: s
|
|
3244
|
+
spendingScriptHash: s,
|
|
3245
|
+
version: n
|
|
3171
3246
|
}
|
|
3172
3247
|
}, this;
|
|
3173
3248
|
};
|
|
3174
3249
|
spendingReferenceTxInInlineDatumPresent = () => (this.txInInlineDatumPresent(), this);
|
|
3175
|
-
spendingReferenceTxInRedeemerValue = (e, t =
|
|
3250
|
+
spendingReferenceTxInRedeemerValue = (e, t = { ...at }) => (this.txInRedeemerValue(e, t), this);
|
|
3176
3251
|
readOnlyTxInReference = (e, t) => (this.meshTxBuilderBody.referenceInputs.push({ txHash: e, txIndex: t }), this);
|
|
3177
3252
|
mintPlutusScriptV2 = () => (this.addingPlutusMint = !0, this);
|
|
3178
3253
|
mint = (e, t, s) => (this.mintItem && this.queueMint(), this.mintItem = {
|
|
@@ -3181,14 +3256,17 @@ class Zs {
|
|
|
3181
3256
|
assetName: s,
|
|
3182
3257
|
amount: e
|
|
3183
3258
|
}, this.addingPlutusMint = !1, this);
|
|
3184
|
-
mintingScript = (e) => {
|
|
3259
|
+
mintingScript = (e, t = "V2") => {
|
|
3185
3260
|
if (!this.mintItem)
|
|
3186
3261
|
throw Error("Undefined mint");
|
|
3187
3262
|
if (!this.mintItem.type)
|
|
3188
3263
|
throw Error("Mint information missing");
|
|
3189
|
-
return this.mintItem.scriptSource = {
|
|
3264
|
+
return this.mintItem.scriptSource = {
|
|
3265
|
+
type: "Provided",
|
|
3266
|
+
script: { code: e, version: t }
|
|
3267
|
+
}, this;
|
|
3190
3268
|
};
|
|
3191
|
-
mintTxInReference = (e, t) => {
|
|
3269
|
+
mintTxInReference = (e, t, s = "V2") => {
|
|
3192
3270
|
if (!this.mintItem)
|
|
3193
3271
|
throw Error("Undefined mint");
|
|
3194
3272
|
if (!this.mintItem.type)
|
|
@@ -3200,10 +3278,11 @@ class Zs {
|
|
|
3200
3278
|
return this.mintItem.scriptSource = {
|
|
3201
3279
|
type: "Reference Script",
|
|
3202
3280
|
txHash: e,
|
|
3203
|
-
txIndex: t
|
|
3281
|
+
txIndex: t,
|
|
3282
|
+
version: s
|
|
3204
3283
|
}, this;
|
|
3205
3284
|
};
|
|
3206
|
-
mintReferenceTxInRedeemerValue = (e, t =
|
|
3285
|
+
mintReferenceTxInRedeemerValue = (e, t = { ...at }, s = "Mesh") => {
|
|
3207
3286
|
if (!this.mintItem)
|
|
3208
3287
|
throw Error("Undefined mint");
|
|
3209
3288
|
if (this.mintItem.type == "Native")
|
|
@@ -3211,14 +3290,26 @@ class Zs {
|
|
|
3211
3290
|
if (this.mintItem.type == "Plutus") {
|
|
3212
3291
|
if (!this.mintItem.policyId)
|
|
3213
3292
|
throw Error("PolicyId information missing from mint asset");
|
|
3293
|
+
if (s === "Mesh")
|
|
3294
|
+
return this.mintItem.redeemer = {
|
|
3295
|
+
data: {
|
|
3296
|
+
type: s,
|
|
3297
|
+
content: e
|
|
3298
|
+
},
|
|
3299
|
+
exUnits: t
|
|
3300
|
+
}, this;
|
|
3301
|
+
const n = this.castRawDataToJsonString(e);
|
|
3214
3302
|
this.mintItem.redeemer = {
|
|
3215
|
-
data:
|
|
3303
|
+
data: {
|
|
3304
|
+
type: s,
|
|
3305
|
+
content: n
|
|
3306
|
+
},
|
|
3216
3307
|
exUnits: t
|
|
3217
3308
|
};
|
|
3218
3309
|
}
|
|
3219
3310
|
return this;
|
|
3220
3311
|
};
|
|
3221
|
-
mintRedeemerValue = (e, t) => (this.mintReferenceTxInRedeemerValue(e, t), this);
|
|
3312
|
+
mintRedeemerValue = (e, t = { ...at }, s = "Mesh") => (this.mintReferenceTxInRedeemerValue(e, t, s), this);
|
|
3222
3313
|
requiredSignerHash = (e) => (this.meshTxBuilderBody.requiredSignatures.push(e), this);
|
|
3223
3314
|
txInCollateral = (e, t, s, n) => (this.collateralQueueItem && this.meshTxBuilderBody.collaterals.push(this.collateralQueueItem), this.collateralQueueItem = {
|
|
3224
3315
|
type: "PubKey",
|
|
@@ -3234,8 +3325,8 @@ class Zs {
|
|
|
3234
3325
|
invalidHereafter = (e) => (this.meshTxBuilderBody.validityRange.invalidHereafter = e, this);
|
|
3235
3326
|
metadataValue = (e, t) => (this.meshTxBuilderBody.metadata.push({ tag: e, metadata: t }), this);
|
|
3236
3327
|
protocolParams = (e) => {
|
|
3237
|
-
const t = { ...
|
|
3238
|
-
return this._protocolParams = t, this.txBuilder =
|
|
3328
|
+
const t = { ...v, ...e };
|
|
3329
|
+
return this._protocolParams = t, this.txBuilder = Et(t), this;
|
|
3239
3330
|
};
|
|
3240
3331
|
signingKey = (e) => (this.meshTxBuilderBody.signingKey.push(e), this);
|
|
3241
3332
|
addAllSigningKeys = (e) => {
|
|
@@ -3279,7 +3370,7 @@ class Zs {
|
|
|
3279
3370
|
};
|
|
3280
3371
|
makePlutusScriptSource = (e) => {
|
|
3281
3372
|
const t = a.ScriptHash.from_hex(e.spendingScriptHash), s = a.TransactionInput.new(a.TransactionHash.from_hex(e.txHash), e.txIndex);
|
|
3282
|
-
return a.PlutusScriptSource.new_ref_input_with_lang_ver(t, s,
|
|
3373
|
+
return a.PlutusScriptSource.new_ref_input_with_lang_ver(t, s, R[e.version]);
|
|
3283
3374
|
};
|
|
3284
3375
|
addAllInputs = (e) => {
|
|
3285
3376
|
for (let t = 0; t < e.length; t++) {
|
|
@@ -3301,14 +3392,14 @@ class Zs {
|
|
|
3301
3392
|
let s;
|
|
3302
3393
|
const { datumSource: n, scriptSource: i, redeemer: o } = e;
|
|
3303
3394
|
if (n.type === "Provided")
|
|
3304
|
-
s = a.DatumSource.new(
|
|
3395
|
+
s = a.DatumSource.new(this.castDataToPlutusData(n.data));
|
|
3305
3396
|
else {
|
|
3306
3397
|
const d = a.TransactionInput.new(a.TransactionHash.from_hex(n.txHash), n.txIndex);
|
|
3307
3398
|
s = a.DatumSource.new_ref_input(d);
|
|
3308
3399
|
}
|
|
3309
3400
|
let c;
|
|
3310
|
-
i.type == "Inline" ? c = this.makePlutusScriptSource(i.txInInfo) : c = a.PlutusScriptSource.new(a.PlutusScript.from_hex_with_version(i.
|
|
3311
|
-
const u = a.Redeemer.new(a.RedeemerTag.new_spend(), a.BigNum.from_str("0"),
|
|
3401
|
+
i.type == "Inline" ? c = this.makePlutusScriptSource(i.txInInfo) : c = a.PlutusScriptSource.new(a.PlutusScript.from_hex_with_version(i.script.code, R[i.script.version]));
|
|
3402
|
+
const u = a.Redeemer.new(a.RedeemerTag.new_spend(), a.BigNum.from_str("0"), this.castDataToPlutusData(o.data), a.ExUnits.new(a.BigNum.from_str(String(o.exUnits.mem)), a.BigNum.from_str(String(o.exUnits.steps))));
|
|
3312
3403
|
this.txBuilder.add_plutus_script_input(a.PlutusWitness.new_with_ref(c, s, u), a.TransactionInput.new(a.TransactionHash.from_hex(t.txHash), t.txIndex), Z(t.amount));
|
|
3313
3404
|
};
|
|
3314
3405
|
addAllOutputs = (e) => {
|
|
@@ -3322,7 +3413,7 @@ class Zs {
|
|
|
3322
3413
|
if (i.is_zero() && o === void 0)
|
|
3323
3414
|
throw Error("Invalid output amount");
|
|
3324
3415
|
let c = a.TransactionOutputBuilder.new().with_address(K(t));
|
|
3325
|
-
s && s.type === "Hash" && (c = c.with_data_hash(a.hash_plutus_data(
|
|
3416
|
+
s && s.type === "Hash" && (c = c.with_data_hash(a.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(a.ScriptRef.new_plutus_script(a.PlutusScript.from_hex_with_version(n.code, R[n.version]))));
|
|
3326
3417
|
const u = c.next();
|
|
3327
3418
|
if (o) {
|
|
3328
3419
|
const d = i.coin().is_zero() ? u.with_asset_and_min_required_coin_by_utxo_cost(o, Ht(this._protocolParams.coinsPerUTxOSize)).build() : u.with_coin_and_asset(i.coin(), o).build();
|
|
@@ -3343,7 +3434,13 @@ class Zs {
|
|
|
3343
3434
|
addCollateral = (e, t) => {
|
|
3344
3435
|
e.add_input(a.Address.from_bech32(t.txIn.address), a.TransactionInput.new(a.TransactionHash.from_hex(t.txIn.txHash), t.txIn.txIndex), Z(t.txIn.amount));
|
|
3345
3436
|
};
|
|
3346
|
-
addCollateralReturn = (e
|
|
3437
|
+
addCollateralReturn = (e) => {
|
|
3438
|
+
var s;
|
|
3439
|
+
const t = (s = this.txBuilder.get_fee_if_set()) == null ? void 0 : s.to_js_value();
|
|
3440
|
+
if (t) {
|
|
3441
|
+
const n = Math.ceil(this._protocolParams.collateralPercent * Number(t) / 100);
|
|
3442
|
+
this.txBuilder.set_total_collateral_and_return(a.BigNum.from_str(String(n)), a.Address.from_bech32(e));
|
|
3443
|
+
}
|
|
3347
3444
|
};
|
|
3348
3445
|
addAllReferenceInputs = (e) => {
|
|
3349
3446
|
e.forEach((t) => {
|
|
@@ -3371,13 +3468,13 @@ class Zs {
|
|
|
3371
3468
|
this.txBuilder.set_mint_builder(t);
|
|
3372
3469
|
};
|
|
3373
3470
|
addPlutusMint = (e, { redeemer: t, policyId: s, scriptSource: n, assetName: i, amount: o }, c) => {
|
|
3374
|
-
const u = a.Redeemer.new(a.RedeemerTag.new_mint(), a.BigNum.from_str(String(c)),
|
|
3471
|
+
const u = a.Redeemer.new(a.RedeemerTag.new_mint(), a.BigNum.from_str(String(c)), this.castDataToPlutusData(t.data), a.ExUnits.new(a.BigNum.from_str(String(t.exUnits.mem)), a.BigNum.from_str(String(t.exUnits.steps)))), d = n.type === "Reference Script" ? a.PlutusScriptSource.new_ref_input_with_lang_ver(a.ScriptHash.from_hex(s), a.TransactionInput.new(a.TransactionHash.from_hex(n.txHash), n.txIndex), R[n.version]) : a.PlutusScriptSource.new(a.PlutusScript.from_hex_with_version(n.script.code, R[n.script.version]));
|
|
3375
3472
|
e.add_asset(a.MintWitness.new_plutus_script(d, u), a.AssetName.new(Buffer.from(i, "hex")), a.Int.new_i32(o));
|
|
3376
3473
|
};
|
|
3377
3474
|
addNativeMint = (e, { scriptSource: t, assetName: s, amount: n }) => {
|
|
3378
3475
|
if (t.type === "Reference Script")
|
|
3379
3476
|
throw Error("Native mint cannot have reference script");
|
|
3380
|
-
e.add_asset(a.MintWitness.new_native_script(a.NativeScript.from_hex(t.
|
|
3477
|
+
e.add_asset(a.MintWitness.new_native_script(a.NativeScript.from_hex(t.script.code)), a.AssetName.new(Buffer.from(s, "hex")), a.Int.new_i32(n));
|
|
3381
3478
|
};
|
|
3382
3479
|
queueAllLastItem = () => {
|
|
3383
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();
|
|
@@ -3406,17 +3503,19 @@ class Zs {
|
|
|
3406
3503
|
switch (s.tag) {
|
|
3407
3504
|
case "SPEND": {
|
|
3408
3505
|
const n = e.inputs[s.index];
|
|
3409
|
-
n.type == "Script" && n.scriptTxIn.redeemer && (n.scriptTxIn.redeemer.exUnits.mem = s.budget.mem, n.scriptTxIn.redeemer.exUnits.steps = s.budget.steps);
|
|
3506
|
+
n.type == "Script" && n.scriptTxIn.redeemer && (n.scriptTxIn.redeemer.exUnits.mem = Math.floor(s.budget.mem * this.txEvaluationMultiplier), n.scriptTxIn.redeemer.exUnits.steps = Math.floor(s.budget.steps * this.txEvaluationMultiplier));
|
|
3410
3507
|
break;
|
|
3411
3508
|
}
|
|
3412
3509
|
case "MINT": {
|
|
3413
3510
|
const n = e.mints[s.index];
|
|
3414
|
-
n.type == "Plutus" && n.redeemer && (n.redeemer.exUnits.mem = s.budget.mem, n.redeemer.exUnits.steps = s.budget.steps);
|
|
3511
|
+
n.type == "Plutus" && n.redeemer && (n.redeemer.exUnits.mem = Math.floor(s.budget.mem * this.txEvaluationMultiplier), n.redeemer.exUnits.steps = Math.floor(s.budget.steps * this.txEvaluationMultiplier));
|
|
3415
3512
|
break;
|
|
3416
3513
|
}
|
|
3417
3514
|
}
|
|
3418
3515
|
});
|
|
3419
3516
|
};
|
|
3517
|
+
castRawDataToJsonString = (e) => typeof e == "object" ? JSON.stringify(e) : e;
|
|
3518
|
+
castDataToPlutusData = ({ type: e, content: t }) => e === "Mesh" ? tt(t) : a.PlutusData.from_json(t, a.PlutusDatumSchema.DetailedSchema);
|
|
3420
3519
|
}
|
|
3421
3520
|
class Dr extends Zs {
|
|
3422
3521
|
_fetcher;
|
|
@@ -3489,7 +3588,7 @@ class C {
|
|
|
3489
3588
|
}
|
|
3490
3589
|
getAccount(e, t) {
|
|
3491
3590
|
return this.accountContext(e, t, (s, n) => {
|
|
3492
|
-
const i = 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 =
|
|
3591
|
+
const i = 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();
|
|
3493
3592
|
return {
|
|
3494
3593
|
baseAddress: i,
|
|
3495
3594
|
enterpriseAddress: o,
|
|
@@ -3512,7 +3611,7 @@ class C {
|
|
|
3512
3611
|
}
|
|
3513
3612
|
signTx(e, t, s, n, i) {
|
|
3514
3613
|
try {
|
|
3515
|
-
const o =
|
|
3614
|
+
const o = Me(js(n));
|
|
3516
3615
|
return this.accountContext(e, t, (c, u) => {
|
|
3517
3616
|
const d = a.Vkeywitnesses.new();
|
|
3518
3617
|
return C.resolveSigners(n, s, c.to_public().hash().to_hex()).forEach((l) => {
|
|
@@ -3529,11 +3628,11 @@ class C {
|
|
|
3529
3628
|
}
|
|
3530
3629
|
}
|
|
3531
3630
|
static encryptMnemonic(e, t) {
|
|
3532
|
-
const s = we(e.join(" ")), n =
|
|
3631
|
+
const s = we(e.join(" ")), n = qe(s), i = b(n.as_bytes());
|
|
3533
3632
|
return n.free(), C.encrypt(i, t);
|
|
3534
3633
|
}
|
|
3535
3634
|
static encryptPrivateKey(e, t) {
|
|
3536
|
-
const s = a.Bip32PrivateKey.from_bech32(e), n =
|
|
3635
|
+
const s = a.Bip32PrivateKey.from_bech32(e), n = b(s.as_bytes());
|
|
3537
3636
|
return s.free(), C.encrypt(n, t);
|
|
3538
3637
|
}
|
|
3539
3638
|
static encryptSigningKeys(e, t, s) {
|
|
@@ -3549,20 +3648,20 @@ class C {
|
|
|
3549
3648
|
}
|
|
3550
3649
|
static decrypt(e, t) {
|
|
3551
3650
|
try {
|
|
3552
|
-
return a.decrypt_with_password(
|
|
3651
|
+
return a.decrypt_with_password(E(t), e);
|
|
3553
3652
|
} catch {
|
|
3554
3653
|
throw new Error("The password is incorrect.");
|
|
3555
3654
|
}
|
|
3556
3655
|
}
|
|
3557
3656
|
static encrypt(e, t) {
|
|
3558
3657
|
const s = Ce("0123456789abcdef"), n = s(64), i = s(24);
|
|
3559
|
-
return a.encrypt_with_password(
|
|
3658
|
+
return a.encrypt_with_password(E(t), n, i, e);
|
|
3560
3659
|
}
|
|
3561
3660
|
static resolveAddress(e, t, s, n) {
|
|
3562
3661
|
const i = [
|
|
3563
3662
|
fe(e, s.to_public().hash(), n.to_public().hash()),
|
|
3564
3663
|
_e(e, s.to_public().hash()),
|
|
3565
|
-
|
|
3664
|
+
Ft(e, n.to_public().hash())
|
|
3566
3665
|
].find((o) => o.to_address().to_bech32() === t);
|
|
3567
3666
|
if (i !== void 0)
|
|
3568
3667
|
return i.to_address();
|
|
@@ -3571,7 +3670,7 @@ class C {
|
|
|
3571
3670
|
static resolveKeys(e, t, s) {
|
|
3572
3671
|
if (typeof s == "string") {
|
|
3573
3672
|
const o = C.decrypt(s, t);
|
|
3574
|
-
return
|
|
3673
|
+
return Hs(o, e);
|
|
3575
3674
|
}
|
|
3576
3675
|
const n = C.decrypt(s[0], t), i = C.decrypt(s[1], t);
|
|
3577
3676
|
return {
|
|
@@ -3581,78 +3680,78 @@ class C {
|
|
|
3581
3680
|
}
|
|
3582
3681
|
static resolveSigners(e, t, s) {
|
|
3583
3682
|
const n = (c) => {
|
|
3584
|
-
const u = (
|
|
3585
|
-
var
|
|
3586
|
-
if (
|
|
3587
|
-
return
|
|
3588
|
-
const
|
|
3589
|
-
switch (
|
|
3683
|
+
const u = (f, S = [], w = 0) => {
|
|
3684
|
+
var ft, lt, $t, zt, Wt;
|
|
3685
|
+
if (f === void 0 || w >= f.len())
|
|
3686
|
+
return S;
|
|
3687
|
+
const T = f.get(w), U = new Array();
|
|
3688
|
+
switch (T.kind()) {
|
|
3590
3689
|
case a.CertificateKind.StakeDeregistration: {
|
|
3591
|
-
const x = (
|
|
3592
|
-
|
|
3690
|
+
const x = (ft = T.as_stake_deregistration()) == null ? void 0 : ft.stake_credential(), V = (x == null ? void 0 : x.kind()) === a.StakeCredKind.Key ? x.to_keyhash() : void 0;
|
|
3691
|
+
V && U.push(V.to_hex());
|
|
3593
3692
|
break;
|
|
3594
3693
|
}
|
|
3595
3694
|
case a.CertificateKind.StakeDelegation: {
|
|
3596
|
-
const x = (
|
|
3597
|
-
|
|
3695
|
+
const x = (lt = T.as_stake_delegation()) == null ? void 0 : lt.stake_credential(), V = (x == null ? void 0 : x.kind()) === a.StakeCredKind.Key ? x.to_keyhash() : void 0;
|
|
3696
|
+
V && U.push(V.to_hex());
|
|
3598
3697
|
break;
|
|
3599
3698
|
}
|
|
3600
3699
|
case a.CertificateKind.PoolRegistration: {
|
|
3601
|
-
const x = ($t =
|
|
3602
|
-
|
|
3700
|
+
const x = ($t = T.as_pool_registration()) == null ? void 0 : $t.pool_params().pool_owners();
|
|
3701
|
+
U.push(...A(x));
|
|
3603
3702
|
break;
|
|
3604
3703
|
}
|
|
3605
3704
|
case a.CertificateKind.PoolRetirement: {
|
|
3606
|
-
const x = (zt =
|
|
3607
|
-
x &&
|
|
3705
|
+
const x = (zt = T.as_pool_retirement()) == null ? void 0 : zt.pool_keyhash();
|
|
3706
|
+
x && U.push(x.to_hex());
|
|
3608
3707
|
break;
|
|
3609
3708
|
}
|
|
3610
3709
|
case a.CertificateKind.MoveInstantaneousRewardsCert: {
|
|
3611
|
-
const x = (Wt =
|
|
3710
|
+
const x = (Wt = T.as_move_instantaneous_rewards_cert()) == null ? void 0 : Wt.move_instantaneous_reward().as_to_stake_creds();
|
|
3612
3711
|
if (x)
|
|
3613
|
-
for (let
|
|
3614
|
-
const Jt = x.keys().get(
|
|
3615
|
-
jt &&
|
|
3712
|
+
for (let V = 0; V < x.len(); V += 1) {
|
|
3713
|
+
const Jt = x.keys().get(V), jt = Jt.kind() === a.StakeCredKind.Key ? Jt.to_keyhash() : void 0;
|
|
3714
|
+
jt && U.push(jt.to_hex());
|
|
3616
3715
|
}
|
|
3617
3716
|
break;
|
|
3618
3717
|
}
|
|
3619
3718
|
}
|
|
3620
|
-
return u(
|
|
3621
|
-
}, d = (
|
|
3622
|
-
if (
|
|
3623
|
-
return
|
|
3624
|
-
const
|
|
3625
|
-
return d(
|
|
3626
|
-
}, A = (
|
|
3627
|
-
if (
|
|
3628
|
-
return
|
|
3629
|
-
const
|
|
3630
|
-
return l(
|
|
3631
|
-
}, g = c.certs(),
|
|
3719
|
+
return u(f, [...S, ...U], w + 1);
|
|
3720
|
+
}, d = (f, S = [], w = 0) => {
|
|
3721
|
+
if (f === void 0 || w >= f.len())
|
|
3722
|
+
return S;
|
|
3723
|
+
const T = f.get(w).index(), U = f.get(w).transaction_id(), ft = t.find((lt) => lt.input.outputIndex === T && lt.input.txHash === U.to_hex()) !== void 0 ? s : "OUR_PRINCESS_IS_IN_ANOTHER_CASTLE";
|
|
3724
|
+
return d(f, [...S, ft], w + 1);
|
|
3725
|
+
}, A = (f, S = [], w = 0) => f === void 0 || w >= f.len() ? S : A(f, [...S, f.get(w).to_hex()], w + 1), l = (f, S = [], w = 0) => {
|
|
3726
|
+
if (f === void 0 || w >= f.len())
|
|
3727
|
+
return S;
|
|
3728
|
+
const T = f.keys().get(w).payment_cred(), U = T.kind() === a.StakeCredKind.Key ? T.to_keyhash() : void 0;
|
|
3729
|
+
return l(f, U ? [...S, U.to_hex()] : S, w + 1);
|
|
3730
|
+
}, g = c.certs(), I = c.collateral(), y = c.inputs(), k = c.required_signers(), z = c.withdrawals();
|
|
3632
3731
|
return [
|
|
3633
3732
|
...u(g),
|
|
3634
|
-
...d(
|
|
3733
|
+
...d(I),
|
|
3635
3734
|
...d(y),
|
|
3636
|
-
...A(
|
|
3735
|
+
...A(k),
|
|
3637
3736
|
...l(z)
|
|
3638
3737
|
];
|
|
3639
3738
|
}, i = (c) => {
|
|
3640
3739
|
const u = (A, l = []) => {
|
|
3641
|
-
var g,
|
|
3740
|
+
var g, I, y, k;
|
|
3642
3741
|
if (A)
|
|
3643
3742
|
for (let z = 0; z < A.len(); z += 1) {
|
|
3644
|
-
const
|
|
3645
|
-
switch (
|
|
3743
|
+
const f = A.get(z);
|
|
3744
|
+
switch (f.kind()) {
|
|
3646
3745
|
case a.NativeScriptKind.ScriptPubkey: {
|
|
3647
|
-
const
|
|
3648
|
-
return
|
|
3746
|
+
const S = (g = f.as_script_pubkey()) == null ? void 0 : g.addr_keyhash().to_hex();
|
|
3747
|
+
return S ? [...l, S] : l;
|
|
3649
3748
|
}
|
|
3650
3749
|
case a.NativeScriptKind.ScriptAll:
|
|
3651
|
-
return u((
|
|
3750
|
+
return u((I = f.as_script_all()) == null ? void 0 : I.native_scripts(), l);
|
|
3652
3751
|
case a.NativeScriptKind.ScriptAny:
|
|
3653
|
-
return u((y =
|
|
3752
|
+
return u((y = f.as_script_any()) == null ? void 0 : y.native_scripts(), l);
|
|
3654
3753
|
case a.NativeScriptKind.ScriptNOfK:
|
|
3655
|
-
return u((
|
|
3754
|
+
return u((k = f.as_script_n_of_k()) == null ? void 0 : k.native_scripts(), l);
|
|
3656
3755
|
}
|
|
3657
3756
|
}
|
|
3658
3757
|
return l;
|
|
@@ -3667,7 +3766,7 @@ class C {
|
|
|
3667
3766
|
]);
|
|
3668
3767
|
}
|
|
3669
3768
|
}
|
|
3670
|
-
const
|
|
3769
|
+
const P = "MARI0TIME";
|
|
3671
3770
|
class kr {
|
|
3672
3771
|
_fetcher;
|
|
3673
3772
|
_submitter;
|
|
@@ -3675,45 +3774,45 @@ class kr {
|
|
|
3675
3774
|
constructor(e) {
|
|
3676
3775
|
switch (this._fetcher = e.fetcher, this._submitter = e.submitter, e.key.type) {
|
|
3677
3776
|
case "mnemonic":
|
|
3678
|
-
this._wallet = new C(e.networkId, C.encryptMnemonic(e.key.words,
|
|
3777
|
+
this._wallet = new C(e.networkId, C.encryptMnemonic(e.key.words, P));
|
|
3679
3778
|
break;
|
|
3680
3779
|
case "root":
|
|
3681
|
-
this._wallet = new C(e.networkId, C.encryptPrivateKey(e.key.bech32,
|
|
3780
|
+
this._wallet = new C(e.networkId, C.encryptPrivateKey(e.key.bech32, P));
|
|
3682
3781
|
break;
|
|
3683
3782
|
case "cli":
|
|
3684
|
-
this._wallet = new C(e.networkId, C.encryptSigningKeys(e.key.payment, e.key.stake ?? "f0".repeat(34),
|
|
3783
|
+
this._wallet = new C(e.networkId, C.encryptSigningKeys(e.key.payment, e.key.stake ?? "f0".repeat(34), P));
|
|
3685
3784
|
}
|
|
3686
3785
|
}
|
|
3687
3786
|
getBaseAddress(e = 0) {
|
|
3688
|
-
return this._wallet.getAccount(e,
|
|
3787
|
+
return this._wallet.getAccount(e, P).baseAddress;
|
|
3689
3788
|
}
|
|
3690
3789
|
getPaymentAddress(e = 0) {
|
|
3691
|
-
return this._wallet.getAccount(e,
|
|
3790
|
+
return this._wallet.getAccount(e, P).enterpriseAddress;
|
|
3692
3791
|
}
|
|
3693
3792
|
getRewardAddress(e = 0) {
|
|
3694
|
-
return this._wallet.getAccount(e,
|
|
3793
|
+
return this._wallet.getAccount(e, P).rewardAddress;
|
|
3695
3794
|
}
|
|
3696
3795
|
getUsedAddress(e = 0) {
|
|
3697
|
-
const t = this._wallet.getAccount(e,
|
|
3796
|
+
const t = this._wallet.getAccount(e, P);
|
|
3698
3797
|
return K(t.enterpriseAddress);
|
|
3699
3798
|
}
|
|
3700
|
-
getUsedCollateral(e =
|
|
3799
|
+
getUsedCollateral(e = v.maxCollateralInputs) {
|
|
3701
3800
|
throw new Error("getUsedCollateral not implemented.");
|
|
3702
3801
|
}
|
|
3703
3802
|
async getUsedUTxOs(e = 0) {
|
|
3704
|
-
const t = this._wallet.getAccount(e,
|
|
3705
|
-
return (await this._fetcher.fetchAddressUTxOs(t.enterpriseAddress)).map((n) =>
|
|
3803
|
+
const t = this._wallet.getAccount(e, P);
|
|
3804
|
+
return (await this._fetcher.fetchAddressUTxOs(t.enterpriseAddress)).map((n) => M(n));
|
|
3706
3805
|
}
|
|
3707
3806
|
signData(e, t, s = 0) {
|
|
3708
3807
|
try {
|
|
3709
|
-
return this._wallet.signData(s,
|
|
3808
|
+
return this._wallet.signData(s, P, e, t);
|
|
3710
3809
|
} catch (n) {
|
|
3711
3810
|
throw new Error(`[AppWallet] An error occurred during signData: ${n}.`);
|
|
3712
3811
|
}
|
|
3713
3812
|
}
|
|
3714
3813
|
async signTx(e, t = !1, s = 0) {
|
|
3715
3814
|
try {
|
|
3716
|
-
const n = this._wallet.getAccount(s,
|
|
3815
|
+
const n = this._wallet.getAccount(s, P), i = await this._fetcher.fetchAddressUTxOs(n.enterpriseAddress), o = this._wallet.signTx(s, P, i, e, t), c = Y(e), u = c.witness_set(), d = Ge(u, o);
|
|
3717
3816
|
return u.set_vkeys(d), a.Transaction.new(c.body(), u, c.auxiliary_data()).to_hex();
|
|
3718
3817
|
} catch (n) {
|
|
3719
3818
|
throw new Error(`[AppWallet] An error occurred during signTx: ${n}.`);
|
|
@@ -3750,38 +3849,38 @@ class Ot {
|
|
|
3750
3849
|
}
|
|
3751
3850
|
async getBalance() {
|
|
3752
3851
|
const e = await this._walletInstance.getBalance();
|
|
3753
|
-
return
|
|
3852
|
+
return Re(Gs(e));
|
|
3754
3853
|
}
|
|
3755
3854
|
async getChangeAddress() {
|
|
3756
3855
|
const e = await this._walletInstance.getChangeAddress();
|
|
3757
|
-
return
|
|
3856
|
+
return nt(e).to_bech32();
|
|
3758
3857
|
}
|
|
3759
|
-
async getCollateral(e =
|
|
3760
|
-
return (await this.getUsedCollateral(e)).map((s) =>
|
|
3858
|
+
async getCollateral(e = v.maxCollateralInputs) {
|
|
3859
|
+
return (await this.getUsedCollateral(e)).map((s) => vt(s));
|
|
3761
3860
|
}
|
|
3762
3861
|
getNetworkId() {
|
|
3763
3862
|
return this._walletInstance.getNetworkId();
|
|
3764
3863
|
}
|
|
3765
3864
|
async getRewardAddresses() {
|
|
3766
|
-
return (await this._walletInstance.getRewardAddresses()).map((t) =>
|
|
3865
|
+
return (await this._walletInstance.getRewardAddresses()).map((t) => nt(t).to_bech32());
|
|
3767
3866
|
}
|
|
3768
3867
|
async getUnusedAddresses() {
|
|
3769
|
-
return (await this._walletInstance.getUnusedAddresses()).map((t) =>
|
|
3868
|
+
return (await this._walletInstance.getUnusedAddresses()).map((t) => nt(t).to_bech32());
|
|
3770
3869
|
}
|
|
3771
3870
|
async getUsedAddresses() {
|
|
3772
|
-
return (await this._walletInstance.getUsedAddresses()).map((t) =>
|
|
3871
|
+
return (await this._walletInstance.getUsedAddresses()).map((t) => nt(t).to_bech32());
|
|
3773
3872
|
}
|
|
3774
3873
|
async getUtxos() {
|
|
3775
|
-
return (await this.getUsedUTxOs()).map((t) =>
|
|
3874
|
+
return (await this.getUsedUTxOs()).map((t) => vt(t));
|
|
3776
3875
|
}
|
|
3777
3876
|
signData(e, t) {
|
|
3778
3877
|
const s = K(e).to_hex();
|
|
3779
|
-
return this._walletInstance.signData(s,
|
|
3878
|
+
return this._walletInstance.signData(s, E(t));
|
|
3780
3879
|
}
|
|
3781
3880
|
async signTx(e, t = !1) {
|
|
3782
3881
|
try {
|
|
3783
3882
|
const s = Y(e), n = s.witness_set(), i = await this._walletInstance.signTx(e, t), o = Ls(i).vkeys() ?? a.Vkeywitnesses.new(), c = Ge(n, o);
|
|
3784
|
-
return n.set_vkeys(c),
|
|
3883
|
+
return n.set_vkeys(c), b(a.Transaction.new(s.body(), n, s.auxiliary_data()).to_bytes());
|
|
3785
3884
|
} catch (s) {
|
|
3786
3885
|
throw new Error(`[BrowserWallet] An error occurred during signTx: ${JSON.stringify(s)}.`);
|
|
3787
3886
|
}
|
|
@@ -3791,9 +3890,9 @@ class Ot {
|
|
|
3791
3890
|
}
|
|
3792
3891
|
async getUsedAddress() {
|
|
3793
3892
|
const e = await this._walletInstance.getUsedAddresses();
|
|
3794
|
-
return
|
|
3893
|
+
return nt(e[0]);
|
|
3795
3894
|
}
|
|
3796
|
-
async getUsedCollateral(e =
|
|
3895
|
+
async getUsedCollateral(e = v.maxCollateralInputs) {
|
|
3797
3896
|
return (await this._walletInstance.experimental.getCollateral() ?? []).map((s) => Ie(s)).slice(0, e);
|
|
3798
3897
|
}
|
|
3799
3898
|
async getUsedUTxOs() {
|
|
@@ -3905,8 +4004,8 @@ export {
|
|
|
3905
4004
|
Qr as MaestroProvider,
|
|
3906
4005
|
Dr as MeshTxBuilder,
|
|
3907
4006
|
Tr as MinaWallet,
|
|
3908
|
-
|
|
3909
|
-
|
|
4007
|
+
Sr as OgmiosProvider,
|
|
4008
|
+
Er as TangoProvider,
|
|
3910
4009
|
$ as Transaction,
|
|
3911
4010
|
cr as checkSignature,
|
|
3912
4011
|
_r as generateNonce,
|
|
@@ -3914,7 +4013,7 @@ export {
|
|
|
3914
4013
|
is as keepRelevant,
|
|
3915
4014
|
or as largestFirst,
|
|
3916
4015
|
os as largestFirstMultiAsset,
|
|
3917
|
-
|
|
4016
|
+
et as parseAssetUnit,
|
|
3918
4017
|
h as parseHttpError,
|
|
3919
4018
|
yr as readPlutusData,
|
|
3920
4019
|
xr as readTransaction,
|
|
@@ -3923,15 +4022,15 @@ export {
|
|
|
3923
4022
|
Js as resolveFingerprint,
|
|
3924
4023
|
hr as resolveLanguageView,
|
|
3925
4024
|
lr as resolveNativeScriptHash,
|
|
3926
|
-
|
|
4025
|
+
it as resolvePaymentKeyHash,
|
|
3927
4026
|
Ar as resolvePlutusScriptAddress,
|
|
3928
4027
|
gr as resolvePlutusScriptHash,
|
|
3929
4028
|
mr as resolvePoolId,
|
|
3930
4029
|
Ir as resolvePrivateKey,
|
|
3931
|
-
|
|
4030
|
+
Ut as resolveRewardAddress,
|
|
3932
4031
|
pr as resolveScriptRef,
|
|
3933
4032
|
fr as resolveSlotNo,
|
|
3934
|
-
|
|
4033
|
+
gt as resolveStakeKeyHash,
|
|
3935
4034
|
Le as resolveTxFees,
|
|
3936
4035
|
js as resolveTxHash
|
|
3937
4036
|
};
|