@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.
- package/dist/ecency-sdk.es.d.ts +1 -1
- package/dist/ecency-sdk.es.js +24 -20
- package/package.json +1 -1
package/dist/ecency-sdk.es.d.ts
CHANGED
@@ -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>;
|
package/dist/ecency-sdk.es.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { useCallback as O } from "react";
|
2
|
-
import { useQuery as d, useQueryClient as
|
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
|
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
|
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
|
38
|
+
function fe(e) {
|
39
39
|
return j(e).toString("hex");
|
40
40
|
}
|
41
|
-
function
|
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
|
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
|
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
|
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 =
|
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:
|
199
|
+
hdPath: I[t]
|
200
200
|
}));
|
201
|
-
await
|
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
|
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:
|
305
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
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
|
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 =
|
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
|
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
|
-
|
469
|
+
W as delay,
|
466
470
|
g as getWallet,
|
467
|
-
|
471
|
+
fe as mnemonicToSeedBip39,
|
468
472
|
z as useAccountUpdate,
|
469
473
|
ge as useCoinGeckoPriceQuery,
|
470
|
-
|
474
|
+
ye as useGetExternalWalletBalanceQuery,
|
471
475
|
q as useHiveKeysQuery,
|
472
476
|
ve as useImportWallet,
|
473
477
|
Pe as useSaveWalletInformationToMetadata,
|