@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.cjs
CHANGED
|
@@ -2901,51 +2901,6 @@ function getAllTokensListQueryOptions(username) {
|
|
|
2901
2901
|
}
|
|
2902
2902
|
});
|
|
2903
2903
|
}
|
|
2904
|
-
var ACTION_ALIAS_MAP = {
|
|
2905
|
-
"transfer-to-savings": "transfer-saving" /* TransferToSavings */,
|
|
2906
|
-
"transfer-savings": "transfer-saving" /* TransferToSavings */,
|
|
2907
|
-
"savings-transfer": "transfer-saving" /* TransferToSavings */,
|
|
2908
|
-
"withdraw-from-savings": "withdraw-saving" /* WithdrawFromSavings */,
|
|
2909
|
-
"withdraw-savings": "withdraw-saving" /* WithdrawFromSavings */,
|
|
2910
|
-
"savings-withdraw": "withdraw-saving" /* WithdrawFromSavings */,
|
|
2911
|
-
"transfer-from-savings": "withdraw-saving" /* WithdrawFromSavings */,
|
|
2912
|
-
"powerup": "power-up" /* PowerUp */,
|
|
2913
|
-
"power-down": "power-down" /* PowerDown */,
|
|
2914
|
-
"powerdown": "power-down" /* PowerDown */,
|
|
2915
|
-
"withdraw-vesting": "power-down" /* PowerDown */,
|
|
2916
|
-
"hp-delegate": "delegate" /* Delegate */,
|
|
2917
|
-
"delegate-hp": "delegate" /* Delegate */,
|
|
2918
|
-
"delegate-power": "delegate" /* Delegate */,
|
|
2919
|
-
"delegate-vesting-shares": "delegate" /* Delegate */,
|
|
2920
|
-
"undelegate-power": "undelegate" /* Undelegate */,
|
|
2921
|
-
"undelegate-token": "undelegate" /* Undelegate */,
|
|
2922
|
-
"stake-token": "stake" /* Stake */,
|
|
2923
|
-
"stake-power": "stake" /* Stake */,
|
|
2924
|
-
"unstake-token": "unstake" /* Unstake */,
|
|
2925
|
-
"unstake-power": "unstake" /* Unstake */,
|
|
2926
|
-
"transfer-to-vesting": "power-up" /* PowerUp */,
|
|
2927
|
-
"lock-liquidity": "lock" /* LockLiquidity */,
|
|
2928
|
-
"lock-liq": "lock" /* LockLiquidity */,
|
|
2929
|
-
"gift-points": "gift" /* Gift */,
|
|
2930
|
-
"points-gift": "gift" /* Gift */,
|
|
2931
|
-
"promote-post": "promote" /* Promote */,
|
|
2932
|
-
"promote-entry": "promote" /* Promote */,
|
|
2933
|
-
boost: "promote" /* Promote */,
|
|
2934
|
-
convert: "swap" /* Swap */,
|
|
2935
|
-
"swap-token": "swap" /* Swap */,
|
|
2936
|
-
"swap_tokens": "swap" /* Swap */,
|
|
2937
|
-
"claim-points": "claim" /* Claim */,
|
|
2938
|
-
"claim-rewards": "claim" /* Claim */,
|
|
2939
|
-
"buy-points": "buy" /* Buy */,
|
|
2940
|
-
"ecency-point-transfer": "transfer" /* Transfer */,
|
|
2941
|
-
"spkcc-spk-send": "transfer" /* Transfer */,
|
|
2942
|
-
"withdraw-routes": "withdraw-routes" /* WithdrawRoutes */,
|
|
2943
|
-
"withdrawroutes": "withdraw-routes" /* WithdrawRoutes */,
|
|
2944
|
-
"claim-interest": "claim-interest" /* ClaimInterest */
|
|
2945
|
-
};
|
|
2946
|
-
var KNOWN_OPERATION_VALUES = new Map(
|
|
2947
|
-
Object.values(AssetOperation).map((value) => [value, value])
|
|
2948
|
-
);
|
|
2949
2904
|
var DERIVED_PART_KEY_MAP = {
|
|
2950
2905
|
liquid: ["liquid", "liquidBalance", "liquid_amount", "liquidTokens"],
|
|
2951
2906
|
savings: ["savings", "savingsBalance", "savings_amount"],
|
|
@@ -3111,34 +3066,6 @@ function normalizeExtraDataParts(rawExtraData) {
|
|
|
3111
3066
|
}).filter((part) => Boolean(part));
|
|
3112
3067
|
return parts.length ? parts : void 0;
|
|
3113
3068
|
}
|
|
3114
|
-
function normalizeActionKey(value) {
|
|
3115
|
-
return value.trim().toLowerCase().replace(/[\s_]+/g, "-");
|
|
3116
|
-
}
|
|
3117
|
-
function mapActions(rawActions) {
|
|
3118
|
-
if (!rawActions) {
|
|
3119
|
-
return [];
|
|
3120
|
-
}
|
|
3121
|
-
const rawList = Array.isArray(rawActions) ? rawActions : [rawActions];
|
|
3122
|
-
const result = [];
|
|
3123
|
-
for (const raw of rawList) {
|
|
3124
|
-
let candidate;
|
|
3125
|
-
if (typeof raw === "string") {
|
|
3126
|
-
candidate = raw;
|
|
3127
|
-
} else if (raw && typeof raw === "object") {
|
|
3128
|
-
const record = raw;
|
|
3129
|
-
candidate = normalizeString(record.code) ?? normalizeString(record.id) ?? normalizeString(record.name) ?? normalizeString(record.action);
|
|
3130
|
-
}
|
|
3131
|
-
if (!candidate) {
|
|
3132
|
-
continue;
|
|
3133
|
-
}
|
|
3134
|
-
const canonical = normalizeActionKey(candidate);
|
|
3135
|
-
const operation = KNOWN_OPERATION_VALUES.get(canonical) ?? ACTION_ALIAS_MAP[canonical];
|
|
3136
|
-
if (operation && !result.includes(operation)) {
|
|
3137
|
-
result.push(operation);
|
|
3138
|
-
}
|
|
3139
|
-
}
|
|
3140
|
-
return result;
|
|
3141
|
-
}
|
|
3142
3069
|
function parseToken(rawToken) {
|
|
3143
3070
|
if (!rawToken || typeof rawToken !== "object") {
|
|
3144
3071
|
return void 0;
|
|
@@ -3168,19 +3095,17 @@ function parseToken(rawToken) {
|
|
|
3168
3095
|
const pendingRewards = normalizeNumber(token.pendingRewards);
|
|
3169
3096
|
return {
|
|
3170
3097
|
symbol: normalizedSymbol,
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
token.actions ?? token.available_actions ?? token.availableActions ?? token.operations ?? token.supportedActions
|
|
3183
|
-
)
|
|
3098
|
+
name: normalizedSymbol,
|
|
3099
|
+
title,
|
|
3100
|
+
price,
|
|
3101
|
+
accountBalance,
|
|
3102
|
+
apr: apr ? Number.parseFloat(apr) : void 0,
|
|
3103
|
+
layer: layer ?? void 0,
|
|
3104
|
+
pendingRewards: pendingRewards ?? void 0,
|
|
3105
|
+
parts,
|
|
3106
|
+
actions: token.actions ?? token.available_actions ?? token.availableActions ?? token.operations ?? token.supportedActions,
|
|
3107
|
+
fiatRate: normalizeNumber(token.fiatRate) ?? void 0,
|
|
3108
|
+
fiatCurrency: normalizeString(token.fiatCurrency) ?? void 0
|
|
3184
3109
|
};
|
|
3185
3110
|
}
|
|
3186
3111
|
function extractTokens(payload) {
|
|
@@ -3337,7 +3262,7 @@ function getAccountWalletListQueryOptions(username, currency = "usd") {
|
|
|
3337
3262
|
try {
|
|
3338
3263
|
const portfolio = await queryClient.fetchQuery(portfolioQuery);
|
|
3339
3264
|
const tokensFromPortfolio = portfolio.wallets.map(
|
|
3340
|
-
(asset) => asset.
|
|
3265
|
+
(asset) => asset.name
|
|
3341
3266
|
);
|
|
3342
3267
|
if (tokensFromPortfolio.length > 0) {
|
|
3343
3268
|
const visibleTokens = tokensFromPortfolio.map((token) => token?.toUpperCase?.()).filter((token) => Boolean(token)).filter(isTokenVisible);
|
|
@@ -3811,9 +3736,19 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
|
|
|
3811
3736
|
try {
|
|
3812
3737
|
const portfolio = await queryClient.fetchQuery(portfolioQuery);
|
|
3813
3738
|
const assetInfo = portfolio.wallets.find(
|
|
3814
|
-
(assetItem) => assetItem.
|
|
3739
|
+
(assetItem) => assetItem.name === asset.toUpperCase()
|
|
3815
3740
|
);
|
|
3816
|
-
return
|
|
3741
|
+
if (!assetInfo) return void 0;
|
|
3742
|
+
return {
|
|
3743
|
+
name: assetInfo.name,
|
|
3744
|
+
title: assetInfo.title,
|
|
3745
|
+
price: assetInfo.price ?? assetInfo.fiatRate ?? 0,
|
|
3746
|
+
accountBalance: assetInfo.accountBalance ?? 0,
|
|
3747
|
+
apr: assetInfo.apr,
|
|
3748
|
+
layer: assetInfo.layer,
|
|
3749
|
+
pendingRewards: assetInfo.pendingRewards,
|
|
3750
|
+
parts: assetInfo.parts
|
|
3751
|
+
};
|
|
3817
3752
|
} catch (e) {
|
|
3818
3753
|
return void 0;
|
|
3819
3754
|
}
|
|
@@ -3872,16 +3807,6 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
|
|
|
3872
3807
|
}
|
|
3873
3808
|
});
|
|
3874
3809
|
}
|
|
3875
|
-
function normalizePartKey2(value) {
|
|
3876
|
-
return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
3877
|
-
}
|
|
3878
|
-
function hasNonZeroSavingsBalance(parts) {
|
|
3879
|
-
return Boolean(
|
|
3880
|
-
parts?.some(
|
|
3881
|
-
(part) => normalizePartKey2(part.name) === "savings" && Number(part.balance) > 0
|
|
3882
|
-
)
|
|
3883
|
-
);
|
|
3884
|
-
}
|
|
3885
3810
|
function getTokenOperationsQueryOptions(token, username, isForOwner = false, currency = "usd") {
|
|
3886
3811
|
return reactQuery.queryOptions({
|
|
3887
3812
|
queryKey: ["wallets", "token-operations", token, username, isForOwner, currency],
|
|
@@ -3896,16 +3821,93 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
|
|
|
3896
3821
|
getVisionPortfolioQueryOptions(username, currency)
|
|
3897
3822
|
);
|
|
3898
3823
|
const assetEntry = portfolio.wallets.find(
|
|
3899
|
-
(assetItem) => assetItem.
|
|
3824
|
+
(assetItem) => assetItem.symbol?.toUpperCase() === normalizedToken
|
|
3900
3825
|
);
|
|
3901
3826
|
if (!assetEntry) {
|
|
3902
3827
|
return [];
|
|
3903
3828
|
}
|
|
3904
|
-
const
|
|
3905
|
-
const
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3829
|
+
const rawActions = assetEntry.actions ?? [];
|
|
3830
|
+
const operations = rawActions.map((action) => {
|
|
3831
|
+
if (typeof action === "string") return action;
|
|
3832
|
+
if (action && typeof action === "object") {
|
|
3833
|
+
const record = action;
|
|
3834
|
+
return record.id ?? record.code ?? record.name ?? record.action;
|
|
3835
|
+
}
|
|
3836
|
+
return void 0;
|
|
3837
|
+
}).filter((id) => Boolean(id)).map((id) => {
|
|
3838
|
+
const canonical = id.trim().toLowerCase().replace(/[\s_]+/g, "-");
|
|
3839
|
+
const aliasMap = {
|
|
3840
|
+
// Common operations
|
|
3841
|
+
"transfer": "transfer" /* Transfer */,
|
|
3842
|
+
"ecency-point-transfer": "transfer" /* Transfer */,
|
|
3843
|
+
"spkcc-spk-send": "transfer" /* Transfer */,
|
|
3844
|
+
// Savings operations
|
|
3845
|
+
"transfer-to-savings": "transfer-saving" /* TransferToSavings */,
|
|
3846
|
+
"transfer-savings": "transfer-saving" /* TransferToSavings */,
|
|
3847
|
+
"savings-transfer": "transfer-saving" /* TransferToSavings */,
|
|
3848
|
+
"withdraw-from-savings": "withdraw-saving" /* WithdrawFromSavings */,
|
|
3849
|
+
"transfer-from-savings": "withdraw-saving" /* WithdrawFromSavings */,
|
|
3850
|
+
"withdraw-savings": "withdraw-saving" /* WithdrawFromSavings */,
|
|
3851
|
+
"savings-withdraw": "withdraw-saving" /* WithdrawFromSavings */,
|
|
3852
|
+
// Vesting/Power operations
|
|
3853
|
+
"transfer-to-vesting": "power-up" /* PowerUp */,
|
|
3854
|
+
"powerup": "power-up" /* PowerUp */,
|
|
3855
|
+
"power-up": "power-up" /* PowerUp */,
|
|
3856
|
+
"withdraw-vesting": "power-down" /* PowerDown */,
|
|
3857
|
+
"power-down": "power-down" /* PowerDown */,
|
|
3858
|
+
"powerdown": "power-down" /* PowerDown */,
|
|
3859
|
+
// Delegation
|
|
3860
|
+
"delegate": "delegate" /* Delegate */,
|
|
3861
|
+
"delegate-vesting-shares": "delegate" /* Delegate */,
|
|
3862
|
+
"hp-delegate": "delegate" /* Delegate */,
|
|
3863
|
+
"delegate-hp": "delegate" /* Delegate */,
|
|
3864
|
+
"delegate-power": "delegate" /* Delegate */,
|
|
3865
|
+
"undelegate": "undelegate" /* Undelegate */,
|
|
3866
|
+
"undelegate-power": "undelegate" /* Undelegate */,
|
|
3867
|
+
"undelegate-token": "undelegate" /* Undelegate */,
|
|
3868
|
+
// Staking (Layer 2)
|
|
3869
|
+
"stake": "stake" /* Stake */,
|
|
3870
|
+
"stake-token": "stake" /* Stake */,
|
|
3871
|
+
"stake-power": "stake" /* Stake */,
|
|
3872
|
+
"unstake": "unstake" /* Unstake */,
|
|
3873
|
+
"unstake-token": "unstake" /* Unstake */,
|
|
3874
|
+
"unstake-power": "unstake" /* Unstake */,
|
|
3875
|
+
// Swap/Convert
|
|
3876
|
+
"swap": "swap" /* Swap */,
|
|
3877
|
+
"swap-token": "swap" /* Swap */,
|
|
3878
|
+
"swap-tokens": "swap" /* Swap */,
|
|
3879
|
+
"convert": "swap" /* Swap */,
|
|
3880
|
+
// Points operations
|
|
3881
|
+
"promote": "promote" /* Promote */,
|
|
3882
|
+
"promote-post": "promote" /* Promote */,
|
|
3883
|
+
"promote-entry": "promote" /* Promote */,
|
|
3884
|
+
"boost": "promote" /* Promote */,
|
|
3885
|
+
"gift": "gift" /* Gift */,
|
|
3886
|
+
"gift-points": "gift" /* Gift */,
|
|
3887
|
+
"points-gift": "gift" /* Gift */,
|
|
3888
|
+
"claim": "claim" /* Claim */,
|
|
3889
|
+
"claim-rewards": "claim" /* Claim */,
|
|
3890
|
+
"claim-points": "claim" /* Claim */,
|
|
3891
|
+
"buy": "buy" /* Buy */,
|
|
3892
|
+
"buy-points": "buy" /* Buy */,
|
|
3893
|
+
// Other
|
|
3894
|
+
"claim-interest": "claim-interest" /* ClaimInterest */,
|
|
3895
|
+
"withdraw-routes": "withdraw-routes" /* WithdrawRoutes */,
|
|
3896
|
+
"withdrawroutes": "withdraw-routes" /* WithdrawRoutes */,
|
|
3897
|
+
"lock": "lock" /* LockLiquidity */,
|
|
3898
|
+
"lock-liquidity": "lock" /* LockLiquidity */,
|
|
3899
|
+
"lock-liq": "lock" /* LockLiquidity */
|
|
3900
|
+
};
|
|
3901
|
+
const mapped = aliasMap[canonical];
|
|
3902
|
+
if (mapped) return mapped;
|
|
3903
|
+
const directMatch = Object.values(AssetOperation).find(
|
|
3904
|
+
(op) => op.toLowerCase() === canonical
|
|
3905
|
+
);
|
|
3906
|
+
return directMatch;
|
|
3907
|
+
}).filter((op) => Boolean(op));
|
|
3908
|
+
const isHiveOrHbd = ["HIVE", "HBD"].includes(normalizedToken);
|
|
3909
|
+
const hasSavings = Number(assetEntry.savings ?? 0) > 0;
|
|
3910
|
+
if (isHiveOrHbd && !hasSavings) {
|
|
3909
3911
|
return operations.filter(
|
|
3910
3912
|
(operation) => operation !== "withdraw-saving" /* WithdrawFromSavings */
|
|
3911
3913
|
);
|