@ecency/wallets 1.5.11 → 1.5.13
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 +26 -12
- package/dist/browser/index.js +29 -45
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +29 -45
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +29 -45
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -2906,49 +2906,33 @@ function normalizeNumber(value) {
|
|
|
2906
2906
|
}
|
|
2907
2907
|
return void 0;
|
|
2908
2908
|
}
|
|
2909
|
-
function normalizeApr(value) {
|
|
2910
|
-
const numeric = normalizeNumber(value);
|
|
2911
|
-
if (numeric === void 0) {
|
|
2912
|
-
if (typeof value === "string") {
|
|
2913
|
-
const trimmed = value.trim();
|
|
2914
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
2915
|
-
}
|
|
2916
|
-
return void 0;
|
|
2917
|
-
}
|
|
2918
|
-
return numeric.toString();
|
|
2919
|
-
}
|
|
2920
2909
|
function parseToken(rawToken) {
|
|
2921
2910
|
if (!rawToken || typeof rawToken !== "object") {
|
|
2922
2911
|
return void 0;
|
|
2923
2912
|
}
|
|
2924
2913
|
const token = rawToken;
|
|
2925
|
-
const symbol = normalizeString(token.symbol) ?? normalizeString(token.asset) ?? normalizeString(token.name);
|
|
2926
|
-
if (!symbol) {
|
|
2927
|
-
return void 0;
|
|
2928
|
-
}
|
|
2929
|
-
const normalizedSymbol = symbol.toUpperCase();
|
|
2930
|
-
const title = normalizeString(token.title) ?? normalizeString(token.display) ?? normalizeString(token.label) ?? normalizeString(token.friendlyName) ?? normalizeString(token.name) ?? normalizedSymbol;
|
|
2931
|
-
const price = normalizeNumber(token.fiatRate) ?? 0;
|
|
2932
|
-
const apr = normalizeApr(token.apr) ?? normalizeApr(token.aprPercent) ?? normalizeApr(token.metrics?.apr) ?? normalizeApr(
|
|
2933
|
-
token.metrics?.aprPercent
|
|
2934
|
-
);
|
|
2935
|
-
const accountBalance = normalizeNumber(token.balance) ?? normalizeNumber(token.accountBalance) ?? normalizeNumber(token.totalBalance) ?? normalizeNumber(token.total) ?? normalizeNumber(token.amount) ?? 0;
|
|
2936
|
-
const layer = normalizeString(token.layer) ?? normalizeString(token.chain) ?? normalizeString(token.category) ?? normalizeString(token.type);
|
|
2937
|
-
const pendingRewards = normalizeNumber(token.pendingRewards);
|
|
2938
|
-
const savings = normalizeNumber(token.savings);
|
|
2939
2914
|
return {
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2915
|
+
name: normalizeString(token.name) ?? "",
|
|
2916
|
+
symbol: normalizeString(token.symbol) ?? "",
|
|
2917
|
+
layer: normalizeString(token.layer) ?? "hive",
|
|
2918
|
+
balance: normalizeNumber(token.balance) ?? 0,
|
|
2919
|
+
fiatRate: normalizeNumber(token.fiatRate) ?? 0,
|
|
2920
|
+
currency: normalizeString(token.currency) ?? "usd",
|
|
2921
|
+
precision: normalizeNumber(token.precision) ?? 3,
|
|
2922
|
+
address: normalizeString(token.address),
|
|
2923
|
+
error: normalizeString(token.error),
|
|
2924
|
+
pendingRewards: normalizeNumber(token.pendingRewards),
|
|
2925
|
+
pendingRewardsFiat: normalizeNumber(token.pendingRewardsFiat),
|
|
2926
|
+
liquid: normalizeNumber(token.liquid),
|
|
2927
|
+
liquidFiat: normalizeNumber(token.liquidFiat),
|
|
2928
|
+
savings: normalizeNumber(token.savings),
|
|
2929
|
+
savingsFiat: normalizeNumber(token.savingsFiat),
|
|
2930
|
+
staked: normalizeNumber(token.staked),
|
|
2931
|
+
stakedFiat: normalizeNumber(token.stakedFiat),
|
|
2932
|
+
iconUrl: normalizeString(token.iconUrl),
|
|
2933
|
+
actions: token.actions ?? [],
|
|
2934
|
+
extraData: token.extraData ?? [],
|
|
2935
|
+
apr: normalizeNumber(token.apr)
|
|
2952
2936
|
};
|
|
2953
2937
|
}
|
|
2954
2938
|
function extractTokens(payload) {
|
|
@@ -3012,7 +2996,7 @@ function getVisionPortfolioQueryOptions(username, currency = "usd") {
|
|
|
3012
2996
|
if (!username) {
|
|
3013
2997
|
throw new Error("[SDK][Wallets] \u2013 username is required");
|
|
3014
2998
|
}
|
|
3015
|
-
if (
|
|
2999
|
+
if (CONFIG.privateApiHost === void 0 || CONFIG.privateApiHost === null) {
|
|
3016
3000
|
throw new Error(
|
|
3017
3001
|
"[SDK][Wallets] \u2013 privateApiHost isn't configured for portfolio"
|
|
3018
3002
|
);
|
|
@@ -3105,7 +3089,7 @@ function getAccountWalletListQueryOptions(username, currency = "usd") {
|
|
|
3105
3089
|
try {
|
|
3106
3090
|
const portfolio = await queryClient.fetchQuery(portfolioQuery);
|
|
3107
3091
|
const tokensFromPortfolio = portfolio.wallets.map(
|
|
3108
|
-
(asset) => asset.
|
|
3092
|
+
(asset) => asset.symbol
|
|
3109
3093
|
);
|
|
3110
3094
|
if (tokensFromPortfolio.length > 0) {
|
|
3111
3095
|
const visibleTokens = tokensFromPortfolio.map((token) => token?.toUpperCase?.()).filter((token) => Boolean(token)).filter(isTokenVisible);
|
|
@@ -3579,14 +3563,14 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
|
|
|
3579
3563
|
try {
|
|
3580
3564
|
const portfolio = await queryClient.fetchQuery(portfolioQuery);
|
|
3581
3565
|
const assetInfo = portfolio.wallets.find(
|
|
3582
|
-
(assetItem) => assetItem.
|
|
3566
|
+
(assetItem) => assetItem.symbol.toUpperCase() === asset.toUpperCase()
|
|
3583
3567
|
);
|
|
3584
3568
|
if (!assetInfo) return void 0;
|
|
3585
3569
|
return {
|
|
3586
|
-
name: assetInfo.
|
|
3587
|
-
title: assetInfo.
|
|
3588
|
-
price: assetInfo.
|
|
3589
|
-
accountBalance: assetInfo.
|
|
3570
|
+
name: assetInfo.symbol,
|
|
3571
|
+
title: assetInfo.name,
|
|
3572
|
+
price: assetInfo.fiatRate,
|
|
3573
|
+
accountBalance: assetInfo.balance,
|
|
3590
3574
|
apr: assetInfo.apr?.toString(),
|
|
3591
3575
|
layer: assetInfo.layer,
|
|
3592
3576
|
pendingRewards: assetInfo.pendingRewards
|
|
@@ -3663,7 +3647,7 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
|
|
|
3663
3647
|
getVisionPortfolioQueryOptions(username, currency)
|
|
3664
3648
|
);
|
|
3665
3649
|
const assetEntry = portfolio.wallets.find(
|
|
3666
|
-
(assetItem) => assetItem.symbol
|
|
3650
|
+
(assetItem) => assetItem.symbol.toUpperCase() === normalizedToken
|
|
3667
3651
|
);
|
|
3668
3652
|
if (!assetEntry) {
|
|
3669
3653
|
return [];
|