@ecency/sdk 1.0.9 → 1.0.10

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.
@@ -95,7 +95,7 @@ wallets: Map<EcencyWalletCurrency, EcencyCreateWalletInformation>;
95
95
 
96
96
  export declare function useSeedPhrase(username: string): UseQueryResult<string, Error>;
97
97
 
98
- export declare function useSignOperation(username: string): UseMutationResult<any, Error, Operation, unknown>;
98
+ export declare function useSignOperation(username: string | undefined): UseMutationResult<any, Error, Operation, unknown>;
99
99
 
100
100
  export declare function useWalletCreate(username: string, currency: EcencyWalletCurrency): {
101
101
  createWallet: UseMutationResult<EcencyCreateWalletInformation, Error, void, unknown>;
@@ -1,5 +1,5 @@
1
1
  import { useCallback as O } from "react";
2
- import { useQuery as d, useQueryClient as f, useMutation as p } from "@tanstack/react-query";
2
+ import { useQuery as d, useQueryClient as y, useMutation as p } 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";
@@ -10,9 +10,9 @@ import { AptosWallet as D } from "@okxweb3/coin-aptos";
10
10
  import _, { mnemonicToSeedSync as j } from "bip39";
11
11
  import { LRUCache as H } from "lru-cache";
12
12
  import { PrivateKey as u, Client as E } from "@hiveio/dhive";
13
- import W from "hivesigner";
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
- function B(e) {
15
+ function W(e) {
16
16
  return new Promise((t) => setTimeout(t, e));
17
17
  }
18
18
  function g(e) {
@@ -35,10 +35,10 @@ function g(e) {
35
35
  return;
36
36
  }
37
37
  }
38
- function ye(e) {
38
+ function fe(e) {
39
39
  return j(e).toString("hex");
40
40
  }
41
- function fe(e, t) {
41
+ function ye(e, t) {
42
42
  return d({
43
43
  queryKey: ["ecency-wallets", "external-wallet-balance", e, t],
44
44
  queryFn: async () => {
@@ -74,12 +74,12 @@ function fe(e, t) {
74
74
  `https://tonapi.io/v1/blockchain/getAccount?account=${t}`
75
75
  )).json()).balance / 1e9;
76
76
  case o.APT:
77
- const y = (await (await fetch(
77
+ const f = (await (await fetch(
78
78
  `https://fullnode.mainnet.aptoslabs.com/v1/accounts/${t}/resources`
79
79
  )).json()).find(
80
80
  (k) => k.type.includes("coin::CoinStore")
81
81
  );
82
- return y ? parseInt(y.data.coin.value) / 1e8 : 0;
82
+ return f ? parseInt(f.data.coin.value) / 1e8 : 0;
83
83
  case o.ATOM:
84
84
  return +(await (await fetch(
85
85
  `https://rest.cosmos.directory/cosmoshub/auth/accounts/${t}`
@@ -172,7 +172,7 @@ function q(e) {
172
172
  }
173
173
  });
174
174
  }
175
- const J = {
175
+ const I = {
176
176
  [o.BTC]: "m/44'/0'/0'/0/0",
177
177
  // Bitcoin (BIP44)
178
178
  [o.ETH]: "m/44'/60'/0'/0/0",
@@ -189,16 +189,16 @@ const J = {
189
189
  // Cosmos (BIP44)
190
190
  };
191
191
  function Te(e, t) {
192
- const { data: n } = T(e), s = f(), a = p({
192
+ const { data: n } = T(e), s = y(), a = p({
193
193
  mutationKey: ["ecency-wallets", "create-wallet", e, t],
194
194
  mutationFn: async () => {
195
195
  if (!n)
196
196
  throw new Error("[Ecency][Wallets] - No seed to create a wallet");
197
197
  const r = g(t), c = await (r == null ? void 0 : r.getDerivedPrivateKey({
198
198
  mnemonic: n,
199
- hdPath: J[t]
199
+ hdPath: I[t]
200
200
  }));
201
- await B(1e3);
201
+ await W(1e3);
202
202
  const l = await (r == null ? void 0 : r.getNewAddress({
203
203
  privateKey: c
204
204
  }));
@@ -248,7 +248,7 @@ const m = {
248
248
  }
249
249
  )
250
250
  };
251
- function Q(e) {
251
+ function J(e) {
252
252
  const { data: t } = d({
253
253
  queryKey: ["ecency-wallets", "wallets", e]
254
254
  }), { data: n } = q(e);
@@ -301,8 +301,8 @@ function v() {
301
301
  const be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
302
302
  __proto__: null,
303
303
  useCheckWalletExistence: v,
304
- useCreateAccountWithWallets: Q
305
- }, Symbol.toStringTag, { value: "Module" })), I = {
304
+ useCreateAccountWithWallets: J
305
+ }, Symbol.toStringTag, { value: "Module" })), Q = {
306
306
  [o.BTC]: ["m/84'/0'/0'/0/0"],
307
307
  [o.ETH]: ["m/84'/60'/0'/0/0"],
308
308
  // its not working for Trust, Exodus, todo: check others below
@@ -314,7 +314,7 @@ const be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
314
314
  [o.ATOM]: ["m/84'/118'/0'/0'/0"]
315
315
  };
316
316
  async function $(e, t, n) {
317
- for (const s of I[n] || [])
317
+ for (const s of Q[n] || [])
318
318
  try {
319
319
  const a = await t.getDerivedPrivateKey({
320
320
  mnemonic: e,
@@ -330,7 +330,7 @@ async function $(e, t, n) {
330
330
  return [];
331
331
  }
332
332
  function ve(e, t) {
333
- const n = f(), { mutateAsync: s } = v();
333
+ const n = y(), { mutateAsync: s } = v();
334
334
  return p({
335
335
  mutationKey: ["ecency-wallets", "import-wallet", e, t],
336
336
  mutationFn: async ({ privateKeyOrSeed: a }) => {
@@ -397,6 +397,10 @@ function P(e = [], t, n) {
397
397
  return p({
398
398
  mutationKey: [...e, t],
399
399
  mutationFn: async (s) => {
400
+ if (!t)
401
+ throw new Error(
402
+ "[Core][Broadcast] Attempted to call broadcast API with anon user"
403
+ );
400
404
  const a = V(t);
401
405
  if (a) {
402
406
  const r = u.fromString(a);
@@ -407,7 +411,7 @@ function P(e = [], t, n) {
407
411
  }
408
412
  let i = U(t);
409
413
  if (i)
410
- return (await new W.Client({
414
+ return (await new B.Client({
411
415
  accessToken: i
412
416
  }).broadcast(n(s))).result;
413
417
  throw new Error(
@@ -462,12 +466,12 @@ function Se(e) {
462
466
  export {
463
467
  o as EcencyWalletCurrency,
464
468
  be as EcencyWalletsPrivateApi,
465
- B as delay,
469
+ W as delay,
466
470
  g as getWallet,
467
- ye as mnemonicToSeedBip39,
471
+ fe as mnemonicToSeedBip39,
468
472
  z as useAccountUpdate,
469
473
  ge as useCoinGeckoPriceQuery,
470
- fe as useGetExternalWalletBalanceQuery,
474
+ ye as useGetExternalWalletBalanceQuery,
471
475
  q as useHiveKeysQuery,
472
476
  ve as useImportWallet,
473
477
  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.9",
4
+ "version": "1.0.10",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/ecency-sdk.umd.js",