@otoplo/wallet-common 0.1.15 → 0.2.0

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.
Files changed (56) hide show
  1. package/dist/index.js +555 -579
  2. package/dist/index.js.map +1 -1
  3. package/dist/types/persistence/datastore/db.d.ts +5 -3
  4. package/dist/types/persistence/datastore/db.d.ts.map +1 -1
  5. package/dist/types/persistence/wallet-db.d.ts +10 -18
  6. package/dist/types/persistence/wallet-db.d.ts.map +1 -1
  7. package/dist/types/services/asset.d.ts +5 -9
  8. package/dist/types/services/asset.d.ts.map +1 -1
  9. package/dist/types/services/cache.d.ts +4 -2
  10. package/dist/types/services/cache.d.ts.map +1 -1
  11. package/dist/types/services/wallet.d.ts +2 -1
  12. package/dist/types/services/wallet.d.ts.map +1 -1
  13. package/dist/types/state/hooks.d.ts +2 -1
  14. package/dist/types/state/hooks.d.ts.map +1 -1
  15. package/dist/types/state/slices/market.d.ts +54 -0
  16. package/dist/types/state/slices/market.d.ts.map +1 -0
  17. package/dist/types/state/slices/status.d.ts +0 -27
  18. package/dist/types/state/slices/status.d.ts.map +1 -1
  19. package/dist/types/state/slices/wallet.d.ts +21 -220
  20. package/dist/types/state/slices/wallet.d.ts.map +1 -1
  21. package/dist/types/state/store.d.ts +3 -0
  22. package/dist/types/state/store.d.ts.map +1 -1
  23. package/dist/types/types/db.types.d.ts +16 -11
  24. package/dist/types/types/db.types.d.ts.map +1 -1
  25. package/dist/types/types/wallet.types.d.ts +39 -14
  26. package/dist/types/types/wallet.types.d.ts.map +1 -1
  27. package/dist/types/utils/asset.d.ts +3 -6
  28. package/dist/types/utils/asset.d.ts.map +1 -1
  29. package/dist/types/utils/common.d.ts +0 -1
  30. package/dist/types/utils/common.d.ts.map +1 -1
  31. package/dist/types/utils/enums.d.ts +0 -4
  32. package/dist/types/utils/enums.d.ts.map +1 -1
  33. package/dist/types/utils/index.d.ts +1 -1
  34. package/dist/types/utils/index.d.ts.map +1 -1
  35. package/dist/types/utils/{price.d.ts → market.d.ts} +19 -13
  36. package/dist/types/utils/market.d.ts.map +1 -0
  37. package/package.json +4 -5
  38. package/src/persistence/datastore/db.ts +5 -3
  39. package/src/persistence/wallet-db.ts +28 -28
  40. package/src/services/asset.ts +69 -162
  41. package/src/services/cache.ts +12 -2
  42. package/src/services/wallet.ts +23 -21
  43. package/src/state/hooks.ts +3 -1
  44. package/src/state/slices/market.ts +47 -0
  45. package/src/state/slices/status.ts +2 -31
  46. package/src/state/slices/wallet.ts +8 -13
  47. package/src/state/store.ts +3 -0
  48. package/src/types/db.types.ts +17 -12
  49. package/src/types/wallet.types.ts +40 -16
  50. package/src/utils/asset.ts +12 -52
  51. package/src/utils/common.ts +0 -6
  52. package/src/utils/enums.ts +0 -5
  53. package/src/utils/index.ts +1 -1
  54. package/src/utils/market.ts +97 -0
  55. package/dist/types/utils/price.d.ts.map +0 -1
  56. package/src/utils/price.ts +0 -46
