@ecency/wallets 1.5.55 → 2.0.1

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.
@@ -2,24 +2,11 @@ import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { UseMutationOptions } from '@tanstack/react-query';
3
3
  import { 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, SpkApiWallet, SpkMarkets, Symbol, Token, TokenMetadata, Transfer, TransferToSavings, TransferToVesting, TransformedSpkMarkets, 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, getLarynxAssetGeneralInfoQueryOptions, getLarynxPowerAssetGeneralInfoQueryOptions, getPointsAssetGeneralInfoQueryOptions, getPointsAssetTransactionsQueryOptions, getPointsQueryOptions, getSpkAssetGeneralInfoQueryOptions, getSpkMarketsQueryOptions, getSpkWalletQueryOptions, isEmptyDate, parseAsset, resolveHiveOperationFilters, rewardSpk, useClaimPoints, useWalletOperation, vestsToHp } from '@ecency/sdk';
5
- import { BaseWallet, SignTxParams } from '@okxweb3/coin-base';
6
- import { Client } from '@hiveio/dhive';
7
- import { Transaction, SignedTransaction, TransactionConfirmation } from '@hiveio/dhive/lib/chain/transaction';
8
- import { utxoTx } from '@okxweb3/coin-bitcoin/dist/type';
9
- import { Network } from '@okxweb3/coin-bitcoin/dist/bitcoinjs-lib';
10
- import { EthTxParams } from '@okxweb3/coin-ethereum/dist/EthWallet';
11
- import { SolSignParam } from '@okxweb3/coin-solana/dist/SolWallet';
12
- import { TrxSignParam } from '@okxweb3/coin-tron/dist/TrxWallet';
13
- import { TxData } from '@okxweb3/coin-ton/dist/api/types';
14
- import { AptosParam } from '@okxweb3/coin-aptos/dist/AptosWallet';
15
5
 
16
6
  declare enum EcencyWalletCurrency {
17
7
  BTC = "BTC",
18
8
  ETH = "ETH",
19
9
  BNB = "BNB",
20
- APT = "APT",
21
- TON = "TON",
22
- TRON = "TRX",
23
10
  SOL = "SOL"
24
11
  }
25
12
 
@@ -30,6 +17,44 @@ declare enum EcencyWalletBasicTokens {
30
17
  HiveDollar = "HBD"
31
18
  }
32
19
 
