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