@ecency/wallets 1.5.14 → 1.5.16

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.
@@ -1289,14 +1289,16 @@ async function transferHive(payload, auth) {
1289
1289
  },
1290
1290
  key
1291
1291
  );
1292
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1292
+ } else if (payload.type === "keychain") {
1293
1293
  if (auth?.broadcast) {
1294
1294
  return auth.broadcast([operation], "active");
1295
1295
  }
1296
- if (payload.type === "hiveauth") {
1297
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1298
- }
1299
1296
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1297
+ } else if (payload.type === "hiveauth") {
1298
+ if (auth?.broadcast) {
1299
+ return auth.broadcast([operation], "active");
1300
+ }
1301
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1300
1302
  } else {
1301
1303
  return hs__default.default.sendOperation(
1302
1304
  operation,
@@ -1320,14 +1322,16 @@ async function transferToSavingsHive(payload, auth) {
1320
1322
  [["transfer_to_savings", params]],
1321
1323
  key
1322
1324
  );
1323
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1325
+ } else if (payload.type === "keychain") {
1324
1326
  if (auth?.broadcast) {
1325
1327
  return auth.broadcast([operation], "active");
1326
1328
  }
1327
- if (payload.type === "hiveauth") {
1328
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1329
- }
1330
1329
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1330
+ } else if (payload.type === "hiveauth") {
1331
+ if (auth?.broadcast) {
1332
+ return auth.broadcast([operation], "active");
1333
+ }
1334
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1331
1335
  } else {
1332
1336
  return hs__default.default.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1333
1337
  });
@@ -1350,15 +1354,18 @@ async function transferFromSavingsHive(payload, auth) {
1350
1354
  key
1351
1355
  );
1352
1356
  }
1353
- if (payload.type === "keychain" || payload.type === "hiveauth") {
1357
+ if (payload.type === "keychain") {
1354
1358
  if (auth?.broadcast) {
1355
1359
  return auth.broadcast([operation], "active");
1356
1360
  }
1357
- if (payload.type === "hiveauth") {
1358
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1359
- }
1360
1361
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1361
1362
  }
1363
+ if (payload.type === "hiveauth") {
1364
+ if (auth?.broadcast) {
1365
+ return auth.broadcast([operation], "active");
1366
+ }
1367
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1368
+ }
1362
1369
  return hs__default.default.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1363
1370
  });
1364
1371
  }
@@ -1376,14 +1383,16 @@ async function powerUpHive(payload, auth) {
1376
1383
  [["transfer_to_vesting", params]],
1377
1384
  key
1378
1385
  );
1379
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1386
+ } else if (payload.type === "keychain") {
1380
1387
  if (auth?.broadcast) {
1381
1388
  return auth.broadcast([operation], "active");
1382
1389
  }
1383
- if (payload.type === "hiveauth") {
1384
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1385
- }
1386
1390
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1391
+ } else if (payload.type === "hiveauth") {
1392
+ if (auth?.broadcast) {
1393
+ return auth.broadcast([operation], "active");
1394
+ }
1395
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1387
1396
  } else {
1388
1397
  return hs__default.default.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1389
1398
  });
@@ -1402,14 +1411,16 @@ async function delegateHive(payload, auth) {
1402
1411
  [operation],
1403
1412
  key
1404
1413
  );
1405
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1414
+ } else if (payload.type === "keychain") {
1406
1415
  if (auth?.broadcast) {
1407
1416
  return auth.broadcast([operation], "active");
1408
1417
  }
1409
- if (payload.type === "hiveauth") {
1410
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1411
- }
1412
1418
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1419
+ } else if (payload.type === "hiveauth") {
1420
+ if (auth?.broadcast) {
1421
+ return auth.broadcast([operation], "active");
1422
+ }
1423
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1413
1424
  } else {
1414
1425
  return hs__default.default.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1415
1426
  });
@@ -1427,14 +1438,16 @@ async function powerDownHive(payload, auth) {
1427
1438
  [operation],
1428
1439
  key
1429
1440
  );
1430
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1441
+ } else if (payload.type === "keychain") {
1431
1442
  if (auth?.broadcast) {
1432
1443
  return auth.broadcast([operation], "active");
1433
1444
  }
1434
- if (payload.type === "hiveauth") {
1435
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1436
- }
1437
1445
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1446
+ } else if (payload.type === "hiveauth") {
1447
+ if (auth?.broadcast) {
1448
+ return auth.broadcast([operation], "active");
1449
+ }
1450
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1438
1451
  } else {
1439
1452
  return hs__default.default.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1440
1453
  });
