@ecency/wallets 1.5.9 → 1.5.10
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 +17 -2
- package/dist/browser/index.js +107 -105
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +107 -105
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +107 -105
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -1816,8 +1816,23 @@ declare function useWalletsCacheQuery(username?: string): _tanstack_react_query.
|
|
|
1816
1816
|
|
|
1817
1817
|
interface VisionPortfolioWalletItem {
|
|
1818
1818
|
symbol: string;
|
|
1819
|
-
|
|
1820
|
-
|
|
1819
|
+
name: string;
|
|
1820
|
+
title?: string;
|
|
1821
|
+
price?: number;
|
|
1822
|
+
accountBalance?: number;
|
|
1823
|
+
apr?: number;
|
|
1824
|
+
layer?: string;
|
|
1825
|
+
pendingRewards?: number;
|
|
1826
|
+
parts?: {
|
|
1827
|
+
name: string;
|
|
1828
|
+
balance: number;
|
|
1829
|
+
}[];
|
|
1830
|
+
actions?: Array<{
|
|
1831
|
+
id: string;
|
|
1832
|
+
[key: string]: unknown;
|
|
1833
|
+
} | string>;
|
|
1834
|
+
fiatRate?: number;
|
|
1835
|
+
fiatCurrency?: string;
|
|
1821
1836
|
}
|
|
1822
1837
|
interface VisionPortfolioResponse {
|
|
1823
1838
|
username: string;
|
package/dist/browser/index.js
CHANGED
|
@@ -2876,51 +2876,6 @@ function getAllTokensListQueryOptions(username) {
|
|
|
2876
2876
|
}
|
|
2877
2877
|
});
|
|
2878
2878
|
}
|
|
2879
|
-
var ACTION_ALIAS_MAP = {
|
|
2880
|
-
"transfer-to-savings": "transfer-saving" /* TransferToSavings */,
|
|
2881
|
-
"transfer-savings": "transfer-saving" /* TransferToSavings */,
|
|
2882
|
-
"savings-transfer": "transfer-saving" /* TransferToSavings */,
|
|
2883
|
-
"withdraw-from-savings": "withdraw-saving" /* WithdrawFromSavings */,
|
|
2884
|
-
"withdraw-savings": "withdraw-saving" /* WithdrawFromSavings */,
|
|
2885
|
-
"savings-withdraw": "withdraw-saving" /* WithdrawFromSavings */,
|
|
2886
|
-
"transfer-from-savings": "withdraw-saving" /* WithdrawFromSavings */,
|
|
2887
|
-
"powerup": "power-up" /* PowerUp */,
|
|
2888
|
-
"power-down": "power-down" /* PowerDown */,
|
|
2889
|
-
"powerdown": "power-down" /* PowerDown */,
|
|
2890
|
-
"withdraw-vesting": "power-down" /* PowerDown */,
|
|
2891
|
-
"hp-delegate": "delegate" /* Delegate */,
|
|
2892
|
-
"delegate-hp": "delegate" /* Delegate */,
|
|
2893
|
-
"delegate-power": "delegate" /* Delegate */,
|
|
2894
|
-
"delegate-vesting-shares": "delegate" /* Delegate */,
|
|
2895
|
-
"undelegate-power": "undelegate" /* Undelegate */,
|
|
2896
|
-
"undelegate-token": "undelegate" /* Undelegate */,
|
|
2897
|
-
"stake-token": "stake" /* Stake */,
|
|
2898
|
-
"stake-power": "stake" /* Stake */,
|
|
2899
|
-
"unstake-token": "unstake" /* Unstake */,
|
|
2900
|
-
"unstake-power": "unstake" /* Unstake */,
|
|
2901
|
-
"transfer-to-vesting": "power-up" /* PowerUp */,
|
|
2902
|
-
"lock-liquidity": "lock" /* LockLiquidity */,
|
|
2903
|
-
"lock-liq": "lock" /* LockLiquidity */,
|
|
2904
|
-
"gift-points": "gift" /* Gift */,
|
|
2905
|
-
"points-gift": "gift" /* Gift */,
|
|
2906
|
-
"promote-post": "promote" /* Promote */,
|
|
2907
|
-
"promote-entry": "promote" /* Promote */,
|
|
2908
|
-
boost: "promote" /* Promote */,
|
|
2909
|
-
convert: "swap" /* Swap */,
|
|
2910
|
-
"swap-token": "swap" /* Swap */,
|
|
2911
|
-
"swap_tokens": "swap" /* Swap */,
|
|
2912
|
-
"claim-points": "claim" /* Claim */,
|
|
2913
|
-
"claim-rewards": "claim" /* Claim */,
|
|
2914
|
-
"buy-points": "buy" /* Buy */,
|
|
2915
|
-
"ecency-point-transfer": "transfer" /* Transfer */,
|
|
2916
|
-
"spkcc-spk-send": "transfer" /* Transfer */,
|
|
2917
|
-
"withdraw-routes": "withdraw-routes" /* WithdrawRoutes */,
|
|
2918
|
-
"withdrawroutes": "withdraw-routes" /* WithdrawRoutes */,
|
|
2919
|
-
"claim-interest": "claim-interest" /* ClaimInterest */
|
|
2920
|
-
};
|
|
2921
|
-
var KNOWN_OPERATION_VALUES = new Map(
|
|
2922
|
-
Object.values(AssetOperation).map((value) => [value, value])
|
|
2923
|
-
);
|
|
2924
2879
|
var DERIVED_PART_KEY_MAP = {
|
|
2925
2880
|
liquid: ["liquid", "liquidBalance", "liquid_amount", "liquidTokens"],
|
|
2926
2881
|
savings: ["savings", "savingsBalance", "savings_amount"],
|
|
@@ -3086,34 +3041,6 @@ function normalizeExtraDataParts(rawExtraData) {
|
|
|
3086
3041
|
}).filter((part) => Boolean(part));
|
|
3087
3042
|
return parts.length ? parts : void 0;
|
|
3088
3043
|
}
|
|
3089
|
-
function normalizeActionKey(value) {
|
|
3090
|
-
return value.trim().toLowerCase().replace(/[\s_]+/g, "-");
|
|
3091
|
-
}
|
|
3092
|
-
function mapActions(rawActions) {
|
|
3093
|
-
if (!rawActions) {
|
|
3094
|
-
return [];
|
|
3095
|
-
}
|
|
3096
|
-
const rawList = Array.isArray(rawActions) ? rawActions : [rawActions];
|
|
3097
|
-
const result = [];
|
|
3098
|
-
for (const raw of rawList) {
|
|
3099
|
-
let candidate;
|
|
3100
|
-
if (typeof raw === "string") {
|
|
3101
|
-
candidate = raw;
|
|
3102
|
-
} else if (raw && typeof raw === "object") {
|
|
3103
|
-
const record = raw;
|
|
3104
|
-
candidate = normalizeString(record.code) ?? normalizeString(record.id) ?? normalizeString(record.name) ?? normalizeString(record.action);
|
|
3105
|
-
}
|
|
3106
|
-
if (!candidate) {
|
|
3107
|
-
continue;
|
|
3108
|
-
}
|
|
3109
|
-
const canonical = normalizeActionKey(candidate);
|
|
3110
|
-
const operation = KNOWN_OPERATION_VALUES.get(canonical) ?? ACTION_ALIAS_MAP[canonical];
|
|
3111
|
-
if (operation && !result.includes(operation)) {
|
|
3112
|
-
result.push(operation);
|
|
3113
|
-
}
|
|
3114
|
-
}
|
|
3115
|
-
return result;
|
|
3116
|
-
}
|
|
3117
3044
|
function parseToken(rawToken) {
|
|
3118
3045
|
if (!rawToken || typeof rawToken !== "object") {
|
|
3119
3046
|
return void 0;
|
|
@@ -3143,19 +3070,17 @@ function parseToken(rawToken) {
|
|
|
3143
3070
|
const pendingRewards = normalizeNumber(token.pendingRewards);
|
|
3144
3071
|
return {
|
|
3145
3072
|
symbol: normalizedSymbol,
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
token.actions ?? token.available_actions ?? token.availableActions ?? token.operations ?? token.supportedActions
|
|
3158
|
-
)
|
|
3073
|
+
name: normalizedSymbol,
|
|
3074
|
+
title,
|
|
3075
|
+
price,
|
|
3076
|
+
accountBalance,
|
|
3077
|
+
apr: apr ? Number.parseFloat(apr) : void 0,
|
|
3078
|
+
layer: layer ?? void 0,
|
|
3079
|
+
pendingRewards: pendingRewards ?? void 0,
|
|
3080
|
+
parts,
|
|
3081
|
+
actions: token.actions ?? token.available_actions ?? token.availableActions ?? token.operations ?? token.supportedActions,
|
|
3082
|
+
fiatRate: normalizeNumber(token.fiatRate) ?? void 0,
|
|
3083
|
+
fiatCurrency: normalizeString(token.fiatCurrency) ?? void 0
|
|
3159
3084
|
};
|
|
3160
3085
|
}
|
|
3161
3086
|
function extractTokens(payload) {
|
|
@@ -3312,7 +3237,7 @@ function getAccountWalletListQueryOptions(username, currency = "usd") {
|
|
|
3312
3237
|
try {
|
|
3313
3238
|
const portfolio = await queryClient.fetchQuery(portfolioQuery);
|
|
3314
3239
|
const tokensFromPortfolio = portfolio.wallets.map(
|
|
3315
|
-
(asset) => asset.
|
|
3240
|
+
(asset) => asset.name
|
|
3316
3241
|
);
|
|
3317
3242
|
if (tokensFromPortfolio.length > 0) {
|
|
3318
3243
|
const visibleTokens = tokensFromPortfolio.map((token) => token?.toUpperCase?.()).filter((token) => Boolean(token)).filter(isTokenVisible);
|
|
@@ -3786,9 +3711,19 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
|
|
|
3786
3711
|
try {
|
|
3787
3712
|
const portfolio = await queryClient.fetchQuery(portfolioQuery);
|
|
3788
3713
|
const assetInfo = portfolio.wallets.find(
|
|
3789
|
-
(assetItem) => assetItem.
|
|
3714
|
+
(assetItem) => assetItem.name === asset.toUpperCase()
|
|
3790
3715
|
);
|
|
3791
|
-
return
|
|
3716
|
+
if (!assetInfo) return void 0;
|
|
3717
|
+
return {
|
|
3718
|
+
name: assetInfo.name,
|
|
3719
|
+
title: assetInfo.title,
|
|
3720
|
+
price: assetInfo.price ?? assetInfo.fiatRate ?? 0,
|
|
3721
|
+
accountBalance: assetInfo.accountBalance ?? 0,
|
|
3722
|
+
apr: assetInfo.apr,
|
|
3723
|
+
layer: assetInfo.layer,
|
|
3724
|
+
pendingRewards: assetInfo.pendingRewards,
|
|
3725
|
+
parts: assetInfo.parts
|
|
3726
|
+
};
|
|
3792
3727
|
} catch (e) {
|
|
3793
3728
|
return void 0;
|
|
3794
3729
|
}
|
|
@@ -3847,16 +3782,6 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
|
|
|
3847
3782
|
}
|
|
3848
3783
|
});
|
|
3849
3784
|
}
|
|
3850
|
-
function normalizePartKey2(value) {
|
|
3851
|
-
return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
3852
|
-
}
|
|
3853
|
-
function hasNonZeroSavingsBalance(parts) {
|
|
3854
|
-
return Boolean(
|
|
3855
|
-
parts?.some(
|
|
3856
|
-
(part) => normalizePartKey2(part.name) === "savings" && Number(part.balance) > 0
|
|
3857
|
-
)
|
|
3858
|
-
);
|
|
3859
|
-
}
|
|
3860
3785
|
function getTokenOperationsQueryOptions(token, username, isForOwner = false, currency = "usd") {
|
|
3861
3786
|
return queryOptions({
|
|
3862
3787
|
queryKey: ["wallets", "token-operations", token, username, isForOwner, currency],
|
|
@@ -3871,16 +3796,93 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
|
|
|
3871
3796
|
getVisionPortfolioQueryOptions(username, currency)
|
|
3872
3797
|
);
|
|
3873
3798
|
const assetEntry = portfolio.wallets.find(
|
|
3874
|
-
(assetItem) => assetItem.
|
|
3799
|
+
(assetItem) => assetItem.symbol?.toUpperCase() === normalizedToken
|
|
3875
3800
|
);
|
|
3876
3801
|
if (!assetEntry) {
|
|
3877
3802
|
return [];
|
|
3878
3803
|
}
|
|
3879
|
-
const
|
|
3880
|
-
const
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3804
|
+
const rawActions = assetEntry.actions ?? [];
|
|
3805
|
+
const operations = rawActions.map((action) => {
|
|
3806
|
+
if (typeof action === "string") return action;
|
|
3807
|
+
if (action && typeof action === "object") {
|
|
3808
|
+
const record = action;
|
|
3809
|
+
return record.id ?? record.code ?? record.name ?? record.action;
|
|
3810
|
+
}
|
|
3811
|
+
return void 0;
|
|
3812
|
+
}).filter((id) => Boolean(id)).map((id) => {
|
|
3813
|
+
const canonical = id.trim().toLowerCase().replace(/[\s_]+/g, "-");
|
|
3814
|
+
const aliasMap = {
|
|
3815
|
+
// Common operations
|
|
3816
|
+
"transfer": "transfer" /* Transfer */,
|
|
3817
|
+
"ecency-point-transfer": "transfer" /* Transfer */,
|
|
3818
|
+
"spkcc-spk-send": "transfer" /* Transfer */,
|
|
3819
|
+
// Savings operations
|
|
3820
|
+
"transfer-to-savings": "transfer-saving" /* TransferToSavings */,
|
|
3821
|
+
"transfer-savings": "transfer-saving" /* TransferToSavings */,
|
|
3822
|
+
"savings-transfer": "transfer-saving" /* TransferToSavings */,
|
|
3823
|
+
"withdraw-from-savings": "withdraw-saving" /* WithdrawFromSavings */,
|
|
3824
|
+
"transfer-from-savings": "withdraw-saving" /* WithdrawFromSavings */,
|
|
3825
|
+
"withdraw-savings": "withdraw-saving" /* WithdrawFromSavings */,
|
|
3826
|
+
"savings-withdraw": "withdraw-saving" /* WithdrawFromSavings */,
|
|
3827
|
+
// Vesting/Power operations
|
|
3828
|
+
"transfer-to-vesting": "power-up" /* PowerUp */,
|
|
3829
|
+
"powerup": "power-up" /* PowerUp */,
|
|
3830
|
+
"power-up": "power-up" /* PowerUp */,
|
|
3831
|
+
"withdraw-vesting": "power-down" /* PowerDown */,
|
|
3832
|
+
"power-down": "power-down" /* PowerDown */,
|
|
3833
|
+
"powerdown": "power-down" /* PowerDown */,
|
|
3834
|
+
// Delegation
|
|
3835
|
+
"delegate": "delegate" /* Delegate */,
|
|
3836
|
+
"delegate-vesting-shares": "delegate" /* Delegate */,
|
|
3837
|
+
"hp-delegate": "delegate" /* Delegate */,
|
|
3838
|
+
"delegate-hp": "delegate" /* Delegate */,
|
|
3839
|
+
"delegate-power": "delegate" /* Delegate */,
|
|
3840
|
+
"undelegate": "undelegate" /* Undelegate */,
|
|
3841
|
+
"undelegate-power": "undelegate" /* Undelegate */,
|
|
3842
|
+
"undelegate-token": "undelegate" /* Undelegate */,
|
|
3843
|
+
// Staking (Layer 2)
|
|
3844
|
+
"stake": "stake" /* Stake */,
|
|
3845
|
+
"stake-token": "stake" /* Stake */,
|
|
3846
|
+
"stake-power": "stake" /* Stake */,
|
|
3847
|
+
"unstake": "unstake" /* Unstake */,
|
|
3848
|
+
"unstake-token": "unstake" /* Unstake */,
|
|
3849
|
+
"unstake-power": "unstake" /* Unstake */,
|
|
3850
|
+
// Swap/Convert
|
|
3851
|
+
"swap": "swap" /* Swap */,
|
|
3852
|
+
"swap-token": "swap" /* Swap */,
|
|
3853
|
+
"swap-tokens": "swap" /* Swap */,
|
|
3854
|
+
"convert": "swap" /* Swap */,
|
|
3855
|
+
// Points operations
|
|
3856
|
+
"promote": "promote" /* Promote */,
|
|
3857
|
+
"promote-post": "promote" /* Promote */,
|
|
3858
|
+
"promote-entry": "promote" /* Promote */,
|
|
3859
|
+
"boost": "promote" /* Promote */,
|
|
3860
|
+
"gift": "gift" /* Gift */,
|
|
3861
|
+
"gift-points": "gift" /* Gift */,
|
|
3862
|
+
"points-gift": "gift" /* Gift */,
|
|
3863
|
+
"claim": "claim" /* Claim */,
|
|
3864
|
+
"claim-rewards": "claim" /* Claim */,
|
|
3865
|
+
"claim-points": "claim" /* Claim */,
|
|
3866
|
+
"buy": "buy" /* Buy */,
|
|
3867
|
+
"buy-points": "buy" /* Buy */,
|
|
3868
|
+
// Other
|
|
3869
|
+
"claim-interest": "claim-interest" /* ClaimInterest */,
|
|
3870
|
+
"withdraw-routes": "withdraw-routes" /* WithdrawRoutes */,
|
|
3871
|
+
"withdrawroutes": "withdraw-routes" /* WithdrawRoutes */,
|
|
3872
|
+
"lock": "lock" /* LockLiquidity */,
|
|
3873
|
+
"lock-liquidity": "lock" /* LockLiquidity */,
|
|
3874
|
+
"lock-liq": "lock" /* LockLiquidity */
|
|
3875
|
+
};
|
|
3876
|
+
const mapped = aliasMap[canonical];
|
|
3877
|
+
if (mapped) return mapped;
|
|
3878
|
+
const directMatch = Object.values(AssetOperation).find(
|
|
3879
|
+
(op) => op.toLowerCase() === canonical
|
|
3880
|
+
);
|
|
3881
|
+
return directMatch;
|
|
3882
|
+
}).filter((op) => Boolean(op));
|
|
3883
|
+
const isHiveOrHbd = ["HIVE", "HBD"].includes(normalizedToken);
|
|
3884
|
+
const hasSavings = Number(assetEntry.savings ?? 0) > 0;
|
|
3885
|
+
if (isHiveOrHbd && !hasSavings) {
|
|
3884
3886
|
return operations.filter(
|
|
3885
3887
|
(operation) => operation !== "withdraw-saving" /* WithdrawFromSavings */
|
|
3886
3888
|
);
|