@otoplo/wallet-common 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,58 +1,60 @@
1
- import { AddressType as E, Networks as k, Address as b, CommonUtils as W, BufferUtils as y, HDPrivateKey as Z, GroupToken as O, GroupIdType as I, TransactionBuilder as Q, Transaction as B, UnitUtils as ee, Script as A, Opcode as v, Hash as U, ScriptOpcode as J, BNExtended as z, Output as xe, TxSigner as te, SighashType as se, ScriptFactory as Ne, OutputSighashType as ae, BufferWriter as Ee } from "libnexa-ts";
2
- import { ElectrumClient as Me, TransportScheme as L, ConnectionStatus as Be } from "@otoplo/electrum-client";
3
- import { mnemonicToSeedSync as _e, generateMnemonic as Ce, validateMnemonic as Pe } from "@scure/bip39";
4
- import Oe from "jszip";
5
- import { DAppProvider as Ue } from "wallet-comms-sdk";
6
- import { gcm as de } from "@noble/ciphers/aes.js";
7
- import { argon2idAsync as De } from "@noble/hashes/argon2.js";
8
- import { wordlist as ue } from "@scure/bip39/wordlists/english.js";
9
- import { createSlice as M, createAsyncThunk as Ve, createSelector as j } from "@reduxjs/toolkit";
10
- import { useSelector as Re } from "react-redux";
11
- const g = -1, ne = 9223372036854775807n, He = 274710, It = "0014461ad25081cb0119d034385ff154c8d3ad6bdd76";
1
+ import { AddressType as E, Networks as k, Address as b, CommonUtils as W, BufferUtils as m, HDPrivateKey as Z, GroupToken as O, GroupIdType as I, TransactionBuilder as Q, Transaction as B, UnitUtils as ee, Script as A, Opcode as v, Hash as U, ScriptOpcode as J, BNExtended as z, Output as Me, TxSigner as te, SighashType as se, ScriptFactory as Be, OutputSighashType as ae, BufferWriter as _e } from "libnexa-ts";
2
+ import { ElectrumClient as Ce, TransportScheme as L, ConnectionStatus as Pe } from "@otoplo/electrum-client";
3
+ import { mnemonicToSeedSync as Oe, generateMnemonic as Ue, validateMnemonic as De } from "@scure/bip39";
4
+ import Ve from "jszip";
5
+ import { DAppProvider as Re } from "wallet-comms-sdk";
6
+ import { gcm as he } from "@noble/ciphers/aes.js";
7
+ import { argon2idAsync as ne } from "@noble/hashes/argon2.js";
8
+ import { pbkdf2Async as re } from "@noble/hashes/pbkdf2.js";
9
+ import { sha256 as ie } from "@noble/hashes/sha2.js";
10
+ import { wordlist as fe } from "@scure/bip39/wordlists/english.js";
11
+ import { createSlice as M, createAsyncThunk as He, createSelector as j } from "@reduxjs/toolkit";
12
+ import { useSelector as Ke } from "react-redux";
13
+ const g = -1, oe = 9223372036854775807n, Le = 274710, Mt = "0014461ad25081cb0119d034385ff154c8d3ad6bdd76";
12
14
  function T() {
13
15
  return k.defaultNetwork == k.testnet;
14
16
  }
