@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.cjs
CHANGED
|
@@ -2933,49 +2933,33 @@ function normalizeNumber(value) {
|
|
|
2933
2933
|
}
|
|
2934
2934
|
return void 0;
|
|
2935
2935
|
}
|
|
2936
|
-
function normalizeApr(value) {
|
|
2937
|
-
const numeric = normalizeNumber(value);
|
|
2938
|
-
if (numeric === void 0) {
|
|
2939
|
-
if (typeof value === "string") {
|
|
2940
|
-
const trimmed = value.trim();
|
|
2941
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
2942
|
-
}
|
|
2943
|
-
return void 0;
|
|
2944
|
-
}
|
|
2945
|
-
return numeric.toString();
|
|
2946
|
-
}
|
|
2947
2936
|
function parseToken(rawToken) {
|
|
2948
2937
|
if (!rawToken || typeof rawToken !== "object") {
|
|
2949
2938
|
return void 0;
|
|
2950
2939
|
}
|
|
2951
2940
|
const token = rawToken;
|
|
2952
|
-
const symbol = normalizeString(token.symbol) ?? normalizeString(token.asset) ?? normalizeString(token.name);
|
|
2953
|
-
if (!symbol) {
|
|
2954
|
-
return void 0;
|
|
2955
|
-
}
|
|
2956
|
-
const normalizedSymbol = symbol.toUpperCase();
|
|
2957
|
-
const title = normalizeString(token.title) ?? normalizeString(token.display) ?? normalizeString(token.label) ?? normalizeString(token.friendlyName) ?? normalizeString(token.name) ?? normalizedSymbol;
|
|
2958
|
-
const price = normalizeNumber(token.fiatRate) ?? 0;
|
|
2959
|
-
const apr = normalizeApr(token.apr) ?? normalizeApr(token.aprPercent) ?? normalizeApr(token.metrics?.apr) ?? normalizeApr(
|
|
2960
|
-
token.metrics?.aprPercent
|
|
2961
|
-
);
|
|
2962
|
-
const accountBalance = normalizeNumber(token.balance) ?? normalizeNumber(token.accountBalance) ?? normalizeNumber(token.totalBalance) ?? normalizeNumber(token.total) ?? normalizeNumber(token.amount) ?? 0;
|
|
2963
|
-
const layer = normalizeString(token.layer) ?? normalizeString(token.chain) ?? normalizeString(token.category) ?? normalizeString(token.type);
|
|
2964
|
-
const pendingRewards = normalizeNumber(token.pendingRewards);
|
|
2965
|
-
const savings = normalizeNumber(token.savings);
|
|
2966
2941
|
return {
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2942
|
+
name: normalizeString(token.name) ?? "",
|
|
2943
|
+
symbol: normalizeString(token.symbol) ?? "",
|
|
2944
|
+
layer: normalizeString(token.layer) ?? "hive",
|
|
2945
|
+
balance: normalizeNumber(token.balance) ?? 0,
|
|
2946
|
+
fiatRate: normalizeNumber(token.fiatRate) ?? 0,
|
|
2947
|
+
currency: normalizeString(token.currency) ?? "usd",
|
|
2948
|
+
precision: normalizeNumber(token.precision) ?? 3,
|
|
2949
|
+
address: normalizeString(token.address),
|
|
2950
|
+
error: normalizeString(token.error),
|
|
2951
|
+
pendingRewards: normalizeNumber(token.pendingRewards),
|
|
2952
|
+
pendingRewardsFiat: normalizeNumber(token.pendingRewardsFiat),
|
|
2953
|
+
liquid: normalizeNumber(token.liquid),
|
|
2954
|
+
liquidFiat: normalizeNumber(token.liquidFiat),
|
|
2955
|
+
savings: normalizeNumber(token.savings),
|
|
2956
|
+
savingsFiat: normalizeNumber(token.savingsFiat),
|
|
2957
|
+
staked: normalizeNumber(token.staked),
|
|
2958
|
+
stakedFiat: normalizeNumber(token.stakedFiat),
|
|
2959
|
+
iconUrl: normalizeString(token.iconUrl),
|
|
2960
|
+
actions: token.actions ?? [],
|
|
2961
|
+
extraData: token.extraData ?? [],
|
|
2962
|
+
apr: normalizeNumber(token.apr)
|
|
2979
2963
|
};
|
|
2980
2964
|
}
|
|
2981
2965
|
function extractTokens(payload) {
|
|
@@ -3039,7 +3023,7 @@ function getVisionPortfolioQueryOptions(username, currency = "usd") {
|
|
|
3039
3023
|
if (!username) {
|
|
3040
3024
|
throw new Error("[SDK][Wallets] \u2013 username is required");
|
|
3041
3025
|
}
|
|
3042
|
-
if (
|
|
3026
|
+
if (sdk.CONFIG.privateApiHost === void 0 || sdk.CONFIG.privateApiHost === null) {
|
|
3043
3027
|
throw new Error(
|
|
3044
3028
|
"[SDK][Wallets] \u2013 privateApiHost isn't configured for portfolio"
|
|
3045
3029
|
);
|
|
@@ -3132,7 +3116,7 @@ function getAccountWalletListQueryOptions(username, currency = "usd") {
|
|
|
3132
3116
|
try {
|
|
3133
3117
|
const portfolio = await queryClient.fetchQuery(portfolioQuery);
|
|
3134
3118
|
const tokensFromPortfolio = portfolio.wallets.map(
|
|
3135
|
-
(asset) => asset.
|
|
3119
|
+
(asset) => asset.symbol
|
|
3136
3120
|
);
|
|
3137
3121
|
if (tokensFromPortfolio.length > 0) {
|
|
3138
3122
|
const visibleTokens = tokensFromPortfolio.map((token) => token?.toUpperCase?.()).filter((token) => Boolean(token)).filter(isTokenVisible);
|
|
@@ -3606,14 +3590,14 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
|
|
|
3606
3590
|
try {
|
|
3607
3591
|
const portfolio = await queryClient.fetchQuery(portfolioQuery);
|
|
3608
3592
|
const assetInfo = portfolio.wallets.find(
|
|
3609
|
-
(assetItem) => assetItem.
|
|
3593
|
+
(assetItem) => assetItem.symbol.toUpperCase() === asset.toUpperCase()
|
|
3610
3594
|
);
|
|
3611
3595
|
if (!assetInfo) return void 0;
|
|
3612
3596
|
return {
|
|
3613
|
-
name: assetInfo.
|
|
3614
|
-
title: assetInfo.
|
|
3615
|
-
price: assetInfo.
|
|
3616
|
-
accountBalance: assetInfo.
|
|
3597
|
+
name: assetInfo.symbol,
|
|
3598
|
+
title: assetInfo.name,
|
|
3599
|
+
price: assetInfo.fiatRate,
|
|
3600
|
+
accountBalance: assetInfo.balance,
|
|
3617
3601
|
apr: assetInfo.apr?.toString(),
|
|
3618
3602
|
layer: assetInfo.layer,
|
|
3619
3603
|
pendingRewards: assetInfo.pendingRewards
|
|
@@ -3690,7 +3674,7 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
|
|
|
3690
3674
|
getVisionPortfolioQueryOptions(username, currency)
|
|
3691
3675
|
);
|
|
3692
3676
|
const assetEntry = portfolio.wallets.find(
|
|
3693
|
-
(assetItem) => assetItem.symbol
|
|
3677
|
+
(assetItem) => assetItem.symbol.toUpperCase() === normalizedToken
|
|
3694
3678
|
);
|
|
3695
3679
|
if (!assetEntry) {
|
|
3696
3680
|
return [];
|