@ecency/wallets 1.4.17 → 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 +84 -2
- package/dist/browser/index.js +137 -13
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +138 -12
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +137 -13
- 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";
|
|
@@ -2264,7 +2359,7 @@ function getPointsAssetTransactionsQueryOptions(username, type) {
|
|
|
2264
2359
|
}
|
|
2265
2360
|
);
|
|
2266
2361
|
const data = await response.json();
|
|
2267
|
-
return data.map(({ created, type: type2, amount, id }) => ({
|
|
2362
|
+
return data.map(({ created, type: type2, amount, id, sender, receiver, memo }) => ({
|
|
2268
2363
|
created: new Date(created),
|
|
2269
2364
|
type: type2,
|
|
2270
2365
|
results: [
|
|
@@ -2273,7 +2368,10 @@ function getPointsAssetTransactionsQueryOptions(username, type) {
|
|
|
2273
2368
|
asset: "POINTS"
|
|
2274
2369
|
}
|
|
2275
2370
|
],
|
|
2276
|
-
id
|
|
2371
|
+
id,
|
|
2372
|
+
from: sender ?? void 0,
|
|
2373
|
+
to: receiver ?? void 0,
|
|
2374
|
+
memo: memo ?? void 0
|
|
2277
2375
|
}));
|
|
2278
2376
|
}
|
|
2279
2377
|
});
|
|
@@ -2959,26 +3057,50 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false) {
|
|
|
2959
3057
|
return queryOptions({
|
|
2960
3058
|
queryKey: ["wallets", "token-operations", token, username, isForOwner],
|
|
2961
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
|
+
};
|
|
2962
3069
|
switch (token) {
|
|
2963
|
-
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;
|
|
2964
3075
|
return [
|
|
2965
3076
|
"transfer" /* Transfer */,
|
|
2966
3077
|
...isForOwner ? [
|
|
3078
|
+
...savingsBalance && savingsBalance > 0 ? ["withdraw-saving" /* WithdrawFromSavings */] : [],
|
|
2967
3079
|
"transfer-saving" /* TransferToSavings */,
|
|
2968
3080
|
"power-up" /* PowerUp */,
|
|
2969
3081
|
"swap" /* Swap */
|
|
2970
3082
|
] : []
|
|
2971
3083
|
];
|
|
3084
|
+
}
|
|
2972
3085
|
case "HP" /* HivePower */:
|
|
2973
3086
|
return [
|
|
2974
3087
|
"delegate" /* Delegate */,
|
|
2975
|
-
...isForOwner ? ["power-down" /* PowerDown */, "withdraw-
|
|
3088
|
+
...isForOwner ? ["power-down" /* PowerDown */, "withdraw-routes" /* WithdrawRoutes */] : ["power-up" /* PowerUp */]
|
|
2976
3089
|
];
|
|
2977
|
-
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;
|
|
2978
3095
|
return [
|
|
2979
3096
|
"transfer" /* Transfer */,
|
|
2980
|
-
...isForOwner ? [
|
|
3097
|
+
...isForOwner ? [
|
|
3098
|
+
...savingsBalance && savingsBalance > 0 ? ["withdraw-saving" /* WithdrawFromSavings */] : [],
|
|
3099
|
+
"transfer-saving" /* TransferToSavings */,
|
|
3100
|
+
"swap" /* Swap */
|
|
3101
|
+
] : []
|
|
2981
3102
|
];
|
|
3103
|
+
}
|
|
2982
3104
|
case "POINTS" /* Points */:
|
|
2983
3105
|
return [
|
|
2984
3106
|
"gift" /* Gift */,
|
|
@@ -3012,7 +3134,6 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false) {
|
|
|
3012
3134
|
if (!username) {
|
|
3013
3135
|
return ["transfer" /* Transfer */];
|
|
3014
3136
|
}
|
|
3015
|
-
const queryClient = getQueryClient();
|
|
3016
3137
|
const balancesListQuery = getHiveEngineTokensBalancesQueryOptions(username);
|
|
3017
3138
|
const balances = await queryClient.ensureQueryData(balancesListQuery);
|
|
3018
3139
|
const tokensQuery = getHiveEngineTokensMetadataQueryOptions(
|
|
@@ -3379,16 +3500,19 @@ var operationToFunctionMap = {
|
|
|
3379
3500
|
HIVE: {
|
|
3380
3501
|
["transfer" /* Transfer */]: transferHive,
|
|
3381
3502
|
["transfer-saving" /* TransferToSavings */]: transferToSavingsHive,
|
|
3503
|
+
["withdraw-saving" /* WithdrawFromSavings */]: transferFromSavingsHive,
|
|
3382
3504
|
["power-up" /* PowerUp */]: powerUpHive
|
|
3383
3505
|
},
|
|
3384
3506
|
HBD: {
|
|
3385
3507
|
["transfer" /* Transfer */]: transferHive,
|
|
3386
|
-
["transfer-saving" /* TransferToSavings */]: transferToSavingsHive
|
|
3508
|
+
["transfer-saving" /* TransferToSavings */]: transferToSavingsHive,
|
|
3509
|
+
["withdraw-saving" /* WithdrawFromSavings */]: transferFromSavingsHive,
|
|
3510
|
+
["claim-interest" /* ClaimInterest */]: claimInterestHive
|
|
3387
3511
|
},
|
|
3388
3512
|
HP: {
|
|
3389
3513
|
["power-down" /* PowerDown */]: powerDownHive,
|
|
3390
3514
|
["delegate" /* Delegate */]: delegateHive,
|
|
3391
|
-
["withdraw-
|
|
3515
|
+
["withdraw-routes" /* WithdrawRoutes */]: withdrawVestingRouteHive
|
|
3392
3516
|
},
|
|
3393
3517
|
POINTS: {
|
|
3394
3518
|
["gift" /* Gift */]: transferPoint
|
|
@@ -3452,6 +3576,6 @@ function useWalletOperation(username, asset, operation) {
|
|
|
3452
3576
|
// src/index.ts
|
|
3453
3577
|
rememberScryptBsvVersion();
|
|
3454
3578
|
|
|
3455
|
-
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 };
|
|
3456
3580
|
//# sourceMappingURL=index.mjs.map
|
|
3457
3581
|
//# sourceMappingURL=index.mjs.map
|