@ecency/sdk 1.0.19 → 1.0.21
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.js
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
import { useCallback as
|
2
|
-
import { useQuery as m, queryOptions as
|
3
|
-
import { BtcWallet as
|
1
|
+
import { useMemo as K, useCallback as R } from "react";
|
2
|
+
import { useQuery as m, queryOptions as g, useQueryClient as v, useMutation as u } from "@tanstack/react-query";
|
3
|
+
import { BtcWallet as C } from "@okxweb3/coin-bitcoin";
|
4
4
|
import { EthWallet as H } from "@okxweb3/coin-ethereum";
|
5
|
-
import { TrxWallet as
|
6
|
-
import { TonWallet as
|
7
|
-
import { SolWallet as
|
8
|
-
import { AtomWallet as
|
9
|
-
import { AptosWallet as
|
10
|
-
import _, { mnemonicToSeedSync as
|
11
|
-
import { Client as
|
12
|
-
import { LRUCache as
|
13
|
-
import
|
14
|
-
var
|
15
|
-
function
|
16
|
-
return new Promise((
|
5
|
+
import { TrxWallet as N } from "@okxweb3/coin-tron";
|
6
|
+
import { TonWallet as j } from "@okxweb3/coin-ton";
|
7
|
+
import { SolWallet as D } from "@okxweb3/coin-solana";
|
8
|
+
import { AtomWallet as x } from "@okxweb3/coin-cosmos";
|
9
|
+
import { AptosWallet as L } from "@okxweb3/coin-aptos";
|
10
|
+
import _, { mnemonicToSeedSync as F } from "bip39";
|
11
|
+
import { Client as B, PrivateKey as l, cryptoUtils as E } from "@hiveio/dhive";
|
12
|
+
import { LRUCache as q } from "lru-cache";
|
13
|
+
import b from "hivesigner";
|
14
|
+
var a = /* @__PURE__ */ ((e) => (e.BTC = "BTC", e.ETH = "ETH", e.APT = "APT", e.ATOM = "ATOM", e.TON = "TON", e.TRON = "TRX", e.SOL = "SOL", e))(a || {}), h = /* @__PURE__ */ ((e) => (e.Points = "POINTS", e.HivePower = "HP", e.Hive = "HIVE", e.HiveDollar = "HBD", e.Spk = "SPK", e))(h || {});
|
15
|
+
function M(e) {
|
16
|
+
return new Promise((t) => setTimeout(t, e));
|
17
17
|
}
|
18
|
-
function T(
|
19
|
-
switch (
|
20
|
-
case
|
21
|
-
return new R();
|
22
|
-
case o.ETH:
|
23
|
-
return new H();
|
24
|
-
case o.TRON:
|
18
|
+
function T(e) {
|
19
|
+
switch (e) {
|
20
|
+
case a.BTC:
|
25
21
|
return new C();
|
26
|
-
case
|
22
|
+
case a.ETH:
|
23
|
+
return new H();
|
24
|
+
case a.TRON:
|
27
25
|
return new N();
|
28
|
-
case
|
26
|
+
case a.TON:
|
29
27
|
return new j();
|
30
|
-
case
|
28
|
+
case a.SOL:
|
31
29
|
return new D();
|
32
|
-
case
|
30
|
+
case a.ATOM:
|
33
31
|
return new x();
|
32
|
+
case a.APT:
|
33
|
+
return new L();
|
34
34
|
default:
|
35
35
|
return;
|
36
36
|
}
|
37
37
|
}
|
38
|
-
function
|
39
|
-
return
|
38
|
+
function Pe(e) {
|
39
|
+
return F(e).toString("hex");
|
40
40
|
}
|
41
41
|
const p = {
|
42
42
|
privateApiHost: "https://ecency.com",
|
43
43
|
storage: localStorage,
|
44
44
|
storagePrefix: "ecency",
|
45
|
-
hiveClient: new
|
45
|
+
hiveClient: new B(
|
46
46
|
[
|
47
47
|
"https://api.hive.blog",
|
48
48
|
"https://api.deathwing.me",
|
@@ -64,21 +64,21 @@ const p = {
|
|
64
64
|
),
|
65
65
|
heliusApiKey: "fb1e2935-f911-4b1d-8e1c-3863f6879d42"
|
66
66
|
};
|
67
|
-
function
|
67
|
+
function Se(e, t) {
|
68
68
|
return m({
|
69
|
-
queryKey: ["ecency-wallets", "external-wallet-balance",
|
69
|
+
queryKey: ["ecency-wallets", "external-wallet-balance", e, t],
|
70
70
|
queryFn: async () => {
|
71
|
-
switch (
|
72
|
-
case
|
73
|
-
const
|
74
|
-
`https://mempool.space/api/address/${
|
71
|
+
switch (e) {
|
72
|
+
case a.BTC:
|
73
|
+
const o = await (await fetch(
|
74
|
+
`https://mempool.space/api/address/${t}`
|
75
75
|
)).json();
|
76
|
-
return (
|
77
|
-
case
|
76
|
+
return (o.chain_stats.funded_txo_sum - o.chain_stats.spent_txo_sum) / 1e8;
|
77
|
+
case a.ETH:
|
78
78
|
return +(await (await fetch(
|
79
|
-
`https://api.ethplorer.io/getAddressInfo/${
|
79
|
+
`https://api.ethplorer.io/getAddressInfo/${t}?apiKey=freekey`
|
80
80
|
)).json()).ETH.balance;
|
81
|
-
case
|
81
|
+
case a.SOL:
|
82
82
|
return (await (await fetch(
|
83
83
|
`https://rpc.helius.xyz/?api-key=${p.heliusApiKey}`,
|
84
84
|
{
|
@@ -87,43 +87,43 @@ function Tt(t, e) {
|
|
87
87
|
jsonrpc: "2.0",
|
88
88
|
id: "1",
|
89
89
|
method: "getBalance",
|
90
|
-
params: [
|
90
|
+
params: [t]
|
91
91
|
}),
|
92
92
|
headers: {
|
93
93
|
"Content-Type": "application/json"
|
94
94
|
}
|
95
95
|
}
|
96
96
|
)).json()).result.value / 1e9;
|
97
|
-
case
|
97
|
+
case a.TRON:
|
98
98
|
return (await (await fetch(
|
99
|
-
`https://api.trongrid.io/v1/accounts/${
|
99
|
+
`https://api.trongrid.io/v1/accounts/${t}`
|
100
100
|
)).json()).data[0].balance / 1e6;
|
101
|
-
case
|
101
|
+
case a.TON:
|
102
102
|
return (await (await fetch(
|
103
|
-
`https://tonapi.io/v1/blockchain/getAccount?account=${
|
103
|
+
`https://tonapi.io/v1/blockchain/getAccount?account=${t}`
|
104
104
|
)).json()).balance / 1e9;
|
105
|
-
case
|
106
|
-
const
|
107
|
-
`https://fullnode.mainnet.aptoslabs.com/v1/accounts/${
|
105
|
+
case a.APT:
|
106
|
+
const f = (await (await fetch(
|
107
|
+
`https://fullnode.mainnet.aptoslabs.com/v1/accounts/${t}/resources`
|
108
108
|
)).json()).find(
|
109
109
|
(k) => k.type.includes("coin::CoinStore")
|
110
110
|
);
|
111
|
-
return
|
112
|
-
case
|
111
|
+
return f ? parseInt(f.data.coin.value) / 1e8 : 0;
|
112
|
+
case a.ATOM:
|
113
113
|
return +(await (await fetch(
|
114
|
-
`https://rest.cosmos.directory/cosmoshub/auth/accounts/${
|
114
|
+
`https://rest.cosmos.directory/cosmoshub/auth/accounts/${t}`
|
115
115
|
)).json()).result.value.coins[0].amount / 1e6;
|
116
116
|
}
|
117
117
|
}
|
118
118
|
});
|
119
119
|
}
|
120
|
-
function
|
120
|
+
function P(e) {
|
121
121
|
return m({
|
122
|
-
queryKey: ["ecency-wallets", "seed",
|
122
|
+
queryKey: ["ecency-wallets", "seed", e],
|
123
123
|
queryFn: async () => _.generateMnemonic(128)
|
124
124
|
});
|
125
125
|
}
|
126
|
-
const
|
126
|
+
const W = {
|
127
127
|
max: 500,
|
128
128
|
// how long to live in ms
|
129
129
|
ttl: 1e3 * 60 * 5,
|
@@ -131,34 +131,34 @@ const J = {
|
|
131
131
|
allowStale: !1,
|
132
132
|
updateAgeOnGet: !1,
|
133
133
|
updateAgeOnHas: !1
|
134
|
-
},
|
135
|
-
const
|
136
|
-
return
|
134
|
+
}, S = new q(W), y = Symbol("undefined"), Q = (e, t) => S.set(e, t === void 0 ? y : t), I = (e) => {
|
135
|
+
const t = S.get(e);
|
136
|
+
return t === y ? void 0 : t;
|
137
137
|
};
|
138
|
-
function
|
138
|
+
function Oe(e) {
|
139
139
|
return m({
|
140
|
-
queryKey: ["ecency-wallets", "coingecko-price",
|
140
|
+
queryKey: ["ecency-wallets", "coingecko-price", e],
|
141
141
|
queryFn: async () => {
|
142
|
-
let
|
143
|
-
switch (
|
144
|
-
case
|
145
|
-
|
142
|
+
let t = e;
|
143
|
+
switch (e) {
|
144
|
+
case a.BTC:
|
145
|
+
t = "binance-wrapped-btc";
|
146
146
|
break;
|
147
|
-
case
|
148
|
-
|
147
|
+
case a.ETH:
|
148
|
+
t = "ethereum";
|
149
149
|
break;
|
150
|
-
case
|
151
|
-
|
150
|
+
case a.SOL:
|
151
|
+
t = "solana";
|
152
152
|
break;
|
153
|
-
case
|
154
|
-
|
153
|
+
case a.TON:
|
154
|
+
t = "trx";
|
155
155
|
break;
|
156
156
|
default:
|
157
|
-
|
157
|
+
t = e;
|
158
158
|
}
|
159
|
-
let n =
|
159
|
+
let n = I("gecko"), o;
|
160
160
|
if (n)
|
161
|
-
|
161
|
+
o = n;
|
162
162
|
else {
|
163
163
|
const i = await (await fetch(
|
164
164
|
"https://api.coingecko.com/api/v3/simple/price",
|
@@ -166,61 +166,61 @@ function St(t) {
|
|
166
166
|
method: "POST",
|
167
167
|
body: JSON.stringify({
|
168
168
|
params: {
|
169
|
-
ids: [
|
169
|
+
ids: [t],
|
170
170
|
vs_currencies: "usd"
|
171
171
|
}
|
172
172
|
})
|
173
173
|
}
|
174
174
|
)).json();
|
175
|
-
|
175
|
+
Q("gecko", i === void 0 ? y : i), o = i;
|
176
176
|
}
|
177
|
-
return 1 / +
|
177
|
+
return 1 / +o[Object.keys(o)[0]].usd;
|
178
178
|
},
|
179
|
-
enabled: !!
|
179
|
+
enabled: !!e
|
180
180
|
});
|
181
181
|
}
|
182
|
-
function
|
183
|
-
const { data:
|
182
|
+
function J(e) {
|
183
|
+
const { data: t } = P(e);
|
184
184
|
return m({
|
185
|
-
queryKey: ["ecencу-wallets", "hive-keys",
|
185
|
+
queryKey: ["ecencу-wallets", "hive-keys", e, t],
|
186
186
|
queryFn: async () => {
|
187
|
-
if (!
|
187
|
+
if (!t)
|
188
188
|
throw new Error("[Ecency][Wallets] - no seed to create Hive account");
|
189
|
-
const n = l.fromLogin(
|
189
|
+
const n = l.fromLogin(e, t, "owner"), o = l.fromLogin(e, t, "active"), s = l.fromLogin(e, t, "posting"), r = l.fromLogin(e, t, "memo");
|
190
190
|
return {
|
191
|
-
username:
|
191
|
+
username: e,
|
192
192
|
owner: n.toString(),
|
193
|
-
active:
|
193
|
+
active: o.toString(),
|
194
194
|
posting: s.toString(),
|
195
195
|
memo: r.toString(),
|
196
196
|
ownerPubkey: n.createPublic().toString(),
|
197
|
-
activePubkey:
|
197
|
+
activePubkey: o.createPublic().toString(),
|
198
198
|
postingPubkey: s.createPublic().toString(),
|
199
199
|
memoPubkey: r.createPublic().toString()
|
200
200
|
};
|
201
201
|
}
|
202
202
|
});
|
203
203
|
}
|
204
|
-
function
|
205
|
-
return
|
206
|
-
queryKey: ["ecency-wallets", "points",
|
204
|
+
function Ae(e, t) {
|
205
|
+
return g({
|
206
|
+
queryKey: ["ecency-wallets", "points", e, t],
|
207
207
|
queryFn: async () => await (await fetch(
|
208
208
|
`${p.privateApiHost}/private-api/points`,
|
209
209
|
{
|
210
210
|
method: "POST",
|
211
211
|
body: JSON.stringify({
|
212
|
-
username:
|
212
|
+
username: e.replace("@", "")
|
213
213
|
})
|
214
214
|
}
|
215
215
|
)).json(),
|
216
216
|
staleTime: 3e4,
|
217
217
|
refetchOnMount: !0,
|
218
|
-
enabled: !!
|
218
|
+
enabled: !!e
|
219
219
|
});
|
220
220
|
}
|
221
|
-
function
|
222
|
-
return
|
223
|
-
queryKey: ["hive-engine", "tokens-list",
|
221
|
+
function $(e, t) {
|
222
|
+
return g({
|
223
|
+
queryKey: ["hive-engine", "tokens-list", e, t],
|
224
224
|
queryFn: async () => (await (await fetch(
|
225
225
|
`${p.privateApiHost}/private-api/engine-api`,
|
226
226
|
{
|
@@ -232,8 +232,8 @@ function I(t, e) {
|
|
232
232
|
contract: "market",
|
233
233
|
table: "metrics",
|
234
234
|
query: {
|
235
|
-
symbol:
|
236
|
-
account:
|
235
|
+
symbol: t,
|
236
|
+
account: e
|
237
237
|
}
|
238
238
|
},
|
239
239
|
id: 1
|
@@ -243,94 +243,102 @@ function I(t, e) {
|
|
243
243
|
)).json()).result
|
244
244
|
});
|
245
245
|
}
|
246
|
-
function
|
247
|
-
const { data: t } = m(
|
248
|
-
return
|
249
|
-
() =>
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
246
|
+
function ke(e) {
|
247
|
+
const { data: t } = m($());
|
248
|
+
return K(
|
249
|
+
() => {
|
250
|
+
var n;
|
251
|
+
return {
|
252
|
+
basic: [
|
253
|
+
h.Points,
|
254
|
+
h.Hive,
|
255
|
+
h.HivePower,
|
256
|
+
h.HiveDollar,
|
257
|
+
h.Spk
|
258
|
+
].filter((o) => o.toLowerCase().includes(e.toLowerCase())),
|
259
|
+
external: Object.values(a).filter(
|
260
|
+
(o) => o.toLowerCase().includes(e.toLowerCase())
|
261
|
+
),
|
262
|
+
layer2: ((n = t == null ? void 0 : t.map(({ symbol: o }) => o)) == null ? void 0 : n.filter(
|
263
|
+
(o) => o.toLowerCase().includes(e.toLowerCase())
|
264
|
+
)) ?? []
|
265
|
+
};
|
266
|
+
},
|
267
|
+
[t, e]
|
260
268
|
);
|
261
269
|
}
|
262
270
|
const G = {
|
263
|
-
[
|
271
|
+
[a.BTC]: "m/44'/0'/0'/0/0",
|
264
272
|
// Bitcoin (BIP44)
|
265
|
-
[
|
273
|
+
[a.ETH]: "m/44'/60'/0'/0/0",
|
266
274
|
// Ethereum (BIP44)
|
267
|
-
[
|
275
|
+
[a.SOL]: "m/44'/501'/0'/0'",
|
268
276
|
// Solana (BIP44)
|
269
|
-
[
|
277
|
+
[a.TON]: "m/44'/607'/0'",
|
270
278
|
// TON (BIP44)
|
271
|
-
[
|
279
|
+
[a.TRON]: "m/44'/195'/0'/0/0",
|
272
280
|
// Tron (BIP44)
|
273
|
-
[
|
281
|
+
[a.APT]: "m/44'/637'/0'/0'/0'",
|
274
282
|
// Aptos (BIP44)
|
275
|
-
[
|
283
|
+
[a.ATOM]: "m/44'/118'/0'/0/0"
|
276
284
|
// Cosmos (BIP44)
|
277
285
|
};
|
278
|
-
function
|
279
|
-
const { data: n } =
|
280
|
-
mutationKey: ["ecency-wallets", "create-wallet",
|
286
|
+
function Ke(e, t) {
|
287
|
+
const { data: n } = P(e), o = v(), s = u({
|
288
|
+
mutationKey: ["ecency-wallets", "create-wallet", e, t],
|
281
289
|
mutationFn: async () => {
|
282
290
|
if (!n)
|
283
291
|
throw new Error("[Ecency][Wallets] - No seed to create a wallet");
|
284
|
-
const i = T(
|
292
|
+
const i = T(t), c = await (i == null ? void 0 : i.getDerivedPrivateKey({
|
285
293
|
mnemonic: n,
|
286
|
-
hdPath: G[
|
294
|
+
hdPath: G[t]
|
287
295
|
}));
|
288
|
-
await
|
289
|
-
const
|
296
|
+
await M(1e3);
|
297
|
+
const d = await (i == null ? void 0 : i.getNewAddress({
|
290
298
|
privateKey: c
|
291
299
|
}));
|
292
300
|
return {
|
293
301
|
privateKey: c,
|
294
|
-
address:
|
295
|
-
publicKey:
|
296
|
-
username:
|
297
|
-
currency:
|
302
|
+
address: d.address,
|
303
|
+
publicKey: d.publicKey,
|
304
|
+
username: e,
|
305
|
+
currency: t
|
298
306
|
};
|
299
307
|
},
|
300
308
|
onSuccess: (i) => {
|
301
|
-
|
309
|
+
o.setQueryData(
|
302
310
|
["ecency-wallets", "wallets", i.username],
|
303
311
|
(c) => new Map(c ? Array.from(c.entries()) : []).set(i.currency, i)
|
304
312
|
);
|
305
313
|
}
|
306
|
-
}), r =
|
314
|
+
}), r = R(() => {
|
307
315
|
}, []);
|
308
316
|
return {
|
309
317
|
createWallet: s,
|
310
318
|
importWallet: r
|
311
319
|
};
|
312
320
|
}
|
313
|
-
function
|
314
|
-
const { data:
|
315
|
-
queryKey: ["ecency-wallets", "wallets",
|
316
|
-
}), { data: n } =
|
321
|
+
function V(e) {
|
322
|
+
const { data: t } = m({
|
323
|
+
queryKey: ["ecency-wallets", "wallets", e]
|
324
|
+
}), { data: n } = J(e);
|
317
325
|
return u({
|
318
|
-
mutationKey: ["ecency-wallets", "create-account-with-wallets",
|
319
|
-
mutationFn: ({ currency:
|
326
|
+
mutationKey: ["ecency-wallets", "create-account-with-wallets", e],
|
327
|
+
mutationFn: ({ currency: o, address: s }) => fetch(p.privateApiHost + "/private-api/wallets-add", {
|
320
328
|
method: "POST",
|
321
329
|
headers: {
|
322
330
|
"Content-Type": "application/json"
|
323
331
|
},
|
324
332
|
body: JSON.stringify({
|
325
|
-
username:
|
326
|
-
token:
|
333
|
+
username: e,
|
334
|
+
token: o,
|
327
335
|
address: s,
|
328
336
|
meta: {
|
329
337
|
ownerPublicKey: n == null ? void 0 : n.ownerPubkey,
|
330
338
|
activePublicKey: n == null ? void 0 : n.activePubkey,
|
331
339
|
postingPublicKey: n == null ? void 0 : n.postingPubkey,
|
332
340
|
memoPublicKey: n == null ? void 0 : n.memoPubkey,
|
333
|
-
...Array.from((
|
341
|
+
...Array.from((t == null ? void 0 : t.entries()) ?? []).reduce(
|
334
342
|
(r, [i, c]) => ({
|
335
343
|
...r,
|
336
344
|
[i]: c.address
|
@@ -342,10 +350,10 @@ function W(t) {
|
|
342
350
|
})
|
343
351
|
});
|
344
352
|
}
|
345
|
-
function
|
353
|
+
function O() {
|
346
354
|
return u({
|
347
355
|
mutationKey: ["ecency-wallets", "check-wallet-existence"],
|
348
|
-
mutationFn: async ({ address:
|
356
|
+
mutationFn: async ({ address: e, currency: t }) => (await (await fetch(
|
349
357
|
p.privateApiHost + "/private-api/wallets-exist",
|
350
358
|
{
|
351
359
|
method: "POST",
|
@@ -353,37 +361,37 @@ function A() {
|
|
353
361
|
"Content-Type": "application/json"
|
354
362
|
},
|
355
363
|
body: JSON.stringify({
|
356
|
-
address:
|
357
|
-
token:
|
364
|
+
address: e,
|
365
|
+
token: t
|
358
366
|
})
|
359
367
|
}
|
360
368
|
)).json()).length === 0
|
361
369
|
});
|
362
370
|
}
|
363
|
-
const
|
371
|
+
const Re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
364
372
|
__proto__: null,
|
365
|
-
useCheckWalletExistence:
|
366
|
-
useCreateAccountWithWallets:
|
373
|
+
useCheckWalletExistence: O,
|
374
|
+
useCreateAccountWithWallets: V
|
367
375
|
}, Symbol.toStringTag, { value: "Module" })), U = {
|
368
|
-
[
|
369
|
-
[
|
376
|
+
[a.BTC]: ["m/84'/0'/0'/0/0"],
|
377
|
+
[a.ETH]: ["m/84'/60'/0'/0/0"],
|
370
378
|
// its not working for Trust, Exodus, todo: check others below
|
371
|
-
[
|
372
|
-
[
|
373
|
-
[
|
374
|
-
[
|
379
|
+
[a.SOL]: ["m/84'/501'/0'/0/0"],
|
380
|
+
[a.TRON]: ["m/44'/195'/0'/0'/0'"],
|
381
|
+
[a.APT]: ["m/84'/637'/0'/0/0"],
|
382
|
+
[a.TON]: [],
|
375
383
|
// Disabled
|
376
|
-
[
|
384
|
+
[a.ATOM]: ["m/84'/118'/0'/0'/0"]
|
377
385
|
};
|
378
|
-
async function
|
379
|
-
for (const
|
386
|
+
async function z(e, t, n) {
|
387
|
+
for (const o of U[n] || [])
|
380
388
|
try {
|
381
|
-
const s = await
|
382
|
-
mnemonic:
|
383
|
-
hdPath:
|
384
|
-
}), r = await
|
389
|
+
const s = await t.getDerivedPrivateKey({
|
390
|
+
mnemonic: e,
|
391
|
+
hdPath: o
|
392
|
+
}), r = await t.getNewAddress({
|
385
393
|
privateKey: s,
|
386
|
-
addressType: n ===
|
394
|
+
addressType: n === a.BTC ? "segwit_native" : void 0
|
387
395
|
});
|
388
396
|
return [s.toString(), r.address];
|
389
397
|
} catch {
|
@@ -391,109 +399,109 @@ async function V(t, e, n) {
|
|
391
399
|
}
|
392
400
|
return [];
|
393
401
|
}
|
394
|
-
function
|
395
|
-
const n =
|
402
|
+
function Ce(e, t) {
|
403
|
+
const n = v(), { mutateAsync: o } = O();
|
396
404
|
return u({
|
397
|
-
mutationKey: ["ecency-wallets", "import-wallet",
|
405
|
+
mutationKey: ["ecency-wallets", "import-wallet", e, t],
|
398
406
|
mutationFn: async ({ privateKeyOrSeed: s }) => {
|
399
|
-
const r = T(
|
407
|
+
const r = T(t);
|
400
408
|
if (!r)
|
401
409
|
throw new Error("Cannot find token for this currency");
|
402
410
|
const i = s.split(" ").length === 12;
|
403
|
-
let c,
|
404
|
-
if (i ? [
|
411
|
+
let c, d = s;
|
412
|
+
if (i ? [d, c] = await z(
|
405
413
|
s,
|
406
414
|
r,
|
407
|
-
|
415
|
+
t
|
408
416
|
) : c = (await r.getNewAddress({
|
409
417
|
privateKey: s
|
410
418
|
})).address, !c || !s)
|
411
419
|
throw new Error(
|
412
420
|
"Private key/seed phrase isn't matching with public key or token"
|
413
421
|
);
|
414
|
-
if (!await
|
422
|
+
if (!await o({
|
415
423
|
address: c,
|
416
|
-
currency:
|
424
|
+
currency: t
|
417
425
|
}))
|
418
426
|
throw new Error(
|
419
427
|
"This wallet has already in use by Hive account. Please, try another one"
|
420
428
|
);
|
421
429
|
return {
|
422
|
-
privateKey:
|
430
|
+
privateKey: d,
|
423
431
|
address: c,
|
424
432
|
publicKey: ""
|
425
433
|
};
|
426
434
|
},
|
427
435
|
onSuccess: ({ privateKey: s, publicKey: r, address: i }) => {
|
428
436
|
n.setQueryData(
|
429
|
-
["ecency-wallets", "wallets",
|
430
|
-
(c) => new Map(c ? Array.from(c.entries()) : []).set(
|
437
|
+
["ecency-wallets", "wallets", e],
|
438
|
+
(c) => new Map(c ? Array.from(c.entries()) : []).set(t, {
|
431
439
|
privateKey: s,
|
432
440
|
publicKey: r,
|
433
441
|
address: i,
|
434
|
-
username:
|
435
|
-
currency:
|
442
|
+
username: e,
|
443
|
+
currency: t,
|
436
444
|
custom: !0
|
437
445
|
})
|
438
446
|
);
|
439
447
|
}
|
440
448
|
});
|
441
449
|
}
|
442
|
-
function
|
443
|
-
let
|
444
|
-
if (
|
445
|
-
return JSON.parse(
|
450
|
+
function X(e) {
|
451
|
+
let t = atob(e);
|
452
|
+
if (t[0] === "{")
|
453
|
+
return JSON.parse(t);
|
446
454
|
}
|
447
|
-
const
|
455
|
+
const w = (e) => {
|
448
456
|
try {
|
449
|
-
const
|
450
|
-
p.storagePrefix + "_user_" +
|
457
|
+
const t = p.storage.getItem(
|
458
|
+
p.storagePrefix + "_user_" + e
|
451
459
|
);
|
452
|
-
return
|
453
|
-
} catch (
|
454
|
-
console.error(
|
460
|
+
return X(JSON.parse(t));
|
461
|
+
} catch (t) {
|
462
|
+
console.error(t);
|
455
463
|
return;
|
456
464
|
}
|
457
|
-
},
|
458
|
-
function
|
465
|
+
}, Y = (e) => w(e) && w(e).accessToken, Z = (e) => w(e) && w(e).postingKey;
|
466
|
+
function ee(e = [], t, n) {
|
459
467
|
return u({
|
460
|
-
mutationKey: [...
|
461
|
-
mutationFn: async (
|
462
|
-
if (!
|
468
|
+
mutationKey: [...e, t],
|
469
|
+
mutationFn: async (o) => {
|
470
|
+
if (!t)
|
463
471
|
throw new Error(
|
464
472
|
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
465
473
|
);
|
466
|
-
const s =
|
474
|
+
const s = Z(t);
|
467
475
|
if (s) {
|
468
476
|
const i = l.fromString(s);
|
469
477
|
return p.hiveClient.broadcast.sendOperations(
|
470
|
-
n(
|
478
|
+
n(o),
|
471
479
|
i
|
472
480
|
);
|
473
481
|
}
|
474
|
-
let r =
|
482
|
+
let r = Y(t);
|
475
483
|
if (r)
|
476
|
-
return (await new
|
484
|
+
return (await new b.Client({
|
477
485
|
accessToken: r
|
478
|
-
}).broadcast(n(
|
486
|
+
}).broadcast(n(o))).result;
|
479
487
|
throw new Error(
|
480
488
|
"[SDK][Broadcast] – cannot broadcast w/o posting key or token"
|
481
489
|
);
|
482
490
|
}
|
483
491
|
});
|
484
492
|
}
|
485
|
-
function
|
486
|
-
return
|
493
|
+
function te(e) {
|
494
|
+
return ee(
|
487
495
|
["accounts", "update"],
|
488
|
-
|
489
|
-
(
|
496
|
+
e,
|
497
|
+
(t) => [
|
490
498
|
[
|
491
499
|
"account_update2",
|
492
500
|
{
|
493
|
-
account:
|
501
|
+
account: e,
|
494
502
|
json_metadata: "",
|
495
503
|
posting_json_metadata: JSON.stringify({
|
496
|
-
profile: { ...
|
504
|
+
profile: { ...t, version: 2 }
|
497
505
|
}),
|
498
506
|
extensions: []
|
499
507
|
}
|
@@ -501,16 +509,16 @@ function tt(t) {
|
|
501
509
|
]
|
502
510
|
);
|
503
511
|
}
|
504
|
-
function
|
505
|
-
const { mutateAsync:
|
512
|
+
function He(e) {
|
513
|
+
const { mutateAsync: t } = te(e);
|
506
514
|
return u({
|
507
|
-
mutationKey: ["ecency-wallets", "save-wallet-to-metadata",
|
515
|
+
mutationKey: ["ecency-wallets", "save-wallet-to-metadata", e],
|
508
516
|
mutationFn: ({
|
509
517
|
wallets: n
|
510
|
-
}) =>
|
518
|
+
}) => t(
|
511
519
|
Array.from(n.entries() ?? []).reduce(
|
512
|
-
(
|
513
|
-
...
|
520
|
+
(o, [s, r]) => ({
|
521
|
+
...o,
|
514
522
|
[s]: r.address
|
515
523
|
}),
|
516
524
|
{}
|
@@ -518,72 +526,72 @@ function Ht(t) {
|
|
518
526
|
)
|
519
527
|
});
|
520
528
|
}
|
521
|
-
function
|
529
|
+
function Ne(e) {
|
522
530
|
return u({
|
523
|
-
mutationKey: ["operations", "sign",
|
531
|
+
mutationKey: ["operations", "sign", e],
|
524
532
|
mutationFn: ({
|
525
|
-
operation:
|
533
|
+
operation: t,
|
526
534
|
keyOrSeed: n
|
527
535
|
}) => {
|
528
|
-
if (!
|
536
|
+
if (!e)
|
529
537
|
throw new Error("[Operations][Sign] – cannot sign op with anon user");
|
530
|
-
let
|
531
|
-
return n.split(" ").length === 12 ?
|
532
|
-
[
|
533
|
-
|
538
|
+
let o;
|
539
|
+
return n.split(" ").length === 12 ? o = l.fromLogin(e, n, "active") : E.isWif(n) ? o = l.fromString(n) : o = l.from(n), p.hiveClient.broadcast.sendOperations(
|
540
|
+
[t],
|
541
|
+
o
|
534
542
|
);
|
535
543
|
}
|
536
544
|
});
|
537
545
|
}
|
538
|
-
const
|
546
|
+
const ne = (e, t, n, o = null) => new Promise((s, r) => {
|
539
547
|
var i;
|
540
548
|
(i = window.hive_keychain) == null || i.requestBroadcast(
|
541
|
-
t,
|
542
549
|
e,
|
550
|
+
t,
|
543
551
|
n,
|
544
552
|
(c) => {
|
545
553
|
c.success || r({ message: "Operation cancelled" }), s(c);
|
546
554
|
},
|
547
|
-
|
555
|
+
o
|
548
556
|
);
|
549
557
|
});
|
550
|
-
function
|
558
|
+
function je(e, t = "Active") {
|
551
559
|
return u({
|
552
|
-
mutationKey: ["operations", "sign-keychain",
|
560
|
+
mutationKey: ["operations", "sign-keychain", e],
|
553
561
|
mutationFn: ({ operation: n }) => {
|
554
|
-
if (!
|
562
|
+
if (!e)
|
555
563
|
throw new Error(
|
556
564
|
"[SDK][Keychain] – cannot sign operation with anon user"
|
557
565
|
);
|
558
|
-
return
|
566
|
+
return ne(e, [n], t);
|
559
567
|
}
|
560
568
|
});
|
561
569
|
}
|
562
|
-
function
|
570
|
+
function De(e = "/") {
|
563
571
|
return u({
|
564
|
-
mutationKey: ["operations", "sign-hivesigner",
|
565
|
-
mutationFn: async ({ operation:
|
572
|
+
mutationKey: ["operations", "sign-hivesigner", e],
|
573
|
+
mutationFn: async ({ operation: t }) => b.sendOperation(t, { callback: e }, () => {
|
566
574
|
})
|
567
575
|
});
|
568
576
|
}
|
569
577
|
export {
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
578
|
+
h as EcencyWalletBasicTokens,
|
579
|
+
a as EcencyWalletCurrency,
|
580
|
+
Re as EcencyWalletsPrivateApi,
|
581
|
+
M as delay,
|
582
|
+
Ae as getAccountPointsQueryOptions,
|
575
583
|
T as getWallet,
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
584
|
+
Pe as mnemonicToSeedBip39,
|
585
|
+
te as useAccountUpdate,
|
586
|
+
Oe as useCoinGeckoPriceQuery,
|
587
|
+
ke as useGetAllTokensListQuery,
|
588
|
+
Se as useGetExternalWalletBalanceQuery,
|
589
|
+
J as useHiveKeysQuery,
|
590
|
+
Ce as useImportWallet,
|
591
|
+
He as useSaveWalletInformationToMetadata,
|
592
|
+
P as useSeedPhrase,
|
593
|
+
De as useSignOperationByHivesigner,
|
594
|
+
Ne as useSignOperationByKey,
|
595
|
+
je as useSignOperationByKeychain,
|
596
|
+
Ke as useWalletCreate
|
589
597
|
};
|
@@ -1,2 +1,6 @@
|
|
1
|
-
import { EcencyWalletBasicTokens } from '../enums';
|
2
|
-
export declare function useGetAllTokensListQuery(
|
1
|
+
import { EcencyWalletBasicTokens, EcencyWalletCurrency } from '../enums';
|
2
|
+
export declare function useGetAllTokensListQuery(query: string): {
|
3
|
+
basic: EcencyWalletBasicTokens[];
|
4
|
+
external: EcencyWalletCurrency[];
|
5
|
+
layer2: string[];
|
6
|
+
};
|