@ecency/wallets 1.4.35 → 1.5.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.
- package/dist/browser/index.d.ts +177 -44
- package/dist/browser/index.js +255 -6
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +259 -5
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +253 -6
- package/dist/node/index.mjs.map +1 -1
- package/package.json +3 -1
package/dist/node/index.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { cryptoUtils } from '@hiveio/dhive/lib/crypto';
|
|
|
14
14
|
import { Memo } from '@hiveio/dhive/lib/memo';
|
|
15
15
|
import dayjs from 'dayjs';
|
|
16
16
|
import hs from 'hivesigner';
|
|
17
|
+
import numeral from 'numeral';
|
|
17
18
|
import * as R from 'remeda';
|
|
18
19
|
|
|
19
20
|
var __defProp = Object.defineProperty;
|
|
@@ -182,7 +183,14 @@ function useGetExternalWalletBalanceQuery(currency, address) {
|
|
|
182
183
|
function useSeedPhrase(username) {
|
|
183
184
|
return useQuery({
|
|
184
185
|
queryKey: ["ecency-wallets", "seed", username],
|
|
185
|
-
queryFn: async () => bip39.generateMnemonic(128)
|
|
186
|
+
queryFn: async () => bip39.generateMnemonic(128),
|
|
187
|
+
// CRITICAL: Prevent seed regeneration - cache forever
|
|
188
|
+
// Once generated, the seed must NEVER change to ensure consistency between:
|
|
189
|
+
// 1. Displayed seed phrase
|
|
190
|
+
// 2. Downloaded seed file
|
|
191
|
+
// 3. Keys sent to API for account creation
|
|
192
|
+
staleTime: Infinity,
|
|
193
|
+
gcTime: Infinity
|
|
186
194
|
});
|
|
187
195
|
}
|
|
188
196
|
var options = {
|
|
@@ -1901,6 +1909,221 @@ function getLarynxPowerAssetGeneralInfoQueryOptions(username) {
|
|
|
1901
1909
|
}
|
|
1902
1910
|
});
|
|
1903
1911
|
}
|
|
1912
|
+
function getAllHiveEngineTokensQueryOptions(account, symbol) {
|
|
1913
|
+
return queryOptions({
|
|
1914
|
+
queryKey: ["assets", "hive-engine", "all-tokens", account, symbol],
|
|
1915
|
+
queryFn: async () => {
|
|
1916
|
+
try {
|
|
1917
|
+
const response = await fetch(
|
|
1918
|
+
`${CONFIG.privateApiHost}/private-api/engine-api`,
|
|
1919
|
+
{
|
|
1920
|
+
method: "POST",
|
|
1921
|
+
body: JSON.stringify({
|
|
1922
|
+
jsonrpc: "2.0",
|
|
1923
|
+
method: "find",
|
|
1924
|
+
params: {
|
|
1925
|
+
contract: "market",
|
|
1926
|
+
table: "metrics",
|
|
1927
|
+
query: {
|
|
1928
|
+
...symbol && { symbol },
|
|
1929
|
+
...account && { account }
|
|
1930
|
+
}
|
|
1931
|
+
},
|
|
1932
|
+
id: 1
|
|
1933
|
+
}),
|
|
1934
|
+
headers: { "Content-type": "application/json" }
|
|
1935
|
+
}
|
|
1936
|
+
);
|
|
1937
|
+
const data = await response.json();
|
|
1938
|
+
return data.result;
|
|
1939
|
+
} catch (e) {
|
|
1940
|
+
return [];
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
});
|
|
1944
|
+
}
|
|
1945
|
+
function formattedNumber(value, options2 = void 0) {
|
|
1946
|
+
let opts = {
|
|
1947
|
+
fractionDigits: 3,
|
|
1948
|
+
prefix: "",
|
|
1949
|
+
suffix: ""
|
|
1950
|
+
};
|
|
1951
|
+
if (options2) {
|
|
1952
|
+
opts = { ...opts, ...options2 };
|
|
1953
|
+
}
|
|
1954
|
+
const { fractionDigits, prefix, suffix } = opts;
|
|
1955
|
+
let format4 = "0,0";
|
|
1956
|
+
if (fractionDigits) {
|
|
1957
|
+
format4 += "." + "0".repeat(fractionDigits);
|
|
1958
|
+
}
|
|
1959
|
+
let out = "";
|
|
1960
|
+
if (prefix) out += prefix + " ";
|
|
1961
|
+
const av = Math.abs(parseFloat(value.toString())) < 1e-4 ? 0 : value;
|
|
1962
|
+
out += numeral(av).format(format4);
|
|
1963
|
+
if (suffix) out += " " + suffix;
|
|
1964
|
+
return out;
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
// src/modules/assets/hive-engine/utils/hive-engine-token.ts
|
|
1968
|
+
var HiveEngineToken = class {
|
|
1969
|
+
symbol;
|
|
1970
|
+
name;
|
|
1971
|
+
icon;
|
|
1972
|
+
precision;
|
|
1973
|
+
stakingEnabled;
|
|
1974
|
+
delegationEnabled;
|
|
1975
|
+
balance;
|
|
1976
|
+
stake;
|
|
1977
|
+
stakedBalance;
|
|
1978
|
+
delegationsIn;
|
|
1979
|
+
delegationsOut;
|
|
1980
|
+
usdValue;
|
|
1981
|
+
constructor(props) {
|
|
1982
|
+
this.symbol = props.symbol;
|
|
1983
|
+
this.name = props.name || "";
|
|
1984
|
+
this.icon = props.icon || "";
|
|
1985
|
+
this.precision = props.precision || 0;
|
|
1986
|
+
this.stakingEnabled = props.stakingEnabled || false;
|
|
1987
|
+
this.delegationEnabled = props.delegationEnabled || false;
|
|
1988
|
+
this.balance = parseFloat(props.balance) || 0;
|
|
1989
|
+
this.stake = parseFloat(props.stake) || 0;
|
|
1990
|
+
this.delegationsIn = parseFloat(props.delegationsIn) || 0;
|
|
1991
|
+
this.delegationsOut = parseFloat(props.delegationsOut) || 0;
|
|
1992
|
+
this.stakedBalance = this.stake + this.delegationsIn - this.delegationsOut;
|
|
1993
|
+
this.usdValue = props.usdValue;
|
|
1994
|
+
}
|
|
1995
|
+
hasDelegations = () => {
|
|
1996
|
+
if (!this.delegationEnabled) {
|
|
1997
|
+
return false;
|
|
1998
|
+
}
|
|
1999
|
+
return this.delegationsIn > 0 && this.delegationsOut > 0;
|
|
2000
|
+
};
|
|
2001
|
+
delegations = () => {
|
|
2002
|
+
if (!this.hasDelegations()) {
|
|
2003
|
+
return "";
|
|
2004
|
+
}
|
|
2005
|
+
return `(${formattedNumber(this.stake, {
|
|
2006
|
+
fractionDigits: this.precision
|
|
2007
|
+
})} + ${formattedNumber(this.delegationsIn, {
|
|
2008
|
+
fractionDigits: this.precision
|
|
2009
|
+
})} - ${formattedNumber(this.delegationsOut, {
|
|
2010
|
+
fractionDigits: this.precision
|
|
2011
|
+
})})`;
|
|
2012
|
+
};
|
|
2013
|
+
staked = () => {
|
|
2014
|
+
if (!this.stakingEnabled) {
|
|
2015
|
+
return "-";
|
|
2016
|
+
}
|
|
2017
|
+
if (this.stakedBalance < 1e-4) {
|
|
2018
|
+
return this.stakedBalance.toString();
|
|
2019
|
+
}
|
|
2020
|
+
return formattedNumber(this.stakedBalance, {
|
|
2021
|
+
fractionDigits: this.precision
|
|
2022
|
+
});
|
|
2023
|
+
};
|
|
2024
|
+
balanced = () => {
|
|
2025
|
+
if (this.balance < 1e-4) {
|
|
2026
|
+
return this.balance.toString();
|
|
2027
|
+
}
|
|
2028
|
+
return formattedNumber(this.balance, { fractionDigits: this.precision });
|
|
2029
|
+
};
|
|
2030
|
+
};
|
|
2031
|
+
|
|
2032
|
+
// src/modules/assets/hive-engine/queries/get-hive-engine-balances-with-usd-query-options.ts
|
|
2033
|
+
function getHiveEngineBalancesWithUsdQueryOptions(account, dynamicProps, allTokens) {
|
|
2034
|
+
return queryOptions({
|
|
2035
|
+
queryKey: [
|
|
2036
|
+
"assets",
|
|
2037
|
+
"hive-engine",
|
|
2038
|
+
"balances-with-usd",
|
|
2039
|
+
account,
|
|
2040
|
+
dynamicProps,
|
|
2041
|
+
allTokens
|
|
2042
|
+
],
|
|
2043
|
+
queryFn: async () => {
|
|
2044
|
+
if (!account) {
|
|
2045
|
+
throw new Error("[HiveEngine] No account in a balances query");
|
|
2046
|
+
}
|
|
2047
|
+
const balancesResponse = await fetch(
|
|
2048
|
+
`${CONFIG.privateApiHost}/private-api/engine-api`,
|
|
2049
|
+
{
|
|
2050
|
+
method: "POST",
|
|
2051
|
+
body: JSON.stringify({
|
|
2052
|
+
jsonrpc: "2.0",
|
|
2053
|
+
method: "find",
|
|
2054
|
+
params: {
|
|
2055
|
+
contract: "tokens",
|
|
2056
|
+
table: "balances",
|
|
2057
|
+
query: {
|
|
2058
|
+
account
|
|
2059
|
+
}
|
|
2060
|
+
},
|
|
2061
|
+
id: 1
|
|
2062
|
+
}),
|
|
2063
|
+
headers: { "Content-type": "application/json" }
|
|
2064
|
+
}
|
|
2065
|
+
);
|
|
2066
|
+
const balancesData = await balancesResponse.json();
|
|
2067
|
+
const balances = balancesData.result || [];
|
|
2068
|
+
const tokensResponse = await fetch(
|
|
2069
|
+
`${CONFIG.privateApiHost}/private-api/engine-api`,
|
|
2070
|
+
{
|
|
2071
|
+
method: "POST",
|
|
2072
|
+
body: JSON.stringify({
|
|
2073
|
+
jsonrpc: "2.0",
|
|
2074
|
+
method: "find",
|
|
2075
|
+
params: {
|
|
2076
|
+
contract: "tokens",
|
|
2077
|
+
table: "tokens",
|
|
2078
|
+
query: {
|
|
2079
|
+
symbol: { $in: balances.map((t) => t.symbol) }
|
|
2080
|
+
}
|
|
2081
|
+
},
|
|
2082
|
+
id: 2
|
|
2083
|
+
}),
|
|
2084
|
+
headers: { "Content-type": "application/json" }
|
|
2085
|
+
}
|
|
2086
|
+
);
|
|
2087
|
+
const tokensData = await tokensResponse.json();
|
|
2088
|
+
const tokens = tokensData.result || [];
|
|
2089
|
+
const pricePerHive = dynamicProps ? dynamicProps.base / dynamicProps.quote : 0;
|
|
2090
|
+
const metrics = Array.isArray(
|
|
2091
|
+
allTokens
|
|
2092
|
+
) ? allTokens : [];
|
|
2093
|
+
return balances.map((balance) => {
|
|
2094
|
+
const token = tokens.find((t) => t.symbol === balance.symbol);
|
|
2095
|
+
let tokenMetadata;
|
|
2096
|
+
if (token?.metadata) {
|
|
2097
|
+
try {
|
|
2098
|
+
tokenMetadata = JSON.parse(token.metadata);
|
|
2099
|
+
} catch {
|
|
2100
|
+
tokenMetadata = void 0;
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
const metric = metrics.find((m) => m.symbol === balance.symbol);
|
|
2104
|
+
const lastPrice = Number(metric?.lastPrice ?? "0");
|
|
2105
|
+
const balanceAmount = Number(balance.balance);
|
|
2106
|
+
const usdValue = balance.symbol === "SWAP.HIVE" ? pricePerHive * balanceAmount : lastPrice === 0 ? 0 : Number(
|
|
2107
|
+
(lastPrice * pricePerHive * balanceAmount).toFixed(10)
|
|
2108
|
+
);
|
|
2109
|
+
return new HiveEngineToken({
|
|
2110
|
+
symbol: balance.symbol,
|
|
2111
|
+
name: token?.name ?? balance.symbol,
|
|
2112
|
+
icon: tokenMetadata?.icon ?? "",
|
|
2113
|
+
precision: token?.precision ?? 0,
|
|
2114
|
+
stakingEnabled: token?.stakingEnabled ?? false,
|
|
2115
|
+
delegationEnabled: token?.delegationEnabled ?? false,
|
|
2116
|
+
balance: balance.balance,
|
|
2117
|
+
stake: balance.stake,
|
|
2118
|
+
delegationsIn: balance.delegationsIn,
|
|
2119
|
+
delegationsOut: balance.delegationsOut,
|
|
2120
|
+
usdValue
|
|
2121
|
+
});
|
|
2122
|
+
});
|
|
2123
|
+
},
|
|
2124
|
+
enabled: !!account
|
|
2125
|
+
});
|
|
2126
|
+
}
|
|
1904
2127
|
function getHiveEngineTokensMetadataQueryOptions(tokens) {
|
|
1905
2128
|
return queryOptions({
|
|
1906
2129
|
queryKey: ["assets", "hive-engine", "metadata-list", tokens],
|
|
@@ -2088,6 +2311,30 @@ function getHiveEngineTokensMetricsQueryOptions(symbol, interval = "daily") {
|
|
|
2088
2311
|
}
|
|
2089
2312
|
});
|
|
2090
2313
|
}
|
|
2314
|
+
function getHiveEngineUnclaimedRewardsQueryOptions(username) {
|
|
2315
|
+
return queryOptions({
|
|
2316
|
+
queryKey: ["assets", "hive-engine", "unclaimed", username],
|
|
2317
|
+
staleTime: 6e4,
|
|
2318
|
+
refetchInterval: 9e4,
|
|
2319
|
+
enabled: !!username,
|
|
2320
|
+
queryFn: async () => {
|
|
2321
|
+
try {
|
|
2322
|
+
const response = await fetch(
|
|
2323
|
+
CONFIG.privateApiHost + `/private-api/engine-reward-api/${username}?hive=1`
|
|
2324
|
+
);
|
|
2325
|
+
if (!response.ok) {
|
|
2326
|
+
return [];
|
|
2327
|
+
}
|
|
2328
|
+
const data = await response.json();
|
|
2329
|
+
return Object.values(data).filter(
|
|
2330
|
+
({ pending_token }) => pending_token > 0
|
|
2331
|
+
);
|
|
2332
|
+
} catch (e) {
|
|
2333
|
+
return [];
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
});
|
|
2337
|
+
}
|
|
2091
2338
|
async function delegateEngineToken(payload) {
|
|
2092
2339
|
const parsedAsset = parseAsset(payload.amount);
|
|
2093
2340
|
const quantity = parsedAsset.amount.toString();
|
|
@@ -3541,13 +3788,13 @@ function getTronAssetGeneralInfoQueryOptions(username) {
|
|
|
3541
3788
|
// src/modules/wallets/queries/get-account-wallet-asset-info-query-options.ts
|
|
3542
3789
|
function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { refetch: false }) {
|
|
3543
3790
|
const queryClient = getQueryClient();
|
|
3544
|
-
const fetchQuery = async (
|
|
3791
|
+
const fetchQuery = async (queryOptions43) => {
|
|
3545
3792
|
if (options2.refetch) {
|
|
3546
|
-
await queryClient.fetchQuery(
|
|
3793
|
+
await queryClient.fetchQuery(queryOptions43);
|
|
3547
3794
|
} else {
|
|
3548
|
-
await queryClient.prefetchQuery(
|
|
3795
|
+
await queryClient.prefetchQuery(queryOptions43);
|
|
3549
3796
|
}
|
|
3550
|
-
return queryClient.getQueryData(
|
|
3797
|
+
return queryClient.getQueryData(queryOptions43.queryKey);
|
|
3551
3798
|
};
|
|
3552
3799
|
const portfolioQuery = getVisionPortfolioQueryOptions(username);
|
|
3553
3800
|
const getPortfolioAssetInfo = async () => {
|
|
@@ -4084,6 +4331,6 @@ function useWalletOperation(username, asset, operation) {
|
|
|
4084
4331
|
// src/index.ts
|
|
4085
4332
|
rememberScryptBsvVersion();
|
|
4086
4333
|
|
|
4087
|
-
export { AssetOperation, EcencyWalletBasicTokens, EcencyWalletCurrency, private_api_exports as EcencyWalletsPrivateApi, HIVE_ACCOUNT_OPERATION_GROUPS, HIVE_OPERATION_LIST, HIVE_OPERATION_NAME_BY_ID, HIVE_OPERATION_ORDERS, NaiMap, PointTransactionType, Symbol2 as Symbol, broadcastWithWalletHiveAuth, 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, getVisionPortfolioQueryOptions, getWallet, hasWalletHiveAuthBroadcast, isEmptyDate, lockLarynx, mnemonicToSeedBip39, parseAsset, powerDownHive, powerUpHive, powerUpLarynx, registerWalletHiveAuthBroadcast, resolveHiveOperationFilters, 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 };
|
|
4334
|
+
export { AssetOperation, EcencyWalletBasicTokens, EcencyWalletCurrency, private_api_exports as EcencyWalletsPrivateApi, HIVE_ACCOUNT_OPERATION_GROUPS, HIVE_OPERATION_LIST, HIVE_OPERATION_NAME_BY_ID, HIVE_OPERATION_ORDERS, HiveEngineToken, NaiMap, PointTransactionType, Symbol2 as Symbol, broadcastWithWalletHiveAuth, buildAptTx, buildEthTx, buildExternalTx, buildPsbt, buildSolTx, buildTonTx, buildTronTx, claimInterestHive, decryptMemoWithAccounts, decryptMemoWithKeys, delay, delegateEngineToken, delegateHive, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, encryptMemoWithAccounts, encryptMemoWithKeys, formattedNumber, getAccountWalletAssetInfoQueryOptions, getAccountWalletListQueryOptions, getAllHiveEngineTokensQueryOptions, getAllTokensListQueryOptions, getBoundFetch, 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, getTokenOperationsQueryOptions, getTokenPriceQueryOptions, getVisionPortfolioQueryOptions, getWallet, hasWalletHiveAuthBroadcast, isEmptyDate, lockLarynx, mnemonicToSeedBip39, parseAsset, powerDownHive, powerUpHive, powerUpLarynx, registerWalletHiveAuthBroadcast, resolveHiveOperationFilters, 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 };
|
|
4088
4335
|
//# sourceMappingURL=index.mjs.map
|
|
4089
4336
|
//# sourceMappingURL=index.mjs.map
|