@otoplo/wallet-common 0.1.13 → 0.1.14
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 +315 -300
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/persistence/datastore/db.d.ts +39 -0
- package/dist/types/persistence/datastore/db.d.ts.map +1 -0
- package/dist/types/persistence/datastore/index.d.ts +3 -0
- package/dist/types/persistence/datastore/index.d.ts.map +1 -0
- package/dist/types/persistence/datastore/kv.d.ts +34 -0
- package/dist/types/persistence/datastore/kv.d.ts.map +1 -0
- package/dist/types/persistence/index.d.ts +3 -0
- package/dist/types/persistence/index.d.ts.map +1 -0
- package/dist/types/persistence/wallet-db.d.ts +61 -0
- package/dist/types/persistence/wallet-db.d.ts.map +1 -0
- package/dist/types/services/asset.d.ts +19 -0
- package/dist/types/services/asset.d.ts.map +1 -0
- package/dist/types/services/cache.d.ts +14 -0
- package/dist/types/services/cache.d.ts.map +1 -0
- package/dist/types/services/discovery.d.ts +14 -0
- package/dist/types/services/discovery.d.ts.map +1 -0
- package/dist/types/services/index.d.ts +9 -0
- package/dist/types/services/index.d.ts.map +1 -0
- package/dist/types/services/key.d.ts +13 -0
- package/dist/types/services/key.d.ts.map +1 -0
- package/dist/types/services/rostrum.d.ts +32 -0
- package/dist/types/services/rostrum.d.ts.map +1 -0
- package/dist/types/services/session.d.ts +48 -0
- package/dist/types/services/session.d.ts.map +1 -0
- package/dist/types/services/transaction.d.ts +41 -0
- package/dist/types/services/transaction.d.ts.map +1 -0
- package/dist/types/services/tx-transformer.d.ts +22 -0
- package/dist/types/services/tx-transformer.d.ts.map +1 -0
- package/dist/types/services/wallet.d.ts +101 -0
- package/dist/types/services/wallet.d.ts.map +1 -0
- package/dist/types/state/hooks.d.ts +16 -0
- package/dist/types/state/hooks.d.ts.map +1 -0
- package/dist/types/state/index.d.ts +4 -0
- package/dist/types/state/index.d.ts.map +1 -0
- package/dist/types/state/slices/auth.d.ts +17 -0
- package/dist/types/state/slices/auth.d.ts.map +1 -0
- package/dist/types/state/slices/dapp.d.ts +29 -0
- package/dist/types/state/slices/dapp.d.ts.map +1 -0
- package/dist/types/state/slices/index.d.ts +7 -0
- package/dist/types/state/slices/index.d.ts.map +1 -0
- package/dist/types/state/slices/loader.d.ts +15 -0
- package/dist/types/state/slices/loader.d.ts.map +1 -0
- package/dist/types/state/slices/notifications.d.ts +142 -0
- package/dist/types/state/slices/notifications.d.ts.map +1 -0
- package/dist/types/state/slices/status.d.ts +62 -0
- package/dist/types/state/slices/status.d.ts.map +1 -0
- package/dist/types/state/slices/wallet.d.ts +1032 -0
- package/dist/types/state/slices/wallet.d.ts.map +1 -0
- package/dist/types/state/store.d.ts +23 -0
- package/dist/types/state/store.d.ts.map +1 -0
- package/dist/types/types/dapp.types.d.ts +19 -0
- package/dist/types/types/dapp.types.d.ts.map +1 -0
- package/dist/types/types/db.types.d.ts +128 -0
- package/dist/types/types/db.types.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +6 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/notification.types.d.ts +21 -0
- package/dist/types/types/notification.types.d.ts.map +1 -0
- package/dist/types/types/rostrum.types.d.ts +145 -0
- package/dist/types/types/rostrum.types.d.ts.map +1 -0
- package/dist/types/types/wallet.types.d.ts +54 -0
- package/dist/types/types/wallet.types.d.ts.map +1 -0
- package/dist/types/utils/asset.d.ts +9 -0
- package/dist/types/utils/asset.d.ts.map +1 -0
- package/dist/types/utils/common.d.ts +27 -0
- package/dist/types/utils/common.d.ts.map +1 -0
- package/dist/types/utils/enums.d.ts +20 -0
- package/dist/types/utils/enums.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +8 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/keypath.d.ts +5 -0
- package/dist/types/utils/keypath.d.ts.map +1 -0
- package/dist/types/utils/price.d.ts +42 -0
- package/dist/types/utils/price.d.ts.map +1 -0
- package/dist/types/utils/seed.d.ts +5 -0
- package/dist/types/utils/seed.d.ts.map +1 -0
- package/dist/types/utils/vault.d.ts +8 -0
- package/dist/types/utils/vault.d.ts.map +1 -0
- package/package.json +7 -6
- package/src/index.ts +1 -1
- package/src/utils/common.ts +20 -1
- package/dist/index.d.ts +0 -2305
package/dist/index.js
CHANGED
|
@@ -1,69 +1,70 @@
|
|
|
1
|
-
import { AddressType as E, Networks as k, Address as S, CommonUtils as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import _e from "
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
1
|
+
import { AddressType as E, Networks as k, Address as S, CommonUtils as $, BufferUtils as y, HDPrivateKey as Q, GroupToken as O, GroupIdType as I, TransactionBuilder as ee, Transaction as B, UnitUtils as te, Script as A, Opcode as v, Hash as D, ScriptOpcode as W, BNExtended as z, Output as Ne, TxSigner as se, SighashType as ae, ScriptFactory as xe, OutputSighashType as ne, BufferWriter as Ee } from "libnexa-ts";
|
|
2
|
+
import U from "js-big-decimal";
|
|
3
|
+
import { ElectrumClient as Me, TransportScheme as F, ConnectionStatus as Be } from "@otoplo/electrum-client";
|
|
4
|
+
import { mnemonicToSeedSync as Ce, generateMnemonic as Pe, validateMnemonic as _e } from "@scure/bip39";
|
|
5
|
+
import Oe from "jszip";
|
|
6
|
+
import { DAppProvider as Ue } from "wallet-comms-sdk";
|
|
7
|
+
import { wordlist as ue } from "@scure/bip39/wordlists/english.js";
|
|
8
|
+
import { createSlice as M, createAsyncThunk as De, createSelector as j } from "@reduxjs/toolkit";
|
|
9
|
+
import { useSelector as Ve } from "react-redux";
|
|
10
|
+
const m = -1, ie = 9223372036854775807n, Re = 274710, It = "0014461ad25081cb0119d034385ff154c8d3ad6bdd76";
|
|
10
11
|
function T() {
|
|
11
12
|
return k.defaultNetwork == k.testnet;
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
+
function Nt(a) {
|
|
14
15
|
return T() ? a == "508c843a4b98fb25f57cf9ebafb245a5c16468f06519cdd467059a91e7b79d52" : a == "edc7144fe1ba4edd0edf35d7eea90f6cb1dba42314aa85da8207e97c5339c801";
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
+
function G(a, e = E.PayToScriptTemplate) {
|
|
17
18
|
return S.isValid(a, k.defaultNetwork, e);
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function xt() {
|
|
20
21
|
return `https://${T() ? "testnet-" : ""}explorer.nexa.org`;
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function X() {
|
|
23
24
|
return Math.floor(Date.now() / 1e3);
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function Et(a, e) {
|
|
26
27
|
const t = (e - a) * 2, s = /* @__PURE__ */ new Date();
|
|
27
28
|
return s.setMinutes(s.getMinutes() + t), s.toLocaleDateString();
|
|
28
29
|
}
|
|
29
30
|
function P(a) {
|
|
30
31
|
return !a || a.length === 0;
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
+
function Mt(a, e = 0) {
|
|
33
34
|
if (!a || a.length <= e)
|
|
34
35
|
return a || "";
|
|
35
36
|
const t = "...", s = Math.floor((e - t.length) / 2), n = a.slice(0, s), i = a.slice(a.length - s);
|
|
36
37
|
return n + t + i;
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
+
function Bt(a) {
|
|
39
40
|
return a.length === 0 ? "" : a.charAt(0).toUpperCase() + a.substring(1);
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
42
|
+
function H(a) {
|
|
43
|
+
return $.isHexa(a) ? y.hexToBuffer(a) : S.fromString(a).data;
|
|
43
44
|
}
|
|
44
45
|
function b(a) {
|
|
45
|
-
return
|
|
46
|
+
return $.isHexa(a) ? a : y.bufferToHex(H(a));
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
-
return
|
|
48
|
+
function re(a) {
|
|
49
|
+
return $.isHexa(a) ? new S(H(a), k.defaultNetwork, E.GroupIdAddress).toString() : a;
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
+
function V(a) {
|
|
51
52
|
return a == null || a === "" ? "" : BigInt(a) <= 0n ? "0" : a.toString();
|
|
52
53
|
}
|
|
53
|
-
function
|
|
54
|
+
function oe(a) {
|
|
54
55
|
let e = BigInt(0), t = BigInt(0);
|
|
55
56
|
return a.forEach((s) => {
|
|
56
57
|
e += BigInt(s.confirmed), t += BigInt(s.unconfirmed);
|
|
57
58
|
}), { confirmed: e.toString(), unconfirmed: t.toString() };
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
+
function J(a) {
|
|
60
61
|
const e = {};
|
|
61
62
|
return a.forEach((t) => {
|
|
62
63
|
for (const s in t)
|
|
63
64
|
e[s] ? (e[s].confirmed = (BigInt(e[s].confirmed) + BigInt(t[s].confirmed)).toString(), e[s].unconfirmed = (BigInt(e[s].unconfirmed) + BigInt(t[s].unconfirmed)).toString()) : e[s] = { confirmed: BigInt(t[s].confirmed).toString(), unconfirmed: BigInt(t[s].unconfirmed).toString() };
|
|
64
65
|
}), e;
|
|
65
66
|
}
|
|
66
|
-
const
|
|
67
|
+
const le = {
|
|
67
68
|
// Images
|
|
68
69
|
//'.svg': { media: 'image', mime: 'image/svg+xml' },
|
|
69
70
|
".gif": { media: "image", mime: "image/gif" },
|
|
@@ -86,19 +87,30 @@ const ue = {
|
|
|
86
87
|
".wav": { media: "audio", mime: "audio/wav" },
|
|
87
88
|
".m4a": { media: "audio", mime: "audio/mp4" }
|
|
88
89
|
};
|
|
89
|
-
function
|
|
90
|
+
function Ct(a) {
|
|
90
91
|
const e = a.lastIndexOf(".");
|
|
91
92
|
if (e === -1) return "unknown";
|
|
92
93
|
const t = a.slice(e).toLowerCase();
|
|
93
|
-
return
|
|
94
|
+
return le[t]?.media ?? "unknown";
|
|
94
95
|
}
|
|
95
|
-
function
|
|
96
|
+
function Pt(a) {
|
|
96
97
|
const e = a.lastIndexOf(".");
|
|
97
98
|
if (e === -1) return "application/octet-stream";
|
|
98
99
|
const t = a.slice(e).toLowerCase();
|
|
99
|
-
return
|
|
100
|
+
return le[t]?.mime ?? "application/octet-stream";
|
|
101
|
+
}
|
|
102
|
+
function _t(a) {
|
|
103
|
+
return new Promise((e) => setTimeout(e, a));
|
|
104
|
+
}
|
|
105
|
+
function He(a) {
|
|
106
|
+
let e = U.getPrettyValue(a);
|
|
107
|
+
return e.match(/\./) && (e = e.replace(/\.?0+$/, "")), e;
|
|
108
|
+
}
|
|
109
|
+
function Ot(a, e, t = !1) {
|
|
110
|
+
const s = U.multiply(a, e), n = U.round(s, 2, U.RoundingModes.HALF_DOWN);
|
|
111
|
+
return t ? He(n) : n;
|
|
100
112
|
}
|
|
101
|
-
class
|
|
113
|
+
class Ut {
|
|
102
114
|
getPrefix() {
|
|
103
115
|
return T() ? "testnet-" : "";
|
|
104
116
|
}
|
|
@@ -183,8 +195,8 @@ class Ct {
|
|
|
183
195
|
await this.setValue("auto-lock", `${e}`);
|
|
184
196
|
}
|
|
185
197
|
}
|
|
186
|
-
var f = /* @__PURE__ */ ((a) => (a[a.MAIN = 0] = "MAIN", a[a.VAULT = 1] = "VAULT", a[a.DAPP = 2] = "DAPP", a))(f || {}),
|
|
187
|
-
class
|
|
198
|
+
var f = /* @__PURE__ */ ((a) => (a[a.MAIN = 0] = "MAIN", a[a.VAULT = 1] = "VAULT", a[a.DAPP = 2] = "DAPP", a))(f || {}), g = /* @__PURE__ */ ((a) => (a[a.RECEIVE = 0] = "RECEIVE", a[a.CHANGE = 1] = "CHANGE", a))(g || {}), C = /* @__PURE__ */ ((a) => (a.SignMessage = "signMessage", a.AddToken = "addToken", a.SignTransaction = "signTransaction", a.SendTransaction = "sendTransaction", a))(C || {}), R = /* @__PURE__ */ ((a) => (a.TOKEN = "token", a.NFT = "nft", a))(R || {});
|
|
199
|
+
class Dt {
|
|
188
200
|
store;
|
|
189
201
|
updateCallback;
|
|
190
202
|
constructor(e) {
|
|
@@ -228,8 +240,8 @@ class Mt {
|
|
|
228
240
|
const s = {
|
|
229
241
|
accountId: e,
|
|
230
242
|
tokenIdHex: t.tokenIdHex,
|
|
231
|
-
type:
|
|
232
|
-
addedTime:
|
|
243
|
+
type: R.TOKEN,
|
|
244
|
+
addedTime: X()
|
|
233
245
|
};
|
|
234
246
|
await this.store.upsertAsset(s), await this.store.upsertToken(t), this.notify({ type: "token_added", accountId: e, token: s });
|
|
235
247
|
}
|
|
@@ -358,7 +370,7 @@ class Mt {
|
|
|
358
370
|
return this.store.upsertVault(t);
|
|
359
371
|
}
|
|
360
372
|
}
|
|
361
|
-
class
|
|
373
|
+
class Vt {
|
|
362
374
|
walletDb;
|
|
363
375
|
tokens = /* @__PURE__ */ new Map();
|
|
364
376
|
nfts = /* @__PURE__ */ new Map();
|
|
@@ -387,7 +399,7 @@ class Pt {
|
|
|
387
399
|
this.nfts.delete(b(e));
|
|
388
400
|
}
|
|
389
401
|
}
|
|
390
|
-
class
|
|
402
|
+
class he {
|
|
391
403
|
kvStore;
|
|
392
404
|
client;
|
|
393
405
|
constructor(e) {
|
|
@@ -463,7 +475,7 @@ class le {
|
|
|
463
475
|
}
|
|
464
476
|
async connect(e) {
|
|
465
477
|
try {
|
|
466
|
-
e || (e = await this.getCurrentInstance()), this.client = new
|
|
478
|
+
e || (e = await this.getCurrentInstance()), this.client = new Me("com.otoplo.wallet", "1.4.3", e.host, e.port, e.scheme, 45 * 1e3, 10 * 1e3), await this.client.connect();
|
|
467
479
|
} catch (t) {
|
|
468
480
|
throw t instanceof Error ? console.info(t.message) : console.error(t), t;
|
|
469
481
|
}
|
|
@@ -497,25 +509,25 @@ class le {
|
|
|
497
509
|
}
|
|
498
510
|
async getCurrentInstance() {
|
|
499
511
|
const e = await this.kvStore.getRostrumParams();
|
|
500
|
-
return e ||
|
|
512
|
+
return e || he.getPredefinedInstances()[0];
|
|
501
513
|
}
|
|
502
514
|
static getPredefinedInstances() {
|
|
503
515
|
return T() ? [
|
|
504
516
|
{
|
|
505
|
-
scheme:
|
|
517
|
+
scheme: F.WSS,
|
|
506
518
|
host: "testnet-electrum.nexa.org",
|
|
507
519
|
port: 30004,
|
|
508
520
|
label: "NexaOrg"
|
|
509
521
|
}
|
|
510
522
|
] : [
|
|
511
523
|
{
|
|
512
|
-
scheme:
|
|
524
|
+
scheme: F.WSS,
|
|
513
525
|
host: "rostrum.otoplo.com",
|
|
514
526
|
port: 443,
|
|
515
527
|
label: "Otoplo"
|
|
516
528
|
},
|
|
517
529
|
{
|
|
518
|
-
scheme:
|
|
530
|
+
scheme: F.WSS,
|
|
519
531
|
host: "electrum.nexa.org",
|
|
520
532
|
port: 20004,
|
|
521
533
|
label: "NexaOrg"
|
|
@@ -523,10 +535,10 @@ class le {
|
|
|
523
535
|
];
|
|
524
536
|
}
|
|
525
537
|
}
|
|
526
|
-
function
|
|
538
|
+
function N(a, e, t) {
|
|
527
539
|
return `${a}'/${e}/${t}`;
|
|
528
540
|
}
|
|
529
|
-
function
|
|
541
|
+
function Ke(a) {
|
|
530
542
|
const e = a.split("/");
|
|
531
543
|
return {
|
|
532
544
|
account: parseInt(e[0].replace("'", "")),
|
|
@@ -534,34 +546,34 @@ function Re(a) {
|
|
|
534
546
|
index: parseInt(e[2])
|
|
535
547
|
};
|
|
536
548
|
}
|
|
537
|
-
class
|
|
549
|
+
class Rt {
|
|
538
550
|
seed;
|
|
539
551
|
masterKey;
|
|
540
552
|
accountKeys = /* @__PURE__ */ new Map();
|
|
541
553
|
walletKeys = /* @__PURE__ */ new Map();
|
|
542
554
|
init(e) {
|
|
543
|
-
this.seed = typeof e == "string" ? Ce(e) : e, this.masterKey =
|
|
555
|
+
this.seed = typeof e == "string" ? Ce(e) : e, this.masterKey = Q.fromSeed(this.seed).deriveChild(44, !0).deriveChild(29223, !0);
|
|
544
556
|
}
|
|
545
557
|
reset() {
|
|
546
558
|
if (!this.seed)
|
|
547
559
|
throw new Error("KeysManager not initialized");
|
|
548
|
-
this.masterKey =
|
|
560
|
+
this.masterKey = Q.fromSeed(this.seed).deriveChild(44, !0).deriveChild(29223, !0), this.accountKeys.clear(), this.walletKeys.clear();
|
|
549
561
|
}
|
|
550
562
|
getAccountKey(e) {
|
|
551
563
|
let t = this.accountKeys.get(e);
|
|
552
564
|
return t || (t = this.masterKey.deriveChild(e, !0), this.accountKeys.set(e, t)), t;
|
|
553
565
|
}
|
|
554
566
|
getKey(e) {
|
|
555
|
-
const t = typeof e == "string" ? e :
|
|
567
|
+
const t = typeof e == "string" ? e : N(e.account, e.type, e.index);
|
|
556
568
|
let s = this.walletKeys.get(t);
|
|
557
569
|
if (!s) {
|
|
558
|
-
const { account: n, type: i, index: o } = typeof e == "string" ?
|
|
570
|
+
const { account: n, type: i, index: o } = typeof e == "string" ? Ke(e) : e;
|
|
559
571
|
s = this.getAccountKey(n).deriveChild(i, !1).deriveChild(o, !1), this.walletKeys.set(t, s);
|
|
560
572
|
}
|
|
561
573
|
return s;
|
|
562
574
|
}
|
|
563
575
|
}
|
|
564
|
-
function
|
|
576
|
+
function fe() {
|
|
565
577
|
return {
|
|
566
578
|
name: "NiftyArt",
|
|
567
579
|
ticker: "NIFTY",
|
|
@@ -572,36 +584,36 @@ function he() {
|
|
|
572
584
|
decimals: 0
|
|
573
585
|
};
|
|
574
586
|
}
|
|
575
|
-
function
|
|
576
|
-
return
|
|
587
|
+
function Ht(a) {
|
|
588
|
+
return Z(Ge() + a, "raw");
|
|
577
589
|
}
|
|
578
|
-
function
|
|
590
|
+
function q(a) {
|
|
579
591
|
try {
|
|
580
|
-
const e =
|
|
581
|
-
return O.isSubgroup(e) ? y.bufferToHex(e.subarray(0, 32)) ===
|
|
592
|
+
const e = H(a);
|
|
593
|
+
return O.isSubgroup(e) ? y.bufferToHex(e.subarray(0, 32)) === fe().tokenIdHex : !1;
|
|
582
594
|
} catch {
|
|
583
595
|
return !1;
|
|
584
596
|
}
|
|
585
597
|
}
|
|
586
|
-
function
|
|
587
|
-
return a =
|
|
598
|
+
function Le(a) {
|
|
599
|
+
return a = Y(a), Z(a, "json");
|
|
588
600
|
}
|
|
589
|
-
function
|
|
590
|
-
return a =
|
|
601
|
+
function Fe(a) {
|
|
602
|
+
return a = Y(a), Z(a, "raw");
|
|
591
603
|
}
|
|
592
|
-
function
|
|
604
|
+
function ce(a, e) {
|
|
593
605
|
return a && typeof a == "string" ? a.startsWith("http") ? a.replace("http://", "https://") : a.startsWith("ipfs://") ? a : `${new URL(e).origin}${a}` : "";
|
|
594
606
|
}
|
|
595
|
-
function
|
|
596
|
-
return a ?
|
|
607
|
+
function Kt(a) {
|
|
608
|
+
return a ? Y(a) : null;
|
|
597
609
|
}
|
|
598
|
-
function
|
|
610
|
+
function Y(a, e = "https://ipfs.nebula.markets/") {
|
|
599
611
|
return a?.startsWith("ipfs://") ? e + a.substring(7) : a;
|
|
600
612
|
}
|
|
601
|
-
function
|
|
613
|
+
function Ge() {
|
|
602
614
|
return `https://${T() ? "testnet." : ""}niftyart.cash/_public/`;
|
|
603
615
|
}
|
|
604
|
-
async function
|
|
616
|
+
async function Z(a, e) {
|
|
605
617
|
try {
|
|
606
618
|
const t = await fetch(a);
|
|
607
619
|
if (!t.ok)
|
|
@@ -615,7 +627,7 @@ async function Y(a, e) {
|
|
|
615
627
|
throw new Error(`Unexpected Error: ${t}`);
|
|
616
628
|
}
|
|
617
629
|
}
|
|
618
|
-
class
|
|
630
|
+
class Lt {
|
|
619
631
|
walletDb;
|
|
620
632
|
rostrumService;
|
|
621
633
|
walletCache;
|
|
@@ -631,19 +643,19 @@ class Dt {
|
|
|
631
643
|
}
|
|
632
644
|
const s = await this.rostrumService.getTokenGenesis(e), n = y.hexToBuffer(s.token_id_hex);
|
|
633
645
|
let i = "", o = "";
|
|
634
|
-
if (s.op_return_id == I.NRC2 || s.op_return_id == I.NRC3 ||
|
|
646
|
+
if (s.op_return_id == I.NRC2 || s.op_return_id == I.NRC3 || q(e))
|
|
635
647
|
return;
|
|
636
648
|
if (O.isSubgroup(n) && (i = new S(O.getParentGroupId(n), k.defaultNetwork, E.GroupIdAddress).toString()), s.document_url)
|
|
637
649
|
try {
|
|
638
650
|
if (s.op_return_id == I.NRC1) {
|
|
639
|
-
const c = await
|
|
651
|
+
const c = await Fe(s.document_url), u = (await Oe.loadAsync(c)).file("info.json");
|
|
640
652
|
if (u) {
|
|
641
653
|
const l = await u.async("string"), h = JSON.parse(l);
|
|
642
|
-
o =
|
|
654
|
+
o = ce(h[0]?.icon, s.document_url);
|
|
643
655
|
}
|
|
644
656
|
} else {
|
|
645
|
-
const c = await
|
|
646
|
-
o =
|
|
657
|
+
const c = await Le(s.document_url);
|
|
658
|
+
o = ce(c[0]?.icon, s.document_url);
|
|
647
659
|
}
|
|
648
660
|
} catch (c) {
|
|
649
661
|
console.error("Failed to load metadata", c);
|
|
@@ -664,7 +676,7 @@ class Dt {
|
|
|
664
676
|
}
|
|
665
677
|
async isNftToken(e) {
|
|
666
678
|
try {
|
|
667
|
-
if (
|
|
679
|
+
if (q(e) || await this.walletCache.getNftById(e) || (await this.rostrumService.getTokenGenesis(e)).op_return_id == I.NRC3)
|
|
668
680
|
return !0;
|
|
669
681
|
} catch (t) {
|
|
670
682
|
console.error(t);
|
|
@@ -674,7 +686,7 @@ class Dt {
|
|
|
674
686
|
async getAssetInfo(e) {
|
|
675
687
|
let t = await this.getTokenInfo(e);
|
|
676
688
|
return t || await this.isNftToken(e) && (t = {
|
|
677
|
-
token:
|
|
689
|
+
token: re(e),
|
|
678
690
|
tokenIdHex: b(e),
|
|
679
691
|
decimals: 0
|
|
680
692
|
}), t;
|
|
@@ -684,7 +696,7 @@ class Dt {
|
|
|
684
696
|
const o = {
|
|
685
697
|
accountId: e,
|
|
686
698
|
tokenIdHex: t,
|
|
687
|
-
type:
|
|
699
|
+
type: R.NFT,
|
|
688
700
|
addedTime: s
|
|
689
701
|
};
|
|
690
702
|
await this.walletDb.saveAsset(o, !0);
|
|
@@ -692,12 +704,12 @@ class Dt {
|
|
|
692
704
|
}
|
|
693
705
|
const i = await this.rostrumService.getTokenGenesis(t);
|
|
694
706
|
if (i.op_return_id == I.NRC3) {
|
|
695
|
-
const o =
|
|
707
|
+
const o = H(t);
|
|
696
708
|
if (O.isSubgroup(o)) {
|
|
697
709
|
const r = new S(o.subarray(0, 32), k.defaultNetwork, E.GroupIdAddress).toString(), c = await this.rostrumService.getTokenGenesis(r);
|
|
698
710
|
c?.op_return_id == I.NRC2 && await this.saveNft(e, t, i.document_url ?? "", r, s, c?.name ?? "");
|
|
699
711
|
}
|
|
700
|
-
} else
|
|
712
|
+
} else q(t) && await this.saveNft(e, t, "nifty", fe().token, s, "");
|
|
701
713
|
}
|
|
702
714
|
async saveNft(e, t, s, n, i, o) {
|
|
703
715
|
if (s)
|
|
@@ -705,11 +717,11 @@ class Dt {
|
|
|
705
717
|
const r = {
|
|
706
718
|
accountId: e,
|
|
707
719
|
tokenIdHex: t,
|
|
708
|
-
type:
|
|
720
|
+
type: R.NFT,
|
|
709
721
|
addedTime: i
|
|
710
722
|
}, c = {
|
|
711
723
|
parentGroup: n,
|
|
712
|
-
token:
|
|
724
|
+
token: re(t),
|
|
713
725
|
tokenIdHex: t,
|
|
714
726
|
source: s,
|
|
715
727
|
collection: o
|
|
@@ -733,11 +745,11 @@ class Dt {
|
|
|
733
745
|
await i(r.tokenIdHex);
|
|
734
746
|
for (const [r, c] of Object.entries(t)) {
|
|
735
747
|
const d = b(r), u = c && BigInt(c.confirmed) + BigInt(c.unconfirmed) > 0n, l = n?.some((p) => p.tokenIdHex == d);
|
|
736
|
-
!u && !l || u && l || !await this.isNftToken(d) || (!u && l ? await i(d) : await this.handleNftReceive(e, d,
|
|
748
|
+
!u && !l || u && l || !await this.isNftToken(d) || (!u && l ? await i(d) : await this.handleNftReceive(e, d, X()));
|
|
737
749
|
}
|
|
738
750
|
}
|
|
739
751
|
}
|
|
740
|
-
class
|
|
752
|
+
class Ft {
|
|
741
753
|
rostrumService;
|
|
742
754
|
keyManager;
|
|
743
755
|
walletDb;
|
|
@@ -756,7 +768,7 @@ class Vt {
|
|
|
756
768
|
return { txs: i, lastHeight: s };
|
|
757
769
|
}
|
|
758
770
|
async fetchVaultTransactions(e) {
|
|
759
|
-
const t = await this.rostrumService.getTransactionsHistory(e,
|
|
771
|
+
const t = await this.rostrumService.getTransactionsHistory(e, Re), s = [];
|
|
760
772
|
for (const n of t) {
|
|
761
773
|
const i = this.classifyTransaction(n.tx_hash, [e]);
|
|
762
774
|
s.push(i);
|
|
@@ -789,7 +801,7 @@ class Vt {
|
|
|
789
801
|
address: l.addresses[0],
|
|
790
802
|
nexaAmount: l.value_satoshi.toString(),
|
|
791
803
|
assetId: l.token_id_hex ?? "",
|
|
792
|
-
assetAmount:
|
|
804
|
+
assetAmount: V(l.groupQuantity)
|
|
793
805
|
};
|
|
794
806
|
t.includes(h.address) ? n.push(h) : i.push(h);
|
|
795
807
|
}
|
|
@@ -799,7 +811,7 @@ class Vt {
|
|
|
799
811
|
address: l.scriptPubKey.addresses[0],
|
|
800
812
|
nexaAmount: l.value_satoshi.toString(),
|
|
801
813
|
assetId: l.scriptPubKey.token_id_hex ?? "",
|
|
802
|
-
assetAmount:
|
|
814
|
+
assetAmount: V(l.scriptPubKey.groupQuantity)
|
|
803
815
|
};
|
|
804
816
|
t.includes(h.address) ? o.push(h) : r.push(h);
|
|
805
817
|
}
|
|
@@ -811,7 +823,7 @@ class Vt {
|
|
|
811
823
|
// Will be set in classifyAndSaveTransaction
|
|
812
824
|
txId: s.txid,
|
|
813
825
|
txIdem: s.txidem,
|
|
814
|
-
time: d ? s.time :
|
|
826
|
+
time: d ? s.time : X(),
|
|
815
827
|
height: d ? s.height : 0,
|
|
816
828
|
type: c,
|
|
817
829
|
fee: s.fee_satoshi.toString(),
|
|
@@ -834,23 +846,23 @@ class Vt {
|
|
|
834
846
|
const n = {
|
|
835
847
|
isConsolidate: !0,
|
|
836
848
|
templateData: s
|
|
837
|
-
}, i = new
|
|
849
|
+
}, i = new ee(), o = await this.populateNexaInputsAndChange(i, e, t, n);
|
|
838
850
|
return this.finalizeTransaction(i, Array.from(o.values()));
|
|
839
851
|
}
|
|
840
852
|
prepareTransaction(e, t, s, n) {
|
|
841
|
-
if (!
|
|
853
|
+
if (!G(e) && !G(e, E.PayToPublicKeyHash))
|
|
842
854
|
throw new Error("Invalid Address.");
|
|
843
|
-
if (s && BigInt(t) < 1n || !s && parseInt(t) <
|
|
855
|
+
if (s && BigInt(t) < 1n || !s && parseInt(t) < B.DUST_AMOUNT)
|
|
844
856
|
throw new Error("The amount is too low.");
|
|
845
|
-
if (s && BigInt(t) >
|
|
857
|
+
if (s && BigInt(t) > ie || !s && parseInt(t) > B.MAX_MONEY)
|
|
846
858
|
throw new Error("The amount is too high.");
|
|
847
|
-
const i = new
|
|
859
|
+
const i = new ee();
|
|
848
860
|
if (n && i.addData(n), s) {
|
|
849
|
-
if (!
|
|
861
|
+
if (!G(s, E.GroupIdAddress))
|
|
850
862
|
throw new Error("Invalid Token ID");
|
|
851
863
|
if (S.getOutputType(e) === 0)
|
|
852
864
|
throw new Error("Token must be sent to script template address");
|
|
853
|
-
i.to(e,
|
|
865
|
+
i.to(e, B.DUST_AMOUNT, s, BigInt(t));
|
|
854
866
|
} else
|
|
855
867
|
i.to(e, t);
|
|
856
868
|
return i;
|
|
@@ -884,13 +896,13 @@ class Vt {
|
|
|
884
896
|
if (_ < 0n)
|
|
885
897
|
continue;
|
|
886
898
|
if (_ == 0n && n.feeFromAmount) {
|
|
887
|
-
const
|
|
888
|
-
return p.updateOutputAmount(0, r -
|
|
899
|
+
const K = p.estimateRequiredFee();
|
|
900
|
+
return p.updateOutputAmount(0, r - K), o;
|
|
889
901
|
}
|
|
890
902
|
if (e.change(s), n.feeFromAmount) {
|
|
891
|
-
const
|
|
892
|
-
let
|
|
893
|
-
p.updateOutputAmount(0, r -
|
|
903
|
+
const K = p.getChangeOutput();
|
|
904
|
+
let L = p.estimateRequiredFee();
|
|
905
|
+
p.updateOutputAmount(0, r - L), !K && p.getChangeOutput() && (L = p.estimateRequiredFee(), p.updateOutputAmount(0, r - L));
|
|
894
906
|
}
|
|
895
907
|
if (p.getUnspentValue() < p.estimateRequiredFee())
|
|
896
908
|
continue;
|
|
@@ -905,8 +917,8 @@ class Vt {
|
|
|
905
917
|
}
|
|
906
918
|
const c = {
|
|
907
919
|
errorMsg: "Not enough Nexa balance.",
|
|
908
|
-
amount:
|
|
909
|
-
fee:
|
|
920
|
+
amount: te.formatNEXA(e.transaction.outputs[0].value),
|
|
921
|
+
fee: te.formatNEXA(e.transaction.estimateRequiredFee())
|
|
910
922
|
};
|
|
911
923
|
throw new Error(JSON.stringify(c));
|
|
912
924
|
}
|
|
@@ -930,14 +942,14 @@ class Vt {
|
|
|
930
942
|
const p = this.keyManager.getKey(u.keyPath);
|
|
931
943
|
c.set(u.address, p.privateKey);
|
|
932
944
|
}
|
|
933
|
-
if (d >
|
|
945
|
+
if (d > ie)
|
|
934
946
|
throw new Error("Token inputs exceeded max amount. Consider sending in small chunks");
|
|
935
947
|
if (e.transaction.inputs.length > this.MAX_INPUTS_OUTPUTS)
|
|
936
948
|
throw new Error("Too many inputs. Consider consolidating transactions or reduce the send amount.");
|
|
937
949
|
if (d == i)
|
|
938
950
|
return c;
|
|
939
951
|
if (d > i)
|
|
940
|
-
return e.to(s,
|
|
952
|
+
return e.to(s, B.DUST_AMOUNT, n, d - i), c;
|
|
941
953
|
}
|
|
942
954
|
}
|
|
943
955
|
throw new Error("Not enough token balance");
|
|
@@ -956,13 +968,13 @@ class Vt {
|
|
|
956
968
|
return JSON.stringify(t, null, 2);
|
|
957
969
|
}
|
|
958
970
|
}
|
|
959
|
-
function
|
|
960
|
-
return
|
|
971
|
+
function Gt(a = 12) {
|
|
972
|
+
return Pe(ue, a === 24 ? 256 : 128);
|
|
961
973
|
}
|
|
962
|
-
function
|
|
963
|
-
return
|
|
974
|
+
function Je(a) {
|
|
975
|
+
return _e(a, ue);
|
|
964
976
|
}
|
|
965
|
-
async function
|
|
977
|
+
async function pe(a, e) {
|
|
966
978
|
const t = await crypto.subtle.importKey(
|
|
967
979
|
"raw",
|
|
968
980
|
new Uint8Array(a),
|
|
@@ -986,8 +998,8 @@ async function fe(a, e) {
|
|
|
986
998
|
["encrypt", "decrypt"]
|
|
987
999
|
);
|
|
988
1000
|
}
|
|
989
|
-
async function
|
|
990
|
-
const t = y.utf8ToBuffer(e), s = y.getRandomBuffer(16), n = y.getRandomBuffer(12), i = y.utf8ToBuffer(a), o = await
|
|
1001
|
+
async function Jt(a, e) {
|
|
1002
|
+
const t = y.utf8ToBuffer(e), s = y.getRandomBuffer(16), n = y.getRandomBuffer(12), i = y.utf8ToBuffer(a), o = await pe(t, s), r = await crypto.subtle.encrypt(
|
|
991
1003
|
{
|
|
992
1004
|
name: "AES-GCM",
|
|
993
1005
|
iv: new Uint8Array(n)
|
|
@@ -997,8 +1009,8 @@ async function Ht(a, e) {
|
|
|
997
1009
|
), c = y.concat([s, n, new Uint8Array(r)]);
|
|
998
1010
|
return y.bufferToBase64(c);
|
|
999
1011
|
}
|
|
1000
|
-
async function
|
|
1001
|
-
const t = y.utf8ToBuffer(e), s = y.base64ToBuffer(a), n = s.slice(0, 16), i = s.slice(16, 28), o = s.slice(28), r = await
|
|
1012
|
+
async function qe(a, e) {
|
|
1013
|
+
const t = y.utf8ToBuffer(e), s = y.base64ToBuffer(a), n = s.slice(0, 16), i = s.slice(16, 28), o = s.slice(28), r = await pe(t, n), c = await crypto.subtle.decrypt(
|
|
1002
1014
|
{
|
|
1003
1015
|
name: "AES-GCM",
|
|
1004
1016
|
iv: i
|
|
@@ -1008,11 +1020,11 @@ async function Ge(a, e) {
|
|
|
1008
1020
|
);
|
|
1009
1021
|
return y.bufferToUtf8(new Uint8Array(c));
|
|
1010
1022
|
}
|
|
1011
|
-
async function
|
|
1023
|
+
async function qt(a, e) {
|
|
1012
1024
|
try {
|
|
1013
1025
|
if (a) {
|
|
1014
|
-
const t = await
|
|
1015
|
-
if (t &&
|
|
1026
|
+
const t = await qe(a, e);
|
|
1027
|
+
if (t && Je(t))
|
|
1016
1028
|
return t;
|
|
1017
1029
|
}
|
|
1018
1030
|
return !1;
|
|
@@ -1020,7 +1032,7 @@ async function Kt(a, e) {
|
|
|
1020
1032
|
return !1;
|
|
1021
1033
|
}
|
|
1022
1034
|
}
|
|
1023
|
-
const
|
|
1035
|
+
const ye = [
|
|
1024
1036
|
{ code: "usd", symbol: "$", name: "US Dollar" },
|
|
1025
1037
|
{ code: "eur", symbol: "€", name: "Euro" },
|
|
1026
1038
|
{ code: "gbp", symbol: "£", name: "British Pound" },
|
|
@@ -1029,48 +1041,48 @@ const pe = [
|
|
|
1029
1041
|
{ code: "aud", symbol: "A$", name: "Australian Dollar" },
|
|
1030
1042
|
{ code: "cad", symbol: "C$", name: "Canadian Dollar" },
|
|
1031
1043
|
{ code: "chf", symbol: "Fr", name: "Swiss Franc" }
|
|
1032
|
-
],
|
|
1033
|
-
|
|
1034
|
-
),
|
|
1035
|
-
async function
|
|
1036
|
-
const a =
|
|
1044
|
+
], We = Object.fromEntries(
|
|
1045
|
+
ye.map((a) => [a.code, a.symbol])
|
|
1046
|
+
), me = ye.map((a) => a.code);
|
|
1047
|
+
async function ze() {
|
|
1048
|
+
const a = me.join(","), e = await fetch(`https://api.coingecko.com/api/v3/simple/price?ids=nexacoin&include_24hr_change=true&vs_currencies=${a}`);
|
|
1037
1049
|
if (!e.ok)
|
|
1038
1050
|
throw new Error("Failed to fetch price");
|
|
1039
1051
|
return (await e.json()).nexacoin || {};
|
|
1040
1052
|
}
|
|
1041
|
-
function
|
|
1042
|
-
return
|
|
1053
|
+
function Wt(a) {
|
|
1054
|
+
return We[a] || a;
|
|
1043
1055
|
}
|
|
1044
1056
|
function ge() {
|
|
1045
1057
|
const a = {};
|
|
1046
|
-
return
|
|
1058
|
+
return me.forEach((e) => {
|
|
1047
1059
|
a[e] = { value: 0, change: 0 };
|
|
1048
1060
|
}), a;
|
|
1049
1061
|
}
|
|
1050
|
-
function
|
|
1062
|
+
function $e() {
|
|
1051
1063
|
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);
|
|
1052
1064
|
}
|
|
1053
|
-
function
|
|
1054
|
-
const a =
|
|
1055
|
-
return
|
|
1065
|
+
function je() {
|
|
1066
|
+
const a = $e();
|
|
1067
|
+
return D.sha256ripemd160(a.toBuffer());
|
|
1056
1068
|
}
|
|
1057
|
-
function
|
|
1069
|
+
function Xe(a) {
|
|
1058
1070
|
return A.empty().add(a.toBuffer());
|
|
1059
1071
|
}
|
|
1060
|
-
function
|
|
1061
|
-
const e =
|
|
1062
|
-
return
|
|
1072
|
+
function Ye(a) {
|
|
1073
|
+
const e = Xe(a);
|
|
1074
|
+
return D.sha256ripemd160(e.toBuffer());
|
|
1063
1075
|
}
|
|
1064
|
-
function
|
|
1065
|
-
return a.map((e) => e <= 16 ?
|
|
1076
|
+
function Ze(a) {
|
|
1077
|
+
return a.map((e) => e <= 16 ? W.smallInt(e) : z.fromNumber(e).toScriptNumBuffer());
|
|
1066
1078
|
}
|
|
1067
|
-
function
|
|
1079
|
+
function Qe(a, e) {
|
|
1068
1080
|
if (e.length !== 2)
|
|
1069
1081
|
return;
|
|
1070
|
-
const t =
|
|
1082
|
+
const t = je(), s = Ye(a), n = Ze(e);
|
|
1071
1083
|
return S.fromScriptTemplate(t, s, n).toString();
|
|
1072
1084
|
}
|
|
1073
|
-
class
|
|
1085
|
+
class zt {
|
|
1074
1086
|
walletDb;
|
|
1075
1087
|
keyManager;
|
|
1076
1088
|
providers;
|
|
@@ -1104,14 +1116,14 @@ class Ft {
|
|
|
1104
1116
|
}
|
|
1105
1117
|
async reload(e) {
|
|
1106
1118
|
for (const t of e.values()) {
|
|
1107
|
-
if (t.id ==
|
|
1119
|
+
if (t.id == m)
|
|
1108
1120
|
continue;
|
|
1109
1121
|
const s = await this.walletDb.getAccountSessions(t.id), n = this.providers.get(t.id), i = s.map(async (r) => {
|
|
1110
1122
|
if (n?.has(r.sessionId))
|
|
1111
1123
|
return;
|
|
1112
1124
|
let c;
|
|
1113
1125
|
try {
|
|
1114
|
-
c = new
|
|
1126
|
+
c = new Ue(r.uri);
|
|
1115
1127
|
const d = c.getSessionInfo();
|
|
1116
1128
|
await c.connect(3e3);
|
|
1117
1129
|
const u = await c.getAppInfo(2e3);
|
|
@@ -1177,8 +1189,8 @@ class Ft {
|
|
|
1177
1189
|
const n = (i, o) => new Promise((r, c) => {
|
|
1178
1190
|
this.handlers.set(i, { resolve: r, reject: c }), this.notify({ type: "new_request", request: { type: i, accountId: e.id, sessionId: s, request: o } });
|
|
1179
1191
|
});
|
|
1180
|
-
t.onSignMessage((i) => n(
|
|
1181
|
-
const i = { account: f.DAPP, type:
|
|
1192
|
+
t.onSignMessage((i) => n(C.SignMessage, i)), t.onAddToken((i) => n(C.AddToken, i)), t.onSendTransaction((i) => n(C.SendTransaction, i)), t.onSignTransaction((i) => n(C.SignTransaction, i)), t.onGetAccount(() => {
|
|
1193
|
+
const i = { account: f.DAPP, type: g.RECEIVE, index: e.id };
|
|
1182
1194
|
return {
|
|
1183
1195
|
name: e.name,
|
|
1184
1196
|
address: e.address,
|
|
@@ -1195,7 +1207,7 @@ class Ft {
|
|
|
1195
1207
|
});
|
|
1196
1208
|
}
|
|
1197
1209
|
}
|
|
1198
|
-
class
|
|
1210
|
+
class $t {
|
|
1199
1211
|
rostrumService;
|
|
1200
1212
|
keyManager;
|
|
1201
1213
|
assetService;
|
|
@@ -1212,7 +1224,7 @@ class Gt {
|
|
|
1212
1224
|
address: t.address,
|
|
1213
1225
|
privateKey: this.keyManager.getKey(t.keyPath).privateKey,
|
|
1214
1226
|
txDetails: {
|
|
1215
|
-
tx: new
|
|
1227
|
+
tx: new B(e),
|
|
1216
1228
|
send: [],
|
|
1217
1229
|
receive: []
|
|
1218
1230
|
},
|
|
@@ -1239,13 +1251,13 @@ class Gt {
|
|
|
1239
1251
|
const s = e.txDetails.tx.inputs[t], n = await this.rostrumService.getUtxo(y.bufferToHex(s.outpoint));
|
|
1240
1252
|
if (n.status == "spent")
|
|
1241
1253
|
throw new Error("Input UTXO is already spent.");
|
|
1242
|
-
if (s.output = new
|
|
1254
|
+
if (s.output = new Ne(n.amount, n.scriptpubkey), s.output.address == e.address) {
|
|
1243
1255
|
const i = n.token_id_hex || "NEXA";
|
|
1244
1256
|
e.myInputs.set(t, {
|
|
1245
1257
|
address: e.address,
|
|
1246
1258
|
nexaAmount: n.amount.toString(),
|
|
1247
1259
|
assetId: i,
|
|
1248
|
-
assetAmount:
|
|
1260
|
+
assetAmount: V(n.group_quantity) || n.amount.toString()
|
|
1249
1261
|
}), e.involvedAssets.add(i), s.scriptSig.isEmpty() && e.inputsToSign.add(t);
|
|
1250
1262
|
}
|
|
1251
1263
|
s.scriptSig.findPlaceholder() > 0 && e.inputsToSign.add(t);
|
|
@@ -1259,7 +1271,7 @@ class Gt {
|
|
|
1259
1271
|
address: s.address,
|
|
1260
1272
|
nexaAmount: s.value.toString(),
|
|
1261
1273
|
assetId: n,
|
|
1262
|
-
assetAmount:
|
|
1274
|
+
assetAmount: V(s.groupAmount) || s.value.toString()
|
|
1263
1275
|
};
|
|
1264
1276
|
e.involvedAssets.add(n), e.myOutputs.set(t, i);
|
|
1265
1277
|
}
|
|
@@ -1271,12 +1283,12 @@ class Gt {
|
|
|
1271
1283
|
const s = e.txDetails.tx.inputs[t], n = this.validateAndGetSubscript(s);
|
|
1272
1284
|
if (s.scriptSig.isEmpty()) {
|
|
1273
1285
|
e.allMyOutputsCovered = !0;
|
|
1274
|
-
const i =
|
|
1286
|
+
const i = se.sign(e.txDetails.tx, t, ae.ALL, n, e.privateKey).toTxFormat(), o = A.empty().add(e.privateKey.publicKey.toBuffer());
|
|
1275
1287
|
s.scriptSig = xe.buildScriptTemplateIn(void 0, o, A.empty().add(i));
|
|
1276
1288
|
} else {
|
|
1277
|
-
const i = s.scriptSig.findPlaceholder(), r = s.scriptSig.chunks[i].buf.subarray(64), c =
|
|
1289
|
+
const i = s.scriptSig.findPlaceholder(), r = s.scriptSig.chunks[i].buf.subarray(64), c = ae.fromBuffer(r);
|
|
1278
1290
|
this.processSignatureCoverage(e, c);
|
|
1279
|
-
const d =
|
|
1291
|
+
const d = se.sign(e.txDetails.tx, t, c, n, e.privateKey).toTxFormat(r);
|
|
1280
1292
|
s.scriptSig.replaceChunk(i, A.empty().add(d));
|
|
1281
1293
|
}
|
|
1282
1294
|
}
|
|
@@ -1293,7 +1305,7 @@ class Gt {
|
|
|
1293
1305
|
if (!e.scriptSig.isScriptTemplateIn())
|
|
1294
1306
|
throw new Error("Unsupported input script type.");
|
|
1295
1307
|
const t = e.output.scriptPubKey.getTemplateHash(), s = e.scriptSig.chunks[0].buf;
|
|
1296
|
-
if (y.equals(t,
|
|
1308
|
+
if (y.equals(t, D.sha256ripemd160(s)) || y.equals(t, D.sha256sha256(s)))
|
|
1297
1309
|
return A.fromBuffer(s);
|
|
1298
1310
|
throw new Error("Invalid input script template.");
|
|
1299
1311
|
}
|
|
@@ -1301,9 +1313,9 @@ class Gt {
|
|
|
1301
1313
|
}
|
|
1302
1314
|
processSignatureCoverage(e, t) {
|
|
1303
1315
|
if (!e.allMyOutputsCovered)
|
|
1304
|
-
if (t.outType ==
|
|
1316
|
+
if (t.outType == ne.TWO)
|
|
1305
1317
|
e.coveredOutputs.add(t.outData[0]), e.coveredOutputs.add(t.outData[1]), this.checkSignatureCoverage(e);
|
|
1306
|
-
else if (t.outType ==
|
|
1318
|
+
else if (t.outType == ne.FIRSTN) {
|
|
1307
1319
|
const s = t.outData[0];
|
|
1308
1320
|
for (let n = 0; n < s; n++)
|
|
1309
1321
|
e.coveredOutputs.add(n);
|
|
@@ -1335,8 +1347,8 @@ class Gt {
|
|
|
1335
1347
|
}
|
|
1336
1348
|
}
|
|
1337
1349
|
}
|
|
1338
|
-
const
|
|
1339
|
-
class
|
|
1350
|
+
const et = 274710, tt = "0014461ad25081cb0119d034385ff154c8d3ad6bdd76";
|
|
1351
|
+
class st {
|
|
1340
1352
|
rostrumService;
|
|
1341
1353
|
keyManager;
|
|
1342
1354
|
constructor(e, t) {
|
|
@@ -1369,16 +1381,16 @@ class et {
|
|
|
1369
1381
|
}), n;
|
|
1370
1382
|
}
|
|
1371
1383
|
async checkVaultsForAddress(e) {
|
|
1372
|
-
const t = /* @__PURE__ */ new Set(), s = await this.rostrumService.getTransactionsHistory(e,
|
|
1384
|
+
const t = /* @__PURE__ */ new Set(), s = await this.rostrumService.getTransactionsHistory(e, et);
|
|
1373
1385
|
for (const n of s) {
|
|
1374
|
-
const o = (await this.rostrumService.getTransaction(n.tx_hash)).vout.filter((r) => r.scriptPubKey.hex.startsWith(
|
|
1386
|
+
const o = (await this.rostrumService.getTransaction(n.tx_hash)).vout.filter((r) => r.scriptPubKey.hex.startsWith(tt));
|
|
1375
1387
|
for (const r of o)
|
|
1376
1388
|
t.add(r.scriptPubKey.hex);
|
|
1377
1389
|
}
|
|
1378
1390
|
return t;
|
|
1379
1391
|
}
|
|
1380
1392
|
parseVaultDetails(e) {
|
|
1381
|
-
const t = A.fromHex(e), s = new
|
|
1393
|
+
const t = A.fromHex(e), s = new Ee().writeVarLengthBuf(t.toBuffer()).toBuffer(), n = new S(s).toString(), i = t.getVisibleArgs(), o = z.fromScriptNumBuffer(i.chunks[0].buf).toNumber(), r = W.isSmallIntOp(i.chunks[1].opcodenum) ? W.decodeOP_N(i.chunks[1].opcodenum) : z.fromScriptNumBuffer(i.chunks[1].buf).toNumber(), c = [o, r], d = this.keyManager.getKey({ account: f.VAULT, type: g.RECEIVE, index: r }), u = Qe(d.publicKey, c);
|
|
1382
1394
|
return n != u ? void 0 : {
|
|
1383
1395
|
address: n,
|
|
1384
1396
|
block: o,
|
|
@@ -1391,9 +1403,9 @@ class et {
|
|
|
1391
1403
|
};
|
|
1392
1404
|
}
|
|
1393
1405
|
}
|
|
1394
|
-
class
|
|
1406
|
+
class x {
|
|
1395
1407
|
constructor(e, t, s, n, i, o, r) {
|
|
1396
|
-
this.keyManager = e, this.kvStore = t, this.walletDb = s, this.rostrumService = n, this.assetService = i, this.transactionService = o, this.sessionManager = r, this.discoveryService = new
|
|
1408
|
+
this.keyManager = e, this.kvStore = t, this.walletDb = s, this.rostrumService = n, this.assetService = i, this.transactionService = o, this.sessionManager = r, this.discoveryService = new st(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();
|
|
1397
1409
|
}
|
|
1398
1410
|
static GAP_LIMIT = 20;
|
|
1399
1411
|
static DEBOUNCE_MS = 1e3;
|
|
@@ -1422,22 +1434,22 @@ class N {
|
|
|
1422
1434
|
getReceiveAddress() {
|
|
1423
1435
|
return this.receiveAddresses.find((e) => !e.used).address;
|
|
1424
1436
|
}
|
|
1425
|
-
getChangeAddress(e =
|
|
1426
|
-
return e !=
|
|
1437
|
+
getChangeAddress(e = m) {
|
|
1438
|
+
return e != m ? this.accounts.get(e).address : this.changeAddresses.find((t) => !t.used).address;
|
|
1427
1439
|
}
|
|
1428
|
-
getUsedAddressKeys(e =
|
|
1429
|
-
if (e !=
|
|
1440
|
+
getUsedAddressKeys(e = m) {
|
|
1441
|
+
if (e != m) {
|
|
1430
1442
|
const t = this.accounts.get(e);
|
|
1431
1443
|
return [{
|
|
1432
1444
|
address: t.address,
|
|
1433
|
-
keyPath:
|
|
1445
|
+
keyPath: N(f.DAPP, 0, t.id),
|
|
1434
1446
|
balance: t.balance,
|
|
1435
1447
|
tokensBalance: t.tokensBalance
|
|
1436
1448
|
}];
|
|
1437
1449
|
}
|
|
1438
1450
|
return this.getMainAddresses().filter((t) => t.used).map((t) => ({
|
|
1439
1451
|
address: t.address,
|
|
1440
|
-
keyPath:
|
|
1452
|
+
keyPath: N(f.MAIN, t.space, t.idx),
|
|
1441
1453
|
balance: t.balance,
|
|
1442
1454
|
tokensBalance: t.tokensBalance
|
|
1443
1455
|
}));
|
|
@@ -1453,8 +1465,8 @@ class N {
|
|
|
1453
1465
|
}
|
|
1454
1466
|
async discoverWallet() {
|
|
1455
1467
|
this.notify({ type: "discover_wallet", loading: !0 });
|
|
1456
|
-
const e = this.discoveryService.discoverWalletIndex(f.MAIN,
|
|
1457
|
-
this.receiveAddresses = this.deriveAddresses(
|
|
1468
|
+
const e = this.discoveryService.discoverWalletIndex(f.MAIN, g.RECEIVE), t = this.discoveryService.discoverWalletIndex(f.MAIN, g.CHANGE), s = this.discoveryService.discoverWalletIndex(f.DAPP, g.RECEIVE), [n, i, o] = await Promise.all([e, t, s]);
|
|
1469
|
+
this.receiveAddresses = this.deriveAddresses(g.RECEIVE, 0, n + x.GAP_LIMIT), this.changeAddresses = this.deriveAddresses(g.CHANGE, 0, i + x.GAP_LIMIT), this.accounts = this.deriveAccounts(0, o + 1), this.accounts.forEach((r) => this.accountsAddressToId.set(r.address, r.id)), await this.saveAddresses(this.receiveAddresses), await this.saveAddresses(this.changeAddresses), await this.saveAccounts(this.accounts), this.initState(), await this.initialSync(), this.notify({ type: "discover_wallet", loading: !1 }), this.notify({ type: "load_wallet", loading: !1 }), await this.rescanVaults();
|
|
1458
1470
|
}
|
|
1459
1471
|
async loadWallet() {
|
|
1460
1472
|
this.receiveAddresses = await this.walletDb.getReceiveAddresses(), this.changeAddresses = await this.walletDb.getChangeAddresses();
|
|
@@ -1466,7 +1478,7 @@ class N {
|
|
|
1466
1478
|
async initialSync() {
|
|
1467
1479
|
await this.subscribeAddresses(this.getAllAddresses(), !0);
|
|
1468
1480
|
const e = [];
|
|
1469
|
-
e.push(this.assetService.fetchAndSaveTokens(
|
|
1481
|
+
e.push(this.assetService.fetchAndSaveTokens(m, J(this.getMainAddresses().map((t) => t.tokensBalance))));
|
|
1470
1482
|
for (const t of this.accounts.values())
|
|
1471
1483
|
e.push(this.assetService.fetchAndSaveTokens(t.id, t.tokensBalance));
|
|
1472
1484
|
await Promise.all(e);
|
|
@@ -1482,11 +1494,11 @@ class N {
|
|
|
1482
1494
|
this.notify({
|
|
1483
1495
|
type: "new_account",
|
|
1484
1496
|
account: {
|
|
1485
|
-
id:
|
|
1497
|
+
id: m,
|
|
1486
1498
|
name: "Main Wallet",
|
|
1487
1499
|
address: this.getReceiveAddress(),
|
|
1488
|
-
balance:
|
|
1489
|
-
tokensBalance:
|
|
1500
|
+
balance: oe(e.map((t) => t.balance)),
|
|
1501
|
+
tokensBalance: J(e.map((t) => t.tokensBalance)),
|
|
1490
1502
|
tokens: [],
|
|
1491
1503
|
sessions: {}
|
|
1492
1504
|
}
|
|
@@ -1518,7 +1530,7 @@ class N {
|
|
|
1518
1530
|
deriveAddresses(e, t, s) {
|
|
1519
1531
|
const n = [];
|
|
1520
1532
|
for (let i = t; i < t + s; i++) {
|
|
1521
|
-
const o =
|
|
1533
|
+
const o = N(f.MAIN, e, i), c = {
|
|
1522
1534
|
address: this.keyManager.getKey(o).privateKey.toAddress().toString(),
|
|
1523
1535
|
space: e,
|
|
1524
1536
|
idx: i,
|
|
@@ -1536,7 +1548,7 @@ class N {
|
|
|
1536
1548
|
deriveAccounts(e, t) {
|
|
1537
1549
|
const s = /* @__PURE__ */ new Map();
|
|
1538
1550
|
for (let n = e; n < e + t; n++) {
|
|
1539
|
-
const i =
|
|
1551
|
+
const i = N(f.DAPP, 0, n), o = this.keyManager.getKey(i).privateKey.toAddress().toString(), r = {
|
|
1540
1552
|
id: n,
|
|
1541
1553
|
name: `Account ${n + 1}`,
|
|
1542
1554
|
address: o,
|
|
@@ -1585,7 +1597,7 @@ class N {
|
|
|
1585
1597
|
registerUpdate(e) {
|
|
1586
1598
|
this.pendingUpdates.set(e.address.address, e), clearTimeout(this.updateTimer), this.updateTimer = setTimeout(() => {
|
|
1587
1599
|
this.processPendingUpdates();
|
|
1588
|
-
},
|
|
1600
|
+
}, x.DEBOUNCE_MS);
|
|
1589
1601
|
}
|
|
1590
1602
|
async processPendingUpdates() {
|
|
1591
1603
|
if (this.pendingUpdates.size !== 0)
|
|
@@ -1627,12 +1639,12 @@ class N {
|
|
|
1627
1639
|
for (const { txs: r } of e)
|
|
1628
1640
|
for (const c of r)
|
|
1629
1641
|
t.set(c.tx_hash, c);
|
|
1630
|
-
await this.checkGapLimit(
|
|
1631
|
-
const s = this.getMainAddresses(), n =
|
|
1632
|
-
this.notify({ type: "account_balance_updated", accountId:
|
|
1633
|
-
const o = this.assetService.syncNfts(
|
|
1642
|
+
await this.checkGapLimit(g.RECEIVE), await this.checkGapLimit(g.CHANGE);
|
|
1643
|
+
const s = this.getMainAddresses(), n = oe(s.map((r) => r.balance)), i = J(s.map((r) => r.tokensBalance));
|
|
1644
|
+
this.notify({ type: "account_balance_updated", accountId: m, balance: n, tokensBalance: i }), this.notify({ type: "main_address_updated", address: this.getReceiveAddress() });
|
|
1645
|
+
const o = this.assetService.syncNfts(m, i);
|
|
1634
1646
|
for (const r of t.values())
|
|
1635
|
-
await this.transactionService.classifyAndSaveTransaction(
|
|
1647
|
+
await this.transactionService.classifyAndSaveTransaction(m, r.tx_hash, s.map((c) => c.address));
|
|
1636
1648
|
await o;
|
|
1637
1649
|
}
|
|
1638
1650
|
async postProcessAccountUpdate(e) {
|
|
@@ -1662,16 +1674,16 @@ class N {
|
|
|
1662
1674
|
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 };
|
|
1663
1675
|
}
|
|
1664
1676
|
async checkGapLimit(e) {
|
|
1665
|
-
const t = e ===
|
|
1666
|
-
if (n <
|
|
1667
|
-
const i =
|
|
1677
|
+
const t = e === g.RECEIVE ? this.receiveAddresses : this.changeAddresses, s = e === g.RECEIVE ? "Receive" : "Change", n = t.filter((i) => !i.used).length;
|
|
1678
|
+
if (n < x.GAP_LIMIT) {
|
|
1679
|
+
const i = x.GAP_LIMIT - n, o = t[t.length - 1].idx;
|
|
1668
1680
|
console.log(`Deriving ${i} more ${s} addresses...`);
|
|
1669
1681
|
const r = this.deriveAddresses(e, o + 1, i);
|
|
1670
|
-
e ===
|
|
1682
|
+
e === g.RECEIVE ? this.receiveAddresses.push(...r) : this.changeAddresses.push(...r), await this.saveAddresses(r), await this.subscribeAddresses(r);
|
|
1671
1683
|
}
|
|
1672
1684
|
}
|
|
1673
1685
|
async addNewAccount(e, t) {
|
|
1674
|
-
const s =
|
|
1686
|
+
const s = N(f.DAPP, 0, e), n = this.keyManager.getKey(s).privateKey.toAddress().toString(), i = {
|
|
1675
1687
|
id: e,
|
|
1676
1688
|
name: t,
|
|
1677
1689
|
address: n,
|
|
@@ -1702,7 +1714,7 @@ class N {
|
|
|
1702
1714
|
s.name = t, await this.walletDb.updateAccountName(e, t);
|
|
1703
1715
|
}
|
|
1704
1716
|
rescanAccount(e) {
|
|
1705
|
-
if (e ==
|
|
1717
|
+
if (e == m) {
|
|
1706
1718
|
const t = this.getMainAddresses();
|
|
1707
1719
|
for (const s of t)
|
|
1708
1720
|
s.height = 0, this.registerUpdate({ address: s, result: s.statusHash });
|
|
@@ -1755,12 +1767,12 @@ class N {
|
|
|
1755
1767
|
return e.type == f.MAIN;
|
|
1756
1768
|
}
|
|
1757
1769
|
}
|
|
1758
|
-
const
|
|
1770
|
+
const at = {
|
|
1759
1771
|
isWalletExist: !1,
|
|
1760
1772
|
isAuthorized: !1
|
|
1761
|
-
},
|
|
1773
|
+
}, we = M({
|
|
1762
1774
|
name: "auth",
|
|
1763
|
-
initialState:
|
|
1775
|
+
initialState: at,
|
|
1764
1776
|
reducers: {
|
|
1765
1777
|
setWalletExist: (a, e) => {
|
|
1766
1778
|
a.isWalletExist = e.payload;
|
|
@@ -1769,12 +1781,12 @@ const tt = {
|
|
|
1769
1781
|
a.isAuthorized = e.payload;
|
|
1770
1782
|
}
|
|
1771
1783
|
}
|
|
1772
|
-
}),
|
|
1784
|
+
}), jt = we.actions, nt = we.reducer, it = {
|
|
1773
1785
|
modalType: null,
|
|
1774
1786
|
currentRequest: null
|
|
1775
|
-
},
|
|
1787
|
+
}, ve = M({
|
|
1776
1788
|
name: "dappModal",
|
|
1777
|
-
initialState:
|
|
1789
|
+
initialState: it,
|
|
1778
1790
|
reducers: {
|
|
1779
1791
|
showRequest(a, e) {
|
|
1780
1792
|
a.modalType = e.payload.type, a.currentRequest = e.payload;
|
|
@@ -1783,24 +1795,24 @@ const tt = {
|
|
|
1783
1795
|
a.modalType = null, a.currentRequest = null;
|
|
1784
1796
|
}
|
|
1785
1797
|
}
|
|
1786
|
-
}),
|
|
1798
|
+
}), Xt = ve.actions, rt = ve.reducer, ot = {
|
|
1787
1799
|
counter: 0,
|
|
1788
1800
|
loading: !1
|
|
1789
|
-
},
|
|
1801
|
+
}, Ae = M({
|
|
1790
1802
|
name: "loader",
|
|
1791
|
-
initialState:
|
|
1803
|
+
initialState: ot,
|
|
1792
1804
|
reducers: {
|
|
1793
1805
|
setLoader: (a, e) => {
|
|
1794
1806
|
const t = e.payload.loading ? a.counter + 1 : Math.max(0, a.counter - 1);
|
|
1795
1807
|
a.counter = t, a.loading = t > 0, a.text = e.payload.text;
|
|
1796
1808
|
}
|
|
1797
1809
|
}
|
|
1798
|
-
}),
|
|
1810
|
+
}), Yt = Ae.actions, ct = Ae.reducer, dt = {
|
|
1799
1811
|
wallet: {},
|
|
1800
1812
|
web3: {}
|
|
1801
|
-
},
|
|
1813
|
+
}, be = M({
|
|
1802
1814
|
name: "notifications",
|
|
1803
|
-
initialState:
|
|
1815
|
+
initialState: dt,
|
|
1804
1816
|
reducers: {
|
|
1805
1817
|
addNotification: (a, e) => {
|
|
1806
1818
|
e.payload.type == "wallet" ? a.wallet[e.payload.id] = e.payload : e.payload.type == "web3" && (a.web3[e.payload.id] = e.payload);
|
|
@@ -1812,16 +1824,16 @@ const tt = {
|
|
|
1812
1824
|
e.payload === "wallet" ? a.wallet = {} : e.payload === "web3" ? a.web3 = {} : e.payload === "all" && (a.wallet = {}, a.web3 = {});
|
|
1813
1825
|
}
|
|
1814
1826
|
}
|
|
1815
|
-
}),
|
|
1827
|
+
}), Zt = be.actions, ut = be.reducer, lt = {
|
|
1816
1828
|
status: "Offline",
|
|
1817
1829
|
height: 0,
|
|
1818
1830
|
price: ge(),
|
|
1819
1831
|
hasNetwork: !0,
|
|
1820
1832
|
isSuspended: !1
|
|
1821
|
-
},
|
|
1833
|
+
}, de = De("status/fetchPrice", async () => {
|
|
1822
1834
|
const a = ge();
|
|
1823
1835
|
try {
|
|
1824
|
-
const e = await
|
|
1836
|
+
const e = await ze();
|
|
1825
1837
|
Object.keys(e).forEach((t) => {
|
|
1826
1838
|
a[t] = {
|
|
1827
1839
|
value: e[t],
|
|
@@ -1831,9 +1843,9 @@ const tt = {
|
|
|
1831
1843
|
} catch {
|
|
1832
1844
|
}
|
|
1833
1845
|
return a;
|
|
1834
|
-
}),
|
|
1846
|
+
}), Se = M({
|
|
1835
1847
|
name: "status",
|
|
1836
|
-
initialState:
|
|
1848
|
+
initialState: lt,
|
|
1837
1849
|
reducers: {
|
|
1838
1850
|
setHeight: (a, e) => {
|
|
1839
1851
|
e.payload > 0 && (a.status = "Online"), a.height = e.payload;
|
|
@@ -1849,18 +1861,18 @@ const tt = {
|
|
|
1849
1861
|
}
|
|
1850
1862
|
},
|
|
1851
1863
|
extraReducers: (a) => {
|
|
1852
|
-
a.addCase(
|
|
1864
|
+
a.addCase(de.fulfilled, (e, t) => {
|
|
1853
1865
|
e.price = t.payload;
|
|
1854
|
-
}).addCase(
|
|
1866
|
+
}).addCase(de.rejected, (e, t) => {
|
|
1855
1867
|
console.error(t.error.message);
|
|
1856
1868
|
});
|
|
1857
1869
|
}
|
|
1858
|
-
}),
|
|
1870
|
+
}), Qt = Se.actions, ht = Se.reducer, ft = {
|
|
1859
1871
|
isAuthorized: !1,
|
|
1860
|
-
selectedAccount:
|
|
1872
|
+
selectedAccount: m,
|
|
1861
1873
|
accounts: {
|
|
1862
1874
|
"-1": {
|
|
1863
|
-
id:
|
|
1875
|
+
id: m,
|
|
1864
1876
|
name: "Main Wallet",
|
|
1865
1877
|
address: "",
|
|
1866
1878
|
balance: { confirmed: "0", unconfirmed: "0" },
|
|
@@ -1874,9 +1886,9 @@ const tt = {
|
|
|
1874
1886
|
initLoad: !0,
|
|
1875
1887
|
txUpdateTrigger: 0,
|
|
1876
1888
|
nftsUpdateTrigger: 0
|
|
1877
|
-
},
|
|
1889
|
+
}, ke = M({
|
|
1878
1890
|
name: "wallet",
|
|
1879
|
-
initialState:
|
|
1891
|
+
initialState: ft,
|
|
1880
1892
|
reducers: {
|
|
1881
1893
|
setInitLoad: (a, e) => {
|
|
1882
1894
|
a.initLoad = e.payload;
|
|
@@ -1897,7 +1909,7 @@ const tt = {
|
|
|
1897
1909
|
a.accounts[e.payload.id] = e.payload;
|
|
1898
1910
|
},
|
|
1899
1911
|
setMainAddress: (a, e) => {
|
|
1900
|
-
a.accounts[
|
|
1912
|
+
a.accounts[m].address = e.payload;
|
|
1901
1913
|
},
|
|
1902
1914
|
setAccountBalance: (a, e) => {
|
|
1903
1915
|
a.accounts[e.payload.id].balance = e.payload.balance, a.accounts[e.payload.id].tokensBalance = e.payload.tokensBalance;
|
|
@@ -1932,110 +1944,113 @@ const tt = {
|
|
|
1932
1944
|
a.accounts[e.payload.accountId].sessions = {};
|
|
1933
1945
|
}
|
|
1934
1946
|
}
|
|
1935
|
-
}),
|
|
1936
|
-
loader:
|
|
1937
|
-
dapp:
|
|
1938
|
-
status:
|
|
1939
|
-
wallet:
|
|
1940
|
-
auth:
|
|
1941
|
-
notifications:
|
|
1942
|
-
}, w =
|
|
1947
|
+
}), es = ke.actions, pt = ke.reducer, ts = {
|
|
1948
|
+
loader: ct,
|
|
1949
|
+
dapp: rt,
|
|
1950
|
+
status: ht,
|
|
1951
|
+
wallet: pt,
|
|
1952
|
+
auth: nt,
|
|
1953
|
+
notifications: ut
|
|
1954
|
+
}, w = Ve.withTypes(), ss = () => w((a) => a.auth), as = () => w((a) => a.status.height), ns = (a) => w((e) => e.wallet.accounts[a]), is = () => w((a) => a.wallet.selectedAccount), rs = () => w((a) => Math.max(...Object.keys(a.wallet.accounts).map(Number))), os = (a) => w((e) => e.wallet.accounts[a].address), cs = (a) => w((e) => e.wallet.accounts[a].balance), ds = (a, e) => w((t) => t.wallet.accounts[a].tokensBalance[e]), us = (a, e) => w((t) => t.wallet.accounts[a].sessions[e]), ls = () => w((a) => a.wallet.vaults), Te = j(
|
|
1943
1955
|
[(a) => a.notifications.wallet],
|
|
1944
1956
|
(a) => Object.values(a).sort((e, t) => t.createdAt - e.createdAt)
|
|
1945
|
-
),
|
|
1957
|
+
), Ie = j(
|
|
1946
1958
|
[(a) => a.notifications.web3],
|
|
1947
1959
|
(a) => Object.values(a).sort((e, t) => t.createdAt - e.createdAt)
|
|
1948
|
-
),
|
|
1949
|
-
[
|
|
1960
|
+
), yt = j(
|
|
1961
|
+
[Te, Ie],
|
|
1950
1962
|
(a, e) => [...a, ...e].sort((t, s) => s.createdAt - t.createdAt)
|
|
1951
|
-
),
|
|
1963
|
+
), hs = () => w(Te), fs = () => w(Ie), ps = () => w(yt);
|
|
1952
1964
|
export {
|
|
1953
1965
|
f as AccountType,
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
Xe as
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
1966
|
+
Lt as AssetService,
|
|
1967
|
+
R as AssetType,
|
|
1968
|
+
ye as CURRENCIES,
|
|
1969
|
+
Ut as KVStore,
|
|
1970
|
+
Rt as KeyManager,
|
|
1971
|
+
g as KeySpace,
|
|
1972
|
+
m as MAIN_WALLET_ID,
|
|
1973
|
+
ie as MAX_INT64,
|
|
1974
|
+
he as RostrumService,
|
|
1975
|
+
zt as SessionManager,
|
|
1976
|
+
C as SessionRequestType,
|
|
1977
|
+
Ft as TransactionService,
|
|
1978
|
+
$t as TransactionTransformer,
|
|
1979
|
+
Re as VAULT_FIRST_BLOCK,
|
|
1980
|
+
It as VAULT_SCRIPT_PREFIX,
|
|
1981
|
+
Vt as WalletCache,
|
|
1982
|
+
Dt as WalletDB,
|
|
1983
|
+
x as WalletManager,
|
|
1984
|
+
jt as authActions,
|
|
1985
|
+
nt as authReducer,
|
|
1986
|
+
Ot as calcAmountValue,
|
|
1987
|
+
Bt as capitalizeFirstLetter,
|
|
1988
|
+
me as currencyCodes,
|
|
1989
|
+
We as currencySymbols,
|
|
1990
|
+
X as currentTimestamp,
|
|
1991
|
+
Xt as dappModalActions,
|
|
1992
|
+
rt as dappModalReducer,
|
|
1993
|
+
Jt as encryptMnemonic,
|
|
1994
|
+
Et as estimateDateByFutureBlock,
|
|
1995
|
+
Fe as fetchAssetBlob,
|
|
1996
|
+
Le as fetchAssetDoc,
|
|
1997
|
+
Ht as fetchNiftyNFT,
|
|
1998
|
+
de as fetchPrice,
|
|
1999
|
+
Gt as generateNewMnemonic,
|
|
2000
|
+
Qe as generateVaultAddress,
|
|
2001
|
+
Xe as generateVaultConstraint,
|
|
2002
|
+
Ze as generateVaultVisibleArgs,
|
|
2003
|
+
H as getAddressBuffer,
|
|
2004
|
+
Wt as getCurrencySymbol,
|
|
2005
|
+
xt as getExplorerUrl,
|
|
2006
|
+
Ct as getFileMediaType,
|
|
2007
|
+
Pt as getFileMimeType,
|
|
2008
|
+
ze as getNexaPrices,
|
|
2009
|
+
fe as getNiftyToken,
|
|
2010
|
+
Ye as getVaultConstraintHash,
|
|
2011
|
+
$e as getVaultTemplate,
|
|
2012
|
+
je as getVaultTemplateHash,
|
|
2000
2013
|
ge as initializePrices,
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2014
|
+
Nt as isGenesisHashValid,
|
|
2015
|
+
Je as isMnemonicValid,
|
|
2016
|
+
q as isNiftySubgroup,
|
|
2004
2017
|
P as isNullOrEmpty,
|
|
2005
2018
|
T as isTestnet,
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2019
|
+
G as isValidNexaAddress,
|
|
2020
|
+
N as keyPathToString,
|
|
2021
|
+
Yt as loaderActions,
|
|
2022
|
+
ct as loaderReducer,
|
|
2023
|
+
Zt as notificationsActions,
|
|
2024
|
+
ut as notificationsReducer,
|
|
2025
|
+
Kt as parseTokenDataUrl,
|
|
2026
|
+
He as prettifyAmount,
|
|
2027
|
+
ts as sharedReducers,
|
|
2028
|
+
_t as sleep,
|
|
2029
|
+
Qt as statusActions,
|
|
2030
|
+
ht as statusReducer,
|
|
2031
|
+
Ke as stringToKeyPath,
|
|
2032
|
+
oe as sumBalance,
|
|
2033
|
+
J as sumTokensBalance,
|
|
2034
|
+
V as tokenAmountToAssetAmount,
|
|
2035
|
+
re as tokenHexToAddr,
|
|
2021
2036
|
b as tokenIdToHex,
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2037
|
+
ce as transformTokenIconUrl,
|
|
2038
|
+
Mt as truncateStringMiddle,
|
|
2039
|
+
ns as useAccount,
|
|
2040
|
+
ps as useAllNotifications,
|
|
2041
|
+
ss as useAuth,
|
|
2042
|
+
as as useBlockHeight,
|
|
2043
|
+
us as useDAppSession,
|
|
2044
|
+
rs as useLastAccountId,
|
|
2045
|
+
os as useMainReceiveAddress,
|
|
2046
|
+
is as useSelectedAccount,
|
|
2047
|
+
ds as useTokenBalance,
|
|
2048
|
+
ls as useVaults,
|
|
2049
|
+
cs as useWalletBalance,
|
|
2050
|
+
hs as useWalletNotifications,
|
|
2051
|
+
fs as useWeb3Notifications,
|
|
2052
|
+
qt as validateAndDecryptMnemonic,
|
|
2053
|
+
es as walletActions,
|
|
2054
|
+
pt as walletReducer
|
|
2040
2055
|
};
|
|
2041
2056
|
//# sourceMappingURL=index.js.map
|