@ecency/wallets 1.0.14 → 1.0.17
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.d.ts +3 -3
- package/dist/ecency-wallets.es.js +37 -37
- package/package.json +1 -1
|
@@ -29,11 +29,11 @@ export declare interface EcencyHiveKeys {
|
|
|
29
29
|
export declare enum EcencyWalletCurrency {
|
|
30
30
|
BTC = "btc",
|
|
31
31
|
ETH = "eth",
|
|
32
|
-
APT = "
|
|
32
|
+
APT = "aptos",
|
|
33
33
|
ATOM = "cosmos",
|
|
34
34
|
TON = "ton",
|
|
35
35
|
TRON = "tron",
|
|
36
|
-
SOL = "
|
|
36
|
+
SOL = "solana"
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
declare namespace EcencyWalletsPrivateApi {
|
|
@@ -79,7 +79,7 @@ address: string;
|
|
|
79
79
|
publicKey: string;
|
|
80
80
|
}, Error, Payload_2, unknown>;
|
|
81
81
|
|
|
82
|
-
export declare function useSeedPhrase(): UseQueryResult<string, Error>;
|
|
82
|
+
export declare function useSeedPhrase(username: string): UseQueryResult<string, Error>;
|
|
83
83
|
|
|
84
84
|
export declare function useWalletCreate(username: string, currency: EcencyWalletCurrency): {
|
|
85
85
|
createWallet: UseMutationResult<EcencyCreateWalletInformation, Error, void, unknown>;
|
|
@@ -10,7 +10,7 @@ import { AptosWallet as D } from "@okxweb3/coin-aptos";
|
|
|
10
10
|
import K, { mnemonicToSeedSync as _ } from "bip39";
|
|
11
11
|
import { LRUCache as H } from "lru-cache";
|
|
12
12
|
import { PrivateKey as u } from "@hiveio/dhive";
|
|
13
|
-
var o = /* @__PURE__ */ ((e) => (e.BTC = "btc", e.ETH = "eth", e.APT = "
|
|
13
|
+
var o = /* @__PURE__ */ ((e) => (e.BTC = "btc", e.ETH = "eth", e.APT = "aptos", e.ATOM = "cosmos", e.TON = "ton", e.TRON = "tron", e.SOL = "solana", e))(o || {});
|
|
14
14
|
function j(e) {
|
|
15
15
|
return new Promise((t) => setTimeout(t, e));
|
|
16
16
|
}
|
|
@@ -34,7 +34,7 @@ function T(e) {
|
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function re(e) {
|
|
38
38
|
return _(e).toString("hex");
|
|
39
39
|
}
|
|
40
40
|
function ce(e, t) {
|
|
@@ -93,9 +93,9 @@ function ce(e, t) {
|
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
function b() {
|
|
96
|
+
function b(e) {
|
|
97
97
|
return p({
|
|
98
|
-
queryKey: ["ecency-wallets", "seed"],
|
|
98
|
+
queryKey: ["ecency-wallets", "seed", e],
|
|
99
99
|
queryFn: async () => K.generateMnemonic(128)
|
|
100
100
|
});
|
|
101
101
|
}
|
|
@@ -156,23 +156,23 @@ function le(e) {
|
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
function L(e) {
|
|
159
|
-
const { data: t } = b();
|
|
159
|
+
const { data: t } = b(e);
|
|
160
160
|
return p({
|
|
161
161
|
queryKey: ["ecencу-wallets", "hive-keys", e, t],
|
|
162
162
|
queryFn: async () => {
|
|
163
163
|
if (!t)
|
|
164
164
|
throw new Error("[Ecency][Wallets] - no seed to create Hive account");
|
|
165
|
-
const n = u.fromLogin(e, t, "owner"), a = u.fromLogin(e, t, "active"),
|
|
165
|
+
const n = u.fromLogin(e, t, "owner"), a = u.fromLogin(e, t, "active"), r = u.fromLogin(e, t, "posting"), i = u.fromLogin(e, t, "memo");
|
|
166
166
|
return {
|
|
167
167
|
username: e,
|
|
168
168
|
owner: n.toString(),
|
|
169
169
|
active: a.toString(),
|
|
170
|
-
posting:
|
|
171
|
-
memo:
|
|
170
|
+
posting: r.toString(),
|
|
171
|
+
memo: i.toString(),
|
|
172
172
|
ownerPubkey: n.createPublic().toString(),
|
|
173
173
|
activePubkey: a.createPublic().toString(),
|
|
174
|
-
postingPubkey:
|
|
175
|
-
memoPubkey:
|
|
174
|
+
postingPubkey: r.createPublic().toString(),
|
|
175
|
+
memoPubkey: i.createPublic().toString()
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
178
|
});
|
|
@@ -182,19 +182,19 @@ const W = {
|
|
|
182
182
|
// Bitcoin (BIP44)
|
|
183
183
|
[o.ETH]: "m/44'/60'/0'/0/0",
|
|
184
184
|
// Ethereum (BIP44)
|
|
185
|
-
[o.SOL]: "m/44'/501'/0'/0
|
|
185
|
+
[o.SOL]: "m/44'/501'/0'/0'",
|
|
186
186
|
// Solana (BIP44)
|
|
187
187
|
[o.TON]: "m/44'/396'/0'/0/0",
|
|
188
188
|
// TON (BIP44)
|
|
189
189
|
[o.TRON]: "m/44'/195'/0'/0/0",
|
|
190
190
|
// Tron (BIP44)
|
|
191
|
-
[o.APT]: "m/44'/637'/0'/0/0",
|
|
191
|
+
[o.APT]: "m/44'/637'/0'/0'/0'",
|
|
192
192
|
// Aptos (BIP44)
|
|
193
193
|
[o.ATOM]: "m/44'/118'/0'/0/0"
|
|
194
194
|
// Cosmos (BIP44)
|
|
195
195
|
};
|
|
196
196
|
function pe(e, t) {
|
|
197
|
-
const { data: n } = b(), a = h(),
|
|
197
|
+
const { data: n } = b(e), a = h(), r = m({
|
|
198
198
|
mutationKey: ["ecency-wallets", "create-wallet", e, t],
|
|
199
199
|
mutationFn: async () => {
|
|
200
200
|
if (!n)
|
|
@@ -221,11 +221,11 @@ function pe(e, t) {
|
|
|
221
221
|
(c) => new Map(c ? Array.from(c.entries()) : []).set(s.currency, s)
|
|
222
222
|
);
|
|
223
223
|
}
|
|
224
|
-
}),
|
|
224
|
+
}), i = P(() => {
|
|
225
225
|
}, []);
|
|
226
226
|
return {
|
|
227
|
-
createWallet:
|
|
228
|
-
importWallet:
|
|
227
|
+
createWallet: r,
|
|
228
|
+
importWallet: i
|
|
229
229
|
};
|
|
230
230
|
}
|
|
231
231
|
const q = { privateApiHost: "https://ecency.com" };
|
|
@@ -235,7 +235,7 @@ function M(e) {
|
|
|
235
235
|
}), { data: n } = L(e);
|
|
236
236
|
return m({
|
|
237
237
|
mutationKey: ["ecency-wallets", "create-account-with-wallets", e],
|
|
238
|
-
mutationFn: ({ currency: a, address:
|
|
238
|
+
mutationFn: ({ currency: a, address: r }) => fetch(q.privateApiHost + "/private-api/wallets-add", {
|
|
239
239
|
method: "POST",
|
|
240
240
|
headers: {
|
|
241
241
|
"Content-Type": "application/json"
|
|
@@ -243,15 +243,15 @@ function M(e) {
|
|
|
243
243
|
body: JSON.stringify({
|
|
244
244
|
username: e,
|
|
245
245
|
token: a,
|
|
246
|
-
address:
|
|
246
|
+
address: r,
|
|
247
247
|
meta: {
|
|
248
248
|
ownerPublicKey: n == null ? void 0 : n.ownerPubkey,
|
|
249
249
|
activePublicKey: n == null ? void 0 : n.activePubkey,
|
|
250
250
|
postingPublicKey: n == null ? void 0 : n.postingPubkey,
|
|
251
251
|
memoPublicKey: n == null ? void 0 : n.memoPubkey,
|
|
252
252
|
...Array.from((t == null ? void 0 : t.entries()) ?? []).reduce(
|
|
253
|
-
(
|
|
254
|
-
...
|
|
253
|
+
(i, [s, c]) => ({
|
|
254
|
+
...i,
|
|
255
255
|
[s]: c.address
|
|
256
256
|
}),
|
|
257
257
|
{}
|
|
@@ -292,18 +292,18 @@ const ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
292
292
|
[o.ATOM]: [void 0]
|
|
293
293
|
};
|
|
294
294
|
async function Q(e, t, n, a) {
|
|
295
|
-
for (const
|
|
295
|
+
for (const r of x[a] || [])
|
|
296
296
|
try {
|
|
297
|
-
const
|
|
297
|
+
const i = await n.getDerivedPrivateKey({
|
|
298
298
|
mnemonic: e,
|
|
299
|
-
hdPath:
|
|
299
|
+
hdPath: r
|
|
300
300
|
});
|
|
301
301
|
for (const s of F[a])
|
|
302
302
|
if ((await n.getNewAddress({
|
|
303
|
-
privateKey:
|
|
303
|
+
privateKey: i,
|
|
304
304
|
addressType: s
|
|
305
305
|
})).address === t)
|
|
306
|
-
return
|
|
306
|
+
return i;
|
|
307
307
|
} catch {
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
@@ -312,26 +312,26 @@ function me(e, t) {
|
|
|
312
312
|
const n = h();
|
|
313
313
|
return m({
|
|
314
314
|
mutationKey: ["ecency-wallets", "import-wallet", e, t],
|
|
315
|
-
mutationFn: async ({ privateKeyOrSeed: a, address:
|
|
316
|
-
const
|
|
317
|
-
if (!
|
|
315
|
+
mutationFn: async ({ privateKeyOrSeed: a, address: r }) => {
|
|
316
|
+
const i = T(t);
|
|
317
|
+
if (!i)
|
|
318
318
|
throw new Error("Cannot find token for this currency");
|
|
319
319
|
const s = a.split(" ").length === 12;
|
|
320
320
|
let c = !1, l = a;
|
|
321
321
|
if (s)
|
|
322
322
|
l = await Q(
|
|
323
323
|
a,
|
|
324
|
-
i,
|
|
325
324
|
r,
|
|
325
|
+
i,
|
|
326
326
|
t
|
|
327
327
|
), c = !!l;
|
|
328
328
|
else {
|
|
329
|
-
const w = await
|
|
329
|
+
const w = await i.getNewAddress({
|
|
330
330
|
privateKey: a
|
|
331
|
-
}), f = await
|
|
331
|
+
}), f = await i.validPrivateKey({
|
|
332
332
|
privateKey: a
|
|
333
333
|
});
|
|
334
|
-
c = w.address ===
|
|
334
|
+
c = w.address === r && f.isValid;
|
|
335
335
|
}
|
|
336
336
|
if (!c)
|
|
337
337
|
throw new Error(
|
|
@@ -339,17 +339,17 @@ function me(e, t) {
|
|
|
339
339
|
);
|
|
340
340
|
return {
|
|
341
341
|
privateKey: l,
|
|
342
|
-
address:
|
|
342
|
+
address: r,
|
|
343
343
|
publicKey: ""
|
|
344
344
|
};
|
|
345
345
|
},
|
|
346
|
-
onSuccess: ({ privateKey: a, publicKey:
|
|
346
|
+
onSuccess: ({ privateKey: a, publicKey: r, address: i }) => {
|
|
347
347
|
n.setQueryData(
|
|
348
348
|
["ecency-wallets", "wallets", e],
|
|
349
349
|
(s) => new Map(s ? Array.from(s.entries()) : []).set(t, {
|
|
350
350
|
privateKey: a,
|
|
351
|
-
publicKey:
|
|
352
|
-
address:
|
|
351
|
+
publicKey: r,
|
|
352
|
+
address: i,
|
|
353
353
|
username: e,
|
|
354
354
|
currency: t,
|
|
355
355
|
custom: !0
|
|
@@ -363,7 +363,7 @@ export {
|
|
|
363
363
|
ue as EcencyWalletsPrivateApi,
|
|
364
364
|
j as delay,
|
|
365
365
|
T as getWallet,
|
|
366
|
-
|
|
366
|
+
re as mnemonicToSeedBip39,
|
|
367
367
|
le as useCoinGeckoPriceQuery,
|
|
368
368
|
ce as useGetExternalWalletBalanceQuery,
|
|
369
369
|
L as useHiveKeysQuery,
|