@ecency/wallets 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/{ecency-wallets.es.js → ecency-sdk.es.js} +173 -119
  2. package/dist/index.d.ts +1 -0
  3. package/dist/modules/wallets/enums/ecency-wallet-basic-tokens.d.ts +7 -0
  4. package/dist/modules/wallets/enums/ecency-wallet-currency.d.ts +9 -0
  5. package/dist/modules/wallets/enums/index.d.ts +2 -0
  6. package/dist/modules/wallets/functions/get-keys-from-seed.d.ts +3 -0
  7. package/dist/modules/wallets/functions/index.d.ts +1 -0
  8. package/dist/modules/wallets/index.d.ts +4 -0
  9. package/dist/modules/wallets/mutations/index.d.ts +4 -0
  10. package/dist/modules/wallets/mutations/private-api/check-wallet-existence.d.ts +7 -0
  11. package/dist/modules/wallets/mutations/private-api/create-account-with-wallets.d.ts +7 -0
  12. package/dist/modules/wallets/mutations/private-api/index.d.ts +2 -0
  13. package/dist/modules/wallets/mutations/private-api-namespace.d.ts +2 -0
  14. package/dist/modules/wallets/mutations/save-wallet-information-to-metadata.d.ts +5 -0
  15. package/dist/modules/wallets/mutations/use-import-wallet.d.ts +10 -0
  16. package/dist/modules/wallets/mutations/use-wallet-create.d.ts +6 -0
  17. package/dist/modules/wallets/queries/get-account-points-query-options.d.ts +9 -0
  18. package/dist/modules/wallets/queries/index.d.ts +6 -0
  19. package/dist/modules/wallets/queries/use-coingecko-price-query.d.ts +2 -0
  20. package/dist/modules/wallets/queries/use-get-account-wallet-list-query.d.ts +9 -0
  21. package/dist/modules/wallets/queries/use-get-all-tokens-list-query.d.ts +6 -0
  22. package/dist/modules/wallets/queries/use-get-external-wallet-query.d.ts +10 -0
  23. package/dist/modules/wallets/queries/use-hive-keys-query.d.ts +2 -0
  24. package/dist/modules/wallets/queries/use-seed-phrase.d.ts +1 -0
  25. package/dist/modules/wallets/types/account-points-response.d.ts +4 -0
  26. package/dist/modules/wallets/types/ecency-create-wallet-information.d.ts +9 -0
  27. package/dist/modules/wallets/types/ecency-hive-keys.d.ts +12 -0
  28. package/dist/modules/wallets/types/index.d.ts +3 -0
  29. package/dist/modules/wallets/utils/delay.d.ts +1 -0
  30. package/dist/modules/wallets/utils/get-wallet.d.ts +3 -0
  31. package/dist/modules/wallets/utils/index.d.ts +3 -0
  32. package/dist/modules/wallets/utils/mnemonic-to-seed-bip-39.d.ts +1 -0
  33. package/dist/vite.config.d.ts +2 -0
  34. package/package.json +10 -8
  35. package/Readme.md +0 -36
  36. package/dist/ecency-wallets.es.d.ts +0 -97
@@ -1,65 +1,57 @@
1
- import { useCallback as R } from "react";
2
- import { useQuery as p, useQueryClient as y, useMutation as m } from "@tanstack/react-query";
3
- import { BtcWallet as O } from "@okxweb3/coin-bitcoin";
4
- import { EthWallet as v } from "@okxweb3/coin-ethereum";
5
- import { TrxWallet as k } from "@okxweb3/coin-tron";
6
- import { TonWallet as A } from "@okxweb3/coin-ton";
1
+ import { useMemo as S, useCallback as A } from "react";
2
+ import { useQuery as p, queryOptions as R, useQueryClient as h, useMutation as m } from "@tanstack/react-query";
3
+ import { BtcWallet as k } from "@okxweb3/coin-bitcoin";
4
+ import { EthWallet as H } from "@okxweb3/coin-ethereum";
5
+ import { TrxWallet as C } from "@okxweb3/coin-tron";
6
+ import { TonWallet as K } from "@okxweb3/coin-ton";
7
7
  import { SolWallet as N } from "@okxweb3/coin-solana";
8
- import { AtomWallet as K } from "@okxweb3/coin-cosmos";
9
- import { AptosWallet as D } from "@okxweb3/coin-aptos";
10
- import j, { mnemonicToSeedSync as C } from "bip39";
11
- import { LRUCache as H } from "lru-cache";
12
- import { PrivateKey as u } from "@hiveio/dhive";
13
- var o = /* @__PURE__ */ ((e) => (e.BTC = "btc", e.ETH = "eth", e.APT = "aptos", e.ATOM = "cosmos", e.TON = "ton", e.TRON = "tron", e.SOL = "solana", e))(o || {});
14
- function x(e) {
8
+ import { AtomWallet as D } from "@okxweb3/coin-cosmos";
9
+ import { AptosWallet as L } from "@okxweb3/coin-aptos";
10
+ import j from "bip39";
11
+ import { CONFIG as d, getHiveEngineTokensListQueryOptions as x, useAccountUpdate as M } from "@ecency/sdk";
12
+ import { LRUCache as _ } from "lru-cache";
13
+ import { PrivateKey as w } from "@hiveio/dhive";
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 || {}), u = /* @__PURE__ */ ((e) => (e.Points = "POINTS", e.HivePower = "HP", e.Hive = "HIVE", e.HiveDollar = "HBD", e.Spk = "SPK", e))(u || {});
15
+ function E(e) {
15
16
  return new Promise((t) => setTimeout(t, e));
16
17
  }
