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