@ecency/sdk 1.0.6 → 1.0.8
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.
- package/dist/ecency-sdk.es.d.ts +3 -1
- package/dist/ecency-sdk.es.js +34 -34
- package/package.json +1 -1
package/dist/ecency-sdk.es.d.ts
CHANGED
@@ -88,7 +88,9 @@ address: any;
|
|
88
88
|
publicKey: string;
|
89
89
|
}, Error, Payload_3, unknown>;
|
90
90
|
|
91
|
-
export declare function useSaveWalletInformationToMetadata(username: string): UseMutationResult<any, Error,
|
91
|
+
export declare function useSaveWalletInformationToMetadata(username: string): UseMutationResult<any, Error, {
|
92
|
+
wallets: Map<EcencyWalletCurrency, EcencyCreateWalletInformation>;
|
93
|
+
}, unknown>;
|
92
94
|
|
93
95
|
export declare function useSeedPhrase(username: string): UseQueryResult<string, Error>;
|
94
96
|
|
package/dist/ecency-sdk.es.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { useCallback as k } from "react";
|
2
|
-
import { useQuery as
|
2
|
+
import { useQuery as d, useQueryClient as f, useMutation as p } from "@tanstack/react-query";
|
3
3
|
import { BtcWallet as O } from "@okxweb3/coin-bitcoin";
|
4
4
|
import { EthWallet as A } from "@okxweb3/coin-ethereum";
|
5
5
|
import { TrxWallet as R } from "@okxweb3/coin-tron";
|
@@ -9,7 +9,7 @@ import { AtomWallet as C } from "@okxweb3/coin-cosmos";
|
|
9
9
|
import { AptosWallet as x } from "@okxweb3/coin-aptos";
|
10
10
|
import D, { mnemonicToSeedSync as _ } from "bip39";
|
11
11
|
import { LRUCache as j } from "lru-cache";
|
12
|
-
import { PrivateKey as
|
12
|
+
import { PrivateKey as u, Client as H } from "@hiveio/dhive";
|
13
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) {
|
@@ -39,7 +39,7 @@ function ye(e) {
|
|
39
39
|
return _(e).toString("hex");
|
40
40
|
}
|
41
41
|
function fe(e, t) {
|
42
|
-
return
|
42
|
+
return d({
|
43
43
|
queryKey: ["ecency-wallets", "external-wallet-balance", e, t],
|
44
44
|
queryFn: async () => {
|
45
45
|
switch (e) {
|
@@ -89,7 +89,7 @@ function fe(e, t) {
|
|
89
89
|
});
|
90
90
|
}
|
91
91
|
function T(e) {
|
92
|
-
return
|
92
|
+
return d({
|
93
93
|
queryKey: ["ecency-wallets", "seed", e],
|
94
94
|
queryFn: async () => D.generateMnemonic(128)
|
95
95
|
});
|
@@ -107,7 +107,7 @@ const B = {
|
|
107
107
|
return t === w ? void 0 : t;
|
108
108
|
};
|
109
109
|
function ge(e) {
|
110
|
-
return
|
110
|
+
return d({
|
111
111
|
queryKey: ["ecency-wallets", "coingecko-price", e],
|
112
112
|
queryFn: async () => {
|
113
113
|
let t = e;
|
@@ -150,14 +150,14 @@ function ge(e) {
|
|
150
150
|
enabled: !!e
|
151
151
|
});
|
152
152
|
}
|
153
|
-
function
|
153
|
+
function L(e) {
|
154
154
|
const { data: t } = T(e);
|
155
|
-
return
|
155
|
+
return d({
|
156
156
|
queryKey: ["ecencу-wallets", "hive-keys", e, t],
|
157
157
|
queryFn: async () => {
|
158
158
|
if (!t)
|
159
159
|
throw new Error("[Ecency][Wallets] - no seed to create Hive account");
|
160
|
-
const n =
|
160
|
+
const n = u.fromLogin(e, t, "owner"), s = u.fromLogin(e, t, "active"), a = u.fromLogin(e, t, "posting"), i = u.fromLogin(e, t, "memo");
|
161
161
|
return {
|
162
162
|
username: e,
|
163
163
|
owner: n.toString(),
|
@@ -172,7 +172,7 @@ function q(e) {
|
|
172
172
|
}
|
173
173
|
});
|
174
174
|
}
|
175
|
-
const
|
175
|
+
const q = {
|
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,14 +189,14 @@ const L = {
|
|
189
189
|
// Cosmos (BIP44)
|
190
190
|
};
|
191
191
|
function Te(e, t) {
|
192
|
-
const { data: n } = T(e), s = f(), a =
|
192
|
+
const { data: n } = T(e), s = f(), 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:
|
199
|
+
hdPath: q[t]
|
200
200
|
}));
|
201
201
|
await W(1e3);
|
202
202
|
const l = await (r == null ? void 0 : r.getNewAddress({
|
@@ -223,7 +223,7 @@ function Te(e, t) {
|
|
223
223
|
importWallet: i
|
224
224
|
};
|
225
225
|
}
|
226
|
-
const
|
226
|
+
const m = {
|
227
227
|
privateApiHost: "https://ecency.com",
|
228
228
|
storage: localStorage,
|
229
229
|
storagePrefix: "ecency",
|
@@ -249,12 +249,12 @@ const d = {
|
|
249
249
|
)
|
250
250
|
};
|
251
251
|
function J(e) {
|
252
|
-
const { data: t } =
|
252
|
+
const { data: t } = d({
|
253
253
|
queryKey: ["ecency-wallets", "wallets", e]
|
254
|
-
}), { data: n } =
|
255
|
-
return
|
254
|
+
}), { data: n } = L(e);
|
255
|
+
return p({
|
256
256
|
mutationKey: ["ecency-wallets", "create-account-with-wallets", e],
|
257
|
-
mutationFn: ({ currency: s, address: a }) => fetch(
|
257
|
+
mutationFn: ({ currency: s, address: a }) => fetch(m.privateApiHost + "/private-api/wallets-add", {
|
258
258
|
method: "POST",
|
259
259
|
headers: {
|
260
260
|
"Content-Type": "application/json"
|
@@ -281,10 +281,10 @@ function J(e) {
|
|
281
281
|
});
|
282
282
|
}
|
283
283
|
function v() {
|
284
|
-
return
|
284
|
+
return p({
|
285
285
|
mutationKey: ["ecency-wallets", "check-wallet-existence"],
|
286
286
|
mutationFn: async ({ address: e, currency: t }) => (await (await fetch(
|
287
|
-
|
287
|
+
m.privateApiHost + "/private-api/wallets-exist",
|
288
288
|
{
|
289
289
|
method: "POST",
|
290
290
|
headers: {
|
@@ -331,7 +331,7 @@ async function I(e, t, n) {
|
|
331
331
|
}
|
332
332
|
function ve(e, t) {
|
333
333
|
const n = f(), { mutateAsync: s } = v();
|
334
|
-
return
|
334
|
+
return p({
|
335
335
|
mutationKey: ["ecency-wallets", "import-wallet", e, t],
|
336
336
|
mutationFn: async ({ privateKeyOrSeed: a }) => {
|
337
337
|
const i = g(t);
|
@@ -384,8 +384,8 @@ function $(e) {
|
|
384
384
|
}
|
385
385
|
const h = (e) => {
|
386
386
|
try {
|
387
|
-
const t =
|
388
|
-
|
387
|
+
const t = m.storage.getItem(
|
388
|
+
m.storagePrefix + "_user_" + e
|
389
389
|
);
|
390
390
|
return $(JSON.parse(t));
|
391
391
|
} catch (t) {
|
@@ -394,13 +394,13 @@ const h = (e) => {
|
|
394
394
|
}
|
395
395
|
}, G = (e) => h(e) && h(e).accessToken, U = (e) => h(e) && h(e).postingKey;
|
396
396
|
function V(e = [], t, n) {
|
397
|
-
return
|
397
|
+
return p({
|
398
398
|
mutationKey: [...e, t],
|
399
399
|
mutationFn: async (s) => {
|
400
400
|
const a = U(t);
|
401
401
|
if (a) {
|
402
|
-
const r =
|
403
|
-
return
|
402
|
+
const r = u.fromString(a);
|
403
|
+
return m.hiveClient.broadcast.sendOperations(
|
404
404
|
n(s),
|
405
405
|
r
|
406
406
|
);
|
@@ -420,7 +420,7 @@ function z(e) {
|
|
420
420
|
return V(
|
421
421
|
["accounts", "update"],
|
422
422
|
e,
|
423
|
-
(
|
423
|
+
(t) => [
|
424
424
|
[
|
425
425
|
"account_update2",
|
426
426
|
{
|
@@ -436,20 +436,20 @@ function z(e) {
|
|
436
436
|
);
|
437
437
|
}
|
438
438
|
function Pe(e) {
|
439
|
-
const {
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
439
|
+
const { mutateAsync: t } = z(e);
|
440
|
+
return p({
|
441
|
+
mutationKey: ["ecency-wallets", "save-wallet-to-metadata", e],
|
442
|
+
mutationFn: ({
|
443
|
+
wallets: n
|
444
|
+
}) => t(
|
445
|
+
Array.from(n.entries() ?? []).reduce(
|
446
446
|
(s, [a, i]) => ({
|
447
447
|
...s,
|
448
448
|
[a]: i.address
|
449
449
|
}),
|
450
450
|
{}
|
451
451
|
)
|
452
|
-
|
452
|
+
)
|
453
453
|
});
|
454
454
|
}
|
455
455
|
export {
|
@@ -461,7 +461,7 @@ export {
|
|
461
461
|
z as useAccountUpdate,
|
462
462
|
ge as useCoinGeckoPriceQuery,
|
463
463
|
fe as useGetExternalWalletBalanceQuery,
|
464
|
-
|
464
|
+
L as useHiveKeysQuery,
|
465
465
|
ve as useImportWallet,
|
466
466
|
Pe as useSaveWalletInformationToMetadata,
|
467
467
|
T as useSeedPhrase,
|