@ecency/sdk 1.0.4 → 1.0.5

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,16 +1,16 @@
1
- import { useCallback as O } from "react";
1
+ import { useCallback as k } from "react";
2
2
  import { useQuery as p, useQueryClient as f, useMutation as u } from "@tanstack/react-query";
3
- import { BtcWallet as k } from "@okxweb3/coin-bitcoin";
4
- import { EthWallet as R } from "@okxweb3/coin-ethereum";
5
- import { TrxWallet as A } from "@okxweb3/coin-tron";
3
+ import { BtcWallet as O } from "@okxweb3/coin-bitcoin";
4
+ import { EthWallet as A } from "@okxweb3/coin-ethereum";
5
+ import { TrxWallet as R } from "@okxweb3/coin-tron";
6
6
  import { TonWallet as K } from "@okxweb3/coin-ton";
7
7
  import { SolWallet as N } from "@okxweb3/coin-solana";
8
8
  import { AtomWallet as C } from "@okxweb3/coin-cosmos";
9
- import { AptosWallet as _ } from "@okxweb3/coin-aptos";
10
- import j, { mnemonicToSeedSync as x } from "bip39";
11
- import { LRUCache as D } from "lru-cache";
9
+ import { AptosWallet as x } from "@okxweb3/coin-aptos";
10
+ import D, { mnemonicToSeedSync as _ } from "bip39";
11
+ import { LRUCache as j } from "lru-cache";
12
12
  import { PrivateKey as m, Client as H } from "@hiveio/dhive";
13
- import B from "hivesigner";
13
+ import E 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) {
16
16
  return new Promise((t) => setTimeout(t, e));
@@ -18,11 +18,11 @@ function W(e) {
18
18
  function g(e) {
19
19
  switch (e) {
20
20
  case o.BTC:
21
- return new k();
21
+ return new O();
22
22
  case o.ETH:
23
- return new R();
24
- case o.TRON:
25
23
  return new A();
24
+ case o.TRON:
25
+ return new R();
26
26
  case o.TON:
27
27
  return new K();
28
28
  case o.SOL:
@@ -30,13 +30,13 @@ function g(e) {
30
30
  case o.ATOM:
31
31
  return new C();
32
32
  case o.APT:
33
- return new _();
33
+ return new x();
34
34
  default:
35
35
  return;
36
36
  }
37
37
  }
38
38
  function ye(e) {
39
- return x(e).toString("hex");
39
+ return _(e).toString("hex");
40
40
  }
41
41
  function fe(e, t) {
42
42
  return p({
@@ -49,15 +49,9 @@ function fe(e, t) {
49
49
  )).json();
50
50
  return (s.chain_stats.funded_txo_sum - s.chain_stats.spent_txo_sum) / 1e8;
51
51
  case o.ETH:
52
- return +(await (await fetch("https://eth.llamarpc.com", {
53
- method: "POST",
54
- body: JSON.stringify({
55
- jsonrpc: "2.0",
56
- id: "1",
57
- method: "eth_getBalance",
58
- params: [t, "latest"]
59
- })
60
- })).json()).result / 1e18;
52
+ return +(await (await fetch(
53
+ `https://api.ethplorer.io/getAddressInfo/${t}?apiKey=freekey`
54
+ )).json()).ETH.balance;
61
55
  case o.SOL:
62
56
  return (await (await fetch(
63
57
  "https://api.mainnet-beta.solana.com",
@@ -97,10 +91,10 @@ function fe(e, t) {
97
91
  function T(e) {
98
92
  return p({
99
93
  queryKey: ["ecency-wallets", "seed", e],
100
- queryFn: async () => j.generateMnemonic(128)
94
+ queryFn: async () => D.generateMnemonic(128)
101
95
  });
102
96
  }
103
- const E = {
97
+ const B = {
104
98
  max: 500,
105
99
  // how long to live in ms
106
100
  ttl: 1e3 * 60 * 5,
@@ -108,7 +102,7 @@ const E = {
108
102
  allowStale: !1,
109
103
  updateAgeOnGet: !1,
110
104
  updateAgeOnHas: !1
111
- }, b = new D(E), w = Symbol("undefined"), F = (e, t) => b.set(e, t === void 0 ? w : t), M = (e) => {
105
+ }, b = new j(B), w = Symbol("undefined"), F = (e, t) => b.set(e, t === void 0 ? w : t), M = (e) => {
112
106
  const t = b.get(e);
113
107
  return t === w ? void 0 : t;
114
108
  };
@@ -222,7 +216,7 @@ function Te(e, t) {
222
216
  (c) => new Map(c ? Array.from(c.entries()) : []).set(r.currency, r)
223
217
  );
224
218
  }
225
- }), i = O(() => {
219
+ }), i = k(() => {
226
220
  }, []);
227
221
  return {
228
222
  createWallet: a,
@@ -319,7 +313,7 @@ const be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
319
313
  // Disabled
320
314
  [o.ATOM]: ["m/84'/118'/0'/0'/0"]
321
315
  };
322
- async function G(e, t, n) {
316
+ async function I(e, t, n) {
323
317
  for (const s of Q[n] || [])
324
318
  try {
325
319
  const a = await t.getDerivedPrivateKey({
@@ -345,7 +339,7 @@ function ve(e, t) {
345
339
  throw new Error("Cannot find token for this currency");
346
340
  const r = a.split(" ").length === 12;
347
341
  let c, l = a;
348
- if (r ? [l, c] = await G(
342
+ if (r ? [l, c] = await I(
349
343
  a,
350
344
  i,
351
345
  t
@@ -383,7 +377,7 @@ function ve(e, t) {
383
377
  }
384
378
  });
385
379
  }
386
- function I(e) {
380
+ function $(e) {
387
381
  let t = atob(e);
388
382
  if (t[0] === "{")
389
383
  return JSON.parse(t);
@@ -393,12 +387,12 @@ const h = (e) => {
393
387
  const t = d.storage.getItem(
394
388
  d.storagePrefix + "_user_" + e
395
389
  );
396
- return I(JSON.parse(t));
390
+ return $(JSON.parse(t));
397
391
  } catch (t) {
398
392
  console.error(t);
399
393
  return;
400
394
  }
401
- }, $ = (e) => h(e) && h(e).accessToken, U = (e) => h(e) && h(e).postingKey;
395
+ }, G = (e) => h(e) && h(e).accessToken, U = (e) => h(e) && h(e).postingKey;
402
396
  function V(e = [], t, n) {
403
397
  return u({
404
398
  mutationKey: [...e, t],
@@ -411,9 +405,9 @@ function V(e = [], t, n) {
411
405
  r
412
406
  );
413
407
  }
414
- let i = $(t);
408
+ let i = G(t);
415
409
  if (i)
416
- return (await new B.Client({
410
+ return (await new E.Client({
417
411
  accessToken: i
418
412
  }).broadcast(n(s))).result;
419
413
  throw new Error(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ecency/sdk",
3
3
  "private": false,
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/ecency-sdk.umd.js",