@@ -1455,15 +1468,18 @@ async function withdrawVestingRouteHive(payload, auth) {
1455
1468
  key
1456
1469
  );
1457
1470
  }
1458
- if (payload.type === "keychain" || payload.type === "hiveauth") {
1471
+ if (payload.type === "keychain") {
1459
1472
  if (auth?.broadcast) {
1460
1473
  return auth.broadcast([operation], "active");
1461
1474
  }
1462
- if (payload.type === "hiveauth") {
1463
- return broadcastWithWalletHiveAuth(payload.from_account, [operation], "active");
1464
- }
1465
1475
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1466
1476
  }
1477
+ if (payload.type === "hiveauth") {
1478
+ if (auth?.broadcast) {
1479
+ return auth.broadcast([operation], "active");
1480
+ }
1481
+ return broadcastWithWalletHiveAuth(payload.from_account, [operation], "active");
1482
+ }
1467
1483
  const { type, ...params } = payload;
1468
1484
  return hs__default.default.sendOperation(operation, { callback: `https://ecency.com/@${params.from_account}/wallet` }, () => {
1469
1485
  });
@@ -1565,15 +1581,18 @@ async function claimInterestHive(payload, auth) {
1565
1581
  const { key } = payload;
1566
1582
  return sdk.CONFIG.hiveClient.broadcast.sendOperations(operations, key);
1567
1583
  }
1568
- if (payload.type === "keychain" || payload.type === "hiveauth") {
1584
+ if (payload.type === "keychain") {
1569
1585
  if (auth?.broadcast) {
1570
1586
  return auth.broadcast(operations, "active");
1571
1587
  }
1572
- if (payload.type === "hiveauth") {
1573
- return broadcastWithWalletHiveAuth(payload.from, operations, "active");
1574
- }
1575
1588
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1576
1589
  }
1590
+ if (payload.type === "hiveauth") {
1591
+ if (auth?.broadcast) {
1592
+ return auth.broadcast(operations, "active");
1593
+ }
1594
+ return broadcastWithWalletHiveAuth(payload.from, operations, "active");
1595
+ }
1577
1596
  return hs__default.default.sendOperations(operations, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1578
1597
  });
1579
1598
  }
@@ -1591,14 +1610,16 @@ async function convertHbd(payload, auth) {
1591
1610
  [["convert", { ...params, owner: params.from, requestid }]],
1592
1611
  key
1593
1612
  );
1594
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1613
+ } else if (payload.type === "keychain") {
1595
1614
  if (auth?.broadcast) {
1596
1615
  return auth.broadcast([operation], "active");
1597
1616
  }
1598
- if (payload.type === "hiveauth") {
1599
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1600
- }
1601
1617
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1618
+ } else if (payload.type === "hiveauth") {
1619
+ if (auth?.broadcast) {
1620
+ return auth.broadcast([operation], "active");
1621
+ }
1622
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1602
1623
  } else {
1603
1624
  return hs__default.default.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1604
1625
  });
