@ecency/wallets 1.5.11 → 1.5.12
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/browser/index.d.ts
CHANGED
|
@@ -1815,22 +1815,36 @@ declare function getTokenOperationsQueryOptions(token: string, username: string,
|
|
|
1815
1815
|
|
|
1816
1816
|
declare function useWalletsCacheQuery(username?: string): _tanstack_react_query.DefinedUseQueryResult<Map<EcencyWalletCurrency, EcencyTokenMetadata>, Error>;
|
|
1817
1817
|
|
|
1818
|
+
type PortfolioLayer = "points" | "hive" | "chain" | "spk" | "engine";
|
|
1819
|
+
interface TokenAction {
|
|
1820
|
+
id: string;
|
|
1821
|
+
[key: string]: unknown;
|
|
1822
|
+
}
|
|
1818
1823
|
interface VisionPortfolioWalletItem {
|
|
1819
|
-
symbol: string;
|
|
1820
1824
|
name: string;
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1825
|
+
symbol: string;
|
|
1826
|
+
layer: PortfolioLayer;
|
|
1827
|
+
balance: number;
|
|
1828
|
+
fiatRate: number;
|
|
1829
|
+
currency: string;
|
|
1830
|
+
precision: number;
|
|
1831
|
+
address?: string;
|
|
1832
|
+
error?: string;
|
|
1826
1833
|
pendingRewards?: number;
|
|
1834
|
+
pendingRewardsFiat?: number;
|
|
1835
|
+
liquid?: number;
|
|
1836
|
+
liquidFiat?: number;
|
|
1827
1837
|
savings?: number;
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1838
|
+
savingsFiat?: number;
|
|
1839
|
+
staked?: number;
|
|
1840
|
+
stakedFiat?: number;
|
|
1841
|
+
iconUrl?: string;
|
|
1842
|
+
actions?: TokenAction[];
|
|
1843
|
+
extraData?: Array<{
|
|
1844
|
+
dataKey: string;
|
|
1845
|
+
value: any;
|
|
1846
|
+
}>;
|
|
1847
|
+
apr?: number;
|
|
1834
1848
|
}
|
|
1835
1849
|
interface VisionPortfolioResponse {
|
|
1836
1850
|
username: string;
|
package/dist/browser/index.js
CHANGED
|
@@ -2908,49 +2908,33 @@ function normalizeNumber(value) {
|
|
|
2908
2908
|
}
|
|
2909
2909
|
return void 0;
|
|
2910
2910
|
}
|
|
2911
|
-
function normalizeApr(value) {
|
|
2912
|
-
const numeric = normalizeNumber(value);
|
|
2913
|
-
if (numeric === void 0) {
|
|
2914
|
-
if (typeof value === "string") {
|
|
2915
|
-
const trimmed = value.trim();
|
|
2916
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
2917
|
-
}
|
|
2918
|
-
return void 0;
|
|
2919
|
-
}
|
|
2920
|
-
return numeric.toString();
|
|
2921
|
-
}
|
|
2922
2911
|
function parseToken(rawToken) {
|
|
2923
2912
|
if (!rawToken || typeof rawToken !== "object") {
|
|
2924
2913
|
return void 0;
|
|
2925
2914
|
}
|
|
2926
2915
|
const token = rawToken;
|
|
2927
|
-
const symbol = normalizeString(token.symbol) ?? normalizeString(token.asset) ?? normalizeString(token.name);
|
|
2928
|
-
if (!symbol) {
|
|
2929
|
-
return void 0;
|
|
2930
|
-
}
|
|
2931
|
-
const normalizedSymbol = symbol.toUpperCase();
|
|
2932
|
-
const title = normalizeString(token.title) ?? normalizeString(token.display) ?? normalizeString(token.label) ?? normalizeString(token.friendlyName) ?? normalizeString(token.name) ?? normalizedSymbol;
|
|
2933
|
-
const price = normalizeNumber(token.fiatRate) ?? 0;
|
|
2934
|
-
const apr = normalizeApr(token.apr) ?? normalizeApr(token.aprPercent) ?? normalizeApr(token.metrics?.apr) ?? normalizeApr(
|
|
2935
|
-
token.metrics?.aprPercent
|
|
2936
|
-
);
|
|
2937
|
-
const accountBalance = normalizeNumber(token.balance) ?? normalizeNumber(token.accountBalance) ?? normalizeNumber(token.totalBalance) ?? normalizeNumber(token.total) ?? normalizeNumber(token.amount) ?? 0;
|
|
2938
|
-
const layer = normalizeString(token.layer) ?? normalizeString(token.chain) ?? normalizeString(token.category) ?? normalizeString(token.type);
|
|
2939
|
-
const pendingRewards = normalizeNumber(token.pendingRewards);
|
|
2940
|
-
const savings = normalizeNumber(token.savings);
|
|
2941
2916
|
return {
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2917
|
+
name: normalizeString(token.name) ?? "",
|
|
2918
|
+
symbol: normalizeString(token.symbol) ?? "",
|
|
2919
|
+
layer: normalizeString(token.layer) ?? "hive",
|
|
2920
|
+
balance: normalizeNumber(token.balance) ?? 0,
|
|
2921
|
+
fiatRate: normalizeNumber(token.fiatRate) ?? 0,
|
|
2922
|
+
currency: normalizeString(token.currency) ?? "usd",
|
|
2923
|
+
precision: normalizeNumber(token.precision) ?? 3,
|
|
2924
|
+
address: normalizeString(token.address),
|
|
2925
|
+
error: normalizeString(token.error),
|
|
2926
|
+
pendingRewards: normalizeNumber(token.pendingRewards),
|
|
2927
|
+
pendingRewardsFiat: normalizeNumber(token.pendingRewardsFiat),
|
|
2928
|
+
liquid: normalizeNumber(token.liquid),
|
|
2929
|
+
liquidFiat: normalizeNumber(token.liquidFiat),
|
|
2930
|
+
savings: normalizeNumber(token.savings),
|
|
2931
|
+
savingsFiat: normalizeNumber(token.savingsFiat),
|
|
2932
|
+
staked: normalizeNumber(token.staked),
|
|
2933
|
+
stakedFiat: normalizeNumber(token.stakedFiat),
|
|
2934
|
+
iconUrl: normalizeString(token.iconUrl),
|
|
2935
|
+
actions: token.actions ?? [],
|
|
2936
|
+
extraData: token.extraData ?? [],
|
|
2937
|
+
apr: normalizeNumber(token.apr)
|
|
2954
2938
|
};
|
|
2955
2939
|
}
|
|
2956
2940
|
function extractTokens(payload) {
|
|
@@ -3014,7 +2998,7 @@ function getVisionPortfolioQueryOptions(username, currency = "usd") {
|
|
|
3014
2998
|
if (!username) {
|
|
3015
2999
|
throw new Error("[SDK][Wallets] \u2013 username is required");
|
|
3016
3000
|
}
|
|
3017
|
-
if (
|
|
3001
|
+
if (CONFIG.privateApiHost === void 0 || CONFIG.privateApiHost === null) {
|
|
3018
3002
|
throw new Error(
|
|
3019
3003
|
"[SDK][Wallets] \u2013 privateApiHost isn't configured for portfolio"
|
|
3020
3004
|
);
|
|
@@ -3107,7 +3091,7 @@ function getAccountWalletListQueryOptions(username, currency = "usd") {
|
|
|
3107
3091
|
try {
|
|
3108
3092
|
const portfolio = await queryClient.fetchQuery(portfolioQuery);
|
|
3109
3093
|
const tokensFromPortfolio = portfolio.wallets.map(
|
|
3110
|
-
(asset) => asset.
|
|
3094
|
+
(asset) => asset.symbol
|
|
3111
3095
|
);
|
|
3112
3096
|
if (tokensFromPortfolio.length > 0) {
|
|
3113
3097
|
const visibleTokens = tokensFromPortfolio.map((token) => token?.toUpperCase?.()).filter((token) => Boolean(token)).filter(isTokenVisible);
|
|
@@ -3581,14 +3565,14 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
|
|
|
3581
3565
|
try {
|
|
3582
3566
|
const portfolio = await queryClient.fetchQuery(portfolioQuery);
|
|
3583
3567
|
const assetInfo = portfolio.wallets.find(
|
|
3584
|
-
(assetItem) => assetItem.
|
|
3568
|
+
(assetItem) => assetItem.symbol.toUpperCase() === asset.toUpperCase()
|
|
3585
3569
|
);
|
|
3586
3570
|
if (!assetInfo) return void 0;
|
|
3587
3571
|
return {
|
|
3588
|
-
name: assetInfo.
|
|
3589
|
-
title: assetInfo.
|
|
3590
|
-
price: assetInfo.
|
|
3591
|
-
accountBalance: assetInfo.
|
|
3572
|
+
name: assetInfo.symbol,
|
|
3573
|
+
title: assetInfo.name,
|
|
3574
|
+
price: assetInfo.fiatRate,
|
|
3575
|
+
accountBalance: assetInfo.balance,
|
|
3592
3576
|
apr: assetInfo.apr?.toString(),
|
|
3593
3577
|
layer: assetInfo.layer,
|
|
3594
3578
|
pendingRewards: assetInfo.pendingRewards
|
|
@@ -3665,7 +3649,7 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
|
|
|
3665
3649
|
getVisionPortfolioQueryOptions(username, currency)
|
|
3666
3650
|
);
|
|
3667
3651
|
const assetEntry = portfolio.wallets.find(
|
|
3668
|
-
(assetItem) => assetItem.symbol
|
|
3652
|
+
(assetItem) => assetItem.symbol.toUpperCase() === normalizedToken
|
|
3669
3653
|
);
|
|
3670
3654
|
if (!assetEntry) {
|
|
3671
3655
|
return [];
|