@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.
@@ -1264,14 +1264,16 @@ async function transferHive(payload, auth) {
1264
1264
  },
1265
1265
  key
1266
1266
  );
1267
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1267
+ } else if (payload.type === "keychain") {
1268
1268
  if (auth?.broadcast) {
1269
1269
  return auth.broadcast([operation], "active");
1270
1270
  }
1271
- if (payload.type === "hiveauth") {
1272
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1273
- }
1274
1271
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1272
+ } else if (payload.type === "hiveauth") {
1273
+ if (auth?.broadcast) {
1274
+ return auth.broadcast([operation], "active");
1275
+ }
1276
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1275
1277
  } else {
1276
1278
  return hs.sendOperation(
1277
1279
  operation,
@@ -1295,14 +1297,16 @@ async function transferToSavingsHive(payload, auth) {
1295
1297
  [["transfer_to_savings", params]],
1296
1298
  key
1297
1299
  );
1298
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1300
+ } else if (payload.type === "keychain") {
1299
1301
  if (auth?.broadcast) {
1300
1302
  return auth.broadcast([operation], "active");
1301
1303
  }
1302
- if (payload.type === "hiveauth") {
1303
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1304
- }
1305
1304
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1305
+ } else if (payload.type === "hiveauth") {
1306
+ if (auth?.broadcast) {
1307
+ return auth.broadcast([operation], "active");
1308
+ }
1309
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1306
1310
  } else {
1307
1311
  return hs.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1308
1312
  });
@@ -1325,15 +1329,18 @@ async function transferFromSavingsHive(payload, auth) {
1325
1329
  key
1326
1330
  );
1327
1331
  }
1328
- if (payload.type === "keychain" || payload.type === "hiveauth") {
1332
+ if (payload.type === "keychain") {
1329
1333
  if (auth?.broadcast) {
1330
1334
  return auth.broadcast([operation], "active");
1331
1335
  }
1332
- if (payload.type === "hiveauth") {
1333
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1334
- }
1335
1336
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1336
1337
  }
1338
+ if (payload.type === "hiveauth") {
1339
+ if (auth?.broadcast) {
1340
+ return auth.broadcast([operation], "active");
1341
+ }
1342
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1343
+ }
1337
1344
  return hs.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1338
1345
  });
1339
1346
  }
@@ -1351,14 +1358,16 @@ async function powerUpHive(payload, auth) {
1351
1358
  [["transfer_to_vesting", params]],
1352
1359
  key
1353
1360
  );
1354
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1361
+ } else if (payload.type === "keychain") {
1355
1362
  if (auth?.broadcast) {
1356
1363
  return auth.broadcast([operation], "active");
1357
1364
  }
1358
- if (payload.type === "hiveauth") {
1359
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1360
- }
1361
1365
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1366
+ } else if (payload.type === "hiveauth") {
1367
+ if (auth?.broadcast) {
1368
+ return auth.broadcast([operation], "active");
1369
+ }
1370
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1362
1371
  } else {
1363
1372
  return hs.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1364
1373
  });
@@ -1377,14 +1386,16 @@ async function delegateHive(payload, auth) {
1377
1386
  [operation],
1378
1387
  key
1379
1388
  );
1380
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1389
+ } else if (payload.type === "keychain") {
1381
1390
  if (auth?.broadcast) {
1382
1391
  return auth.broadcast([operation], "active");
1383
1392
  }
1384
- if (payload.type === "hiveauth") {
1385
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1386
- }
1387
1393
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1394
+ } else if (payload.type === "hiveauth") {
1395
+ if (auth?.broadcast) {
1396
+ return auth.broadcast([operation], "active");
1397
+ }
1398
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1388
1399
  } else {
1389
1400
  return hs.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1390
1401
  });
@@ -1402,14 +1413,16 @@ async function powerDownHive(payload, auth) {
1402
1413
  [operation],
1403
1414
  key
1404
1415
  );
1405
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1416
+ } else if (payload.type === "keychain") {
1406
1417
  if (auth?.broadcast) {
1407
1418
  return auth.broadcast([operation], "active");
1408
1419
  }
1409
- if (payload.type === "hiveauth") {
1410
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1411
- }
1412
1420
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1421
+ } else if (payload.type === "hiveauth") {
1422
+ if (auth?.broadcast) {
1423
+ return auth.broadcast([operation], "active");
1424
+ }
1425
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1413
1426
  } else {
1414
1427
  return hs.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1415
1428
  });
