@ecency/wallets 1.5.2 → 1.5.4

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.
@@ -1,4 +1,5 @@
1
- import { CONFIG, getAccountFullQueryOptions, getQueryClient, getDynamicPropsQueryOptions, Keychain, useBroadcastMutation, EcencyAnalytics, getAccessToken, useAccountUpdate } from '@ecency/sdk';
1
+ import { CONFIG, getAccountFullQueryOptions, getQueryClient, getDynamicPropsQueryOptions, useBroadcastMutation, getSpkMarkets, getSpkWallet, getHiveEngineTokensMarket, getHiveEngineTokensBalances, getHiveEngineTokensMetadata, getHiveEngineTokenTransactions, getHiveEngineTokenMetrics, getHiveEngineUnclaimedRewards, EcencyAnalytics, useAccountUpdate } from '@ecency/sdk';
2
+ export { getHiveEngineMetrics, getHiveEngineOpenOrders, getHiveEngineOrderBook, getHiveEngineTradeHistory } from '@ecency/sdk';
2
3
  import { useQuery, queryOptions, infiniteQueryOptions, useQueryClient, useMutation } from '@tanstack/react-query';
3
4
  import bip39, { mnemonicToSeedSync } from 'bip39';
4
5
  import { LRUCache } from 'lru-cache';
@@ -1237,7 +1238,7 @@ function getHivePowerDelegatingsQueryOptions(username) {
1237
1238
  )
1238
1239
  });
1239
1240
  }
1240
- async function transferHive(payload) {
1241
+ async function transferHive(payload, auth) {
1241
1242
  const parsedAsset = parseAsset(payload.amount);
1242
1243
  const token = parsedAsset.symbol;
1243
1244
  const precision = token === "VESTS" /* VESTS */ ? 6 : 3;
@@ -1263,26 +1264,14 @@ async function transferHive(payload) {
1263
1264
  },
1264
1265
  key
1265
1266
  );
1266
- } else if (payload.type === "keychain") {
1267
- return new Promise(
1268
- (resolve, reject) => window.hive_keychain?.requestTransfer(
1269
- payload.from,
1270
- payload.to,
1271
- formattedAmount,
1272
- payload.memo,
1273
- token,
1274
- (resp) => {
1275
- if (!resp.success) {
1276
- reject({ message: "Operation cancelled" });
1277
- }
1278
- resolve(resp);
1279
- },
1280
- true,
1281
- null
1282
- )
1283
- );
1284
- } else if (payload.type === "hiveauth") {
1285
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1267
+ } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1268
+ if (auth?.broadcast) {
1269
+ return auth.broadcast([operation], "active");
1270
+ }
1271
+ if (payload.type === "hiveauth") {
1272
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1273
+ }
1274
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1286
1275
  } else {
1287
1276
  return hs.sendOperation(
1288
1277
  operation,
@@ -1292,7 +1281,7 @@ async function transferHive(payload) {
1292
1281
  );
1293
1282
  }
1294
1283
  }
1295
- async function transferToSavingsHive(payload) {
1284
+ async function transferToSavingsHive(payload, auth) {
1296
1285
  const operationPayload = {
1297
1286
  from: payload.from,
1298
1287
  to: payload.to,
@@ -1306,16 +1295,20 @@ async function transferToSavingsHive(payload) {
1306
1295
  [["transfer_to_savings", params]],
1307
1296
  key
1308
1297
  );
1309
- } else if (payload.type === "keychain") {
1310
- return Keychain.broadcast(payload.from, [operation], "Active");
1311
- } else if (payload.type === "hiveauth") {
1312
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1298
+ } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1299
+ if (auth?.broadcast) {
1300
+ return auth.broadcast([operation], "active");
1301
+ }
1302
+ if (payload.type === "hiveauth") {
1303
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1304
+ }
1305
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1313
1306
  } else {
1314
1307
  return hs.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1315
1308
  });
1316
1309
  }
1317
1310
  }
1318
- async function transferFromSavingsHive(payload) {
1311
+ async function transferFromSavingsHive(payload, auth) {
1319
1312
  const requestId = payload.request_id ?? Date.now() >>> 0;
1320
1313
  const operationPayload = {
1321
1314
  from: payload.from,
@@ -1332,16 +1325,19 @@ async function transferFromSavingsHive(payload) {
1332
1325
  key
1333
1326
  );
1334
1327
  }
1335
- if (payload.type === "keychain") {
1336
- return Keychain.broadcast(payload.from, [operation], "Active");
1337
- }
1338
- if (payload.type === "hiveauth") {
1339
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1328
+ if (payload.type === "keychain" || payload.type === "hiveauth") {
1329
+ if (auth?.broadcast) {
1330
+ return auth.broadcast([operation], "active");
1331
+ }
1332
+ if (payload.type === "hiveauth") {
1333
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1334
+ }
1335
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1340
1336
  }
1341
1337
  return hs.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1342
1338
  });
1343
1339
  }
1344
- async function powerUpHive(payload) {
1340
+ async function powerUpHive(payload, auth) {
1345
1341
  const operationPayload = {
1346
1342
  from: payload.from,
1347
1343
  to: payload.to,
@@ -1355,16 +1351,20 @@ async function powerUpHive(payload) {
1355
1351
  [["transfer_to_vesting", params]],
1356
1352
  key
1357
1353
  );
1358
- } else if (payload.type === "keychain") {
1359
- return Keychain.broadcast(payload.from, [operation], "Active");
1360
- } else if (payload.type === "hiveauth") {
1361
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1354
+ } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1355
+ if (auth?.broadcast) {
1356
+ return auth.broadcast([operation], "active");
1357
+ }
1358
+ if (payload.type === "hiveauth") {
1359
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1360
+ }
1361
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1362
1362
  } else {
1363
1363
  return hs.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1364
1364
  });
1365
1365
  }
1366
1366
  }
