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