package/dist/index.js CHANGED
@@ -1,70 +1,69 @@
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";
11
- function T() {
12
- return k.defaultNetwork == k.testnet;
1
+ import { AddressType as O, Networks as E, Address as I, CommonUtils as $, BufferUtils as m, HDPrivateKey as J, TransactionBuilder as j, Transaction as x, UnitUtils as z, Script as b, Opcode as A, Hash as _, ScriptOpcode as L, BNExtended as F, Output as we, TxSigner as q, SighashType as X, ScriptFactory as Ae, OutputSighashType as Y, BufferWriter as ve } from "libnexa-ts";
2
+ import B from "js-big-decimal";
3
+ import { ElectrumClient as be, TransportScheme as H, ConnectionStatus as Se } from "@otoplo/electrum-client";
4
+ import { mnemonicToSeedSync as ke, generateMnemonic as Te, validateMnemonic as Ie } from "@scure/bip39";
5
+ import { DAppProvider as xe } from "wallet-comms-sdk";
6
+ import { wordlist as se } from "@scure/bip39/wordlists/english.js";
7
+ import { createSlice as S, createAsyncThunk as Ne, createSelector as W } from "@reduxjs/toolkit";
8
+ import { useSelector as Me } from "react-redux";
9
+ const w = -1, Z = 9223372036854775807n, Ee = 274710, yt = "0014461ad25081cb0119d034385ff154c8d3ad6bdd76";
10
+ function C() {
11
+ return E.defaultNetwork == E.testnet;
13
12
  }
14
- function Nt(a) {
15
- return T() ? a == "508c843a4b98fb25f57cf9ebafb245a5c16468f06519cdd467059a91e7b79d52" : a == "edc7144fe1ba4edd0edf35d7eea90f6cb1dba42314aa85da8207e97c5339c801";
13
+ function wt(a) {
14
+ return C() ? a == "508c843a4b98fb25f57cf9ebafb245a5c16468f06519cdd467059a91e7b79d52" : a == "edc7144fe1ba4edd0edf35d7eea90f6cb1dba42314aa85da8207e97c5339c801";
16
15
  }
17
- function G(a, e = E.PayToScriptTemplate) {
18
- return S.isValid(a, k.defaultNetwork, e);
16
+ function R(a, e = O.PayToScriptTemplate) {
17
+ return I.isValid(a, E.defaultNetwork, e);
19
18
  }
20
- function xt() {
21
- return `https://${T() ? "testnet-" : ""}explorer.nexa.org`;
19
+ function At() {
20
+ return `https://${C() ? "testnet-" : ""}explorer.nexa.org`;
22
21
  }
23
- function X() {
22
+ function G() {
24
23
  return Math.floor(Date.now() / 1e3);
25
24
  }
26
- function Et(a, e) {
25
+ function vt(a, e) {
27
26
  const t = (e - a) * 2, s = /* @__PURE__ */ new Date();
28
27
  return s.setMinutes(s.getMinutes() + t), s.toLocaleDateString();
29
28
  }
30
- function P(a) {
29
+ function M(a) {
31
30
  return !a || a.length === 0;
32
31
  }
33
- function Mt(a, e = 0) {
32
+ function bt(a, e = 0) {
34
33
  if (!a || a.length <= e)
35
34
  return a || "";
36
35
  const t = "...", s = Math.floor((e - t.length) / 2), n = a.slice(0, s), i = a.slice(a.length - s);
37
36
  return n + t + i;
38
37
  }
39
- function Bt(a) {
38
+ function St(a) {
40
39
  return a.length === 0 ? "" : a.charAt(0).toUpperCase() + a.substring(1);
41
40
  }
42
- function H(a) {
43
- return $.isHexa(a) ? y.hexToBuffer(a) : S.fromString(a).data;
41
+ function ae(a) {
42
+ return $.isHexa(a) ? m.hexToBuffer(a) : I.fromString(a).data;
44
43
  }
45
- function b(a) {
46
- return $.isHexa(a) ? a : y.bufferToHex(H(a));
44
+ function v(a) {
45
+ return $.isHexa(a) ? a : m.bufferToHex(ae(a));
47
46
  }
48
- function re(a) {
49
- return $.isHexa(a) ? new S(H(a), k.defaultNetwork, E.GroupIdAddress).toString() : a;
47
+ function kt(a) {
48
+ return $.isHexa(a) ? new I(ae(a), E.defaultNetwork, O.GroupIdAddress).toString() : a;
50
49
  }
51
- function V(a) {
50
+ function U(a) {
52
51
  return a == null || a === "" ? "" : BigInt(a) <= 0n ? "0" : a.toString();
53
52
  }
54
- function oe(a) {
53
+ function Q(a) {
55
54
  let e = BigInt(0), t = BigInt(0);
56
55
  return a.forEach((s) => {
57
56
  e += BigInt(s.confirmed), t += BigInt(s.unconfirmed);
58
57
  }), { confirmed: e.toString(), unconfirmed: t.toString() };
59
58
  }
60
- function J(a) {
59
+ function K(a) {
61
60
  const e = {};
62
61
  return a.forEach((t) => {
63
62
  for (const s in t)
64
63
  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() };
65
64
  }), e;
66
65
  }
67
- const le = {
66
+ const ne = {
68
67
  // Images
69
68
  //'.svg': { media: 'image', mime: 'image/svg+xml' },
70
69
  ".gif": { media: "image", mime: "image/gif" },
@@ -87,32 +86,28 @@ const le = {
87
86
  ".wav": { media: "audio", mime: "audio/wav" },
88
87
  ".m4a": { media: "audio", mime: "audio/mp4" }
89
88
  };
90
- function Ct(a) {
89
+ function Tt(a) {
91
90
  const e = a.lastIndexOf(".");
92
91
  if (e === -1) return "unknown";
93
92
  const t = a.slice(e).toLowerCase();
94
- return le[t]?.media ?? "unknown";
93
+ return ne[t]?.media ?? "unknown";
95
94
  }
96
- function Pt(a) {
95
+ function It(a) {
97
96
  const e = a.lastIndexOf(".");
98
97
  if (e === -1) return "application/octet-stream";
99
98
  const t = a.slice(e).toLowerCase();
100
- return le[t]?.mime ?? "application/octet-stream";
99
+ return ne[t]?.mime ?? "application/octet-stream";
101
100
  }
102
- function _t(a) {
101
+ function xt(a) {
103
102
  return new Promise((e) => setTimeout(e, a));
104
103
  }
105
- function He(a) {
106
- let e = U.getPrettyValue(a);
104
+ function Nt(a) {
105
+ let e = B.getPrettyValue(a);
107
106
  return e.match(/\./) && (e = e.replace(/\.?0+$/, "")), e;
108
107
  }
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;
112
- }
113
- class Ut {
108
+ class Mt {
114
109
  getPrefix() {
115
- return T() ? "testnet-" : "";
110
+ return C() ? "testnet-" : "";
116
111
  }
117
112
  async getEncryptedSeed() {
118
113
  return this.getValue("seed");
@@ -169,7 +164,7 @@ class Ut {
169
164
  }
170
165
  async getRequireAuth() {
171
166
  const e = await this.getValue("auth");
172
- return P(e) || e === "true";
167
+ return M(e) || e === "true";
173
168
  }
174
169
  async setRequireAuth(e) {
175
170
  await this.setValue("auth", JSON.stringify(e));
@@ -179,7 +174,7 @@ class Ut {
179
174
  return e ? Number(e) : void 0;
180
175
  }
181
176
  async setReleaseNotesTime(e) {
182
- P(e) ? await this.removeValue("show-notes") : await this.setValue("show-notes", e);
177
+ M(e) ? await this.removeValue("show-notes") : await this.setValue("show-notes", e);
183
178
  }
184
179
  async getIsTestnet() {
185
180
  return await this.getValue("testnet") === "1";
@@ -195,8 +190,8 @@ class Ut {
195
190
  await this.setValue("auto-lock", `${e}`);
196
191
  }
197
192
  }
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 {
193
+ var h = /* @__PURE__ */ ((a) => (a[a.MAIN = 0] = "MAIN", a[a.VAULT = 1] = "VAULT", a[a.DAPP = 2] = "DAPP", a))(h || {}), y = /* @__PURE__ */ ((a) => (a[a.RECEIVE = 0] = "RECEIVE", a[a.CHANGE = 1] = "CHANGE", a))(y || {}), N = /* @__PURE__ */ ((a) => (a.SignMessage = "signMessage", a.AddToken = "addToken", a.SignTransaction = "signTransaction", a.SendTransaction = "sendTransaction", a))(N || {});
194
+ class Et {
200
195
  store;
201
196
  updateCallback;
202
197
  constructor(e) {
@@ -240,22 +235,28 @@ class Dt {
240
235
  const s = {
241
236
  accountId: e,
242
237
  tokenIdHex: t.tokenIdHex,
243
- type: R.TOKEN,
244
- addedTime: X()
238
+ type: "token",
239
+ addedTime: G()
245
240
  };
246
- await this.store.upsertAsset(s), await this.store.upsertToken(t), this.notify({ type: "token_added", accountId: e, token: s });
241
+ await this.store.upsertToken(t), await this.saveAsset(s), this.notify({ type: "token_refresh" });
247
242
  }
248
- async getLocalTokens(e) {
249
- return this.store.getTokens(e);
243
+ async getLocalTokens(e, t, s) {
244
+ return this.store.getTokens(e, t, s);
250
245
  }
251
246
  async getToken(e) {
252
247
  return this.store.getToken(e);
253
248
  }
254
249
  async deleteToken(e, t) {
255
- await this.removeAsset(e, t), await this.store.countAssetsById(t) == 0 && await this.store.deleteToken(t), this.notify({ type: "token_removed", accountId: e, tokenId: t });
250
+ await this.removeAsset(e, t), await this.store.countAssetsById(t) == 0 && await this.store.deleteToken(t), this.notify({ type: "token_refresh" });
256
251
  }
257
- async saveNft(e, t) {
258
- await this.store.upsertNft(t), await this.saveAsset(e, !0);
252
+ async saveNft(e, t, s) {
253
+ const n = {
254
+ accountId: e,
255
+ tokenIdHex: t.tokenIdHex,
256
+ type: "nft",
257
+ addedTime: s
258
+ };
259
+ await this.store.upsertNft(t), await this.saveAsset(n), this.notify({ type: "nft_refresh" });
259
260
  }
260
261
  async getLocalNfts(e, t, s) {
261
262
  return this.store.getNfts(e, t, s);
@@ -263,8 +264,8 @@ class Dt {
263
264
  async getLocalNft(e) {
264
265
  return this.store.getNft(e);
265
266
  }
266
- async deleteNft(e, t, s = !1) {
267
- await this.removeAsset(e, t), await this.store.countAssetsById(t) == 0 && (await this.store.deleteNft(t), this.notify({ type: "nft_deleted", id: t })), s && this.notify({ type: "nft_refresh" });
267
+ async deleteNft(e, t) {
268
+ await this.removeAsset(e, t), await this.store.countAssetsById(t) == 0 && await this.store.deleteNft(t), this.notify({ type: "nft_refresh" });
268
269
  }
269
270
  async countLocalNfts(e) {
270
271
  return this.store.countNfts(e);
@@ -272,15 +273,15 @@ class Dt {
272
273
  async isNftExist(e) {
273
274
  return this.store.isNftExist(e);
274
275
  }
275
- async saveAsset(e, t = !1) {
276
- await this.store.upsertAsset(e), t && this.notify({ type: "nft_refresh" });
276
+ async getAssets(e, t) {
277
+ return this.store.getAssets(e, t);
278
+ }
279
+ async saveAsset(e) {
280
+ await this.store.upsertAsset(e);
277
281
  }
278
282
  async removeAsset(e, t) {
279
283
  return this.store.deleteAsset(e, t);
280
284
  }
281
- async isAssetExistForAccount(e, t) {
282
- return this.store.isAssetExistForAccount(e, t);
283
- }
284
285
  async saveAccount(e) {
285
286
  const t = {
286
287
  id: e.id,
@@ -297,7 +298,7 @@ class Dt {
297
298
  async getAccounts() {
298
299
  return (await this.store.getAccounts()).map((t) => ({
299
300
  ...t,
300
- type: f.DAPP,
301
+ type: h.DAPP,
301
302
  balance: JSON.parse(t.balance),
302
303
  tokensBalance: JSON.parse(t.tokensBalance)
303
304
  }));
@@ -333,7 +334,7 @@ class Dt {
333
334
  async getReceiveAddresses() {
334
335
  return (await this.store.getReceiveAddresses()).map((t) => ({
335
336
  ...t,
336
- type: f.MAIN,
337
+ type: h.MAIN,
337
338
  balance: JSON.parse(t.balance),
338
339
  tokensBalance: JSON.parse(t.tokensBalance)
339
340
  }));
@@ -341,7 +342,7 @@ class Dt {
341
342
  async getChangeAddresses() {
342
343
  return (await this.store.getChangeAddresses()).map((t) => ({
343
344
  ...t,
344
- type: f.MAIN,
345
+ type: h.MAIN,
345
346
  balance: JSON.parse(t.balance),
346
347
  tokensBalance: JSON.parse(t.tokensBalance)
347
348
  }));
@@ -352,7 +353,7 @@ class Dt {
352
353
  async getVaults() {
353
354
  return (await this.store.getVaults()).map((t) => ({
354
355
  ...t,
355
- type: f.VAULT,
356
+ type: h.VAULT,
356
357
  balance: JSON.parse(t.balance),
357
358
  tokensBalance: JSON.parse(t.tokensBalance)
358
359
  }));
@@ -370,7 +371,7 @@ class Dt {
370
371
  return this.store.upsertVault(t);
371
372
  }
372
373
  }
373
- class Vt {
374
+ class Ct {
374
375
  walletDb;
375
376
  tokens = /* @__PURE__ */ new Map();
376
377
  nfts = /* @__PURE__ */ new Map();
@@ -380,26 +381,32 @@ class Vt {
380
381
  clear() {
381
382
  this.tokens.clear(), this.nfts.clear();
382
383
  }
383
- async getTokenById(e) {
384
- if (e = b(e), this.tokens.has(e))
384
+ hasToken(e) {
385
+ return e = v(e), this.tokens.has(e);
386
+ }
387
+ hasNft(e) {
388
+ return e = v(e), this.nfts.has(e);
389
+ }
390
+ async getToken(e) {
391
+ if (e = v(e), this.tokens.has(e))
385
392
  return this.tokens.get(e);
386
393
  const t = await this.walletDb.getToken(e);
387
394
  return t && this.tokens.set(e, t), t;
388
395
  }
389
- async getNftById(e) {
390
- if (e = b(e), this.nfts.has(e))
396
+ async getNft(e) {
397
+ if (e = v(e), this.nfts.has(e))
391
398
  return this.nfts.get(e);
392
399
  const t = await this.walletDb.getLocalNft(e);
393
400
  return t && this.nfts.set(e, t), t;
394
401
  }
395
402
  removeToken(e) {
396
- this.tokens.delete(b(e));
403
+ this.tokens.delete(v(e));
397
404
  }
398
405
  removeNft(e) {
399
- this.nfts.delete(b(e));
406
+ this.nfts.delete(v(e));
400
407
  }
401
408
  }
402
- class he {
409
+ class ie {
403
410
  kvStore;
404
411
  client;
405
412
  constructor(e) {
@@ -475,7 +482,7 @@ class he {
475
482
  }
476
483
  async connect(e) {
477
484
  try {
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();
485
+ e || (e = await this.getCurrentInstance()), this.client = new be("com.otoplo.wallet", "1.4.3", e.host, e.port, e.scheme, 45 * 1e3, 10 * 1e3), await this.client.connect();
479
486
  } catch (t) {
480
487
  throw t instanceof Error ? console.info(t.message) : console.error(t), t;
481
488
  }
@@ -498,7 +505,7 @@ class he {
498
505
  const t = Date.now();
499
506
  return new Promise((s, n) => {
500
507
  const i = () => {
501
- if (this.client?.connectionStatus == Be.CONNECTED)
508
+ if (this.client?.connectionStatus == Se.CONNECTED)
502
509
  return s();
503
510
  if (Date.now() - t > e)
504
511
  return n(new Error("Rostrum Connection timeout"));
@@ -509,25 +516,25 @@ class he {
509
516
  }
510
517
  async getCurrentInstance() {
511
518
  const e = await this.kvStore.getRostrumParams();
512
- return e || he.getPredefinedInstances()[0];
519
+ return e || ie.getPredefinedInstances()[0];
513
520
  }
514
521
  static getPredefinedInstances() {
515
- return T() ? [
522
+ return C() ? [
516
523
  {
517
- scheme: F.WSS,
524
+ scheme: H.WSS,
518
525
  host: "testnet-electrum.nexa.org",
519
526
  port: 30004,
520
527
  label: "NexaOrg"
521
528
  }
522
529
  ] : [
523
530
  {
524
- scheme: F.WSS,
531
+ scheme: H.WSS,
525
532
  host: "rostrum.otoplo.com",
526
533
  port: 443,
527
534
  label: "Otoplo"
528
535
  },
529
536
  {
530
- scheme: F.WSS,
537
+ scheme: H.WSS,
531
538
  host: "electrum.nexa.org",
532
539
  port: 20004,
533
540
  label: "NexaOrg"
@@ -535,10 +542,10 @@ class he {
535
542
  ];
536
543
  }
537
544
  }
538
- function N(a, e, t) {
545
+ function k(a, e, t) {
539
546
  return `${a}'/${e}/${t}`;
540
547
  }
541
- function Ke(a) {
548
+ function Ce(a) {
542
549
  const e = a.split("/");
543
550
  return {
544
551
  account: parseInt(e[0].replace("'", "")),
@@ -546,210 +553,154 @@ function Ke(a) {
546
553
  index: parseInt(e[2])
547
554
  };
548
555
  }
549
- class Rt {
556
+ class Pt {
550
557
  seed;
551
558
  masterKey;
552
559
  accountKeys = /* @__PURE__ */ new Map();
553
560
  walletKeys = /* @__PURE__ */ new Map();
554
561
  init(e) {
555
- this.seed = typeof e == "string" ? Ce(e) : e, this.masterKey = Q.fromSeed(this.seed).deriveChild(44, !0).deriveChild(29223, !0);
562
+ this.seed = typeof e == "string" ? ke(e) : e, this.masterKey = J.fromSeed(this.seed).deriveChild(44, !0).deriveChild(29223, !0);
556
563
  }
557
564
  reset() {
558
565
  if (!this.seed)
559
566
  throw new Error("KeysManager not initialized");
560
- this.masterKey = Q.fromSeed(this.seed).deriveChild(44, !0).deriveChild(29223, !0), this.accountKeys.clear(), this.walletKeys.clear();
567
+ this.masterKey = J.fromSeed(this.seed).deriveChild(44, !0).deriveChild(29223, !0), this.accountKeys.clear(), this.walletKeys.clear();
561
568
  }
562
569
  getAccountKey(e) {
563
570
  let t = this.accountKeys.get(e);
564
571
  return t || (t = this.masterKey.deriveChild(e, !0), this.accountKeys.set(e, t)), t;
565
572
  }
566
573
  getKey(e) {
567
- const t = typeof e == "string" ? e : N(e.account, e.type, e.index);
574
+ const t = typeof e == "string" ? e : k(e.account, e.type, e.index);
568
575
  let s = this.walletKeys.get(t);
569
576
  if (!s) {
570
- const { account: n, type: i, index: o } = typeof e == "string" ? Ke(e) : e;
577
+ const { account: n, type: i, index: o } = typeof e == "string" ? Ce(e) : e;
571
578
  s = this.getAccountKey(n).deriveChild(i, !1).deriveChild(o, !1), this.walletKeys.set(t, s);
572
579
  }
573
580
  return s;
574
581
  }
575
582
  }
576
- function fe() {
577
- return {
578
- name: "NiftyArt",
579
- ticker: "NIFTY",
580
- iconUrl: "https://niftyart.cash/td/niftyicon.svg",
581
- parentGroup: "",
582
- token: T() ? "nexatest:tq8r37lcjlqazz7vuvug84q2ev50573hesrnxkv9y6hvhhl5k5qqqnmyf79mx" : "nexa:tr9v70v4s9s6jfwz32ts60zqmmkp50lqv7t0ux620d50xa7dhyqqqcg6kdm6f",
583
- tokenIdHex: T() ? "0e38fbf897c1d10bcce33883d40acb28fa7a37cc0733598526aecbdff4b50000" : "cacf3d958161a925c28a970d3c40deec1a3fe06796fe1b4a7b68f377cdb90000",
584
- decimals: 0
585
- };
586
- }
587
- function Ht(a) {
588
- return Z(Ge() + a, "raw");
589
- }
590
- function q(a) {
591
- try {
592
- const e = H(a);
593
- return O.isSubgroup(e) ? y.bufferToHex(e.subarray(0, 32)) === fe().tokenIdHex : !1;
594
- } catch {
595
- return !1;
596
- }
597
- }
598
- function Le(a) {
599
- return a = Y(a), Z(a, "json");
600
- }
601
- function Fe(a) {
602
- return a = Y(a), Z(a, "raw");
603
- }
604
- function ce(a, e) {
583
+ function Bt(a, e) {
605
584
  return a && typeof a == "string" ? a.startsWith("http") ? a.replace("http://", "https://") : a.startsWith("ipfs://") ? a : `${new URL(e).origin}${a}` : "";
606
585
  }
607
- function Kt(a) {
608
- return a ? Y(a) : null;
586
+ function Ot(a) {
587
+ return a ? Pe(a) : null;
609
588
  }
610
- function Y(a, e = "https://ipfs.nebula.markets/") {
589
+ function Pe(a, e = "https://ipfs.nebula.markets/") {
611
590
  return a?.startsWith("ipfs://") ? e + a.substring(7) : a;
612
591
  }
613
- function Ge() {
614
- return `https://${T() ? "testnet." : ""}niftyart.cash/_public/`;
592
+ function Be(a) {
593
+ return Oe(`${re()}/metadata/${a}`, "json");
594
+ }
595
+ function _t(a, e) {
596
+ return `${re()}/assets/${a}/${e}`;
615
597
  }
616
- async function Z(a, e) {
598
+ function re() {
599
+ return `https://${C() ? "testapi" : "api"}.otoplo.com`;
600
+ }
601
+ async function Oe(a, e) {
617
602
  try {
618
603
  const t = await fetch(a);
619
604
  if (!t.ok)
620
605
  throw new Error(`Failed to perform GET. status: ${t.status}`);
621
- if (e === "raw") {
622
- const s = await t.arrayBuffer();
623
- return new Uint8Array(s);
624
- } else
625
- return await t.json();
606
+ if (e !== "raw") return await t.json();
626
607
  } catch (t) {
627
608
  throw new Error(`Unexpected Error: ${t}`);
628
609
  }
629
610
  }
630
- class Lt {
611
+ class Ut {
631
612
  walletDb;
632
- rostrumService;
633
613
  walletCache;
634
- constructor(e, t, s) {
635
- this.walletDb = e, this.rostrumService = t, this.walletCache = s;
614
+ constructor(e, t) {
615
+ this.walletDb = e, this.walletCache = t;
636
616
  }
637
- async getTokenInfo(e, t = !0) {
617
+ async getAssetInfo(e) {
638
618
  try {
639
- if (t) {
640
- const c = await this.walletCache.getTokenById(e);
641
- if (c)
642
- return c;
619
+ if (this.walletCache.hasToken(e)) {
620
+ const t = await this.walletCache.getToken(e);
621
+ return {
622
+ type: "token",
623
+ parent: t.parent,
624
+ token: t.token,
625
+ tokenIdHex: t.tokenIdHex,
626
+ data: {
627
+ name: t.name,
628
+ ticker: t.ticker,
629
+ decimals: t.decimals,
630
+ iconUrl: t.iconUrl
631
+ }
632
+ };
643
633
  }
644
- const s = await this.rostrumService.getTokenGenesis(e), n = y.hexToBuffer(s.token_id_hex);
645
- let i = "", o = "";
646
- if (s.op_return_id == I.NRC2 || s.op_return_id == I.NRC3 || q(e))
647
- return;
648
- if (O.isSubgroup(n) && (i = new S(O.getParentGroupId(n), k.defaultNetwork, E.GroupIdAddress).toString()), s.document_url)
649
- try {
650
- if (s.op_return_id == I.NRC1) {
651
- const c = await Fe(s.document_url), u = (await Oe.loadAsync(c)).file("info.json");
652
- if (u) {
653
- const l = await u.async("string"), h = JSON.parse(l);
654
- o = ce(h[0]?.icon, s.document_url);
655
- }
656
- } else {
657
- const c = await Le(s.document_url);
658
- o = ce(c[0]?.icon, s.document_url);
634
+ if (this.walletCache.hasNft(e)) {
635
+ const t = await this.walletCache.getNft(e);
636
+ return {
637
+ type: "nft",
638
+ parent: t.parent,
639
+ token: t.token,
640
+ tokenIdHex: t.tokenIdHex,
641
+ data: {
642
+ name: t.name,
643
+ series: t.series,
644
+ collection: t.collection,
645
+ author: t.author,
646
+ public: t.public,
647
+ front: t.front,
648
+ back: t.back
659
649
  }
660
- } catch (c) {
661
- console.error("Failed to load metadata", c);
662
- }
663
- return {
664
- token: s.group,
665
- tokenIdHex: s.token_id_hex,
666
- decimals: s.decimal_places ?? 0,
667
- parentGroup: i,
668
- name: s.name ?? "",
669
- ticker: s.ticker ?? "",
670
- iconUrl: o
671
- };
672
- } catch (s) {
673
- console.error(s);
674
- return;
675
- }
676
- }
677
- async isNftToken(e) {
678
- try {
679
- if (q(e) || await this.walletCache.getNftById(e) || (await this.rostrumService.getTokenGenesis(e)).op_return_id == I.NRC3)
680
- return !0;
650
+ };
651
+ }
652
+ return await Be(e);
681
653
  } catch (t) {
682
654
  console.error(t);
655
+ return;
683
656
  }
684
- return !1;
685
- }
686
- async getAssetInfo(e) {
687
- let t = await this.getTokenInfo(e);
688
- return t || await this.isNftToken(e) && (t = {
689
- token: re(e),
690
- tokenIdHex: b(e),
691
- decimals: 0
692
- }), t;
693
657
  }
694
658
  async handleNftReceive(e, t, s) {
695
- if (await this.walletDb.isNftExist(t)) {
696
- const o = {
697
- accountId: e,
698
- tokenIdHex: t,
699
- type: R.NFT,
700
- addedTime: s
659
+ const n = await this.getAssetInfo(t);
660
+ if (n && n.type == "nft") {
661
+ const i = {
662
+ token: n.token,
663
+ tokenIdHex: n.tokenIdHex,
664
+ parent: n.parent,
665
+ ...n.data
701
666
  };
702
- await this.walletDb.saveAsset(o, !0);
703
- return;
667
+ await this.walletDb.saveNft(e, i, s);
704
668
  }
705
- const i = await this.rostrumService.getTokenGenesis(t);
706
- if (i.op_return_id == I.NRC3) {
707
- const o = H(t);
708
- if (O.isSubgroup(o)) {
709
- const r = new S(o.subarray(0, 32), k.defaultNetwork, E.GroupIdAddress).toString(), c = await this.rostrumService.getTokenGenesis(r);
710
- c?.op_return_id == I.NRC2 && await this.saveNft(e, t, i.document_url ?? "", r, s, c?.name ?? "");
711
- }
712
- } else q(t) && await this.saveNft(e, t, "nifty", fe().token, s, "");
713
669
  }
714
- async saveNft(e, t, s, n, i, o) {
715
- if (s)
716
- try {
717
- const r = {
718
- accountId: e,
719
- tokenIdHex: t,
720
- type: R.NFT,
721
- addedTime: i
722
- }, c = {
723
- parentGroup: n,
724
- token: re(t),
725
- tokenIdHex: t,
726
- source: s,
727
- collection: o
728
- };
729
- await this.walletDb.saveNft(r, c);
730
- } catch (r) {
731
- console.error("failed to save NFT", r);
732
- }
733
- }
734
- async fetchAndSaveTokens(e, t) {
670
+ async syncTokens(e, t) {
735
671
  for (const s in t) {
736
- const n = await this.getTokenInfo(s);
737
- n && await this.walletDb.saveToken(e, n);
672
+ const n = t[s];
673
+ if (n && BigInt(n.confirmed) + BigInt(n.unconfirmed) > 0n) {
674
+ const i = await this.getAssetInfo(s);
675
+ if (i && i.type == "token") {
676
+ const o = {
677
+ token: i.token,
678
+ tokenIdHex: i.tokenIdHex,
679
+ parent: i.parent,
680
+ ...i.data
681
+ };
682
+ await this.walletDb.saveToken(e, o);
683
+ }
684
+ }
738
685
  }
739
686
  }
740
687
  async syncNfts(e, t) {
741
- const s = Object.keys(t), n = await this.walletDb.getLocalNfts(e, 1, 1e3), i = async (r) => {
742
- await this.walletDb.deleteNft(e, r, !0), this.walletCache.removeNft(r);
743
- }, o = n?.filter((r) => !s.includes(r.tokenIdHex)) ?? [];
744
- for (const r of o)
745
- await i(r.tokenIdHex);
746
- for (const [r, c] of Object.entries(t)) {
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()));
688
+ const s = Object.keys(t), n = await this.walletDb.getAssets(e, "nft"), i = n?.filter((o) => !s.includes(o.tokenIdHex)) ?? [];
689
+ for (const o of i)
690
+ await this.deleteNft(e, o.tokenIdHex);
691
+ for (const [o, r] of Object.entries(t)) {
692
+ const c = v(o), d = r && BigInt(r.confirmed) + BigInt(r.unconfirmed) > 0n, u = n?.some((l) => l.tokenIdHex == c);
693
+ !d && !u || d && u || (!d && u ? await this.deleteNft(e, c) : await this.handleNftReceive(e, c, G()));
749
694
  }
750
695
  }
696
+ async deleteToken(e, t) {
697
+ await this.walletDb.deleteToken(e, t), this.walletCache.removeToken(t);
698
+ }
699
+ async deleteNft(e, t) {
700
+ await this.walletDb.deleteNft(e, t), this.walletCache.removeNft(t);
701
+ }
751
702
  }
752
- class Ft {
703
+ class Dt {
753
704
  rostrumService;
754
705
  keyManager;
755
706
  walletDb;
@@ -768,7 +719,7 @@ class Ft {
768
719
  return { txs: i, lastHeight: s };
769
720
  }
770
721
  async fetchVaultTransactions(e) {
771
- const t = await this.rostrumService.getTransactionsHistory(e, Re), s = [];
722
+ const t = await this.rostrumService.getTransactionsHistory(e, Ee), s = [];
772
723
  for (const n of t) {
773
724
  const i = this.classifyTransaction(n.tx_hash, [e]);
774
725
  s.push(i);
@@ -797,23 +748,23 @@ class Ft {
797
748
  async classifyTransaction(e, t) {
798
749
  const s = await this.rostrumService.getTransaction(e), n = [], i = [], o = [], r = [];
799
750
  for (const l of s.vin) {
800
- const h = {
751
+ const p = {
801
752
  address: l.addresses[0],
802
753
  nexaAmount: l.value_satoshi.toString(),
803
754
  assetId: l.token_id_hex ?? "",
804
- assetAmount: V(l.groupQuantity)
755
+ assetAmount: U(l.groupQuantity)
805
756
  };
806
- t.includes(h.address) ? n.push(h) : i.push(h);
757
+ t.includes(p.address) ? n.push(p) : i.push(p);
807
758
  }
808
759
  for (const l of s.vout) {
809
- if (P(l.scriptPubKey.addresses)) continue;
810
- const h = {
760
+ if (M(l.scriptPubKey.addresses)) continue;
761
+ const p = {
811
762
  address: l.scriptPubKey.addresses[0],
812
763
  nexaAmount: l.value_satoshi.toString(),
813
764
  assetId: l.scriptPubKey.token_id_hex ?? "",
814
- assetAmount: V(l.scriptPubKey.groupQuantity)
765
+ assetAmount: U(l.scriptPubKey.groupQuantity)
815
766
  };
816
- t.includes(h.address) ? o.push(h) : r.push(h);
767
+ t.includes(p.address) ? o.push(p) : r.push(p);
817
768
  }
818
769
  let c;
819
770
  n.length === 0 ? c = "receive" : o.length === 0 ? c = "send" : i.length === 0 && r.length === 0 ? c = "self" : i.length === 0 && r.length > 0 ? c = "send" : i.length > 0 && r.length === 0 ? c = "receive" : c = "swap";
@@ -823,7 +774,7 @@ class Ft {
823
774
  // Will be set in classifyAndSaveTransaction
824
775
  txId: s.txid,
825
776
  txIdem: s.txidem,
826
- time: d ? s.time : X(),
777
+ time: d ? s.time : G(),
827
778
  height: d ? s.height : 0,
828
779
  type: c,
829
780
  fee: s.fee_satoshi.toString(),
@@ -839,72 +790,72 @@ class Ft {
839
790
  r && u.feePerByte(r);
840
791
  let l = /* @__PURE__ */ new Map();
841
792
  o && (l = await this.populateTokenInputsAndChange(u, e, s, o, BigInt(n)));
842
- const h = await this.populateNexaInputsAndChange(u, e, s, d);
843
- return l.forEach((p, _) => h.set(_, p)), await this.finalizeTransaction(u, Array.from(h.values()));
793
+ const p = await this.populateNexaInputsAndChange(u, e, s, d);
794
+ return l.forEach((f, P) => p.set(P, f)), await this.finalizeTransaction(u, Array.from(p.values()));
844
795
  }
845
796
  async buildAndSignConsolidateTransaction(e, t, s) {
846
797
  const n = {
847
798
  isConsolidate: !0,
848
799
  templateData: s
849
- }, i = new ee(), o = await this.populateNexaInputsAndChange(i, e, t, n);
800
+ }, i = new j(), o = await this.populateNexaInputsAndChange(i, e, t, n);
850
801
  return this.finalizeTransaction(i, Array.from(o.values()));
851
802
  }
852
803
  prepareTransaction(e, t, s, n) {
853
- if (!G(e) && !G(e, E.PayToPublicKeyHash))
804
+ if (!R(e) && !R(e, O.PayToPublicKeyHash))
854
805
  throw new Error("Invalid Address.");
855
- if (s && BigInt(t) < 1n || !s && parseInt(t) < B.DUST_AMOUNT)
806
+ if (s && BigInt(t) < 1n || !s && parseInt(t) < x.DUST_AMOUNT)
856
807
  throw new Error("The amount is too low.");
857
- if (s && BigInt(t) > ie || !s && parseInt(t) > B.MAX_MONEY)
808
+ if (s && BigInt(t) > Z || !s && parseInt(t) > x.MAX_MONEY)
858
809
  throw new Error("The amount is too high.");
859
- const i = new ee();
810
+ const i = new j();
860
811
  if (n && i.addData(n), s) {
861
- if (!G(s, E.GroupIdAddress))
812
+ if (!R(s, O.GroupIdAddress))
862
813
  throw new Error("Invalid Token ID");
863
- if (S.getOutputType(e) === 0)
814
+ if (I.getOutputType(e) === 0)
864
815
  throw new Error("Token must be sent to script template address");
865
- i.to(e, B.DUST_AMOUNT, s, BigInt(t));
816
+ i.to(e, x.DUST_AMOUNT, s, BigInt(t));
866
817
  } else
867
818
  i.to(e, t);
868
819
  return i;
869
820
  }
870
821
  async populateNexaInputsAndChange(e, t, s, n) {
871
822
  const i = t.filter((d) => BigInt(d.balance.confirmed) + BigInt(d.balance.unconfirmed) > 0n);
872
- if (P(i))
823
+ if (M(i))
873
824
  throw new Error("Not enough Nexa balance.");
874
825
  const o = /* @__PURE__ */ new Map(), r = n.isConsolidate ? 0 : Number(e.transaction.outputs.find((d) => d.value > 0n).value);
875
826
  for (const d of i) {
876
827
  const u = await this.rostrumService.getNexaUtxos(d.address);
877
828
  for (const l of u) {
878
- const h = {
829
+ const p = {
879
830
  outpoint: l.outpoint_hash,
880
831
  address: d.address,
881
832
  satoshis: l.value,
882
833
  templateData: n.templateData
883
834
  };
884
- if (e.from(h), !o.has(d.address)) {
885
- const p = this.keyManager.getKey(d.keyPath);
886
- o.set(d.address, p.privateKey);
835
+ if (e.from(p), !o.has(d.address)) {
836
+ const f = this.keyManager.getKey(d.keyPath);
837
+ o.set(d.address, f.privateKey);
887
838
  }
888
839
  if (n.isConsolidate) {
889
840
  if (e.change(s), e.transaction.inputs.length > this.MAX_INPUTS_OUTPUTS)
890
841
  return o;
891
842
  } else {
892
- const p = e.transaction;
893
- if (p.inputs.length > this.MAX_INPUTS_OUTPUTS)
843
+ const f = e.transaction;
844
+ if (f.inputs.length > this.MAX_INPUTS_OUTPUTS)
894
845
  throw new Error("Too many inputs. Consider consolidate transactions or reduce the send amount.");
895
- const _ = p.getUnspentValue();
896
- if (_ < 0n)
846
+ const P = f.getUnspentValue();
847
+ if (P < 0n)
897
848
  continue;
898
- if (_ == 0n && n.feeFromAmount) {
899
- const K = p.estimateRequiredFee();
900
- return p.updateOutputAmount(0, r - K), o;
849
+ if (P == 0n && n.feeFromAmount) {
850
+ const D = f.estimateRequiredFee();
851
+ return f.updateOutputAmount(0, r - D), o;
901
852
  }
902
853
  if (e.change(s), n.feeFromAmount) {
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));
854
+ const D = f.getChangeOutput();
855
+ let V = f.estimateRequiredFee();
856
+ f.updateOutputAmount(0, r - V), !D && f.getChangeOutput() && (V = f.estimateRequiredFee(), f.updateOutputAmount(0, r - V));
906
857
  }
907
- if (p.getUnspentValue() < p.estimateRequiredFee())
858
+ if (f.getUnspentValue() < f.estimateRequiredFee())
908
859
  continue;
909
860
  return o;
910
861
  }
@@ -917,39 +868,39 @@ class Ft {
917
868
  }
918
869
  const c = {
919
870
  errorMsg: "Not enough Nexa balance.",
920
- amount: te.formatNEXA(e.transaction.outputs[0].value),
921
- fee: te.formatNEXA(e.transaction.estimateRequiredFee())
871
+ amount: z.formatNEXA(e.transaction.outputs[0].value),
872
+ fee: z.formatNEXA(e.transaction.estimateRequiredFee())
922
873
  };
923
874
  throw new Error(JSON.stringify(c));
924
875
  }
925
876
  async populateTokenInputsAndChange(e, t, s, n, i) {
926
- const o = b(n), r = t.filter((u) => Object.keys(u.tokensBalance).includes(o));
927
- if (P(r))
877
+ const o = v(n), r = t.filter((u) => Object.keys(u.tokensBalance).includes(o));
878
+ if (M(r))
928
879
  throw new Error("Not enough token balance.");
929
880
  const c = /* @__PURE__ */ new Map();
930
881
  let d = 0n;
931
882
  for (const u of r) {
932
883
  const l = await this.rostrumService.getTokenUtxos(u.address, n);
933
- for (const h of l)
934
- if (!(BigInt(h.token_amount) < 0n)) {
884
+ for (const p of l)
885
+ if (!(BigInt(p.token_amount) < 0n)) {
935
886
  if (e.from({
936
- outpoint: h.outpoint_hash,
887
+ outpoint: p.outpoint_hash,
937
888
  address: u.address,
938
- satoshis: h.value,
939
- groupId: h.group,
940
- groupAmount: BigInt(h.token_amount)
941
- }), d = d + BigInt(h.token_amount), !c.has(u.address)) {
942
- const p = this.keyManager.getKey(u.keyPath);
943
- c.set(u.address, p.privateKey);
889
+ satoshis: p.value,
890
+ groupId: p.group,
891
+ groupAmount: BigInt(p.token_amount)
892
+ }), d = d + BigInt(p.token_amount), !c.has(u.address)) {
893
+ const f = this.keyManager.getKey(u.keyPath);
894
+ c.set(u.address, f.privateKey);
944
895
  }
945
- if (d > ie)
896
+ if (d > Z)
946
897
  throw new Error("Token inputs exceeded max amount. Consider sending in small chunks");
947
898
  if (e.transaction.inputs.length > this.MAX_INPUTS_OUTPUTS)
948
899
  throw new Error("Too many inputs. Consider consolidating transactions or reduce the send amount.");
949
900
  if (d == i)
950
901
  return c;
951
902
  if (d > i)
952
- return e.to(s, B.DUST_AMOUNT, n, d - i), c;
903
+ return e.to(s, x.DUST_AMOUNT, n, d - i), c;
953
904
  }
954
905
  }
955
906
  throw new Error("Not enough token balance");
@@ -968,13 +919,13 @@ class Ft {
968
919
  return JSON.stringify(t, null, 2);
969
920
  }
970
921
  }
971
- function Gt(a = 12) {
972
- return Pe(ue, a === 24 ? 256 : 128);
922
+ function Vt(a = 12) {
923
+ return Te(se, a === 24 ? 256 : 128);
973
924
  }
974
- function Je(a) {
975
- return _e(a, ue);
925
+ function _e(a) {
926
+ return Ie(a, se);
976
927
  }
977
- async function pe(a, e) {
928
+ async function oe(a, e) {
978
929
  const t = await crypto.subtle.importKey(
979
930
  "raw",
980
931
  new Uint8Array(a),
@@ -998,19 +949,19 @@ async function pe(a, e) {
998
949
  ["encrypt", "decrypt"]
999
950
  );
1000
951
  }
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(
952
+ async function Ht(a, e) {
953
+ const t = m.utf8ToBuffer(e), s = m.getRandomBuffer(16), n = m.getRandomBuffer(12), i = m.utf8ToBuffer(a), o = await oe(t, s), r = await crypto.subtle.encrypt(
1003
954
  {
1004
955
  name: "AES-GCM",
1005
956
  iv: new Uint8Array(n)
1006
957
  },
1007
958
  o,
1008
959
  new Uint8Array(i)
1009
- ), c = y.concat([s, n, new Uint8Array(r)]);
1010
- return y.bufferToBase64(c);
960
+ ), c = m.concat([s, n, new Uint8Array(r)]);
961
+ return m.bufferToBase64(c);
1011
962
  }
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(
963
+ async function Ue(a, e) {
964
+ const t = m.utf8ToBuffer(e), s = m.base64ToBuffer(a), n = s.slice(0, 16), i = s.slice(16, 28), o = s.slice(28), r = await oe(t, n), c = await crypto.subtle.decrypt(
1014
965
  {
1015
966
  name: "AES-GCM",
1016
967
  iv: i
@@ -1018,13 +969,13 @@ async function qe(a, e) {
1018
969
  r,
1019
970
  o
1020
971
  );
1021
- return y.bufferToUtf8(new Uint8Array(c));
972
+ return m.bufferToUtf8(new Uint8Array(c));
1022
973
  }
1023
- async function qt(a, e) {
974
+ async function Rt(a, e) {
1024
975
  try {
1025
976
  if (a) {
1026
- const t = await qe(a, e);
1027
- if (t && Je(t))
977
+ const t = await Ue(a, e);
978
+ if (t && _e(t))
1028
979
  return t;
1029
980
  }
1030
981
  return !1;
@@ -1032,57 +983,83 @@ async function qt(a, e) {
1032
983
  return !1;
1033
984
  }
1034
985
  }
1035
- const ye = [
986
+ const ce = [
1036
987
  { code: "usd", symbol: "$", name: "US Dollar" },
1037
988
  { code: "eur", symbol: "€", name: "Euro" },
1038
989
  { code: "gbp", symbol: "£", name: "British Pound" },
1039
- { code: "cny", symbol: "¥", name: "Chinese Yuan" },
1040
- { code: "jpy", symbol: "¥", name: "Japanese Yen" },
1041
990
  { code: "aud", symbol: "A$", name: "Australian Dollar" },
1042
991
  { 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}`);
1049
- if (!e.ok)
1050
- throw new Error("Failed to fetch price");
1051
- return (await e.json()).nexacoin || {};
992
+ { code: "chf", symbol: "Fr", name: "Swiss Franc" },
993
+ { code: "inr", symbol: "₹", name: "Indian Rupee" },
994
+ { code: "cny", symbol: "¥", name: "Chinese Yuan" },
995
+ { code: "jpy", symbol: "¥", name: "Japanese Yen" }
996
+ ], De = Object.fromEntries(
997
+ ce.map((a) => [a.code, a.symbol])
998
+ ), Kt = ce.map((a) => a.code), ee = {
999
+ nexacoin: "nexa"
1000
+ };
1001
+ async function Ve(a) {
1002
+ const e = Object.keys(ee).join(","), t = await fetch(`https://api.coingecko.com/api/v3/coins/markets?ids=${e}&vs_currency=${a}`);
1003
+ if (!t.ok)
1004
+ throw new Error("Failed to fetch market data");
1005
+ const s = await t.json(), n = {};
1006
+ return s.forEach((i) => {
1007
+ n[ee[i.id]] = {
1008
+ id: i.id,
1009
+ name: i.name ?? "",
1010
+ symbol: i.symbol ?? "",
1011
+ image: i.image ?? "",
1012
+ price: i.current_price ?? 0,
1013
+ priceChange: i.price_change_24h,
1014
+ priceChangePercentage: i.price_change_percentage_24h,
1015
+ marketCap: i.market_cap,
1016
+ fdv: i.fully_diluted_valuation,
1017
+ circSupply: i.circulating_supply,
1018
+ totalSupply: i.total_supply,
1019
+ maxSupply: i.max_supply,
1020
+ totalVolume: i.total_volume
1021
+ };
1022
+ }), n;
1052
1023
  }
1053
- function Wt(a) {
1054
- return We[a] || a;
1024
+ function Lt(a) {
1025
+ return De[a] || a;
1055
1026
  }
1056
- function ge() {
1057
- const a = {};
1058
- return me.forEach((e) => {
1059
- a[e] = { value: 0, change: 0 };
1060
- }), a;
1027
+ function Ft(a, e, t) {
1028
+ const s = B.multiply(a, e), n = B.round(s, 2, B.RoundingModes.HALF_DOWN);
1029
+ return t ? He(n, t) : n;
1061
1030
  }
1062
- function $e() {
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);
1031
+ function He(a, e, t = "en-US") {
1032
+ return new Intl.NumberFormat(t, {
1033
+ style: "currency",
1034
+ currency: e,
1035
+ maximumFractionDigits: 2,
1036
+ minimumFractionDigits: 2
1037
+ }).format(Number(a));
1064
1038
  }
1065
- function je() {
1066
- const a = $e();
1067
- return D.sha256ripemd160(a.toBuffer());
1039
+ function Re() {
1040
+ return b.empty().add(A.OP_FROMALTSTACK).add(A.OP_DROP).add(A.OP_FROMALTSTACK).add(A.OP_CHECKLOCKTIMEVERIFY).add(A.OP_DROP).add(A.OP_FROMALTSTACK).add(A.OP_CHECKSIGVERIFY);
1068
1041
  }
1069
- function Xe(a) {
1070
- return A.empty().add(a.toBuffer());
1042
+ function Ke() {
1043
+ const a = Re();
1044
+ return _.sha256ripemd160(a.toBuffer());
1071
1045
  }
1072
- function Ye(a) {
1073
- const e = Xe(a);
1074
- return D.sha256ripemd160(e.toBuffer());
1046
+ function Le(a) {
1047
+ return b.empty().add(a.toBuffer());
1075
1048
  }
1076
- function Ze(a) {
1077
- return a.map((e) => e <= 16 ? W.smallInt(e) : z.fromNumber(e).toScriptNumBuffer());
1049
+ function Fe(a) {
1050
+ const e = Le(a);
1051
+ return _.sha256ripemd160(e.toBuffer());
1078
1052
  }
1079
- function Qe(a, e) {
1053
+ function $e(a) {
1054
+ return a.map((e) => e <= 16 ? L.smallInt(e) : F.fromNumber(e).toScriptNumBuffer());
1055
+ }
1056
+ function We(a, e) {
1080
1057
  if (e.length !== 2)
1081
1058
  return;
1082
- const t = je(), s = Ye(a), n = Ze(e);
1083
- return S.fromScriptTemplate(t, s, n).toString();
1059
+ const t = Ke(), s = Fe(a), n = $e(e);
1060
+ return I.fromScriptTemplate(t, s, n).toString();
1084
1061
  }
1085
- class zt {
1062
+ class $t {
1086
1063
  walletDb;
1087
1064
  keyManager;
1088
1065
  providers;
@@ -1116,25 +1093,25 @@ class zt {
1116
1093
  }
1117
1094
  async reload(e) {
1118
1095
  for (const t of e.values()) {
1119
- if (t.id == m)
1096
+ if (t.id == w)
1120
1097
  continue;
1121
1098
  const s = await this.walletDb.getAccountSessions(t.id), n = this.providers.get(t.id), i = s.map(async (r) => {
1122
1099
  if (n?.has(r.sessionId))
1123
1100
  return;
1124
1101
  let c;
1125
1102
  try {
1126
- c = new Ue(r.uri);
1103
+ c = new xe(r.uri);
1127
1104
  const d = c.getSessionInfo();
1128
1105
  await c.connect(3e3);
1129
1106
  const u = await c.getAppInfo(2e3);
1130
1107
  await c.joinSession(t.address, 2e3);
1131
1108
  const l = await c.fetchPendingMessages();
1132
- for (const h of l)
1109
+ for (const p of l)
1133
1110
  this.notify({
1134
1111
  type: "new_notification",
1135
1112
  notification: {
1136
1113
  id: crypto.randomUUID(),
1137
- createdAt: h.createdAt,
1114
+ createdAt: p.createdAt,
1138
1115
  type: "web3",
1139
1116
  title: "Request pending approval",
1140
1117
  message: `A connected dApp (${u.name}) has requested an action from your Account: ${t.name}. Review the request details before approving or rejecting.`,
@@ -1142,7 +1119,7 @@ class zt {
1142
1119
  type: "DAPP_REQUEST",
1143
1120
  account: t.id,
1144
1121
  sessionId: d.sessionId,
1145
- payload: h.message
1122
+ payload: p.message
1146
1123
  }
1147
1124
  }
1148
1125
  });
@@ -1189,14 +1166,14 @@ class zt {
1189
1166
  const n = (i, o) => new Promise((r, c) => {
1190
1167
  this.handlers.set(i, { resolve: r, reject: c }), this.notify({ type: "new_request", request: { type: i, accountId: e.id, sessionId: s, request: o } });
1191
1168
  });
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 };
1169
+ t.onSignMessage((i) => n(N.SignMessage, i)), t.onAddToken((i) => n(N.AddToken, i)), t.onSendTransaction((i) => n(N.SendTransaction, i)), t.onSignTransaction((i) => n(N.SignTransaction, i)), t.onGetAccount(() => {
1170
+ const i = { account: h.DAPP, type: y.RECEIVE, index: e.id };
1194
1171
  return {
1195
1172
  name: e.name,
1196
1173
  address: e.address,
1197
1174
  pubkey: this.keyManager.getKey(i).publicKey.toString(),
1198
1175
  blockchain: "nexa",
1199
- network: k.defaultNetwork.name,
1176
+ network: E.defaultNetwork.name,
1200
1177
  capabilities: {
1201
1178
  addToken: !0,
1202
1179
  sendTransaction: !0,
@@ -1207,7 +1184,7 @@ class zt {
1207
1184
  });
1208
1185
  }
1209
1186
  }
1210
- class $t {
1187
+ class Wt {
1211
1188
  rostrumService;
1212
1189
  keyManager;
1213
1190
  assetService;
@@ -1224,7 +1201,7 @@ class $t {
1224
1201
  address: t.address,
1225
1202
  privateKey: this.keyManager.getKey(t.keyPath).privateKey,
1226
1203
  txDetails: {
1227
- tx: new B(e),
1204
+ tx: new x(e),
1228
1205
  send: [],
1229
1206
  receive: []
1230
1207
  },
@@ -1248,16 +1225,16 @@ class $t {
1248
1225
  await Promise.all(t);
1249
1226
  }
1250
1227
  async processInput(e, t) {
1251
- const s = e.txDetails.tx.inputs[t], n = await this.rostrumService.getUtxo(y.bufferToHex(s.outpoint));
1228
+ const s = e.txDetails.tx.inputs[t], n = await this.rostrumService.getUtxo(m.bufferToHex(s.outpoint));
1252
1229
  if (n.status == "spent")
1253
1230
  throw new Error("Input UTXO is already spent.");
1254
- if (s.output = new Ne(n.amount, n.scriptpubkey), s.output.address == e.address) {
1231
+ if (s.output = new we(n.amount, n.scriptpubkey), s.output.address == e.address) {
1255
1232
  const i = n.token_id_hex || "NEXA";
1256
1233
  e.myInputs.set(t, {
1257
1234
  address: e.address,
1258
1235
  nexaAmount: n.amount.toString(),
1259
1236
  assetId: i,
1260
- assetAmount: V(n.group_quantity) || n.amount.toString()
1237
+ assetAmount: U(n.group_quantity) || n.amount.toString()
1261
1238
  }), e.involvedAssets.add(i), s.scriptSig.isEmpty() && e.inputsToSign.add(t);
1262
1239
  }
1263
1240
  s.scriptSig.findPlaceholder() > 0 && e.inputsToSign.add(t);
@@ -1267,11 +1244,11 @@ class $t {
1267
1244
  const s = e.txDetails.tx.outputs[t].toObject();
1268
1245
  if (s.address !== e.address)
1269
1246
  continue;
1270
- const n = s.groupId ? b(s.groupId) : "NEXA", i = {
1247
+ const n = s.groupId ? v(s.groupId) : "NEXA", i = {
1271
1248
  address: s.address,
1272
1249
  nexaAmount: s.value.toString(),
1273
1250
  assetId: n,
1274
- assetAmount: V(s.groupAmount) || s.value.toString()
1251
+ assetAmount: U(s.groupAmount) || s.value.toString()
1275
1252
  };
1276
1253
  e.involvedAssets.add(n), e.myOutputs.set(t, i);
1277
1254
  }
@@ -1283,13 +1260,13 @@ class $t {
1283
1260
  const s = e.txDetails.tx.inputs[t], n = this.validateAndGetSubscript(s);
1284
1261
  if (s.scriptSig.isEmpty()) {
1285
1262
  e.allMyOutputsCovered = !0;
1286
- const i = se.sign(e.txDetails.tx, t, ae.ALL, n, e.privateKey).toTxFormat(), o = A.empty().add(e.privateKey.publicKey.toBuffer());
1287
- s.scriptSig = xe.buildScriptTemplateIn(void 0, o, A.empty().add(i));
1263
+ const i = q.sign(e.txDetails.tx, t, X.ALL, n, e.privateKey).toTxFormat(), o = b.empty().add(e.privateKey.publicKey.toBuffer());
1264
+ s.scriptSig = Ae.buildScriptTemplateIn(void 0, o, b.empty().add(i));
1288
1265
  } else {
1289
- const i = s.scriptSig.findPlaceholder(), r = s.scriptSig.chunks[i].buf.subarray(64), c = ae.fromBuffer(r);
1266
+ const i = s.scriptSig.findPlaceholder(), r = s.scriptSig.chunks[i].buf.subarray(64), c = X.fromBuffer(r);
1290
1267
  this.processSignatureCoverage(e, c);
1291
- const d = se.sign(e.txDetails.tx, t, c, n, e.privateKey).toTxFormat(r);
1292
- s.scriptSig.replaceChunk(i, A.empty().add(d));
1268
+ const d = q.sign(e.txDetails.tx, t, c, n, e.privateKey).toTxFormat(r);
1269
+ s.scriptSig.replaceChunk(i, b.empty().add(d));
1293
1270
  }
1294
1271
  }
1295
1272
  if (!e.allMyOutputsCovered)
@@ -1298,24 +1275,24 @@ class $t {
1298
1275
  validateAndGetSubscript(e) {
1299
1276
  if (e.output.scriptPubKey.isPublicKeyTemplateOut()) {
1300
1277
  if (e.scriptSig.isEmpty() || e.scriptSig.isPublicKeyTemplateIn())
1301
- return A.empty().add(v.OP_FROMALTSTACK).add(v.OP_CHECKSIGVERIFY);
1278
+ return b.empty().add(A.OP_FROMALTSTACK).add(A.OP_CHECKSIGVERIFY);
1302
1279
  throw new Error("Invalid input script type.");
1303
1280
  }
1304
1281
  if (e.output.scriptPubKey.isScriptTemplateOut()) {
1305
1282
  if (!e.scriptSig.isScriptTemplateIn())
1306
1283
  throw new Error("Unsupported input script type.");
1307
1284
  const t = e.output.scriptPubKey.getTemplateHash(), s = e.scriptSig.chunks[0].buf;
1308
- if (y.equals(t, D.sha256ripemd160(s)) || y.equals(t, D.sha256sha256(s)))
1309
- return A.fromBuffer(s);
1285
+ if (m.equals(t, _.sha256ripemd160(s)) || m.equals(t, _.sha256sha256(s)))
1286
+ return b.fromBuffer(s);
1310
1287
  throw new Error("Invalid input script template.");
1311
1288
  }
1312
1289
  throw new Error("Unsupported prevout script type.");
1313
1290
  }
1314
1291
  processSignatureCoverage(e, t) {
1315
1292
  if (!e.allMyOutputsCovered)
1316
- if (t.outType == ne.TWO)
1293
+ if (t.outType == Y.TWO)
1317
1294
  e.coveredOutputs.add(t.outData[0]), e.coveredOutputs.add(t.outData[1]), this.checkSignatureCoverage(e);
1318
- else if (t.outType == ne.FIRSTN) {
1295
+ else if (t.outType == Y.FIRSTN) {
1319
1296
  const s = t.outData[0];
1320
1297
  for (let n = 0; n < s; n++)
1321
1298
  e.coveredOutputs.add(n);
@@ -1347,8 +1324,8 @@ class $t {
1347
1324
  }
1348
1325
  }
1349
1326
  }
1350
- const et = 274710, tt = "0014461ad25081cb0119d034385ff154c8d3ad6bdd76";
1351
- class st {
1327
+ const Ge = 274710, Je = "0014461ad25081cb0119d034385ff154c8d3ad6bdd76";
1328
+ class je {
1352
1329
  rostrumService;
1353
1330
  keyManager;
1354
1331
  constructor(e, t) {
@@ -1381,16 +1358,16 @@ class st {
1381
1358
  }), n;
1382
1359
  }
1383
1360
  async checkVaultsForAddress(e) {
1384
- const t = /* @__PURE__ */ new Set(), s = await this.rostrumService.getTransactionsHistory(e, et);
1361
+ const t = /* @__PURE__ */ new Set(), s = await this.rostrumService.getTransactionsHistory(e, Ge);
1385
1362
  for (const n of s) {
1386
- const o = (await this.rostrumService.getTransaction(n.tx_hash)).vout.filter((r) => r.scriptPubKey.hex.startsWith(tt));
1363
+ const o = (await this.rostrumService.getTransaction(n.tx_hash)).vout.filter((r) => r.scriptPubKey.hex.startsWith(Je));
1387
1364
  for (const r of o)
1388
1365
  t.add(r.scriptPubKey.hex);
1389
1366
  }
1390
1367
  return t;
1391
1368
  }
1392
1369
  parseVaultDetails(e) {
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);
1370
+ const t = b.fromHex(e), s = new ve().writeVarLengthBuf(t.toBuffer()).toBuffer(), n = new I(s).toString(), i = t.getVisibleArgs(), o = F.fromScriptNumBuffer(i.chunks[0].buf).toNumber(), r = L.isSmallIntOp(i.chunks[1].opcodenum) ? L.decodeOP_N(i.chunks[1].opcodenum) : F.fromScriptNumBuffer(i.chunks[1].buf).toNumber(), c = [o, r], d = this.keyManager.getKey({ account: h.VAULT, type: y.RECEIVE, index: r }), u = We(d.publicKey, c);
1394
1371
  return n != u ? void 0 : {
1395
1372
  address: n,
1396
1373
  block: o,
@@ -1399,13 +1376,13 @@ class st {
1399
1376
  balance: { confirmed: "0", unconfirmed: "0" },
1400
1377
  tokensBalance: {},
1401
1378
  height: 0,
1402
- type: f.VAULT
1379
+ type: h.VAULT
1403
1380
  };
1404
1381
  }
1405
1382
  }
1406
- class x {
1383
+ class T {
1407
1384
  constructor(e, t, s, n, i, o, r) {
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();
1385
+ this.keyManager = e, this.kvStore = t, this.walletDb = s, this.rostrumService = n, this.assetService = i, this.transactionService = o, this.sessionManager = r, this.discoveryService = new je(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();
1409
1386
  }
1410
1387
  static GAP_LIMIT = 20;
1411
1388
  static DEBOUNCE_MS = 1e3;
@@ -1434,22 +1411,22 @@ class x {
1434
1411
  getReceiveAddress() {
1435
1412
  return this.receiveAddresses.find((e) => !e.used).address;
1436
1413
  }
1437
- getChangeAddress(e = m) {
1438
- return e != m ? this.accounts.get(e).address : this.changeAddresses.find((t) => !t.used).address;
1414
+ getChangeAddress(e = w) {
1415
+ return e != w ? this.accounts.get(e).address : this.changeAddresses.find((t) => !t.used).address;
1439
1416
  }
1440
- getUsedAddressKeys(e = m) {
1441
- if (e != m) {
1417
+ getUsedAddressKeys(e = w) {
1418
+ if (e != w) {
1442
1419
  const t = this.accounts.get(e);
1443
1420
  return [{
1444
1421
  address: t.address,
1445
- keyPath: N(f.DAPP, 0, t.id),
1422
+ keyPath: k(h.DAPP, 0, t.id),
1446
1423
  balance: t.balance,
1447
1424
  tokensBalance: t.tokensBalance
1448
1425
  }];
1449
1426
  }
1450
1427
  return this.getMainAddresses().filter((t) => t.used).map((t) => ({
1451
1428
  address: t.address,
1452
- keyPath: N(f.MAIN, t.space, t.idx),
1429
+ keyPath: k(h.MAIN, t.space, t.idx),
1453
1430
  balance: t.balance,
1454
1431
  tokensBalance: t.tokensBalance
1455
1432
  }));
@@ -1465,8 +1442,8 @@ class x {
1465
1442
  }
1466
1443
  async discoverWallet() {
1467
1444
  this.notify({ type: "discover_wallet", loading: !0 });
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();
1445
+ const e = this.discoveryService.discoverWalletIndex(h.MAIN, y.RECEIVE), t = this.discoveryService.discoverWalletIndex(h.MAIN, y.CHANGE), s = this.discoveryService.discoverWalletIndex(h.DAPP, y.RECEIVE), [n, i, o] = await Promise.all([e, t, s]);
1446
+ this.receiveAddresses = this.deriveAddresses(y.RECEIVE, 0, n + T.GAP_LIMIT), this.changeAddresses = this.deriveAddresses(y.CHANGE, 0, i + T.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();
1470
1447
  }
1471
1448
  async loadWallet() {
1472
1449
  this.receiveAddresses = await this.walletDb.getReceiveAddresses(), this.changeAddresses = await this.walletDb.getChangeAddresses();
@@ -1478,9 +1455,9 @@ class x {
1478
1455
  async initialSync() {
1479
1456
  await this.subscribeAddresses(this.getAllAddresses(), !0);
1480
1457
  const e = [];
1481
- e.push(this.assetService.fetchAndSaveTokens(m, J(this.getMainAddresses().map((t) => t.tokensBalance))));
1458
+ e.push(this.assetService.syncTokens(w, K(this.getMainAddresses().map((t) => t.tokensBalance))));
1482
1459
  for (const t of this.accounts.values())
1483
- e.push(this.assetService.fetchAndSaveTokens(t.id, t.tokensBalance));
1460
+ e.push(this.assetService.syncTokens(t.id, t.tokensBalance));
1484
1461
  await Promise.all(e);
1485
1462
  }
1486
1463
  async reconnectSync() {
@@ -1494,12 +1471,11 @@ class x {
1494
1471
  this.notify({
1495
1472
  type: "new_account",
1496
1473
  account: {
1497
- id: m,
1474
+ id: w,
1498
1475
  name: "Main Wallet",
1499
1476
  address: this.getReceiveAddress(),
1500
- balance: oe(e.map((t) => t.balance)),
1501
- tokensBalance: J(e.map((t) => t.tokensBalance)),
1502
- tokens: [],
1477
+ balance: Q(e.map((t) => t.balance)),
1478
+ tokensBalance: K(e.map((t) => t.tokensBalance)),
1503
1479
  sessions: {}
1504
1480
  }
1505
1481
  });
@@ -1512,7 +1488,6 @@ class x {
1512
1488
  address: t.address,
1513
1489
  balance: t.balance,
1514
1490
  tokensBalance: t.tokensBalance,
1515
- tokens: [],
1516
1491
  sessions: {}
1517
1492
  }
1518
1493
  });
@@ -1530,7 +1505,7 @@ class x {
1530
1505
  deriveAddresses(e, t, s) {
1531
1506
  const n = [];
1532
1507
  for (let i = t; i < t + s; i++) {
1533
- const o = N(f.MAIN, e, i), c = {
1508
+ const o = k(h.MAIN, e, i), c = {
1534
1509
  address: this.keyManager.getKey(o).privateKey.toAddress().toString(),
1535
1510
  space: e,
1536
1511
  idx: i,
@@ -1539,7 +1514,7 @@ class x {
1539
1514
  statusHash: "",
1540
1515
  balance: { confirmed: "0", unconfirmed: "0" },
1541
1516
  tokensBalance: {},
1542
- type: f.MAIN
1517
+ type: h.MAIN
1543
1518
  };
1544
1519
  n.push(c);
1545
1520
  }
@@ -1548,7 +1523,7 @@ class x {
1548
1523
  deriveAccounts(e, t) {
1549
1524
  const s = /* @__PURE__ */ new Map();
1550
1525
  for (let n = e; n < e + t; n++) {
1551
- const i = N(f.DAPP, 0, n), o = this.keyManager.getKey(i).privateKey.toAddress().toString(), r = {
1526
+ const i = k(h.DAPP, 0, n), o = this.keyManager.getKey(i).privateKey.toAddress().toString(), r = {
1552
1527
  id: n,
1553
1528
  name: `Account ${n + 1}`,
1554
1529
  address: o,
@@ -1557,7 +1532,7 @@ class x {
1557
1532
  statusHash: "",
1558
1533
  balance: { confirmed: "0", unconfirmed: "0" },
1559
1534
  tokensBalance: {},
1560
- type: f.DAPP
1535
+ type: h.DAPP
1561
1536
  };
1562
1537
  s.set(r.id, r);
1563
1538
  }
@@ -1597,7 +1572,7 @@ class x {
1597
1572
  registerUpdate(e) {
1598
1573
  this.pendingUpdates.set(e.address.address, e), clearTimeout(this.updateTimer), this.updateTimer = setTimeout(() => {
1599
1574
  this.processPendingUpdates();
1600
- }, x.DEBOUNCE_MS);
1575
+ }, T.DEBOUNCE_MS);
1601
1576
  }
1602
1577
  async processPendingUpdates() {
1603
1578
  if (this.pendingUpdates.size !== 0)
@@ -1625,7 +1600,7 @@ class x {
1625
1600
  const c = this.addressResolvers.get(r);
1626
1601
  c && (c(), this.addressResolvers.delete(r));
1627
1602
  }
1628
- await Promise.all([this.postProcessWalletUpdate(o), this.postProcessAccountUpdate(i)]);
1603
+ await Promise.all([this.postProcessWalletUpdate(o), this.postProcessAccountsUpdate(i)]);
1629
1604
  } catch (e) {
1630
1605
  console.error("Error processing pending updates:", e);
1631
1606
  } finally {
@@ -1636,27 +1611,32 @@ class x {
1636
1611
  if (e.length === 0)
1637
1612
  return;
1638
1613
  const t = /* @__PURE__ */ new Map();
1639
- for (const { txs: r } of e)
1640
- for (const c of r)
1641
- t.set(c.tx_hash, c);
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);
1646
- for (const r of t.values())
1647
- await this.transactionService.classifyAndSaveTransaction(m, r.tx_hash, s.map((c) => c.address));
1648
- await o;
1649
- }
1650
- async postProcessAccountUpdate(e) {
1651
- if (e.length !== 0)
1652
- for (const { address: t, txs: s } of e) {
1653
- const n = t;
1654
- this.notify({ type: "account_balance_updated", accountId: n.id, balance: n.balance, tokensBalance: n.tokensBalance });
1655
- const i = this.assetService.syncNfts(n.id, n.tokensBalance);
1656
- for (const o of s)
1657
- await this.transactionService.classifyAndSaveTransaction(n.id, o.tx_hash, [n.address]);
1658
- await i;
1659
- }
1614
+ for (const { txs: o } of e)
1615
+ for (const r of o)
1616
+ t.set(r.tx_hash, r);
1617
+ await this.checkGapLimit(y.RECEIVE), await this.checkGapLimit(y.CHANGE);
1618
+ const s = this.getMainAddresses(), n = Q(s.map((o) => o.balance)), i = K(s.map((o) => o.tokensBalance));
1619
+ this.notify({ type: "account_balance_updated", accountId: w, balance: n, tokensBalance: i }), this.notify({ type: "main_address_updated", address: this.getReceiveAddress() }), await this.postProcessActivity(w, Array.from(t.values()), s.map((o) => o.address), i);
1620
+ }
1621
+ async postProcessAccountsUpdate(e) {
1622
+ if (e.length === 0)
1623
+ return;
1624
+ const t = [];
1625
+ for (const { address: s, txs: n } of e) {
1626
+ const i = s;
1627
+ this.notify({ type: "account_balance_updated", accountId: i.id, balance: i.balance, tokensBalance: i.tokensBalance });
1628
+ const o = this.postProcessActivity(i.id, n, [i.address], i.tokensBalance);
1629
+ t.push(o);
1630
+ }
1631
+ await Promise.all(t);
1632
+ }
1633
+ async postProcessActivity(e, t, s, n) {
1634
+ const i = [], o = this.assetService.syncNfts(e, n);
1635
+ for (const r of t) {
1636
+ const c = this.transactionService.classifyAndSaveTransaction(e, r.tx_hash, s);
1637
+ i.push(c);
1638
+ }
1639
+ i.push(o), await Promise.all(i);
1660
1640
  }
1661
1641
  async fetchAndUpdateAddress(e, t) {
1662
1642
  e.statusHash = t, e.balance = await this.rostrumService.getBalance(e.address), e.tokensBalance = await this.rostrumService.getTokensBalance(e.address);
@@ -1674,16 +1654,16 @@ class x {
1674
1654
  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 };
1675
1655
  }
1676
1656
  async checkGapLimit(e) {
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;
1657
+ const t = e === y.RECEIVE ? this.receiveAddresses : this.changeAddresses, s = e === y.RECEIVE ? "Receive" : "Change", n = t.filter((i) => !i.used).length;
1658
+ if (n < T.GAP_LIMIT) {
1659
+ const i = T.GAP_LIMIT - n, o = t[t.length - 1].idx;
1680
1660
  console.log(`Deriving ${i} more ${s} addresses...`);
1681
1661
  const r = this.deriveAddresses(e, o + 1, i);
1682
- e === g.RECEIVE ? this.receiveAddresses.push(...r) : this.changeAddresses.push(...r), await this.saveAddresses(r), await this.subscribeAddresses(r);
1662
+ e === y.RECEIVE ? this.receiveAddresses.push(...r) : this.changeAddresses.push(...r), await this.saveAddresses(r), await this.subscribeAddresses(r);
1683
1663
  }
1684
1664
  }
1685
1665
  async addNewAccount(e, t) {
1686
- const s = N(f.DAPP, 0, e), n = this.keyManager.getKey(s).privateKey.toAddress().toString(), i = {
1666
+ const s = k(h.DAPP, 0, e), n = this.keyManager.getKey(s).privateKey.toAddress().toString(), i = {
1687
1667
  id: e,
1688
1668
  name: t,
1689
1669
  address: n,
@@ -1692,9 +1672,9 @@ class x {
1692
1672
  statusHash: "",
1693
1673
  balance: { confirmed: "0", unconfirmed: "0" },
1694
1674
  tokensBalance: {},
1695
- type: f.DAPP
1675
+ type: h.DAPP
1696
1676
  };
1697
- this.accounts.set(e, i), this.accountsAddressToId.set(n, e), await this.walletDb.saveAccount(i), await this.subscribeAddresses([i]), this.notify({
1677
+ this.accounts.set(e, i), this.accountsAddressToId.set(n, e), await this.walletDb.saveAccount(i), this.notify({
1698
1678
  type: "new_account",
1699
1679
  account: {
1700
1680
  id: i.id,
@@ -1702,10 +1682,9 @@ class x {
1702
1682
  address: i.address,
1703
1683
  balance: i.balance,
1704
1684
  tokensBalance: i.tokensBalance,
1705
- tokens: [],
1706
1685
  sessions: {}
1707
1686
  }
1708
- });
1687
+ }), await this.subscribeAddresses([i]);
1709
1688
  }
1710
1689
  async updateAccountName(e, t) {
1711
1690
  if (!t)
@@ -1714,7 +1693,7 @@ class x {
1714
1693
  s.name = t, await this.walletDb.updateAccountName(e, t);
1715
1694
  }
1716
1695
  rescanAccount(e) {
1717
- if (e == m) {
1696
+ if (e == w) {
1718
1697
  const t = this.getMainAddresses();
1719
1698
  for (const s of t)
1720
1699
  s.height = 0, this.registerUpdate({ address: s, result: s.statusHash });
@@ -1735,12 +1714,12 @@ class x {
1735
1714
  statusHash: "",
1736
1715
  balance: { confirmed: "0", unconfirmed: "0" },
1737
1716
  tokensBalance: {},
1738
- type: f.VAULT
1717
+ type: h.VAULT
1739
1718
  };
1740
1719
  await this.addVault(n);
1741
1720
  }
1742
1721
  async addVault(e) {
1743
- this.vaults.set(e.address, e), await this.walletDb.saveVault(e), await this.subscribeAddresses([e]), this.notify({
1722
+ this.vaults.set(e.address, e), await this.walletDb.saveVault(e), this.notify({
1744
1723
  type: "new_vault",
1745
1724
  vault: {
1746
1725
  address: e.address,
@@ -1748,7 +1727,7 @@ class x {
1748
1727
  block: e.block,
1749
1728
  index: e.idx
1750
1729
  }
1751
- });
1730
+ }), await this.subscribeAddresses([e]);
1752
1731
  }
1753
1732
  async rescanVaults() {
1754
1733
  let e = !1;
@@ -1758,21 +1737,21 @@ class x {
1758
1737
  return await Promise.all(s), e;
1759
1738
  }
1760
1739
  isVaultAddress(e) {
1761
- return e.type == f.VAULT;
1740
+ return e.type == h.VAULT;
1762
1741
  }
1763
1742
  isAccountAddress(e) {
1764
- return e.type == f.DAPP;
1743
+ return e.type == h.DAPP;
1765
1744
  }
1766
1745
  isMainAddress(e) {
1767
- return e.type == f.MAIN;
1746
+ return e.type == h.MAIN;
1768
1747
  }
1769
1748
  }
1770
- const at = {
1749
+ const ze = {
1771
1750
  isWalletExist: !1,
1772
1751
  isAuthorized: !1
1773
- }, we = M({
1752
+ }, de = S({
1774
1753
  name: "auth",
1775
- initialState: at,
1754
+ initialState: ze,
1776
1755
  reducers: {
1777
1756
  setWalletExist: (a, e) => {
1778
1757
  a.isWalletExist = e.payload;
@@ -1781,12 +1760,12 @@ const at = {
1781
1760
  a.isAuthorized = e.payload;
1782
1761
  }
1783
1762
  }
1784
- }), jt = we.actions, nt = we.reducer, it = {
1763
+ }), Gt = de.actions, qe = de.reducer, Xe = {
1785
1764
  modalType: null,
1786
1765
  currentRequest: null
1787
- }, ve = M({
1766
+ }, ue = S({
1788
1767
  name: "dappModal",
1789
- initialState: it,
1768
+ initialState: Xe,
1790
1769
  reducers: {
1791
1770
  showRequest(a, e) {
1792
1771
  a.modalType = e.payload.type, a.currentRequest = e.payload;
@@ -1795,24 +1774,50 @@ const at = {
1795
1774
  a.modalType = null, a.currentRequest = null;
1796
1775
  }
1797
1776
  }
1798
- }), Xt = ve.actions, rt = ve.reducer, ot = {
1777
+ }), Jt = ue.actions, Ye = ue.reducer, Ze = {
1799
1778
  counter: 0,
1800
1779
  loading: !1
1801
- }, Ae = M({
1780
+ }, le = S({
1802
1781
  name: "loader",
1803
- initialState: ot,
1782
+ initialState: Ze,
1804
1783
  reducers: {
1805
1784
  setLoader: (a, e) => {
1806
1785
  const t = e.payload.loading ? a.counter + 1 : Math.max(0, a.counter - 1);
1807
1786
  a.counter = t, a.loading = t > 0, a.text = e.payload.text;
1808
1787
  }
1809
1788
  }
1810
- }), Yt = Ae.actions, ct = Ae.reducer, dt = {
1789
+ }), jt = le.actions, Qe = le.reducer, et = {
1790
+ currency: "usd",
1791
+ data: {}
1792
+ }, te = Ne("market/updateMarketData", async (a, e) => {
1793
+ const t = e.getState();
1794
+ return await Ve(t.market.currency);
1795
+ }), he = S({
1796
+ name: "market",
1797
+ initialState: et,
1798
+ reducers: {
1799
+ setCurrency: (a, e) => {
1800
+ a.currency = e.payload;
1801
+ },
1802
+ setMarketData: (a, e) => {
1803
+ a.data = e.payload;
1804
+ }
1805
+ },
1806
+ extraReducers: (a) => {
1807
+ a.addCase(te.fulfilled, (e, t) => {
1808
+ e.data = t.payload;
1809
+ }).addCase(te.rejected, (e, t) => {
1810
+ console.error(t.error.message);
1811
+ });
1812
+ }
1813
+ });
1814
+ he.actions;
1815
+ const tt = he.reducer, st = {
1811
1816
  wallet: {},
1812
1817
  web3: {}
1813
- }, be = M({
1818
+ }, pe = S({
1814
1819
  name: "notifications",
1815
- initialState: dt,
1820
+ initialState: st,
1816
1821
  reducers: {
1817
1822
  addNotification: (a, e) => {
1818
1823
  e.payload.type == "wallet" ? a.wallet[e.payload.id] = e.payload : e.payload.type == "web3" && (a.web3[e.payload.id] = e.payload);
@@ -1824,28 +1829,14 @@ const at = {
1824
1829
  e.payload === "wallet" ? a.wallet = {} : e.payload === "web3" ? a.web3 = {} : e.payload === "all" && (a.wallet = {}, a.web3 = {});
1825
1830
  }
1826
1831
  }
1827
- }), Zt = be.actions, ut = be.reducer, lt = {
1832
+ }), zt = pe.actions, at = pe.reducer, nt = {
1828
1833
  status: "Offline",
1829
1834
  height: 0,
1830
- price: ge(),
1831
1835
  hasNetwork: !0,
1832
1836
  isSuspended: !1
1833
- }, de = De("status/fetchPrice", async () => {
1834
- const a = ge();
1835
- try {
1836
- const e = await ze();
1837
- Object.keys(e).forEach((t) => {
1838
- a[t] = {
1839
- value: e[t],
1840
- change: e[`${t}_24h_change`]
1841
- };
1842
- });
1843
- } catch {
1844
- }
1845
- return a;
1846
- }), Se = M({
1837
+ }, fe = S({
1847
1838
  name: "status",
1848
- initialState: lt,
1839
+ initialState: nt,
1849
1840
  reducers: {
1850
1841
  setHeight: (a, e) => {
1851
1842
  e.payload > 0 && (a.status = "Online"), a.height = e.payload;
@@ -1859,25 +1850,17 @@ const at = {
1859
1850
  setIsSuspended: (a, e) => {
1860
1851
  a.isSuspended = e.payload;
1861
1852
  }
1862
- },
1863
- extraReducers: (a) => {
1864
- a.addCase(de.fulfilled, (e, t) => {
1865
- e.price = t.payload;
1866
- }).addCase(de.rejected, (e, t) => {
1867
- console.error(t.error.message);
1868
- });
1869
1853
  }
1870
- }), Qt = Se.actions, ht = Se.reducer, ft = {
1854
+ }), qt = fe.actions, it = fe.reducer, rt = {
1871
1855
  isAuthorized: !1,
1872
- selectedAccount: m,
1856
+ selectedAccount: w,
1873
1857
  accounts: {
1874
1858
  "-1": {
1875
- id: m,
1859
+ id: w,
1876
1860
  name: "Main Wallet",
1877
1861
  address: "",
1878
1862
  balance: { confirmed: "0", unconfirmed: "0" },
1879
1863
  tokensBalance: {},
1880
- tokens: [],
1881
1864
  sessions: {}
1882
1865
  }
1883
1866
  },
@@ -1885,10 +1868,11 @@ const at = {
1885
1868
  sync: !1,
1886
1869
  initLoad: !0,
1887
1870
  txUpdateTrigger: 0,
1888
- nftsUpdateTrigger: 0
1889
- }, ke = M({
1871
+ nftsUpdateTrigger: 0,
1872
+ tokensUpdateTrigger: 0
1873
+ }, me = S({
1890
1874
  name: "wallet",
1891
- initialState: ft,
1875
+ initialState: rt,
1892
1876
  reducers: {
1893
1877
  setInitLoad: (a, e) => {
1894
1878
  a.initLoad = e.payload;
@@ -1909,7 +1893,7 @@ const at = {
1909
1893
  a.accounts[e.payload.id] = e.payload;
1910
1894
  },
1911
1895
  setMainAddress: (a, e) => {
1912
- a.accounts[m].address = e.payload;
1896
+ a.accounts[w].address = e.payload;
1913
1897
  },
1914
1898
  setAccountBalance: (a, e) => {
1915
1899
  a.accounts[e.payload.id].balance = e.payload.balance, a.accounts[e.payload.id].tokensBalance = e.payload.tokensBalance;
@@ -1917,21 +1901,15 @@ const at = {
1917
1901
  setAccountName: (a, e) => {
1918
1902
  a.accounts[e.payload.id].name = e.payload.name;
1919
1903
  },
1920
- setTokens: (a, e) => {
1921
- a.accounts[e.payload.id].tokens = e.payload.assets;
1922
- },
1923
- addToken: (a, e) => {
1924
- a.accounts[e.payload.id].tokens.unshift(e.payload.asset);
1925
- },
1926
- removeToken: (a, e) => {
1927
- a.accounts[e.payload.id].tokens = a.accounts[e.payload.id].tokens.filter((t) => t.tokenIdHex !== e.payload.tokenId);
1928
- },
1929
1904
  refreshTxs: (a) => {
1930
1905
  a.txUpdateTrigger++;
1931
1906
  },
1932
1907
  refreshNfts: (a) => {
1933
1908
  a.nftsUpdateTrigger++;
1934
1909
  },
1910
+ refreshTokens: (a) => {
1911
+ a.tokensUpdateTrigger++;
1912
+ },
1935
1913
  addSession(a, e) {
1936
1914
  const { accountId: t, sessionInfo: s } = e.payload;
1937
1915
  a.accounts[t].sessions[s.details.sessionId] = s;
@@ -1944,113 +1922,111 @@ const at = {
1944
1922
  a.accounts[e.payload.accountId].sessions = {};
1945
1923
  }
1946
1924
  }
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(
1925
+ }), Xt = me.actions, ot = me.reducer, Yt = {
1926
+ loader: Qe,
1927
+ dapp: Ye,
1928
+ status: it,
1929
+ wallet: ot,
1930
+ auth: qe,
1931
+ notifications: at,
1932
+ market: tt
1933
+ }, g = Me.withTypes(), Zt = () => g((a) => a.auth), Qt = (a) => g((e) => e.market.data[a]), es = () => g((a) => a.status.height), ts = (a) => g((e) => e.wallet.accounts[a]), ss = () => g((a) => a.wallet.selectedAccount), as = () => g((a) => Math.max(...Object.keys(a.wallet.accounts).map(Number))), ns = (a) => g((e) => e.wallet.accounts[a].address), is = (a) => g((e) => e.wallet.accounts[a].balance), rs = (a, e) => g((t) => t.wallet.accounts[a].tokensBalance[e]), os = (a, e) => g((t) => t.wallet.accounts[a].sessions[e]), cs = () => g((a) => a.wallet.vaults), ge = W(
1955
1934
  [(a) => a.notifications.wallet],
1956
1935
  (a) => Object.values(a).sort((e, t) => t.createdAt - e.createdAt)
1957
- ), Ie = j(
1936
+ ), ye = W(
1958
1937
  [(a) => a.notifications.web3],
1959
1938
  (a) => Object.values(a).sort((e, t) => t.createdAt - e.createdAt)
1960
- ), yt = j(
1961
- [Te, Ie],
1939
+ ), ct = W(
1940
+ [ge, ye],
1962
1941
  (a, e) => [...a, ...e].sort((t, s) => s.createdAt - t.createdAt)
1963
- ), hs = () => w(Te), fs = () => w(Ie), ps = () => w(yt);
1942
+ ), ds = () => g(ge), us = () => g(ye), ls = () => g(ct);
1964
1943
  export {
1965
- f as AccountType,
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,
2013
- ge as initializePrices,
2014
- Nt as isGenesisHashValid,
2015
- Je as isMnemonicValid,
2016
- q as isNiftySubgroup,
2017
- P as isNullOrEmpty,
2018
- T as isTestnet,
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
1944
+ h as AccountType,
1945
+ Ut as AssetService,
1946
+ ce as CURRENCIES,
1947
+ Mt as KVStore,
1948
+ Pt as KeyManager,
1949
+ y as KeySpace,
1950
+ w as MAIN_WALLET_ID,
1951
+ Z as MAX_INT64,
1952
+ ie as RostrumService,
1953
+ ee as SUPPORTED_TOKENS,
1954
+ $t as SessionManager,
1955
+ N as SessionRequestType,
1956
+ Dt as TransactionService,
1957
+ Wt as TransactionTransformer,
1958
+ Ee as VAULT_FIRST_BLOCK,
1959
+ yt as VAULT_SCRIPT_PREFIX,
1960
+ Ct as WalletCache,
1961
+ Et as WalletDB,
1962
+ T as WalletManager,
1963
+ Gt as authActions,
1964
+ qe as authReducer,
1965
+ Ft as calculateFiatValue,
1966
+ St as capitalizeFirstLetter,
1967
+ Kt as currencyCodes,
1968
+ De as currencySymbols,
1969
+ G as currentTimestamp,
1970
+ Jt as dappModalActions,
1971
+ Ye as dappModalReducer,
1972
+ Ht as encryptMnemonic,
1973
+ vt as estimateDateByFutureBlock,
1974
+ He as formatMoney,
1975
+ Vt as generateNewMnemonic,
1976
+ We as generateVaultAddress,
1977
+ Le as generateVaultConstraint,
1978
+ $e as generateVaultVisibleArgs,
1979
+ ae as getAddressBuffer,
1980
+ _t as getAssetFileUrl,
1981
+ Be as getAssetMetadata,
1982
+ Lt as getCurrencySymbol,
1983
+ At as getExplorerUrl,
1984
+ Tt as getFileMediaType,
1985
+ It as getFileMimeType,
1986
+ Ve as getMarketData,
1987
+ Fe as getVaultConstraintHash,
1988
+ Re as getVaultTemplate,
1989
+ Ke as getVaultTemplateHash,
1990
+ wt as isGenesisHashValid,
1991
+ _e as isMnemonicValid,
1992
+ M as isNullOrEmpty,
1993
+ C as isTestnet,
1994
+ R as isValidNexaAddress,
1995
+ k as keyPathToString,
1996
+ jt as loaderActions,
1997
+ Qe as loaderReducer,
1998
+ zt as notificationsActions,
1999
+ at as notificationsReducer,
2000
+ Ot as parseTokenDataUrl,
2001
+ Nt as prettifyAmount,
2002
+ Yt as sharedReducers,
2003
+ xt as sleep,
2004
+ qt as statusActions,
2005
+ it as statusReducer,
2006
+ Ce as stringToKeyPath,
2007
+ Q as sumBalance,
2008
+ K as sumTokensBalance,
2009
+ U as tokenAmountToAssetAmount,
2010
+ kt as tokenHexToAddr,
2011
+ v as tokenIdToHex,
2012
+ Bt as transformTokenIconUrl,
2013
+ bt as truncateStringMiddle,
2014
+ ts as useAccount,
2015
+ ls as useAllNotifications,
2016
+ Zt as useAuth,
2017
+ es as useBlockHeight,
2018
+ os as useDAppSession,
2019
+ as as useLastAccountId,
2020
+ ns as useMainReceiveAddress,
2021
+ Qt as useMarketData,
2022
+ ss as useSelectedAccount,
2023
+ rs as useTokenBalance,
2024
+ cs as useVaults,
2025
+ is as useWalletBalance,
2026
+ ds as useWalletNotifications,
2027
+ us as useWeb3Notifications,
2028
+ Rt as validateAndDecryptMnemonic,
2029
+ Xt as walletActions,
2030
+ ot as walletReducer
2055
2031
  };
2056
2032
  //# sourceMappingURL=index.js.map