@ecency/wallets 1.0.14 → 1.0.16

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.
@@ -79,7 +79,7 @@ address: string;
79
79
  publicKey: string;
80
80
  }, Error, Payload_2, unknown>;
81
81
 
82
- export declare function useSeedPhrase(): UseQueryResult<string, Error>;
82
+ export declare function useSeedPhrase(username: string): UseQueryResult<string, Error>;
83
83
 
84
84
  export declare function useWalletCreate(username: string, currency: EcencyWalletCurrency): {
85
85
  createWallet: UseMutationResult<EcencyCreateWalletInformation, Error, void, unknown>;
@@ -34,7 +34,7 @@ function T(e) {
34
34
  return;
35
35
  }
36
36
  }
37
- function ie(e) {
37
+ function re(e) {
38
38
  return _(e).toString("hex");
39
39
  }
40
40
  function ce(e, t) {
@@ -93,9 +93,9 @@ function ce(e, t) {
93
93
  }
94
94
  });
95
95
  }
96
- function b() {
96
+ function b(e) {
97
97
  return p({
98
- queryKey: ["ecency-wallets", "seed"],
98
+ queryKey: ["ecency-wallets", "seed", e],
99
99
  queryFn: async () => K.generateMnemonic(128)
100
100
  });
101
101
  }
@@ -156,23 +156,23 @@ function le(e) {
156
156
  });
157
157
  }