@@ -1651,14 +1672,16 @@ async function transferSpk(payload, auth) {
1651
1672
  if (payload.type === "key" && "key" in payload) {
1652
1673
  const { key } = payload;
1653
1674
  return sdk.CONFIG.hiveClient.broadcast.json(op, key);
1654
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1675
+ } else if (payload.type === "keychain") {
1655
1676
  if (auth?.broadcast) {
1656
1677
  return auth.broadcast([operation], "active");
1657
1678
  }
1658
- if (payload.type === "hiveauth") {
1659
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1660
- }
1661
1679
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1680
+ } else if (payload.type === "hiveauth") {
1681
+ if (auth?.broadcast) {
1682
+ return auth.broadcast([operation], "active");
1683
+ }
1684
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1662
1685
  } else {
1663
1686
  const { amount } = parseAsset(payload.amount);
1664
1687
  return hs__default.default.sign(
@@ -1698,14 +1721,16 @@ var lockLarynx = async (payload, auth) => {
1698
1721
  if (payload.type === "key" && "key" in payload) {
1699
1722
  const { key } = payload;
1700
1723
  return sdk.CONFIG.hiveClient.broadcast.json(op, key);
1701
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1724
+ } else if (payload.type === "keychain") {
1702
1725
  if (auth?.broadcast) {
1703
1726
  return auth.broadcast([operation], "active");
1704
1727
  }
1705
- if (payload.type === "hiveauth") {
1706
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1707
- }
1708
1728
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1729
+ } else if (payload.type === "hiveauth") {
1730
+ if (auth?.broadcast) {
1731
+ return auth.broadcast([operation], "active");
1732
+ }
1733
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1709
1734
  } else {
1710
1735
  const { amount } = parseAsset(payload.amount);
1711
1736
  return hs__default.default.sign(
@@ -1741,14 +1766,16 @@ async function powerUpLarynx(payload, auth) {
1741
1766
  if (payload.type === "key" && "key" in payload) {
1742
1767
  const { key } = payload;
1743
1768
  return sdk.CONFIG.hiveClient.broadcast.json(op, key);
1744
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1769
+ } else if (payload.type === "keychain") {
1745
1770
  if (auth?.broadcast) {
1746
1771
  return auth.broadcast([operation], "active");
1747
1772
  }
1748
- if (payload.type === "hiveauth") {
1749
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1750
- }
1751
1773
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1774
+ } else if (payload.type === "hiveauth") {
1775
+ if (auth?.broadcast) {
1776
+ return auth.broadcast([operation], "active");
1777
+ }
1778
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1752
1779
  } else {
1753
1780
  const { amount } = parseAsset(payload.amount);
1754
1781
  return hs__default.default.sign(
@@ -1788,14 +1815,16 @@ async function transferLarynx(payload, auth) {
1788
1815
  if (payload.type === "key" && "key" in payload) {
1789
1816
  const { key } = payload;
1790
1817
  return sdk.CONFIG.hiveClient.broadcast.json(op, key);
1791
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1818
+ } else if (payload.type === "keychain") {
1792
1819
  if (auth?.broadcast) {
1793
1820
  return auth.broadcast([operation], "active");
1794
1821
  }
1795
- if (payload.type === "hiveauth") {
1796
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1797
- }
1798
1822
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1823
+ } else if (payload.type === "hiveauth") {
1824
+ if (auth?.broadcast) {
1825
+ return auth.broadcast([operation], "active");
1826
+ }
1827
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1799
1828
  } else {
1800
1829
  const { amount } = parseAsset(payload.amount);
1801
1830
  return hs__default.default.sign(
@@ -2297,16 +2326,17 @@ function getHiveEngineUnclaimedRewardsQueryOptions(username) {
2297
2326
 
2298
2327
  // src/modules/assets/hive-engine/mutations/broadcast-hive-engine-operation.ts
2299
2328
  async function broadcastHiveEngineOperation(payload, operation, auth) {
2300
- if (payload.type === "keychain" || payload.type === "hiveauth") {
2329
+ if (payload.type === "keychain") {
2301
2330
  if (auth?.broadcast) {
2302
2331
  return auth.broadcast([operation], "active");
2303
2332
  }
2304
- if (payload.type === "hiveauth") {
2305
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
2306
- }
2307
- if (payload.type === "keychain") {
2308
- throw new Error("[SDK][Wallets] \u2013 keychain requires auth.broadcast");
2333
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
2334
+ }
2335
+ if (payload.type === "hiveauth") {
2336
+ if (auth?.broadcast) {
2337
+ return auth.broadcast([operation], "active");
2309
2338
  }
2339
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
2310
2340
  }
2311
2341
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
2312
2342
  }
@@ -2637,15 +2667,18 @@ async function claimHiveEngineRewards(payload, auth) {
2637
2667
  if (payload.type === "key" && "key" in payload) {
2638
2668
  return sdk.CONFIG.hiveClient.broadcast.sendOperations([operation], payload.key);
2639
2669
  }
2640
- if (payload.type === "keychain" || payload.type === "hiveauth") {
2670
+ if (payload.type === "keychain") {
2641
2671
  if (auth?.broadcast) {
2642
2672
  return auth.broadcast([operation], "posting");
2643
2673
  }
2644
- if (payload.type === "hiveauth") {
2645
- return broadcastWithWalletHiveAuth(payload.account, [operation], "posting");
2646
- }
2647
2674
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
2648
2675
  }
2676
+ if (payload.type === "hiveauth") {
2677
+ if (auth?.broadcast) {
2678
+ return auth.broadcast([operation], "posting");
2679
+ }
2680
+ return broadcastWithWalletHiveAuth(payload.account, [operation], "posting");
2681
+ }
2649
2682
  return hs__default.default.sendOperation(
2650
2683
  operation,
2651
2684
  { callback: `https://ecency.com/@${payload.account}/wallet/engine` },
@@ -2828,15 +2861,18 @@ async function transferPoint({
2828
2861
  const { key } = payload;
2829
2862
  return sdk.CONFIG.hiveClient.broadcast.sendOperations([op], key);
2830
2863
  }
2831
- if (type === "keychain" || type === "hiveauth") {
2864
+ if (type === "keychain") {
2832
2865
  if (auth?.broadcast) {
2833
2866
  return auth.broadcast([op], "active");
2834
2867
  }
2835
- if (type === "hiveauth") {
2836
- return broadcastWithWalletHiveAuth(from, [op], "active");
2837
- }
2838
2868
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
2839
2869
  }
2870
+ if (type === "hiveauth") {
2871
+ if (auth?.broadcast) {
2872
+ return auth.broadcast([op], "active");
2873
+ }
2874
+ return broadcastWithWalletHiveAuth(from, [op], "active");
2875
+ }
2840
2876
  return hs__default.default.sendOperation(op, { callback: `https://ecency.com/@${from}/wallet` }, () => {
2841
2877
  });
2842
2878
  }
@@ -3620,6 +3656,37 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
3620
3656
  (assetItem) => assetItem.symbol.toUpperCase() === asset.toUpperCase()
3621
3657
  );
3622
3658
  if (!assetInfo) return void 0;
3659
+ const parts = [];
3660
+ if (assetInfo.liquid !== void 0 && assetInfo.liquid !== null) {
3661
+ parts.push({ name: "liquid", balance: assetInfo.liquid });
3662
+ }
3663
+ if (assetInfo.staked !== void 0 && assetInfo.staked !== null && assetInfo.staked > 0) {
3664
+ parts.push({ name: "staked", balance: assetInfo.staked });
3665
+ }
3666
+ if (assetInfo.savings !== void 0 && assetInfo.savings !== null && assetInfo.savings > 0) {
3667
+ parts.push({ name: "savings", balance: assetInfo.savings });
3668
+ }
3669
+ if (assetInfo.extraData && Array.isArray(assetInfo.extraData)) {
3670
+ for (const extraItem of assetInfo.extraData) {
3671
+ if (!extraItem || typeof extraItem !== "object") continue;
3672
+ const dataKey = extraItem.dataKey;
3673
+ const value = extraItem.value;
3674
+ if (typeof value === "string") {
3675
+ const cleanValue = value.replace(/,/g, "");
3676
+ const match = cleanValue.match(/[+-]?\s*(\d+(?:\.\d+)?)/);
3677
+ if (match) {
3678
+ const numValue = Math.abs(Number.parseFloat(match[1]));
3679
+ if (dataKey === "delegated_hive_power") {
3680
+ parts.push({ name: "outgoing_delegations", balance: numValue });
3681
+ } else if (dataKey === "received_hive_power") {
3682
+ parts.push({ name: "incoming_delegations", balance: numValue });
3683
+ } else if (dataKey === "powering_down_hive_power") {
3684
+ parts.push({ name: "pending_power_down", balance: numValue });
3685
+ }
3686
+ }
3687
+ }
3688
+ }
3689
+ }
3623
3690
  return {
3624
3691
  name: assetInfo.symbol,
3625
3692
  title: assetInfo.name,
@@ -3627,7 +3694,8 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
3627
3694
  accountBalance: assetInfo.balance,
3628
3695
  apr: assetInfo.apr?.toString(),
3629
3696
  layer: assetInfo.layer,
3630
- pendingRewards: assetInfo.pendingRewards
3697
+ pendingRewards: assetInfo.pendingRewards,
3698
+ parts
3631
3699
  };
3632
3700
  } catch (e) {
3633
3701
  return void 0;
@@ -4174,7 +4242,18 @@ var engineOperationToFunctionMap = {
4174
4242
  ["stake" /* Stake */]: stakeEngineToken,
4175
4243
  ["unstake" /* Unstake */]: unstakeEngineToken,
4176
4244
  ["delegate" /* Delegate */]: delegateEngineToken,
4177
- ["undelegate" /* Undelegate */]: undelegateEngineToken
4245
+ ["undelegate" /* Undelegate */]: undelegateEngineToken,
4246
+ ["claim" /* Claim */]: (payload, auth) => {
4247
+ return claimHiveEngineRewards(
4248
+ {
4249
+ account: payload.from,
4250
+ tokens: [payload.asset],
4251
+ type: payload.type,
4252
+ ...payload.type === "key" && payload.key ? { key: payload.key } : {}
4253
+ },
4254
+ auth
4255
+ );
4256
+ }
4178
4257
  };
4179
4258
  function useWalletOperation(username, asset, operation, auth) {
4180
4259
  const { mutateAsync: recordActivity } = sdk.EcencyAnalytics.useRecordActivity(