@ecency/wallets 1.4.7 → 1.4.8
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/browser/index.d.ts +2 -2
- package/dist/browser/index.js +71 -58
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +71 -58
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +71 -58
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -1413,7 +1413,7 @@ declare function useGetExternalWalletBalanceQuery(currency: EcencyWalletCurrency
|
|
|
1413
1413
|
|
|
1414
1414
|
declare function useSeedPhrase(username: string): _tanstack_react_query.UseQueryResult<string, Error>;
|
|
1415
1415
|
|
|
1416
|
-
declare function
|
|
1416
|
+
declare function getTokenPriceQueryOptions(currency?: string): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<number, Error, number, (string | undefined)[]>, "queryFn"> & {
|
|
1417
1417
|
queryFn?: _tanstack_react_query.QueryFunction<number, (string | undefined)[], never> | undefined;
|
|
1418
1418
|
} & {
|
|
1419
1419
|
queryKey: (string | undefined)[] & {
|
|
@@ -1644,4 +1644,4 @@ declare function buildExternalTx(currency: EcencyWalletCurrency, tx: ExternalTxP
|
|
|
1644
1644
|
|
|
1645
1645
|
declare function getBoundFetch(): typeof fetch;
|
|
1646
1646
|
|
|
1647
|
-
export { type AccountPointsResponse, type Asset, AssetOperation, type DelegateEnginePayload, type EcencyHiveKeys, type EcencyTokenMetadata, EcencyWalletBasicTokens, EcencyWalletCurrency, index as EcencyWalletsPrivateApi, type ExternalTxParams, type ExternalWalletBalance, type GeneralAssetInfo, type GeneralAssetTransaction, type HiveBasedAssetSignType, type HiveEngineMarketResponse, type HiveEngineMetric, type HiveEngineTokenBalance, type HiveEngineTokenMetadataResponse, type HiveEngineTransaction, type HiveKeyDerivation, type HiveRole, NaiMap, type PointTransaction, PointTransactionType, type Points, type PointsResponse, type SpkApiWallet, type SpkMarkets, type StakeEnginePayload, Symbol, type TransferEnginePayload, type TransferPayload, type TransformedSpkMarkets, type UndelegateEnginePayload, type UnstakeEnginePayload, buildAptTx, buildEthTx, buildExternalTx, buildPsbt, buildSolTx, buildTonTx, buildTronTx, decryptMemoWithAccounts, decryptMemoWithKeys, delay, delegateEngineToken, delegateHive, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, encryptMemoWithAccounts, encryptMemoWithKeys, getAccountWalletAssetInfoQueryOptions, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getBoundFetch,
|
|
1647
|
+
export { type AccountPointsResponse, type Asset, AssetOperation, type DelegateEnginePayload, type EcencyHiveKeys, type EcencyTokenMetadata, EcencyWalletBasicTokens, EcencyWalletCurrency, index as EcencyWalletsPrivateApi, type ExternalTxParams, type ExternalWalletBalance, type GeneralAssetInfo, type GeneralAssetTransaction, type HiveBasedAssetSignType, type HiveEngineMarketResponse, type HiveEngineMetric, type HiveEngineTokenBalance, type HiveEngineTokenMetadataResponse, type HiveEngineTransaction, type HiveKeyDerivation, type HiveRole, NaiMap, type PointTransaction, PointTransactionType, type Points, type PointsResponse, type SpkApiWallet, type SpkMarkets, type StakeEnginePayload, Symbol, type TransferEnginePayload, type TransferPayload, type TransformedSpkMarkets, type UndelegateEnginePayload, type UnstakeEnginePayload, buildAptTx, buildEthTx, buildExternalTx, buildPsbt, buildSolTx, buildTonTx, buildTronTx, decryptMemoWithAccounts, decryptMemoWithKeys, delay, delegateEngineToken, delegateHive, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, encryptMemoWithAccounts, encryptMemoWithKeys, getAccountWalletAssetInfoQueryOptions, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getBoundFetch, getHbdAssetGeneralInfoQueryOptions, getHbdAssetTransactionsQueryOptions, getHiveAssetGeneralInfoQueryOptions, getHiveAssetMetricQueryOptions, getHiveAssetTransactionsQueryOptions, getHiveAssetWithdrawalRoutesQueryOptions, getHiveEngineTokenGeneralInfoQueryOptions, getHiveEngineTokenTransactionsQueryOptions, getHiveEngineTokensBalancesQueryOptions, getHiveEngineTokensMarketQueryOptions, getHiveEngineTokensMetadataQueryOptions, getHiveEngineTokensMetricsQueryOptions, getHivePowerAssetGeneralInfoQueryOptions, getHivePowerAssetTransactionsQueryOptions, getHivePowerDelegatesInfiniteQueryOptions, getHivePowerDelegatingsQueryOptions, getLarynxAssetGeneralInfoQueryOptions, getLarynxPowerAssetGeneralInfoQueryOptions, getPointsAssetGeneralInfoQueryOptions, getPointsAssetTransactionsQueryOptions, getPointsQueryOptions, getSpkAssetGeneralInfoQueryOptions, getSpkMarketsQueryOptions, getTokenOperationsQueryOptions, getTokenPriceQueryOptions, getWallet, isEmptyDate, lockLarynx, mnemonicToSeedBip39, parseAsset, powerDownHive, powerUpHive, powerUpLarynx, rewardSpk, signDigest, signExternalTx, signExternalTxAndBroadcast, signTx, signTxAndBroadcast, stakeEngineToken, transferEngineToken, transferHive, transferPoint, transferSpk, transferToSavingsHive, undelegateEngineToken, unstakeEngineToken, useClaimPoints, useClaimRewards, useGetExternalWalletBalanceQuery, useHiveKeysQuery, useImportWallet, useSaveWalletInformationToMetadata, useSeedPhrase, useWalletCreate, useWalletOperation, useWalletsCacheQuery, vestsToHp, withdrawVestingRouteHive };
|
package/dist/browser/index.js
CHANGED
|
@@ -202,55 +202,67 @@ var cacheGet = (key) => {
|
|
|
202
202
|
const v = cache.get(key);
|
|
203
203
|
return v === undefinedValue ? void 0 : v;
|
|
204
204
|
};
|
|
205
|
-
|
|
205
|
+
var CURRENCY_TO_TOKEN_MAP = {
|
|
206
|
+
["BTC" /* BTC */]: "btc",
|
|
207
|
+
["ETH" /* ETH */]: "eth",
|
|
208
|
+
["SOL" /* SOL */]: "sol",
|
|
209
|
+
["TON" /* TON */]: "ton",
|
|
210
|
+
["TRX" /* TRON */]: "trx",
|
|
211
|
+
["APT" /* APT */]: "apt",
|
|
212
|
+
["BNB" /* BNB */]: "bnb",
|
|
213
|
+
HBD: "hbd",
|
|
214
|
+
HIVE: "hive"
|
|
215
|
+
};
|
|
216
|
+
var MARKET_DATA_CACHE_KEY = "market-data/latest";
|
|
217
|
+
var normalizeCurrencyToToken = (currency) => {
|
|
218
|
+
const upperCased = currency.toUpperCase();
|
|
219
|
+
return CURRENCY_TO_TOKEN_MAP[upperCased] ?? currency.toLowerCase();
|
|
220
|
+
};
|
|
221
|
+
function getTokenPriceQueryOptions(currency) {
|
|
206
222
|
return queryOptions({
|
|
207
|
-
queryKey: ["ecency-wallets", "
|
|
223
|
+
queryKey: ["ecency-wallets", "market-data", currency],
|
|
208
224
|
queryFn: async () => {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
break;
|
|
214
|
-
case "ETH" /* ETH */:
|
|
215
|
-
curr = "ethereum";
|
|
216
|
-
break;
|
|
217
|
-
case "SOL" /* SOL */:
|
|
218
|
-
curr = "solana";
|
|
219
|
-
break;
|
|
220
|
-
case "TON" /* TON */:
|
|
221
|
-
curr = "ton";
|
|
222
|
-
break;
|
|
223
|
-
case "TRX" /* TRON */:
|
|
224
|
-
curr = "tron";
|
|
225
|
-
break;
|
|
226
|
-
case "APT" /* APT */:
|
|
227
|
-
curr = "aptos";
|
|
228
|
-
break;
|
|
229
|
-
case "BNB" /* BNB */:
|
|
230
|
-
curr = "binancecoin";
|
|
231
|
-
break;
|
|
232
|
-
case "TON" /* TON */:
|
|
233
|
-
curr = "the-open-network";
|
|
234
|
-
break;
|
|
235
|
-
default:
|
|
236
|
-
curr = currency;
|
|
225
|
+
if (!currency) {
|
|
226
|
+
throw new Error(
|
|
227
|
+
"[SDK][Wallets][MarketData] \u2013 currency wasn`t provided"
|
|
228
|
+
);
|
|
237
229
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
230
|
+
if (!CONFIG.privateApiHost) {
|
|
231
|
+
throw new Error(
|
|
232
|
+
"[SDK][Wallets][MarketData] \u2013 privateApiHost isn`t configured"
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
const token = normalizeCurrencyToToken(currency);
|
|
236
|
+
let marketData = cacheGet(MARKET_DATA_CACHE_KEY);
|
|
237
|
+
if (!marketData) {
|
|
243
238
|
const httpResponse = await fetch(
|
|
244
|
-
|
|
239
|
+
`${CONFIG.privateApiHost}/private-api/market-data/latest`,
|
|
245
240
|
{
|
|
246
241
|
method: "GET"
|
|
247
242
|
}
|
|
248
243
|
);
|
|
244
|
+
if (!httpResponse.ok) {
|
|
245
|
+
throw new Error(
|
|
246
|
+
`[SDK][Wallets][MarketData] \u2013 failed to fetch latest market data (${httpResponse.status})`
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
249
|
const data = await httpResponse.json();
|
|
250
|
-
cacheSet(
|
|
251
|
-
|
|
250
|
+
cacheSet(MARKET_DATA_CACHE_KEY, data);
|
|
251
|
+
marketData = data;
|
|
252
|
+
}
|
|
253
|
+
const tokenData = marketData[token];
|
|
254
|
+
if (!tokenData) {
|
|
255
|
+
throw new Error(
|
|
256
|
+
`[SDK][Wallets][MarketData] \u2013 missing market data for token: ${token}`
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
const usdQuote = tokenData.quotes?.usd;
|
|
260
|
+
if (!usdQuote) {
|
|
261
|
+
throw new Error(
|
|
262
|
+
`[SDK][Wallets][MarketData] \u2013 missing USD quote for token: ${token}`
|
|
263
|
+
);
|
|
252
264
|
}
|
|
253
|
-
return
|
|
265
|
+
return Number(usdQuote.price);
|
|
254
266
|
},
|
|
255
267
|
enabled: !!currency
|
|
256
268
|
});
|
|
@@ -746,11 +758,12 @@ function getHbdAssetGeneralInfoQueryOptions(username) {
|
|
|
746
758
|
);
|
|
747
759
|
let price = 1;
|
|
748
760
|
try {
|
|
749
|
-
|
|
750
|
-
"
|
|
761
|
+
await CONFIG.queryClient.prefetchQuery(
|
|
762
|
+
getTokenPriceQueryOptions("HBD")
|
|
751
763
|
);
|
|
752
|
-
const
|
|
753
|
-
|
|
764
|
+
const marketPrice = CONFIG.queryClient.getQueryData(
|
|
765
|
+
getTokenPriceQueryOptions("HBD").queryKey
|
|
766
|
+
) ?? 0;
|
|
754
767
|
if (typeof marketPrice === "number" && Number.isFinite(marketPrice)) {
|
|
755
768
|
price = marketPrice;
|
|
756
769
|
}
|
|
@@ -2486,10 +2499,10 @@ function getAptAssetGeneralInfoQueryOptions(username) {
|
|
|
2486
2499
|
getAptAssetBalanceQueryOptions(address).queryKey
|
|
2487
2500
|
) ?? 0) / 1e8;
|
|
2488
2501
|
await CONFIG.queryClient.prefetchQuery(
|
|
2489
|
-
|
|
2502
|
+
getTokenPriceQueryOptions("APT")
|
|
2490
2503
|
);
|
|
2491
2504
|
const price = CONFIG.queryClient.getQueryData(
|
|
2492
|
-
|
|
2505
|
+
getTokenPriceQueryOptions("APT").queryKey
|
|
2493
2506
|
) ?? 0;
|
|
2494
2507
|
return {
|
|
2495
2508
|
name: "APT",
|
|
@@ -2537,10 +2550,10 @@ function getBnbAssetGeneralInfoQueryOptions(username) {
|
|
|
2537
2550
|
getBnbAssetBalanceQueryOptions(address).queryKey
|
|
2538
2551
|
) ?? 0) / 1e18;
|
|
2539
2552
|
await CONFIG.queryClient.prefetchQuery(
|
|
2540
|
-
|
|
2553
|
+
getTokenPriceQueryOptions("BNB")
|
|
2541
2554
|
);
|
|
2542
2555
|
const price = CONFIG.queryClient.getQueryData(
|
|
2543
|
-
|
|
2556
|
+
getTokenPriceQueryOptions("BNB").queryKey
|
|
2544
2557
|
) ?? 0;
|
|
2545
2558
|
return {
|
|
2546
2559
|
name: "BNB",
|
|
@@ -2588,10 +2601,10 @@ function getBtcAssetGeneralInfoQueryOptions(username) {
|
|
|
2588
2601
|
getBtcAssetBalanceQueryOptions(address).queryKey
|
|
2589
2602
|
) ?? 0) / 1e8;
|
|
2590
2603
|
await CONFIG.queryClient.prefetchQuery(
|
|
2591
|
-
|
|
2604
|
+
getTokenPriceQueryOptions("BTC")
|
|
2592
2605
|
);
|
|
2593
2606
|
const price = CONFIG.queryClient.getQueryData(
|
|
2594
|
-
|
|
2607
|
+
getTokenPriceQueryOptions("BTC").queryKey
|
|
2595
2608
|
) ?? 0;
|
|
2596
2609
|
return {
|
|
2597
2610
|
name: "BTC",
|
|
@@ -2639,10 +2652,10 @@ function getEthAssetGeneralInfoQueryOptions(username) {
|
|
|
2639
2652
|
getEthAssetBalanceQueryOptions(address).queryKey
|
|
2640
2653
|
) ?? 0) / 1e18;
|
|
2641
2654
|
await CONFIG.queryClient.prefetchQuery(
|
|
2642
|
-
|
|
2655
|
+
getTokenPriceQueryOptions("ETH")
|
|
2643
2656
|
);
|
|
2644
2657
|
const price = CONFIG.queryClient.getQueryData(
|
|
2645
|
-
|
|
2658
|
+
getTokenPriceQueryOptions("ETH").queryKey
|
|
2646
2659
|
) ?? 0;
|
|
2647
2660
|
return {
|
|
2648
2661
|
name: "ETH",
|
|
@@ -2690,10 +2703,10 @@ function getSolAssetGeneralInfoQueryOptions(username) {
|
|
|
2690
2703
|
getSolAssetBalanceQueryOptions(address).queryKey
|
|
2691
2704
|
) ?? 0) / 1e9;
|
|
2692
2705
|
await CONFIG.queryClient.prefetchQuery(
|
|
2693
|
-
|
|
2706
|
+
getTokenPriceQueryOptions("SOL")
|
|
2694
2707
|
);
|
|
2695
2708
|
const price = CONFIG.queryClient.getQueryData(
|
|
2696
|
-
|
|
2709
|
+
getTokenPriceQueryOptions("SOL").queryKey
|
|
2697
2710
|
) ?? 0;
|
|
2698
2711
|
return {
|
|
2699
2712
|
name: "SOL",
|
|
@@ -2741,10 +2754,10 @@ function getTonAssetGeneralInfoQueryOptions(username) {
|
|
|
2741
2754
|
getTonAssetBalanceQueryOptions(address).queryKey
|
|
2742
2755
|
) ?? 0) / 1e9;
|
|
2743
2756
|
await CONFIG.queryClient.prefetchQuery(
|
|
2744
|
-
|
|
2757
|
+
getTokenPriceQueryOptions("TON")
|
|
2745
2758
|
);
|
|
2746
2759
|
const price = CONFIG.queryClient.getQueryData(
|
|
2747
|
-
|
|
2760
|
+
getTokenPriceQueryOptions("TON").queryKey
|
|
2748
2761
|
) ?? 0;
|
|
2749
2762
|
return {
|
|
2750
2763
|
name: "TON",
|
|
@@ -2792,10 +2805,10 @@ function getTronAssetGeneralInfoQueryOptions(username) {
|
|
|
2792
2805
|
getTronAssetBalanceQueryOptions(address).queryKey
|
|
2793
2806
|
) ?? 0) / 1e6;
|
|
2794
2807
|
await CONFIG.queryClient.prefetchQuery(
|
|
2795
|
-
|
|
2808
|
+
getTokenPriceQueryOptions("TRX")
|
|
2796
2809
|
);
|
|
2797
2810
|
const price = CONFIG.queryClient.getQueryData(
|
|
2798
|
-
|
|
2811
|
+
getTokenPriceQueryOptions("TRX").queryKey
|
|
2799
2812
|
) ?? 0;
|
|
2800
2813
|
return {
|
|
2801
2814
|
name: "TRX",
|
|
@@ -3342,6 +3355,6 @@ function useWalletOperation(username, asset, operation) {
|
|
|
3342
3355
|
// src/index.ts
|
|
3343
3356
|
rememberScryptBsvVersion();
|
|
3344
3357
|
|
|
3345
|
-
export { AssetOperation, EcencyWalletBasicTokens, EcencyWalletCurrency, private_api_exports as EcencyWalletsPrivateApi, NaiMap, PointTransactionType, Symbol2 as Symbol, buildAptTx, buildEthTx, buildExternalTx, buildPsbt, buildSolTx, buildTonTx, buildTronTx, decryptMemoWithAccounts, decryptMemoWithKeys, delay, delegateEngineToken, delegateHive, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, encryptMemoWithAccounts, encryptMemoWithKeys, getAccountWalletAssetInfoQueryOptions, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getBoundFetch,
|
|
3358
|
+
export { AssetOperation, EcencyWalletBasicTokens, EcencyWalletCurrency, private_api_exports as EcencyWalletsPrivateApi, NaiMap, PointTransactionType, Symbol2 as Symbol, buildAptTx, buildEthTx, buildExternalTx, buildPsbt, buildSolTx, buildTonTx, buildTronTx, decryptMemoWithAccounts, decryptMemoWithKeys, delay, delegateEngineToken, delegateHive, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, encryptMemoWithAccounts, encryptMemoWithKeys, getAccountWalletAssetInfoQueryOptions, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getBoundFetch, getHbdAssetGeneralInfoQueryOptions, getHbdAssetTransactionsQueryOptions, getHiveAssetGeneralInfoQueryOptions, getHiveAssetMetricQueryOptions, getHiveAssetTransactionsQueryOptions, getHiveAssetWithdrawalRoutesQueryOptions, getHiveEngineTokenGeneralInfoQueryOptions, getHiveEngineTokenTransactionsQueryOptions, getHiveEngineTokensBalancesQueryOptions, getHiveEngineTokensMarketQueryOptions, getHiveEngineTokensMetadataQueryOptions, getHiveEngineTokensMetricsQueryOptions, getHivePowerAssetGeneralInfoQueryOptions, getHivePowerAssetTransactionsQueryOptions, getHivePowerDelegatesInfiniteQueryOptions, getHivePowerDelegatingsQueryOptions, getLarynxAssetGeneralInfoQueryOptions, getLarynxPowerAssetGeneralInfoQueryOptions, getPointsAssetGeneralInfoQueryOptions, getPointsAssetTransactionsQueryOptions, getPointsQueryOptions, getSpkAssetGeneralInfoQueryOptions, getSpkMarketsQueryOptions, getTokenOperationsQueryOptions, getTokenPriceQueryOptions, getWallet, isEmptyDate, lockLarynx, mnemonicToSeedBip39, parseAsset, powerDownHive, powerUpHive, powerUpLarynx, rewardSpk, signDigest, signExternalTx, signExternalTxAndBroadcast, signTx, signTxAndBroadcast, stakeEngineToken, transferEngineToken, transferHive, transferPoint, transferSpk, transferToSavingsHive, undelegateEngineToken, unstakeEngineToken, useClaimPoints, useClaimRewards, useGetExternalWalletBalanceQuery, useHiveKeysQuery, useImportWallet, useSaveWalletInformationToMetadata, useSeedPhrase, useWalletCreate, useWalletOperation, useWalletsCacheQuery, vestsToHp, withdrawVestingRouteHive };
|
|
3346
3359
|
//# sourceMappingURL=index.js.map
|
|
3347
3360
|
//# sourceMappingURL=index.js.map
|