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