@otoplo/wallet-common 0.1.15 → 0.2.1

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