17
- function h(e) {
18
+ function T(e) {
18
19
  switch (e) {
19
20
  case o.BTC:
20
- return new O();
21
+ return new k();
21
22
  case o.ETH:
22
- return new v();
23
+ return new H();
23
24
  case o.TRON:
24
- return new k();
25
+ return new C();
25
26
  case o.TON:
26
- return new A();
27
+ return new K();
27
28
  case o.SOL:
28
29
  return new N();
29
30
  case o.ATOM:
30
- return new K();
31
- case o.APT:
32
31
  return new D();
32
+ case o.APT:
33
+ return new L();
33
34
  default:
34
35
  return;
35
36
  }
36
37
  }
37
- function ce(e) {
38
- return C(e).toString("hex");
39
- }
40
- function ie(e, t) {
38
+ function me(e, t) {
41
39
  return p({
42
40
  queryKey: ["ecency-wallets", "external-wallet-balance", e, t],
43
41
  queryFn: async () => {
44
42
  switch (e) {
45
43
  case o.BTC:
46
- const r = await (await fetch(
44
+ const a = await (await fetch(
47
45
  `https://mempool.space/api/address/${t}`
48
46
  )).json();
49
- return (r.chain_stats.funded_txo_sum - r.chain_stats.spent_txo_sum) / 1e8;
47
+ return (a.chain_stats.funded_txo_sum - a.chain_stats.spent_txo_sum) / 1e8;
50
48
  case o.ETH:
51
- return +(await (await fetch("https://eth.llamarpc.com", {
52
- method: "POST",
53
- body: JSON.stringify({
54
- jsonrpc: "2.0",
55
- id: "1",
56
- method: "eth_getBalance",
57
- params: [t, "latest"]
58
- })
59
- })).json()).result / 1e18;
49
+ return +(await (await fetch(
50
+ `https://api.ethplorer.io/getAddressInfo/${t}?apiKey=freekey`
51
+ )).json()).ETH.balance;
60
52
  case o.SOL:
61
53
  return (await (await fetch(
62
- "https://api.mainnet-beta.solana.com",
54
+ `https://rpc.helius.xyz/?api-key=${d.heliusApiKey}`,
63
55
  {
64
56
  method: "POST",
65
57
  body: JSON.stringify({
@@ -67,7 +59,10 @@ function ie(e, t) {
67
59
  id: "1",
68
60
  method: "getBalance",
69
61
  params: [t]
70
- })
62
+ }),
63
+ headers: {
64
+ "Content-Type": "application/json"
65
+ }
71
66
  }
72
67
  )).json()).result.value / 1e9;
73
68
  case o.TRON:
@@ -79,12 +74,12 @@ function ie(e, t) {
79
74
  `https://tonapi.io/v1/blockchain/getAccount?account=${t}`
80
75
  )).json()).balance / 1e9;
81
76
  case o.APT:
82
- const d = (await (await fetch(
77
+ const f = (await (await fetch(
83
78
  `https://fullnode.mainnet.aptoslabs.com/v1/accounts/${t}/resources`
84
79
  )).json()).find(
85
- (S) => S.type.includes("coin::CoinStore")
80
+ (O) => O.type.includes("coin::CoinStore")
86
81
  );
87
- return d ? parseInt(d.data.coin.value) / 1e8 : 0;
82
+ return f ? parseInt(f.data.coin.value) / 1e8 : 0;
88
83
  case o.ATOM:
89
84
  return +(await (await fetch(
90
85
  `https://rest.cosmos.directory/cosmoshub/auth/accounts/${t}`
@@ -93,13 +88,13 @@ function ie(e, t) {
93
88
  }
94
89
  });
95
90
  }
96
- function f(e) {
91
+ function b(e) {
97
92
  return p({
98
93
  queryKey: ["ecency-wallets", "seed", e],
99
94
  queryFn: async () => j.generateMnemonic(128)
100
95
  });
101
96
  }
102
- const W = {
97
+ const F = {
103
98
  max: 500,
104
99
  // how long to live in ms
105
100
  ttl: 1e3 * 60 * 5,
@@ -107,11 +102,11 @@ const W = {
107
102
  allowStale: !1,
108
103
  updateAgeOnGet: !1,
109
104
  updateAgeOnHas: !1
110
- }, b = new H(W), w = Symbol("undefined"), _ = (e, t) => b.set(e, t === void 0 ? w : t), E = (e) => {
111
- const t = b.get(e);
112
- return t === w ? void 0 : t;
105
+ }, g = new _(F), y = Symbol("undefined"), q = (e, t) => g.set(e, t === void 0 ? y : t), W = (e) => {
106
+ const t = g.get(e);
107
+ return t === y ? void 0 : t;
113
108
  };
114
- function le(e) {
109
+ function we(e) {
115
110
  return p({
116
111
  queryKey: ["ecency-wallets", "coingecko-price", e],
117
112
  queryFn: async () => {
@@ -132,11 +127,11 @@ function le(e) {
132
127
  default:
133
128
  t = e;
134
129
  }
135
- let n = E("gecko"), r;
130
+ let n = W("gecko"), a;
136
131
  if (n)
137
- r = n;
132
+ a = n;
138
133
  else {
139
- const a = await (await fetch(
134
+ const r = await (await fetch(
140
135
  "https://api.coingecko.com/api/v3/simple/price",
141
136
  {
142
137
  method: "POST",
@@ -148,35 +143,76 @@ function le(e) {
148
143
  })
149
144
  }
150
145
  )).json();
151
- _("gecko", a === void 0 ? w : a), r = a;
146
+ q("gecko", r === void 0 ? y : r), a = r;
152
147
  }
153
- return 1 / +r[Object.keys(r)[0]].usd;
148
+ return 1 / +a[Object.keys(a)[0]].usd;
154
149
  },
155
150
  enabled: !!e
156
151
  });
157
152
  }
158
- function q(e) {
159
- const { data: t } = f(e);
153
+ function Q(e) {
154
+ const { data: t } = b(e);
160
155
  return p({
161
156
  queryKey: ["ecencу-wallets", "hive-keys", e, t],
162
157
  queryFn: async () => {
163
158
  if (!t)
164
159
  throw new Error("[Ecency][Wallets] - no seed to create Hive account");
165
- const n = u.fromLogin(e, t, "owner"), r = u.fromLogin(e, t, "active"), s = u.fromLogin(e, t, "posting"), i = u.fromLogin(e, t, "memo");
160
+ const n = w.fromLogin(e, t, "owner"), a = w.fromLogin(e, t, "active"), s = w.fromLogin(e, t, "posting"), c = w.fromLogin(e, t, "memo");
166
161
  return {
167
162
  username: e,
168
163
  owner: n.toString(),
169
- active: r.toString(),
164
+ active: a.toString(),
170
165
  posting: s.toString(),
171
- memo: i.toString(),
166
+ memo: c.toString(),
172
167
  ownerPubkey: n.createPublic().toString(),
173
- activePubkey: r.createPublic().toString(),
168
+ activePubkey: a.createPublic().toString(),
174
169
  postingPubkey: s.createPublic().toString(),
175
- memoPubkey: i.createPublic().toString()
170
+ memoPubkey: c.createPublic().toString()
176
171
  };
177
172
  }
178
173
  });
179
174
  }
175
+ function de(e, t) {
176
+ return R({
177
+ queryKey: ["ecency-wallets", "points", e, t],
178
+ queryFn: async () => await (await fetch(
179
+ `${d.privateApiHost}/private-api/points`,
180
+ {
181
+ method: "POST",
182
+ body: JSON.stringify({
183
+ username: e.replace("@", "")
184
+ })
185
+ }
186
+ )).json(),
187
+ staleTime: 3e4,
188
+ refetchOnMount: !0,
189
+ enabled: !!e
190
+ });
191
+ }
192
+ function ye(e) {
193
+ const { data: t } = p(x());
194
+ return S(
195
+ () => {
196
+ var n;
197
+ return {
198
+ basic: [
199
+ u.Points,
200
+ u.Hive,
201
+ u.HivePower,
202
+ u.HiveDollar,
203
+ u.Spk
204
+ ].filter((a) => a.toLowerCase().includes(e.toLowerCase())),
205
+ external: Object.values(o).filter(
206
+ (a) => a.toLowerCase().includes(e.toLowerCase())
207
+ ),
208
+ layer2: ((n = t == null ? void 0 : t.map(({ symbol: a }) => a)) == null ? void 0 : n.filter(
209
+ (a) => a.toLowerCase().includes(e.toLowerCase())
210
+ )) ?? []
211
+ };
212
+ },
213
+ [t, e]
214
+ );
215
+ }
180
216
  const B = {
181
217
  [o.BTC]: "m/44'/0'/0'/0/0",
182
218
  // Bitcoin (BIP44)
@@ -193,56 +229,55 @@ const B = {
193
229
  [o.ATOM]: "m/44'/118'/0'/0/0"
194
230
  // Cosmos (BIP44)
195
231
  };
196
- function pe(e, t) {
197
- const { data: n } = f(e), r = y(), s = m({
232
+ function fe(e, t) {
233
+ const { data: n } = b(e), a = h(), s = m({
198
234
  mutationKey: ["ecency-wallets", "create-wallet", e, t],
199
235
  mutationFn: async () => {
200
236
  if (!n)
201
237
  throw new Error("[Ecency][Wallets] - No seed to create a wallet");
202
- const a = h(t), c = await (a == null ? void 0 : a.getDerivedPrivateKey({
238
+ const r = T(t), i = await (r == null ? void 0 : r.getDerivedPrivateKey({
203
239
  mnemonic: n,
204
240
  hdPath: B[t]
205
241
  }));
206
- await x(1e3);
207
- const l = await (a == null ? void 0 : a.getNewAddress({
208
- privateKey: c
242
+ await E(1e3);
243
+ const l = await (r == null ? void 0 : r.getNewAddress({
244
+ privateKey: i
209
245
  }));
210
246
  return {
211
- privateKey: c,
247
+ privateKey: i,
212
248
  address: l.address,
213
249
  publicKey: l.publicKey,
214
250
  username: e,
215
251
  currency: t
216
252
  };
217
253
  },
218
- onSuccess: (a) => {
219
- r.setQueryData(
220
- ["ecency-wallets", "wallets", a.username],
221
- (c) => new Map(c ? Array.from(c.entries()) : []).set(a.currency, a)
254
+ onSuccess: (r) => {
255
+ a.setQueryData(
256
+ ["ecency-wallets", "wallets", r.username],
257
+ (i) => new Map(i ? Array.from(i.entries()) : []).set(r.currency, r)
222
258
  );
223
259
  }
224
- }), i = R(() => {
260
+ }), c = A(() => {
225
261
  }, []);
226
262
  return {
227
263
  createWallet: s,
228
- importWallet: i
264
+ importWallet: c
229
265
  };
230
266
  }
231
- const g = { privateApiHost: "https://ecency.com" };
232
- function L(e) {
267
+ function I(e) {
233
268
  const { data: t } = p({
234
269
  queryKey: ["ecency-wallets", "wallets", e]
235
- }), { data: n } = q(e);
270
+ }), { data: n } = Q(e);
236
271
  return m({
237
272
  mutationKey: ["ecency-wallets", "create-account-with-wallets", e],
238
- mutationFn: ({ currency: r, address: s }) => fetch(g.privateApiHost + "/private-api/wallets-add", {
273
+ mutationFn: ({ currency: a, address: s }) => fetch(d.privateApiHost + "/private-api/wallets-add", {
239
274
  method: "POST",
240
275
  headers: {
241
276
  "Content-Type": "application/json"
242
277
  },
243
278
  body: JSON.stringify({
244
279
  username: e,
245
- token: r,
280
+ token: a,
246
281
  address: s,
247
282
  meta: {
248
283
  ownerPublicKey: n == null ? void 0 : n.ownerPubkey,
@@ -250,9 +285,9 @@ function L(e) {
250
285
  postingPublicKey: n == null ? void 0 : n.postingPubkey,
251
286
  memoPublicKey: n == null ? void 0 : n.memoPubkey,
252
287
  ...Array.from((t == null ? void 0 : t.entries()) ?? []).reduce(
253
- (i, [a, c]) => ({
254
- ...i,
255
- [a]: c.address
288
+ (c, [r, i]) => ({
289
+ ...c,
290
+ [r]: i.address
256
291
  }),
257
292
  {}
258
293
  )
@@ -261,11 +296,11 @@ function L(e) {
261
296
  })
262
297
  });
263
298
  }
264
- function T() {
299
+ function P() {
265
300
  return m({
266
301
  mutationKey: ["ecency-wallets", "check-wallet-existence"],
267
302
  mutationFn: async ({ address: e, currency: t }) => (await (await fetch(
268
- g.privateApiHost + "/private-api/wallets-exist",
303
+ d.privateApiHost + "/private-api/wallets-exist",
269
304
  {
270
305
  method: "POST",
271
306
  headers: {
@@ -279,59 +314,59 @@ function T() {
279
314
  )).json()).length === 0
280
315
  });
281
316
  }
282
- const ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
317
+ const he = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
283
318
  __proto__: null,
284
- useCheckWalletExistence: T,
285
- useCreateAccountWithWallets: L
286
- }, Symbol.toStringTag, { value: "Module" })), F = {
319
+ useCheckWalletExistence: P,
320
+ useCreateAccountWithWallets: I
321
+ }, Symbol.toStringTag, { value: "Module" })), $ = {
287
322
  [o.BTC]: ["m/84'/0'/0'/0/0"],
288
323
  [o.ETH]: ["m/84'/60'/0'/0/0"],
289
324
  // its not working for Trust, Exodus, todo: check others below
290
325
  [o.SOL]: ["m/84'/501'/0'/0/0"],
291
- [o.TRON]: ["m/84'/195'/0'/0/0"],
326
+ [o.TRON]: ["m/44'/195'/0'/0'/0'"],
292
327
  [o.APT]: ["m/84'/637'/0'/0/0"],
293
328
  [o.TON]: [],
294
329
  // Disabled
295
330
  [o.ATOM]: ["m/84'/118'/0'/0'/0"]
296
331
  };
297
- async function M(e, t, n) {
298
- for (const r of F[n] || [])
332
+ async function G(e, t, n) {
333
+ for (const a of $[n] || [])
299
334
  try {
300
335
  const s = await t.getDerivedPrivateKey({
301
336
  mnemonic: e,
302
- hdPath: r
303
- }), i = await t.getNewAddress({
337
+ hdPath: a
338
+ }), c = await t.getNewAddress({
304
339
  privateKey: s,
305
- addressType: "segwit_native"
340
+ addressType: n === o.BTC ? "segwit_native" : void 0
306
341
  });
307
- return [s.toString(), i.address];
342
+ return [s.toString(), c.address];
308
343
  } catch {
309
344
  return [];
310
345
  }
311
346
  return [];
312
347
  }
313
- function me(e, t) {
314
- const n = y(), { mutateAsync: r } = T();
348
+ function Te(e, t) {
349
+ const n = h(), { mutateAsync: a } = P();
315
350
  return m({
316
351
  mutationKey: ["ecency-wallets", "import-wallet", e, t],
317
352
  mutationFn: async ({ privateKeyOrSeed: s }) => {
318
- const i = h(t);
319
- if (!i)
353
+ const c = T(t);
354
+ if (!c)
320
355
  throw new Error("Cannot find token for this currency");
321
- const a = s.split(" ").length === 12;
322
- let c, l = s;
323
- if (a ? [l, c] = await M(
356
+ const r = s.split(" ").length === 12;
357
+ let i, l = s;
358
+ if (r ? [l, i] = await G(
324
359
  s,
325
- i,
360
+ c,
326
361
  t
327
- ) : c = (await i.getNewAddress({
362
+ ) : i = (await c.getNewAddress({
328
363
  privateKey: s
329
- })).address, !c || !s)
364
+ })).address, !i || !s)
330
365
  throw new Error(
331
366
  "Private key/seed phrase isn't matching with public key or token"
332
367
  );
333
- if (!await r({
334
- address: c,
368
+ if (!await a({
369
+ address: i,
335
370
  currency: t
336
371
  }))
337
372
  throw new Error(
@@ -339,17 +374,17 @@ function me(e, t) {
339
374
  );
340
375
  return {
341
376
  privateKey: l,
342
- address: c,
377
+ address: i,
343
378
  publicKey: ""
344
379
  };
345
380
  },
346
- onSuccess: ({ privateKey: s, publicKey: i, address: a }) => {
381
+ onSuccess: ({ privateKey: s, publicKey: c, address: r }) => {
347
382
  n.setQueryData(
348
383
  ["ecency-wallets", "wallets", e],
349
- (c) => new Map(c ? Array.from(c.entries()) : []).set(t, {
384
+ (i) => new Map(i ? Array.from(i.entries()) : []).set(t, {
350
385
  privateKey: s,
351
- publicKey: i,
352
- address: a,
386
+ publicKey: c,
387
+ address: r,
353
388
  username: e,
354
389
  currency: t,
355
390
  custom: !0
@@ -358,16 +393,35 @@ function me(e, t) {
358
393
  }
359
394
  });
360
395
  }
396
+ function be(e) {
397
+ const { mutateAsync: t } = M(e);
398
+ return m({
399
+ mutationKey: ["ecency-wallets", "save-wallet-to-metadata", e],
400
+ mutationFn: ({
401
+ wallets: n
402
+ }) => t({
403
+ profile: {},
404
+ tokens: Array.from(n.entries() ?? []).map(([a, s]) => ({
405
+ symbol: a,
406
+ type: "CHAIN",
407
+ meta: {
408
+ address: s.address
409
+ }
410
+ }))
411
+ })
412
+ });
413
+ }
361
414
  export {
415
+ u as EcencyWalletBasicTokens,
362
416
  o as EcencyWalletCurrency,
363
- ue as EcencyWalletsPrivateApi,
364
- x as delay,
365
- h as getWallet,
366
- ce as mnemonicToSeedBip39,
367
- le as useCoinGeckoPriceQuery,
368
- ie as useGetExternalWalletBalanceQuery,
369
- q as useHiveKeysQuery,
370
- me as useImportWallet,
371
- f as useSeedPhrase,
372
- pe as useWalletCreate
417
+ he as EcencyWalletsPrivateApi,
418
+ de as getAccountPointsQueryOptions,
419
+ we as useCoinGeckoPriceQuery,
420
+ ye as useGetAllTokensListQuery,
421
+ me as useGetExternalWalletBalanceQuery,
422
+ Q as useHiveKeysQuery,
423
+ Te as useImportWallet,
424
+ be as useSaveWalletInformationToMetadata,
425
+ b as useSeedPhrase,
426
+ fe as useWalletCreate
373
427
  };
@@ -0,0 +1 @@
1
+ export * from './modules/wallets';
@@ -0,0 +1,7 @@
1
+ export declare enum EcencyWalletBasicTokens {
2
+ Points = "POINTS",
3
+ HivePower = "HP",
4
+ Hive = "HIVE",
5
+ HiveDollar = "HBD",
6
+ Spk = "SPK"
7
+ }
@@ -0,0 +1,9 @@
1
+ export declare enum EcencyWalletCurrency {
2
+ BTC = "BTC",
3
+ ETH = "ETH",
4
+ APT = "APT",
5
+ ATOM = "ATOM",
6
+ TON = "TON",
7
+ TRON = "TRX",
8
+ SOL = "SOL"
9
+ }
@@ -0,0 +1,2 @@
1
+ export * from './ecency-wallet-currency';
2
+ export * from './ecency-wallet-basic-tokens';
@@ -0,0 +1,3 @@
1
+ import { EcencyWalletCurrency } from '../enums';
2
+ import { BaseWallet } from '@okxweb3/coin-base';
3
+ export declare function getKeysFromSeed(mnemonic: string, wallet: BaseWallet, currency: EcencyWalletCurrency): Promise<never[] | readonly [any, any]>;
@@ -0,0 +1 @@
1
+ export * from './get-keys-from-seed';
@@ -0,0 +1,4 @@
1
+ export * from './enums';
2
+ export * from './mutations';
3
+ export * from './queries';
4
+ export * from './types';
@@ -0,0 +1,4 @@
1
+ export * from './use-wallet-create';
2
+ export * from './private-api-namespace';
3
+ export * from './use-import-wallet';
4
+ export * from './save-wallet-information-to-metadata';
@@ -0,0 +1,7 @@
1
+ import { EcencyWalletCurrency } from '../../enums';
2
+ interface Payload {
3
+ address: string;
4
+ currency: EcencyWalletCurrency;
5
+ }
6
+ export declare function useCheckWalletExistence(): import('@tanstack/react-query').UseMutationResult<boolean, Error, Payload, unknown>;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import { EcencyWalletCurrency } from '../../enums';
2
+ interface Payload {
3
+ currency: EcencyWalletCurrency;
4
+ address: string;
5
+ }
6
+ export declare function useCreateAccountWithWallets(username: string): import('@tanstack/react-query').UseMutationResult<Response, Error, Payload, unknown>;
7
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './create-account-with-wallets';
2
+ export * from './check-wallet-existence';
@@ -0,0 +1,2 @@
1
+ import * as EcencyWalletsPrivateApi from "./private-api";
2
+ export { EcencyWalletsPrivateApi };
@@ -0,0 +1,5 @@
1
+ import { EcencyWalletCurrency } from '../enums';
2
+ import { EcencyCreateWalletInformation } from '../types';
3
+ export declare function useSaveWalletInformationToMetadata(username: string): import('@tanstack/react-query').UseMutationResult<any, Error, {
4
+ wallets: Map<EcencyWalletCurrency, EcencyCreateWalletInformation>;
5
+ }, unknown>;
@@ -0,0 +1,10 @@
1
+ import { EcencyWalletCurrency } from '../enums';
2
+ interface Payload {
3
+ privateKeyOrSeed: string;
4
+ }
5
+ export declare function useImportWallet(username: string, currency: EcencyWalletCurrency): import('@tanstack/react-query').UseMutationResult<{
6
+ privateKey: string;
7
+ address: any;
8
+ publicKey: string;
9
+ }, Error, Payload, unknown>;
10
+ export {};
@@ -0,0 +1,6 @@
1
+ import { EcencyCreateWalletInformation } from '../types';
2
+ import { EcencyWalletCurrency } from '../enums';
3
+ export declare function useWalletCreate(username: string, currency: EcencyWalletCurrency): {
4
+ createWallet: import('@tanstack/react-query').UseMutationResult<EcencyCreateWalletInformation, Error, void, unknown>;
5
+ importWallet: () => void;
6
+ };
@@ -0,0 +1,9 @@
1
+ import { AccountPointsResponse } from '../types';
2
+ export declare function getAccountPointsQueryOptions(username?: string, filter?: string): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<AccountPointsResponse, Error, AccountPointsResponse, (string | undefined)[]>, "queryFn"> & {
3
+ queryFn?: import('@tanstack/query-core').QueryFunction<AccountPointsResponse, (string | undefined)[], never> | undefined;
4
+ } & {
5
+ queryKey: (string | undefined)[] & {
6
+ [dataTagSymbol]: AccountPointsResponse;
7
+ [dataTagErrorSymbol]: Error;
8
+ };
9
+ };
@@ -0,0 +1,6 @@
1
+ export * from './use-get-external-wallet-query';
2
+ export * from './use-seed-phrase';
3
+ export * from './use-coingecko-price-query';
4
+ export * from './use-hive-keys-query';
5
+ export * from './get-account-points-query-options';
6
+ export * from './use-get-all-tokens-list-query';
@@ -0,0 +1,2 @@
1
+ import { EcencyWalletCurrency } from '../enums';
2
+ export declare function useCoinGeckoPriceQuery(currency?: EcencyWalletCurrency): import('@tanstack/react-query').UseQueryResult<number, Error>;
@@ -0,0 +1,9 @@
1
+ import { EcencyWalletBasicTokens } from '../enums';
2
+ export declare function getAccountWalletListQueryOptions(username: string): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<EcencyWalletBasicTokens[], Error, EcencyWalletBasicTokens[], string[]>, "queryFn"> & {
3
+ queryFn?: import('@tanstack/query-core').QueryFunction<EcencyWalletBasicTokens[], string[], never> | undefined;
4
+ } & {
5
+ queryKey: string[] & {
6
+ [dataTagSymbol]: EcencyWalletBasicTokens[];
7
+ [dataTagErrorSymbol]: Error;
8
+ };
9
+ };
@@ -0,0 +1,6 @@
1
+ import { EcencyWalletBasicTokens, EcencyWalletCurrency } from '../enums';
2
+ export declare function useGetAllTokensListQuery(query: string): {
3
+ basic: EcencyWalletBasicTokens[];
4
+ external: EcencyWalletCurrency[];
5
+ layer2: string[];
6
+ };
@@ -0,0 +1,10 @@
1
+ import { EcencyWalletCurrency } from '../enums';
2
+ /**
3
+ * Returns information about the actual balance of the given currency address
4
+ * using various of public APIs
5
+ * todo extract URLs to configs
6
+ * @param currency
7
+ * @param address
8
+ * @returns
9
+ */
10
+ export declare function useGetExternalWalletBalanceQuery(currency: EcencyWalletCurrency, address: string): import('@tanstack/react-query').UseQueryResult<number, Error>;
@@ -0,0 +1,2 @@
1
+ import { EcencyHiveKeys } from '../types';
2
+ export declare function useHiveKeysQuery(username: string): import('@tanstack/react-query').UseQueryResult<EcencyHiveKeys, Error>;
@@ -0,0 +1 @@
1
+ export declare function useSeedPhrase(username: string): import('@tanstack/react-query').UseQueryResult<string, Error>;
@@ -0,0 +1,4 @@
1
+ export interface AccountPointsResponse {
2
+ points: string;
3
+ unclaimed_points: string;
4
+ }
@@ -0,0 +1,9 @@
1
+ import { EcencyWalletCurrency } from '../enums';
2
+ export interface EcencyCreateWalletInformation {
3
+ address: string;
4
+ privateKey: string;
5
+ publicKey: string;
6
+ username: string;
7
+ currency: EcencyWalletCurrency;
8
+ custom?: boolean;
9
+ }
@@ -0,0 +1,12 @@
1
+ export interface EcencyHiveKeys {
2
+ username: string;
3
+ owner: string;
4
+ active: string;
5
+ posting: string;
6
+ memo: string;
7
+ masterPassword: string;
8
+ ownerPubkey: string;
9
+ activePubkey: string;
10
+ postingPubkey: string;
11
+ memoPubkey: string;
12
+ }
@@ -0,0 +1,3 @@
1
+ export * from './ecency-create-wallet-information';
2
+ export * from './ecency-hive-keys';
3
+ export * from './account-points-response';
@@ -0,0 +1 @@
1
+ export declare function delay(ms: number): Promise<unknown>;
@@ -0,0 +1,3 @@
1
+ import { BaseWallet } from '@okxweb3/coin-base';
2
+ import { EcencyWalletCurrency } from '../enums';
3
+ export declare function getWallet(currency: EcencyWalletCurrency): BaseWallet | undefined;
@@ -0,0 +1,3 @@
1
+ export * from './delay';
2
+ export * from './get-wallet';
3
+ export * from './mnemonic-to-seed-bip-39';
@@ -0,0 +1 @@
1
+ export declare function mnemonicToSeedBip39(value: string): string;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vite').UserConfig;
2
+ export default _default;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@ecency/wallets",
3
3
  "private": false,
4
- "version": "1.1.1",
4
+ "version": "1.2.0",
5
5
  "type": "module",
6
- "main": "./dist/ecency-wallets.umd.js",
7
- "module": "./dist/ecency-wallets.es.js",
8
- "typings": "./dist/ecency-wallets.es.d.ts",
6
+ "license": "MIT",
7
+ "main": "./dist/ecency-sdk.umd.js",
8
+ "module": "./dist/ecency-sdk.es.js",
9
+ "typings": "./dist/index.d.ts",
9
10
  "files": [
10
11
  "dist",
11
12
  "README.md"
@@ -17,7 +18,7 @@
17
18
  },
18
19
  "devDependencies": {
19
20
  "@hiveio/dhive": "^1.3.2",
20
- "@tanstack/react-query": "^5.66.11",
21
+ "@tanstack/react-query": "^5.74.4",
21
22
  "@types/node": "^22.13.8",
22
23
  "@types/react": "^19.0.10",
23
24
  "@vitejs/plugin-react": "^4.3.4",
@@ -25,12 +26,12 @@
25
26
  "lru-cache": "^11.0.2",
26
27
  "prettier": "^3.5.2",
27
28
  "react": "^19.0.0",
28
- "typescript": "~5.7.2",
29
29
  "vite": "^6.2.0",
30
- "vite-plugin-dts": "^4.5.1",
30
+ "vite-plugin-dts": "4.5.3",
31
31
  "vite-plugin-node-polyfills": "^0.23.0"
32
32
  },
33
33
  "dependencies": {
34
+ "@ecency/sdk": "./packages/core",
34
35
  "@okxweb3/coin-aptos": "^1.2.0",
35
36
  "@okxweb3/coin-base": "^1.1.2",
36
37
  "@okxweb3/coin-bitcoin": "^1.2.0",
@@ -40,6 +41,7 @@
40
41
  "@okxweb3/coin-ton": "^1.1.1-beta.1",
41
42
  "@okxweb3/coin-tron": "^1.1.0",
42
43
  "@okxweb3/crypto-lib": "^1.0.10",
43
- "bip39": "^3.1.0"
44
+ "bip39": "^3.1.0",
45
+ "hivesigner": "3.3.4"
44
46
  }
45
47
  }
package/Readme.md DELETED
@@ -1,36 +0,0 @@
1
- # Ecency wallets – manage Hive account and attach external wallets to it in Ecency system
2
-
3
- [![NPM](https://img.shields.io/npm/v/@ecency/wallets.svg)](https://www.npmjs.com/package/@ecency/wallets) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
4
-
5
- ## Overview
6
-
7
- `@ecency/wallets` provides an API for managing Hive blockchain wallets and external cryptocurrency wallets within the Ecency ecosystem.
8
-
9
- ## Installation
10
-
11
- ```sh
12
- yarn add @ecency/wallets
13
- # or
14
- npm install @ecency/wallets
15
- ```
16
-
17
- ## Setup
18
-
19
- 1. Install `react @tanstack/react-query @hiveio/dhive`
20
- 2. Use!
21
-
22
- ## Features
23
-
24
- This package built on top of [@hiveio/dhive](https://www.npmjs.com/package/@hiveio/dhive) and [okweb3](http://okx.github.io/) packages.
25
-
26
- Main functionality is creating wallets based on seed phrase([BIP39](https://www.npmjs.com/package/bip39)) and generating addresses with keys on device. Seed phrases and private keys are never sent to any API, all operations happen locally.
27
-
28
- Supportings tokens: BTC, ETH, SOL, TRX, TON, ATOM, APT – theoretically all child tokens of these systems. Make forks for it.
29
-
30
- ## Roadmap
31
-
32
- - Add more Hive wallets operations
33
- - Allow to sign transactions with external wallets
34
- - Allow to import existing wallets by phrase or private keys
35
- - Support of DASH
36
- - Support of DOGE
@@ -1,97 +0,0 @@
1
- import { BaseWallet } from '@okxweb3/coin-base';
2
- import { UseMutationResult } from '@tanstack/react-query';
3
- import { UseQueryResult } from '@tanstack/react-query';
4
-
5
- export declare function delay(ms: number): Promise<unknown>;
6
-
7
- export declare interface EcencyCreateWalletInformation {
8
- address: string;
9
- privateKey: string;
10
- publicKey: string;
11
- username: string;
12
- currency: EcencyWalletCurrency;
13
- custom?: boolean;
14
- }
15
-
16
- export declare interface EcencyHiveKeys {
17
- username: string;
18
- owner: string;
19
- active: string;
20
- posting: string;
21
- memo: string;
22
- masterPassword: string;
23
- ownerPubkey: string;
24
- activePubkey: string;
25
- postingPubkey: string;
26
- memoPubkey: string;
27
- }
28
-
29
- export declare enum EcencyWalletCurrency {
30
- BTC = "btc",
31
- ETH = "eth",
32
- APT = "aptos",
33
- ATOM = "cosmos",
34
- TON = "ton",
35
- TRON = "tron",
36
- SOL = "solana"
37
- }
38
-
39
- declare namespace EcencyWalletsPrivateApi {
40
- export {
41
- useCreateAccountWithWallets,
42
- useCheckWalletExistence
43
- }
44
- }
45
- export { EcencyWalletsPrivateApi }
46
-
47
- export declare function getWallet(currency: EcencyWalletCurrency): BaseWallet | undefined;
48
-
49
- export declare function mnemonicToSeedBip39(value: string): string;
50
-
51
- declare interface Payload {
52
- currency: EcencyWalletCurrency;
53
- address: string;
54
- }
55
-
56
- declare interface Payload_2 {
57
- address: string;
58
- currency: EcencyWalletCurrency;
59
- }
60
-
61
- declare interface Payload_3 {
62
- address: string;
63
- privateKeyOrSeed: string;
64
- }
65
-
66
- declare function useCheckWalletExistence(): UseMutationResult<boolean, Error, Payload_2, unknown>;
67
-
68
- export declare function useCoinGeckoPriceQuery(currency?: EcencyWalletCurrency): UseQueryResult<number, Error>;
69
-
70
- declare function useCreateAccountWithWallets(username: string): UseMutationResult<Response, Error, Payload, unknown>;
71
-
72
- /**
73
- * Returns information about the actual balance of the given currency address
74
- * using various of public APIs
75
- * todo extract URLs to configs
76
- * @param currency
77
- * @param address
78
- * @returns
79
- */
80
- export declare function useGetExternalWalletBalanceQuery(currency: EcencyWalletCurrency, address: string): UseQueryResult<number, Error>;
81
-
82
- export declare function useHiveKeysQuery(username: string): UseQueryResult<EcencyHiveKeys, Error>;
83
-
84
- export declare function useImportWallet(username: string, currency: EcencyWalletCurrency): UseMutationResult< {
85
- privateKey: string;
86
- address: any;
87
- publicKey: string;
88
- }, Error, Payload_3, unknown>;
89
-
90
- export declare function useSeedPhrase(username: string): UseQueryResult<string, Error>;
91
-
92
- export declare function useWalletCreate(username: string, currency: EcencyWalletCurrency): {
93
- createWallet: UseMutationResult<EcencyCreateWalletInformation, Error, void, unknown>;
94
- importWallet: () => void;
95
- };
96
-
97
- export { }