1367
- async function delegateHive(payload) {
1367
+ async function delegateHive(payload, auth) {
1368
1368
  const operationPayload = {
1369
1369
  delegator: payload.from,
1370
1370
  delegatee: payload.to,
@@ -1377,16 +1377,20 @@ async function delegateHive(payload) {
1377
1377
  [operation],
1378
1378
  key
1379
1379
  );
1380
- } else if (payload.type === "keychain") {
1381
- return Keychain.broadcast(payload.from, [operation], "Active");
1382
- } else if (payload.type === "hiveauth") {
1383
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1380
+ } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1381
+ if (auth?.broadcast) {
1382
+ return auth.broadcast([operation], "active");
1383
+ }
1384
+ if (payload.type === "hiveauth") {
1385
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1386
+ }
1387
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1384
1388
  } else {
1385
1389
  return hs.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1386
1390
  });
1387
1391
  }
1388
1392
  }
1389
- async function powerDownHive(payload) {
1393
+ async function powerDownHive(payload, auth) {
1390
1394
  const operationPayload = {
1391
1395
  account: payload.from,
1392
1396
  vesting_shares: payload.amount
@@ -1398,16 +1402,20 @@ async function powerDownHive(payload) {
1398
1402
  [operation],
1399
1403
  key
1400
1404
  );
1401
- } else if (payload.type === "keychain") {
1402
- return Keychain.broadcast(payload.from, [operation], "Active");
1403
- } else if (payload.type === "hiveauth") {
1404
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1405
+ } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1406
+ if (auth?.broadcast) {
1407
+ return auth.broadcast([operation], "active");
1408
+ }
1409
+ if (payload.type === "hiveauth") {
1410
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1411
+ }
1412
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1405
1413
  } else {
1406
1414
  return hs.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1407
1415
  });
1408
1416
  }
1409
1417
  }
