@ecency/wallets 1.4.18 → 1.4.19
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 +72 -2
- package/dist/browser/index.js +132 -11
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +133 -10
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +132 -11
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -654,11 +654,31 @@ function getHiveAssetGeneralInfoQueryOptions(username) {
|
|
|
654
654
|
);
|
|
655
655
|
const marketTicker = await CONFIG.hiveClient.call("condenser_api", "get_ticker", []).catch(() => void 0);
|
|
656
656
|
const marketPrice = Number.parseFloat(marketTicker?.latest ?? "");
|
|
657
|
+
if (!accountData) {
|
|
658
|
+
return {
|
|
659
|
+
name: "HIVE",
|
|
660
|
+
title: "Hive",
|
|
661
|
+
price: Number.isFinite(marketPrice) ? marketPrice : dynamicProps ? dynamicProps.base / dynamicProps.quote : 0,
|
|
662
|
+
accountBalance: 0
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
const liquidBalance = parseAsset(accountData.balance).amount;
|
|
666
|
+
const savingsBalance = parseAsset(accountData.savings_balance).amount;
|
|
657
667
|
return {
|
|
658
668
|
name: "HIVE",
|
|
659
669
|
title: "Hive",
|
|
660
670
|
price: Number.isFinite(marketPrice) ? marketPrice : dynamicProps ? dynamicProps.base / dynamicProps.quote : 0,
|
|
661
|
-
accountBalance:
|
|
671
|
+
accountBalance: liquidBalance + savingsBalance,
|
|
672
|
+
parts: [
|
|
673
|
+
{
|
|
674
|
+
name: "current",
|
|
675
|
+
balance: liquidBalance
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
name: "savings",
|
|
679
|
+
balance: savingsBalance
|
|
680
|
+
}
|
|
681
|
+
]
|
|
662
682
|
};
|
|
663
683
|
}
|
|
664
684
|
});
|
|
@@ -784,7 +804,7 @@ function getHbdAssetGeneralInfoQueryOptions(username) {
|
|
|
784
804
|
apr: ((dynamicProps?.hbdInterestRate ?? 0) / 100).toFixed(3),
|
|
785
805
|
parts: [
|
|
786
806
|
{
|
|
787
|
-
name: "
|
|
807
|
+
name: "current",
|
|
788
808
|
balance: parseAsset(accountData.hbd_balance).amount
|
|
789
809
|
},
|
|
790
810
|
{
|
|
@@ -1160,6 +1180,36 @@ async function transferToSavingsHive(payload) {
|
|
|
1160
1180
|
);
|
|
1161
1181
|
}
|
|
1162
1182
|
}
|
|
1183
|
+
async function transferFromSavingsHive(payload) {
|
|
1184
|
+
const requestId = payload.request_id ?? Date.now() >>> 0;
|
|
1185
|
+
const operationPayload = {
|
|
1186
|
+
from: payload.from,
|
|
1187
|
+
to: payload.to,
|
|
1188
|
+
amount: payload.amount,
|
|
1189
|
+
memo: payload.memo,
|
|
1190
|
+
request_id: requestId
|
|
1191
|
+
};
|
|
1192
|
+
if (payload.type === "key" && "key" in payload) {
|
|
1193
|
+
const { key } = payload;
|
|
1194
|
+
return CONFIG.hiveClient.broadcast.sendOperations(
|
|
1195
|
+
[["transfer_from_savings", operationPayload]],
|
|
1196
|
+
key
|
|
1197
|
+
);
|
|
1198
|
+
}
|
|
1199
|
+
if (payload.type === "keychain") {
|
|
1200
|
+
return Keychain.broadcast(
|
|
1201
|
+
payload.from,
|
|
1202
|
+
[["transfer_from_savings", operationPayload]],
|
|
1203
|
+
"Active"
|
|
1204
|
+
);
|
|
1205
|
+
}
|
|
1206
|
+
return hs.sendOperation(
|
|
1207
|
+
["transfer_from_savings", operationPayload],
|
|
1208
|
+
{ callback: `https://ecency.com/@${payload.from}/wallet` },
|
|
1209
|
+
() => {
|
|
1210
|
+
}
|
|
1211
|
+
);
|
|
1212
|
+
}
|
|
1163
1213
|
async function powerUpHive(payload) {
|
|
1164
1214
|
if (payload.type === "key" && "key" in payload) {
|
|
1165
1215
|
const { key, type, ...params } = payload;
|
|
@@ -1298,15 +1348,60 @@ function useClaimRewards(username, onSuccess) {
|
|
|
1298
1348
|
}
|
|
1299
1349
|
);
|
|
1300
1350
|
}
|
|
1351
|
+
async function claimInterestHive(payload) {
|
|
1352
|
+
const requestId = payload.request_id ?? Date.now() >>> 0;
|
|
1353
|
+
const baseOperation = {
|
|
1354
|
+
from: payload.from,
|
|
1355
|
+
to: payload.to,
|
|
1356
|
+
amount: payload.amount,
|
|
1357
|
+
memo: payload.memo,
|
|
1358
|
+
request_id: requestId
|
|
1359
|
+
};
|
|
1360
|
+
const cancelOperation = {
|
|
1361
|
+
from: payload.from,
|
|
1362
|
+
request_id: requestId
|
|
1363
|
+
};
|
|
1364
|
+
if (payload.type === "key" && "key" in payload) {
|
|
1365
|
+
const { key } = payload;
|
|
1366
|
+
return CONFIG.hiveClient.broadcast.sendOperations(
|
|
1367
|
+
[
|
|
1368
|
+
["transfer_from_savings", baseOperation],
|
|
1369
|
+
["cancel_transfer_from_savings", cancelOperation]
|
|
1370
|
+
],
|
|
1371
|
+
key
|
|
1372
|
+
);
|
|
1373
|
+
}
|
|
1374
|
+
if (payload.type === "keychain") {
|
|
1375
|
+
return Keychain.broadcast(
|
|
1376
|
+
payload.from,
|
|
1377
|
+
[
|
|
1378
|
+
["transfer_from_savings", baseOperation],
|
|
1379
|
+
["cancel_transfer_from_savings", cancelOperation]
|
|
1380
|
+
],
|
|
1381
|
+
"Active"
|
|
1382
|
+
);
|
|
1383
|
+
}
|
|
1384
|
+
return hs.sendOperations(
|
|
1385
|
+
[
|
|
1386
|
+
["transfer_from_savings", baseOperation],
|
|
1387
|
+
["cancel_transfer_from_savings", cancelOperation]
|
|
1388
|
+
],
|
|
1389
|
+
{ callback: `https://ecency.com/@${payload.from}/wallet` },
|
|
1390
|
+
() => {
|
|
1391
|
+
}
|
|
1392
|
+
);
|
|
1393
|
+
}
|
|
1301
1394
|
|
|
1302
1395
|
// src/modules/assets/types/asset-operation.ts
|
|
1303
1396
|
var AssetOperation = /* @__PURE__ */ ((AssetOperation2) => {
|
|
1304
1397
|
AssetOperation2["Transfer"] = "transfer";
|
|
1305
1398
|
AssetOperation2["TransferToSavings"] = "transfer-saving";
|
|
1399
|
+
AssetOperation2["WithdrawFromSavings"] = "withdraw-saving";
|
|
1306
1400
|
AssetOperation2["Delegate"] = "delegate";
|
|
1307
1401
|
AssetOperation2["PowerUp"] = "power-up";
|
|
1308
1402
|
AssetOperation2["PowerDown"] = "power-down";
|
|
1309
|
-
AssetOperation2["WithdrawRoutes"] = "withdraw-
|
|
1403
|
+
AssetOperation2["WithdrawRoutes"] = "withdraw-routes";
|
|
1404
|
+
AssetOperation2["ClaimInterest"] = "claim-interest";
|
|
1310
1405
|
AssetOperation2["Swap"] = "swap";
|
|
1311
1406
|
AssetOperation2["Gift"] = "gift";
|
|
1312
1407
|
AssetOperation2["Promote"] = "promote";
|
|
@@ -2962,26 +3057,50 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false) {
|
|
|
2962
3057
|
return queryOptions({
|
|
2963
3058
|
queryKey: ["wallets", "token-operations", token, username, isForOwner],
|
|
2964
3059
|
queryFn: async () => {
|
|
3060
|
+
const queryClient = getQueryClient();
|
|
3061
|
+
const ensureAssetInfo = async () => {
|
|
3062
|
+
if (!isForOwner || !username) {
|
|
3063
|
+
return void 0;
|
|
3064
|
+
}
|
|
3065
|
+
return await queryClient.ensureQueryData(
|
|
3066
|
+
getAccountWalletAssetInfoQueryOptions(username, token)
|
|
3067
|
+
);
|
|
3068
|
+
};
|
|
2965
3069
|
switch (token) {
|
|
2966
|
-
case "HIVE" /* Hive */:
|
|
3070
|
+
case "HIVE" /* Hive */: {
|
|
3071
|
+
const assetInfo = await ensureAssetInfo();
|
|
3072
|
+
const savingsBalance = assetInfo?.parts?.find(
|
|
3073
|
+
(part) => part.name === "savings"
|
|
3074
|
+
)?.balance;
|
|
2967
3075
|
return [
|
|
2968
3076
|
"transfer" /* Transfer */,
|
|
2969
3077
|
...isForOwner ? [
|
|
3078
|
+
...savingsBalance && savingsBalance > 0 ? ["withdraw-saving" /* WithdrawFromSavings */] : [],
|
|
2970
3079
|
"transfer-saving" /* TransferToSavings */,
|
|
2971
3080
|
"power-up" /* PowerUp */,
|
|
2972
3081
|
"swap" /* Swap */
|
|
2973
3082
|
] : []
|
|
2974
3083
|
];
|
|
3084
|
+
}
|
|
2975
3085
|
case "HP" /* HivePower */:
|
|
2976
3086
|
return [
|
|
2977
3087
|
"delegate" /* Delegate */,
|
|
2978
|
-
...isForOwner ? ["power-down" /* PowerDown */, "withdraw-
|
|
3088
|
+
...isForOwner ? ["power-down" /* PowerDown */, "withdraw-routes" /* WithdrawRoutes */] : ["power-up" /* PowerUp */]
|
|
2979
3089
|
];
|
|
2980
|
-
case "HBD" /* HiveDollar */:
|
|
3090
|
+
case "HBD" /* HiveDollar */: {
|
|
3091
|
+
const assetInfo = await ensureAssetInfo();
|
|
3092
|
+
const savingsBalance = assetInfo?.parts?.find(
|
|
3093
|
+
(part) => part.name === "savings"
|
|
3094
|
+
)?.balance;
|
|
2981
3095
|
return [
|
|
2982
3096
|
"transfer" /* Transfer */,
|
|
2983
|
-
...isForOwner ? [
|
|
3097
|
+
...isForOwner ? [
|
|
3098
|
+
...savingsBalance && savingsBalance > 0 ? ["withdraw-saving" /* WithdrawFromSavings */] : [],
|
|
3099
|
+
"transfer-saving" /* TransferToSavings */,
|
|
3100
|
+
"swap" /* Swap */
|
|
3101
|
+
] : []
|
|
2984
3102
|
];
|
|
3103
|
+
}
|
|
2985
3104
|
case "POINTS" /* Points */:
|
|
2986
3105
|
return [
|
|
2987
3106
|
"gift" /* Gift */,
|
|
@@ -3015,7 +3134,6 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false) {
|
|
|
3015
3134
|
if (!username) {
|
|
3016
3135
|
return ["transfer" /* Transfer */];
|
|
3017
3136
|
}
|
|
3018
|
-
const queryClient = getQueryClient();
|
|
3019
3137
|
const balancesListQuery = getHiveEngineTokensBalancesQueryOptions(username);
|
|
3020
3138
|
const balances = await queryClient.ensureQueryData(balancesListQuery);
|
|
3021
3139
|
const tokensQuery = getHiveEngineTokensMetadataQueryOptions(
|
|
@@ -3382,16 +3500,19 @@ var operationToFunctionMap = {
|
|
|
3382
3500
|
HIVE: {
|
|
3383
3501
|
["transfer" /* Transfer */]: transferHive,
|
|
3384
3502
|
["transfer-saving" /* TransferToSavings */]: transferToSavingsHive,
|
|
3503
|
+
["withdraw-saving" /* WithdrawFromSavings */]: transferFromSavingsHive,
|
|
3385
3504
|
["power-up" /* PowerUp */]: powerUpHive
|
|
3386
3505
|
},
|
|
3387
3506
|
HBD: {
|
|
3388
3507
|
["transfer" /* Transfer */]: transferHive,
|
|
3389
|
-
["transfer-saving" /* TransferToSavings */]: transferToSavingsHive
|
|
3508
|
+
["transfer-saving" /* TransferToSavings */]: transferToSavingsHive,
|
|
3509
|
+
["withdraw-saving" /* WithdrawFromSavings */]: transferFromSavingsHive,
|
|
3510
|
+
["claim-interest" /* ClaimInterest */]: claimInterestHive
|
|
3390
3511
|
},
|
|
3391
3512
|
HP: {
|
|
3392
3513
|
["power-down" /* PowerDown */]: powerDownHive,
|
|
3393
3514
|
["delegate" /* Delegate */]: delegateHive,
|
|
3394
|
-
["withdraw-
|
|
3515
|
+
["withdraw-routes" /* WithdrawRoutes */]: withdrawVestingRouteHive
|
|
3395
3516
|
},
|
|
3396
3517
|
POINTS: {
|
|
3397
3518
|
["gift" /* Gift */]: transferPoint
|
|
@@ -3455,6 +3576,6 @@ function useWalletOperation(username, asset, operation) {
|
|
|
3455
3576
|
// src/index.ts
|
|
3456
3577
|
rememberScryptBsvVersion();
|
|
3457
3578
|
|
|
3458
|
-
export { AssetOperation, EcencyWalletBasicTokens, EcencyWalletCurrency, private_api_exports as EcencyWalletsPrivateApi, NaiMap, PointTransactionType, Symbol2 as Symbol, buildAptTx, buildEthTx, buildExternalTx, buildPsbt, buildSolTx, buildTonTx, buildTronTx, decryptMemoWithAccounts, decryptMemoWithKeys, delay, delegateEngineToken, delegateHive, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, encryptMemoWithAccounts, encryptMemoWithKeys, getAccountWalletAssetInfoQueryOptions, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getBoundFetch, getHbdAssetGeneralInfoQueryOptions, getHbdAssetTransactionsQueryOptions, getHiveAssetGeneralInfoQueryOptions, getHiveAssetMetricQueryOptions, getHiveAssetTransactionsQueryOptions, getHiveAssetWithdrawalRoutesQueryOptions, getHiveEngineTokenGeneralInfoQueryOptions, getHiveEngineTokenTransactionsQueryOptions, getHiveEngineTokensBalancesQueryOptions, getHiveEngineTokensMarketQueryOptions, getHiveEngineTokensMetadataQueryOptions, getHiveEngineTokensMetricsQueryOptions, getHivePowerAssetGeneralInfoQueryOptions, getHivePowerAssetTransactionsQueryOptions, getHivePowerDelegatesInfiniteQueryOptions, getHivePowerDelegatingsQueryOptions, getLarynxAssetGeneralInfoQueryOptions, getLarynxPowerAssetGeneralInfoQueryOptions, getPointsAssetGeneralInfoQueryOptions, getPointsAssetTransactionsQueryOptions, getPointsQueryOptions, getSpkAssetGeneralInfoQueryOptions, getSpkMarketsQueryOptions, getTokenOperationsQueryOptions, getTokenPriceQueryOptions, getWallet, isEmptyDate, lockLarynx, mnemonicToSeedBip39, parseAsset, powerDownHive, powerUpHive, powerUpLarynx, rewardSpk, signDigest, signExternalTx, signExternalTxAndBroadcast, signTx, signTxAndBroadcast, stakeEngineToken, transferEngineToken, transferHive, transferLarynx, transferPoint, transferSpk, transferToSavingsHive, undelegateEngineToken, unstakeEngineToken, useClaimPoints, useClaimRewards, useGetExternalWalletBalanceQuery, useHiveKeysQuery, useImportWallet, useSaveWalletInformationToMetadata, useSeedPhrase, useWalletCreate, useWalletOperation, useWalletsCacheQuery, vestsToHp, withdrawVestingRouteHive };
|
|
3579
|
+
export { AssetOperation, EcencyWalletBasicTokens, EcencyWalletCurrency, private_api_exports as EcencyWalletsPrivateApi, NaiMap, PointTransactionType, Symbol2 as Symbol, buildAptTx, buildEthTx, buildExternalTx, buildPsbt, buildSolTx, buildTonTx, buildTronTx, claimInterestHive, decryptMemoWithAccounts, decryptMemoWithKeys, delay, delegateEngineToken, delegateHive, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, encryptMemoWithAccounts, encryptMemoWithKeys, getAccountWalletAssetInfoQueryOptions, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getBoundFetch, getHbdAssetGeneralInfoQueryOptions, getHbdAssetTransactionsQueryOptions, getHiveAssetGeneralInfoQueryOptions, getHiveAssetMetricQueryOptions, getHiveAssetTransactionsQueryOptions, getHiveAssetWithdrawalRoutesQueryOptions, getHiveEngineTokenGeneralInfoQueryOptions, getHiveEngineTokenTransactionsQueryOptions, getHiveEngineTokensBalancesQueryOptions, getHiveEngineTokensMarketQueryOptions, getHiveEngineTokensMetadataQueryOptions, getHiveEngineTokensMetricsQueryOptions, getHivePowerAssetGeneralInfoQueryOptions, getHivePowerAssetTransactionsQueryOptions, getHivePowerDelegatesInfiniteQueryOptions, getHivePowerDelegatingsQueryOptions, getLarynxAssetGeneralInfoQueryOptions, getLarynxPowerAssetGeneralInfoQueryOptions, getPointsAssetGeneralInfoQueryOptions, getPointsAssetTransactionsQueryOptions, getPointsQueryOptions, getSpkAssetGeneralInfoQueryOptions, getSpkMarketsQueryOptions, getTokenOperationsQueryOptions, getTokenPriceQueryOptions, getWallet, isEmptyDate, lockLarynx, mnemonicToSeedBip39, parseAsset, powerDownHive, powerUpHive, powerUpLarynx, rewardSpk, signDigest, signExternalTx, signExternalTxAndBroadcast, signTx, signTxAndBroadcast, stakeEngineToken, transferEngineToken, transferFromSavingsHive, transferHive, transferLarynx, transferPoint, transferSpk, transferToSavingsHive, undelegateEngineToken, unstakeEngineToken, useClaimPoints, useClaimRewards, useGetExternalWalletBalanceQuery, useHiveKeysQuery, useImportWallet, useSaveWalletInformationToMetadata, useSeedPhrase, useWalletCreate, useWalletOperation, useWalletsCacheQuery, vestsToHp, withdrawVestingRouteHive };
|
|
3459
3580
|
//# sourceMappingURL=index.mjs.map
|
|
3460
3581
|
//# sourceMappingURL=index.mjs.map
|