@otoplo/wallet-common 0.1.12 → 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 +337 -319
- 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 -2278
package/dist/index.js
CHANGED
|
@@ -1,69 +1,70 @@
|
|
|
1
|
-
import { AddressType as E, Networks as k, Address 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
|
-
return
|
|
17
|
+
function G(a, e = E.PayToScriptTemplate) {
|
|
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
|
-
function
|
|
45
|
-
return
|
|
45
|
+
function b(a) {
|
|
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 Mt {
|
|
|
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 Bt {
|
|
|
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 Bt {
|
|
|
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();
|
|
@@ -369,25 +381,25 @@ class Ct {
|
|
|
369
381
|
this.tokens.clear(), this.nfts.clear();
|
|
370
382
|
}
|
|
371
383
|
async getTokenById(e) {
|
|
372
|
-
if (e =
|
|
384
|
+
if (e = b(e), this.tokens.has(e))
|
|
373
385
|
return this.tokens.get(e);
|
|
374
386
|
const t = await this.walletDb.getToken(e);
|
|
375
387
|
return t && this.tokens.set(e, t), t;
|
|
376
388
|
}
|
|
377
389
|
async getNftById(e) {
|
|
378
|
-
if (e =
|
|
390
|
+
if (e = b(e), this.nfts.has(e))
|
|
379
391
|
return this.nfts.get(e);
|
|
380
392
|
const t = await this.walletDb.getLocalNft(e);
|
|
381
393
|
return t && this.nfts.set(e, t), t;
|
|
382
394
|
}
|
|
383
395
|
removeToken(e) {
|
|
384
|
-
this.tokens.delete(
|
|
396
|
+
this.tokens.delete(b(e));
|
|
385
397
|
}
|
|
386
398
|
removeNft(e) {
|
|
387
|
-
this.nfts.delete(
|
|
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
|
}
|
|
@@ -486,7 +498,7 @@ class le {
|
|
|
486
498
|
const t = Date.now();
|
|
487
499
|
return new Promise((s, n) => {
|
|
488
500
|
const i = () => {
|
|
489
|
-
if (this.client?.connectionStatus ==
|
|
501
|
+
if (this.client?.connectionStatus == Be.CONNECTED)
|
|
490
502
|
return s();
|
|
491
503
|
if (Date.now() - t > e)
|
|
492
504
|
return n(new Error("Rostrum Connection timeout"));
|
|
@@ -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" ?
|
|
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
590
|
function q(a) {
|
|
579
591
|
try {
|
|
580
|
-
const e =
|
|
581
|
-
return O.isSubgroup(e) ?
|
|
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;
|
|
@@ -629,21 +641,21 @@ class Ut {
|
|
|
629
641
|
if (c)
|
|
630
642
|
return c;
|
|
631
643
|
}
|
|
632
|
-
const s = await this.rostrumService.getTokenGenesis(e), n =
|
|
644
|
+
const s = await this.rostrumService.getTokenGenesis(e), n = y.hexToBuffer(s.token_id_hex);
|
|
633
645
|
let i = "", o = "";
|
|
634
646
|
if (s.op_return_id == I.NRC2 || s.op_return_id == I.NRC3 || q(e))
|
|
635
647
|
return;
|
|
636
|
-
if (O.isSubgroup(n) && (i = new
|
|
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);
|
|
@@ -674,8 +686,8 @@ class Ut {
|
|
|
674
686
|
async getAssetInfo(e) {
|
|
675
687
|
let t = await this.getTokenInfo(e);
|
|
676
688
|
return t || await this.isNftToken(e) && (t = {
|
|
677
|
-
token:
|
|
678
|
-
tokenIdHex:
|
|
689
|
+
token: re(e),
|
|
690
|
+
tokenIdHex: b(e),
|
|
679
691
|
decimals: 0
|
|
680
692
|
}), t;
|
|
681
693
|
}
|
|
@@ -684,7 +696,7 @@ class Ut {
|
|
|
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 Ut {
|
|
|
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
|
-
const r = new
|
|
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 q(t) && await this.saveNft(e, t, "nifty",
|
|
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 Ut {
|
|
|
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
|
|
@@ -732,12 +744,12 @@ class Ut {
|
|
|
732
744
|
for (const r of o)
|
|
733
745
|
await i(r.tokenIdHex);
|
|
734
746
|
for (const [r, c] of Object.entries(t)) {
|
|
735
|
-
const d =
|
|
736
|
-
!u && !l || u && l || !await this.isNftToken(d) || (!u && l ? await i(d) : await this.handleNftReceive(e, d,
|
|
747
|
+
const d = b(r), u = c && BigInt(c.confirmed) + BigInt(c.unconfirmed) > 0n, l = n?.some((p) => p.tokenIdHex == 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 Dt {
|
|
|
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 Dt {
|
|
|
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 Dt {
|
|
|
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 Dt {
|
|
|
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,21 +846,21 @@ class Dt {
|
|
|
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
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
|
-
if (
|
|
863
|
+
if (S.getOutputType(e) === 0)
|
|
852
864
|
throw new Error("Token must be sent to script template address");
|
|
853
865
|
i.to(e, B.DUST_AMOUNT, s, BigInt(t));
|
|
854
866
|
} else
|
|
@@ -884,13 +896,13 @@ class Dt {
|
|
|
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,13 +917,13 @@ class Dt {
|
|
|
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
|
}
|
|
913
925
|
async populateTokenInputsAndChange(e, t, s, n, i) {
|
|
914
|
-
const o =
|
|
926
|
+
const o = b(n), r = t.filter((u) => Object.keys(u.tokensBalance).includes(o));
|
|
915
927
|
if (P(r))
|
|
916
928
|
throw new Error("Not enough token balance.");
|
|
917
929
|
const c = /* @__PURE__ */ new Map();
|
|
@@ -930,7 +942,7 @@ class Dt {
|
|
|
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.");
|
|
@@ -956,13 +968,13 @@ class Dt {
|
|
|
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,19 +998,19 @@ async function fe(a, e) {
|
|
|
986
998
|
["encrypt", "decrypt"]
|
|
987
999
|
);
|
|
988
1000
|
}
|
|
989
|
-
async function
|
|
990
|
-
const t =
|
|
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)
|
|
994
1006
|
},
|
|
995
1007
|
o,
|
|
996
1008
|
new Uint8Array(i)
|
|
997
|
-
), c =
|
|
998
|
-
return
|
|
1009
|
+
), c = y.concat([s, n, new Uint8Array(r)]);
|
|
1010
|
+
return y.bufferToBase64(c);
|
|
999
1011
|
}
|
|
1000
|
-
async function
|
|
1001
|
-
const t =
|
|
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
|
|
@@ -1006,13 +1018,13 @@ async function Ge(a, e) {
|
|
|
1006
1018
|
r,
|
|
1007
1019
|
o
|
|
1008
1020
|
);
|
|
1009
|
-
return
|
|
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,55 +1032,57 @@ async function Ht(a, e) {
|
|
|
1020
1032
|
return !1;
|
|
1021
1033
|
}
|
|
1022
1034
|
}
|
|
1023
|
-
const
|
|
1024
|
-
usd: "$",
|
|
1025
|
-
eur: "€",
|
|
1026
|
-
gbp: "£",
|
|
1027
|
-
cny: "¥",
|
|
1028
|
-
jpy: "¥",
|
|
1029
|
-
aud: "A$",
|
|
1030
|
-
cad: "C$",
|
|
1031
|
-
chf: "Fr"
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
+
const ye = [
|
|
1036
|
+
{ code: "usd", symbol: "$", name: "US Dollar" },
|
|
1037
|
+
{ code: "eur", symbol: "€", name: "Euro" },
|
|
1038
|
+
{ code: "gbp", symbol: "£", name: "British Pound" },
|
|
1039
|
+
{ code: "cny", symbol: "¥", name: "Chinese Yuan" },
|
|
1040
|
+
{ code: "jpy", symbol: "¥", name: "Japanese Yen" },
|
|
1041
|
+
{ code: "aud", symbol: "A$", name: "Australian Dollar" },
|
|
1042
|
+
{ code: "cad", symbol: "C$", name: "Canadian Dollar" },
|
|
1043
|
+
{ code: "chf", symbol: "Fr", name: "Swiss Franc" }
|
|
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}`);
|
|
1035
1049
|
if (!e.ok)
|
|
1036
1050
|
throw new Error("Failed to fetch price");
|
|
1037
1051
|
return (await e.json()).nexacoin || {};
|
|
1038
1052
|
}
|
|
1039
|
-
function
|
|
1040
|
-
return
|
|
1053
|
+
function Wt(a) {
|
|
1054
|
+
return We[a] || a;
|
|
1041
1055
|
}
|
|
1042
|
-
function
|
|
1056
|
+
function ge() {
|
|
1043
1057
|
const a = {};
|
|
1044
|
-
return
|
|
1058
|
+
return me.forEach((e) => {
|
|
1045
1059
|
a[e] = { value: 0, change: 0 };
|
|
1046
1060
|
}), a;
|
|
1047
1061
|
}
|
|
1048
|
-
function
|
|
1062
|
+
function $e() {
|
|
1049
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);
|
|
1050
1064
|
}
|
|
1051
|
-
function
|
|
1052
|
-
const a =
|
|
1053
|
-
return
|
|
1065
|
+
function je() {
|
|
1066
|
+
const a = $e();
|
|
1067
|
+
return D.sha256ripemd160(a.toBuffer());
|
|
1054
1068
|
}
|
|
1055
|
-
function
|
|
1069
|
+
function Xe(a) {
|
|
1056
1070
|
return A.empty().add(a.toBuffer());
|
|
1057
1071
|
}
|
|
1058
|
-
function
|
|
1059
|
-
const e =
|
|
1060
|
-
return
|
|
1072
|
+
function Ye(a) {
|
|
1073
|
+
const e = Xe(a);
|
|
1074
|
+
return D.sha256ripemd160(e.toBuffer());
|
|
1061
1075
|
}
|
|
1062
|
-
function
|
|
1063
|
-
return a.map((e) => e <= 16 ?
|
|
1076
|
+
function Ze(a) {
|
|
1077
|
+
return a.map((e) => e <= 16 ? W.smallInt(e) : z.fromNumber(e).toScriptNumBuffer());
|
|
1064
1078
|
}
|
|
1065
|
-
function
|
|
1079
|
+
function Qe(a, e) {
|
|
1066
1080
|
if (e.length !== 2)
|
|
1067
1081
|
return;
|
|
1068
|
-
const t =
|
|
1069
|
-
return
|
|
1082
|
+
const t = je(), s = Ye(a), n = Ze(e);
|
|
1083
|
+
return S.fromScriptTemplate(t, s, n).toString();
|
|
1070
1084
|
}
|
|
1071
|
-
class
|
|
1085
|
+
class zt {
|
|
1072
1086
|
walletDb;
|
|
1073
1087
|
keyManager;
|
|
1074
1088
|
providers;
|
|
@@ -1102,14 +1116,14 @@ class Lt {
|
|
|
1102
1116
|
}
|
|
1103
1117
|
async reload(e) {
|
|
1104
1118
|
for (const t of e.values()) {
|
|
1105
|
-
if (t.id ==
|
|
1119
|
+
if (t.id == m)
|
|
1106
1120
|
continue;
|
|
1107
1121
|
const s = await this.walletDb.getAccountSessions(t.id), n = this.providers.get(t.id), i = s.map(async (r) => {
|
|
1108
1122
|
if (n?.has(r.sessionId))
|
|
1109
1123
|
return;
|
|
1110
1124
|
let c;
|
|
1111
1125
|
try {
|
|
1112
|
-
c = new
|
|
1126
|
+
c = new Ue(r.uri);
|
|
1113
1127
|
const d = c.getSessionInfo();
|
|
1114
1128
|
await c.connect(3e3);
|
|
1115
1129
|
const u = await c.getAppInfo(2e3);
|
|
@@ -1176,7 +1190,7 @@ class Lt {
|
|
|
1176
1190
|
this.handlers.set(i, { resolve: r, reject: c }), this.notify({ type: "new_request", request: { type: i, accountId: e.id, sessionId: s, request: o } });
|
|
1177
1191
|
});
|
|
1178
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(() => {
|
|
1179
|
-
const i = { account: f.DAPP, type:
|
|
1193
|
+
const i = { account: f.DAPP, type: g.RECEIVE, index: e.id };
|
|
1180
1194
|
return {
|
|
1181
1195
|
name: e.name,
|
|
1182
1196
|
address: e.address,
|
|
@@ -1193,7 +1207,7 @@ class Lt {
|
|
|
1193
1207
|
});
|
|
1194
1208
|
}
|
|
1195
1209
|
}
|
|
1196
|
-
class
|
|
1210
|
+
class $t {
|
|
1197
1211
|
rostrumService;
|
|
1198
1212
|
keyManager;
|
|
1199
1213
|
assetService;
|
|
@@ -1234,16 +1248,16 @@ class Ft {
|
|
|
1234
1248
|
await Promise.all(t);
|
|
1235
1249
|
}
|
|
1236
1250
|
async processInput(e, t) {
|
|
1237
|
-
const s = e.txDetails.tx.inputs[t], n = await this.rostrumService.getUtxo(
|
|
1251
|
+
const s = e.txDetails.tx.inputs[t], n = await this.rostrumService.getUtxo(y.bufferToHex(s.outpoint));
|
|
1238
1252
|
if (n.status == "spent")
|
|
1239
1253
|
throw new Error("Input UTXO is already spent.");
|
|
1240
|
-
if (s.output = new
|
|
1254
|
+
if (s.output = new Ne(n.amount, n.scriptpubkey), s.output.address == e.address) {
|
|
1241
1255
|
const i = n.token_id_hex || "NEXA";
|
|
1242
1256
|
e.myInputs.set(t, {
|
|
1243
1257
|
address: e.address,
|
|
1244
1258
|
nexaAmount: n.amount.toString(),
|
|
1245
1259
|
assetId: i,
|
|
1246
|
-
assetAmount:
|
|
1260
|
+
assetAmount: V(n.group_quantity) || n.amount.toString()
|
|
1247
1261
|
}), e.involvedAssets.add(i), s.scriptSig.isEmpty() && e.inputsToSign.add(t);
|
|
1248
1262
|
}
|
|
1249
1263
|
s.scriptSig.findPlaceholder() > 0 && e.inputsToSign.add(t);
|
|
@@ -1253,11 +1267,11 @@ class Ft {
|
|
|
1253
1267
|
const s = e.txDetails.tx.outputs[t].toObject();
|
|
1254
1268
|
if (s.address !== e.address)
|
|
1255
1269
|
continue;
|
|
1256
|
-
const n = s.groupId ?
|
|
1270
|
+
const n = s.groupId ? b(s.groupId) : "NEXA", i = {
|
|
1257
1271
|
address: s.address,
|
|
1258
1272
|
nexaAmount: s.value.toString(),
|
|
1259
1273
|
assetId: n,
|
|
1260
|
-
assetAmount:
|
|
1274
|
+
assetAmount: V(s.groupAmount) || s.value.toString()
|
|
1261
1275
|
};
|
|
1262
1276
|
e.involvedAssets.add(n), e.myOutputs.set(t, i);
|
|
1263
1277
|
}
|
|
@@ -1269,12 +1283,12 @@ class Ft {
|
|
|
1269
1283
|
const s = e.txDetails.tx.inputs[t], n = this.validateAndGetSubscript(s);
|
|
1270
1284
|
if (s.scriptSig.isEmpty()) {
|
|
1271
1285
|
e.allMyOutputsCovered = !0;
|
|
1272
|
-
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());
|
|
1273
1287
|
s.scriptSig = xe.buildScriptTemplateIn(void 0, o, A.empty().add(i));
|
|
1274
1288
|
} else {
|
|
1275
|
-
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);
|
|
1276
1290
|
this.processSignatureCoverage(e, c);
|
|
1277
|
-
const d =
|
|
1291
|
+
const d = se.sign(e.txDetails.tx, t, c, n, e.privateKey).toTxFormat(r);
|
|
1278
1292
|
s.scriptSig.replaceChunk(i, A.empty().add(d));
|
|
1279
1293
|
}
|
|
1280
1294
|
}
|
|
@@ -1291,7 +1305,7 @@ class Ft {
|
|
|
1291
1305
|
if (!e.scriptSig.isScriptTemplateIn())
|
|
1292
1306
|
throw new Error("Unsupported input script type.");
|
|
1293
1307
|
const t = e.output.scriptPubKey.getTemplateHash(), s = e.scriptSig.chunks[0].buf;
|
|
1294
|
-
if (
|
|
1308
|
+
if (y.equals(t, D.sha256ripemd160(s)) || y.equals(t, D.sha256sha256(s)))
|
|
1295
1309
|
return A.fromBuffer(s);
|
|
1296
1310
|
throw new Error("Invalid input script template.");
|
|
1297
1311
|
}
|
|
@@ -1299,9 +1313,9 @@ class Ft {
|
|
|
1299
1313
|
}
|
|
1300
1314
|
processSignatureCoverage(e, t) {
|
|
1301
1315
|
if (!e.allMyOutputsCovered)
|
|
1302
|
-
if (t.outType ==
|
|
1316
|
+
if (t.outType == ne.TWO)
|
|
1303
1317
|
e.coveredOutputs.add(t.outData[0]), e.coveredOutputs.add(t.outData[1]), this.checkSignatureCoverage(e);
|
|
1304
|
-
else if (t.outType ==
|
|
1318
|
+
else if (t.outType == ne.FIRSTN) {
|
|
1305
1319
|
const s = t.outData[0];
|
|
1306
1320
|
for (let n = 0; n < s; n++)
|
|
1307
1321
|
e.coveredOutputs.add(n);
|
|
@@ -1333,8 +1347,8 @@ class Ft {
|
|
|
1333
1347
|
}
|
|
1334
1348
|
}
|
|
1335
1349
|
}
|
|
1336
|
-
const
|
|
1337
|
-
class
|
|
1350
|
+
const et = 274710, tt = "0014461ad25081cb0119d034385ff154c8d3ad6bdd76";
|
|
1351
|
+
class st {
|
|
1338
1352
|
rostrumService;
|
|
1339
1353
|
keyManager;
|
|
1340
1354
|
constructor(e, t) {
|
|
@@ -1367,16 +1381,16 @@ class Qe {
|
|
|
1367
1381
|
}), n;
|
|
1368
1382
|
}
|
|
1369
1383
|
async checkVaultsForAddress(e) {
|
|
1370
|
-
const t = /* @__PURE__ */ new Set(), s = await this.rostrumService.getTransactionsHistory(e,
|
|
1384
|
+
const t = /* @__PURE__ */ new Set(), s = await this.rostrumService.getTransactionsHistory(e, et);
|
|
1371
1385
|
for (const n of s) {
|
|
1372
|
-
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));
|
|
1373
1387
|
for (const r of o)
|
|
1374
1388
|
t.add(r.scriptPubKey.hex);
|
|
1375
1389
|
}
|
|
1376
1390
|
return t;
|
|
1377
1391
|
}
|
|
1378
1392
|
parseVaultDetails(e) {
|
|
1379
|
-
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);
|
|
1380
1394
|
return n != u ? void 0 : {
|
|
1381
1395
|
address: n,
|
|
1382
1396
|
block: o,
|
|
@@ -1389,9 +1403,9 @@ class Qe {
|
|
|
1389
1403
|
};
|
|
1390
1404
|
}
|
|
1391
1405
|
}
|
|
1392
|
-
class
|
|
1406
|
+
class x {
|
|
1393
1407
|
constructor(e, t, s, n, i, o, r) {
|
|
1394
|
-
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();
|
|
1395
1409
|
}
|
|
1396
1410
|
static GAP_LIMIT = 20;
|
|
1397
1411
|
static DEBOUNCE_MS = 1e3;
|
|
@@ -1420,22 +1434,22 @@ class N {
|
|
|
1420
1434
|
getReceiveAddress() {
|
|
1421
1435
|
return this.receiveAddresses.find((e) => !e.used).address;
|
|
1422
1436
|
}
|
|
1423
|
-
getChangeAddress(e =
|
|
1424
|
-
return e !=
|
|
1437
|
+
getChangeAddress(e = m) {
|
|
1438
|
+
return e != m ? this.accounts.get(e).address : this.changeAddresses.find((t) => !t.used).address;
|
|
1425
1439
|
}
|
|
1426
|
-
getUsedAddressKeys(e =
|
|
1427
|
-
if (e !=
|
|
1440
|
+
getUsedAddressKeys(e = m) {
|
|
1441
|
+
if (e != m) {
|
|
1428
1442
|
const t = this.accounts.get(e);
|
|
1429
1443
|
return [{
|
|
1430
1444
|
address: t.address,
|
|
1431
|
-
keyPath:
|
|
1445
|
+
keyPath: N(f.DAPP, 0, t.id),
|
|
1432
1446
|
balance: t.balance,
|
|
1433
1447
|
tokensBalance: t.tokensBalance
|
|
1434
1448
|
}];
|
|
1435
1449
|
}
|
|
1436
1450
|
return this.getMainAddresses().filter((t) => t.used).map((t) => ({
|
|
1437
1451
|
address: t.address,
|
|
1438
|
-
keyPath:
|
|
1452
|
+
keyPath: N(f.MAIN, t.space, t.idx),
|
|
1439
1453
|
balance: t.balance,
|
|
1440
1454
|
tokensBalance: t.tokensBalance
|
|
1441
1455
|
}));
|
|
@@ -1451,8 +1465,8 @@ class N {
|
|
|
1451
1465
|
}
|
|
1452
1466
|
async discoverWallet() {
|
|
1453
1467
|
this.notify({ type: "discover_wallet", loading: !0 });
|
|
1454
|
-
const e = this.discoveryService.discoverWalletIndex(f.MAIN,
|
|
1455
|
-
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();
|
|
1456
1470
|
}
|
|
1457
1471
|
async loadWallet() {
|
|
1458
1472
|
this.receiveAddresses = await this.walletDb.getReceiveAddresses(), this.changeAddresses = await this.walletDb.getChangeAddresses();
|
|
@@ -1464,7 +1478,7 @@ class N {
|
|
|
1464
1478
|
async initialSync() {
|
|
1465
1479
|
await this.subscribeAddresses(this.getAllAddresses(), !0);
|
|
1466
1480
|
const e = [];
|
|
1467
|
-
e.push(this.assetService.fetchAndSaveTokens(
|
|
1481
|
+
e.push(this.assetService.fetchAndSaveTokens(m, J(this.getMainAddresses().map((t) => t.tokensBalance))));
|
|
1468
1482
|
for (const t of this.accounts.values())
|
|
1469
1483
|
e.push(this.assetService.fetchAndSaveTokens(t.id, t.tokensBalance));
|
|
1470
1484
|
await Promise.all(e);
|
|
@@ -1480,11 +1494,11 @@ class N {
|
|
|
1480
1494
|
this.notify({
|
|
1481
1495
|
type: "new_account",
|
|
1482
1496
|
account: {
|
|
1483
|
-
id:
|
|
1497
|
+
id: m,
|
|
1484
1498
|
name: "Main Wallet",
|
|
1485
1499
|
address: this.getReceiveAddress(),
|
|
1486
|
-
balance:
|
|
1487
|
-
tokensBalance:
|
|
1500
|
+
balance: oe(e.map((t) => t.balance)),
|
|
1501
|
+
tokensBalance: J(e.map((t) => t.tokensBalance)),
|
|
1488
1502
|
tokens: [],
|
|
1489
1503
|
sessions: {}
|
|
1490
1504
|
}
|
|
@@ -1516,7 +1530,7 @@ class N {
|
|
|
1516
1530
|
deriveAddresses(e, t, s) {
|
|
1517
1531
|
const n = [];
|
|
1518
1532
|
for (let i = t; i < t + s; i++) {
|
|
1519
|
-
const o =
|
|
1533
|
+
const o = N(f.MAIN, e, i), c = {
|
|
1520
1534
|
address: this.keyManager.getKey(o).privateKey.toAddress().toString(),
|
|
1521
1535
|
space: e,
|
|
1522
1536
|
idx: i,
|
|
@@ -1534,7 +1548,7 @@ class N {
|
|
|
1534
1548
|
deriveAccounts(e, t) {
|
|
1535
1549
|
const s = /* @__PURE__ */ new Map();
|
|
1536
1550
|
for (let n = e; n < e + t; n++) {
|
|
1537
|
-
const i =
|
|
1551
|
+
const i = N(f.DAPP, 0, n), o = this.keyManager.getKey(i).privateKey.toAddress().toString(), r = {
|
|
1538
1552
|
id: n,
|
|
1539
1553
|
name: `Account ${n + 1}`,
|
|
1540
1554
|
address: o,
|
|
@@ -1583,7 +1597,7 @@ class N {
|
|
|
1583
1597
|
registerUpdate(e) {
|
|
1584
1598
|
this.pendingUpdates.set(e.address.address, e), clearTimeout(this.updateTimer), this.updateTimer = setTimeout(() => {
|
|
1585
1599
|
this.processPendingUpdates();
|
|
1586
|
-
},
|
|
1600
|
+
}, x.DEBOUNCE_MS);
|
|
1587
1601
|
}
|
|
1588
1602
|
async processPendingUpdates() {
|
|
1589
1603
|
if (this.pendingUpdates.size !== 0)
|
|
@@ -1625,12 +1639,12 @@ class N {
|
|
|
1625
1639
|
for (const { txs: r } of e)
|
|
1626
1640
|
for (const c of r)
|
|
1627
1641
|
t.set(c.tx_hash, c);
|
|
1628
|
-
await this.checkGapLimit(
|
|
1629
|
-
const s = this.getMainAddresses(), n =
|
|
1630
|
-
this.notify({ type: "account_balance_updated", accountId:
|
|
1631
|
-
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);
|
|
1632
1646
|
for (const r of t.values())
|
|
1633
|
-
await this.transactionService.classifyAndSaveTransaction(
|
|
1647
|
+
await this.transactionService.classifyAndSaveTransaction(m, r.tx_hash, s.map((c) => c.address));
|
|
1634
1648
|
await o;
|
|
1635
1649
|
}
|
|
1636
1650
|
async postProcessAccountUpdate(e) {
|
|
@@ -1660,16 +1674,16 @@ class N {
|
|
|
1660
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 };
|
|
1661
1675
|
}
|
|
1662
1676
|
async checkGapLimit(e) {
|
|
1663
|
-
const t = e ===
|
|
1664
|
-
if (n <
|
|
1665
|
-
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;
|
|
1666
1680
|
console.log(`Deriving ${i} more ${s} addresses...`);
|
|
1667
1681
|
const r = this.deriveAddresses(e, o + 1, i);
|
|
1668
|
-
e ===
|
|
1682
|
+
e === g.RECEIVE ? this.receiveAddresses.push(...r) : this.changeAddresses.push(...r), await this.saveAddresses(r), await this.subscribeAddresses(r);
|
|
1669
1683
|
}
|
|
1670
1684
|
}
|
|
1671
1685
|
async addNewAccount(e, t) {
|
|
1672
|
-
const s =
|
|
1686
|
+
const s = N(f.DAPP, 0, e), n = this.keyManager.getKey(s).privateKey.toAddress().toString(), i = {
|
|
1673
1687
|
id: e,
|
|
1674
1688
|
name: t,
|
|
1675
1689
|
address: n,
|
|
@@ -1700,7 +1714,7 @@ class N {
|
|
|
1700
1714
|
s.name = t, await this.walletDb.updateAccountName(e, t);
|
|
1701
1715
|
}
|
|
1702
1716
|
rescanAccount(e) {
|
|
1703
|
-
if (e ==
|
|
1717
|
+
if (e == m) {
|
|
1704
1718
|
const t = this.getMainAddresses();
|
|
1705
1719
|
for (const s of t)
|
|
1706
1720
|
s.height = 0, this.registerUpdate({ address: s, result: s.statusHash });
|
|
@@ -1753,12 +1767,12 @@ class N {
|
|
|
1753
1767
|
return e.type == f.MAIN;
|
|
1754
1768
|
}
|
|
1755
1769
|
}
|
|
1756
|
-
const
|
|
1770
|
+
const at = {
|
|
1757
1771
|
isWalletExist: !1,
|
|
1758
1772
|
isAuthorized: !1
|
|
1759
|
-
},
|
|
1773
|
+
}, we = M({
|
|
1760
1774
|
name: "auth",
|
|
1761
|
-
initialState:
|
|
1775
|
+
initialState: at,
|
|
1762
1776
|
reducers: {
|
|
1763
1777
|
setWalletExist: (a, e) => {
|
|
1764
1778
|
a.isWalletExist = e.payload;
|
|
@@ -1767,12 +1781,12 @@ const et = {
|
|
|
1767
1781
|
a.isAuthorized = e.payload;
|
|
1768
1782
|
}
|
|
1769
1783
|
}
|
|
1770
|
-
}),
|
|
1784
|
+
}), jt = we.actions, nt = we.reducer, it = {
|
|
1771
1785
|
modalType: null,
|
|
1772
1786
|
currentRequest: null
|
|
1773
|
-
},
|
|
1787
|
+
}, ve = M({
|
|
1774
1788
|
name: "dappModal",
|
|
1775
|
-
initialState:
|
|
1789
|
+
initialState: it,
|
|
1776
1790
|
reducers: {
|
|
1777
1791
|
showRequest(a, e) {
|
|
1778
1792
|
a.modalType = e.payload.type, a.currentRequest = e.payload;
|
|
@@ -1781,24 +1795,24 @@ const et = {
|
|
|
1781
1795
|
a.modalType = null, a.currentRequest = null;
|
|
1782
1796
|
}
|
|
1783
1797
|
}
|
|
1784
|
-
}),
|
|
1798
|
+
}), Xt = ve.actions, rt = ve.reducer, ot = {
|
|
1785
1799
|
counter: 0,
|
|
1786
1800
|
loading: !1
|
|
1787
|
-
},
|
|
1801
|
+
}, Ae = M({
|
|
1788
1802
|
name: "loader",
|
|
1789
|
-
initialState:
|
|
1803
|
+
initialState: ot,
|
|
1790
1804
|
reducers: {
|
|
1791
1805
|
setLoader: (a, e) => {
|
|
1792
1806
|
const t = e.payload.loading ? a.counter + 1 : Math.max(0, a.counter - 1);
|
|
1793
1807
|
a.counter = t, a.loading = t > 0, a.text = e.payload.text;
|
|
1794
1808
|
}
|
|
1795
1809
|
}
|
|
1796
|
-
}),
|
|
1810
|
+
}), Yt = Ae.actions, ct = Ae.reducer, dt = {
|
|
1797
1811
|
wallet: {},
|
|
1798
1812
|
web3: {}
|
|
1799
|
-
},
|
|
1813
|
+
}, be = M({
|
|
1800
1814
|
name: "notifications",
|
|
1801
|
-
initialState:
|
|
1815
|
+
initialState: dt,
|
|
1802
1816
|
reducers: {
|
|
1803
1817
|
addNotification: (a, e) => {
|
|
1804
1818
|
e.payload.type == "wallet" ? a.wallet[e.payload.id] = e.payload : e.payload.type == "web3" && (a.web3[e.payload.id] = e.payload);
|
|
@@ -1810,16 +1824,16 @@ const et = {
|
|
|
1810
1824
|
e.payload === "wallet" ? a.wallet = {} : e.payload === "web3" ? a.web3 = {} : e.payload === "all" && (a.wallet = {}, a.web3 = {});
|
|
1811
1825
|
}
|
|
1812
1826
|
}
|
|
1813
|
-
}),
|
|
1827
|
+
}), Zt = be.actions, ut = be.reducer, lt = {
|
|
1814
1828
|
status: "Offline",
|
|
1815
1829
|
height: 0,
|
|
1816
|
-
price:
|
|
1830
|
+
price: ge(),
|
|
1817
1831
|
hasNetwork: !0,
|
|
1818
1832
|
isSuspended: !1
|
|
1819
|
-
},
|
|
1820
|
-
const a =
|
|
1833
|
+
}, de = De("status/fetchPrice", async () => {
|
|
1834
|
+
const a = ge();
|
|
1821
1835
|
try {
|
|
1822
|
-
const e = await
|
|
1836
|
+
const e = await ze();
|
|
1823
1837
|
Object.keys(e).forEach((t) => {
|
|
1824
1838
|
a[t] = {
|
|
1825
1839
|
value: e[t],
|
|
@@ -1831,7 +1845,7 @@ const et = {
|
|
|
1831
1845
|
return a;
|
|
1832
1846
|
}), Se = M({
|
|
1833
1847
|
name: "status",
|
|
1834
|
-
initialState:
|
|
1848
|
+
initialState: lt,
|
|
1835
1849
|
reducers: {
|
|
1836
1850
|
setHeight: (a, e) => {
|
|
1837
1851
|
e.payload > 0 && (a.status = "Online"), a.height = e.payload;
|
|
@@ -1847,18 +1861,18 @@ const et = {
|
|
|
1847
1861
|
}
|
|
1848
1862
|
},
|
|
1849
1863
|
extraReducers: (a) => {
|
|
1850
|
-
a.addCase(
|
|
1864
|
+
a.addCase(de.fulfilled, (e, t) => {
|
|
1851
1865
|
e.price = t.payload;
|
|
1852
|
-
}).addCase(
|
|
1866
|
+
}).addCase(de.rejected, (e, t) => {
|
|
1853
1867
|
console.error(t.error.message);
|
|
1854
1868
|
});
|
|
1855
1869
|
}
|
|
1856
|
-
}),
|
|
1870
|
+
}), Qt = Se.actions, ht = Se.reducer, ft = {
|
|
1857
1871
|
isAuthorized: !1,
|
|
1858
|
-
selectedAccount:
|
|
1872
|
+
selectedAccount: m,
|
|
1859
1873
|
accounts: {
|
|
1860
1874
|
"-1": {
|
|
1861
|
-
id:
|
|
1875
|
+
id: m,
|
|
1862
1876
|
name: "Main Wallet",
|
|
1863
1877
|
address: "",
|
|
1864
1878
|
balance: { confirmed: "0", unconfirmed: "0" },
|
|
@@ -1872,9 +1886,9 @@ const et = {
|
|
|
1872
1886
|
initLoad: !0,
|
|
1873
1887
|
txUpdateTrigger: 0,
|
|
1874
1888
|
nftsUpdateTrigger: 0
|
|
1875
|
-
},
|
|
1889
|
+
}, ke = M({
|
|
1876
1890
|
name: "wallet",
|
|
1877
|
-
initialState:
|
|
1891
|
+
initialState: ft,
|
|
1878
1892
|
reducers: {
|
|
1879
1893
|
setInitLoad: (a, e) => {
|
|
1880
1894
|
a.initLoad = e.payload;
|
|
@@ -1895,7 +1909,7 @@ const et = {
|
|
|
1895
1909
|
a.accounts[e.payload.id] = e.payload;
|
|
1896
1910
|
},
|
|
1897
1911
|
setMainAddress: (a, e) => {
|
|
1898
|
-
a.accounts[
|
|
1912
|
+
a.accounts[m].address = e.payload;
|
|
1899
1913
|
},
|
|
1900
1914
|
setAccountBalance: (a, e) => {
|
|
1901
1915
|
a.accounts[e.payload.id].balance = e.payload.balance, a.accounts[e.payload.id].tokensBalance = e.payload.tokensBalance;
|
|
@@ -1930,109 +1944,113 @@ const et = {
|
|
|
1930
1944
|
a.accounts[e.payload.accountId].sessions = {};
|
|
1931
1945
|
}
|
|
1932
1946
|
}
|
|
1933
|
-
}),
|
|
1934
|
-
loader:
|
|
1935
|
-
dapp:
|
|
1936
|
-
status:
|
|
1937
|
-
wallet:
|
|
1938
|
-
auth:
|
|
1939
|
-
notifications:
|
|
1940
|
-
}, 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(
|
|
1941
1955
|
[(a) => a.notifications.wallet],
|
|
1942
1956
|
(a) => Object.values(a).sort((e, t) => t.createdAt - e.createdAt)
|
|
1943
|
-
),
|
|
1957
|
+
), Ie = j(
|
|
1944
1958
|
[(a) => a.notifications.web3],
|
|
1945
1959
|
(a) => Object.values(a).sort((e, t) => t.createdAt - e.createdAt)
|
|
1946
|
-
),
|
|
1947
|
-
[
|
|
1960
|
+
), yt = j(
|
|
1961
|
+
[Te, Ie],
|
|
1948
1962
|
(a, e) => [...a, ...e].sort((t, s) => s.createdAt - t.createdAt)
|
|
1949
|
-
),
|
|
1963
|
+
), hs = () => w(Te), fs = () => w(Ie), ps = () => w(yt);
|
|
1950
1964
|
export {
|
|
1951
1965
|
f as AccountType,
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
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,
|
|
1961
1976
|
C as SessionRequestType,
|
|
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
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
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,
|
|
2013
|
+
ge as initializePrices,
|
|
2014
|
+
Nt as isGenesisHashValid,
|
|
2015
|
+
Je as isMnemonicValid,
|
|
2000
2016
|
q as isNiftySubgroup,
|
|
2001
2017
|
P as isNullOrEmpty,
|
|
2002
2018
|
T as isTestnet,
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
is as
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
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,
|
|
2036
|
+
b as tokenIdToHex,
|
|
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
|
|
2037
2055
|
};
|
|
2038
2056
|
//# sourceMappingURL=index.js.map
|