158
158
  function L(e) {
159
- const { data: t } = b();
159
+ const { data: t } = b(e);
160
160
  return p({
161
161
  queryKey: ["ecencу-wallets", "hive-keys", e, t],
162
162
  queryFn: async () => {
163
163
  if (!t)
164
164
  throw new Error("[Ecency][Wallets] - no seed to create Hive account");
165
- const n = u.fromLogin(e, t, "owner"), a = u.fromLogin(e, t, "active"), i = u.fromLogin(e, t, "posting"), r = u.fromLogin(e, t, "memo");
165
+ const n = u.fromLogin(e, t, "owner"), a = u.fromLogin(e, t, "active"), r = u.fromLogin(e, t, "posting"), i = u.fromLogin(e, t, "memo");
166
166
  return {
167
167
  username: e,
168
168
  owner: n.toString(),
169
169
  active: a.toString(),
170
- posting: i.toString(),
171
- memo: r.toString(),
170
+ posting: r.toString(),
171
+ memo: i.toString(),
172
172
  ownerPubkey: n.createPublic().toString(),
173
173
  activePubkey: a.createPublic().toString(),
174
- postingPubkey: i.createPublic().toString(),
175
- memoPubkey: r.createPublic().toString()
174
+ postingPubkey: r.createPublic().toString(),
175
+ memoPubkey: i.createPublic().toString()
176
176
  };
177
177
  }
178
178
  });
@@ -194,7 +194,7 @@ const W = {
194
194
  // Cosmos (BIP44)
195
195
  };
196
196
  function pe(e, t) {
197
- const { data: n } = b(), a = h(), i = m({
197
+ const { data: n } = b(e), a = h(), r = m({
198
198
  mutationKey: ["ecency-wallets", "create-wallet", e, t],
199
199
  mutationFn: async () => {
200
200
  if (!n)
@@ -221,11 +221,11 @@ function pe(e, t) {
221
221
  (c) => new Map(c ? Array.from(c.entries()) : []).set(s.currency, s)
222
222
  );
223
223
  }
224
- }), r = P(() => {
224
+ }), i = P(() => {
225
225
  }, []);
226
226
  return {
227
- createWallet: i,
228
- importWallet: r
227
+ createWallet: r,
228
+ importWallet: i
229
229
  };
230
230
  }
231
231
  const q = { privateApiHost: "https://ecency.com" };
@@ -235,7 +235,7 @@ function M(e) {
235
235
  }), { data: n } = L(e);
236
236
  return m({
237
237
  mutationKey: ["ecency-wallets", "create-account-with-wallets", e],
238
- mutationFn: ({ currency: a, address: i }) => fetch(q.privateApiHost + "/private-api/wallets-add", {
238
+ mutationFn: ({ currency: a, address: r }) => fetch(q.privateApiHost + "/private-api/wallets-add", {
239
239
  method: "POST",
240
240
  headers: {
241
241
  "Content-Type": "application/json"
@@ -243,15 +243,15 @@ function M(e) {
243
243
  body: JSON.stringify({
244
244
  username: e,
245
245
  token: a,
246
- address: i,
246
+ address: r,
247
247
  meta: {
248
248
  ownerPublicKey: n == null ? void 0 : n.ownerPubkey,
249
249
  activePublicKey: n == null ? void 0 : n.activePubkey,
250
250
  postingPublicKey: n == null ? void 0 : n.postingPubkey,
251
251
  memoPublicKey: n == null ? void 0 : n.memoPubkey,
252
252
  ...Array.from((t == null ? void 0 : t.entries()) ?? []).reduce(
253
- (r, [s, c]) => ({
254
- ...r,
253
+ (i, [s, c]) => ({
254
+ ...i,
255
255
  [s]: c.address
256
256
  }),
257
257
  {}
@@ -292,18 +292,18 @@ const ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
292
292
  [o.ATOM]: [void 0]
293
293
  };
294
294
  async function Q(e, t, n, a) {
295
- for (const i of x[a] || [])
295
+ for (const r of x[a] || [])
296
296
  try {
297
- const r = await n.getDerivedPrivateKey({
297
+ const i = await n.getDerivedPrivateKey({
298
298
  mnemonic: e,
299
- hdPath: i
299
+ hdPath: r
300
300
  });
301
301
  for (const s of F[a])
302
302
  if ((await n.getNewAddress({
303
- privateKey: r,
303
+ privateKey: i,
304
304
  addressType: s
305
305
  })).address === t)
306
- return r;
306
+ return i;
307
307
  } catch {
308
308
  return;
309
309
  }
@@ -312,26 +312,26 @@ function me(e, t) {
312
312
  const n = h();
313
313
  return m({
314
314
  mutationKey: ["ecency-wallets", "import-wallet", e, t],
315
- mutationFn: async ({ privateKeyOrSeed: a, address: i }) => {
316
- const r = T(t);
317
- if (!r)
315
+ mutationFn: async ({ privateKeyOrSeed: a, address: r }) => {
316
+ const i = T(t);
317
+ if (!i)
318
318
  throw new Error("Cannot find token for this currency");
319
319
  const s = a.split(" ").length === 12;
320
320
  let c = !1, l = a;
321
321
  if (s)
322
322
  l = await Q(
323
323
  a,
324
- i,
325
324
  r,
325
+ i,
326
326
  t
327
327
  ), c = !!l;
328
328
  else {
329
- const w = await r.getNewAddress({
329
+ const w = await i.getNewAddress({
330
330
  privateKey: a
331
- }), f = await r.validPrivateKey({
331
+ }), f = await i.validPrivateKey({
332
332
  privateKey: a
333
333
  });
334
- c = w.address === i && f.isValid;
334
+ c = w.address === r && f.isValid;
335
335
  }
336
336
  if (!c)
337
337
  throw new Error(
@@ -339,17 +339,17 @@ function me(e, t) {
339
339
  );
340
340
  return {
341
341
  privateKey: l,
342
- address: i,
342
+ address: r,
343
343
  publicKey: ""
344
344
  };
345
345
  },
346
- onSuccess: ({ privateKey: a, publicKey: i, address: r }) => {
346
+ onSuccess: ({ privateKey: a, publicKey: r, address: i }) => {
347
347
  n.setQueryData(
348
348
  ["ecency-wallets", "wallets", e],
349
349
  (s) => new Map(s ? Array.from(s.entries()) : []).set(t, {
350
350
  privateKey: a,
351
- publicKey: i,
352
- address: r,
351
+ publicKey: r,
352
+ address: i,
353
353
  username: e,
354
354
  currency: t,
355
355
  custom: !0
@@ -363,7 +363,7 @@ export {
363
363
  ue as EcencyWalletsPrivateApi,
364
364
  j as delay,
365
365
  T as getWallet,
366
- ie as mnemonicToSeedBip39,
366
+ re as mnemonicToSeedBip39,
367
367
  le as useCoinGeckoPriceQuery,
368
368
  ce as useGetExternalWalletBalanceQuery,
369
369
  L as useHiveKeysQuery,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ecency/wallets",
3
3
  "private": false,
4
- "version": "1.0.14",
4
+ "version": "1.0.16",
5
5
  "type": "module",
6
6
  "main": "./dist/ecency-wallets.umd.js",
7
7
  "module": "./dist/ecency-wallets.es.js",