@ecency/wallets 5.0.81 → 5.0.83
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 +29 -2
- package/dist/browser/index.js +36 -25
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +36 -24
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +36 -25
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
2
|
import { UseMutationOptions } from '@tanstack/react-query';
|
|
3
|
-
import { AuthContext, HiveEngineTokenMetadataResponse, AssetOperation } from '@ecency/sdk';
|
|
3
|
+
import { AccountProfile, AuthContext, HiveEngineTokenMetadataResponse, AssetOperation } from '@ecency/sdk';
|
|
4
4
|
export { Asset, AssetOperation, AuthorReward, CancelTransferFromSavings, ClaimRewardBalance, CollateralizedConvert, CommentBenefactor, CommentPayoutUpdate, CommentReward, CurationReward, DelegateVestingShares, DelegatedVestingShare, EffectiveCommentVote, FillCollateralizedConvertRequest, FillConvertRequest, FillOrder, FillRecurrentTransfers, FillVestingWithdraw, GeneralAssetInfo, GeneralAssetTransaction, HIVE_ACCOUNT_OPERATION_GROUPS, HIVE_OPERATION_LIST, HIVE_OPERATION_NAME_BY_ID, HIVE_OPERATION_ORDERS, HiveBasedAssetSignType, HiveEngineMarketResponse, HiveEngineMetric, HiveEngineOpenOrder, HiveEngineOrderBookEntry, HiveEngineToken, HiveEngineTokenBalance, HiveEngineTokenInfo, HiveEngineTokenMetadataResponse, HiveEngineTokenStatus, HiveEngineTransaction, HiveMarketMetric, HiveOperationFilter, HiveOperationFilterKey, HiveOperationFilterValue, HiveOperationGroup, HiveOperationName, HiveTransaction, WithdrawRoute as HiveWithdrawRoute, Interest, LimitOrderCancel, LimitOrderCreate, NaiMap, PointTransaction, PointTransactionType, Points, PointsResponse, ProducerReward, ProposalPay, ReceivedVestingShare, RecurrentTransfers, ReturnVestingDelegation, SetWithdrawRoute, Symbol, Token, TokenMetadata, Transfer, TransferToSavings, TransferToVesting, UpdateProposalVotes, VoteProxy, WalletOperationPayload, WithdrawVesting, formattedNumber, getAccountWalletAssetInfoQueryOptions, getAllHiveEngineTokensQueryOptions, getHbdAssetGeneralInfoQueryOptions, getHbdAssetTransactionsQueryOptions, getHiveAssetGeneralInfoQueryOptions, getHiveAssetMetricQueryOptions, getHiveAssetTransactionsQueryOptions, getHiveAssetWithdrawalRoutesQueryOptions, getHiveEngineBalancesWithUsdQueryOptions, getHiveEngineTokenGeneralInfoQueryOptions, getHiveEngineTokenTransactionsQueryOptions, getHiveEngineTokensBalancesQueryOptions, getHiveEngineTokensMarketQueryOptions, getHiveEngineTokensMetadataQueryOptions, getHiveEngineTokensMetricsQueryOptions, getHiveEngineUnclaimedRewardsQueryOptions, getHivePowerAssetGeneralInfoQueryOptions, getHivePowerAssetTransactionsQueryOptions, getHivePowerDelegatesInfiniteQueryOptions, getHivePowerDelegatingsQueryOptions, getPointsAssetGeneralInfoQueryOptions, getPointsAssetTransactionsQueryOptions, getPointsQueryOptions, isEmptyDate, parseAsset, resolveHiveOperationFilters, useClaimPoints, useWalletOperation, vestsToHp } from '@ecency/sdk';
|
|
5
5
|
|
|
6
6
|
declare enum EcencyWalletCurrency {
|
|
@@ -87,6 +87,33 @@ interface AccountPointsResponse {
|
|
|
87
87
|
unclaimed_points: string;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Assemble the `profile.tokens` array to broadcast.
|
|
92
|
+
*
|
|
93
|
+
* `profile.tokens` is written wholesale, so whatever this returns IS the user's
|
|
94
|
+
* new on-chain token list — anything omitted is deleted, and since no app other
|
|
95
|
+
* than Ecency writes this field, the deletion is unrecoverable.
|
|
96
|
+
*
|
|
97
|
+
* Which entries survive depends on what the caller manages, inferred from the
|
|
98
|
+
* payload itself:
|
|
99
|
+
*
|
|
100
|
+
* - A payload carrying non-chain entries comes from the wallet token picker,
|
|
101
|
+
* which owns the COMPLETE list — it always sends the basic Hive assets plus
|
|
102
|
+
* every selected engine token, and deselecting one means omitting it. Unlisted
|
|
103
|
+
* entries are therefore dropped, which is what the user asked for.
|
|
104
|
+
* - A CHAIN-only payload comes from the external-wallet screens, which know
|
|
105
|
+
* nothing about engine tokens. Their unlisted entries are carried forward.
|
|
106
|
+
*
|
|
107
|
+
* Inferring rather than taking a flag keeps this fix inside the package (the
|
|
108
|
+
* apps resolve it through the committed dist, so a new public option could not
|
|
109
|
+
* be used by a caller until the next release). It is also safe in the degenerate
|
|
110
|
+
* case: if the picker somehow submits before its token list has loaded, the
|
|
111
|
+
* payload is chain-only and we preserve — the non-destructive outcome.
|
|
112
|
+
*
|
|
113
|
+
* @param existingTokens the account's current on-chain `profile.tokens`
|
|
114
|
+
* @param tokens the caller's payload
|
|
115
|
+
*/
|
|
116
|
+
declare function buildTokensPayload(existingTokens: AccountProfile["tokens"], tokens: EcencyTokenMetadata[]): AccountProfile["tokens"];
|
|
90
117
|
/**
|
|
91
118
|
* Saving of token(s) metadata to Hive profile
|
|
92
119
|
* It may contain: external wallets(see EcencyWalletCurrency), Hive tokens arrangement
|
|
@@ -284,4 +311,4 @@ declare function installHiveSnap(): Promise<void>;
|
|
|
284
311
|
*/
|
|
285
312
|
declare function getHivePublicKeys(): Promise<HivePublicKey[]>;
|
|
286
313
|
|
|
287
|
-
export { type AccountPointsResponse, type EcencyHiveKeys, type EcencyTokenMetadata, EcencyWalletBasicTokens, EcencyWalletCurrency, index as EcencyWalletsPrivateApi, type ExternalWalletBalance, type HiveKeyDerivation, type HivePublicKey, type HiveRole, type TransferableCurrency, type WalletAddressMap, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, discoverMetaMaskWallets, ensureEvmChain, estimateEvmGas, fetchEvmAddress, fetchMultichainAddresses, formatLamports, formatWei, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getEvmChainConfig, getEvmExplorerUrl, getHivePublicKeys, getSolExplorerUrl, getTokenOperationsQueryOptions, getTokenPriceQueryOptions, installHiveSnap, parseToLamports, parseToWei, sendEvmTransfer, sendSolTransfer, useExternalTransfer, useGetExternalWalletBalanceQuery, useSaveWalletInformationToMetadata };
|
|
314
|
+
export { type AccountPointsResponse, type EcencyHiveKeys, type EcencyTokenMetadata, EcencyWalletBasicTokens, EcencyWalletCurrency, index as EcencyWalletsPrivateApi, type ExternalWalletBalance, type HiveKeyDerivation, type HivePublicKey, type HiveRole, type TransferableCurrency, type WalletAddressMap, buildTokensPayload, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, discoverMetaMaskWallets, ensureEvmChain, estimateEvmGas, fetchEvmAddress, fetchMultichainAddresses, formatLamports, formatWei, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getEvmChainConfig, getEvmExplorerUrl, getHivePublicKeys, getSolExplorerUrl, getTokenOperationsQueryOptions, getTokenPriceQueryOptions, installHiveSnap, parseToLamports, parseToWei, sendEvmTransfer, sendSolTransfer, useExternalTransfer, useGetExternalWalletBalanceQuery, useSaveWalletInformationToMetadata };
|
package/dist/browser/index.js
CHANGED
|
@@ -631,15 +631,17 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
|
|
|
631
631
|
}
|
|
632
632
|
|
|
633
633
|
// src/modules/wallets/mutations/save-wallet-information-to-metadata.ts
|
|
634
|
+
var isChainToken = ({
|
|
635
|
+
type,
|
|
636
|
+
symbol
|
|
637
|
+
}) => type === "CHAIN" || Object.values(EcencyWalletCurrency).includes(symbol);
|
|
634
638
|
function getGroupedChainTokens(tokens, defaultShow) {
|
|
635
639
|
if (!tokens) {
|
|
636
640
|
return {};
|
|
637
641
|
}
|
|
638
642
|
return R.pipe(
|
|
639
643
|
tokens,
|
|
640
|
-
R.filter(
|
|
641
|
-
({ type, symbol }) => type === "CHAIN" || Object.values(EcencyWalletCurrency).includes(symbol)
|
|
642
|
-
),
|
|
644
|
+
R.filter(isChainToken),
|
|
643
645
|
R.map((item) => {
|
|
644
646
|
const meta = {
|
|
645
647
|
...item.meta ?? {}
|
|
@@ -659,6 +661,35 @@ function getGroupedChainTokens(tokens, defaultShow) {
|
|
|
659
661
|
)
|
|
660
662
|
);
|
|
661
663
|
}
|
|
664
|
+
function buildTokensPayload(existingTokens, tokens) {
|
|
665
|
+
const profileChainTokens = getGroupedChainTokens(existingTokens);
|
|
666
|
+
const payloadTokens = tokens.map(({ currency, type, privateKey, username, ...meta }) => ({
|
|
667
|
+
symbol: currency,
|
|
668
|
+
type: type ?? (Object.values(EcencyWalletCurrency).includes(currency) ? "CHAIN" : void 0),
|
|
669
|
+
meta
|
|
670
|
+
})) ?? [];
|
|
671
|
+
const payloadChainTokens = getGroupedChainTokens(payloadTokens, true);
|
|
672
|
+
const payloadNonChainTokens = (payloadTokens ?? []).filter(
|
|
673
|
+
(token) => !isChainToken(token)
|
|
674
|
+
);
|
|
675
|
+
const mergedChainTokens = R.pipe(
|
|
676
|
+
profileChainTokens,
|
|
677
|
+
R.mergeDeep(payloadChainTokens),
|
|
678
|
+
R.values()
|
|
679
|
+
);
|
|
680
|
+
const managesNonChainTokens = payloadNonChainTokens.length > 0;
|
|
681
|
+
const payloadSymbols = new Set(
|
|
682
|
+
(payloadTokens ?? []).map(({ symbol }) => symbol)
|
|
683
|
+
);
|
|
684
|
+
const preservedTokens = managesNonChainTokens ? [] : (existingTokens ?? []).filter(
|
|
685
|
+
(token) => !isChainToken(token) && !payloadSymbols.has(token.symbol)
|
|
686
|
+
);
|
|
687
|
+
return [
|
|
688
|
+
...preservedTokens,
|
|
689
|
+
...payloadNonChainTokens,
|
|
690
|
+
...mergedChainTokens
|
|
691
|
+
];
|
|
692
|
+
}
|
|
662
693
|
function useSaveWalletInformationToMetadata(username, auth, options2) {
|
|
663
694
|
const queryClient = useQueryClient();
|
|
664
695
|
const { data: accountData } = useQuery(getAccountFullQueryOptions(username));
|
|
@@ -673,28 +704,8 @@ function useSaveWalletInformationToMetadata(username, auth, options2) {
|
|
|
673
704
|
if (!accountData) {
|
|
674
705
|
throw new Error("[SDK][Wallets] \u2013 no account data to save wallets");
|
|
675
706
|
}
|
|
676
|
-
const profileChainTokens = getGroupedChainTokens(
|
|
677
|
-
accountData.profile?.tokens
|
|
678
|
-
);
|
|
679
|
-
const payloadTokens = tokens.map(({ currency, type, privateKey, username: username2, ...meta }) => ({
|
|
680
|
-
symbol: currency,
|
|
681
|
-
type: type ?? (Object.values(EcencyWalletCurrency).includes(currency) ? "CHAIN" : void 0),
|
|
682
|
-
meta
|
|
683
|
-
})) ?? [];
|
|
684
|
-
const payloadChainTokens = getGroupedChainTokens(payloadTokens, true);
|
|
685
|
-
const payloadNonChainTokens = payloadTokens.filter(
|
|
686
|
-
({ type, symbol }) => type !== "CHAIN" && !Object.values(EcencyWalletCurrency).includes(symbol)
|
|
687
|
-
);
|
|
688
|
-
const mergedChainTokens = R.pipe(
|
|
689
|
-
profileChainTokens,
|
|
690
|
-
R.mergeDeep(payloadChainTokens),
|
|
691
|
-
R.values()
|
|
692
|
-
);
|
|
693
707
|
return updateProfile({
|
|
694
|
-
tokens:
|
|
695
|
-
...payloadNonChainTokens,
|
|
696
|
-
...mergedChainTokens
|
|
697
|
-
]
|
|
708
|
+
tokens: buildTokensPayload(accountData.profile?.tokens, tokens)
|
|
698
709
|
});
|
|
699
710
|
},
|
|
700
711
|
onError: options2?.onError,
|
|
@@ -1137,6 +1148,6 @@ async function getHivePublicKeys() {
|
|
|
1137
1148
|
// src/index.ts
|
|
1138
1149
|
rememberScryptBsvVersion();
|
|
1139
1150
|
|
|
1140
|
-
export { EcencyWalletBasicTokens, EcencyWalletCurrency, private_api_exports as EcencyWalletsPrivateApi, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, discoverMetaMaskWallets, ensureEvmChain, estimateEvmGas, fetchEvmAddress, fetchMultichainAddresses, formatLamports, formatWei, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getEvmChainConfig, getEvmExplorerUrl, getHivePublicKeys, getSolExplorerUrl, getTokenOperationsQueryOptions, getTokenPriceQueryOptions, installHiveSnap, parseToLamports, parseToWei, sendEvmTransfer, sendSolTransfer, useExternalTransfer, useGetExternalWalletBalanceQuery, useSaveWalletInformationToMetadata };
|
|
1151
|
+
export { EcencyWalletBasicTokens, EcencyWalletCurrency, private_api_exports as EcencyWalletsPrivateApi, buildTokensPayload, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, discoverMetaMaskWallets, ensureEvmChain, estimateEvmGas, fetchEvmAddress, fetchMultichainAddresses, formatLamports, formatWei, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getEvmChainConfig, getEvmExplorerUrl, getHivePublicKeys, getSolExplorerUrl, getTokenOperationsQueryOptions, getTokenPriceQueryOptions, installHiveSnap, parseToLamports, parseToWei, sendEvmTransfer, sendSolTransfer, useExternalTransfer, useGetExternalWalletBalanceQuery, useSaveWalletInformationToMetadata };
|
|
1141
1152
|
//# sourceMappingURL=index.js.map
|
|
1142
1153
|
//# sourceMappingURL=index.js.map
|