1410
- async function withdrawVestingRouteHive(payload) {
1418
+ async function withdrawVestingRouteHive(payload, auth) {
1411
1419
  const baseParams = {
1412
1420
  from_account: payload.from_account,
1413
1421
  to_account: payload.to_account,
@@ -1422,24 +1430,25 @@ async function withdrawVestingRouteHive(payload) {
1422
1430
  key
1423
1431
  );
1424
1432
  }
1425
- if (payload.type === "keychain") {
1426
- const { type: type2, ...params2 } = payload;
1427
- return Keychain.broadcast(params2.from_account, [operation], "Active");
1428
- }
1429
- if (payload.type === "hiveauth") {
1430
- return broadcastWithWalletHiveAuth(payload.from_account, [operation], "active");
1433
+ if (payload.type === "keychain" || payload.type === "hiveauth") {
1434
+ if (auth?.broadcast) {
1435
+ return auth.broadcast([operation], "active");
1436
+ }
1437
+ if (payload.type === "hiveauth") {
1438
+ return broadcastWithWalletHiveAuth(payload.from_account, [operation], "active");
1439
+ }
1440
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1431
1441
  }
1432
1442
  const { type, ...params } = payload;
1433
1443
  return hs.sendOperation(operation, { callback: `https://ecency.com/@${params.from_account}/wallet` }, () => {
1434
1444
  });
1435
1445
  }
1436
- function useClaimRewards(username, accessToken, onSuccess) {
1446
+ function useClaimRewards(username, auth, onSuccess) {
1437
1447
  const { data } = useQuery(getAccountFullQueryOptions(username));
1438
1448
  const queryClient = useQueryClient();
1439
1449
  return useBroadcastMutation(
1440
1450
  ["assets", "hive", "claim-rewards", data?.name],
1441
1451
  username,
1442
- accessToken,
1443
1452
  () => {
1444
1453
  if (!data) {
1445
1454
  throw new Error("Failed to fetch account while claiming balance");
@@ -1467,13 +1476,25 @@ function useClaimRewards(username, accessToken, onSuccess) {
1467
1476
  queryClient.invalidateQueries({
1468
1477
  queryKey: getAccountFullQueryOptions(username).queryKey
1469
1478
  });
1479
+ queryClient.invalidateQueries({
1480
+ queryKey: getHiveAssetGeneralInfoQueryOptions(username).queryKey
1481
+ });
1482
+ queryClient.invalidateQueries({
1483
+ queryKey: getHbdAssetGeneralInfoQueryOptions(username).queryKey
1484
+ });
1470
1485
  queryClient.invalidateQueries({
1471
1486
  queryKey: getHivePowerAssetGeneralInfoQueryOptions(username).queryKey
1472
1487
  });
1473
- }
1488
+ ["HIVE", "HBD", "HP"].forEach((asset) => {
1489
+ queryClient.invalidateQueries({
1490
+ queryKey: ["ecency-wallets", "asset-info", username, asset]
1491
+ });
1492
+ });
1493
+ },
1494
+ auth
1474
1495
  );
1475
1496
  }
1476
- async function claimInterestHive(payload) {
1497
+ async function claimInterestHive(payload, auth) {
1477
1498
  const requestId = payload.request_id ?? Date.now() >>> 0;
1478
1499
  const baseOperation = {
1479
1500
  from: payload.from,
@@ -1494,11 +1515,14 @@ async function claimInterestHive(payload) {
1494
1515
  const { key } = payload;
1495
1516
  return CONFIG.hiveClient.broadcast.sendOperations(operations, key);
1496
1517
  }
1497
- if (payload.type === "keychain") {
1498
- return Keychain.broadcast(payload.from, operations, "Active");
1499
- }
1500
- if (payload.type === "hiveauth") {
1501
- return broadcastWithWalletHiveAuth(payload.from, operations, "active");
1518
+ if (payload.type === "keychain" || payload.type === "hiveauth") {
1519
+ if (auth?.broadcast) {
1520
+ return auth.broadcast(operations, "active");
1521
+ }
1522
+ if (payload.type === "hiveauth") {
1523
+ return broadcastWithWalletHiveAuth(payload.from, operations, "active");
1524
+ }
1525
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1502
1526
  }
1503
1527
  return hs.sendOperations(operations, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1504
1528
  });
@@ -1525,7 +1549,7 @@ var AssetOperation = /* @__PURE__ */ ((AssetOperation2) => {
1525
1549
  AssetOperation2["Undelegate"] = "undelegate";
1526
1550
  return AssetOperation2;
1527
1551
  })(AssetOperation || {});
1528
- async function transferSpk(payload) {
1552
+ async function transferSpk(payload, auth) {
1529
1553
  const json = JSON.stringify({
1530
1554
  to: payload.to,
1531
1555
  amount: parseAsset(payload.amount).amount * 1e3,
@@ -1549,16 +1573,14 @@ async function transferSpk(payload) {
1549
1573
  if (payload.type === "key" && "key" in payload) {
1550
1574
  const { key } = payload;
1551
1575
  return CONFIG.hiveClient.broadcast.json(op, key);
1552
- } else if (payload.type === "keychain") {
1553
- return Keychain.customJson(
1554
- payload.from,
1555
- "spkcc_spk_send",
1556
- "Active",
1557
- json,
1558
- payload.to
1559
- );
1560
- } else if (payload.type === "hiveauth") {
1561
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1576
+ } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1577
+ if (auth?.broadcast) {
1578
+ return auth.broadcast([operation], "active");
1579
+ }
1580
+ if (payload.type === "hiveauth") {
1581
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1582
+ }
1583
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1562
1584
  } else {
1563
1585
  const { amount } = parseAsset(payload.amount);
1564
1586
  return hs.sign(
@@ -1578,7 +1600,7 @@ async function transferSpk(payload) {
1578
1600
  );
1579
1601
  }
1580
1602
  }
1581
- var lockLarynx = async (payload) => {
1603
+ var lockLarynx = async (payload, auth) => {
1582
1604
  const json = JSON.stringify({ amount: +payload.amount * 1e3 });
1583
1605
  const op = {
1584
1606
  id: payload.mode === "lock" ? "spkcc_gov_up" : "spkcc_gov_down",
@@ -1598,16 +1620,14 @@ var lockLarynx = async (payload) => {
1598
1620
  if (payload.type === "key" && "key" in payload) {
1599
1621
  const { key } = payload;
1600
1622
  return CONFIG.hiveClient.broadcast.json(op, key);
1601
- } else if (payload.type === "keychain") {
1602
- return Keychain.customJson(
1603
- payload.from,
1604
- op.id,
1605
- "Active",
1606
- json,
1607
- payload.from
1608
- );
1609
- } else if (payload.type === "hiveauth") {
1610
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1623
+ } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1624
+ if (auth?.broadcast) {
1625
+ return auth.broadcast([operation], "active");
1626
+ }
1627
+ if (payload.type === "hiveauth") {
1628
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1629
+ }
1630
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1611
1631
  } else {
1612
1632
  const { amount } = parseAsset(payload.amount);
1613
1633
  return hs.sign(
@@ -1623,7 +1643,7 @@ var lockLarynx = async (payload) => {
1623
1643
  );
1624
1644
  }
1625
1645
  };
1626
- async function powerUpLarynx(payload) {
1646
+ async function powerUpLarynx(payload, auth) {
1627
1647
  const json = JSON.stringify({ amount: +payload.amount * 1e3 });
1628
1648
  const op = {
1629
1649
  id: `spkcc_power_${payload.mode}`,
@@ -1643,16 +1663,14 @@ async function powerUpLarynx(payload) {
1643
1663
  if (payload.type === "key" && "key" in payload) {
1644
1664
  const { key } = payload;
1645
1665
  return CONFIG.hiveClient.broadcast.json(op, key);
1646
- } else if (payload.type === "keychain") {
1647
- return Keychain.customJson(
1648
- payload.from,
1649
- `spkcc_power_${payload.mode}`,
1650
- "Active",
1651
- json,
1652
- ""
1653
- );
1654
- } else if (payload.type === "hiveauth") {
1655
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1666
+ } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1667
+ if (auth?.broadcast) {
1668
+ return auth.broadcast([operation], "active");
1669
+ }
1670
+ if (payload.type === "hiveauth") {
1671
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1672
+ }
1673
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1656
1674
  } else {
1657
1675
  const { amount } = parseAsset(payload.amount);
1658
1676
  return hs.sign(
@@ -1668,7 +1686,7 @@ async function powerUpLarynx(payload) {
1668
1686
  );
1669
1687
  }
1670
1688
  }
1671
- async function transferLarynx(payload) {
1689
+ async function transferLarynx(payload, auth) {
1672
1690
  const json = JSON.stringify({
1673
1691
  to: payload.to,
1674
1692
  amount: parseAsset(payload.amount).amount * 1e3,
@@ -1692,16 +1710,14 @@ async function transferLarynx(payload) {
1692
1710
  if (payload.type === "key" && "key" in payload) {
1693
1711
  const { key } = payload;
1694
1712
  return CONFIG.hiveClient.broadcast.json(op, key);
1695
- } else if (payload.type === "keychain") {
1696
- return Keychain.customJson(
1697
- payload.from,
1698
- "spkcc_send",
1699
- "Active",
1700
- json,
1701
- payload.to
1702
- );
1703
- } else if (payload.type === "hiveauth") {
1704
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1713
+ } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1714
+ if (auth?.broadcast) {
1715
+ return auth.broadcast([operation], "active");
1716
+ }
1717
+ if (payload.type === "hiveauth") {
1718
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1719
+ }
1720
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1705
1721
  } else {
1706
1722
  const { amount } = parseAsset(payload.amount);
1707
1723
  return hs.sign(
@@ -1727,8 +1743,7 @@ function getSpkMarketsQueryOptions() {
1727
1743
  staleTime: 6e4,
1728
1744
  refetchInterval: 9e4,
1729
1745
  queryFn: async () => {
1730
- const response = await fetch(`${CONFIG.spkNode}/markets`);
1731
- const data = await response.json();
1746
+ const data = await getSpkMarkets();
1732
1747
  return {
1733
1748
  list: Object.entries(data.markets.node).map(([name, node]) => ({
1734
1749
  name,
@@ -1743,8 +1758,10 @@ function getSpkWalletQueryOptions(username) {
1743
1758
  return queryOptions({
1744
1759
  queryKey: ["assets", "spk", "wallet", username],
1745
1760
  queryFn: async () => {
1746
- const response = await fetch(CONFIG.spkNode + `/@${username}`);
1747
- return response.json();
1761
+ if (!username) {
1762
+ throw new Error("[SDK][Wallets][SPK] \u2013 username wasn't provided");
1763
+ }
1764
+ return getSpkWallet(username);
1748
1765
  },
1749
1766
  enabled: !!username,
1750
1767
  staleTime: 6e4,
@@ -1916,32 +1933,7 @@ function getAllHiveEngineTokensQueryOptions(account, symbol) {
1916
1933
  return queryOptions({
1917
1934
  queryKey: ["assets", "hive-engine", "all-tokens", account, symbol],
1918
1935
  queryFn: async () => {
1919
- try {
1920
- const response = await fetch(
1921
- `${CONFIG.privateApiHost}/private-api/engine-api`,
1922
- {
1923
- method: "POST",
1924
- body: JSON.stringify({
1925
- jsonrpc: "2.0",
1926
- method: "find",
1927
- params: {
1928
- contract: "market",
1929
- table: "metrics",
1930
- query: {
1931
- ...symbol && { symbol },
1932
- ...account && { account }
1933
- }
1934
- },
1935
- id: 1
1936
- }),
1937
- headers: { "Content-type": "application/json" }
1938
- }
1939
- );
1940
- const data = await response.json();
1941
- return data.result;
1942
- } catch (e) {
1943
- return [];
1944
- }
1936
+ return getHiveEngineTokensMarket(account, symbol);
1945
1937
  }
1946
1938
  });
1947
1939
  }
@@ -2047,48 +2039,10 @@ function getHiveEngineBalancesWithUsdQueryOptions(account, dynamicProps, allToke
2047
2039
  if (!account) {
2048
2040
  throw new Error("[HiveEngine] No account in a balances query");
2049
2041
  }
2050
- const balancesResponse = await fetch(
2051
- `${CONFIG.privateApiHost}/private-api/engine-api`,
2052
- {
2053
- method: "POST",
2054
- body: JSON.stringify({
2055
- jsonrpc: "2.0",
2056
- method: "find",
2057
- params: {
2058
- contract: "tokens",
2059
- table: "balances",
2060
- query: {
2061
- account
2062
- }
2063
- },
2064
- id: 1
2065
- }),
2066
- headers: { "Content-type": "application/json" }
2067
- }
2042
+ const balances = await getHiveEngineTokensBalances(account);
2043
+ const tokens = await getHiveEngineTokensMetadata(
2044
+ balances.map((t) => t.symbol)
2068
2045
  );
2069
- const balancesData = await balancesResponse.json();
2070
- const balances = balancesData.result || [];
2071
- const tokensResponse = await fetch(
2072
- `${CONFIG.privateApiHost}/private-api/engine-api`,
2073
- {
2074
- method: "POST",
2075
- body: JSON.stringify({
2076
- jsonrpc: "2.0",
2077
- method: "find",
2078
- params: {
2079
- contract: "tokens",
2080
- table: "tokens",
2081
- query: {
2082
- symbol: { $in: balances.map((t) => t.symbol) }
2083
- }
2084
- },
2085
- id: 2
2086
- }),
2087
- headers: { "Content-type": "application/json" }
2088
- }
2089
- );
2090
- const tokensData = await tokensResponse.json();
2091
- const tokens = tokensData.result || [];
2092
2046
  const pricePerHive = dynamicProps ? dynamicProps.base / dynamicProps.quote : 0;
2093
2047
  const metrics = Array.isArray(
2094
2048
  allTokens
@@ -2133,27 +2087,7 @@ function getHiveEngineTokensMetadataQueryOptions(tokens) {
2133
2087
  staleTime: 6e4,
2134
2088
  refetchInterval: 9e4,
2135
2089
  queryFn: async () => {
2136
- const response = await fetch(
2137
- `${CONFIG.privateApiHost}/private-api/engine-api`,
2138
- {
2139
- method: "POST",
2140
- body: JSON.stringify({
2141
- jsonrpc: "2.0",
2142
- method: "find",
2143
- params: {
2144
- contract: "tokens",
2145
- table: "tokens",
2146
- query: {
2147
- symbol: { $in: tokens }
2148
- }
2149
- },
2150
- id: 2
2151
- }),
2152
- headers: { "Content-type": "application/json" }
2153
- }
2154
- );
2155
- const data = await response.json();
2156
- return data.result;
2090
+ return getHiveEngineTokensMetadata(tokens);
2157
2091
  }
2158
2092
  });
2159
2093
  }
@@ -2163,27 +2097,7 @@ function getHiveEngineTokensBalancesQueryOptions(username) {
2163
2097
  staleTime: 6e4,
2164
2098
  refetchInterval: 9e4,
2165
2099
  queryFn: async () => {
2166
- const response = await fetch(
2167
- `${CONFIG.privateApiHost}/private-api/engine-api`,
2168
- {
2169
- method: "POST",
2170
- body: JSON.stringify({
2171
- jsonrpc: "2.0",
2172
- method: "find",
2173
- params: {
2174
- contract: "tokens",
2175
- table: "balances",
2176
- query: {
2177
- account: username
2178
- }
2179
- },
2180
- id: 1
2181
- }),
2182
- headers: { "Content-type": "application/json" }
2183
- }
2184
- );
2185
- const data = await response.json();
2186
- return data.result;
2100
+ return getHiveEngineTokensBalances(username);
2187
2101
  }
2188
2102
  });
2189
2103
  }
@@ -2193,25 +2107,7 @@ function getHiveEngineTokensMarketQueryOptions() {
2193
2107
  staleTime: 6e4,
2194
2108
  refetchInterval: 9e4,
2195
2109
  queryFn: async () => {
2196
- const response = await fetch(
2197
- `${CONFIG.privateApiHost}/private-api/engine-api`,
2198
- {
2199
- method: "POST",
2200
- body: JSON.stringify({
2201
- jsonrpc: "2.0",
2202
- method: "find",
2203
- params: {
2204
- contract: "market",
2205
- table: "metrics",
2206
- query: {}
2207
- },
2208
- id: 1
2209
- }),
2210
- headers: { "Content-type": "application/json" }
2211
- }
2212
- );
2213
- const data = await response.json();
2214
- return data.result;
2110
+ return getHiveEngineTokensMarket();
2215
2111
  }
2216
2112
  });
2217
2113
  }
@@ -2281,18 +2177,12 @@ function getHiveEngineTokenTransactionsQueryOptions(username, symbol, limit = 20
2281
2177
  "[SDK][Wallets] \u2013 hive engine token or username missed"
2282
2178
  );
2283
2179
  }
2284
- const url = new URL(
2285
- `${CONFIG.privateApiHost}/private-api/engine-account-history`
2180
+ return getHiveEngineTokenTransactions(
2181
+ username,
2182
+ symbol,
2183
+ limit,
2184
+ pageParam
2286
2185
  );
2287
- url.searchParams.set("account", username);
2288
- url.searchParams.set("symbol", symbol);
2289
- url.searchParams.set("limit", limit.toString());
2290
- url.searchParams.set("offset", pageParam.toString());
2291
- const response = await fetch(url, {
2292
- method: "GET",
2293
- headers: { "Content-type": "application/json" }
2294
- });
2295
- return await response.json();
2296
2186
  }
2297
2187
  });
2298
2188
  }
@@ -2302,15 +2192,7 @@ function getHiveEngineTokensMetricsQueryOptions(symbol, interval = "daily") {
2302
2192
  staleTime: 6e4,
2303
2193
  refetchInterval: 9e4,
2304
2194
  queryFn: async () => {
2305
- const url = new URL(
2306
- `${CONFIG.privateApiHost}/private-api/engine-chart-api`
2307
- );
2308
- url.searchParams.set("symbol", symbol);
2309
- url.searchParams.set("interval", interval);
2310
- const response = await fetch(url, {
2311
- headers: { "Content-type": "application/json" }
2312
- });
2313
- return await response.json();
2195
+ return getHiveEngineTokenMetrics(symbol, interval);
2314
2196
  }
2315
2197
  });
2316
2198
  }
@@ -2322,13 +2204,9 @@ function getHiveEngineUnclaimedRewardsQueryOptions(username) {
2322
2204
  enabled: !!username,
2323
2205
  queryFn: async () => {
2324
2206
  try {
2325
- const response = await fetch(
2326
- CONFIG.privateApiHost + `/private-api/engine-reward-api/${username}?hive=1`
2207
+ const data = await getHiveEngineUnclaimedRewards(
2208
+ username
2327
2209
  );
2328
- if (!response.ok) {
2329
- return [];
2330
- }
2331
- const data = await response.json();
2332
2210
  return Object.values(data).filter(
2333
2211
  ({ pending_token }) => pending_token > 0
2334
2212
  );
@@ -2338,7 +2216,25 @@ function getHiveEngineUnclaimedRewardsQueryOptions(username) {
2338
2216
  }
2339
2217
  });
2340
2218
  }
2341
- async function delegateEngineToken(payload) {
2219
+
2220
+ // src/modules/assets/hive-engine/mutations/broadcast-hive-engine-operation.ts
2221
+ async function broadcastHiveEngineOperation(payload, operation, auth) {
2222
+ if (payload.type === "keychain" || payload.type === "hiveauth") {
2223
+ if (auth?.broadcast) {
2224
+ return auth.broadcast([operation], "active");
2225
+ }
2226
+ if (payload.type === "hiveauth") {
2227
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
2228
+ }
2229
+ if (payload.type === "keychain") {
2230
+ throw new Error("[SDK][Wallets] \u2013 keychain requires auth.broadcast");
2231
+ }
2232
+ }
2233
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
2234
+ }
2235
+
2236
+ // src/modules/assets/hive-engine/mutations/delegate.ts
2237
+ async function delegateEngineToken(payload, auth) {
2342
2238
  const parsedAsset = parseAsset(payload.amount);
2343
2239
  const quantity = parsedAsset.amount.toString();
2344
2240
  const operation = [
@@ -2375,24 +2271,8 @@ async function delegateEngineToken(payload) {
2375
2271
  required_posting_auths: []
2376
2272
  };
2377
2273
  return CONFIG.hiveClient.broadcast.json(op, key);
2378
- } else if (payload.type === "keychain") {
2379
- return new Promise(
2380
- (resolve, reject) => window.hive_keychain?.requestCustomJson(
2381
- payload.from,
2382
- "ssc-mainnet-hive",
2383
- "Active",
2384
- operation[1].json,
2385
- "Token Delegation",
2386
- (resp) => {
2387
- if (!resp.success) {
2388
- reject({ message: "Operation cancelled" });
2389
- }
2390
- resolve(resp);
2391
- }
2392
- )
2393
- );
2394
- } else if (payload.type === "hiveauth") {
2395
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
2274
+ } else if (payload.type === "keychain" || payload.type === "hiveauth") {
2275
+ return broadcastHiveEngineOperation(payload, operation, auth);
2396
2276
  } else {
2397
2277
  return hs.sendOperation(
2398
2278
  operation,
@@ -2402,7 +2282,7 @@ async function delegateEngineToken(payload) {
2402
2282
  );
2403
2283
  }
2404
2284
  }
2405
- async function undelegateEngineToken(payload) {
2285
+ async function undelegateEngineToken(payload, auth) {
2406
2286
  const parsedAsset = parseAsset(payload.amount);
2407
2287
  const quantity = parsedAsset.amount.toString();
2408
2288
  const operation = [
@@ -2439,24 +2319,8 @@ async function undelegateEngineToken(payload) {
2439
2319
  required_posting_auths: []
2440
2320
  };
2441
2321
  return CONFIG.hiveClient.broadcast.json(op, key);
2442
- } else if (payload.type === "keychain") {
2443
- return new Promise(
2444
- (resolve, reject) => window.hive_keychain?.requestCustomJson(
2445
- payload.from,
2446
- "ssc-mainnet-hive",
2447
- "Active",
2448
- operation[1].json,
2449
- "Token Undelegation",
2450
- (resp) => {
2451
- if (!resp.success) {
2452
- reject({ message: "Operation cancelled" });
2453
- }
2454
- resolve(resp);
2455
- }
2456
- )
2457
- );
2458
- } else if (payload.type === "hiveauth") {
2459
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
2322
+ } else if (payload.type === "keychain" || payload.type === "hiveauth") {
2323
+ return broadcastHiveEngineOperation(payload, operation, auth);
2460
2324
  } else {
2461
2325
  return hs.sendOperation(
2462
2326
  operation,
@@ -2466,7 +2330,7 @@ async function undelegateEngineToken(payload) {
2466
2330
  );
2467
2331
  }
2468
2332
  }
2469
- async function stakeEngineToken(payload) {
2333
+ async function stakeEngineToken(payload, auth) {
2470
2334
  const parsedAsset = parseAsset(payload.amount);
2471
2335
  const quantity = parsedAsset.amount.toString();
2472
2336
  const operation = [
@@ -2503,24 +2367,8 @@ async function stakeEngineToken(payload) {
2503
2367
  required_posting_auths: []
2504
2368
  };
2505
2369
  return CONFIG.hiveClient.broadcast.json(op, key);
2506
- } else if (payload.type === "keychain") {
2507
- return new Promise(
2508
- (resolve, reject) => window.hive_keychain?.requestCustomJson(
2509
- payload.from,
2510
- "ssc-mainnet-hive",
2511
- "Active",
2512
- operation[1].json,
2513
- "Token Staking",
2514
- (resp) => {
2515
- if (!resp.success) {
2516
- reject({ message: "Operation cancelled" });
2517
- }
2518
- resolve(resp);
2519
- }
2520
- )
2521
- );
2522
- } else if (payload.type === "hiveauth") {
2523
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
2370
+ } else if (payload.type === "keychain" || payload.type === "hiveauth") {
2371
+ return broadcastHiveEngineOperation(payload, operation, auth);
2524
2372
  } else {
2525
2373
  return hs.sendOperation(
2526
2374
  operation,
@@ -2530,7 +2378,7 @@ async function stakeEngineToken(payload) {
2530
2378
  );
2531
2379
  }
2532
2380
  }
2533
- async function unstakeEngineToken(payload) {
2381
+ async function unstakeEngineToken(payload, auth) {
2534
2382
  const parsedAsset = parseAsset(payload.amount);
2535
2383
  const quantity = parsedAsset.amount.toString();
2536
2384
  const operation = [
@@ -2567,24 +2415,8 @@ async function unstakeEngineToken(payload) {
2567
2415
  required_posting_auths: []
2568
2416
  };
2569
2417
  return CONFIG.hiveClient.broadcast.json(op, key);
2570
- } else if (payload.type === "keychain") {
2571
- return new Promise(
2572
- (resolve, reject) => window.hive_keychain?.requestCustomJson(
2573
- payload.from,
2574
- "ssc-mainnet-hive",
2575
- "Active",
2576
- operation[1].json,
2577
- "Token Unstaking",
2578
- (resp) => {
2579
- if (!resp.success) {
2580
- reject({ message: "Operation cancelled" });
2581
- }
2582
- resolve(resp);
2583
- }
2584
- )
2585
- );
2586
- } else if (payload.type === "hiveauth") {
2587
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
2418
+ } else if (payload.type === "keychain" || payload.type === "hiveauth") {
2419
+ return broadcastHiveEngineOperation(payload, operation, auth);
2588
2420
  } else {
2589
2421
  return hs.sendOperation(
2590
2422
  operation,
@@ -2594,7 +2426,7 @@ async function unstakeEngineToken(payload) {
2594
2426
  );
2595
2427
  }
2596
2428
  }
2597
- async function transferEngineToken(payload) {
2429
+ async function transferEngineToken(payload, auth) {
2598
2430
  const parsedAsset = parseAsset(payload.amount);
2599
2431
  const quantity = parsedAsset.amount.toString();
2600
2432
  const operation = [
@@ -2633,24 +2465,8 @@ async function transferEngineToken(payload) {
2633
2465
  required_posting_auths: []
2634
2466
  };
2635
2467
  return CONFIG.hiveClient.broadcast.json(op, key);
2636
- } else if (payload.type === "keychain") {
2637
- return new Promise(
2638
- (resolve, reject) => window.hive_keychain?.requestCustomJson(
2639
- payload.from,
2640
- "ssc-mainnet-hive",
2641
- "Active",
2642
- operation[1].json,
2643
- "Token Transfer",
2644
- (resp) => {
2645
- if (!resp.success) {
2646
- reject({ message: "Operation cancelled" });
2647
- }
2648
- resolve(resp);
2649
- }
2650
- )
2651
- );
2652
- } else if (payload.type === "hiveauth") {
2653
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
2468
+ } else if (payload.type === "keychain" || payload.type === "hiveauth") {
2469
+ return broadcastHiveEngineOperation(payload, operation, auth);
2654
2470
  } else {
2655
2471
  return hs.sendOperation(
2656
2472
  operation,
@@ -2660,6 +2476,105 @@ async function transferEngineToken(payload) {
2660
2476
  );
2661
2477
  }
2662
2478
  }
2479
+ var ENGINE_CONTRACT_ID = "ssc-mainnet-hive";
2480
+ function buildEngineOrderPayload(action, symbol, quantity, price) {
2481
+ return {
2482
+ contractName: "market",
2483
+ contractAction: action,
2484
+ contractPayload: { symbol, quantity, price }
2485
+ };
2486
+ }
2487
+ function buildEngineCancelPayload(type, orderId) {
2488
+ return {
2489
+ contractName: "market",
2490
+ contractAction: "cancel",
2491
+ contractPayload: { type, id: orderId }
2492
+ };
2493
+ }
2494
+ function buildEngineOperation(account, payload) {
2495
+ return {
2496
+ id: ENGINE_CONTRACT_ID,
2497
+ required_auths: [account],
2498
+ required_posting_auths: [],
2499
+ json: JSON.stringify(payload)
2500
+ };
2501
+ }
2502
+ async function broadcastEngineOperation(account, payload, options2) {
2503
+ const operation = buildEngineOperation(account, payload);
2504
+ const opTuple = ["custom_json", operation];
2505
+ switch (options2?.method) {
2506
+ case "key": {
2507
+ if (!options2.key) {
2508
+ throw new Error("[SDK][Wallets] \u2013 active key is required");
2509
+ }
2510
+ return CONFIG.hiveClient.broadcast.json(operation, options2.key);
2511
+ }
2512
+ case "keychain":
2513
+ case "hiveauth": {
2514
+ if (options2.auth?.broadcast) {
2515
+ return options2.auth.broadcast([opTuple], "active");
2516
+ }
2517
+ if (options2.method === "hiveauth") {
2518
+ return broadcastWithWalletHiveAuth(account, [opTuple], "active");
2519
+ }
2520
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
2521
+ }
2522
+ case "hivesigner":
2523
+ return hs.sendOperation(
2524
+ opTuple,
2525
+ { callback: `https://ecency.com/@${account}/wallet/engine` },
2526
+ () => {
2527
+ }
2528
+ );
2529
+ default:
2530
+ throw new Error("[SDK][Wallets] \u2013 broadcast method is required");
2531
+ }
2532
+ }
2533
+ var placeHiveEngineBuyOrder = async (account, symbol, quantity, price, options2) => broadcastEngineOperation(
2534
+ account,
2535
+ buildEngineOrderPayload("buy", symbol, quantity, price),
2536
+ options2
2537
+ );
2538
+ var placeHiveEngineSellOrder = async (account, symbol, quantity, price, options2) => broadcastEngineOperation(
2539
+ account,
2540
+ buildEngineOrderPayload("sell", symbol, quantity, price),
2541
+ options2
2542
+ );
2543
+ var cancelHiveEngineOrder = async (account, type, orderId, options2) => broadcastEngineOperation(
2544
+ account,
2545
+ buildEngineCancelPayload(type, orderId),
2546
+ options2
2547
+ );
2548
+ async function claimHiveEngineRewards(payload, auth) {
2549
+ const json = JSON.stringify(payload.tokens.map((symbol) => ({ symbol })));
2550
+ const operation = [
2551
+ "custom_json",
2552
+ {
2553
+ id: "scot_claim_token",
2554
+ required_auths: [],
2555
+ required_posting_auths: [payload.account],
2556
+ json
2557
+ }
2558
+ ];
2559
+ if (payload.type === "key" && "key" in payload) {
2560
+ return CONFIG.hiveClient.broadcast.sendOperations([operation], payload.key);
2561
+ }
2562
+ if (payload.type === "keychain" || payload.type === "hiveauth") {
2563
+ if (auth?.broadcast) {
2564
+ return auth.broadcast([operation], "posting");
2565
+ }
2566
+ if (payload.type === "hiveauth") {
2567
+ return broadcastWithWalletHiveAuth(payload.account, [operation], "posting");
2568
+ }
2569
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
2570
+ }
2571
+ return hs.sendOperation(
2572
+ operation,
2573
+ { callback: `https://ecency.com/@${payload.account}/wallet/engine` },
2574
+ () => {
2575
+ }
2576
+ );
2577
+ }
2663
2578
  function getPointsQueryOptions(username) {
2664
2579
  return queryOptions({
2665
2580
  queryKey: ["assets", "points", username],
@@ -2747,7 +2662,7 @@ function getPointsAssetTransactionsQueryOptions(username, type) {
2747
2662
  }
2748
2663
 
2749
2664
  // src/modules/assets/points/mutations/claim-points.ts
2750
- function useClaimPoints(username, onSuccess, onError) {
2665
+ function useClaimPoints(username, accessToken, onSuccess, onError) {
2751
2666
  const { mutateAsync: recordActivity } = EcencyAnalytics.useRecordActivity(
2752
2667
  username,
2753
2668
  "points-claimed"
@@ -2757,16 +2672,31 @@ function useClaimPoints(username, onSuccess, onError) {
2757
2672
  mutationFn: async () => {
2758
2673
  if (!username) {
2759
2674
  throw new Error(
2760
- "[SDK][Wallets][Assets][Points][Claim] \u2013 username wasn`t provided"
2675
+ "[SDK][Wallets][Assets][Points][Claim] \u2013 username wasn't provided"
2761
2676
  );
2762
2677
  }
2763
- return fetchApi(CONFIG.privateApiHost + "/private-api/points-claim", {
2764
- method: "POST",
2765
- headers: {
2766
- "Content-Type": "application/json"
2767
- },
2768
- body: JSON.stringify({ code: getAccessToken(username) })
2769
- });
2678
+ if (!accessToken) {
2679
+ throw new Error(
2680
+ "[SDK][Wallets][Assets][Points][Claim] \u2013 access token wasn't found"
2681
+ );
2682
+ }
2683
+ const response = await fetchApi(
2684
+ CONFIG.privateApiHost + "/private-api/points-claim",
2685
+ {
2686
+ method: "POST",
2687
+ headers: {
2688
+ "Content-Type": "application/json"
2689
+ },
2690
+ body: JSON.stringify({ code: accessToken })
2691
+ }
2692
+ );
2693
+ if (!response.ok) {
2694
+ const body = await response.text();
2695
+ throw new Error(
2696
+ `[SDK][Wallets][Assets][Points][Claim] \u2013 failed with status ${response.status}${body ? `: ${body}` : ""}`
2697
+ );
2698
+ }
2699
+ return response.json();
2770
2700
  },
2771
2701
  onError,
2772
2702
  onSuccess: () => {
@@ -2794,7 +2724,7 @@ async function transferPoint({
2794
2724
  memo,
2795
2725
  type,
2796
2726
  ...payload
2797
- }) {
2727
+ }, auth) {
2798
2728
  const op = [
2799
2729
  "custom_json",
2800
2730
  {
@@ -2813,11 +2743,14 @@ async function transferPoint({
2813
2743
  const { key } = payload;
2814
2744
  return CONFIG.hiveClient.broadcast.sendOperations([op], key);
2815
2745
  }
2816
- if (type === "keychain") {
2817
- return Keychain.broadcast(from, [op], "Active");
2818
- }
2819
- if (type === "hiveauth") {
2820
- return broadcastWithWalletHiveAuth(from, [op], "active");
2746
+ if (type === "keychain" || type === "hiveauth") {
2747
+ if (auth?.broadcast) {
2748
+ return auth.broadcast([op], "active");
2749
+ }
2750
+ if (type === "hiveauth") {
2751
+ return broadcastWithWalletHiveAuth(from, [op], "active");
2752
+ }
2753
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
2821
2754
  }
2822
2755
  return hs.sendOperation(op, { callback: `https://ecency.com/@${from}/wallet` }, () => {
2823
2756
  });
@@ -4041,7 +3974,7 @@ function useCheckWalletExistence() {
4041
3974
  }
4042
3975
  });
4043
3976
  }
4044
- function useUpdateAccountWithWallets(username) {
3977
+ function useUpdateAccountWithWallets(username, accessToken) {
4045
3978
  const fetchApi = getBoundFetch();
4046
3979
  return useMutation({
4047
3980
  mutationKey: ["ecency-wallets", "create-account-with-wallets", username],
@@ -4051,6 +3984,11 @@ function useUpdateAccountWithWallets(username) {
4051
3984
  return new Response(null, { status: 204 });
4052
3985
  }
4053
3986
  const [primaryToken, primaryAddress] = entries[0] ?? ["", ""];
3987
+ if (!accessToken) {
3988
+ throw new Error(
3989
+ "[SDK][Wallets][PrivateApi][WalletsAdd] \u2013 access token wasn`t found"
3990
+ );
3991
+ }
4054
3992
  return fetchApi(CONFIG.privateApiHost + "/private-api/wallets-add", {
4055
3993
  method: "POST",
4056
3994
  headers: {
@@ -4058,7 +3996,7 @@ function useUpdateAccountWithWallets(username) {
4058
3996
  },
4059
3997
  body: JSON.stringify({
4060
3998
  username,
4061
- code: getAccessToken(username),
3999
+ code: accessToken,
4062
4000
  token: primaryToken,
4063
4001
  address: primaryAddress,
4064
4002
  status: 3,
@@ -4192,14 +4130,10 @@ function getGroupedChainTokens(tokens, defaultShow) {
4192
4130
  )
4193
4131
  );
4194
4132
  }
4195
- function useSaveWalletInformationToMetadata(username, accessToken, auth, options2) {
4133
+ function useSaveWalletInformationToMetadata(username, auth, options2) {
4196
4134
  const queryClient = useQueryClient();
4197
4135
  const { data: accountData } = useQuery(getAccountFullQueryOptions(username));
4198
- const { mutateAsync: updateProfile } = useAccountUpdate(
4199
- username,
4200
- accessToken,
4201
- auth
4202
- );
4136
+ const { mutateAsync: updateProfile } = useAccountUpdate(username, auth);
4203
4137
  return useMutation({
4204
4138
  mutationKey: [
4205
4139
  "ecency-wallets",
@@ -4281,7 +4215,7 @@ var engineOperationToFunctionMap = {
4281
4215
  ["delegate" /* Delegate */]: delegateEngineToken,
4282
4216
  ["undelegate" /* Undelegate */]: undelegateEngineToken
4283
4217
  };
4284
- function useWalletOperation(username, asset, operation) {
4218
+ function useWalletOperation(username, asset, operation, auth) {
4285
4219
  const { mutateAsync: recordActivity } = EcencyAnalytics.useRecordActivity(
4286
4220
  username,
4287
4221
  operation
@@ -4291,17 +4225,18 @@ function useWalletOperation(username, asset, operation) {
4291
4225
  mutationFn: async (payload) => {
4292
4226
  const operationFn = operationToFunctionMap[asset]?.[operation];
4293
4227
  if (operationFn) {
4294
- return operationFn(payload);
4228
+ return operationFn(payload, auth);
4295
4229
  }
4296
4230
  const balancesListQuery = getHiveEngineTokensBalancesQueryOptions(username);
4297
4231
  await getQueryClient().prefetchQuery(balancesListQuery);
4298
4232
  const balances = getQueryClient().getQueryData(
4299
4233
  balancesListQuery.queryKey
4300
4234
  );
4301
- if (balances?.some((b) => b.symbol === asset)) {
4235
+ const engineBalances = balances ?? [];
4236
+ if (engineBalances.some((balance) => balance.symbol === asset)) {
4302
4237
  const operationFn2 = engineOperationToFunctionMap[operation];
4303
4238
  if (operationFn2) {
4304
- return operationFn2({ ...payload, asset });
4239
+ return operationFn2({ ...payload, asset }, auth);
4305
4240
  }
4306
4241
  }
4307
4242
  throw new Error("[SDK][Wallets] \u2013 no operation for given asset");
@@ -4338,6 +4273,6 @@ function useWalletOperation(username, asset, operation) {
4338
4273
  // src/index.ts
4339
4274
  rememberScryptBsvVersion();
4340
4275
 
4341
- 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 };
4276
+ 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, cancelHiveEngineOrder, claimHiveEngineRewards, 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, placeHiveEngineBuyOrder, placeHiveEngineSellOrder, 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 };
4342
4277
  //# sourceMappingURL=index.js.map
4343
4278
  //# sourceMappingURL=index.js.map