@ecency/wallets 1.0.4 → 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.
- package/dist/ecency-wallets.es.js +19 -16
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo as b, useCallback as S } from "react";
|
|
2
|
-
import { useQuery as l, useQueryClient as
|
|
3
|
-
import { BtcWallet as
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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}`
|
|
@@ -104,7 +104,7 @@ const H = {
|
|
|
104
104
|
allowStale: !1,
|
|
105
105
|
updateAgeOnGet: !1,
|
|
106
106
|
updateAgeOnHas: !1
|
|
107
|
-
}, f = new
|
|
107
|
+
}, f = new j(H), m = Symbol("undefined"), W = (e, t) => f.set(e, t === void 0 ? m : t), q = (e) => {
|
|
108
108
|
const t = f.get(e);
|
|
109
109
|
return t === m ? void 0 : t;
|
|
110
110
|
};
|
|
@@ -191,7 +191,7 @@ const B = {
|
|
|
191
191
|
// Cosmos (BIP44)
|
|
192
192
|
};
|
|
193
193
|
function re(e, t) {
|
|
194
|
-
const { data: o } = y(), s =
|
|
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)
|
|
@@ -200,7 +200,7 @@ function re(e, t) {
|
|
|
200
200
|
mnemonic: o,
|
|
201
201
|
hdPath: B[t]
|
|
202
202
|
}));
|
|
203
|
-
await
|
|
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
|
|
229
|
-
function
|
|
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
232
|
}), { data: o } = x(e);
|
|
233
|
-
return
|
|
233
|
+
return w({
|
|
234
234
|
mutationKey: ["ecency-wallets", "create-account-with-wallets", e],
|
|
235
|
-
mutationFn: ({ currency: s, address: c }) => fetch(
|
|
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,12 +260,12 @@ function C(e) {
|
|
|
257
260
|
}
|
|
258
261
|
const ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
259
262
|
__proto__: null,
|
|
260
|
-
useCreateAccountWithWallets:
|
|
263
|
+
useCreateAccountWithWallets: M
|
|
261
264
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
262
265
|
export {
|
|
263
266
|
n as EcencyWalletCurrency,
|
|
264
267
|
ie as EcencyWalletsPrivateApi,
|
|
265
|
-
|
|
268
|
+
K as delay,
|
|
266
269
|
_ as getWallet,
|
|
267
270
|
ce as useCoinGeckoPriceQuery,
|
|
268
271
|
se as useGetExternalWalletBalanceQuery,
|