@ecency/sdk 1.0.14 → 1.0.15
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 +5 -1
- package/dist/ecency-sdk.es.js +232 -222
- package/package.json +1 -1
package/dist/ecency-sdk.es.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { BaseWallet } from '@okxweb3/coin-base';
|
2
2
|
import { Operation } from '@hiveio/dhive';
|
3
|
+
import { TransactionConfirmation } from '@hiveio/dhive';
|
3
4
|
import { UseMutationResult } from '@tanstack/react-query';
|
4
5
|
import { UseQueryResult } from '@tanstack/react-query';
|
5
6
|
|
@@ -95,7 +96,10 @@ wallets: Map<EcencyWalletCurrency, EcencyCreateWalletInformation>;
|
|
95
96
|
|
96
97
|
export declare function useSeedPhrase(username: string): UseQueryResult<string, Error>;
|
97
98
|
|
98
|
-
export declare function
|
99
|
+
export declare function useSignOperationByKey(username: string | undefined): UseMutationResult<TransactionConfirmation, Error, {
|
100
|
+
operation: Operation;
|
101
|
+
keyOrSeed: string;
|
102
|
+
}, unknown>;
|
99
103
|
|
100
104
|
export declare function useWalletCreate(username: string, currency: EcencyWalletCurrency): {
|
101
105
|
createWallet: UseMutationResult<EcencyCreateWalletInformation, Error, void, unknown>;
|
package/dist/ecency-sdk.es.js
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
import { useCallback as
|
2
|
-
import { useQuery as
|
3
|
-
import { BtcWallet as
|
4
|
-
import { EthWallet as
|
5
|
-
import { TrxWallet as
|
6
|
-
import { TonWallet as
|
7
|
-
import { SolWallet as
|
8
|
-
import { AtomWallet as
|
9
|
-
import { AptosWallet as
|
10
|
-
import
|
11
|
-
import { Client as
|
1
|
+
import { useCallback as A } from "react";
|
2
|
+
import { useQuery as d, useQueryClient as y, useMutation as u } from "@tanstack/react-query";
|
3
|
+
import { BtcWallet as O } from "@okxweb3/coin-bitcoin";
|
4
|
+
import { EthWallet as k } from "@okxweb3/coin-ethereum";
|
5
|
+
import { TrxWallet as R } from "@okxweb3/coin-tron";
|
6
|
+
import { TonWallet as K } from "@okxweb3/coin-ton";
|
7
|
+
import { SolWallet as C } from "@okxweb3/coin-solana";
|
8
|
+
import { AtomWallet as N } from "@okxweb3/coin-cosmos";
|
9
|
+
import { AptosWallet as x } from "@okxweb3/coin-aptos";
|
10
|
+
import j, { mnemonicToSeedSync as D } from "bip39";
|
11
|
+
import { Client as _, PrivateKey as l, cryptoUtils as H } from "@hiveio/dhive";
|
12
12
|
import { LRUCache as E } from "lru-cache";
|
13
13
|
import B from "hivesigner";
|
14
|
-
var
|
15
|
-
function W(
|
16
|
-
return new Promise((
|
14
|
+
var n = /* @__PURE__ */ ((t) => (t.BTC = "BTC", t.ETH = "ETH", t.APT = "APT", t.ATOM = "ATOM", t.TON = "TON", t.TRON = "TRX", t.SOL = "SOL", t))(n || {});
|
15
|
+
function W(t) {
|
16
|
+
return new Promise((e) => setTimeout(e, t));
|
17
17
|
}
|
18
|
-
function g(
|
19
|
-
switch (
|
20
|
-
case
|
21
|
-
return new
|
22
|
-
case
|
18
|
+
function g(t) {
|
19
|
+
switch (t) {
|
20
|
+
case n.BTC:
|
21
|
+
return new O();
|
22
|
+
case n.ETH:
|
23
|
+
return new k();
|
24
|
+
case n.TRON:
|
23
25
|
return new R();
|
24
|
-
case
|
26
|
+
case n.TON:
|
25
27
|
return new K();
|
26
|
-
case
|
28
|
+
case n.SOL:
|
27
29
|
return new C();
|
28
|
-
case
|
30
|
+
case n.ATOM:
|
29
31
|
return new N();
|
30
|
-
case
|
32
|
+
case n.APT:
|
31
33
|
return new x();
|
32
|
-
case o.APT:
|
33
|
-
return new j();
|
34
34
|
default:
|
35
35
|
return;
|
36
36
|
}
|
37
37
|
}
|
38
|
-
function
|
39
|
-
return
|
38
|
+
function yt(t) {
|
39
|
+
return D(t).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 _(
|
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
|
68
|
-
return
|
69
|
-
queryKey: ["ecency-wallets", "external-wallet-balance",
|
67
|
+
function gt(t, e) {
|
68
|
+
return d({
|
69
|
+
queryKey: ["ecency-wallets", "external-wallet-balance", t, e],
|
70
70
|
queryFn: async () => {
|
71
|
-
switch (
|
72
|
-
case
|
73
|
-
const
|
74
|
-
`https://mempool.space/api/address/${
|
71
|
+
switch (t) {
|
72
|
+
case n.BTC:
|
73
|
+
const a = await (await fetch(
|
74
|
+
`https://mempool.space/api/address/${e}`
|
75
75
|
)).json();
|
76
|
-
return (
|
77
|
-
case
|
76
|
+
return (a.chain_stats.funded_txo_sum - a.chain_stats.spent_txo_sum) / 1e8;
|
77
|
+
case n.ETH:
|
78
78
|
return +(await (await fetch(
|
79
|
-
`https://api.ethplorer.io/getAddressInfo/${
|
79
|
+
`https://api.ethplorer.io/getAddressInfo/${e}?apiKey=freekey`
|
80
80
|
)).json()).ETH.balance;
|
81
|
-
case
|
81
|
+
case n.SOL:
|
82
82
|
return (await (await fetch(
|
83
83
|
`https://rpc.helius.xyz/?api-key=${p.heliusApiKey}`,
|
84
84
|
{
|
@@ -87,40 +87,40 @@ function fe(e, t) {
|
|
87
87
|
jsonrpc: "2.0",
|
88
88
|
id: "1",
|
89
89
|
method: "getBalance",
|
90
|
-
params: [
|
90
|
+
params: [e]
|
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 n.TRON:
|
98
98
|
return (await (await fetch(
|
99
|
-
`https://api.trongrid.io/v1/accounts/${
|
99
|
+
`https://api.trongrid.io/v1/accounts/${e}`
|
100
100
|
)).json()).data[0].balance / 1e6;
|
101
|
-
case
|
101
|
+
case n.TON:
|
102
102
|
return (await (await fetch(
|
103
|
-
`https://tonapi.io/v1/blockchain/getAccount?account=${
|
103
|
+
`https://tonapi.io/v1/blockchain/getAccount?account=${e}`
|
104
104
|
)).json()).balance / 1e9;
|
105
|
-
case
|
106
|
-
const
|
107
|
-
`https://fullnode.mainnet.aptoslabs.com/v1/accounts/${
|
105
|
+
case n.APT:
|
106
|
+
const w = (await (await fetch(
|
107
|
+
`https://fullnode.mainnet.aptoslabs.com/v1/accounts/${e}/resources`
|
108
108
|
)).json()).find(
|
109
|
-
(
|
109
|
+
(S) => S.type.includes("coin::CoinStore")
|
110
110
|
);
|
111
|
-
return
|
112
|
-
case
|
111
|
+
return w ? parseInt(w.data.coin.value) / 1e8 : 0;
|
112
|
+
case n.ATOM:
|
113
113
|
return +(await (await fetch(
|
114
|
-
`https://rest.cosmos.directory/cosmoshub/auth/accounts/${
|
114
|
+
`https://rest.cosmos.directory/cosmoshub/auth/accounts/${e}`
|
115
115
|
)).json()).result.value.coins[0].amount / 1e6;
|
116
116
|
}
|
117
117
|
}
|
118
118
|
});
|
119
119
|
}
|
120
|
-
function T(
|
121
|
-
return
|
122
|
-
queryKey: ["ecency-wallets", "seed",
|
123
|
-
queryFn: async () =>
|
120
|
+
function T(t) {
|
121
|
+
return d({
|
122
|
+
queryKey: ["ecency-wallets", "seed", t],
|
123
|
+
queryFn: async () => j.generateMnemonic(128)
|
124
124
|
});
|
125
125
|
}
|
126
126
|
const F = {
|
@@ -131,34 +131,34 @@ const F = {
|
|
131
131
|
allowStale: !1,
|
132
132
|
updateAgeOnGet: !1,
|
133
133
|
updateAgeOnHas: !1
|
134
|
-
}, b = new E(F),
|
135
|
-
const
|
136
|
-
return
|
134
|
+
}, b = new E(F), f = Symbol("undefined"), L = (t, e) => b.set(t, e === void 0 ? f : e), M = (t) => {
|
135
|
+
const e = b.get(t);
|
136
|
+
return e === f ? void 0 : e;
|
137
137
|
};
|
138
|
-
function
|
139
|
-
return
|
140
|
-
queryKey: ["ecency-wallets", "coingecko-price",
|
138
|
+
function Tt(t) {
|
139
|
+
return d({
|
140
|
+
queryKey: ["ecency-wallets", "coingecko-price", t],
|
141
141
|
queryFn: async () => {
|
142
|
-
let
|
143
|
-
switch (
|
144
|
-
case
|
145
|
-
|
142
|
+
let e = t;
|
143
|
+
switch (t) {
|
144
|
+
case n.BTC:
|
145
|
+
e = "binance-wrapped-btc";
|
146
146
|
break;
|
147
|
-
case
|
148
|
-
|
147
|
+
case n.ETH:
|
148
|
+
e = "ethereum";
|
149
149
|
break;
|
150
|
-
case
|
151
|
-
|
150
|
+
case n.SOL:
|
151
|
+
e = "solana";
|
152
152
|
break;
|
153
|
-
case
|
154
|
-
|
153
|
+
case n.TON:
|
154
|
+
e = "trx";
|
155
155
|
break;
|
156
156
|
default:
|
157
|
-
|
157
|
+
e = t;
|
158
158
|
}
|
159
|
-
let
|
160
|
-
if (
|
161
|
-
|
159
|
+
let o = M("gecko"), a;
|
160
|
+
if (o)
|
161
|
+
a = o;
|
162
162
|
else {
|
163
163
|
const r = await (await fetch(
|
164
164
|
"https://api.coingecko.com/api/v3/simple/price",
|
@@ -166,113 +166,113 @@ function ge(e) {
|
|
166
166
|
method: "POST",
|
167
167
|
body: JSON.stringify({
|
168
168
|
params: {
|
169
|
-
ids: [
|
169
|
+
ids: [e],
|
170
170
|
vs_currencies: "usd"
|
171
171
|
}
|
172
172
|
})
|
173
173
|
}
|
174
174
|
)).json();
|
175
|
-
|
175
|
+
L("gecko", r === void 0 ? f : r), a = r;
|
176
176
|
}
|
177
|
-
return 1 / +
|
177
|
+
return 1 / +a[Object.keys(a)[0]].usd;
|
178
178
|
},
|
179
|
-
enabled: !!
|
179
|
+
enabled: !!t
|
180
180
|
});
|
181
181
|
}
|
182
|
-
function q(
|
183
|
-
const { data:
|
184
|
-
return
|
185
|
-
queryKey: ["ecencу-wallets", "hive-keys",
|
182
|
+
function q(t) {
|
183
|
+
const { data: e } = T(t);
|
184
|
+
return d({
|
185
|
+
queryKey: ["ecencу-wallets", "hive-keys", t, e],
|
186
186
|
queryFn: async () => {
|
187
|
-
if (!
|
187
|
+
if (!e)
|
188
188
|
throw new Error("[Ecency][Wallets] - no seed to create Hive account");
|
189
|
-
const
|
189
|
+
const o = l.fromLogin(t, e, "owner"), a = l.fromLogin(t, e, "active"), s = l.fromLogin(t, e, "posting"), i = l.fromLogin(t, e, "memo");
|
190
190
|
return {
|
191
|
-
username:
|
192
|
-
owner:
|
193
|
-
active:
|
194
|
-
posting:
|
191
|
+
username: t,
|
192
|
+
owner: o.toString(),
|
193
|
+
active: a.toString(),
|
194
|
+
posting: s.toString(),
|
195
195
|
memo: i.toString(),
|
196
|
-
ownerPubkey:
|
197
|
-
activePubkey:
|
198
|
-
postingPubkey:
|
196
|
+
ownerPubkey: o.createPublic().toString(),
|
197
|
+
activePubkey: a.createPublic().toString(),
|
198
|
+
postingPubkey: s.createPublic().toString(),
|
199
199
|
memoPubkey: i.createPublic().toString()
|
200
200
|
};
|
201
201
|
}
|
202
202
|
});
|
203
203
|
}
|
204
204
|
const I = {
|
205
|
-
[
|
205
|
+
[n.BTC]: "m/44'/0'/0'/0/0",
|
206
206
|
// Bitcoin (BIP44)
|
207
|
-
[
|
207
|
+
[n.ETH]: "m/44'/60'/0'/0/0",
|
208
208
|
// Ethereum (BIP44)
|
209
|
-
[
|
209
|
+
[n.SOL]: "m/44'/501'/0'/0'",
|
210
210
|
// Solana (BIP44)
|
211
|
-
[
|
211
|
+
[n.TON]: "m/44'/607'/0'",
|
212
212
|
// TON (BIP44)
|
213
|
-
[
|
213
|
+
[n.TRON]: "m/44'/195'/0'/0/0",
|
214
214
|
// Tron (BIP44)
|
215
|
-
[
|
215
|
+
[n.APT]: "m/44'/637'/0'/0'/0'",
|
216
216
|
// Aptos (BIP44)
|
217
|
-
[
|
217
|
+
[n.ATOM]: "m/44'/118'/0'/0/0"
|
218
218
|
// Cosmos (BIP44)
|
219
219
|
};
|
220
|
-
function
|
221
|
-
const { data:
|
222
|
-
mutationKey: ["ecency-wallets", "create-wallet",
|
220
|
+
function bt(t, e) {
|
221
|
+
const { data: o } = T(t), a = y(), s = u({
|
222
|
+
mutationKey: ["ecency-wallets", "create-wallet", t, e],
|
223
223
|
mutationFn: async () => {
|
224
|
-
if (!
|
224
|
+
if (!o)
|
225
225
|
throw new Error("[Ecency][Wallets] - No seed to create a wallet");
|
226
|
-
const r = g(
|
227
|
-
mnemonic:
|
228
|
-
hdPath: I[
|
226
|
+
const r = g(e), c = await (r == null ? void 0 : r.getDerivedPrivateKey({
|
227
|
+
mnemonic: o,
|
228
|
+
hdPath: I[e]
|
229
229
|
}));
|
230
230
|
await W(1e3);
|
231
|
-
const
|
231
|
+
const m = await (r == null ? void 0 : r.getNewAddress({
|
232
232
|
privateKey: c
|
233
233
|
}));
|
234
234
|
return {
|
235
235
|
privateKey: c,
|
236
|
-
address:
|
237
|
-
publicKey:
|
238
|
-
username:
|
239
|
-
currency:
|
236
|
+
address: m.address,
|
237
|
+
publicKey: m.publicKey,
|
238
|
+
username: t,
|
239
|
+
currency: e
|
240
240
|
};
|
241
241
|
},
|
242
242
|
onSuccess: (r) => {
|
243
|
-
|
243
|
+
a.setQueryData(
|
244
244
|
["ecency-wallets", "wallets", r.username],
|
245
245
|
(c) => new Map(c ? Array.from(c.entries()) : []).set(r.currency, r)
|
246
246
|
);
|
247
247
|
}
|
248
|
-
}), i =
|
248
|
+
}), i = A(() => {
|
249
249
|
}, []);
|
250
250
|
return {
|
251
|
-
createWallet:
|
251
|
+
createWallet: s,
|
252
252
|
importWallet: i
|
253
253
|
};
|
254
254
|
}
|
255
|
-
function J(
|
256
|
-
const { data:
|
257
|
-
queryKey: ["ecency-wallets", "wallets",
|
258
|
-
}), { data:
|
255
|
+
function J(t) {
|
256
|
+
const { data: e } = d({
|
257
|
+
queryKey: ["ecency-wallets", "wallets", t]
|
258
|
+
}), { data: o } = q(t);
|
259
259
|
return u({
|
260
|
-
mutationKey: ["ecency-wallets", "create-account-with-wallets",
|
261
|
-
mutationFn: ({ currency:
|
260
|
+
mutationKey: ["ecency-wallets", "create-account-with-wallets", t],
|
261
|
+
mutationFn: ({ currency: a, address: s }) => fetch(p.privateApiHost + "/private-api/wallets-add", {
|
262
262
|
method: "POST",
|
263
263
|
headers: {
|
264
264
|
"Content-Type": "application/json"
|
265
265
|
},
|
266
266
|
body: JSON.stringify({
|
267
|
-
username:
|
268
|
-
token:
|
269
|
-
address:
|
267
|
+
username: t,
|
268
|
+
token: a,
|
269
|
+
address: s,
|
270
270
|
meta: {
|
271
|
-
ownerPublicKey:
|
272
|
-
activePublicKey:
|
273
|
-
postingPublicKey:
|
274
|
-
memoPublicKey:
|
275
|
-
...Array.from((
|
271
|
+
ownerPublicKey: o == null ? void 0 : o.ownerPubkey,
|
272
|
+
activePublicKey: o == null ? void 0 : o.activePubkey,
|
273
|
+
postingPublicKey: o == null ? void 0 : o.postingPubkey,
|
274
|
+
memoPublicKey: o == null ? void 0 : o.memoPubkey,
|
275
|
+
...Array.from((e == null ? void 0 : e.entries()) ?? []).reduce(
|
276
276
|
(i, [r, c]) => ({
|
277
277
|
...i,
|
278
278
|
[r]: c.address
|
@@ -287,7 +287,7 @@ function J(e) {
|
|
287
287
|
function v() {
|
288
288
|
return u({
|
289
289
|
mutationKey: ["ecency-wallets", "check-wallet-existence"],
|
290
|
-
mutationFn: async ({ address:
|
290
|
+
mutationFn: async ({ address: t, currency: e }) => (await (await fetch(
|
291
291
|
p.privateApiHost + "/private-api/wallets-exist",
|
292
292
|
{
|
293
293
|
method: "POST",
|
@@ -295,147 +295,147 @@ function v() {
|
|
295
295
|
"Content-Type": "application/json"
|
296
296
|
},
|
297
297
|
body: JSON.stringify({
|
298
|
-
address:
|
299
|
-
token:
|
298
|
+
address: t,
|
299
|
+
token: e
|
300
300
|
})
|
301
301
|
}
|
302
302
|
)).json()).length === 0
|
303
303
|
});
|
304
304
|
}
|
305
|
-
const
|
305
|
+
const vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
306
306
|
__proto__: null,
|
307
307
|
useCheckWalletExistence: v,
|
308
308
|
useCreateAccountWithWallets: J
|
309
309
|
}, Symbol.toStringTag, { value: "Module" })), Q = {
|
310
|
-
[
|
311
|
-
[
|
310
|
+
[n.BTC]: ["m/84'/0'/0'/0/0"],
|
311
|
+
[n.ETH]: ["m/84'/60'/0'/0/0"],
|
312
312
|
// its not working for Trust, Exodus, todo: check others below
|
313
|
-
[
|
314
|
-
[
|
315
|
-
[
|
316
|
-
[
|
313
|
+
[n.SOL]: ["m/84'/501'/0'/0/0"],
|
314
|
+
[n.TRON]: ["m/44'/195'/0'/0'/0'"],
|
315
|
+
[n.APT]: ["m/84'/637'/0'/0/0"],
|
316
|
+
[n.TON]: [],
|
317
317
|
// Disabled
|
318
|
-
[
|
318
|
+
[n.ATOM]: ["m/84'/118'/0'/0'/0"]
|
319
319
|
};
|
320
|
-
async function $(
|
321
|
-
for (const
|
320
|
+
async function $(t, e, o) {
|
321
|
+
for (const a of Q[o] || [])
|
322
322
|
try {
|
323
|
-
const
|
324
|
-
mnemonic:
|
325
|
-
hdPath:
|
326
|
-
}), i = await
|
327
|
-
privateKey:
|
328
|
-
addressType:
|
323
|
+
const s = await e.getDerivedPrivateKey({
|
324
|
+
mnemonic: t,
|
325
|
+
hdPath: a
|
326
|
+
}), i = await e.getNewAddress({
|
327
|
+
privateKey: s,
|
328
|
+
addressType: o === n.BTC ? "segwit_native" : void 0
|
329
329
|
});
|
330
|
-
return [
|
330
|
+
return [s.toString(), i.address];
|
331
331
|
} catch {
|
332
332
|
return [];
|
333
333
|
}
|
334
334
|
return [];
|
335
335
|
}
|
336
|
-
function
|
337
|
-
const
|
336
|
+
function Pt(t, e) {
|
337
|
+
const o = y(), { mutateAsync: a } = v();
|
338
338
|
return u({
|
339
|
-
mutationKey: ["ecency-wallets", "import-wallet",
|
340
|
-
mutationFn: async ({ privateKeyOrSeed:
|
341
|
-
const i = g(
|
339
|
+
mutationKey: ["ecency-wallets", "import-wallet", t, e],
|
340
|
+
mutationFn: async ({ privateKeyOrSeed: s }) => {
|
341
|
+
const i = g(e);
|
342
342
|
if (!i)
|
343
343
|
throw new Error("Cannot find token for this currency");
|
344
|
-
const r =
|
345
|
-
let c,
|
346
|
-
if (r ? [
|
347
|
-
|
344
|
+
const r = s.split(" ").length === 12;
|
345
|
+
let c, m = s;
|
346
|
+
if (r ? [m, c] = await $(
|
347
|
+
s,
|
348
348
|
i,
|
349
|
-
|
349
|
+
e
|
350
350
|
) : c = (await i.getNewAddress({
|
351
|
-
privateKey:
|
352
|
-
})).address, !c || !
|
351
|
+
privateKey: s
|
352
|
+
})).address, !c || !s)
|
353
353
|
throw new Error(
|
354
354
|
"Private key/seed phrase isn't matching with public key or token"
|
355
355
|
);
|
356
|
-
if (!await
|
356
|
+
if (!await a({
|
357
357
|
address: c,
|
358
|
-
currency:
|
358
|
+
currency: e
|
359
359
|
}))
|
360
360
|
throw new Error(
|
361
361
|
"This wallet has already in use by Hive account. Please, try another one"
|
362
362
|
);
|
363
363
|
return {
|
364
|
-
privateKey:
|
364
|
+
privateKey: m,
|
365
365
|
address: c,
|
366
366
|
publicKey: ""
|
367
367
|
};
|
368
368
|
},
|
369
|
-
onSuccess: ({ privateKey:
|
370
|
-
|
371
|
-
["ecency-wallets", "wallets",
|
372
|
-
(c) => new Map(c ? Array.from(c.entries()) : []).set(
|
373
|
-
privateKey:
|
369
|
+
onSuccess: ({ privateKey: s, publicKey: i, address: r }) => {
|
370
|
+
o.setQueryData(
|
371
|
+
["ecency-wallets", "wallets", t],
|
372
|
+
(c) => new Map(c ? Array.from(c.entries()) : []).set(e, {
|
373
|
+
privateKey: s,
|
374
374
|
publicKey: i,
|
375
375
|
address: r,
|
376
|
-
username:
|
377
|
-
currency:
|
376
|
+
username: t,
|
377
|
+
currency: e,
|
378
378
|
custom: !0
|
379
379
|
})
|
380
380
|
);
|
381
381
|
}
|
382
382
|
});
|
383
383
|
}
|
384
|
-
function G(
|
385
|
-
let
|
386
|
-
if (
|
387
|
-
return JSON.parse(
|
384
|
+
function G(t) {
|
385
|
+
let e = atob(t);
|
386
|
+
if (e[0] === "{")
|
387
|
+
return JSON.parse(e);
|
388
388
|
}
|
389
|
-
const h = (
|
389
|
+
const h = (t) => {
|
390
390
|
try {
|
391
|
-
const
|
392
|
-
p.storagePrefix + "_user_" +
|
391
|
+
const e = p.storage.getItem(
|
392
|
+
p.storagePrefix + "_user_" + t
|
393
393
|
);
|
394
|
-
return G(JSON.parse(
|
395
|
-
} catch (
|
396
|
-
console.error(
|
394
|
+
return G(JSON.parse(e));
|
395
|
+
} catch (e) {
|
396
|
+
console.error(e);
|
397
397
|
return;
|
398
398
|
}
|
399
|
-
}, U = (
|
400
|
-
function
|
399
|
+
}, U = (t) => h(t) && h(t).accessToken, V = (t) => h(t) && h(t).postingKey;
|
400
|
+
function z(t = [], e, o) {
|
401
401
|
return u({
|
402
|
-
mutationKey: [...
|
403
|
-
mutationFn: async (
|
404
|
-
if (!
|
402
|
+
mutationKey: [...t, e],
|
403
|
+
mutationFn: async (a) => {
|
404
|
+
if (!e)
|
405
405
|
throw new Error(
|
406
406
|
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
407
407
|
);
|
408
|
-
const
|
409
|
-
if (
|
410
|
-
const r =
|
408
|
+
const s = V(e);
|
409
|
+
if (s) {
|
410
|
+
const r = l.fromString(s);
|
411
411
|
return p.hiveClient.broadcast.sendOperations(
|
412
|
-
|
412
|
+
o(a),
|
413
413
|
r
|
414
414
|
);
|
415
415
|
}
|
416
|
-
let i = U(
|
416
|
+
let i = U(e);
|
417
417
|
if (i)
|
418
418
|
return (await new B.Client({
|
419
419
|
accessToken: i
|
420
|
-
}).broadcast(
|
420
|
+
}).broadcast(o(a))).result;
|
421
421
|
throw new Error(
|
422
422
|
"[SDK][Broadcast] – cannot broadcast w/o posting key or token"
|
423
423
|
);
|
424
424
|
}
|
425
425
|
});
|
426
426
|
}
|
427
|
-
function
|
428
|
-
return
|
427
|
+
function X(t) {
|
428
|
+
return z(
|
429
429
|
["accounts", "update"],
|
430
|
-
|
431
|
-
(
|
430
|
+
t,
|
431
|
+
(e) => [
|
432
432
|
[
|
433
433
|
"account_update2",
|
434
434
|
{
|
435
|
-
account:
|
435
|
+
account: t,
|
436
436
|
json_metadata: "",
|
437
437
|
posting_json_metadata: JSON.stringify({
|
438
|
-
profile: { ...
|
438
|
+
profile: { ...e, version: 2 }
|
439
439
|
}),
|
440
440
|
extensions: []
|
441
441
|
}
|
@@ -443,43 +443,53 @@ function z(e) {
|
|
443
443
|
]
|
444
444
|
);
|
445
445
|
}
|
446
|
-
function
|
447
|
-
const { mutateAsync:
|
446
|
+
function St(t) {
|
447
|
+
const { mutateAsync: e } = X(t);
|
448
448
|
return u({
|
449
|
-
mutationKey: ["ecency-wallets", "save-wallet-to-metadata",
|
449
|
+
mutationKey: ["ecency-wallets", "save-wallet-to-metadata", t],
|
450
450
|
mutationFn: ({
|
451
|
-
wallets:
|
452
|
-
}) =>
|
453
|
-
Array.from(
|
454
|
-
(
|
455
|
-
...
|
456
|
-
[
|
451
|
+
wallets: o
|
452
|
+
}) => e(
|
453
|
+
Array.from(o.entries() ?? []).reduce(
|
454
|
+
(a, [s, i]) => ({
|
455
|
+
...a,
|
456
|
+
[s]: i.address
|
457
457
|
}),
|
458
458
|
{}
|
459
459
|
)
|
460
460
|
)
|
461
461
|
});
|
462
462
|
}
|
463
|
-
function
|
464
|
-
return
|
465
|
-
["operations", "sign"],
|
466
|
-
|
467
|
-
|
468
|
-
|
463
|
+
function At(t) {
|
464
|
+
return u({
|
465
|
+
mutationKey: ["operations", "sign", t],
|
466
|
+
mutationFn: ({
|
467
|
+
operation: e,
|
468
|
+
keyOrSeed: o
|
469
|
+
}) => {
|
470
|
+
if (!t)
|
471
|
+
throw new Error("[Operations][Sign] – cannot sign op with anon user");
|
472
|
+
let a;
|
473
|
+
return o.split(" ").length === 12 ? a = l.fromLogin(t, o, "active") : H.isWif(o) ? a = l.fromString(o) : a = l.from(o), p.hiveClient.broadcast.sendOperations(
|
474
|
+
[e],
|
475
|
+
a
|
476
|
+
);
|
477
|
+
}
|
478
|
+
});
|
469
479
|
}
|
470
480
|
export {
|
471
|
-
|
472
|
-
|
481
|
+
n as EcencyWalletCurrency,
|
482
|
+
vt as EcencyWalletsPrivateApi,
|
473
483
|
W as delay,
|
474
484
|
g as getWallet,
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
485
|
+
yt as mnemonicToSeedBip39,
|
486
|
+
X as useAccountUpdate,
|
487
|
+
Tt as useCoinGeckoPriceQuery,
|
488
|
+
gt as useGetExternalWalletBalanceQuery,
|
479
489
|
q as useHiveKeysQuery,
|
480
|
-
|
481
|
-
|
490
|
+
Pt as useImportWallet,
|
491
|
+
St as useSaveWalletInformationToMetadata,
|
482
492
|
T as useSeedPhrase,
|
483
|
-
|
484
|
-
|
493
|
+
At as useSignOperationByKey,
|
494
|
+
bt as useWalletCreate
|
485
495
|
};
|