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