@ecency/wallets 1.4.18 → 1.4.20
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 +229 -29
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +230 -28
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +229 -29
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -129,17 +129,47 @@ declare function getHiveAssetGeneralInfoQueryOptions(username: string): _tanstac
|
|
|
129
129
|
title: string;
|
|
130
130
|
price: number;
|
|
131
131
|
accountBalance: number;
|
|
132
|
+
parts?: undefined;
|
|
133
|
+
} | {
|
|
134
|
+
name: string;
|
|
135
|
+
title: string;
|
|
136
|
+
price: number;
|
|
137
|
+
accountBalance: number;
|
|
138
|
+
parts: {
|
|
139
|
+
name: string;
|
|
140
|
+
balance: number;
|
|
141
|
+
}[];
|
|
132
142
|
}, Error, {
|
|
133
143
|
name: string;
|
|
134
144
|
title: string;
|
|
135
145
|
price: number;
|
|
136
146
|
accountBalance: number;
|
|
147
|
+
parts?: undefined;
|
|
148
|
+
} | {
|
|
149
|
+
name: string;
|
|
150
|
+
title: string;
|
|
151
|
+
price: number;
|
|
152
|
+
accountBalance: number;
|
|
153
|
+
parts: {
|
|
154
|
+
name: string;
|
|
155
|
+
balance: number;
|
|
156
|
+
}[];
|
|
137
157
|
}, string[]>, "queryFn"> & {
|
|
138
158
|
queryFn?: _tanstack_react_query.QueryFunction<{
|
|
139
159
|
name: string;
|
|
140
160
|
title: string;
|
|
141
161
|
price: number;
|
|
142
162
|
accountBalance: number;
|
|
163
|
+
parts?: undefined;
|
|
164
|
+
} | {
|
|
165
|
+
name: string;
|
|
166
|
+
title: string;
|
|
167
|
+
price: number;
|
|
168
|
+
accountBalance: number;
|
|
169
|
+
parts: {
|
|
170
|
+
name: string;
|
|
171
|
+
balance: number;
|
|
172
|
+
}[];
|
|
143
173
|
}, string[], never> | undefined;
|
|
144
174
|
} & {
|
|
145
175
|
queryKey: string[] & {
|
|
@@ -148,6 +178,16 @@ declare function getHiveAssetGeneralInfoQueryOptions(username: string): _tanstac
|
|
|
148
178
|
title: string;
|
|
149
179
|
price: number;
|
|
150
180
|
accountBalance: number;
|
|
181
|
+
parts?: undefined;
|
|
182
|
+
} | {
|
|
183
|
+
name: string;
|
|
184
|
+
title: string;
|
|
185
|
+
price: number;
|
|
186
|
+
accountBalance: number;
|
|
187
|
+
parts: {
|
|
188
|
+
name: string;
|
|
189
|
+
balance: number;
|
|
190
|
+
}[];
|
|
151
191
|
};
|
|
152
192
|
[dataTagErrorSymbol]: Error;
|
|
153
193
|
};
|
|
@@ -697,10 +737,12 @@ interface TransformedSpkMarkets {
|
|
|
697
737
|
declare enum AssetOperation {
|
|
698
738
|
Transfer = "transfer",
|
|
699
739
|
TransferToSavings = "transfer-saving",
|
|
740
|
+
WithdrawFromSavings = "withdraw-saving",
|
|
700
741
|
Delegate = "delegate",
|
|
701
742
|
PowerUp = "power-up",
|
|
702
743
|
PowerDown = "power-down",
|
|
703
|
-
WithdrawRoutes = "withdraw-
|
|
744
|
+
WithdrawRoutes = "withdraw-routes",
|
|
745
|
+
ClaimInterest = "claim-interest",
|
|
704
746
|
Swap = "swap",
|
|
705
747
|
Gift = "gift",
|
|
706
748
|
Promote = "promote",
|
|
@@ -749,6 +791,20 @@ declare function transferToSavingsHive<T extends HiveBasedAssetSignType>(payload
|
|
|
749
791
|
key: PrivateKey;
|
|
750
792
|
} : Payload$4<T>): Promise<unknown>;
|
|
751
793
|
|
|
794
|
+
interface PayloadBase$1 {
|
|
795
|
+
from: string;
|
|
796
|
+
to: string;
|
|
797
|
+
amount: string;
|
|
798
|
+
memo: string;
|
|
799
|
+
request_id?: number;
|
|
800
|
+
}
|
|
801
|
+
interface PayloadWithKey$1<T extends HiveBasedAssetSignType> extends PayloadBase$1 {
|
|
802
|
+
type: T;
|
|
803
|
+
}
|
|
804
|
+
declare function transferFromSavingsHive<T extends HiveBasedAssetSignType>(payload: T extends "key" ? PayloadWithKey$1<T> & {
|
|
805
|
+
key: PrivateKey;
|
|
806
|
+
} : PayloadWithKey$1<T>): Promise<unknown>;
|
|
807
|
+
|
|
752
808
|
interface Payload$3<T extends HiveBasedAssetSignType> {
|
|
753
809
|
from: string;
|
|
754
810
|
to: string;
|
|
@@ -793,6 +849,20 @@ declare function withdrawVestingRouteHive<T extends HiveBasedAssetSignType>(payl
|
|
|
793
849
|
|
|
794
850
|
declare function useClaimRewards(username: string, onSuccess: () => void): ReturnType<typeof useBroadcastMutation<void>>;
|
|
795
851
|
|
|
852
|
+
interface PayloadBase {
|
|
853
|
+
from: string;
|
|
854
|
+
to: string;
|
|
855
|
+
amount: string;
|
|
856
|
+
memo: string;
|
|
857
|
+
request_id?: number;
|
|
858
|
+
}
|
|
859
|
+
interface PayloadWithKey<T extends HiveBasedAssetSignType> extends PayloadBase {
|
|
860
|
+
type: T;
|
|
861
|
+
}
|
|
862
|
+
declare function claimInterestHive<T extends HiveBasedAssetSignType>(payload: T extends "key" ? PayloadWithKey<T> & {
|
|
863
|
+
key: PrivateKey;
|
|
864
|
+
} : PayloadWithKey<T>): Promise<unknown>;
|
|
865
|
+
|
|
796
866
|
declare enum Symbol {
|
|
797
867
|
HIVE = "HIVE",
|
|
798
868
|
HBD = "HBD",
|
|
@@ -1681,4 +1751,4 @@ declare function buildExternalTx(currency: EcencyWalletCurrency, tx: ExternalTxP
|
|
|
1681
1751
|
|
|
1682
1752
|
declare function getBoundFetch(): typeof fetch;
|
|
1683
1753
|
|
|
1684
|
-
export { type AccountPointsResponse, type Asset, AssetOperation, type DelegateEnginePayload, type EcencyHiveKeys, type EcencyTokenMetadata, EcencyWalletBasicTokens, EcencyWalletCurrency, index as EcencyWalletsPrivateApi, type ExternalTxParams, type ExternalWalletBalance, type GeneralAssetInfo, type GeneralAssetTransaction, type HiveBasedAssetSignType, type HiveEngineMarketResponse, type HiveEngineMetric, type HiveEngineTokenBalance, type HiveEngineTokenMetadataResponse, type HiveEngineTransaction, type HiveKeyDerivation, type HiveRole, NaiMap, type PointTransaction, PointTransactionType, type Points, type PointsResponse, type SpkApiWallet, type SpkMarkets, type StakeEnginePayload, Symbol, type TransferEnginePayload, type TransferPayload, type TransformedSpkMarkets, type UndelegateEnginePayload, type UnstakeEnginePayload, 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 };
|
|
1754
|
+
export { type AccountPointsResponse, type Asset, AssetOperation, type DelegateEnginePayload, type EcencyHiveKeys, type EcencyTokenMetadata, EcencyWalletBasicTokens, EcencyWalletCurrency, index as EcencyWalletsPrivateApi, type ExternalTxParams, type ExternalWalletBalance, type GeneralAssetInfo, type GeneralAssetTransaction, type HiveBasedAssetSignType, type HiveEngineMarketResponse, type HiveEngineMetric, type HiveEngineTokenBalance, type HiveEngineTokenMetadataResponse, type HiveEngineTransaction, type HiveKeyDerivation, type HiveRole, NaiMap, type PointTransaction, PointTransactionType, type Points, type PointsResponse, type SpkApiWallet, type SpkMarkets, type StakeEnginePayload, Symbol, type TransferEnginePayload, type TransferPayload, type TransformedSpkMarkets, type UndelegateEnginePayload, type UnstakeEnginePayload, 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 };
|
package/dist/browser/index.js
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
|
});
|
|
@@ -707,33 +727,76 @@ function getHivePowerAssetGeneralInfoQueryOptions(username) {
|
|
|
707
727
|
const marketTicker = await CONFIG.hiveClient.call("condenser_api", "get_ticker", []).catch(() => void 0);
|
|
708
728
|
const marketPrice = Number.parseFloat(marketTicker?.latest ?? "");
|
|
709
729
|
const price = Number.isFinite(marketPrice) ? marketPrice : dynamicProps.base / dynamicProps.quote;
|
|
730
|
+
const vestingShares = parseAsset(accountData.vesting_shares).amount;
|
|
731
|
+
const delegatedVests = parseAsset(accountData.delegated_vesting_shares).amount;
|
|
732
|
+
const receivedVests = parseAsset(accountData.received_vesting_shares).amount;
|
|
733
|
+
const withdrawRateVests = parseAsset(accountData.vesting_withdraw_rate).amount;
|
|
734
|
+
const remainingToWithdrawVests = Math.max(
|
|
735
|
+
(Number(accountData.to_withdraw) - Number(accountData.withdrawn)) / 1e6,
|
|
736
|
+
0
|
|
737
|
+
);
|
|
738
|
+
const nextWithdrawalVests = !isEmptyDate(accountData.next_vesting_withdrawal) ? Math.min(withdrawRateVests, remainingToWithdrawVests) : 0;
|
|
739
|
+
const hpBalance = +vestsToHp(
|
|
740
|
+
vestingShares,
|
|
741
|
+
dynamicProps.hivePerMVests
|
|
742
|
+
).toFixed(3);
|
|
743
|
+
const outgoingDelegationsHp = +vestsToHp(
|
|
744
|
+
delegatedVests,
|
|
745
|
+
dynamicProps.hivePerMVests
|
|
746
|
+
).toFixed(3);
|
|
747
|
+
const incomingDelegationsHp = +vestsToHp(
|
|
748
|
+
receivedVests,
|
|
749
|
+
dynamicProps.hivePerMVests
|
|
750
|
+
).toFixed(3);
|
|
751
|
+
const pendingPowerDownHp = +vestsToHp(
|
|
752
|
+
remainingToWithdrawVests,
|
|
753
|
+
dynamicProps.hivePerMVests
|
|
754
|
+
).toFixed(3);
|
|
755
|
+
const nextPowerDownHp = +vestsToHp(
|
|
756
|
+
nextWithdrawalVests,
|
|
757
|
+
dynamicProps.hivePerMVests
|
|
758
|
+
).toFixed(3);
|
|
759
|
+
const totalBalance = Math.max(hpBalance - pendingPowerDownHp, 0);
|
|
760
|
+
const availableHp = Math.max(
|
|
761
|
+
// Owned HP minus the portions already delegated away.
|
|
762
|
+
hpBalance - outgoingDelegationsHp,
|
|
763
|
+
0
|
|
764
|
+
);
|
|
710
765
|
return {
|
|
711
766
|
name: "HP",
|
|
712
767
|
title: "Hive Power",
|
|
713
768
|
price,
|
|
714
|
-
accountBalance: +
|
|
715
|
-
parseAsset(accountData.vesting_shares).amount,
|
|
716
|
-
// parseAsset(accountData.delegated_vesting_shares).amount +
|
|
717
|
-
// parseAsset(accountData.received_vesting_shares).amount -
|
|
718
|
-
// nextVestingSharesWithdrawal,
|
|
719
|
-
dynamicProps.hivePerMVests
|
|
720
|
-
).toFixed(3),
|
|
769
|
+
accountBalance: +totalBalance.toFixed(3),
|
|
721
770
|
apr: getAPR(dynamicProps),
|
|
722
771
|
parts: [
|
|
723
772
|
{
|
|
724
|
-
name: "
|
|
725
|
-
balance:
|
|
726
|
-
parseAsset(accountData.delegated_vesting_shares).amount,
|
|
727
|
-
dynamicProps.hivePerMVests
|
|
728
|
-
).toFixed(3)
|
|
773
|
+
name: "hp_balance",
|
|
774
|
+
balance: hpBalance
|
|
729
775
|
},
|
|
730
776
|
{
|
|
731
|
-
name: "
|
|
732
|
-
balance: +
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
777
|
+
name: "available",
|
|
778
|
+
balance: +availableHp.toFixed(3)
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
name: "outgoing_delegations",
|
|
782
|
+
balance: outgoingDelegationsHp
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
name: "incoming_delegations",
|
|
786
|
+
balance: incomingDelegationsHp
|
|
787
|
+
},
|
|
788
|
+
...pendingPowerDownHp > 0 ? [
|
|
789
|
+
{
|
|
790
|
+
name: "pending_power_down",
|
|
791
|
+
balance: +pendingPowerDownHp.toFixed(3)
|
|
792
|
+
}
|
|
793
|
+
] : [],
|
|
794
|
+
...nextPowerDownHp > 0 && nextPowerDownHp !== pendingPowerDownHp ? [
|
|
795
|
+
{
|
|
796
|
+
name: "next_power_down",
|
|
797
|
+
balance: +nextPowerDownHp.toFixed(3)
|
|
798
|
+
}
|
|
799
|
+
] : []
|
|
737
800
|
]
|
|
738
801
|
};
|
|
739
802
|
}
|
|
@@ -784,7 +847,7 @@ function getHbdAssetGeneralInfoQueryOptions(username) {
|
|
|
784
847
|
apr: ((dynamicProps?.hbdInterestRate ?? 0) / 100).toFixed(3),
|
|
785
848
|
parts: [
|
|
786
849
|
{
|
|
787
|
-
name: "
|
|
850
|
+
name: "current",
|
|
788
851
|
balance: parseAsset(accountData.hbd_balance).amount
|
|
789
852
|
},
|
|
790
853
|
{
|
|
@@ -1160,6 +1223,36 @@ async function transferToSavingsHive(payload) {
|
|
|
1160
1223
|
);
|
|
1161
1224
|
}
|
|
1162
1225
|
}
|
|
1226
|
+
async function transferFromSavingsHive(payload) {
|
|
1227
|
+
const requestId = payload.request_id ?? Date.now() >>> 0;
|
|
1228
|
+
const operationPayload = {
|
|
1229
|
+
from: payload.from,
|
|
1230
|
+
to: payload.to,
|
|
1231
|
+
amount: payload.amount,
|
|
1232
|
+
memo: payload.memo,
|
|
1233
|
+
request_id: requestId
|
|
1234
|
+
};
|
|
1235
|
+
if (payload.type === "key" && "key" in payload) {
|
|
1236
|
+
const { key } = payload;
|
|
1237
|
+
return CONFIG.hiveClient.broadcast.sendOperations(
|
|
1238
|
+
[["transfer_from_savings", operationPayload]],
|
|
1239
|
+
key
|
|
1240
|
+
);
|
|
1241
|
+
}
|
|
1242
|
+
if (payload.type === "keychain") {
|
|
1243
|
+
return Keychain.broadcast(
|
|
1244
|
+
payload.from,
|
|
1245
|
+
[["transfer_from_savings", operationPayload]],
|
|
1246
|
+
"Active"
|
|
1247
|
+
);
|
|
1248
|
+
}
|
|
1249
|
+
return hs.sendOperation(
|
|
1250
|
+
["transfer_from_savings", operationPayload],
|
|
1251
|
+
{ callback: `https://ecency.com/@${payload.from}/wallet` },
|
|
1252
|
+
() => {
|
|
1253
|
+
}
|
|
1254
|
+
);
|
|
1255
|
+
}
|
|
1163
1256
|
async function powerUpHive(payload) {
|
|
1164
1257
|
if (payload.type === "key" && "key" in payload) {
|
|
1165
1258
|
const { key, type, ...params } = payload;
|
|
@@ -1298,15 +1391,60 @@ function useClaimRewards(username, onSuccess) {
|
|
|
1298
1391
|
}
|
|
1299
1392
|
);
|
|
1300
1393
|
}
|
|
1394
|
+
async function claimInterestHive(payload) {
|
|
1395
|
+
const requestId = payload.request_id ?? Date.now() >>> 0;
|
|
1396
|
+
const baseOperation = {
|
|
1397
|
+
from: payload.from,
|
|
1398
|
+
to: payload.to,
|
|
1399
|
+
amount: payload.amount,
|
|
1400
|
+
memo: payload.memo,
|
|
1401
|
+
request_id: requestId
|
|
1402
|
+
};
|
|
1403
|
+
const cancelOperation = {
|
|
1404
|
+
from: payload.from,
|
|
1405
|
+
request_id: requestId
|
|
1406
|
+
};
|
|
1407
|
+
if (payload.type === "key" && "key" in payload) {
|
|
1408
|
+
const { key } = payload;
|
|
1409
|
+
return CONFIG.hiveClient.broadcast.sendOperations(
|
|
1410
|
+
[
|
|
1411
|
+
["transfer_from_savings", baseOperation],
|
|
1412
|
+
["cancel_transfer_from_savings", cancelOperation]
|
|
1413
|
+
],
|
|
1414
|
+
key
|
|
1415
|
+
);
|
|
1416
|
+
}
|
|
1417
|
+
if (payload.type === "keychain") {
|
|
1418
|
+
return Keychain.broadcast(
|
|
1419
|
+
payload.from,
|
|
1420
|
+
[
|
|
1421
|
+
["transfer_from_savings", baseOperation],
|
|
1422
|
+
["cancel_transfer_from_savings", cancelOperation]
|
|
1423
|
+
],
|
|
1424
|
+
"Active"
|
|
1425
|
+
);
|
|
1426
|
+
}
|
|
1427
|
+
return hs.sendOperations(
|
|
1428
|
+
[
|
|
1429
|
+
["transfer_from_savings", baseOperation],
|
|
1430
|
+
["cancel_transfer_from_savings", cancelOperation]
|
|
1431
|
+
],
|
|
1432
|
+
{ callback: `https://ecency.com/@${payload.from}/wallet` },
|
|
1433
|
+
() => {
|
|
1434
|
+
}
|
|
1435
|
+
);
|
|
1436
|
+
}
|
|
1301
1437
|
|
|
1302
1438
|
// src/modules/assets/types/asset-operation.ts
|
|
1303
1439
|
var AssetOperation = /* @__PURE__ */ ((AssetOperation2) => {
|
|
1304
1440
|
AssetOperation2["Transfer"] = "transfer";
|
|
1305
1441
|
AssetOperation2["TransferToSavings"] = "transfer-saving";
|
|
1442
|
+
AssetOperation2["WithdrawFromSavings"] = "withdraw-saving";
|
|
1306
1443
|
AssetOperation2["Delegate"] = "delegate";
|
|
1307
1444
|
AssetOperation2["PowerUp"] = "power-up";
|
|
1308
1445
|
AssetOperation2["PowerDown"] = "power-down";
|
|
1309
|
-
AssetOperation2["WithdrawRoutes"] = "withdraw-
|
|
1446
|
+
AssetOperation2["WithdrawRoutes"] = "withdraw-routes";
|
|
1447
|
+
AssetOperation2["ClaimInterest"] = "claim-interest";
|
|
1310
1448
|
AssetOperation2["Swap"] = "swap";
|
|
1311
1449
|
AssetOperation2["Gift"] = "gift";
|
|
1312
1450
|
AssetOperation2["Promote"] = "promote";
|
|
@@ -2962,26 +3100,86 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false) {
|
|
|
2962
3100
|
return queryOptions({
|
|
2963
3101
|
queryKey: ["wallets", "token-operations", token, username, isForOwner],
|
|
2964
3102
|
queryFn: async () => {
|
|
3103
|
+
const queryClient = getQueryClient();
|
|
3104
|
+
const ensureAssetInfo = async () => {
|
|
3105
|
+
if (!isForOwner || !username) {
|
|
3106
|
+
return void 0;
|
|
3107
|
+
}
|
|
3108
|
+
return await queryClient.ensureQueryData(
|
|
3109
|
+
getAccountWalletAssetInfoQueryOptions(username, token)
|
|
3110
|
+
);
|
|
3111
|
+
};
|
|
2965
3112
|
switch (token) {
|
|
2966
|
-
case "HIVE" /* Hive */:
|
|
3113
|
+
case "HIVE" /* Hive */: {
|
|
3114
|
+
const assetInfo = await ensureAssetInfo();
|
|
3115
|
+
const savingsBalance = assetInfo?.parts?.find(
|
|
3116
|
+
(part) => part.name === "savings"
|
|
3117
|
+
)?.balance;
|
|
3118
|
+
const pendingSavingsWithdrawAmount = await (async () => {
|
|
3119
|
+
if (!isForOwner || !username) {
|
|
3120
|
+
return 0;
|
|
3121
|
+
}
|
|
3122
|
+
try {
|
|
3123
|
+
const response = await CONFIG.hiveClient.database.call(
|
|
3124
|
+
"get_savings_withdraw_from",
|
|
3125
|
+
[username]
|
|
3126
|
+
);
|
|
3127
|
+
return response.reduce((total, request) => {
|
|
3128
|
+
const parsed = parseAsset(request.amount);
|
|
3129
|
+
return parsed.symbol === "HIVE" /* HIVE */ ? total + parsed.amount : total;
|
|
3130
|
+
}, 0);
|
|
3131
|
+
} catch {
|
|
3132
|
+
return 0;
|
|
3133
|
+
}
|
|
3134
|
+
})();
|
|
3135
|
+
const hasAvailableSavingsWithdraw = typeof savingsBalance === "number" && savingsBalance - pendingSavingsWithdrawAmount > 1e-6;
|
|
2967
3136
|
return [
|
|
2968
3137
|
"transfer" /* Transfer */,
|
|
2969
3138
|
...isForOwner ? [
|
|
3139
|
+
...hasAvailableSavingsWithdraw ? ["withdraw-saving" /* WithdrawFromSavings */] : [],
|
|
2970
3140
|
"transfer-saving" /* TransferToSavings */,
|
|
2971
3141
|
"power-up" /* PowerUp */,
|
|
2972
3142
|
"swap" /* Swap */
|
|
2973
3143
|
] : []
|
|
2974
3144
|
];
|
|
3145
|
+
}
|
|
2975
3146
|
case "HP" /* HivePower */:
|
|
2976
3147
|
return [
|
|
2977
3148
|
"delegate" /* Delegate */,
|
|
2978
|
-
...isForOwner ? ["power-down" /* PowerDown */, "withdraw-
|
|
3149
|
+
...isForOwner ? ["power-down" /* PowerDown */, "withdraw-routes" /* WithdrawRoutes */] : ["power-up" /* PowerUp */]
|
|
2979
3150
|
];
|
|
2980
|
-
case "HBD" /* HiveDollar */:
|
|
3151
|
+
case "HBD" /* HiveDollar */: {
|
|
3152
|
+
const assetInfo = await ensureAssetInfo();
|
|
3153
|
+
const savingsBalance = assetInfo?.parts?.find(
|
|
3154
|
+
(part) => part.name === "savings"
|
|
3155
|
+
)?.balance;
|
|
3156
|
+
const pendingSavingsWithdrawAmount = await (async () => {
|
|
3157
|
+
if (!isForOwner || !username) {
|
|
3158
|
+
return 0;
|
|
3159
|
+
}
|
|
3160
|
+
try {
|
|
3161
|
+
const response = await CONFIG.hiveClient.database.call(
|
|
3162
|
+
"get_savings_withdraw_from",
|
|
3163
|
+
[username]
|
|
3164
|
+
);
|
|
3165
|
+
return response.reduce((total, request) => {
|
|
3166
|
+
const parsed = parseAsset(request.amount);
|
|
3167
|
+
return parsed.symbol === "HBD" /* HBD */ ? total + parsed.amount : total;
|
|
3168
|
+
}, 0);
|
|
3169
|
+
} catch {
|
|
3170
|
+
return 0;
|
|
3171
|
+
}
|
|
3172
|
+
})();
|
|
3173
|
+
const hasAvailableSavingsWithdraw = typeof savingsBalance === "number" && savingsBalance - pendingSavingsWithdrawAmount > 1e-6;
|
|
2981
3174
|
return [
|
|
2982
3175
|
"transfer" /* Transfer */,
|
|
2983
|
-
...isForOwner ? [
|
|
3176
|
+
...isForOwner ? [
|
|
3177
|
+
...hasAvailableSavingsWithdraw ? ["withdraw-saving" /* WithdrawFromSavings */] : [],
|
|
3178
|
+
"transfer-saving" /* TransferToSavings */,
|
|
3179
|
+
"swap" /* Swap */
|
|
3180
|
+
] : []
|
|
2984
3181
|
];
|
|
3182
|
+
}
|
|
2985
3183
|
case "POINTS" /* Points */:
|
|
2986
3184
|
return [
|
|
2987
3185
|
"gift" /* Gift */,
|
|
@@ -3015,7 +3213,6 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false) {
|
|
|
3015
3213
|
if (!username) {
|
|
3016
3214
|
return ["transfer" /* Transfer */];
|
|
3017
3215
|
}
|
|
3018
|
-
const queryClient = getQueryClient();
|
|
3019
3216
|
const balancesListQuery = getHiveEngineTokensBalancesQueryOptions(username);
|
|
3020
3217
|
const balances = await queryClient.ensureQueryData(balancesListQuery);
|
|
3021
3218
|
const tokensQuery = getHiveEngineTokensMetadataQueryOptions(
|
|
@@ -3382,16 +3579,19 @@ var operationToFunctionMap = {
|
|
|
3382
3579
|
HIVE: {
|
|
3383
3580
|
["transfer" /* Transfer */]: transferHive,
|
|
3384
3581
|
["transfer-saving" /* TransferToSavings */]: transferToSavingsHive,
|
|
3582
|
+
["withdraw-saving" /* WithdrawFromSavings */]: transferFromSavingsHive,
|
|
3385
3583
|
["power-up" /* PowerUp */]: powerUpHive
|
|
3386
3584
|
},
|
|
3387
3585
|
HBD: {
|
|
3388
3586
|
["transfer" /* Transfer */]: transferHive,
|
|
3389
|
-
["transfer-saving" /* TransferToSavings */]: transferToSavingsHive
|
|
3587
|
+
["transfer-saving" /* TransferToSavings */]: transferToSavingsHive,
|
|
3588
|
+
["withdraw-saving" /* WithdrawFromSavings */]: transferFromSavingsHive,
|
|
3589
|
+
["claim-interest" /* ClaimInterest */]: claimInterestHive
|
|
3390
3590
|
},
|
|
3391
3591
|
HP: {
|
|
3392
3592
|
["power-down" /* PowerDown */]: powerDownHive,
|
|
3393
3593
|
["delegate" /* Delegate */]: delegateHive,
|
|
3394
|
-
["withdraw-
|
|
3594
|
+
["withdraw-routes" /* WithdrawRoutes */]: withdrawVestingRouteHive
|
|
3395
3595
|
},
|
|
3396
3596
|
POINTS: {
|
|
3397
3597
|
["gift" /* Gift */]: transferPoint
|
|
@@ -3455,6 +3655,6 @@ function useWalletOperation(username, asset, operation) {
|
|
|
3455
3655
|
// src/index.ts
|
|
3456
3656
|
rememberScryptBsvVersion();
|
|
3457
3657
|
|
|
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 };
|
|
3658
|
+
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
3659
|
//# sourceMappingURL=index.js.map
|
|
3460
3660
|
//# sourceMappingURL=index.js.map
|