@ecency/wallets 1.0.2 → 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,6 +1,6 @@
1
1
  import { useMemo as b, useCallback as S } from "react";
2
- import { useQuery as l, useQueryClient as g, useMutation as d } from "@tanstack/react-query";
3
- import { BtcWallet as T } from "@okxweb3/coin-bitcoin";
2
+ import { useQuery as l, useQueryClient as T, useMutation as w } from "@tanstack/react-query";
3
+ import { BtcWallet as g } from "@okxweb3/coin-bitcoin";
4
4
  import { EthWallet as R } from "@okxweb3/coin-ethereum";
5
5
  import { TrxWallet as P } from "@okxweb3/coin-tron";
6
6
  import { TonWallet as O } from "@okxweb3/coin-ton";
@@ -8,16 +8,16 @@ import { SolWallet as v } from "@okxweb3/coin-solana";
8
8
  import { AtomWallet as k } from "@okxweb3/coin-cosmos";
9
9
  import { AptosWallet as A } from "@okxweb3/coin-aptos";
10
10
  import D, { mnemonicToSeedSync as N } from "bip39";
11
- import { LRUCache as K } from "lru-cache";
11
+ import { LRUCache as j } from "lru-cache";
12
12
  import { PrivateKey as u } from "@hiveio/dhive";
13
13
  var n = /* @__PURE__ */ ((e) => (e.BTC = "btc", e.ETH = "eth", e.APT = "atpos", e.ATOM = "cosmos", e.TON = "ton", e.TRON = "tron", e.SOL = "Solana", e))(n || {});
14
- function j(e) {
14
+ function K(e) {
15
15
  return new Promise((t) => setTimeout(t, e));
16
16
  }
17
17
  function _(e) {
18
18
  switch (e) {
19
19
  case n.BTC:
20
- return new T();
20
+ return new g();
21
21
  case n.ETH:
22
22
  return new R();
23
23
  case n.TRON:
@@ -76,12 +76,12 @@ function se(e, t) {
76
76
  `https://tonapi.io/v1/blockchain/getAccount?account=${t}`
77
77
  )).json()).balance / 1e9;
78
78
  case n.APT:
79
- const w = (await (await fetch(
79
+ const d = (await (await fetch(
80
80
  `https://fullnode.mainnet.aptoslabs.com/v1/accounts/${t}/resources`
81
81
  )).json()).find(
82
82
  (h) => h.type.includes("coin::CoinStore")
83
83
  );
84
- return w ? parseInt(w.data.coin.value) / 1e8 : 0;
84
+ return d ? parseInt(d.data.coin.value) / 1e8 : 0;
85
85
  case n.ATOM:
86
86
  return +(await (await fetch(
87
87
  `https://rest.cosmos.directory/cosmoshub/auth/accounts/${t}`
@@ -90,13 +90,13 @@ function se(e, t) {
90
90
  }
91
91
  });
92
92
  }
93
- function f() {
93
+ function y() {
94
94
  return l({
95
95
  queryKey: ["ecency-wallets", "seed"],
96
96
  queryFn: async () => D.generateMnemonic(128)
97
97
  });
98
98
  }
99
- const W = {
99
+ const H = {
100
100
  max: 500,
101
101
  // how long to live in ms
102
102
  ttl: 1e3 * 60 * 5,
@@ -104,8 +104,8 @@ const W = {
104
104
  allowStale: !1,
105
105
  updateAgeOnGet: !1,
106
106
  updateAgeOnHas: !1
107
- }, y = new K(W), m = Symbol("undefined"), q = (e, t) => y.set(e, t === void 0 ? m : t), x = (e) => {
108
- const t = y.get(e);
107
+ }, f = new j(H), m = Symbol("undefined"), W = (e, t) => f.set(e, t === void 0 ? m : t), q = (e) => {
108
+ const t = f.get(e);
109
109
  return t === m ? void 0 : t;
110
110
  };
111
111
  function ce(e) {
@@ -126,7 +126,7 @@ function ce(e) {
126
126
  default:
127
127
  t = e;
128
128
  }
129
- let o = x("gecko"), s;
129
+ let o = q("gecko"), s;
130
130
  if (o)
131
131
  s = o;
132
132
  else {
@@ -142,15 +142,15 @@ function ce(e) {
142
142
  })
143
143
  }
144
144
  )).json();
145
- q("gecko", a === void 0 ? m : a), s = a;
145
+ W("gecko", a === void 0 ? m : a), s = a;
146
146
  }
147
147
  return 1 / +s[Object.keys(s)[0]].usd;
148
148
  },
149
149
  enabled: !!e
150
150
  });
151
151
  }
