@ecency/sdk 1.0.10 → 1.0.11

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.
@@ -1,15 +1,15 @@
1
1
  import { useCallback as O } from "react";
2
- import { useQuery as d, useQueryClient as y, useMutation as p } from "@tanstack/react-query";
2
+ import { useQuery as m, useQueryClient as f, useMutation as u } from "@tanstack/react-query";
3
3
  import { BtcWallet as A } from "@okxweb3/coin-bitcoin";
4
4
  import { EthWallet as R } from "@okxweb3/coin-ethereum";
5
5
  import { TrxWallet as K } from "@okxweb3/coin-tron";
6
- import { TonWallet as N } from "@okxweb3/coin-ton";
7
- import { SolWallet as C } from "@okxweb3/coin-solana";
6
+ import { TonWallet as C } from "@okxweb3/coin-ton";
7
+ import { SolWallet as N } from "@okxweb3/coin-solana";
8
8
  import { AtomWallet as x } from "@okxweb3/coin-cosmos";
9
- import { AptosWallet as D } from "@okxweb3/coin-aptos";
10
- import _, { mnemonicToSeedSync as j } from "bip39";
11
- import { LRUCache as H } from "lru-cache";
12
- import { PrivateKey as u, Client as E } from "@hiveio/dhive";
9
+ import { AptosWallet as j } from "@okxweb3/coin-aptos";
10
+ import D, { mnemonicToSeedSync as _ } from "bip39";
11
+ import { Client as H, PrivateKey as d } from "@hiveio/dhive";
12
+ import { LRUCache as E } from "lru-cache";
13
13
  import B from "hivesigner";
14
14
  var o = /* @__PURE__ */ ((e) => (e.BTC = "BTC", e.ETH = "ETH", e.APT = "APT", e.ATOM = "ATOM", e.TON = "TON", e.TRON = "TRX", e.SOL = "SOL", e))(o || {});
15
15
  function W(e) {
@@ -24,22 +24,48 @@ function g(e) {
24
24
  case o.TRON:
25
25
  return new K();
26
26
  case o.TON:
27
- return new N();
28
- case o.SOL:
29
27
  return new C();
28
+ case o.SOL:
29
+ return new N();
30
30
  case o.ATOM:
31
31
  return new x();
32
32
  case o.APT:
33
- return new D();
33
+ return new j();
34
34
  default:
35
35
  return;
36
36
  }
37
37
  }