@@ -1430,15 +1443,18 @@ async function withdrawVestingRouteHive(payload, auth) {
1430
1443
  key
1431
1444
  );
1432
1445
  }
1433
- if (payload.type === "keychain" || payload.type === "hiveauth") {
1446
+ if (payload.type === "keychain") {
1434
1447
  if (auth?.broadcast) {
1435
1448
  return auth.broadcast([operation], "active");
1436
1449
  }
1437
- if (payload.type === "hiveauth") {
1438
- return broadcastWithWalletHiveAuth(payload.from_account, [operation], "active");
1439
- }
1440
1450
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1441
1451
  }
1452
+ if (payload.type === "hiveauth") {
1453
+ if (auth?.broadcast) {
1454
+ return auth.broadcast([operation], "active");
1455
+ }
1456
+ return broadcastWithWalletHiveAuth(payload.from_account, [operation], "active");
1457
+ }
1442
1458
  const { type, ...params } = payload;
1443
1459
  return hs.sendOperation(operation, { callback: `https://ecency.com/@${params.from_account}/wallet` }, () => {
1444
1460
  });
@@ -1540,15 +1556,18 @@ async function claimInterestHive(payload, auth) {
1540
1556
  const { key } = payload;
1541
1557
  return CONFIG.hiveClient.broadcast.sendOperations(operations, key);
1542
1558
  }
1543
- if (payload.type === "keychain" || payload.type === "hiveauth") {
1559
+ if (payload.type === "keychain") {
1544
1560
  if (auth?.broadcast) {
1545
1561
  return auth.broadcast(operations, "active");
1546
1562
  }
1547
- if (payload.type === "hiveauth") {
1548
- return broadcastWithWalletHiveAuth(payload.from, operations, "active");
1549
- }
1550
1563
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1551
1564
  }
1565
+ if (payload.type === "hiveauth") {
1566
+ if (auth?.broadcast) {
1567
+ return auth.broadcast(operations, "active");
1568
+ }
1569
+ return broadcastWithWalletHiveAuth(payload.from, operations, "active");
1570
+ }
1552
1571
  return hs.sendOperations(operations, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1553
1572
  });
1554
1573
  }
@@ -1566,14 +1585,16 @@ async function convertHbd(payload, auth) {
1566
1585
  [["convert", { ...params, owner: params.from, requestid }]],
1567
1586
  key
1568
1587
  );
1569
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1588
+ } else if (payload.type === "keychain") {
1570
1589
  if (auth?.broadcast) {
1571
1590
  return auth.broadcast([operation], "active");
1572
1591
  }
1573
- if (payload.type === "hiveauth") {
1574
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1575
- }
1576
1592
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1593
+ } else if (payload.type === "hiveauth") {
1594
+ if (auth?.broadcast) {
1595
+ return auth.broadcast([operation], "active");
1596
+ }
1597
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1577
1598
  } else {
1578
1599
  return hs.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
1579
1600
  });
