@otoplo/wallet-common 0.1.6 → 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 +318 -310
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/seed.ts +13 -1
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,29 +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
970
|
async function pe(a, e) {
|
|
968
|
-
|
|
969
|
-
|
|
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;
|
|
970
978
|
}
|
|
971
|
-
async function
|
|
972
|
-
const t = y.getRandomBuffer(16), s = y.getRandomBuffer(12), n = y.utf8ToBuffer(a),
|
|
973
|
-
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);
|
|
974
982
|
}
|
|
975
|
-
async function
|
|
976
|
-
const t = y.base64ToBuffer(a), s = t.subarray(0, 16), n = t.subarray(16, 28),
|
|
977
|
-
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);
|
|
978
986
|
}
|
|
979
|
-
async function
|
|
987
|
+
async function $t(a, e) {
|
|
980
988
|
try {
|
|
981
989
|
if (a) {
|
|
982
|
-
const t = await
|
|
983
|
-
if (t &&
|
|
990
|
+
const t = await je(a, e);
|
|
991
|
+
if (t && We(t))
|
|
984
992
|
return t;
|
|
985
993
|
}
|
|
986
994
|
return !1;
|
|
@@ -998,13 +1006,13 @@ const ge = {
|
|
|
998
1006
|
cad: "C$",
|
|
999
1007
|
chf: "Fr"
|
|
1000
1008
|
}, ye = Object.keys(ge);
|
|
1001
|
-
async function
|
|
1009
|
+
async function $e() {
|
|
1002
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}`);
|
|
1003
1011
|
if (!e.ok)
|
|
1004
1012
|
throw new Error("Failed to fetch price");
|
|
1005
1013
|
return (await e.json()).nexacoin || {};
|
|
1006
1014
|
}
|
|
1007
|
-
function
|
|
1015
|
+
function Xt(a) {
|
|
1008
1016
|
return ge[a] || a;
|
|
1009
1017
|
}
|
|
1010
1018
|
function me() {
|
|
@@ -1013,30 +1021,30 @@ function me() {
|
|
|
1013
1021
|
a[e] = { value: 0, change: 0 };
|
|
1014
1022
|
}), a;
|
|
1015
1023
|
}
|
|
1016
|
-
function
|
|
1024
|
+
function Xe() {
|
|
1017
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);
|
|
1018
1026
|
}
|
|
1019
|
-
function
|
|
1020
|
-
const a =
|
|
1027
|
+
function Ye() {
|
|
1028
|
+
const a = Xe();
|
|
1021
1029
|
return U.sha256ripemd160(a.toBuffer());
|
|
1022
1030
|
}
|
|
1023
|
-
function
|
|
1031
|
+
function Ze(a) {
|
|
1024
1032
|
return A.empty().add(a.toBuffer());
|
|
1025
1033
|
}
|
|
1026
|
-
function
|
|
1027
|
-
const e =
|
|
1034
|
+
function Qe(a) {
|
|
1035
|
+
const e = Ze(a);
|
|
1028
1036
|
return U.sha256ripemd160(e.toBuffer());
|
|
1029
1037
|
}
|
|
1030
|
-
function
|
|
1038
|
+
function et(a) {
|
|
1031
1039
|
return a.map((e) => e <= 16 ? J.smallInt(e) : z.fromNumber(e).toScriptNumBuffer());
|
|
1032
1040
|
}
|
|
1033
|
-
function
|
|
1041
|
+
function tt(a, e) {
|
|
1034
1042
|
if (e.length !== 2)
|
|
1035
1043
|
return;
|
|
1036
|
-
const t =
|
|
1044
|
+
const t = Ye(), s = Qe(a), n = et(e);
|
|
1037
1045
|
return b.fromScriptTemplate(t, s, n).toString();
|
|
1038
1046
|
}
|
|
1039
|
-
class
|
|
1047
|
+
class Yt {
|
|
1040
1048
|
walletDb;
|
|
1041
1049
|
keyManager;
|
|
1042
1050
|
providers;
|
|
@@ -1057,8 +1065,8 @@ class Jt {
|
|
|
1057
1065
|
}
|
|
1058
1066
|
add(e, t, s) {
|
|
1059
1067
|
this.providers.has(e.id) || this.providers.set(e.id, /* @__PURE__ */ new Map());
|
|
1060
|
-
const n = s.details.sessionId,
|
|
1061
|
-
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 });
|
|
1062
1070
|
}
|
|
1063
1071
|
remove(e, t) {
|
|
1064
1072
|
const s = this.providers.get(e);
|
|
@@ -1072,12 +1080,12 @@ class Jt {
|
|
|
1072
1080
|
for (const t of e.values()) {
|
|
1073
1081
|
if (t.id == g)
|
|
1074
1082
|
continue;
|
|
1075
|
-
const s = await this.walletDb.getAccountSessions(t.id), n = this.providers.get(t.id),
|
|
1076
|
-
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))
|
|
1077
1085
|
return;
|
|
1078
1086
|
let c;
|
|
1079
1087
|
try {
|
|
1080
|
-
c = new Ue(
|
|
1088
|
+
c = new Ue(i.uri);
|
|
1081
1089
|
const d = c.getSessionInfo();
|
|
1082
1090
|
await c.connect(3e3);
|
|
1083
1091
|
const u = await c.getAppInfo(2e3);
|
|
@@ -1102,11 +1110,11 @@ class Jt {
|
|
|
1102
1110
|
});
|
|
1103
1111
|
return { account: t, provider: c, metadata: { details: d, appInfo: u } };
|
|
1104
1112
|
} catch (d) {
|
|
1105
|
-
console.error(`Failed to reload session ${
|
|
1113
|
+
console.error(`Failed to reload session ${i.sessionId}`, d), c?.disconnect(), await this.walletDb.removeSession(i.sessionId);
|
|
1106
1114
|
}
|
|
1107
|
-
}), o = await Promise.allSettled(
|
|
1108
|
-
for (const
|
|
1109
|
-
|
|
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);
|
|
1110
1118
|
}
|
|
1111
1119
|
}
|
|
1112
1120
|
clear() {
|
|
@@ -1132,23 +1140,23 @@ class Jt {
|
|
|
1132
1140
|
async replayMessage(e, t, s) {
|
|
1133
1141
|
const n = this.providers.get(e);
|
|
1134
1142
|
if (n) {
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1143
|
+
const r = n.get(t);
|
|
1144
|
+
r && await r.replayMessage(s);
|
|
1137
1145
|
}
|
|
1138
1146
|
}
|
|
1139
1147
|
registerHandlers(e, t, s) {
|
|
1140
1148
|
t.onSessionDelete(() => this.walletDb.removeSession(s)), t.onClose(() => {
|
|
1141
1149
|
this.removeOnClose && this.remove(e.id, s);
|
|
1142
1150
|
});
|
|
1143
|
-
const n = (
|
|
1144
|
-
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 } });
|
|
1145
1153
|
});
|
|
1146
|
-
t.onSignMessage((
|
|
1147
|
-
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 };
|
|
1148
1156
|
return {
|
|
1149
1157
|
name: e.name,
|
|
1150
1158
|
address: e.address,
|
|
1151
|
-
pubkey: this.keyManager.getKey(
|
|
1159
|
+
pubkey: this.keyManager.getKey(r).publicKey.toString(),
|
|
1152
1160
|
blockchain: "nexa",
|
|
1153
1161
|
network: k.defaultNetwork.name,
|
|
1154
1162
|
capabilities: {
|
|
@@ -1161,7 +1169,7 @@ class Jt {
|
|
|
1161
1169
|
});
|
|
1162
1170
|
}
|
|
1163
1171
|
}
|
|
1164
|
-
class
|
|
1172
|
+
class Zt {
|
|
1165
1173
|
rostrumService;
|
|
1166
1174
|
keyManager;
|
|
1167
1175
|
assetService;
|
|
@@ -1206,13 +1214,13 @@ class zt {
|
|
|
1206
1214
|
if (n.status == "spent")
|
|
1207
1215
|
throw new Error("Input UTXO is already spent.");
|
|
1208
1216
|
if (s.output = new xe(n.amount, n.scriptpubkey), s.output.address == e.address) {
|
|
1209
|
-
const
|
|
1217
|
+
const r = n.token_id_hex || "NEXA";
|
|
1210
1218
|
e.myInputs.set(t, {
|
|
1211
1219
|
address: e.address,
|
|
1212
1220
|
nexaAmount: n.amount.toString(),
|
|
1213
|
-
assetId:
|
|
1221
|
+
assetId: r,
|
|
1214
1222
|
assetAmount: D(n.group_quantity) || n.amount.toString()
|
|
1215
|
-
}), e.involvedAssets.add(
|
|
1223
|
+
}), e.involvedAssets.add(r), s.scriptSig.isEmpty() && e.inputsToSign.add(t);
|
|
1216
1224
|
}
|
|
1217
1225
|
s.scriptSig.findPlaceholder() > 0 && e.inputsToSign.add(t);
|
|
1218
1226
|
}
|
|
@@ -1221,13 +1229,13 @@ class zt {
|
|
|
1221
1229
|
const s = e.txDetails.tx.outputs[t].toObject();
|
|
1222
1230
|
if (s.address !== e.address)
|
|
1223
1231
|
continue;
|
|
1224
|
-
const n = s.groupId ? S(s.groupId) : "NEXA",
|
|
1232
|
+
const n = s.groupId ? S(s.groupId) : "NEXA", r = {
|
|
1225
1233
|
address: s.address,
|
|
1226
1234
|
nexaAmount: s.value.toString(),
|
|
1227
1235
|
assetId: n,
|
|
1228
1236
|
assetAmount: D(s.groupAmount) || s.value.toString()
|
|
1229
1237
|
};
|
|
1230
|
-
e.involvedAssets.add(n), e.myOutputs.set(t,
|
|
1238
|
+
e.involvedAssets.add(n), e.myOutputs.set(t, r);
|
|
1231
1239
|
}
|
|
1232
1240
|
}
|
|
1233
1241
|
signInputs(e) {
|
|
@@ -1237,13 +1245,13 @@ class zt {
|
|
|
1237
1245
|
const s = e.txDetails.tx.inputs[t], n = this.validateAndGetSubscript(s);
|
|
1238
1246
|
if (s.scriptSig.isEmpty()) {
|
|
1239
1247
|
e.allMyOutputsCovered = !0;
|
|
1240
|
-
const
|
|
1241
|
-
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));
|
|
1242
1250
|
} else {
|
|
1243
|
-
const
|
|
1251
|
+
const r = s.scriptSig.findPlaceholder(), i = s.scriptSig.chunks[r].buf.subarray(64), c = se.fromBuffer(i);
|
|
1244
1252
|
this.processSignatureCoverage(e, c);
|
|
1245
|
-
const d = te.sign(e.txDetails.tx, t, c, n, e.privateKey).toTxFormat(
|
|
1246
|
-
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));
|
|
1247
1255
|
}
|
|
1248
1256
|
}
|
|
1249
1257
|
if (!e.allMyOutputsCovered)
|
|
@@ -1287,68 +1295,68 @@ class zt {
|
|
|
1287
1295
|
}
|
|
1288
1296
|
async processAssetMovements(e) {
|
|
1289
1297
|
const t = Array.from(e.myInputs.values()), s = Array.from(e.myOutputs.values()), n = [];
|
|
1290
|
-
for (const
|
|
1291
|
-
const o = this.processAssetMovement(e,
|
|
1298
|
+
for (const r of e.involvedAssets) {
|
|
1299
|
+
const o = this.processAssetMovement(e, r, t, s);
|
|
1292
1300
|
n.push(o);
|
|
1293
1301
|
}
|
|
1294
1302
|
await Promise.all(n);
|
|
1295
1303
|
}
|
|
1296
1304
|
async processAssetMovement(e, t, s, n) {
|
|
1297
|
-
const
|
|
1298
|
-
if (
|
|
1299
|
-
const
|
|
1300
|
-
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);
|
|
1301
1309
|
}
|
|
1302
1310
|
}
|
|
1303
1311
|
}
|
|
1304
|
-
const
|
|
1305
|
-
class
|
|
1312
|
+
const st = 274710, at = "0014461ad25081cb0119d034385ff154c8d3ad6bdd76";
|
|
1313
|
+
class nt {
|
|
1306
1314
|
rostrumService;
|
|
1307
1315
|
keyManager;
|
|
1308
1316
|
constructor(e, t) {
|
|
1309
1317
|
this.rostrumService = e, this.keyManager = t;
|
|
1310
1318
|
}
|
|
1311
1319
|
async discoverWalletIndex(e, t) {
|
|
1312
|
-
let s = 0, n = !1,
|
|
1320
|
+
let s = 0, n = !1, r = 0;
|
|
1313
1321
|
do {
|
|
1314
1322
|
n = !0;
|
|
1315
|
-
for (let o =
|
|
1316
|
-
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();
|
|
1317
1325
|
await this.rostrumService.isAddressUsed(c) && (s = o, n = !1);
|
|
1318
1326
|
}
|
|
1319
|
-
|
|
1327
|
+
r += 20;
|
|
1320
1328
|
} while (!n);
|
|
1321
1329
|
return s;
|
|
1322
1330
|
}
|
|
1323
1331
|
async discoverVaults(e) {
|
|
1324
1332
|
const t = [];
|
|
1325
|
-
for (const
|
|
1326
|
-
const o = this.checkVaultsForAddress(
|
|
1333
|
+
for (const r of e) {
|
|
1334
|
+
const o = this.checkVaultsForAddress(r);
|
|
1327
1335
|
t.push(o);
|
|
1328
1336
|
}
|
|
1329
1337
|
const s = await Promise.all(t), n = /* @__PURE__ */ new Map();
|
|
1330
|
-
return s.forEach((
|
|
1331
|
-
|
|
1332
|
-
const
|
|
1333
|
-
|
|
1338
|
+
return s.forEach((r) => {
|
|
1339
|
+
r.forEach((o) => {
|
|
1340
|
+
const i = this.parseVaultDetails(o);
|
|
1341
|
+
i && n.set(i.address, i);
|
|
1334
1342
|
});
|
|
1335
1343
|
}), n;
|
|
1336
1344
|
}
|
|
1337
1345
|
async checkVaultsForAddress(e) {
|
|
1338
|
-
const t = /* @__PURE__ */ new Set(), s = await this.rostrumService.getTransactionsHistory(e,
|
|
1346
|
+
const t = /* @__PURE__ */ new Set(), s = await this.rostrumService.getTransactionsHistory(e, st);
|
|
1339
1347
|
for (const n of s) {
|
|
1340
|
-
const o = (await this.rostrumService.getTransaction(n.tx_hash)).vout.filter((
|
|
1341
|
-
for (const
|
|
1342
|
-
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);
|
|
1343
1351
|
}
|
|
1344
1352
|
return t;
|
|
1345
1353
|
}
|
|
1346
1354
|
parseVaultDetails(e) {
|
|
1347
|
-
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);
|
|
1348
1356
|
return n != u ? void 0 : {
|
|
1349
1357
|
address: n,
|
|
1350
1358
|
block: o,
|
|
1351
|
-
idx:
|
|
1359
|
+
idx: i,
|
|
1352
1360
|
statusHash: "",
|
|
1353
1361
|
balance: { confirmed: "0", unconfirmed: "0" },
|
|
1354
1362
|
tokensBalance: {},
|
|
@@ -1358,8 +1366,8 @@ class tt {
|
|
|
1358
1366
|
}
|
|
1359
1367
|
}
|
|
1360
1368
|
class N {
|
|
1361
|
-
constructor(e, t, s, n,
|
|
1362
|
-
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();
|
|
1363
1371
|
}
|
|
1364
1372
|
static GAP_LIMIT = 20;
|
|
1365
1373
|
static DEBOUNCE_MS = 1e3;
|
|
@@ -1419,8 +1427,8 @@ class N {
|
|
|
1419
1427
|
}
|
|
1420
1428
|
async discoverWallet() {
|
|
1421
1429
|
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,
|
|
1423
|
-
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();
|
|
1424
1432
|
}
|
|
1425
1433
|
async loadWallet() {
|
|
1426
1434
|
this.receiveAddresses = await this.walletDb.getReceiveAddresses(), this.changeAddresses = await this.walletDb.getChangeAddresses();
|
|
@@ -1451,7 +1459,7 @@ class N {
|
|
|
1451
1459
|
id: g,
|
|
1452
1460
|
name: "Main Wallet",
|
|
1453
1461
|
address: this.getReceiveAddress(),
|
|
1454
|
-
balance:
|
|
1462
|
+
balance: ie(e.map((t) => t.balance)),
|
|
1455
1463
|
tokensBalance: G(e.map((t) => t.tokensBalance)),
|
|
1456
1464
|
tokens: [],
|
|
1457
1465
|
sessions: {}
|
|
@@ -1483,11 +1491,11 @@ class N {
|
|
|
1483
1491
|
}
|
|
1484
1492
|
deriveAddresses(e, t, s) {
|
|
1485
1493
|
const n = [];
|
|
1486
|
-
for (let
|
|
1487
|
-
const o = x(f.MAIN, e,
|
|
1494
|
+
for (let r = t; r < t + s; r++) {
|
|
1495
|
+
const o = x(f.MAIN, e, r), c = {
|
|
1488
1496
|
address: this.keyManager.getKey(o).privateKey.toAddress().toString(),
|
|
1489
1497
|
space: e,
|
|
1490
|
-
idx:
|
|
1498
|
+
idx: r,
|
|
1491
1499
|
used: !1,
|
|
1492
1500
|
height: 0,
|
|
1493
1501
|
statusHash: "",
|
|
@@ -1502,7 +1510,7 @@ class N {
|
|
|
1502
1510
|
deriveAccounts(e, t) {
|
|
1503
1511
|
const s = /* @__PURE__ */ new Map();
|
|
1504
1512
|
for (let n = e; n < e + t; n++) {
|
|
1505
|
-
const
|
|
1513
|
+
const r = x(f.DAPP, 0, n), o = this.keyManager.getKey(r).privateKey.toAddress().toString(), i = {
|
|
1506
1514
|
id: n,
|
|
1507
1515
|
name: `Account ${n + 1}`,
|
|
1508
1516
|
address: o,
|
|
@@ -1513,7 +1521,7 @@ class N {
|
|
|
1513
1521
|
tokensBalance: {},
|
|
1514
1522
|
type: f.DAPP
|
|
1515
1523
|
};
|
|
1516
|
-
s.set(
|
|
1524
|
+
s.set(i.id, i);
|
|
1517
1525
|
}
|
|
1518
1526
|
return s;
|
|
1519
1527
|
}
|
|
@@ -1527,26 +1535,26 @@ class N {
|
|
|
1527
1535
|
}
|
|
1528
1536
|
async subscribeAddresses(e, t = !1) {
|
|
1529
1537
|
const s = e.map(async (o) => {
|
|
1530
|
-
const
|
|
1531
|
-
return { addr: o, result:
|
|
1532
|
-
}), n = [],
|
|
1533
|
-
for (const { addr: o, result:
|
|
1534
|
-
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) {
|
|
1535
1543
|
if (t) {
|
|
1536
1544
|
const c = new Promise((d) => {
|
|
1537
1545
|
this.addressResolvers.set(o.address, d);
|
|
1538
1546
|
});
|
|
1539
1547
|
n.push(c);
|
|
1540
1548
|
}
|
|
1541
|
-
this.registerUpdate({ address: o, result:
|
|
1549
|
+
this.registerUpdate({ address: o, result: i });
|
|
1542
1550
|
}
|
|
1543
1551
|
await Promise.all(n);
|
|
1544
1552
|
}
|
|
1545
1553
|
onSubscribeEvent = (e) => {
|
|
1546
1554
|
if (!Array.isArray(e) || e.length < 2)
|
|
1547
1555
|
return;
|
|
1548
|
-
const [t, s] = e,
|
|
1549
|
-
|
|
1556
|
+
const [t, s] = e, r = this.getAllAddresses().find((o) => o.address === t);
|
|
1557
|
+
r && r.statusHash !== s && this.registerUpdate({ address: r, result: s });
|
|
1550
1558
|
};
|
|
1551
1559
|
registerUpdate(e) {
|
|
1552
1560
|
this.pendingUpdates.set(e.address.address, e), clearTimeout(this.updateTimer), this.updateTimer = setTimeout(() => {
|
|
@@ -1560,26 +1568,26 @@ class N {
|
|
|
1560
1568
|
const e = Array.from(this.pendingUpdates);
|
|
1561
1569
|
this.pendingUpdates.clear();
|
|
1562
1570
|
const t = [], s = [], n = [];
|
|
1563
|
-
for (const [,
|
|
1564
|
-
if (this.isAccountAddress(
|
|
1565
|
-
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);
|
|
1566
1574
|
t.push(c);
|
|
1567
|
-
} else if (this.isVaultAddress(
|
|
1568
|
-
const c = this.fetchAndUpdateVault(
|
|
1575
|
+
} else if (this.isVaultAddress(i.address)) {
|
|
1576
|
+
const c = this.fetchAndUpdateVault(i.address, i.result);
|
|
1569
1577
|
s.push(c);
|
|
1570
1578
|
} else {
|
|
1571
|
-
const c = this.fetchAndUpdateAddress(
|
|
1579
|
+
const c = this.fetchAndUpdateAddress(i.address, i.result);
|
|
1572
1580
|
n.push(c);
|
|
1573
1581
|
}
|
|
1574
|
-
const
|
|
1582
|
+
const r = await Promise.all(t);
|
|
1575
1583
|
await Promise.all(s);
|
|
1576
1584
|
const o = await Promise.all(n);
|
|
1577
1585
|
if (this.addressResolvers.size > 0)
|
|
1578
|
-
for (const [
|
|
1579
|
-
const c = this.addressResolvers.get(
|
|
1580
|
-
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));
|
|
1581
1589
|
}
|
|
1582
|
-
await Promise.all([this.postProcessWalletUpdate(o), this.postProcessAccountUpdate(
|
|
1590
|
+
await Promise.all([this.postProcessWalletUpdate(o), this.postProcessAccountUpdate(r)]);
|
|
1583
1591
|
} catch (e) {
|
|
1584
1592
|
console.error("Error processing pending updates:", e);
|
|
1585
1593
|
} finally {
|
|
@@ -1590,15 +1598,15 @@ class N {
|
|
|
1590
1598
|
if (e.length === 0)
|
|
1591
1599
|
return;
|
|
1592
1600
|
const t = /* @__PURE__ */ new Map();
|
|
1593
|
-
for (const { txs:
|
|
1594
|
-
for (const c of
|
|
1601
|
+
for (const { txs: i } of e)
|
|
1602
|
+
for (const c of i)
|
|
1595
1603
|
t.set(c.tx_hash, c);
|
|
1596
1604
|
await this.checkGapLimit(m.RECEIVE), await this.checkGapLimit(m.CHANGE);
|
|
1597
|
-
const s = this.getMainAddresses(), n =
|
|
1598
|
-
this.notify({ type: "account_balance_updated", accountId: g, balance: n, tokensBalance:
|
|
1599
|
-
const o = this.assetService.syncNfts(g,
|
|
1600
|
-
for (const
|
|
1601
|
-
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));
|
|
1602
1610
|
await o;
|
|
1603
1611
|
}
|
|
1604
1612
|
async postProcessAccountUpdate(e) {
|
|
@@ -1606,10 +1614,10 @@ class N {
|
|
|
1606
1614
|
for (const { address: t, txs: s } of e) {
|
|
1607
1615
|
const n = t;
|
|
1608
1616
|
this.notify({ type: "account_balance_updated", accountId: n.id, balance: n.balance, tokensBalance: n.tokensBalance });
|
|
1609
|
-
const
|
|
1617
|
+
const r = this.assetService.syncNfts(n.id, n.tokensBalance);
|
|
1610
1618
|
for (const o of s)
|
|
1611
1619
|
await this.transactionService.classifyAndSaveTransaction(n.id, o.tx_hash, [n.address]);
|
|
1612
|
-
await
|
|
1620
|
+
await r;
|
|
1613
1621
|
}
|
|
1614
1622
|
}
|
|
1615
1623
|
async fetchAndUpdateAddress(e, t) {
|
|
@@ -1628,16 +1636,16 @@ class N {
|
|
|
1628
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 };
|
|
1629
1637
|
}
|
|
1630
1638
|
async checkGapLimit(e) {
|
|
1631
|
-
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;
|
|
1632
1640
|
if (n < N.GAP_LIMIT) {
|
|
1633
|
-
const
|
|
1634
|
-
console.log(`Deriving ${
|
|
1635
|
-
const
|
|
1636
|
-
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);
|
|
1637
1645
|
}
|
|
1638
1646
|
}
|
|
1639
1647
|
async addNewAccount(e, t) {
|
|
1640
|
-
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 = {
|
|
1641
1649
|
id: e,
|
|
1642
1650
|
name: t,
|
|
1643
1651
|
address: n,
|
|
@@ -1648,14 +1656,14 @@ class N {
|
|
|
1648
1656
|
tokensBalance: {},
|
|
1649
1657
|
type: f.DAPP
|
|
1650
1658
|
};
|
|
1651
|
-
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({
|
|
1652
1660
|
type: "new_account",
|
|
1653
1661
|
account: {
|
|
1654
|
-
id:
|
|
1655
|
-
name:
|
|
1656
|
-
address:
|
|
1657
|
-
balance:
|
|
1658
|
-
tokensBalance:
|
|
1662
|
+
id: r.id,
|
|
1663
|
+
name: r.name,
|
|
1664
|
+
address: r.address,
|
|
1665
|
+
balance: r.balance,
|
|
1666
|
+
tokensBalance: r.tokensBalance,
|
|
1659
1667
|
tokens: [],
|
|
1660
1668
|
sessions: {}
|
|
1661
1669
|
}
|
|
@@ -1707,8 +1715,8 @@ class N {
|
|
|
1707
1715
|
async rescanVaults() {
|
|
1708
1716
|
let e = !1;
|
|
1709
1717
|
const t = await this.discoveryService.discoverVaults(this.getMainAddresses().map((n) => n.address)), s = [];
|
|
1710
|
-
for (const [n,
|
|
1711
|
-
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)));
|
|
1712
1720
|
return await Promise.all(s), e;
|
|
1713
1721
|
}
|
|
1714
1722
|
isVaultAddress(e) {
|
|
@@ -1721,12 +1729,12 @@ class N {
|
|
|
1721
1729
|
return e.type == f.MAIN;
|
|
1722
1730
|
}
|
|
1723
1731
|
}
|
|
1724
|
-
const
|
|
1732
|
+
const rt = {
|
|
1725
1733
|
isWalletExist: !1,
|
|
1726
1734
|
isAuthorized: !1
|
|
1727
1735
|
}, we = M({
|
|
1728
1736
|
name: "auth",
|
|
1729
|
-
initialState:
|
|
1737
|
+
initialState: rt,
|
|
1730
1738
|
reducers: {
|
|
1731
1739
|
setWalletExist: (a, e) => {
|
|
1732
1740
|
a.isWalletExist = e.payload;
|
|
@@ -1735,12 +1743,12 @@ const st = {
|
|
|
1735
1743
|
a.isAuthorized = e.payload;
|
|
1736
1744
|
}
|
|
1737
1745
|
}
|
|
1738
|
-
}),
|
|
1746
|
+
}), Qt = we.actions, it = we.reducer, ot = {
|
|
1739
1747
|
modalType: null,
|
|
1740
1748
|
currentRequest: null
|
|
1741
1749
|
}, ve = M({
|
|
1742
1750
|
name: "dappModal",
|
|
1743
|
-
initialState:
|
|
1751
|
+
initialState: ot,
|
|
1744
1752
|
reducers: {
|
|
1745
1753
|
showRequest(a, e) {
|
|
1746
1754
|
a.modalType = e.payload.type, a.currentRequest = e.payload;
|
|
@@ -1749,24 +1757,24 @@ const st = {
|
|
|
1749
1757
|
a.modalType = null, a.currentRequest = null;
|
|
1750
1758
|
}
|
|
1751
1759
|
}
|
|
1752
|
-
}),
|
|
1760
|
+
}), es = ve.actions, ct = ve.reducer, dt = {
|
|
1753
1761
|
counter: 0,
|
|
1754
1762
|
loading: !1
|
|
1755
1763
|
}, Ae = M({
|
|
1756
1764
|
name: "loader",
|
|
1757
|
-
initialState:
|
|
1765
|
+
initialState: dt,
|
|
1758
1766
|
reducers: {
|
|
1759
1767
|
setLoader: (a, e) => {
|
|
1760
1768
|
const t = e.payload.loading ? a.counter + 1 : Math.max(0, a.counter - 1);
|
|
1761
1769
|
a.counter = t, a.loading = t > 0, a.text = e.payload.text;
|
|
1762
1770
|
}
|
|
1763
1771
|
}
|
|
1764
|
-
}),
|
|
1772
|
+
}), ts = Ae.actions, ut = Ae.reducer, lt = {
|
|
1765
1773
|
wallet: {},
|
|
1766
1774
|
web3: {}
|
|
1767
1775
|
}, Se = M({
|
|
1768
1776
|
name: "notifications",
|
|
1769
|
-
initialState:
|
|
1777
|
+
initialState: lt,
|
|
1770
1778
|
reducers: {
|
|
1771
1779
|
addNotification: (a, e) => {
|
|
1772
1780
|
e.payload.type == "wallet" ? a.wallet[e.payload.id] = e.payload : e.payload.type == "web3" && (a.web3[e.payload.id] = e.payload);
|
|
@@ -1778,16 +1786,16 @@ const st = {
|
|
|
1778
1786
|
e.payload === "wallet" ? a.wallet = {} : e.payload === "web3" ? a.web3 = {} : e.payload === "all" && (a.wallet = {}, a.web3 = {});
|
|
1779
1787
|
}
|
|
1780
1788
|
}
|
|
1781
|
-
}),
|
|
1789
|
+
}), ss = Se.actions, ht = Se.reducer, ft = {
|
|
1782
1790
|
status: "Offline",
|
|
1783
1791
|
height: 0,
|
|
1784
1792
|
price: me(),
|
|
1785
1793
|
hasNetwork: !0,
|
|
1786
1794
|
isSuspended: !1
|
|
1787
|
-
}, ce =
|
|
1795
|
+
}, ce = Ke("status/fetchPrice", async () => {
|
|
1788
1796
|
const a = me();
|
|
1789
1797
|
try {
|
|
1790
|
-
const e = await
|
|
1798
|
+
const e = await $e();
|
|
1791
1799
|
Object.keys(e).forEach((t) => {
|
|
1792
1800
|
a[t] = {
|
|
1793
1801
|
value: e[t],
|
|
@@ -1799,7 +1807,7 @@ const st = {
|
|
|
1799
1807
|
return a;
|
|
1800
1808
|
}), be = M({
|
|
1801
1809
|
name: "status",
|
|
1802
|
-
initialState:
|
|
1810
|
+
initialState: ft,
|
|
1803
1811
|
reducers: {
|
|
1804
1812
|
setHeight: (a, e) => {
|
|
1805
1813
|
e.payload > 0 && (a.status = "Online"), a.height = e.payload;
|
|
@@ -1821,7 +1829,7 @@ const st = {
|
|
|
1821
1829
|
console.error(t.error.message);
|
|
1822
1830
|
});
|
|
1823
1831
|
}
|
|
1824
|
-
}),
|
|
1832
|
+
}), as = be.actions, pt = be.reducer, gt = {
|
|
1825
1833
|
isAuthorized: !1,
|
|
1826
1834
|
selectedAccount: g,
|
|
1827
1835
|
accounts: {
|
|
@@ -1842,7 +1850,7 @@ const st = {
|
|
|
1842
1850
|
nftsUpdateTrigger: 0
|
|
1843
1851
|
}, ke = M({
|
|
1844
1852
|
name: "wallet",
|
|
1845
|
-
initialState:
|
|
1853
|
+
initialState: gt,
|
|
1846
1854
|
reducers: {
|
|
1847
1855
|
setInitLoad: (a, e) => {
|
|
1848
1856
|
a.initLoad = e.payload;
|
|
@@ -1898,108 +1906,108 @@ const st = {
|
|
|
1898
1906
|
a.accounts[e.payload.accountId].sessions = {};
|
|
1899
1907
|
}
|
|
1900
1908
|
}
|
|
1901
|
-
}),
|
|
1902
|
-
loader:
|
|
1903
|
-
dapp:
|
|
1904
|
-
status:
|
|
1905
|
-
wallet:
|
|
1906
|
-
auth:
|
|
1907
|
-
notifications:
|
|
1908
|
-
}, 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(
|
|
1909
1917
|
[(a) => a.notifications.wallet],
|
|
1910
1918
|
(a) => Object.values(a).sort((e, t) => t.createdAt - e.createdAt)
|
|
1911
1919
|
), Ie = j(
|
|
1912
1920
|
[(a) => a.notifications.web3],
|
|
1913
1921
|
(a) => Object.values(a).sort((e, t) => t.createdAt - e.createdAt)
|
|
1914
|
-
),
|
|
1922
|
+
), mt = j(
|
|
1915
1923
|
[Te, Ie],
|
|
1916
1924
|
(a, e) => [...a, ...e].sort((t, s) => s.createdAt - t.createdAt)
|
|
1917
|
-
),
|
|
1925
|
+
), ys = () => w(Te), ms = () => w(Ie), ws = () => w(mt);
|
|
1918
1926
|
export {
|
|
1919
1927
|
f as AccountType,
|
|
1920
|
-
|
|
1928
|
+
Jt as AssetService,
|
|
1921
1929
|
V as AssetType,
|
|
1922
|
-
|
|
1923
|
-
|
|
1930
|
+
Ht as KVStore,
|
|
1931
|
+
Ft as KeyManager,
|
|
1924
1932
|
m as KeySpace,
|
|
1925
1933
|
g as MAIN_WALLET_ID,
|
|
1926
1934
|
ne as MAX_INT64,
|
|
1927
1935
|
he as RostrumService,
|
|
1928
|
-
|
|
1936
|
+
Yt as SessionManager,
|
|
1929
1937
|
_ as SessionRequestType,
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
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,
|
|
1936
1944
|
N as WalletManager,
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1945
|
+
Qt as authActions,
|
|
1946
|
+
it as authReducer,
|
|
1947
|
+
Dt as capitalizeFirstLetter,
|
|
1940
1948
|
ye as currencies,
|
|
1941
1949
|
$ as currentTimestamp,
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
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,
|
|
1949
1957
|
ce as fetchPrice,
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1958
|
+
Wt as generateNewMnemonic,
|
|
1959
|
+
tt as generateVaultAddress,
|
|
1960
|
+
Ze as generateVaultConstraint,
|
|
1961
|
+
et as generateVaultVisibleArgs,
|
|
1954
1962
|
R as getAddressBuffer,
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1963
|
+
Xt as getCurrencySymbol,
|
|
1964
|
+
Pt as getExplorerUrl,
|
|
1965
|
+
Vt as getFileMediaType,
|
|
1966
|
+
Rt as getFileMimeType,
|
|
1967
|
+
$e as getNexaPrices,
|
|
1960
1968
|
fe as getNiftyToken,
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1969
|
+
Qe as getVaultConstraintHash,
|
|
1970
|
+
Xe as getVaultTemplate,
|
|
1971
|
+
Ye as getVaultTemplateHash,
|
|
1964
1972
|
me as initializePrices,
|
|
1965
|
-
|
|
1966
|
-
|
|
1973
|
+
Ct as isGenesisHashValid,
|
|
1974
|
+
We as isMnemonicValid,
|
|
1967
1975
|
q as isNiftySubgroup,
|
|
1968
1976
|
C as isNullOrEmpty,
|
|
1969
1977
|
T as isTestnet,
|
|
1970
1978
|
F as isValidNexaAddress,
|
|
1971
1979
|
x as keyPathToString,
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
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,
|
|
1982
1990
|
G as sumTokensBalance,
|
|
1983
1991
|
D as tokenAmountToAssetAmount,
|
|
1984
|
-
|
|
1992
|
+
re as tokenHexToAddr,
|
|
1985
1993
|
S as tokenIdToHex,
|
|
1986
1994
|
oe as transformTokenIconUrl,
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
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
|
|
2004
2012
|
};
|
|
2005
2013
|
//# sourceMappingURL=index.js.map
|