38
- function fe(e) {
39
- return j(e).toString("hex");
38
+ function ye(e) {
39
+ return _(e).toString("hex");
40
40
  }
41
- function ye(e, t) {
42
- return d({
41
+ const p = {
42
+ privateApiHost: "https://ecency.com",
43
+ storage: localStorage,
44
+ storagePrefix: "ecency",
45
+ hiveClient: new H(
46
+ [
47
+ "https://api.hive.blog",
48
+ "https://api.deathwing.me",
49
+ "https://rpc.mahdiyari.info",
50
+ "https://api.openhive.network",
51
+ "https://techcoderx.com",
52
+ "https://hive-api.arcange.eu",
53
+ "https://api.syncad.com",
54
+ "https://anyx.io",
55
+ "https://api.c0ff33a.uk",
56
+ "https://hiveapi.actifit.io",
57
+ "https://hive-api.3speak.tv"
58
+ ],
59
+ {
60
+ timeout: 2e3,
61
+ failoverThreshold: 2,
62
+ consoleOnFailover: !0
63
+ }
64
+ ),
65
+ heliusApiKey: void 0
66
+ };
67
+ function fe(e, t) {
68
+ return m({
43
69
  queryKey: ["ecency-wallets", "external-wallet-balance", e, t],
44
70
  queryFn: async () => {
45
71
  switch (e) {
@@ -54,7 +80,7 @@ function ye(e, t) {
54
80
  )).json()).ETH.balance;
55
81
  case o.SOL:
56
82
  return (await (await fetch(
57
- "https://api.mainnet-beta.solana.com",
83
+ `https://rpc.helius.xyz/?api-key=${p.heliusApiKey}`,
58
84
  {
59
85
  method: "POST",
60
86
  body: JSON.stringify({
@@ -62,7 +88,10 @@ function ye(e, t) {
62
88
  id: "1",
63
89
  method: "getBalance",
64
90
  params: [t]
65
- })
91
+ }),
92
+ headers: {
93
+ "Content-Type": "application/json"
94
+ }
66
95
  }
67
96
  )).json()).result.value / 1e9;
68
97
  case o.TRON:
@@ -74,12 +103,12 @@ function ye(e, t) {
74
103
  `https://tonapi.io/v1/blockchain/getAccount?account=${t}`
75
104
  )).json()).balance / 1e9;
76
105
  case o.APT:
77
- const f = (await (await fetch(
106
+ const y = (await (await fetch(
78
107
  `https://fullnode.mainnet.aptoslabs.com/v1/accounts/${t}/resources`
79
108
  )).json()).find(
80
109
  (k) => k.type.includes("coin::CoinStore")
81
110
  );
82
- return f ? parseInt(f.data.coin.value) / 1e8 : 0;
111
+ return y ? parseInt(y.data.coin.value) / 1e8 : 0;
83
112
  case o.ATOM:
84
113
  return +(await (await fetch(
85
114
  `https://rest.cosmos.directory/cosmoshub/auth/accounts/${t}`
@@ -89,9 +118,9 @@ function ye(e, t) {
89
118
  });
90
119
  }
91
120
  function T(e) {
92
- return d({
121
+ return m({
93
122
  queryKey: ["ecency-wallets", "seed", e],
94
- queryFn: async () => _.generateMnemonic(128)
123
+ queryFn: async () => D.generateMnemonic(128)
95
124
  });
96
125
  }
97
126
  const F = {
@@ -102,12 +131,12 @@ const F = {
102
131
  allowStale: !1,
103
132
  updateAgeOnGet: !1,
104
133
  updateAgeOnHas: !1
105
- }, b = new H(F), w = Symbol("undefined"), M = (e, t) => b.set(e, t === void 0 ? w : t), L = (e) => {
134
+ }, b = new E(F), w = Symbol("undefined"), M = (e, t) => b.set(e, t === void 0 ? w : t), L = (e) => {
106
135
  const t = b.get(e);
107
136
  return t === w ? void 0 : t;
108
137
  };
109
138
  function ge(e) {
110
- return d({
139
+ return m({
111
140
  queryKey: ["ecency-wallets", "coingecko-price", e],
112
141
  queryFn: async () => {
113
142
  let t = e;
@@ -152,12 +181,12 @@ function ge(e) {
152
181
  }
153
182
  function q(e) {
154
183
  const { data: t } = T(e);
155
- return d({
184
+ return m({
156
185
  queryKey: ["ecencу-wallets", "hive-keys", e, t],
157
186
  queryFn: async () => {
158
187
  if (!t)
159
188
  throw new Error("[Ecency][Wallets] - no seed to create Hive account");
160
- const n = u.fromLogin(e, t, "owner"), s = u.fromLogin(e, t, "active"), a = u.fromLogin(e, t, "posting"), i = u.fromLogin(e, t, "memo");
189
+ const n = d.fromLogin(e, t, "owner"), s = d.fromLogin(e, t, "active"), a = d.fromLogin(e, t, "posting"), i = d.fromLogin(e, t, "memo");
161
190
  return {
162
191
  username: e,
163
192
  owner: n.toString(),
@@ -189,7 +218,7 @@ const I = {
189
218
  // Cosmos (BIP44)
190
219
  };
191
220
  function Te(e, t) {
192
- const { data: n } = T(e), s = y(), a = p({
221
+ const { data: n } = T(e), s = f(), a = u({
193
222
  mutationKey: ["ecency-wallets", "create-wallet", e, t],
194
223
  mutationFn: async () => {
195
224
  if (!n)
@@ -223,38 +252,13 @@ function Te(e, t) {
223
252
  importWallet: i
224
253
  };
225
254
  }
226
- const m = {
227
- privateApiHost: "https://ecency.com",
228
- storage: localStorage,
229
- storagePrefix: "ecency",
230
- hiveClient: new E(
231
- [
232
- "https://api.hive.blog",
233
- "https://api.deathwing.me",
234
- "https://rpc.mahdiyari.info",
235
- "https://api.openhive.network",
236
- "https://techcoderx.com",
237
- "https://hive-api.arcange.eu",
238
- "https://api.syncad.com",
239
- "https://anyx.io",
240
- "https://api.c0ff33a.uk",
241
- "https://hiveapi.actifit.io",
242
- "https://hive-api.3speak.tv"
243
- ],
244
- {
245
- timeout: 2e3,
246
- failoverThreshold: 2,
247
- consoleOnFailover: !0
248
- }
249
- )
250
- };
251
255
  function J(e) {
252
- const { data: t } = d({
256
+ const { data: t } = m({
253
257
  queryKey: ["ecency-wallets", "wallets", e]
254
258
  }), { data: n } = q(e);
255
- return p({
259
+ return u({
256
260
  mutationKey: ["ecency-wallets", "create-account-with-wallets", e],
257
- mutationFn: ({ currency: s, address: a }) => fetch(m.privateApiHost + "/private-api/wallets-add", {
261
+ mutationFn: ({ currency: s, address: a }) => fetch(p.privateApiHost + "/private-api/wallets-add", {
258
262
  method: "POST",
259
263
  headers: {
260
264
  "Content-Type": "application/json"
@@ -281,10 +285,10 @@ function J(e) {
281
285
  });
282
286
  }
283
287
  function v() {
284
- return p({
288
+ return u({
285
289
  mutationKey: ["ecency-wallets", "check-wallet-existence"],
286
290
  mutationFn: async ({ address: e, currency: t }) => (await (await fetch(
287
- m.privateApiHost + "/private-api/wallets-exist",
291
+ p.privateApiHost + "/private-api/wallets-exist",
288
292
  {
289
293
  method: "POST",
290
294
  headers: {
@@ -330,8 +334,8 @@ async function $(e, t, n) {
330
334
  return [];
331
335
  }
332
336
  function ve(e, t) {
333
- const n = y(), { mutateAsync: s } = v();
334
- return p({
337
+ const n = f(), { mutateAsync: s } = v();
338
+ return u({
335
339
  mutationKey: ["ecency-wallets", "import-wallet", e, t],
336
340
  mutationFn: async ({ privateKeyOrSeed: a }) => {
337
341
  const i = g(t);
@@ -384,8 +388,8 @@ function G(e) {
384
388
  }
385
389
  const h = (e) => {
386
390
  try {
387
- const t = m.storage.getItem(
388
- m.storagePrefix + "_user_" + e
391
+ const t = p.storage.getItem(
392
+ p.storagePrefix + "_user_" + e
389
393
  );
390
394
  return G(JSON.parse(t));
391
395
  } catch (t) {
@@ -394,7 +398,7 @@ const h = (e) => {
394
398
  }
395
399
  }, U = (e) => h(e) && h(e).accessToken, V = (e) => h(e) && h(e).postingKey;
396
400
  function P(e = [], t, n) {
397
- return p({
401
+ return u({
398
402
  mutationKey: [...e, t],
399
403
  mutationFn: async (s) => {
400
404
  if (!t)
@@ -403,8 +407,8 @@ function P(e = [], t, n) {
403
407
  );
404
408
  const a = V(t);
405
409
  if (a) {
406
- const r = u.fromString(a);
407
- return m.hiveClient.broadcast.sendOperations(
410
+ const r = d.fromString(a);
411
+ return p.hiveClient.broadcast.sendOperations(
408
412
  n(s),
409
413
  r
410
414
  );
@@ -441,7 +445,7 @@ function z(e) {
441
445
  }
442
446
  function Pe(e) {
443
447
  const { mutateAsync: t } = z(e);
444
- return p({
448
+ return u({
445
449
  mutationKey: ["ecency-wallets", "save-wallet-to-metadata", e],
446
450
  mutationFn: ({
447
451
  wallets: n
@@ -468,10 +472,10 @@ export {
468
472
  be as EcencyWalletsPrivateApi,
469
473
  W as delay,
470
474
  g as getWallet,
471
- fe as mnemonicToSeedBip39,
475
+ ye as mnemonicToSeedBip39,
472
476
  z as useAccountUpdate,
473
477
  ge as useCoinGeckoPriceQuery,
474
- ye as useGetExternalWalletBalanceQuery,
478
+ fe as useGetExternalWalletBalanceQuery,
475
479
  q as useHiveKeysQuery,
476
480
  ve as useImportWallet,
477
481
  Pe as useSaveWalletInformationToMetadata,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ecency/sdk",
3
3
  "private": false,
4
- "version": "1.0.10",
4
+ "version": "1.0.11",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/ecency-sdk.umd.js",