@@ -1626,14 +1647,16 @@ async function transferSpk(payload, auth) {
1626
1647
  if (payload.type === "key" && "key" in payload) {
1627
1648
  const { key } = payload;
1628
1649
  return CONFIG.hiveClient.broadcast.json(op, key);
1629
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1650
+ } else if (payload.type === "keychain") {
1630
1651
  if (auth?.broadcast) {
1631
1652
  return auth.broadcast([operation], "active");
1632
1653
  }
1633
- if (payload.type === "hiveauth") {
1634
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1635
- }
1636
1654
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1655
+ } else if (payload.type === "hiveauth") {
1656
+ if (auth?.broadcast) {
1657
+ return auth.broadcast([operation], "active");
1658
+ }
1659
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1637
1660
  } else {
1638
1661
  const { amount } = parseAsset(payload.amount);
1639
1662
  return hs.sign(
@@ -1673,14 +1696,16 @@ var lockLarynx = async (payload, auth) => {
1673
1696
  if (payload.type === "key" && "key" in payload) {
1674
1697
  const { key } = payload;
1675
1698
  return CONFIG.hiveClient.broadcast.json(op, key);
1676
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1699
+ } else if (payload.type === "keychain") {
1677
1700
  if (auth?.broadcast) {
1678
1701
  return auth.broadcast([operation], "active");
1679
1702
  }
1680
- if (payload.type === "hiveauth") {
1681
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1682
- }
1683
1703
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1704
+ } else if (payload.type === "hiveauth") {
1705
+ if (auth?.broadcast) {
1706
+ return auth.broadcast([operation], "active");
1707
+ }
1708
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1684
1709
  } else {
1685
1710
  const { amount } = parseAsset(payload.amount);
1686
1711
  return hs.sign(
@@ -1716,14 +1741,16 @@ async function powerUpLarynx(payload, auth) {
1716
1741
  if (payload.type === "key" && "key" in payload) {
1717
1742
  const { key } = payload;
1718
1743
  return CONFIG.hiveClient.broadcast.json(op, key);
1719
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1744
+ } else if (payload.type === "keychain") {
1720
1745
  if (auth?.broadcast) {
1721
1746
  return auth.broadcast([operation], "active");
1722
1747
  }
1723
- if (payload.type === "hiveauth") {
1724
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1725
- }
1726
1748
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1749
+ } else if (payload.type === "hiveauth") {
1750
+ if (auth?.broadcast) {
1751
+ return auth.broadcast([operation], "active");
1752
+ }
1753
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1727
1754
  } else {
1728
1755
  const { amount } = parseAsset(payload.amount);
1729
1756
  return hs.sign(
@@ -1763,14 +1790,16 @@ async function transferLarynx(payload, auth) {
1763
1790
  if (payload.type === "key" && "key" in payload) {
1764
1791
  const { key } = payload;
1765
1792
  return CONFIG.hiveClient.broadcast.json(op, key);
1766
- } else if (payload.type === "keychain" || payload.type === "hiveauth") {
1793
+ } else if (payload.type === "keychain") {
1767
1794
  if (auth?.broadcast) {
1768
1795
  return auth.broadcast([operation], "active");
1769
1796
  }
1770
- if (payload.type === "hiveauth") {
1771
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1772
- }
1773
1797
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
1798
+ } else if (payload.type === "hiveauth") {
1799
+ if (auth?.broadcast) {
1800
+ return auth.broadcast([operation], "active");
1801
+ }
1802
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
1774
1803
  } else {
1775
1804
  const { amount } = parseAsset(payload.amount);
1776
1805
  return hs.sign(
@@ -2272,16 +2301,17 @@ function getHiveEngineUnclaimedRewardsQueryOptions(username) {
2272
2301
 
2273
2302
  // src/modules/assets/hive-engine/mutations/broadcast-hive-engine-operation.ts
2274
2303
  async function broadcastHiveEngineOperation(payload, operation, auth) {
2275
- if (payload.type === "keychain" || payload.type === "hiveauth") {
2304
+ if (payload.type === "keychain") {
2276
2305
  if (auth?.broadcast) {
2277
2306
  return auth.broadcast([operation], "active");
2278
2307
  }
2279
- if (payload.type === "hiveauth") {
2280
- return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
2281
- }
2282
- if (payload.type === "keychain") {
2283
- throw new Error("[SDK][Wallets] \u2013 keychain requires auth.broadcast");
2308
+ throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
2309
+ }
2310
+ if (payload.type === "hiveauth") {
2311
+ if (auth?.broadcast) {
2312
+ return auth.broadcast([operation], "active");
2284
2313
  }
2314
+ return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
2285
2315
  }
2286
2316
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
2287
2317
  }
@@ -2612,15 +2642,18 @@ async function claimHiveEngineRewards(payload, auth) {
2612
2642
  if (payload.type === "key" && "key" in payload) {
2613
2643
  return CONFIG.hiveClient.broadcast.sendOperations([operation], payload.key);
2614
2644
  }
2615
- if (payload.type === "keychain" || payload.type === "hiveauth") {
2645
+ if (payload.type === "keychain") {
2616
2646
  if (auth?.broadcast) {
2617
2647
  return auth.broadcast([operation], "posting");
2618
2648
  }
2619
- if (payload.type === "hiveauth") {
2620
- return broadcastWithWalletHiveAuth(payload.account, [operation], "posting");
2621
- }
2622
2649
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
2623
2650
  }
2651
+ if (payload.type === "hiveauth") {
2652
+ if (auth?.broadcast) {
2653
+ return auth.broadcast([operation], "posting");
2654
+ }
2655
+ return broadcastWithWalletHiveAuth(payload.account, [operation], "posting");
2656
+ }
2624
2657
  return hs.sendOperation(
2625
2658
  operation,
2626
2659
  { callback: `https://ecency.com/@${payload.account}/wallet/engine` },
@@ -2803,15 +2836,18 @@ async function transferPoint({
2803
2836
  const { key } = payload;
2804
2837
  return CONFIG.hiveClient.broadcast.sendOperations([op], key);
2805
2838
  }
2806
- if (type === "keychain" || type === "hiveauth") {
2839
+ if (type === "keychain") {
2807
2840
  if (auth?.broadcast) {
2808
2841
  return auth.broadcast([op], "active");
2809
2842
  }
2810
- if (type === "hiveauth") {
2811
- return broadcastWithWalletHiveAuth(from, [op], "active");
2812
- }
2813
2843
  throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
2814
2844
  }
2845
+ if (type === "hiveauth") {
2846
+ if (auth?.broadcast) {
2847
+ return auth.broadcast([op], "active");
2848
+ }
2849
+ return broadcastWithWalletHiveAuth(from, [op], "active");
2850
+ }
2815
2851
  return hs.sendOperation(op, { callback: `https://ecency.com/@${from}/wallet` }, () => {
2816
2852
  });
2817
2853
  }
@@ -3595,6 +3631,37 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
3595
3631
  (assetItem) => assetItem.symbol.toUpperCase() === asset.toUpperCase()
3596
3632
  );
3597
3633
  if (!assetInfo) return void 0;
3634
+ const parts = [];
3635
+ if (assetInfo.liquid !== void 0 && assetInfo.liquid !== null) {
3636
+ parts.push({ name: "liquid", balance: assetInfo.liquid });
3637
+ }
3638
+ if (assetInfo.staked !== void 0 && assetInfo.staked !== null && assetInfo.staked > 0) {
3639
+ parts.push({ name: "staked", balance: assetInfo.staked });
3640
+ }
3641
+ if (assetInfo.savings !== void 0 && assetInfo.savings !== null && assetInfo.savings > 0) {
3642
+ parts.push({ name: "savings", balance: assetInfo.savings });
3643
+ }
3644
+ if (assetInfo.extraData && Array.isArray(assetInfo.extraData)) {
3645
+ for (const extraItem of assetInfo.extraData) {
3646
+ if (!extraItem || typeof extraItem !== "object") continue;
3647
+ const dataKey = extraItem.dataKey;
3648
+ const value = extraItem.value;
3649
+ if (typeof value === "string") {
3650
+ const cleanValue = value.replace(/,/g, "");
3651
+ const match = cleanValue.match(/[+-]?\s*(\d+(?:\.\d+)?)/);
3652
+ if (match) {
3653
+ const numValue = Math.abs(Number.parseFloat(match[1]));
3654
+ if (dataKey === "delegated_hive_power") {
3655
+ parts.push({ name: "outgoing_delegations", balance: numValue });
3656
+ } else if (dataKey === "received_hive_power") {
3657
+ parts.push({ name: "incoming_delegations", balance: numValue });
3658
+ } else if (dataKey === "powering_down_hive_power") {
3659
+ parts.push({ name: "pending_power_down", balance: numValue });
3660
+ }
3661
+ }
3662
+ }
3663
+ }
3664
+ }
3598
3665
  return {
3599
3666
  name: assetInfo.symbol,
3600
3667
  title: assetInfo.name,
@@ -3602,7 +3669,8 @@ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { ref
3602
3669
  accountBalance: assetInfo.balance,
3603
3670
  apr: assetInfo.apr?.toString(),
3604
3671
  layer: assetInfo.layer,
3605
- pendingRewards: assetInfo.pendingRewards
3672
+ pendingRewards: assetInfo.pendingRewards,
3673
+ parts
3606
3674
  };
3607
3675
  } catch (e) {
3608
3676
  return void 0;
@@ -4149,7 +4217,18 @@ var engineOperationToFunctionMap = {
4149
4217
  ["stake" /* Stake */]: stakeEngineToken,
4150
4218
  ["unstake" /* Unstake */]: unstakeEngineToken,
4151
4219
  ["delegate" /* Delegate */]: delegateEngineToken,
4152
- ["undelegate" /* Undelegate */]: undelegateEngineToken
4220
+ ["undelegate" /* Undelegate */]: undelegateEngineToken,
4221
+ ["claim" /* Claim */]: (payload, auth) => {
4222
+ return claimHiveEngineRewards(
4223
+ {
4224
+ account: payload.from,
4225
+ tokens: [payload.asset],
4226
+ type: payload.type,
4227
+ ...payload.type === "key" && payload.key ? { key: payload.key } : {}
4228
+ },
4229
+ auth
4230
+ );
4231
+ }
4153
4232
  };
4154
4233
  function useWalletOperation(username, asset, operation, auth) {
4155
4234
  const { mutateAsync: recordActivity } = EcencyAnalytics.useRecordActivity(