152
- function B(e) {
153
- const { data: t } = f(), o = b(
152
+ function x(e) {
153
+ const { data: t } = y(), o = b(
154
154
  () => N(t ?? "").toString("hex"),
155
155
  [t]
156
156
  );
@@ -174,7 +174,7 @@ function B(e) {
174
174
  }
175
175
  });
176
176
  }
177
- const H = {
177
+ const B = {
178
178
  [n.BTC]: "m/44'/0'/0'/0/0",
179
179
  // Bitcoin (BIP44)
180
180
  [n.ETH]: "m/44'/60'/0'/0/0",
@@ -191,16 +191,16 @@ const H = {
191
191
  // Cosmos (BIP44)
192
192
  };
193
193
  function re(e, t) {
194
- const { data: o } = f(), s = g(), c = d({
194
+ const { data: o } = y(), s = T(), c = w({
195
195
  mutationKey: ["ecency-wallets", "create-wallet", e, t],
196
196
  mutationFn: async () => {
197
197
  if (!o)
198
198
  throw new Error("[Ecency][Wallets] - No seed to create a wallet");
199
199
  const a = _(t), i = await (a == null ? void 0 : a.getDerivedPrivateKey({
200
200
  mnemonic: o,
201
- hdPath: H[t]
201
+ hdPath: B[t]
202
202
  }));
203
- await j(1e3);
203
+ await K(1e3);
204
204
  const p = await (a == null ? void 0 : a.getNewAddress({
205
205
  privateKey: i
206
206
  }));
@@ -225,15 +225,18 @@ function re(e, t) {
225
225
  importWallet: r
226
226
  };
227
227
  }
228
- const M = {};
229
- function C(e) {
228
+ const C = { privateApiHost: "https://ecency.com" };
229
+ function M(e) {
230
230
  const { data: t } = l({
231
231
  queryKey: ["ecency-wallets", "wallets", e]
232
- }), { data: o } = B(e);
233
- return d({
232
+ }), { data: o } = x(e);
233
+ return w({
234
234
  mutationKey: ["ecency-wallets", "create-account-with-wallets", e],
235
- mutationFn: ({ currency: s, address: c }) => fetch(M + "/private-api/wallets-add", {
235
+ mutationFn: ({ currency: s, address: c }) => fetch(C.privateApiHost + "/private-api/wallets-add", {
236
236
  method: "POST",
237
+ headers: {
238
+ "Content-Type": "application/json"
239
+ },
237
240
  body: JSON.stringify({
238
241
  username: e,
239
242
  token: s,
@@ -257,16 +260,16 @@ function C(e) {
257
260
  }
258
261
  const ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
259
262
  __proto__: null,
260
- useCreateAccountWithWallets: C
263
+ useCreateAccountWithWallets: M
261
264
  }, Symbol.toStringTag, { value: "Module" }));
262
265
  export {
263
266
  n as EcencyWalletCurrency,
264
267
  ie as EcencyWalletsPrivateApi,
265
- j as delay,
268
+ K as delay,
266
269
  _ as getWallet,
267
270
  ce as useCoinGeckoPriceQuery,
268
271
  se as useGetExternalWalletBalanceQuery,
269
- B as useHiveKeysQuery,
270
- f as useSeedPhrase,
272
+ x as useHiveKeysQuery,
273
+ y as useSeedPhrase,
271
274
  re as useWalletCreate
272
275
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ecency/wallets",
3
3
  "private": false,
4
- "version": "1.0.2",
4
+ "version": "1.0.5",
5
5
  "type": "module",
6
6
  "main": "./dist/ecency-wallets.umd.js",
7
7
  "module": "./dist/ecency-wallets.es.js",
@@ -9,11 +9,6 @@
9
9
  "dist",
10
10
  "README.md"
11
11
  ],
12
- "exports": {
13
- ".": {
14
- "import": "./dist/ecency-renderer.es.js"
15
- }
16
- },
17
12
  "scripts": {
18
13
  "dev": "vite",
19
14
  "build": "tsc && vite build",