15
- function xt(a) {
17
+ function Bt(a) {
16
18
  return T() ? a == "508c843a4b98fb25f57cf9ebafb245a5c16468f06519cdd467059a91e7b79d52" : a == "edc7144fe1ba4edd0edf35d7eea90f6cb1dba42314aa85da8207e97c5339c801";
17
19
  }
18
20
  function F(a, e = E.PayToScriptTemplate) {
19
21
  return b.isValid(a, k.defaultNetwork, e);
20
22
  }
21
- function Nt() {
23
+ function _t() {
22
24
  return `https://${T() ? "testnet-" : ""}explorer.nexa.org`;
23
25
  }
24
26
  function $() {
25
27
  return Math.floor(Date.now() / 1e3);
26
28
  }
27
- function Et(a, e) {
29
+ function Ct(a, e) {
28
30
  const t = (e - a) * 2, s = /* @__PURE__ */ new Date();
29
31
  return s.setMinutes(s.getMinutes() + t), s.toLocaleDateString();
30
32
  }
31
33
  function C(a) {
32
34
  return !a || a.length === 0;
33
35
  }
34
- function Mt(a, e = 0) {
36
+ function Pt(a, e = 0) {
35
37
  if (!a || a.length <= e)
36
38
  return a || "";
37
- const t = "...", s = Math.floor((e - t.length) / 2), n = a.slice(0, s), i = a.slice(a.length - s);
38
- return n + t + i;
39
+ const t = "...", s = Math.floor((e - t.length) / 2), n = a.slice(0, s), r = a.slice(a.length - s);
40
+ return n + t + r;
39
41
  }
40
- function Bt(a) {
42
+ function Ot(a) {
41
43
  return a.length === 0 ? "" : a.charAt(0).toUpperCase() + a.substring(1);
42
44
  }
43
45
  function R(a) {
44
- return W.isHexa(a) ? y.hexToBuffer(a) : b.fromString(a).data;
46
+ return W.isHexa(a) ? m.hexToBuffer(a) : b.fromString(a).data;
45
47
  }
46
48
  function S(a) {
47
- return W.isHexa(a) ? a : y.bufferToHex(R(a));
49
+ return W.isHexa(a) ? a : m.bufferToHex(R(a));
48
50
  }
49
- function ie(a) {
51
+ function ce(a) {
50
52
  return W.isHexa(a) ? new b(R(a), k.defaultNetwork, E.GroupIdAddress).toString() : a;
51
53
  }
52
54
  function D(a) {
53
55
  return a == null || a === "" ? "" : BigInt(a) <= 0n ? "0" : a.toString();
54
56
  }
55
- function re(a) {
57
+ function de(a) {
56
58
  let e = BigInt(0), t = BigInt(0);
57
59
  return a.forEach((s) => {
58
60
  e += BigInt(s.confirmed), t += BigInt(s.unconfirmed);
@@ -65,7 +67,7 @@ function G(a) {
65
67
  e[s] ? (e[s].confirmed = (BigInt(e[s].confirmed) + BigInt(t[s].confirmed)).toString(), e[s].unconfirmed = (BigInt(e[s].unconfirmed) + BigInt(t[s].unconfirmed)).toString()) : e[s] = { confirmed: BigInt(t[s].confirmed).toString(), unconfirmed: BigInt(t[s].unconfirmed).toString() };
66
68
  }), e;
67
69
  }
68
- const le = {
70
+ const pe = {
69
71
  // Images
70
72
  //'.svg': { media: 'image', mime: 'image/svg+xml' },
71
73
  ".gif": { media: "image", mime: "image/gif" },
@@ -88,19 +90,19 @@ const le = {
88
90
  ".wav": { media: "audio", mime: "audio/wav" },
89
91
  ".m4a": { media: "audio", mime: "audio/mp4" }
90
92
  };
91
- function _t(a) {
93
+ function Ut(a) {
92
94
  const e = a.lastIndexOf(".");
93
95
  if (e === -1) return "unknown";
94
96
  const t = a.slice(e).toLowerCase();
95
- return le[t]?.media ?? "unknown";
97
+ return pe[t]?.media ?? "unknown";
96
98
  }
97
- function Ct(a) {
99
+ function Dt(a) {
98
100
  const e = a.lastIndexOf(".");
99
101
  if (e === -1) return "application/octet-stream";
100
102
  const t = a.slice(e).toLowerCase();
101
- return le[t]?.mime ?? "application/octet-stream";
103
+ return pe[t]?.mime ?? "application/octet-stream";
102
104
  }
103
- class Pt {
105
+ class Vt {
104
106
  getPrefix() {
105
107
  return T() ? "testnet-" : "";
106
108
  }
@@ -185,8 +187,8 @@ class Pt {
185
187
  await this.setValue("auto-lock", `${e}`);
186
188
  }
187
189
  }
188
- var f = /* @__PURE__ */ ((a) => (a[a.MAIN = 0] = "MAIN", a[a.VAULT = 1] = "VAULT", a[a.DAPP = 2] = "DAPP", a))(f || {}), m = /* @__PURE__ */ ((a) => (a[a.RECEIVE = 0] = "RECEIVE", a[a.CHANGE = 1] = "CHANGE", a))(m || {}), _ = /* @__PURE__ */ ((a) => (a.SignMessage = "signMessage", a.AddToken = "addToken", a.SignTransaction = "signTransaction", a.SendTransaction = "sendTransaction", a))(_ || {}), V = /* @__PURE__ */ ((a) => (a.TOKEN = "token", a.NFT = "nft", a))(V || {});
189
- class Ot {
190
+ var f = /* @__PURE__ */ ((a) => (a[a.MAIN = 0] = "MAIN", a[a.VAULT = 1] = "VAULT", a[a.DAPP = 2] = "DAPP", a))(f || {}), y = /* @__PURE__ */ ((a) => (a[a.RECEIVE = 0] = "RECEIVE", a[a.CHANGE = 1] = "CHANGE", a))(y || {}), _ = /* @__PURE__ */ ((a) => (a.SignMessage = "signMessage", a.AddToken = "addToken", a.SignTransaction = "signTransaction", a.SendTransaction = "sendTransaction", a))(_ || {}), V = /* @__PURE__ */ ((a) => (a.TOKEN = "token", a.NFT = "nft", a))(V || {});
191
+ class Rt {
190
192
  store;
191
193
  updateCallback;
192
194
  constructor(e) {
@@ -360,7 +362,7 @@ class Ot {
360
362
  return this.store.upsertVault(t);
361
363
  }
362
364
  }
363
- class Ut {
365
+ class Ht {
364
366
  walletDb;
365
367
  tokens = /* @__PURE__ */ new Map();
366
368
  nfts = /* @__PURE__ */ new Map();
@@ -389,7 +391,7 @@ class Ut {
389
391
  this.nfts.delete(S(e));
390
392
  }
391
393
  }
392
- class he {
394
+ class ge {
393
395
  kvStore;
394
396
  client;
395
397
  constructor(e) {
@@ -465,7 +467,7 @@ class he {
465
467
  }
466
468
  async connect(e) {
467
469
  try {
468
- e || (e = await this.getCurrentInstance()), this.client = new Me("com.otoplo.wallet", "1.4.3", e.host, e.port, e.scheme, 45 * 1e3, 10 * 1e3), await this.client.connect();
470
+ e || (e = await this.getCurrentInstance()), this.client = new Ce("com.otoplo.wallet", "1.4.3", e.host, e.port, e.scheme, 45 * 1e3, 10 * 1e3), await this.client.connect();
469
471
  } catch (t) {
470
472
  throw t instanceof Error ? console.info(t.message) : console.error(t), t;
471
473
  }
@@ -487,19 +489,19 @@ class he {
487
489
  waitForConnection(e = 5e3) {
488
490
  const t = Date.now();
489
491
  return new Promise((s, n) => {
490
- const i = () => {
491
- if (this.client?.connectionStatus == Be.CONNECTED)
492
+ const r = () => {
493
+ if (this.client?.connectionStatus == Pe.CONNECTED)
492
494
  return s();
493
495
  if (Date.now() - t > e)
494
496
  return n(new Error("Rostrum Connection timeout"));
495
- setTimeout(i, 250);
497
+ setTimeout(r, 250);
496
498
  };
497
- i();
499
+ r();
498
500
  });
499
501
  }
500
502
  async getCurrentInstance() {
501
503
  const e = await this.kvStore.getRostrumParams();
502
- return e || he.getPredefinedInstances()[0];
504
+ return e || ge.getPredefinedInstances()[0];
503
505
  }
504
506
  static getPredefinedInstances() {
505
507
  return T() ? [
@@ -528,7 +530,7 @@ class he {
528
530
  function x(a, e, t) {
529
531
  return `${a}'/${e}/${t}`;
530
532
  }
531
- function Ke(a) {
533
+ function Fe(a) {
532
534
  const e = a.split("/");
533
535
  return {
534
536
  account: parseInt(e[0].replace("'", "")),
@@ -536,13 +538,13 @@ function Ke(a) {
536
538
  index: parseInt(e[2])
537
539
  };
538
540
  }
539
- class Dt {
541
+ class Kt {
540
542
  seed;
541
543
  masterKey;
542
544
  accountKeys = /* @__PURE__ */ new Map();
543
545
  walletKeys = /* @__PURE__ */ new Map();
544
546
  init(e) {
545
- this.seed = typeof e == "string" ? _e(e) : e, this.masterKey = Z.fromSeed(this.seed).deriveChild(44, !0).deriveChild(29223, !0);
547
+ this.seed = typeof e == "string" ? Oe(e) : e, this.masterKey = Z.fromSeed(this.seed).deriveChild(44, !0).deriveChild(29223, !0);
546
548
  }
547
549
  reset() {
548
550
  if (!this.seed)
@@ -557,13 +559,13 @@ class Dt {
557
559
  const t = typeof e == "string" ? e : x(e.account, e.type, e.index);
558
560
  let s = this.walletKeys.get(t);
559
561
  if (!s) {
560
- const { account: n, type: i, index: o } = typeof e == "string" ? Ke(e) : e;
561
- s = this.getAccountKey(n).deriveChild(i, !1).deriveChild(o, !1), this.walletKeys.set(t, s);
562
+ const { account: n, type: r, index: o } = typeof e == "string" ? Fe(e) : e;
563
+ s = this.getAccountKey(n).deriveChild(r, !1).deriveChild(o, !1), this.walletKeys.set(t, s);
562
564
  }
563
565
  return s;
564
566
  }
565
567
  }
566
- function fe() {
568
+ function me() {
567
569
  return {
568
570
  name: "NiftyArt",
569
571
  ticker: "NIFTY",
@@ -574,33 +576,33 @@ function fe() {
574
576
  decimals: 0
575
577
  };
576
578
  }
577
- function Vt(a) {
578
- return Y(Ge() + a, "raw");
579
+ function Lt(a) {
580
+ return Y(Je() + a, "raw");
579
581
  }
580
582
  function q(a) {
581
583
  try {
582
584
  const e = R(a);
583
- return O.isSubgroup(e) ? y.bufferToHex(e.subarray(0, 32)) === fe().tokenIdHex : !1;
585
+ return O.isSubgroup(e) ? m.bufferToHex(e.subarray(0, 32)) === me().tokenIdHex : !1;
584
586
  } catch {
585
587
  return !1;
586
588
  }
587
589
  }
588
- function Le(a) {
590
+ function Ge(a) {
589
591
  return a = X(a), Y(a, "json");
590
592
  }
591
- function Fe(a) {
593
+ function qe(a) {
592
594
  return a = X(a), Y(a, "raw");
593
595
  }
594
- function oe(a, e) {
596
+ function ue(a, e) {
595
597
  return a && typeof a == "string" ? a.startsWith("http") ? a.replace("http://", "https://") : a.startsWith("ipfs://") ? a : `${new URL(e).origin}${a}` : "";
596
598
  }
597
- function Rt(a) {
599
+ function Ft(a) {
598
600
  return a ? X(a) : null;
599
601
  }
600
602
  function X(a, e = "https://ipfs.nebula.markets/") {
601
603
  return a?.startsWith("ipfs://") ? e + a.substring(7) : a;
602
604
  }
603
- function Ge() {
605
+ function Je() {
604
606
  return `https://${T() ? "testnet." : ""}niftyart.cash/_public/`;
605
607
  }
606
608
  async function Y(a, e) {
@@ -617,7 +619,7 @@ async function Y(a, e) {
617
619
  throw new Error(`Unexpected Error: ${t}`);
618
620
  }
619
621
  }
620
- class Ht {
622
+ class Gt {
621
623
  walletDb;
622
624
  rostrumService;
623
625
  walletCache;
@@ -631,21 +633,21 @@ class Ht {
631
633
  if (c)
632
634
  return c;
633
635
  }
634
- const s = await this.rostrumService.getTokenGenesis(e), n = y.hexToBuffer(s.token_id_hex);
635
- let i = "", o = "";
636
+ const s = await this.rostrumService.getTokenGenesis(e), n = m.hexToBuffer(s.token_id_hex);
637
+ let r = "", o = "";
636
638
  if (s.op_return_id == I.NRC2 || s.op_return_id == I.NRC3 || q(e))
637
639
  return;
638
- if (O.isSubgroup(n) && (i = new b(O.getParentGroupId(n), k.defaultNetwork, E.GroupIdAddress).toString()), s.document_url)
640
+ if (O.isSubgroup(n) && (r = new b(O.getParentGroupId(n), k.defaultNetwork, E.GroupIdAddress).toString()), s.document_url)
639
641
  try {
640
642
  if (s.op_return_id == I.NRC1) {
641
- const c = await Fe(s.document_url), u = (await Oe.loadAsync(c)).file("info.json");
643
+ const c = await qe(s.document_url), u = (await Ve.loadAsync(c)).file("info.json");
642
644
  if (u) {
643
645
  const l = await u.async("string"), h = JSON.parse(l);
644
- o = oe(h[0]?.icon, s.document_url);
646
+ o = ue(h[0]?.icon, s.document_url);
645
647
  }
646
648
  } else {
647
- const c = await Le(s.document_url);
648
- o = oe(c[0]?.icon, s.document_url);
649
+ const c = await Ge(s.document_url);
650
+ o = ue(c[0]?.icon, s.document_url);
649
651
  }
650
652
  } catch (c) {
651
653
  console.error("Failed to load metadata", c);
@@ -654,7 +656,7 @@ class Ht {
654
656
  token: s.group,
655
657
  tokenIdHex: s.token_id_hex,
656
658
  decimals: s.decimal_places ?? 0,
657
- parentGroup: i,
659
+ parentGroup: r,
658
660
  name: s.name ?? "",
659
661
  ticker: s.ticker ?? "",
660
662
  iconUrl: o
@@ -676,7 +678,7 @@ class Ht {
676
678
  async getAssetInfo(e) {
677
679
  let t = await this.getTokenInfo(e);
678
680
  return t || await this.isNftToken(e) && (t = {
679
- token: ie(e),
681
+ token: ce(e),
680
682
  tokenIdHex: S(e),
681
683
  decimals: 0
682
684
  }), t;
@@ -692,33 +694,33 @@ class Ht {
692
694
  await this.walletDb.saveAsset(o, !0);
693
695
  return;
694
696
  }
695
- const i = await this.rostrumService.getTokenGenesis(t);
696
- if (i.op_return_id == I.NRC3) {
697
+ const r = await this.rostrumService.getTokenGenesis(t);
698
+ if (r.op_return_id == I.NRC3) {
697
699
  const o = R(t);
698
700
  if (O.isSubgroup(o)) {
699
- const r = new b(o.subarray(0, 32), k.defaultNetwork, E.GroupIdAddress).toString(), c = await this.rostrumService.getTokenGenesis(r);
700
- c?.op_return_id == I.NRC2 && await this.saveNft(e, t, i.document_url ?? "", r, s, c?.name ?? "");
701
+ const i = new b(o.subarray(0, 32), k.defaultNetwork, E.GroupIdAddress).toString(), c = await this.rostrumService.getTokenGenesis(i);
702
+ c?.op_return_id == I.NRC2 && await this.saveNft(e, t, r.document_url ?? "", i, s, c?.name ?? "");
701
703
  }
702
- } else q(t) && await this.saveNft(e, t, "nifty", fe().token, s, "");
704
+ } else q(t) && await this.saveNft(e, t, "nifty", me().token, s, "");
703
705
  }
704
- async saveNft(e, t, s, n, i, o) {
706
+ async saveNft(e, t, s, n, r, o) {
705
707
  if (s)
706
708
  try {
707
- const r = {
709
+ const i = {
708
710
  accountId: e,
709
711
  tokenIdHex: t,
710
712
  type: V.NFT,
711
- addedTime: i
713
+ addedTime: r
712
714
  }, c = {
713
715
  parentGroup: n,
714
- token: ie(t),
716
+ token: ce(t),
715
717
  tokenIdHex: t,
716
718
  source: s,
717
719
  collection: o
718
720
  };
719
- await this.walletDb.saveNft(r, c);
720
- } catch (r) {
721
- console.error("failed to save NFT", r);
721
+ await this.walletDb.saveNft(i, c);
722
+ } catch (i) {
723
+ console.error("failed to save NFT", i);
722
724
  }
723
725
  }
724
726
  async fetchAndSaveTokens(e, t) {
@@ -728,18 +730,18 @@ class Ht {
728
730
  }
729
731
  }
730
732
  async syncNfts(e, t) {
731
- const s = Object.keys(t), n = await this.walletDb.getLocalNfts(e, 1, 1e3), i = async (r) => {
732
- await this.walletDb.deleteNft(e, r, !0), this.walletCache.removeNft(r);
733
- }, o = n?.filter((r) => !s.includes(r.tokenIdHex)) ?? [];
734
- for (const r of o)
735
- await i(r.tokenIdHex);
736
- for (const [r, c] of Object.entries(t)) {
737
- const d = S(r), u = c && BigInt(c.confirmed) + BigInt(c.unconfirmed) > 0n, l = n?.some((p) => p.tokenIdHex == d);
738
- !u && !l || u && l || !await this.isNftToken(d) || (!u && l ? await i(d) : await this.handleNftReceive(e, d, $()));
733
+ const s = Object.keys(t), n = await this.walletDb.getLocalNfts(e, 1, 1e3), r = async (i) => {
734
+ await this.walletDb.deleteNft(e, i, !0), this.walletCache.removeNft(i);
735
+ }, o = n?.filter((i) => !s.includes(i.tokenIdHex)) ?? [];
736
+ for (const i of o)
737
+ await r(i.tokenIdHex);
738
+ for (const [i, c] of Object.entries(t)) {
739
+ const d = S(i), u = c && BigInt(c.confirmed) + BigInt(c.unconfirmed) > 0n, l = n?.some((p) => p.tokenIdHex == d);
740
+ !u && !l || u && l || !await this.isNftToken(d) || (!u && l ? await r(d) : await this.handleNftReceive(e, d, $()));
739
741
  }
740
742
  }
741
743
  }
742
- class Kt {
744
+ class qt {
743
745
  rostrumService;
744
746
  keyManager;
745
747
  walletDb;
@@ -752,40 +754,40 @@ class Kt {
752
754
  }
753
755
  async fetchTransactionsHistory(e, t) {
754
756
  let s = t;
755
- const n = t > 0 ? t + 1 : 0, i = await this.rostrumService.getTransactionsHistory(e, n);
756
- for (const o of i)
757
+ const n = t > 0 ? t + 1 : 0, r = await this.rostrumService.getTransactionsHistory(e, n);
758
+ for (const o of r)
757
759
  s = Math.max(s, o.height);
758
- return { txs: i, lastHeight: s };
760
+ return { txs: r, lastHeight: s };
759
761
  }
760
762
  async fetchVaultTransactions(e) {
761
- const t = await this.rostrumService.getTransactionsHistory(e, He), s = [];
763
+ const t = await this.rostrumService.getTransactionsHistory(e, Le), s = [];
762
764
  for (const n of t) {
763
- const i = this.classifyTransaction(n.tx_hash, [e]);
764
- s.push(i);
765
+ const r = this.classifyTransaction(n.tx_hash, [e]);
766
+ s.push(r);
765
767
  }
766
768
  return Promise.all(s);
767
769
  }
768
770
  async classifyAndSaveTransaction(e, t, s) {
769
771
  const n = await this.classifyTransaction(t, s);
770
772
  n.accountId = e;
771
- const i = {
773
+ const r = {
772
774
  ...n,
773
775
  othersOutputs: JSON.stringify(n.othersOutputs),
774
776
  myOutputs: JSON.stringify(n.myOutputs),
775
777
  myInputs: JSON.stringify(n.myInputs)
776
778
  }, o = /* @__PURE__ */ new Set();
777
- n.myInputs.forEach((r) => r.assetId && o.add(r.assetId)), n.myOutputs.forEach((r) => r.assetId && o.add(r.assetId));
778
- for (const r of o)
779
+ n.myInputs.forEach((i) => i.assetId && o.add(i.assetId)), n.myOutputs.forEach((i) => i.assetId && o.add(i.assetId));
780
+ for (const i of o)
779
781
  await this.walletDb.addAssetTransaction({
780
782
  accountId: e,
781
- assetId: r,
783
+ assetId: i,
782
784
  txIdem: n.txIdem,
783
785
  time: n.time
784
786
  });
785
- await this.walletDb.addLocalTransaction(i);
787
+ await this.walletDb.addLocalTransaction(r);
786
788
  }
787
789
  async classifyTransaction(e, t) {
788
- const s = await this.rostrumService.getTransaction(e), n = [], i = [], o = [], r = [];
790
+ const s = await this.rostrumService.getTransaction(e), n = [], r = [], o = [], i = [];
789
791
  for (const l of s.vin) {
790
792
  const h = {
791
793
  address: l.addresses[0],
@@ -793,7 +795,7 @@ class Kt {
793
795
  assetId: l.token_id_hex ?? "",
794
796
  assetAmount: D(l.groupQuantity)
795
797
  };
796
- t.includes(h.address) ? n.push(h) : i.push(h);
798
+ t.includes(h.address) ? n.push(h) : r.push(h);
797
799
  }
798
800
  for (const l of s.vout) {
799
801
  if (C(l.scriptPubKey.addresses)) continue;
@@ -803,10 +805,10 @@ class Kt {
803
805
  assetId: l.scriptPubKey.token_id_hex ?? "",
804
806
  assetAmount: D(l.scriptPubKey.groupQuantity)
805
807
  };
806
- t.includes(h.address) ? o.push(h) : r.push(h);
808
+ t.includes(h.address) ? o.push(h) : i.push(h);
807
809
  }
808
810
  let c;
809
- n.length === 0 ? c = "receive" : o.length === 0 ? c = "send" : i.length === 0 && r.length === 0 ? c = "self" : i.length === 0 && r.length > 0 ? c = "send" : i.length > 0 && r.length === 0 ? c = "receive" : c = "swap";
811
+ n.length === 0 ? c = "receive" : o.length === 0 ? c = "send" : r.length === 0 && i.length === 0 ? c = "self" : r.length === 0 && i.length > 0 ? c = "send" : r.length > 0 && i.length === 0 ? c = "receive" : c = "swap";
810
812
  const d = s.height > 0;
811
813
  return {
812
814
  accountId: 0,
@@ -817,16 +819,16 @@ class Kt {
817
819
  height: d ? s.height : 0,
818
820
  type: c,
819
821
  fee: s.fee_satoshi.toString(),
820
- othersOutputs: c == "send" || c == "swap" ? r : [],
822
+ othersOutputs: c == "send" || c == "swap" ? i : [],
821
823
  myOutputs: o,
822
824
  myInputs: n
823
825
  };
824
826
  }
825
- async buildAndSignTransferTransaction(e, t, s, n, i, o, r, c) {
827
+ async buildAndSignTransferTransaction(e, t, s, n, r, o, i, c) {
826
828
  const d = {
827
- feeFromAmount: i
829
+ feeFromAmount: r
828
830
  }, u = this.prepareTransaction(t, n, o, c);
829
- r && u.feePerByte(r);
831
+ i && u.feePerByte(i);
830
832
  let l = /* @__PURE__ */ new Map();
831
833
  o && (l = await this.populateTokenInputsAndChange(u, e, s, o, BigInt(n)));
832
834
  const h = await this.populateNexaInputsAndChange(u, e, s, d);
@@ -836,33 +838,33 @@ class Kt {
836
838
  const n = {
837
839
  isConsolidate: !0,
838
840
  templateData: s
839
- }, i = new Q(), o = await this.populateNexaInputsAndChange(i, e, t, n);
840
- return this.finalizeTransaction(i, Array.from(o.values()));
841
+ }, r = new Q(), o = await this.populateNexaInputsAndChange(r, e, t, n);
842
+ return this.finalizeTransaction(r, Array.from(o.values()));
841
843
  }
842
844
  prepareTransaction(e, t, s, n) {
843
845
  if (!F(e) && !F(e, E.PayToPublicKeyHash))
844
846
  throw new Error("Invalid Address.");
845
847
  if (s && BigInt(t) < 1n || !s && parseInt(t) < B.DUST_AMOUNT)
846
848
  throw new Error("The amount is too low.");
847
- if (s && BigInt(t) > ne || !s && parseInt(t) > B.MAX_MONEY)
849
+ if (s && BigInt(t) > oe || !s && parseInt(t) > B.MAX_MONEY)
848
850
  throw new Error("The amount is too high.");
849
- const i = new Q();
850
- if (n && i.addData(n), s) {
851
+ const r = new Q();
852
+ if (n && r.addData(n), s) {
851
853
  if (!F(s, E.GroupIdAddress))
852
854
  throw new Error("Invalid Token ID");
853
855
  if (b.getOutputType(e) === 0)
854
856
  throw new Error("Token must be sent to script template address");
855
- i.to(e, B.DUST_AMOUNT, s, BigInt(t));
857
+ r.to(e, B.DUST_AMOUNT, s, BigInt(t));
856
858
  } else
857
- i.to(e, t);
858
- return i;
859
+ r.to(e, t);
860
+ return r;
859
861
  }
860
862
  async populateNexaInputsAndChange(e, t, s, n) {
861
- const i = t.filter((d) => BigInt(d.balance.confirmed) + BigInt(d.balance.unconfirmed) > 0n);
862
- if (C(i))
863
+ const r = t.filter((d) => BigInt(d.balance.confirmed) + BigInt(d.balance.unconfirmed) > 0n);
864
+ if (C(r))
863
865
  throw new Error("Not enough Nexa balance.");
864
- const o = /* @__PURE__ */ new Map(), r = n.isConsolidate ? 0 : Number(e.transaction.outputs.find((d) => d.value > 0n).value);
865
- for (const d of i) {
866
+ const o = /* @__PURE__ */ new Map(), i = n.isConsolidate ? 0 : Number(e.transaction.outputs.find((d) => d.value > 0n).value);
867
+ for (const d of r) {
866
868
  const u = await this.rostrumService.getNexaUtxos(d.address);
867
869
  for (const l of u) {
868
870
  const h = {
@@ -887,12 +889,12 @@ class Kt {
887
889
  continue;
888
890
  if (P == 0n && n.feeFromAmount) {
889
891
  const H = p.estimateRequiredFee();
890
- return p.updateOutputAmount(0, r - H), o;
892
+ return p.updateOutputAmount(0, i - H), o;
891
893
  }
892
894
  if (e.change(s), n.feeFromAmount) {
893
895
  const H = p.getChangeOutput();
894
896
  let K = p.estimateRequiredFee();
895
- p.updateOutputAmount(0, r - K), !H && p.getChangeOutput() && (K = p.estimateRequiredFee(), p.updateOutputAmount(0, r - K));
897
+ p.updateOutputAmount(0, i - K), !H && p.getChangeOutput() && (K = p.estimateRequiredFee(), p.updateOutputAmount(0, i - K));
896
898
  }
897
899
  if (p.getUnspentValue() < p.estimateRequiredFee())
898
900
  continue;
@@ -912,13 +914,13 @@ class Kt {
912
914
  };
913
915
  throw new Error(JSON.stringify(c));
914
916
  }
915
- async populateTokenInputsAndChange(e, t, s, n, i) {
916
- const o = S(n), r = t.filter((u) => Object.keys(u.tokensBalance).includes(o));
917
- if (C(r))
917
+ async populateTokenInputsAndChange(e, t, s, n, r) {
918
+ const o = S(n), i = t.filter((u) => Object.keys(u.tokensBalance).includes(o));
919
+ if (C(i))
918
920
  throw new Error("Not enough token balance.");
919
921
  const c = /* @__PURE__ */ new Map();
920
922
  let d = 0n;
921
- for (const u of r) {
923
+ for (const u of i) {
922
924
  const l = await this.rostrumService.getTokenUtxos(u.address, n);
923
925
  for (const h of l)
924
926
  if (!(BigInt(h.token_amount) < 0n)) {
@@ -932,14 +934,14 @@ class Kt {
932
934
  const p = this.keyManager.getKey(u.keyPath);
933
935
  c.set(u.address, p.privateKey);
934
936
  }
935
- if (d > ne)
937
+ if (d > oe)
936
938
  throw new Error("Token inputs exceeded max amount. Consider sending in small chunks");
937
939
  if (e.transaction.inputs.length > this.MAX_INPUTS_OUTPUTS)
938
940
  throw new Error("Too many inputs. Consider consolidating transactions or reduce the send amount.");
939
- if (d == i)
941
+ if (d == r)
940
942
  return c;
941
- if (d > i)
942
- return e.to(s, B.DUST_AMOUNT, n, d - i), c;
943
+ if (d > r)
944
+ return e.to(s, B.DUST_AMOUNT, n, d - r), c;
943
945
  }
944
946
  }
945
947
  throw new Error("Not enough token balance");
@@ -958,29 +960,36 @@ class Kt {
958
960
  return JSON.stringify(t, null, 2);
959
961
  }
960
962
  }
961
- function Lt(a = 12) {
962
- return Ce(ue, a === 24 ? 256 : 128);
963
+ function Jt(a = 12) {
964
+ return Ue(fe, a === 24 ? 256 : 128);
963
965
  }
964
- function qe(a) {
965
- return Pe(a, ue);
966
+ function ze(a) {
967
+ return De(a, fe);
966
968
  }
967
- async function pe(a, e) {
968
- const t = performance.now(), s = await De(a, e, { t: 2, m: 19456, p: 1, dkLen: 32 });
969
- return console.log(performance.now() - t), s;
969
+ async function ye(a, e) {
970
+ let t = performance.now();
971
+ const s = await ne(a, e, { t: 2, m: 19456, p: 1, dkLen: 32 });
972
+ console.log(performance.now() - t);
973
+ let n = performance.now();
974
+ await re(ie, a, e, { c: 21e4, dkLen: 32 }), console.log(performance.now() - n);
975
+ let r = performance.now();
976
+ await re(ie, a, e, { c: 1e5, dkLen: 32 }), console.log(performance.now() - r);
977
+ let o = performance.now();
978
+ return await ne(a, e, { t: 4, m: 9216, p: 1, dkLen: 32 }), console.log(performance.now() - o), s;
970
979
  }
971
- async function Ft(a, e) {
972
- const t = y.getRandomBuffer(16), s = y.getRandomBuffer(12), n = y.utf8ToBuffer(a), i = await pe(e, t), o = de(i, s).encrypt(n), r = y.concat([t, s, o]);
973
- return y.bufferToBase64(r);
980
+ async function zt(a, e) {
981
+ const t = m.getRandomBuffer(16), s = m.getRandomBuffer(12), n = m.utf8ToBuffer(a), r = await ye(e, t), o = he(r, s).encrypt(n), i = m.concat([t, s, o]);
982
+ return m.bufferToBase64(i);
974
983
  }
975
- async function Je(a, e) {
976
- const t = y.base64ToBuffer(a), s = t.subarray(0, 16), n = t.subarray(16, 28), i = t.subarray(28), o = await pe(e, s), r = de(o, n).decrypt(i);
977
- return y.bufferToUtf8(r);
984
+ async function We(a, e) {
985
+ const t = m.base64ToBuffer(a), s = t.subarray(0, 16), n = t.subarray(16, 28), r = t.subarray(28), o = await ye(e, s), i = he(o, n).decrypt(r);
986
+ return m.bufferToUtf8(i);
978
987
  }
979
- async function Gt(a, e) {
988
+ async function Wt(a, e) {
980
989
  try {
981
990
  if (a) {
982
- const t = await Je(a, e);
983
- if (t && qe(t))
991
+ const t = await We(a, e);
992
+ if (t && ze(t))
984
993
  return t;
985
994
  }
986
995
  return !1;
@@ -988,7 +997,7 @@ async function Gt(a, e) {
988
997
  return !1;
989
998
  }
990
999
  }
991
- const ge = {
1000
+ const we = {
992
1001
  usd: "$",
993
1002
  eur: "€",
994
1003
  gbp: "£",
@@ -997,46 +1006,46 @@ const ge = {
997
1006
  aud: "A$",
998
1007
  cad: "C$",
999
1008
  chf: "Fr"
1000
- }, ye = Object.keys(ge);
1001
- async function ze() {
1002
- const a = ye.join(","), e = await fetch(`https://api.coingecko.com/api/v3/simple/price?ids=nexacoin&include_24hr_change=true&vs_currencies=${a}`);
1009
+ }, ve = Object.keys(we);
1010
+ async function je() {
1011
+ const a = ve.join(","), e = await fetch(`https://api.coingecko.com/api/v3/simple/price?ids=nexacoin&include_24hr_change=true&vs_currencies=${a}`);
1003
1012
  if (!e.ok)
1004
1013
  throw new Error("Failed to fetch price");
1005
1014
  return (await e.json()).nexacoin || {};
1006
1015
  }
1007
- function qt(a) {
1008
- return ge[a] || a;
1016
+ function jt(a) {
1017
+ return we[a] || a;
1009
1018
  }
1010
- function me() {
1019
+ function Ae() {
1011
1020
  const a = {};
1012
- return ye.forEach((e) => {
1021
+ return ve.forEach((e) => {
1013
1022
  a[e] = { value: 0, change: 0 };
1014
1023
  }), a;
1015
1024
  }
1016
- function We() {
1025
+ function $e() {
1017
1026
  return A.empty().add(v.OP_FROMALTSTACK).add(v.OP_DROP).add(v.OP_FROMALTSTACK).add(v.OP_CHECKLOCKTIMEVERIFY).add(v.OP_DROP).add(v.OP_FROMALTSTACK).add(v.OP_CHECKSIGVERIFY);
1018
1027
  }
1019
- function je() {
1020
- const a = We();
1028
+ function Xe() {
1029
+ const a = $e();
1021
1030
  return U.sha256ripemd160(a.toBuffer());
1022
1031
  }
1023
- function $e(a) {
1032
+ function Ye(a) {
1024
1033
  return A.empty().add(a.toBuffer());
1025
1034
  }
1026
- function Xe(a) {
1027
- const e = $e(a);
1035
+ function Ze(a) {
1036
+ const e = Ye(a);
1028
1037
  return U.sha256ripemd160(e.toBuffer());
1029
1038
  }
1030
- function Ye(a) {
1039
+ function Qe(a) {
1031
1040
  return a.map((e) => e <= 16 ? J.smallInt(e) : z.fromNumber(e).toScriptNumBuffer());
1032
1041
  }
1033
- function Ze(a, e) {
1042
+ function et(a, e) {
1034
1043
  if (e.length !== 2)
1035
1044
  return;
1036
- const t = je(), s = Xe(a), n = Ye(e);
1045
+ const t = Xe(), s = Ze(a), n = Qe(e);
1037
1046
  return b.fromScriptTemplate(t, s, n).toString();
1038
1047
  }
1039
- class Jt {
1048
+ class $t {
1040
1049
  walletDb;
1041
1050
  keyManager;
1042
1051
  providers;
@@ -1057,8 +1066,8 @@ class Jt {
1057
1066
  }
1058
1067
  add(e, t, s) {
1059
1068
  this.providers.has(e.id) || this.providers.set(e.id, /* @__PURE__ */ new Map());
1060
- const n = s.details.sessionId, i = this.providers.get(e.id);
1061
- this.registerHandlers(e, t, n), i.set(n, t), this.notify({ type: "session_added", accountId: e.id, sessionInfo: s });
1069
+ const n = s.details.sessionId, r = this.providers.get(e.id);
1070
+ this.registerHandlers(e, t, n), r.set(n, t), this.notify({ type: "session_added", accountId: e.id, sessionInfo: s });
1062
1071
  }
1063
1072
  remove(e, t) {
1064
1073
  const s = this.providers.get(e);
@@ -1072,12 +1081,12 @@ class Jt {
1072
1081
  for (const t of e.values()) {
1073
1082
  if (t.id == g)
1074
1083
  continue;
1075
- const s = await this.walletDb.getAccountSessions(t.id), n = this.providers.get(t.id), i = s.map(async (r) => {
1076
- if (n?.has(r.sessionId))
1084
+ const s = await this.walletDb.getAccountSessions(t.id), n = this.providers.get(t.id), r = s.map(async (i) => {
1085
+ if (n?.has(i.sessionId))
1077
1086
  return;
1078
1087
  let c;
1079
1088
  try {
1080
- c = new Ue(r.uri);
1089
+ c = new Re(i.uri);
1081
1090
  const d = c.getSessionInfo();
1082
1091
  await c.connect(3e3);
1083
1092
  const u = await c.getAppInfo(2e3);
@@ -1102,11 +1111,11 @@ class Jt {
1102
1111
  });
1103
1112
  return { account: t, provider: c, metadata: { details: d, appInfo: u } };
1104
1113
  } catch (d) {
1105
- console.error(`Failed to reload session ${r.sessionId}`, d), c?.disconnect(), await this.walletDb.removeSession(r.sessionId);
1114
+ console.error(`Failed to reload session ${i.sessionId}`, d), c?.disconnect(), await this.walletDb.removeSession(i.sessionId);
1106
1115
  }
1107
- }), o = await Promise.allSettled(i);
1108
- for (const r of o)
1109
- r.status === "fulfilled" && r.value && this.add(r.value.account, r.value.provider, r.value.metadata);
1116
+ }), o = await Promise.allSettled(r);
1117
+ for (const i of o)
1118
+ i.status === "fulfilled" && i.value && this.add(i.value.account, i.value.provider, i.value.metadata);
1110
1119
  }
1111
1120
  }
1112
1121
  clear() {
@@ -1132,23 +1141,23 @@ class Jt {
1132
1141
  async replayMessage(e, t, s) {
1133
1142
  const n = this.providers.get(e);
1134
1143
  if (n) {
1135
- const i = n.get(t);
1136
- i && await i.replayMessage(s);
1144
+ const r = n.get(t);
1145
+ r && await r.replayMessage(s);
1137
1146
  }
1138
1147
  }
1139
1148
  registerHandlers(e, t, s) {
1140
1149
  t.onSessionDelete(() => this.walletDb.removeSession(s)), t.onClose(() => {
1141
1150
  this.removeOnClose && this.remove(e.id, s);
1142
1151
  });
1143
- const n = (i, o) => new Promise((r, c) => {
1144
- this.handlers.set(i, { resolve: r, reject: c }), this.notify({ type: "new_request", request: { type: i, accountId: e.id, sessionId: s, request: o } });
1152
+ const n = (r, o) => new Promise((i, c) => {
1153
+ this.handlers.set(r, { resolve: i, reject: c }), this.notify({ type: "new_request", request: { type: r, accountId: e.id, sessionId: s, request: o } });
1145
1154
  });
1146
- t.onSignMessage((i) => n(_.SignMessage, i)), t.onAddToken((i) => n(_.AddToken, i)), t.onSendTransaction((i) => n(_.SendTransaction, i)), t.onSignTransaction((i) => n(_.SignTransaction, i)), t.onGetAccount(() => {
1147
- const i = { account: f.DAPP, type: m.RECEIVE, index: e.id };
1155
+ t.onSignMessage((r) => n(_.SignMessage, r)), t.onAddToken((r) => n(_.AddToken, r)), t.onSendTransaction((r) => n(_.SendTransaction, r)), t.onSignTransaction((r) => n(_.SignTransaction, r)), t.onGetAccount(() => {
1156
+ const r = { account: f.DAPP, type: y.RECEIVE, index: e.id };
1148
1157
  return {
1149
1158
  name: e.name,
1150
1159
  address: e.address,
1151
- pubkey: this.keyManager.getKey(i).publicKey.toString(),
1160
+ pubkey: this.keyManager.getKey(r).publicKey.toString(),
1152
1161
  blockchain: "nexa",
1153
1162
  network: k.defaultNetwork.name,
1154
1163
  capabilities: {
@@ -1161,7 +1170,7 @@ class Jt {
1161
1170
  });
1162
1171
  }
1163
1172
  }
1164
- class zt {
1173
+ class Xt {
1165
1174
  rostrumService;
1166
1175
  keyManager;
1167
1176
  assetService;
@@ -1202,17 +1211,17 @@ class zt {
1202
1211
  await Promise.all(t);
1203
1212
  }
1204
1213
  async processInput(e, t) {
1205
- const s = e.txDetails.tx.inputs[t], n = await this.rostrumService.getUtxo(y.bufferToHex(s.outpoint));
1214
+ const s = e.txDetails.tx.inputs[t], n = await this.rostrumService.getUtxo(m.bufferToHex(s.outpoint));
1206
1215
  if (n.status == "spent")
1207
1216
  throw new Error("Input UTXO is already spent.");
1208
- if (s.output = new xe(n.amount, n.scriptpubkey), s.output.address == e.address) {
1209
- const i = n.token_id_hex || "NEXA";
1217
+ if (s.output = new Me(n.amount, n.scriptpubkey), s.output.address == e.address) {
1218
+ const r = n.token_id_hex || "NEXA";
1210
1219
  e.myInputs.set(t, {
1211
1220
  address: e.address,
1212
1221
  nexaAmount: n.amount.toString(),
1213
- assetId: i,
1222
+ assetId: r,
1214
1223
  assetAmount: D(n.group_quantity) || n.amount.toString()
1215
- }), e.involvedAssets.add(i), s.scriptSig.isEmpty() && e.inputsToSign.add(t);
1224
+ }), e.involvedAssets.add(r), s.scriptSig.isEmpty() && e.inputsToSign.add(t);
1216
1225
  }
1217
1226
  s.scriptSig.findPlaceholder() > 0 && e.inputsToSign.add(t);
1218
1227
  }
@@ -1221,13 +1230,13 @@ class zt {
1221
1230
  const s = e.txDetails.tx.outputs[t].toObject();
1222
1231
  if (s.address !== e.address)
1223
1232
  continue;
1224
- const n = s.groupId ? S(s.groupId) : "NEXA", i = {
1233
+ const n = s.groupId ? S(s.groupId) : "NEXA", r = {
1225
1234
  address: s.address,
1226
1235
  nexaAmount: s.value.toString(),
1227
1236
  assetId: n,
1228
1237
  assetAmount: D(s.groupAmount) || s.value.toString()
1229
1238
  };
1230
- e.involvedAssets.add(n), e.myOutputs.set(t, i);
1239
+ e.involvedAssets.add(n), e.myOutputs.set(t, r);
1231
1240
  }
1232
1241
  }
1233
1242
  signInputs(e) {
@@ -1237,13 +1246,13 @@ class zt {
1237
1246
  const s = e.txDetails.tx.inputs[t], n = this.validateAndGetSubscript(s);
1238
1247
  if (s.scriptSig.isEmpty()) {
1239
1248
  e.allMyOutputsCovered = !0;
1240
- const i = te.sign(e.txDetails.tx, t, se.ALL, n, e.privateKey).toTxFormat(), o = A.empty().add(e.privateKey.publicKey.toBuffer());
1241
- s.scriptSig = Ne.buildScriptTemplateIn(void 0, o, A.empty().add(i));
1249
+ const r = te.sign(e.txDetails.tx, t, se.ALL, n, e.privateKey).toTxFormat(), o = A.empty().add(e.privateKey.publicKey.toBuffer());
1250
+ s.scriptSig = Be.buildScriptTemplateIn(void 0, o, A.empty().add(r));
1242
1251
  } else {
1243
- const i = s.scriptSig.findPlaceholder(), r = s.scriptSig.chunks[i].buf.subarray(64), c = se.fromBuffer(r);
1252
+ const r = s.scriptSig.findPlaceholder(), i = s.scriptSig.chunks[r].buf.subarray(64), c = se.fromBuffer(i);
1244
1253
  this.processSignatureCoverage(e, c);
1245
- const d = te.sign(e.txDetails.tx, t, c, n, e.privateKey).toTxFormat(r);
1246
- s.scriptSig.replaceChunk(i, A.empty().add(d));
1254
+ const d = te.sign(e.txDetails.tx, t, c, n, e.privateKey).toTxFormat(i);
1255
+ s.scriptSig.replaceChunk(r, A.empty().add(d));
1247
1256
  }
1248
1257
  }
1249
1258
  if (!e.allMyOutputsCovered)
@@ -1259,7 +1268,7 @@ class zt {
1259
1268
  if (!e.scriptSig.isScriptTemplateIn())
1260
1269
  throw new Error("Unsupported input script type.");
1261
1270
  const t = e.output.scriptPubKey.getTemplateHash(), s = e.scriptSig.chunks[0].buf;
1262
- if (y.equals(t, U.sha256ripemd160(s)) || y.equals(t, U.sha256sha256(s)))
1271
+ if (m.equals(t, U.sha256ripemd160(s)) || m.equals(t, U.sha256sha256(s)))
1263
1272
  return A.fromBuffer(s);
1264
1273
  throw new Error("Invalid input script template.");
1265
1274
  }
@@ -1287,68 +1296,68 @@ class zt {
1287
1296
  }
1288
1297
  async processAssetMovements(e) {
1289
1298
  const t = Array.from(e.myInputs.values()), s = Array.from(e.myOutputs.values()), n = [];
1290
- for (const i of e.involvedAssets) {
1291
- const o = this.processAssetMovement(e, i, t, s);
1299
+ for (const r of e.involvedAssets) {
1300
+ const o = this.processAssetMovement(e, r, t, s);
1292
1301
  n.push(o);
1293
1302
  }
1294
1303
  await Promise.all(n);
1295
1304
  }
1296
1305
  async processAssetMovement(e, t, s, n) {
1297
- const i = s.reduce((r, c) => c.assetId === t ? r + BigInt(c.assetAmount) : r, 0n), o = n.reduce((r, c) => c.assetId === t ? r + BigInt(c.assetAmount) : r, 0n);
1298
- if (i > 0n || o > 0n) {
1299
- const r = { amount: o - i };
1300
- t !== "NEXA" && (r.asset = await this.assetService.getAssetInfo(t)), r.amount > 0n ? e.txDetails.receive.push(r) : r.amount < 0n && e.txDetails.send.push(r);
1306
+ const r = s.reduce((i, c) => c.assetId === t ? i + BigInt(c.assetAmount) : i, 0n), o = n.reduce((i, c) => c.assetId === t ? i + BigInt(c.assetAmount) : i, 0n);
1307
+ if (r > 0n || o > 0n) {
1308
+ const i = { amount: o - r };
1309
+ t !== "NEXA" && (i.asset = await this.assetService.getAssetInfo(t)), i.amount > 0n ? e.txDetails.receive.push(i) : i.amount < 0n && e.txDetails.send.push(i);
1301
1310
  }
1302
1311
  }
1303
1312
  }
1304
- const Qe = 274710, et = "0014461ad25081cb0119d034385ff154c8d3ad6bdd76";
1305
- class tt {
1313
+ const tt = 274710, st = "0014461ad25081cb0119d034385ff154c8d3ad6bdd76";
1314
+ class at {
1306
1315
  rostrumService;
1307
1316
  keyManager;
1308
1317
  constructor(e, t) {
1309
1318
  this.rostrumService = e, this.keyManager = t;
1310
1319
  }
1311
1320
  async discoverWalletIndex(e, t) {
1312
- let s = 0, n = !1, i = 0;
1321
+ let s = 0, n = !1, r = 0;
1313
1322
  do {
1314
1323
  n = !0;
1315
- for (let o = i; o < i + 20; o++) {
1316
- const r = { account: e, type: t, index: o }, c = this.keyManager.getKey(r).privateKey.toAddress().toString();
1324
+ for (let o = r; o < r + 20; o++) {
1325
+ const i = { account: e, type: t, index: o }, c = this.keyManager.getKey(i).privateKey.toAddress().toString();
1317
1326
  await this.rostrumService.isAddressUsed(c) && (s = o, n = !1);
1318
1327
  }
1319
- i += 20;
1328
+ r += 20;
1320
1329
  } while (!n);
1321
1330
  return s;
1322
1331
  }
1323
1332
  async discoverVaults(e) {
1324
1333
  const t = [];
1325
- for (const i of e) {
1326
- const o = this.checkVaultsForAddress(i);
1334
+ for (const r of e) {
1335
+ const o = this.checkVaultsForAddress(r);
1327
1336
  t.push(o);
1328
1337
  }
1329
1338
  const s = await Promise.all(t), n = /* @__PURE__ */ new Map();
1330
- return s.forEach((i) => {
1331
- i.forEach((o) => {
1332
- const r = this.parseVaultDetails(o);
1333
- r && n.set(r.address, r);
1339
+ return s.forEach((r) => {
1340
+ r.forEach((o) => {
1341
+ const i = this.parseVaultDetails(o);
1342
+ i && n.set(i.address, i);
1334
1343
  });
1335
1344
  }), n;
1336
1345
  }
1337
1346
  async checkVaultsForAddress(e) {
1338
- const t = /* @__PURE__ */ new Set(), s = await this.rostrumService.getTransactionsHistory(e, Qe);
1347
+ const t = /* @__PURE__ */ new Set(), s = await this.rostrumService.getTransactionsHistory(e, tt);
1339
1348
  for (const n of s) {
1340
- const o = (await this.rostrumService.getTransaction(n.tx_hash)).vout.filter((r) => r.scriptPubKey.hex.startsWith(et));
1341
- for (const r of o)
1342
- t.add(r.scriptPubKey.hex);
1349
+ const o = (await this.rostrumService.getTransaction(n.tx_hash)).vout.filter((i) => i.scriptPubKey.hex.startsWith(st));
1350
+ for (const i of o)
1351
+ t.add(i.scriptPubKey.hex);
1343
1352
  }
1344
1353
  return t;
1345
1354
  }
1346
1355
  parseVaultDetails(e) {
1347
- const t = A.fromHex(e), s = new Ee().writeVarLengthBuf(t.toBuffer()).toBuffer(), n = new b(s).toString(), i = t.getVisibleArgs(), o = z.fromScriptNumBuffer(i.chunks[0].buf).toNumber(), r = J.isSmallIntOp(i.chunks[1].opcodenum) ? J.decodeOP_N(i.chunks[1].opcodenum) : z.fromScriptNumBuffer(i.chunks[1].buf).toNumber(), c = [o, r], d = this.keyManager.getKey({ account: f.VAULT, type: m.RECEIVE, index: r }), u = Ze(d.publicKey, c);
1356
+ const t = A.fromHex(e), s = new _e().writeVarLengthBuf(t.toBuffer()).toBuffer(), n = new b(s).toString(), r = t.getVisibleArgs(), o = z.fromScriptNumBuffer(r.chunks[0].buf).toNumber(), i = J.isSmallIntOp(r.chunks[1].opcodenum) ? J.decodeOP_N(r.chunks[1].opcodenum) : z.fromScriptNumBuffer(r.chunks[1].buf).toNumber(), c = [o, i], d = this.keyManager.getKey({ account: f.VAULT, type: y.RECEIVE, index: i }), u = et(d.publicKey, c);
1348
1357
  return n != u ? void 0 : {
1349
1358
  address: n,
1350
1359
  block: o,
1351
- idx: r,
1360
+ idx: i,
1352
1361
  statusHash: "",
1353
1362
  balance: { confirmed: "0", unconfirmed: "0" },
1354
1363
  tokensBalance: {},
@@ -1358,8 +1367,8 @@ class tt {
1358
1367
  }
1359
1368
  }
1360
1369
  class N {
1361
- constructor(e, t, s, n, i, o, r) {
1362
- this.keyManager = e, this.kvStore = t, this.walletDb = s, this.rostrumService = n, this.assetService = i, this.transactionService = o, this.sessionManager = r, this.discoveryService = new tt(this.rostrumService, this.keyManager), this.accounts = /* @__PURE__ */ new Map(), this.accountsAddressToId = /* @__PURE__ */ new Map(), this.receiveAddresses = [], this.changeAddresses = [], this.vaults = /* @__PURE__ */ new Map(), this.pendingUpdates = /* @__PURE__ */ new Map(), this.addressResolvers = /* @__PURE__ */ new Map();
1370
+ constructor(e, t, s, n, r, o, i) {
1371
+ this.keyManager = e, this.kvStore = t, this.walletDb = s, this.rostrumService = n, this.assetService = r, this.transactionService = o, this.sessionManager = i, this.discoveryService = new at(this.rostrumService, this.keyManager), this.accounts = /* @__PURE__ */ new Map(), this.accountsAddressToId = /* @__PURE__ */ new Map(), this.receiveAddresses = [], this.changeAddresses = [], this.vaults = /* @__PURE__ */ new Map(), this.pendingUpdates = /* @__PURE__ */ new Map(), this.addressResolvers = /* @__PURE__ */ new Map();
1363
1372
  }
1364
1373
  static GAP_LIMIT = 20;
1365
1374
  static DEBOUNCE_MS = 1e3;
@@ -1419,8 +1428,8 @@ class N {
1419
1428
  }
1420
1429
  async discoverWallet() {
1421
1430
  this.notify({ type: "discover_wallet", loading: !0 });
1422
- const e = this.discoveryService.discoverWalletIndex(f.MAIN, m.RECEIVE), t = this.discoveryService.discoverWalletIndex(f.MAIN, m.CHANGE), s = this.discoveryService.discoverWalletIndex(f.DAPP, m.RECEIVE), [n, i, o] = await Promise.all([e, t, s]);
1423
- this.receiveAddresses = this.deriveAddresses(m.RECEIVE, 0, n + N.GAP_LIMIT), this.changeAddresses = this.deriveAddresses(m.CHANGE, 0, i + N.GAP_LIMIT), this.accounts = this.deriveAccounts(0, o + 1), this.accounts.forEach((r) => this.accountsAddressToId.set(r.address, r.id)), await this.saveAddresses(this.receiveAddresses), await this.saveAddresses(this.changeAddresses), await this.saveAccounts(this.accounts), this.initState(), await this.initialSync(), this.notify({ type: "discover_wallet", loading: !1 }), this.notify({ type: "load_wallet", loading: !1 }), await this.rescanVaults();
1431
+ const e = this.discoveryService.discoverWalletIndex(f.MAIN, y.RECEIVE), t = this.discoveryService.discoverWalletIndex(f.MAIN, y.CHANGE), s = this.discoveryService.discoverWalletIndex(f.DAPP, y.RECEIVE), [n, r, o] = await Promise.all([e, t, s]);
1432
+ this.receiveAddresses = this.deriveAddresses(y.RECEIVE, 0, n + N.GAP_LIMIT), this.changeAddresses = this.deriveAddresses(y.CHANGE, 0, r + N.GAP_LIMIT), this.accounts = this.deriveAccounts(0, o + 1), this.accounts.forEach((i) => this.accountsAddressToId.set(i.address, i.id)), await this.saveAddresses(this.receiveAddresses), await this.saveAddresses(this.changeAddresses), await this.saveAccounts(this.accounts), this.initState(), await this.initialSync(), this.notify({ type: "discover_wallet", loading: !1 }), this.notify({ type: "load_wallet", loading: !1 }), await this.rescanVaults();
1424
1433
  }
1425
1434
  async loadWallet() {
1426
1435
  this.receiveAddresses = await this.walletDb.getReceiveAddresses(), this.changeAddresses = await this.walletDb.getChangeAddresses();
@@ -1451,7 +1460,7 @@ class N {
1451
1460
  id: g,
1452
1461
  name: "Main Wallet",
1453
1462
  address: this.getReceiveAddress(),
1454
- balance: re(e.map((t) => t.balance)),
1463
+ balance: de(e.map((t) => t.balance)),
1455
1464
  tokensBalance: G(e.map((t) => t.tokensBalance)),
1456
1465
  tokens: [],
1457
1466
  sessions: {}
@@ -1483,11 +1492,11 @@ class N {
1483
1492
  }
1484
1493
  deriveAddresses(e, t, s) {
1485
1494
  const n = [];
1486
- for (let i = t; i < t + s; i++) {
1487
- const o = x(f.MAIN, e, i), c = {
1495
+ for (let r = t; r < t + s; r++) {
1496
+ const o = x(f.MAIN, e, r), c = {
1488
1497
  address: this.keyManager.getKey(o).privateKey.toAddress().toString(),
1489
1498
  space: e,
1490
- idx: i,
1499
+ idx: r,
1491
1500
  used: !1,
1492
1501
  height: 0,
1493
1502
  statusHash: "",
@@ -1502,7 +1511,7 @@ class N {
1502
1511
  deriveAccounts(e, t) {
1503
1512
  const s = /* @__PURE__ */ new Map();
1504
1513
  for (let n = e; n < e + t; n++) {
1505
- const i = x(f.DAPP, 0, n), o = this.keyManager.getKey(i).privateKey.toAddress().toString(), r = {
1514
+ const r = x(f.DAPP, 0, n), o = this.keyManager.getKey(r).privateKey.toAddress().toString(), i = {
1506
1515
  id: n,
1507
1516
  name: `Account ${n + 1}`,
1508
1517
  address: o,
@@ -1513,7 +1522,7 @@ class N {
1513
1522
  tokensBalance: {},
1514
1523
  type: f.DAPP
1515
1524
  };
1516
- s.set(r.id, r);
1525
+ s.set(i.id, i);
1517
1526
  }
1518
1527
  return s;
1519
1528
  }
@@ -1527,26 +1536,26 @@ class N {
1527
1536
  }
1528
1537
  async subscribeAddresses(e, t = !1) {
1529
1538
  const s = e.map(async (o) => {
1530
- const r = await this.rostrumService.subscribeAddress(o.address, this.onSubscribeEvent);
1531
- return { addr: o, result: r };
1532
- }), n = [], i = await Promise.all(s);
1533
- for (const { addr: o, result: r } of i)
1534
- if (r && typeof r == "string" && o.statusHash != r) {
1539
+ const i = await this.rostrumService.subscribeAddress(o.address, this.onSubscribeEvent);
1540
+ return { addr: o, result: i };
1541
+ }), n = [], r = await Promise.all(s);
1542
+ for (const { addr: o, result: i } of r)
1543
+ if (i && typeof i == "string" && o.statusHash != i) {
1535
1544
  if (t) {
1536
1545
  const c = new Promise((d) => {
1537
1546
  this.addressResolvers.set(o.address, d);
1538
1547
  });
1539
1548
  n.push(c);
1540
1549
  }
1541
- this.registerUpdate({ address: o, result: r });
1550
+ this.registerUpdate({ address: o, result: i });
1542
1551
  }
1543
1552
  await Promise.all(n);
1544
1553
  }
1545
1554
  onSubscribeEvent = (e) => {
1546
1555
  if (!Array.isArray(e) || e.length < 2)
1547
1556
  return;
1548
- const [t, s] = e, i = this.getAllAddresses().find((o) => o.address === t);
1549
- i && i.statusHash !== s && this.registerUpdate({ address: i, result: s });
1557
+ const [t, s] = e, r = this.getAllAddresses().find((o) => o.address === t);
1558
+ r && r.statusHash !== s && this.registerUpdate({ address: r, result: s });
1550
1559
  };
1551
1560
  registerUpdate(e) {
1552
1561
  this.pendingUpdates.set(e.address.address, e), clearTimeout(this.updateTimer), this.updateTimer = setTimeout(() => {
@@ -1560,26 +1569,26 @@ class N {
1560
1569
  const e = Array.from(this.pendingUpdates);
1561
1570
  this.pendingUpdates.clear();
1562
1571
  const t = [], s = [], n = [];
1563
- for (const [, r] of e)
1564
- if (this.isAccountAddress(r.address)) {
1565
- const c = this.fetchAndUpdateAccount(r.address, r.result);
1572
+ for (const [, i] of e)
1573
+ if (this.isAccountAddress(i.address)) {
1574
+ const c = this.fetchAndUpdateAccount(i.address, i.result);
1566
1575
  t.push(c);
1567
- } else if (this.isVaultAddress(r.address)) {
1568
- const c = this.fetchAndUpdateVault(r.address, r.result);
1576
+ } else if (this.isVaultAddress(i.address)) {
1577
+ const c = this.fetchAndUpdateVault(i.address, i.result);
1569
1578
  s.push(c);
1570
1579
  } else {
1571
- const c = this.fetchAndUpdateAddress(r.address, r.result);
1580
+ const c = this.fetchAndUpdateAddress(i.address, i.result);
1572
1581
  n.push(c);
1573
1582
  }
1574
- const i = await Promise.all(t);
1583
+ const r = await Promise.all(t);
1575
1584
  await Promise.all(s);
1576
1585
  const o = await Promise.all(n);
1577
1586
  if (this.addressResolvers.size > 0)
1578
- for (const [r] of e) {
1579
- const c = this.addressResolvers.get(r);
1580
- c && (c(), this.addressResolvers.delete(r));
1587
+ for (const [i] of e) {
1588
+ const c = this.addressResolvers.get(i);
1589
+ c && (c(), this.addressResolvers.delete(i));
1581
1590
  }
1582
- await Promise.all([this.postProcessWalletUpdate(o), this.postProcessAccountUpdate(i)]);
1591
+ await Promise.all([this.postProcessWalletUpdate(o), this.postProcessAccountUpdate(r)]);
1583
1592
  } catch (e) {
1584
1593
  console.error("Error processing pending updates:", e);
1585
1594
  } finally {
@@ -1590,15 +1599,15 @@ class N {
1590
1599
  if (e.length === 0)
1591
1600
  return;
1592
1601
  const t = /* @__PURE__ */ new Map();
1593
- for (const { txs: r } of e)
1594
- for (const c of r)
1602
+ for (const { txs: i } of e)
1603
+ for (const c of i)
1595
1604
  t.set(c.tx_hash, c);
1596
- await this.checkGapLimit(m.RECEIVE), await this.checkGapLimit(m.CHANGE);
1597
- const s = this.getMainAddresses(), n = re(s.map((r) => r.balance)), i = G(s.map((r) => r.tokensBalance));
1598
- this.notify({ type: "account_balance_updated", accountId: g, balance: n, tokensBalance: i }), this.notify({ type: "main_address_updated", address: this.getReceiveAddress() });
1599
- const o = this.assetService.syncNfts(g, i);
1600
- for (const r of t.values())
1601
- await this.transactionService.classifyAndSaveTransaction(g, r.tx_hash, s.map((c) => c.address));
1605
+ await this.checkGapLimit(y.RECEIVE), await this.checkGapLimit(y.CHANGE);
1606
+ const s = this.getMainAddresses(), n = de(s.map((i) => i.balance)), r = G(s.map((i) => i.tokensBalance));
1607
+ this.notify({ type: "account_balance_updated", accountId: g, balance: n, tokensBalance: r }), this.notify({ type: "main_address_updated", address: this.getReceiveAddress() });
1608
+ const o = this.assetService.syncNfts(g, r);
1609
+ for (const i of t.values())
1610
+ await this.transactionService.classifyAndSaveTransaction(g, i.tx_hash, s.map((c) => c.address));
1602
1611
  await o;
1603
1612
  }
1604
1613
  async postProcessAccountUpdate(e) {
@@ -1606,10 +1615,10 @@ class N {
1606
1615
  for (const { address: t, txs: s } of e) {
1607
1616
  const n = t;
1608
1617
  this.notify({ type: "account_balance_updated", accountId: n.id, balance: n.balance, tokensBalance: n.tokensBalance });
1609
- const i = this.assetService.syncNfts(n.id, n.tokensBalance);
1618
+ const r = this.assetService.syncNfts(n.id, n.tokensBalance);
1610
1619
  for (const o of s)
1611
1620
  await this.transactionService.classifyAndSaveTransaction(n.id, o.tx_hash, [n.address]);
1612
- await i;
1621
+ await r;
1613
1622
  }
1614
1623
  }
1615
1624
  async fetchAndUpdateAddress(e, t) {
@@ -1628,16 +1637,16 @@ class N {
1628
1637
  return e.height = s.lastHeight, await this.walletDb.saveVault(e), this.notify({ type: "vault_balance_updated", address: e.address, balance: e.balance }), { address: e, txs: s.txs };
1629
1638
  }
1630
1639
  async checkGapLimit(e) {
1631
- const t = e === m.RECEIVE ? this.receiveAddresses : this.changeAddresses, s = e === m.RECEIVE ? "Receive" : "Change", n = t.filter((i) => !i.used).length;
1640
+ const t = e === y.RECEIVE ? this.receiveAddresses : this.changeAddresses, s = e === y.RECEIVE ? "Receive" : "Change", n = t.filter((r) => !r.used).length;
1632
1641
  if (n < N.GAP_LIMIT) {
1633
- const i = N.GAP_LIMIT - n, o = t[t.length - 1].idx;
1634
- console.log(`Deriving ${i} more ${s} addresses...`);
1635
- const r = this.deriveAddresses(e, o + 1, i);
1636
- e === m.RECEIVE ? this.receiveAddresses.push(...r) : this.changeAddresses.push(...r), await this.saveAddresses(r), await this.subscribeAddresses(r);
1642
+ const r = N.GAP_LIMIT - n, o = t[t.length - 1].idx;
1643
+ console.log(`Deriving ${r} more ${s} addresses...`);
1644
+ const i = this.deriveAddresses(e, o + 1, r);
1645
+ e === y.RECEIVE ? this.receiveAddresses.push(...i) : this.changeAddresses.push(...i), await this.saveAddresses(i), await this.subscribeAddresses(i);
1637
1646
  }
1638
1647
  }
1639
1648
  async addNewAccount(e, t) {
1640
- const s = x(f.DAPP, 0, e), n = this.keyManager.getKey(s).privateKey.toAddress().toString(), i = {
1649
+ const s = x(f.DAPP, 0, e), n = this.keyManager.getKey(s).privateKey.toAddress().toString(), r = {
1641
1650
  id: e,
1642
1651
  name: t,
1643
1652
  address: n,
@@ -1648,14 +1657,14 @@ class N {
1648
1657
  tokensBalance: {},
1649
1658
  type: f.DAPP
1650
1659
  };
1651
- this.accounts.set(e, i), this.accountsAddressToId.set(n, e), await this.walletDb.saveAccount(i), await this.subscribeAddresses([i]), this.notify({
1660
+ this.accounts.set(e, r), this.accountsAddressToId.set(n, e), await this.walletDb.saveAccount(r), await this.subscribeAddresses([r]), this.notify({
1652
1661
  type: "new_account",
1653
1662
  account: {
1654
- id: i.id,
1655
- name: i.name,
1656
- address: i.address,
1657
- balance: i.balance,
1658
- tokensBalance: i.tokensBalance,
1663
+ id: r.id,
1664
+ name: r.name,
1665
+ address: r.address,
1666
+ balance: r.balance,
1667
+ tokensBalance: r.tokensBalance,
1659
1668
  tokens: [],
1660
1669
  sessions: {}
1661
1670
  }
@@ -1707,8 +1716,8 @@ class N {
1707
1716
  async rescanVaults() {
1708
1717
  let e = !1;
1709
1718
  const t = await this.discoveryService.discoverVaults(this.getMainAddresses().map((n) => n.address)), s = [];
1710
- for (const [n, i] of t)
1711
- this.vaults.has(n) || (e = !0, s.push(this.addVault(i)));
1719
+ for (const [n, r] of t)
1720
+ this.vaults.has(n) || (e = !0, s.push(this.addVault(r)));
1712
1721
  return await Promise.all(s), e;
1713
1722
  }
1714
1723
  isVaultAddress(e) {
@@ -1721,12 +1730,12 @@ class N {
1721
1730
  return e.type == f.MAIN;
1722
1731
  }
1723
1732
  }
1724
- const st = {
1733
+ const nt = {
1725
1734
  isWalletExist: !1,
1726
1735
  isAuthorized: !1
1727
- }, we = M({
1736
+ }, Se = M({
1728
1737
  name: "auth",
1729
- initialState: st,
1738
+ initialState: nt,
1730
1739
  reducers: {
1731
1740
  setWalletExist: (a, e) => {
1732
1741
  a.isWalletExist = e.payload;
@@ -1735,12 +1744,12 @@ const st = {
1735
1744
  a.isAuthorized = e.payload;
1736
1745
  }
1737
1746
  }
1738
- }), Wt = we.actions, at = we.reducer, nt = {
1747
+ }), Yt = Se.actions, rt = Se.reducer, it = {
1739
1748
  modalType: null,
1740
1749
  currentRequest: null
1741
- }, ve = M({
1750
+ }, be = M({
1742
1751
  name: "dappModal",
1743
- initialState: nt,
1752
+ initialState: it,
1744
1753
  reducers: {
1745
1754
  showRequest(a, e) {
1746
1755
  a.modalType = e.payload.type, a.currentRequest = e.payload;
@@ -1749,24 +1758,24 @@ const st = {
1749
1758
  a.modalType = null, a.currentRequest = null;
1750
1759
  }
1751
1760
  }
1752
- }), jt = ve.actions, it = ve.reducer, rt = {
1761
+ }), Zt = be.actions, ot = be.reducer, ct = {
1753
1762
  counter: 0,
1754
1763
  loading: !1
1755
- }, Ae = M({
1764
+ }, ke = M({
1756
1765
  name: "loader",
1757
- initialState: rt,
1766
+ initialState: ct,
1758
1767
  reducers: {
1759
1768
  setLoader: (a, e) => {
1760
1769
  const t = e.payload.loading ? a.counter + 1 : Math.max(0, a.counter - 1);
1761
1770
  a.counter = t, a.loading = t > 0, a.text = e.payload.text;
1762
1771
  }
1763
1772
  }
1764
- }), $t = Ae.actions, ot = Ae.reducer, ct = {
1773
+ }), Qt = ke.actions, dt = ke.reducer, ut = {
1765
1774
  wallet: {},
1766
1775
  web3: {}
1767
- }, Se = M({
1776
+ }, Te = M({
1768
1777
  name: "notifications",
1769
- initialState: ct,
1778
+ initialState: ut,
1770
1779
  reducers: {
1771
1780
  addNotification: (a, e) => {
1772
1781
  e.payload.type == "wallet" ? a.wallet[e.payload.id] = e.payload : e.payload.type == "web3" && (a.web3[e.payload.id] = e.payload);
@@ -1778,16 +1787,16 @@ const st = {
1778
1787
  e.payload === "wallet" ? a.wallet = {} : e.payload === "web3" ? a.web3 = {} : e.payload === "all" && (a.wallet = {}, a.web3 = {});
1779
1788
  }
1780
1789
  }
1781
- }), Xt = Se.actions, dt = Se.reducer, ut = {
1790
+ }), es = Te.actions, lt = Te.reducer, ht = {
1782
1791
  status: "Offline",
1783
1792
  height: 0,
1784
- price: me(),
1793
+ price: Ae(),
1785
1794
  hasNetwork: !0,
1786
1795
  isSuspended: !1
1787
- }, ce = Ve("status/fetchPrice", async () => {
1788
- const a = me();
1796
+ }, le = He("status/fetchPrice", async () => {
1797
+ const a = Ae();
1789
1798
  try {
1790
- const e = await ze();
1799
+ const e = await je();
1791
1800
  Object.keys(e).forEach((t) => {
1792
1801
  a[t] = {
1793
1802
  value: e[t],
@@ -1797,9 +1806,9 @@ const st = {
1797
1806
  } catch {
1798
1807
  }
1799
1808
  return a;
1800
- }), be = M({
1809
+ }), Ie = M({
1801
1810
  name: "status",
1802
- initialState: ut,
1811
+ initialState: ht,
1803
1812
  reducers: {
1804
1813
  setHeight: (a, e) => {
1805
1814
  e.payload > 0 && (a.status = "Online"), a.height = e.payload;
@@ -1815,13 +1824,13 @@ const st = {
1815
1824
  }
1816
1825
  },
1817
1826
  extraReducers: (a) => {
1818
- a.addCase(ce.fulfilled, (e, t) => {
1827
+ a.addCase(le.fulfilled, (e, t) => {
1819
1828
  e.price = t.payload;
1820
- }).addCase(ce.rejected, (e, t) => {
1829
+ }).addCase(le.rejected, (e, t) => {
1821
1830
  console.error(t.error.message);
1822
1831
  });
1823
1832
  }
1824
- }), Yt = be.actions, lt = be.reducer, ht = {
1833
+ }), ts = Ie.actions, ft = Ie.reducer, pt = {
1825
1834
  isAuthorized: !1,
1826
1835
  selectedAccount: g,
1827
1836
  accounts: {
@@ -1840,9 +1849,9 @@ const st = {
1840
1849
  initLoad: !0,
1841
1850
  txUpdateTrigger: 0,
1842
1851
  nftsUpdateTrigger: 0
1843
- }, ke = M({
1852
+ }, xe = M({
1844
1853
  name: "wallet",
1845
- initialState: ht,
1854
+ initialState: pt,
1846
1855
  reducers: {
1847
1856
  setInitLoad: (a, e) => {
1848
1857
  a.initLoad = e.payload;
@@ -1898,108 +1907,108 @@ const st = {
1898
1907
  a.accounts[e.payload.accountId].sessions = {};
1899
1908
  }
1900
1909
  }
1901
- }), Zt = ke.actions, ft = ke.reducer, Qt = {
1902
- loader: ot,
1903
- dapp: it,
1904
- status: lt,
1905
- wallet: ft,
1906
- auth: at,
1907
- notifications: dt
1908
- }, w = Re.withTypes(), es = () => w((a) => a.auth), ts = () => w((a) => a.status.height), ss = (a) => w((e) => e.wallet.accounts[a]), as = () => w((a) => a.wallet.selectedAccount), ns = () => w((a) => Math.max(...Object.keys(a.wallet.accounts).map(Number))), is = (a) => w((e) => e.wallet.accounts[a].address), rs = (a) => w((e) => e.wallet.accounts[a].balance), os = (a, e) => w((t) => t.wallet.accounts[a].tokensBalance[e]), cs = (a, e) => w((t) => t.wallet.accounts[a].sessions[e]), ds = () => w((a) => a.wallet.vaults), Te = j(
1910
+ }), ss = xe.actions, gt = xe.reducer, as = {
1911
+ loader: dt,
1912
+ dapp: ot,
1913
+ status: ft,
1914
+ wallet: gt,
1915
+ auth: rt,
1916
+ notifications: lt
1917
+ }, w = Ke.withTypes(), ns = () => w((a) => a.auth), rs = () => w((a) => a.status.height), is = (a) => w((e) => e.wallet.accounts[a]), os = () => w((a) => a.wallet.selectedAccount), cs = () => w((a) => Math.max(...Object.keys(a.wallet.accounts).map(Number))), ds = (a) => w((e) => e.wallet.accounts[a].address), us = (a) => w((e) => e.wallet.accounts[a].balance), ls = (a, e) => w((t) => t.wallet.accounts[a].tokensBalance[e]), hs = (a, e) => w((t) => t.wallet.accounts[a].sessions[e]), fs = () => w((a) => a.wallet.vaults), Ne = j(
1909
1918
  [(a) => a.notifications.wallet],
1910
1919
  (a) => Object.values(a).sort((e, t) => t.createdAt - e.createdAt)
1911
- ), Ie = j(
1920
+ ), Ee = j(
1912
1921
  [(a) => a.notifications.web3],
1913
1922
  (a) => Object.values(a).sort((e, t) => t.createdAt - e.createdAt)
1914
- ), pt = j(
1915
- [Te, Ie],
1923
+ ), mt = j(
1924
+ [Ne, Ee],
1916
1925
  (a, e) => [...a, ...e].sort((t, s) => s.createdAt - t.createdAt)
1917
- ), us = () => w(Te), ls = () => w(Ie), hs = () => w(pt);
1926
+ ), ps = () => w(Ne), gs = () => w(Ee), ms = () => w(mt);
1918
1927
  export {
1919
1928
  f as AccountType,
1920
- Ht as AssetService,
1929
+ Gt as AssetService,
1921
1930
  V as AssetType,
1922
- Pt as KVStore,
1923
- Dt as KeyManager,
1924
- m as KeySpace,
1931
+ Vt as KVStore,
1932
+ Kt as KeyManager,
1933
+ y as KeySpace,
1925
1934
  g as MAIN_WALLET_ID,
1926
- ne as MAX_INT64,
1927
- he as RostrumService,
1928
- Jt as SessionManager,
1935
+ oe as MAX_INT64,
1936
+ ge as RostrumService,
1937
+ $t as SessionManager,
1929
1938
  _ as SessionRequestType,
1930
- Kt as TransactionService,
1931
- zt as TransactionTransformer,
1932
- He as VAULT_FIRST_BLOCK,
1933
- It as VAULT_SCRIPT_PREFIX,
1934
- Ut as WalletCache,
1935
- Ot as WalletDB,
1939
+ qt as TransactionService,
1940
+ Xt as TransactionTransformer,
1941
+ Le as VAULT_FIRST_BLOCK,
1942
+ Mt as VAULT_SCRIPT_PREFIX,
1943
+ Ht as WalletCache,
1944
+ Rt as WalletDB,
1936
1945
  N as WalletManager,
1937
- Wt as authActions,
1938
- at as authReducer,
1939
- Bt as capitalizeFirstLetter,
1940
- ye as currencies,
1946
+ Yt as authActions,
1947
+ rt as authReducer,
1948
+ Ot as capitalizeFirstLetter,
1949
+ ve as currencies,
1941
1950
  $ as currentTimestamp,
1942
- jt as dappModalActions,
1943
- it as dappModalReducer,
1944
- Ft as encryptMnemonic,
1945
- Et as estimateDateByFutureBlock,
1946
- Fe as fetchAssetBlob,
1947
- Le as fetchAssetDoc,
1948
- Vt as fetchNiftyNFT,
1949
- ce as fetchPrice,
1950
- Lt as generateNewMnemonic,
1951
- Ze as generateVaultAddress,
1952
- $e as generateVaultConstraint,
1953
- Ye as generateVaultVisibleArgs,
1951
+ Zt as dappModalActions,
1952
+ ot as dappModalReducer,
1953
+ zt as encryptMnemonic,
1954
+ Ct as estimateDateByFutureBlock,
1955
+ qe as fetchAssetBlob,
1956
+ Ge as fetchAssetDoc,
1957
+ Lt as fetchNiftyNFT,
1958
+ le as fetchPrice,
1959
+ Jt as generateNewMnemonic,
1960
+ et as generateVaultAddress,
1961
+ Ye as generateVaultConstraint,
1962
+ Qe as generateVaultVisibleArgs,
1954
1963
  R as getAddressBuffer,
1955
- qt as getCurrencySymbol,
1956
- Nt as getExplorerUrl,
1957
- _t as getFileMediaType,
1958
- Ct as getFileMimeType,
1959
- ze as getNexaPrices,
1960
- fe as getNiftyToken,
1961
- Xe as getVaultConstraintHash,
1962
- We as getVaultTemplate,
1963
- je as getVaultTemplateHash,
1964
- me as initializePrices,
1965
- xt as isGenesisHashValid,
1966
- qe as isMnemonicValid,
1964
+ jt as getCurrencySymbol,
1965
+ _t as getExplorerUrl,
1966
+ Ut as getFileMediaType,
1967
+ Dt as getFileMimeType,
1968
+ je as getNexaPrices,
1969
+ me as getNiftyToken,
1970
+ Ze as getVaultConstraintHash,
1971
+ $e as getVaultTemplate,
1972
+ Xe as getVaultTemplateHash,
1973
+ Ae as initializePrices,
1974
+ Bt as isGenesisHashValid,
1975
+ ze as isMnemonicValid,
1967
1976
  q as isNiftySubgroup,
1968
1977
  C as isNullOrEmpty,
1969
1978
  T as isTestnet,
1970
1979
  F as isValidNexaAddress,
1971
1980
  x as keyPathToString,
1972
- $t as loaderActions,
1973
- ot as loaderReducer,
1974
- Xt as notificationsActions,
1975
- dt as notificationsReducer,
1976
- Rt as parseTokenDataUrl,
1977
- Qt as sharedReducers,
1978
- Yt as statusActions,
1979
- lt as statusReducer,
1980
- Ke as stringToKeyPath,
1981
- re as sumBalance,
1981
+ Qt as loaderActions,
1982
+ dt as loaderReducer,
1983
+ es as notificationsActions,
1984
+ lt as notificationsReducer,
1985
+ Ft as parseTokenDataUrl,
1986
+ as as sharedReducers,
1987
+ ts as statusActions,
1988
+ ft as statusReducer,
1989
+ Fe as stringToKeyPath,
1990
+ de as sumBalance,
1982
1991
  G as sumTokensBalance,
1983
1992
  D as tokenAmountToAssetAmount,
1984
- ie as tokenHexToAddr,
1993
+ ce as tokenHexToAddr,
1985
1994
  S as tokenIdToHex,
1986
- oe as transformTokenIconUrl,
1987
- Mt as truncateStringMiddle,
1988
- ss as useAccount,
1989
- hs as useAllNotifications,
1990
- es as useAuth,
1991
- ts as useBlockHeight,
1992
- cs as useDAppSession,
1993
- ns as useLastAccountId,
1994
- is as useMainReceiveAddress,
1995
- as as useSelectedAccount,
1996
- os as useTokenBalance,
1997
- ds as useVaults,
1998
- rs as useWalletBalance,
1999
- us as useWalletNotifications,
2000
- ls as useWeb3Notifications,
2001
- Gt as validateAndDecryptMnemonic,
2002
- Zt as walletActions,
2003
- ft as walletReducer
1995
+ ue as transformTokenIconUrl,
1996
+ Pt as truncateStringMiddle,
1997
+ is as useAccount,
1998
+ ms as useAllNotifications,
1999
+ ns as useAuth,
2000
+ rs as useBlockHeight,
2001
+ hs as useDAppSession,
2002
+ cs as useLastAccountId,
2003
+ ds as useMainReceiveAddress,
2004
+ os as useSelectedAccount,
2005
+ ls as useTokenBalance,
2006
+ fs as useVaults,
2007
+ us as useWalletBalance,
2008
+ ps as useWalletNotifications,
2009
+ gs as useWeb3Notifications,
2010
+ Wt as validateAndDecryptMnemonic,
2011
+ ss as walletActions,
2012
+ gt as walletReducer
2004
2013
  };
2005
2014
  //# sourceMappingURL=index.js.map