@ecency/wallets 1.5.8 → 1.5.9
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.js +44 -26
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +43 -25
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +44 -26
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -3791,6 +3791,21 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
|
|
|
3791
3791
|
}
|
|
3792
3792
|
return queryClient.getQueryData(queryOptions43.queryKey);
|
|
3793
3793
|
};
|
|
3794
|
+
const convertPriceToUserCurrency = async (assetInfo) => {
|
|
3795
|
+
if (!assetInfo || currency === "usd") {
|
|
3796
|
+
return assetInfo;
|
|
3797
|
+
}
|
|
3798
|
+
try {
|
|
3799
|
+
const conversionRate = await sdk.getCurrencyRate(currency);
|
|
3800
|
+
return {
|
|
3801
|
+
...assetInfo,
|
|
3802
|
+
price: assetInfo.price * conversionRate
|
|
3803
|
+
};
|
|
3804
|
+
} catch (error) {
|
|
3805
|
+
console.warn(`Failed to convert price from USD to ${currency}:`, error);
|
|
3806
|
+
return assetInfo;
|
|
3807
|
+
}
|
|
3808
|
+
};
|
|
3794
3809
|
const portfolioQuery = getVisionPortfolioQueryOptions(username, currency);
|
|
3795
3810
|
const getPortfolioAssetInfo = async () => {
|
|
3796
3811
|
try {
|
|
@@ -3807,50 +3822,53 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
|
|
|
3807
3822
|
queryKey: ["ecency-wallets", "asset-info", username, asset, currency],
|
|
3808
3823
|
queryFn: async () => {
|
|
3809
3824
|
const portfolioAssetInfo = await getPortfolioAssetInfo();
|
|
3810
|
-
if (portfolioAssetInfo) {
|
|
3825
|
+
if (portfolioAssetInfo && portfolioAssetInfo.price > 0) {
|
|
3811
3826
|
return portfolioAssetInfo;
|
|
3812
3827
|
}
|
|
3828
|
+
let assetInfo;
|
|
3813
3829
|
if (asset === "HIVE") {
|
|
3814
|
-
|
|
3830
|
+
assetInfo = await fetchQuery(getHiveAssetGeneralInfoQueryOptions(username));
|
|
3815
3831
|
} else if (asset === "HP") {
|
|
3816
|
-
|
|
3832
|
+
assetInfo = await fetchQuery(getHivePowerAssetGeneralInfoQueryOptions(username));
|
|
3817
3833
|
} else if (asset === "HBD") {
|
|
3818
|
-
|
|
3834
|
+
assetInfo = await fetchQuery(getHbdAssetGeneralInfoQueryOptions(username));
|
|
3819
3835
|
} else if (asset === "SPK") {
|
|
3820
|
-
|
|
3836
|
+
assetInfo = await fetchQuery(getSpkAssetGeneralInfoQueryOptions(username));
|
|
3821
3837
|
} else if (asset === "LARYNX") {
|
|
3822
|
-
|
|
3838
|
+
assetInfo = await fetchQuery(getLarynxAssetGeneralInfoQueryOptions(username));
|
|
3823
3839
|
} else if (asset === "LP") {
|
|
3824
|
-
|
|
3840
|
+
assetInfo = await fetchQuery(getLarynxPowerAssetGeneralInfoQueryOptions(username));
|
|
3825
3841
|
} else if (asset === "POINTS") {
|
|
3826
|
-
|
|
3842
|
+
assetInfo = await fetchQuery(getPointsAssetGeneralInfoQueryOptions(username));
|
|
3827
3843
|
} else if (asset === "APT") {
|
|
3828
|
-
|
|
3844
|
+
assetInfo = await fetchQuery(getAptAssetGeneralInfoQueryOptions(username));
|
|
3829
3845
|
} else if (asset === "BNB") {
|
|
3830
|
-
|
|
3846
|
+
assetInfo = await fetchQuery(getBnbAssetGeneralInfoQueryOptions(username));
|
|
3831
3847
|
} else if (asset === "BTC") {
|
|
3832
|
-
|
|
3848
|
+
assetInfo = await fetchQuery(getBtcAssetGeneralInfoQueryOptions(username));
|
|
3833
3849
|
} else if (asset === "ETH") {
|
|
3834
|
-
|
|
3850
|
+
assetInfo = await fetchQuery(getEthAssetGeneralInfoQueryOptions(username));
|
|
3835
3851
|
} else if (asset === "SOL") {
|
|
3836
|
-
|
|
3852
|
+
assetInfo = await fetchQuery(getSolAssetGeneralInfoQueryOptions(username));
|
|
3837
3853
|
} else if (asset === "TON") {
|
|
3838
|
-
|
|
3854
|
+
assetInfo = await fetchQuery(getTonAssetGeneralInfoQueryOptions(username));
|
|
3839
3855
|
} else if (asset === "TRX") {
|
|
3840
|
-
|
|
3841
|
-
}
|
|
3842
|
-
const balances = await queryClient.ensureQueryData(
|
|
3843
|
-
getHiveEngineTokensBalancesQueryOptions(username)
|
|
3844
|
-
);
|
|
3845
|
-
if (balances.some((balance) => balance.symbol === asset)) {
|
|
3846
|
-
return await fetchQuery(
|
|
3847
|
-
getHiveEngineTokenGeneralInfoQueryOptions(username, asset)
|
|
3848
|
-
);
|
|
3856
|
+
assetInfo = await fetchQuery(getTronAssetGeneralInfoQueryOptions(username));
|
|
3849
3857
|
} else {
|
|
3850
|
-
|
|
3851
|
-
|
|
3858
|
+
const balances = await queryClient.ensureQueryData(
|
|
3859
|
+
getHiveEngineTokensBalancesQueryOptions(username)
|
|
3852
3860
|
);
|
|
3861
|
+
if (balances.some((balance) => balance.symbol === asset)) {
|
|
3862
|
+
assetInfo = await fetchQuery(
|
|
3863
|
+
getHiveEngineTokenGeneralInfoQueryOptions(username, asset)
|
|
3864
|
+
);
|
|
3865
|
+
} else {
|
|
3866
|
+
throw new Error(
|
|
3867
|
+
"[SDK][Wallets] \u2013 has requested unrecognized asset info"
|
|
3868
|
+
);
|
|
3869
|
+
}
|
|
3853
3870
|
}
|
|
3871
|
+
return await convertPriceToUserCurrency(assetInfo);
|
|
3854
3872
|
}
|
|
3855
3873
|
});
|
|
3856
3874
|
}
|