20
+ interface HiveKeys {
21
+ ownerPublicKey?: string;
22
+ activePublicKey?: string;
23
+ postingPublicKey?: string;
24
+ memoPublicKey?: string;
25
+ }
26
+ interface Payload$2 {
27
+ currency: EcencyWalletCurrency;
28
+ address: string;
29
+ hiveKeys?: HiveKeys;
30
+ walletAddresses?: Partial<Record<EcencyWalletCurrency, string>>;
31
+ }
32
+ declare function useCreateAccountWithWallets(username: string): _tanstack_react_query.UseMutationResult<Response, Error, Payload$2, unknown>;
33
+
34
+ interface Payload$1 {
35
+ address: string;
36
+ currency: EcencyWalletCurrency;
37
+ }
38
+ declare function useCheckWalletExistence(): _tanstack_react_query.UseMutationResult<boolean, Error, Payload$1, unknown>;
39
+
40
+ interface Payload {
41
+ tokens: Record<string, string>;
42
+ hiveKeys: {
43
+ ownerPublicKey: string;
44
+ activePublicKey: string;
45
+ postingPublicKey: string;
46
+ memoPublicKey: string;
47
+ };
48
+ }
49
+ declare function useUpdateAccountWithWallets(username: string, accessToken: string | undefined): _tanstack_react_query.UseMutationResult<Response, Error, Payload, unknown>;
50
+
51
+ declare const index_useCheckWalletExistence: typeof useCheckWalletExistence;
52
+ declare const index_useCreateAccountWithWallets: typeof useCreateAccountWithWallets;
53
+ declare const index_useUpdateAccountWithWallets: typeof useUpdateAccountWithWallets;
54
+ declare namespace index {
55
+ export { index_useCheckWalletExistence as useCheckWalletExistence, index_useCreateAccountWithWallets as useCreateAccountWithWallets, index_useUpdateAccountWithWallets as useUpdateAccountWithWallets };
56
+ }
57
+
33
58
  interface EcencyTokenMetadata {
34
59
  address?: string;
35
60
  privateKey?: string;
@@ -62,60 +87,6 @@ interface AccountPointsResponse {
62
87
  unclaimed_points: string;
63
88
  }
64
89
 
65
- /**
66
- * Uses for creating wallet logically in the application
67
- *
68
- * Keep attention: this mutation doesn't save wallet to somewhere in a server
69
- */
70
- declare function useWalletCreate(username: string, currency: EcencyWalletCurrency, importedSeed?: string): {
71
- createWallet: _tanstack_react_query.UseMutationResult<EcencyTokenMetadata, Error, void, unknown>;
72
- importWallet: () => void;
73
- };
74
-
75
- interface Payload$3 {
76
- currency: string;
77
- address: string;
78
- }
79
- declare function useCreateAccountWithWallets(username: string): _tanstack_react_query.UseMutationResult<Response, Error, Payload$3, unknown>;
80
-
81
- interface Payload$2 {
82
- address: string;
83
- currency: EcencyWalletCurrency;
84
- }
85
- declare function useCheckWalletExistence(): _tanstack_react_query.UseMutationResult<boolean, Error, Payload$2, unknown>;
86
-
87
- interface Payload$1 {
88
- tokens: Record<string, string>;
89
- hiveKeys: {
90
- ownerPublicKey: string;
91
- activePublicKey: string;
92
- postingPublicKey: string;
93
- memoPublicKey: string;
94
- };
95
- }
96
- declare function useUpdateAccountWithWallets(username: string, accessToken: string | undefined): _tanstack_react_query.UseMutationResult<Response, Error, Payload$1, unknown>;
97
-
98
- declare const index_useCheckWalletExistence: typeof useCheckWalletExistence;
99
- declare const index_useCreateAccountWithWallets: typeof useCreateAccountWithWallets;
100
- declare const index_useUpdateAccountWithWallets: typeof useUpdateAccountWithWallets;
101
- declare namespace index {
102
- export { index_useCheckWalletExistence as useCheckWalletExistence, index_useCreateAccountWithWallets as useCreateAccountWithWallets, index_useUpdateAccountWithWallets as useUpdateAccountWithWallets };
103
- }
104
-
105
- interface Payload {
106
- privateKeyOrSeed: string;
107
- }
108
- /**
109
- * This mutation uses for importing an existing wallet, validation and saving logically in application
110
- *
111
- * Keep attention: this mutation doesn't save wallet to somewhere in a server
112
- */
113
- declare function useImportWallet(username: string, currency: EcencyWalletCurrency): _tanstack_react_query.UseMutationResult<{
114
- privateKey: string;
115
- address: any;
116
- publicKey: string;
117
- }, Error, Payload, unknown>;
118
-
119
90
  /**
120
91
  * Saving of token(s) metadata to Hive profile
121
92
  * It may contain: external wallets(see EcencyWalletCurrency), Hive tokens arrangement
@@ -125,6 +96,19 @@ declare function useImportWallet(username: string, currency: EcencyWalletCurrenc
125
96
  type SaveWalletInformationOptions = Pick<UseMutationOptions<unknown, Error, EcencyTokenMetadata[]>, "onSuccess" | "onError">;
126
97
  declare function useSaveWalletInformationToMetadata(username: string, auth?: AuthContext, options?: SaveWalletInformationOptions): _tanstack_react_query.UseMutationResult<unknown, Error, EcencyTokenMetadata[], unknown>;
127
98
 
99
+ type TransferableCurrency = EcencyWalletCurrency.ETH | EcencyWalletCurrency.BNB | EcencyWalletCurrency.SOL;
100
+ interface ExternalTransferPayload {
101
+ to: string;
102
+ amount: string;
103
+ }
104
+ declare function useExternalTransfer(currency: TransferableCurrency): _tanstack_react_query.UseMutationResult<{
105
+ txHash: string;
106
+ currency: EcencyWalletCurrency.ETH | EcencyWalletCurrency.BNB;
107
+ } | {
108
+ txHash: string;
109
+ currency: EcencyWalletCurrency.SOL;
110
+ }, Error, ExternalTransferPayload, unknown>;
111
+
128
112
  interface ExternalWalletBalance {
129
113
  chain: string;
130
114
  unit: string;
@@ -142,8 +126,6 @@ interface ExternalWalletBalance {
142
126
  }
143
127
  declare function useGetExternalWalletBalanceQuery(currency: EcencyWalletCurrency, address: string): _tanstack_react_query.UseQueryResult<ExternalWalletBalance, Error>;
144
128
 
145
- declare function useSeedPhrase(username: string): _tanstack_react_query.UseQueryResult<string, Error>;
146
-
147
129
  declare function getTokenPriceQueryOptions(currency?: string): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<number, Error, number, (string | undefined)[]>, "queryFn"> & {
148
130
  queryFn?: _tanstack_react_query.QueryFunction<number, (string | undefined)[], never> | undefined;
149
131
  } & {
@@ -153,8 +135,6 @@ declare function getTokenPriceQueryOptions(currency?: string): _tanstack_react_q
153
135
  };
154
136
  };
155
137
 
156
- declare function useHiveKeysQuery(username: string): _tanstack_react_query.UseQueryResult<EcencyHiveKeys, Error>;
157
-
158
138
  declare function getAllTokensListQueryOptions(username?: string): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<{
159
139
  basic: EcencyWalletBasicTokens[];
160
140
  external: EcencyWalletCurrency[];
@@ -202,14 +182,6 @@ declare function getTokenOperationsQueryOptions(token: string, username: string,
202
182
  };
203
183
  };
204
184
 
205
- declare function useWalletsCacheQuery(username?: string): _tanstack_react_query.DefinedUseQueryResult<Map<EcencyWalletCurrency, EcencyTokenMetadata>, Error>;
206
-
207
- declare function delay(ms: number): Promise<unknown>;
208
-
209
- declare function getWallet(currency: EcencyWalletCurrency): BaseWallet | undefined;
210
-
211
- declare function mnemonicToSeedBip39(value: string): string;
212
-
213
185
  type HiveRole = "owner" | "active" | "posting" | "memo";
214
186
  declare function deriveHiveKey(mnemonic: string, role: HiveRole, accountIndex?: number): {
215
187
  readonly privateKey: string;
@@ -244,123 +216,73 @@ declare function deriveHiveMasterPasswordKeys(username: string, masterPassword:
244
216
  type HiveKeyDerivation = "bip44" | "master-password" | "unknown";
245
217
  declare function detectHiveKeyDerivation(username: string, seed: string, type?: "active" | "owner"): Promise<HiveKeyDerivation>;
246
218
 
219
+ interface RequestArguments {
220
+ method: string;
221
+ params?: unknown[] | Record<string, unknown>;
222
+ }
223
+ interface EthereumProvider {
224
+ isMetaMask?: boolean;
225
+ request<T = unknown>(args: RequestArguments): Promise<T>;
226
+ }
227
+ declare global {
228
+ interface Window {
229
+ ethereum?: EthereumProvider;
230
+ }
231
+ }
232
+ declare function getEvmChainConfig(currency: EcencyWalletCurrency): {
233
+ chainId: string;
234
+ name: string;
235
+ rpcUrl: string;
236
+ explorerUrl: string;
237
+ };
238
+ declare function getEvmExplorerUrl(currency: EcencyWalletCurrency, txHash: string): string;
239
+ declare function ensureEvmChain(currency: EcencyWalletCurrency): Promise<void>;
240
+ declare function estimateEvmGas(from: string, to: string, valueHex: string, currency: EcencyWalletCurrency): Promise<{
241
+ gasLimit: string;
242
+ gasPrice: string;
243
+ estimatedFeeWei: bigint;
244
+ }>;
245
+ declare function formatWei(wei: bigint, decimals?: number): string;
246
+ declare function parseToWei(amount: string): string;
247
+ declare function sendEvmTransfer(to: string, amountWei: string, currency: EcencyWalletCurrency): Promise<string>;
248
+
249
+ declare function getSolExplorerUrl(signature: string): string;
250
+ declare function parseToLamports(amount: string): bigint;
251
+ declare function formatLamports(lamports: bigint, decimals?: number): string;
252
+ declare function sendSolTransfer(to: string, amountSol: string): Promise<string>;
253
+
254
+ type WalletAddressMap = Partial<Record<EcencyWalletCurrency, string>>;
255
+ interface HivePublicKey {
256
+ publicKey: string;
257
+ role?: string;
258
+ accountIndex: number;
259
+ addressIndex: number;
260
+ }
247
261
  /**
248
- * Sign a digest using the provided private key.
249
- * @param digest Digest as a Buffer or hex string.
250
- * @param privateKey Private key in WIF format.
251
- * @returns Hex encoded signature string.
252
- */
253
- declare function signDigest(digest: Buffer | string, privateKey: string): string;
254
-
255
- /**
256
- * Sign a transaction with the given private key.
257
- * Optionally a custom chain id can be provided.
258
- *
259
- * @param tx Transaction to sign.
260
- * @param privateKey Private key in WIF format.
261
- * @param chainId Optional chain id as a hex string.
262
- * @returns Signed transaction including the signature.
263
- */
264
- declare function signTx(tx: Transaction, privateKey: string, chainId?: string): SignedTransaction;
265
- /**
266
- * Sign a transaction and broadcast it to the network.
267
- * Optionally a custom chain id can be provided.
268
- *
269
- * @param client Hive client instance used for broadcasting.
270
- * @param tx Transaction to sign.
271
- * @param privateKey Private key in WIF format.
272
- * @param chainId Optional chain id as a hex string.
273
- * @returns Broadcast confirmation.
274
- */
275
- declare function signTxAndBroadcast(client: Client, tx: Transaction, privateKey: string, chainId?: string): Promise<TransactionConfirmation>;
276
-
277
- /**
278
- * Encrypt a memo using explicit keys.
279
- * @param privateKey Sender's private memo key in WIF format.
280
- * @param publicKey Recipient's public memo key.
281
- * @param memo Memo text to encrypt.
282
- */
283
- declare function encryptMemoWithKeys(privateKey: string, publicKey: string, memo: string): string;
284
- /**
285
- * Encrypt a memo by looking up the recipient's memo key from the blockchain.
286
- * @param client Hive client instance used to fetch account information.
287
- * @param fromPrivateKey Sender's private memo key.
288
- * @param toAccount Recipient account name.
289
- * @param memo Memo text to encrypt.
290
- */
291
- declare function encryptMemoWithAccounts(client: Client, fromPrivateKey: string, toAccount: string, memo: string): Promise<string>;
292
-
293
- /**
294
- * Decrypt an encrypted memo using the recipient's private key.
295
- * @param privateKey Private memo key in WIF format.
296
- * @param memo Encrypted memo string.
297
- */
298
- declare function decryptMemoWithKeys(privateKey: string, memo: string): string;
299
- /**
300
- * Decrypt a memo using account information.
301
- * This is an alias of {@link decryptMemoWithKeys} and provided for
302
- * API symmetry with {@link encryptMemoWithAccounts}.
303
- */
304
- declare const decryptMemoWithAccounts: typeof decryptMemoWithKeys;
305
-
306
- /**
307
- * Sign a transaction for an external chain supported by okxweb3 wallets.
308
- *
309
- * @param currency Chain identifier.
310
- * @param params Signing parameters accepted by okxweb3 wallets.
311
- */
312
- declare function signExternalTx(currency: EcencyWalletCurrency, params: SignTxParams): Promise<any>;
313
- /**
314
- * Sign and broadcast a transaction for an external chain. The transaction is
315
- * signed locally and then sent to a public RPC endpoint for broadcasting.
316
- *
317
- * @param currency Chain identifier.
318
- * @param params Signing parameters accepted by okxweb3 wallets.
319
- * @returns RPC response or broadcasted transaction hash.
320
- */
321
- declare function signExternalTxAndBroadcast(currency: EcencyWalletCurrency, params: SignTxParams): Promise<any>;
322
-
323
- /**
324
- * Union type covering all chain-specific build parameters.
325
- */
326
- type ExternalTxParams = utxoTx | EthTxParams | SolSignParam | TrxSignParam | TxData | AptosParam;
327
- /**
328
- * Build a Bitcoin PSBT from UTXO inputs and desired outputs.
329
- *
330
- * @param tx Transaction description accepted by @okxweb3/coin-bitcoin.
331
- * @returns Hex encoded PSBT ready for signing.
332
- */
333
- declare function buildPsbt(tx: utxoTx, network?: Network, maximumFeeRate?: number): string;
334
- /**
335
- * Helper returning raw Ethereum transaction data ready for signing.
262
+ * Fetch non-EVM addresses from MetaMask via the Wallet Standard protocol.
336
263
  *
337
- * The returned object can be passed directly to signExternalTx.
264
+ * MetaMask registers non-EVM wallets (Solana, Bitcoin) as separate Wallet Standard
265
+ * wallets — they are NOT accessible through window.ethereum (EVM-only provider).
338
266
  */
339
- declare function buildEthTx(data: EthTxParams): EthTxParams;
267
+ declare function fetchMultichainAddresses(): Promise<WalletAddressMap>;
340
268
  /**
341
- * Helper returning Solana transaction params used by signExternalTx.
269
+ * Fetch the EVM address from MetaMask via window.ethereum.
270
+ * Returns the first connected account address, or undefined on failure.
342
271
  */
343
- declare function buildSolTx(data: SolSignParam): SolSignParam;
272
+ declare function fetchEvmAddress(): Promise<string | undefined>;
344
273
  /**
345
- * Helper returning Tron transaction params used by signExternalTx.
274
+ * Discover all wallet addresses from MetaMask (EVM + non-EVM).
275
+ * Returns a map of currency -> address. Partial results are returned on failure.
346
276
  */
347
- declare function buildTronTx(data: TrxSignParam): TrxSignParam;
277
+ declare function discoverMetaMaskWallets(): Promise<WalletAddressMap>;
348
278
  /**
349
- * Helper returning TON transaction params used by signExternalTx.
279
+ * Install the Hive Snap in MetaMask.
350
280
  */
351
- declare function buildTonTx(data: TxData): TxData;
281
+ declare function installHiveSnap(): Promise<void>;
352
282
  /**
353
- * Helper returning Aptos transaction params used by signExternalTx.
283
+ * Get Hive public keys from the MetaMask Hive Snap.
284
+ * Returns owner, active, posting, and memo public keys.
354
285
  */
355
- declare function buildAptTx(data: AptosParam): AptosParam;
356
- /**
357
- * Build a transaction for an external chain supported by okxweb3 wallets.
358
- *
359
- * @param currency Chain identifier.
360
- * @param tx Chain specific transaction description.
361
- */
362
- declare function buildExternalTx(currency: EcencyWalletCurrency, tx: ExternalTxParams): string | EthTxParams | SolSignParam | TrxSignParam | TxData | AptosParam;
363
-
364
- declare function getBoundFetch(): typeof fetch;
286
+ declare function getHivePublicKeys(): Promise<HivePublicKey[]>;
365
287
 
366
- export { type AccountPointsResponse, type EcencyHiveKeys, type EcencyTokenMetadata, EcencyWalletBasicTokens, EcencyWalletCurrency, index as EcencyWalletsPrivateApi, type ExternalTxParams, type ExternalWalletBalance, type HiveKeyDerivation, type HiveRole, buildAptTx, buildEthTx, buildExternalTx, buildPsbt, buildSolTx, buildTonTx, buildTronTx, decryptMemoWithAccounts, decryptMemoWithKeys, delay, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, encryptMemoWithAccounts, encryptMemoWithKeys, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getBoundFetch, getTokenOperationsQueryOptions, getTokenPriceQueryOptions, getWallet, mnemonicToSeedBip39, signDigest, signExternalTx, signExternalTxAndBroadcast, signTx, signTxAndBroadcast, useGetExternalWalletBalanceQuery, useHiveKeysQuery, useImportWallet, useSaveWalletInformationToMetadata, useSeedPhrase, useWalletCreate, useWalletsCacheQuery };
288
+ 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 };