hive-nectar 0.0.11__py3-none-any.whl → 0.1.0__py3-none-any.whl

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.

Potentially problematic release.


This version of hive-nectar might be problematic. Click here for more details.

Files changed (56) hide show
  1. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.0.dist-info}/METADATA +10 -11
  2. hive_nectar-0.1.0.dist-info/RECORD +88 -0
  3. nectar/__init__.py +1 -4
  4. nectar/account.py +791 -685
  5. nectar/amount.py +82 -21
  6. nectar/asset.py +1 -2
  7. nectar/block.py +34 -22
  8. nectar/blockchain.py +111 -143
  9. nectar/blockchaininstance.py +396 -247
  10. nectar/blockchainobject.py +33 -5
  11. nectar/cli.py +1058 -1349
  12. nectar/comment.py +313 -181
  13. nectar/community.py +39 -43
  14. nectar/constants.py +1 -14
  15. nectar/discussions.py +793 -139
  16. nectar/hive.py +137 -77
  17. nectar/hivesigner.py +106 -68
  18. nectar/imageuploader.py +33 -23
  19. nectar/instance.py +31 -79
  20. nectar/market.py +128 -264
  21. nectar/memo.py +40 -13
  22. nectar/message.py +23 -10
  23. nectar/nodelist.py +115 -81
  24. nectar/price.py +80 -61
  25. nectar/profile.py +6 -3
  26. nectar/rc.py +45 -25
  27. nectar/snapshot.py +285 -163
  28. nectar/storage.py +16 -5
  29. nectar/transactionbuilder.py +132 -41
  30. nectar/utils.py +37 -17
  31. nectar/version.py +1 -1
  32. nectar/vote.py +171 -30
  33. nectar/wallet.py +26 -19
  34. nectar/witness.py +153 -54
  35. nectarapi/graphenerpc.py +147 -133
  36. nectarapi/noderpc.py +12 -6
  37. nectarapi/rpcutils.py +12 -6
  38. nectarapi/version.py +1 -1
  39. nectarbase/ledgertransactions.py +24 -1
  40. nectarbase/objects.py +17 -6
  41. nectarbase/operations.py +160 -90
  42. nectarbase/signedtransactions.py +38 -2
  43. nectarbase/version.py +1 -1
  44. nectargraphenebase/account.py +295 -17
  45. nectargraphenebase/chains.py +0 -135
  46. nectargraphenebase/ecdsasig.py +152 -176
  47. nectargraphenebase/types.py +18 -4
  48. nectargraphenebase/unsignedtransactions.py +1 -1
  49. nectargraphenebase/version.py +1 -1
  50. hive_nectar-0.0.11.dist-info/RECORD +0 -91
  51. nectar/blurt.py +0 -562
  52. nectar/conveyor.py +0 -308
  53. nectar/steem.py +0 -581
  54. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.0.dist-info}/WHEEL +0 -0
  55. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.0.dist-info}/entry_points.txt +0 -0
  56. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.0.dist-info}/licenses/LICENSE.txt +0 -0
nectar/vote.py CHANGED
@@ -1,5 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  import json
3
+ import warnings
3
4
  from datetime import date, datetime, timezone
4
5
 
5
6
  from prettytable import PrettyTable
@@ -28,18 +29,58 @@ class Vote(BlockchainObject):
28
29
  :param str authorperm: perm link to post/comment
29
30
  :param nectar.nectar.nectar blockchain_instance: nectar
30
31
  instance to use when accesing a RPC
32
+ :param steem_instance: (deprecated) use blockchain_instance instead
33
+ :param hive_instance: (deprecated) use blockchain_instance instead
31
34
  """
32
35
 
33
36
  def __init__(
34
37
  self, voter, authorperm=None, lazy=False, full=False, blockchain_instance=None, **kwargs
35
38
  ):
39
+ # Handle legacy parameters
40
+ """
41
+ Initialize a Vote object representing a single vote on a post or comment.
42
+
43
+ Supports multiple input shapes for `voter`:
44
+ - voter as str with `authorperm` provided: `voter` is the voter name; `authorperm` is parsed into author/permlink.
45
+ - voter as dict containing "author", "permlink", and "voter": uses those fields directly.
46
+ - voter as dict with "authorperm" plus an external `authorperm` argument: resolves author/permlink and fills missing fields.
47
+ - voter as dict with "voter" plus an external `authorperm` argument: resolves author/permlink and fills missing fields.
48
+ - otherwise treats `voter` as an authorpermvoter token (author+permlink+voter), resolving author, permlink, and voter from it.
49
+
50
+ Behavior:
51
+ - Normalizes numeric/time fields via internal parsing before initializing the underlying BlockchainObject.
52
+ - Chooses the blockchain instance in this order: explicit `blockchain_instance`, a deprecated legacy instance passed via `steem_instance` or `hive_instance` (emits DeprecationWarning), then a shared default instance.
53
+ - Validates keyword arguments and raises on unknown or conflicting legacy instance keys.
54
+
55
+ Raises:
56
+ - ValueError: if more than one legacy instance key is supplied.
57
+ - TypeError: if unexpected keyword arguments are present.
58
+ """
59
+ legacy_keys = {"steem_instance", "hive_instance"}
60
+ legacy_instance = None
61
+ for key in legacy_keys:
62
+ if key in kwargs:
63
+ if legacy_instance is not None:
64
+ raise ValueError(
65
+ f"Cannot specify both {key} and another legacy instance parameter"
66
+ )
67
+ legacy_instance = kwargs.pop(key)
68
+ warnings.warn(
69
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
70
+ DeprecationWarning,
71
+ stacklevel=2,
72
+ )
73
+
74
+ # Check for unknown kwargs
75
+ if kwargs:
76
+ raise TypeError(f"Unexpected keyword arguments: {list(kwargs.keys())}")
77
+
78
+ # Prefer explicit blockchain_instance, then legacy
79
+ if blockchain_instance is None and legacy_instance is not None:
80
+ blockchain_instance = legacy_instance
81
+
36
82
  self.full = full
37
83
  self.lazy = lazy
38
- if blockchain_instance is None:
39
- if kwargs.get("steem_instance"):
40
- blockchain_instance = kwargs["steem_instance"]
41
- elif kwargs.get("hive_instance"):
42
- blockchain_instance = kwargs["hive_instance"]
43
84
  self.blockchain = blockchain_instance or shared_blockchain_instance()
44
85
  if isinstance(voter, str) and authorperm is not None:
45
86
  [author, permlink] = resolve_authorperm(authorperm)
@@ -89,10 +130,18 @@ class Vote(BlockchainObject):
89
130
  id_item="authorpermvoter",
90
131
  lazy=lazy,
91
132
  full=full,
92
- blockchain_instance=blockchain_instance,
133
+ blockchain_instance=self.blockchain,
93
134
  )
94
135
 
95
136
  def refresh(self):
137
+ """
138
+ Refresh the Vote object from the blockchain RPC, replacing its internal data with the latest on-chain vote.
139
+
140
+ If the object has no identifier or the blockchain is not connected, this method returns immediately. It resolves author, permlink, and voter from the stored identifier and queries the node for active votes (preferring appbase paths with a condenser fallback). If the matching vote is found, the object is reinitialized with the normalized vote data; otherwise VoteDoesNotExistsException is raised.
141
+
142
+ Raises:
143
+ VoteDoesNotExistsException: if the vote cannot be found or the RPC indicates the vote does not exist.
144
+ """
96
145
  if self.identifier is None:
97
146
  return
98
147
  if not self.blockchain.is_connected():
@@ -210,27 +259,44 @@ class Vote(BlockchainObject):
210
259
 
211
260
  @property
212
261
  def weight(self):
213
- return self["weight"]
262
+ """
263
+ Return the raw vote weight stored for this vote.
214
264
 
215
- @property
216
- def sbd(self):
217
- return self.blockchain.rshares_to_sbd(int(self.get("rshares", 0)))
265
+ The value is read directly from the underlying vote data (self["weight"]) and
266
+ represents the weight field provided by the blockchain (type may be int).
267
+ """
268
+ return self["weight"]
218
269
 
219
270
  @property
220
271
  def hbd(self):
272
+ """
273
+ Return the HBD value equivalent of this vote's rshares.
274
+
275
+ Uses the bound blockchain instance's rshares_to_hbd to convert the vote's integer `rshares` (defaults to 0).
276
+
277
+ Returns:
278
+ float: HBD amount corresponding to the vote's rshares.
279
+ """
221
280
  return self.blockchain.rshares_to_hbd(int(self.get("rshares", 0)))
222
281
 
223
282
  @property
224
283
  def token_backed_dollar(self):
225
- from nectar import Hive
284
+ # Hive-only: always convert to HBD
285
+ """
286
+ Convert this vote's rshares to HBD (Hive-backed dollar).
226
287
 
227
- if isinstance(self.blockchain, Hive):
228
- return self.blockchain.rshares_to_hbd(int(self.get("rshares", 0)))
229
- else:
230
- return self.blockchain.rshares_to_sbd(int(self.get("rshares", 0)))
288
+ Uses the associated blockchain instance's rshares_to_hbd conversion on the vote's "rshares" field (defaults to 0 if missing). This is Hive-specific and always returns HBD-equivalent value for the vote.
289
+ """
290
+ return self.blockchain.rshares_to_hbd(int(self.get("rshares", 0)))
231
291
 
232
292
  @property
233
293
  def rshares(self):
294
+ """
295
+ Return the vote's raw `rshares` as an integer.
296
+
297
+ Converts the stored `rshares` value (which may be a string or number) to an int and returns it.
298
+ If `rshares` is missing, returns 0.
299
+ """
234
300
  return int(self.get("rshares", 0))
235
301
 
236
302
  @property
@@ -273,7 +339,32 @@ class VotesObject(list):
273
339
  return_str=False,
274
340
  **kwargs,
275
341
  ):
276
- table_header = ["Voter", "Votee", "SBD/HBD", "Time", "Rshares", "Percent", "Weight"]
342
+ """
343
+ Render the votes collection as a formatted table, with optional filtering and sorting.
344
+
345
+ Detailed behavior:
346
+ - Filters votes by voter name, votee (author), time window (start/stop), and percent range (start_percent/stop_percent).
347
+ - Sorts votes using sort_key (default "time") and reverse order flag.
348
+ - Formats columns: Voter, Votee, HBD (token equivalent), Time (human-readable delta), Rshares, Percent, Weight.
349
+ - If return_str is True, returns the table string; otherwise prints it to stdout.
350
+
351
+ Parameters:
352
+ voter (str, optional): Only include votes by this voter name.
353
+ votee (str, optional): Only include votes targeting this votee (author).
354
+ start (datetime or str, optional): Inclusive lower bound for vote time; timezone info is added if missing.
355
+ stop (datetime or str, optional): Inclusive upper bound for vote time; timezone info is added if missing.
356
+ start_percent (int, optional): Inclusive lower bound for vote percent.
357
+ stop_percent (int, optional): Inclusive upper bound for vote percent.
358
+ sort_key (str, optional): Attribute name used to sort votes (default "time").
359
+ reverse (bool, optional): If True, sort in descending order (default True).
360
+ allow_refresh (bool, optional): If False, prevents refreshing votes during iteration by marking them as cached.
361
+ return_str (bool, optional): If True, return the rendered table as a string; otherwise print it.
362
+ **kwargs: Passed through to PrettyTable.get_string when rendering the table.
363
+
364
+ Returns:
365
+ str or None: The table string when return_str is True; otherwise None (table is printed).
366
+ """
367
+ table_header = ["Voter", "Votee", "HBD", "Time", "Rshares", "Percent", "Weight"]
277
368
  t = PrettyTable(table_header)
278
369
  t.align = "l"
279
370
  start = addTzInfo(start)
@@ -383,7 +474,13 @@ class VotesObject(list):
383
474
 
384
475
  def print_stats(self, return_str=False, **kwargs):
385
476
  # Using built-in timezone support
386
- table_header = ["voter", "votee", "sbd/hbd", "time", "rshares", "percent", "weight"]
477
+ """
478
+ Print or return a summary table of vote statistics for this collection.
479
+
480
+ If return_str is True, the formatted table is returned as a string; otherwise it is printed.
481
+ Accepts the same filtering and formatting keyword arguments used by printAsTable (e.g., voter, votee, start, stop, start_percent, stop_percent, sort_key, reverse).
482
+ """
483
+ table_header = ["voter", "votee", "hbd", "time", "rshares", "percent", "weight"]
387
484
  t = PrettyTable(table_header)
388
485
  t.align = "l"
389
486
 
@@ -415,15 +512,46 @@ class ActiveVotes(VotesObject):
415
512
  """Obtain a list of votes for a post
416
513
 
417
514
  :param str authorperm: authorperm link
418
- :param Steem steem_instance: Steem() instance to use when accesing a RPC
515
+ :param Blockchain blockchain_instance: Blockchain instance to use when accessing RPC
419
516
  """
420
517
 
421
518
  def __init__(self, authorperm, lazy=False, full=False, blockchain_instance=None, **kwargs):
422
- if blockchain_instance is None:
423
- if kwargs.get("steem_instance"):
424
- blockchain_instance = kwargs["steem_instance"]
425
- elif kwargs.get("hive_instance"):
426
- blockchain_instance = kwargs["hive_instance"]
519
+ # Handle legacy parameters
520
+ """
521
+ Initialize an ActiveVotes collection for a post's active votes.
522
+
523
+ Creates Vote objects for each active vote on the given post (author/permlink) and stores them in the list.
524
+ Accepts multiple input shapes for authorperm:
525
+ - Comment: extracts author/permlink and uses its `active_votes` via RPC.
526
+ - str: an authorperm string, resolved to author and permlink.
527
+ - list: treated as a pre-fetched list of vote dicts.
528
+ - dict: expects keys "active_votes" and "authorperm".
529
+
530
+ Handles legacy keyword parameters "steem_instance" and "hive_instance" (deprecated; a DeprecationWarning is emitted). If no explicit blockchain instance is provided, a shared instance is used. If the blockchain is not connected or no votes are found, initialization returns without populating the collection.
531
+
532
+ Raises:
533
+ ValueError: if multiple legacy instance parameters are provided.
534
+ VoteDoesNotExistsException: when the RPC reports invalid parameters for the requested post (no such post).
535
+ """
536
+ legacy_keys = {"steem_instance", "hive_instance"}
537
+ legacy_instance = None
538
+ for key in legacy_keys:
539
+ if key in kwargs:
540
+ if legacy_instance is not None:
541
+ raise ValueError(
542
+ f"Cannot specify both {key} and another legacy instance parameter"
543
+ )
544
+ legacy_instance = kwargs.pop(key)
545
+ warnings.warn(
546
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
547
+ DeprecationWarning,
548
+ stacklevel=2,
549
+ )
550
+
551
+ # Prefer explicit blockchain_instance, then legacy
552
+ if blockchain_instance is None and legacy_instance is not None:
553
+ blockchain_instance = legacy_instance
554
+
427
555
  self.blockchain = blockchain_instance or shared_blockchain_instance()
428
556
  votes = None
429
557
  if not self.blockchain.is_connected():
@@ -499,7 +627,7 @@ class AccountVotes(VotesObject):
499
627
  Lists the last 100+ votes on the given account.
500
628
 
501
629
  :param str account: Account name
502
- :param Steem steem_instance: Steem() instance to use when accesing a RPC
630
+ :param Blockchain blockchain_instance: Blockchain instance to use when accessing RPC
503
631
  """
504
632
 
505
633
  def __init__(
@@ -511,13 +639,26 @@ class AccountVotes(VotesObject):
511
639
  lazy=False,
512
640
  full=False,
513
641
  blockchain_instance=None,
514
- **kwargs,
515
642
  ):
516
- if blockchain_instance is None:
517
- if kwargs.get("steem_instance"):
518
- blockchain_instance = kwargs["steem_instance"]
519
- elif kwargs.get("hive_instance"):
520
- blockchain_instance = kwargs["hive_instance"]
643
+ """
644
+ Initialize AccountVotes by loading votes for a given account within an optional time window.
645
+
646
+ Creates a collection of votes retrieved from the account's historical votes. Each entry is either a Vote object (default) or the raw vote dict when `raw_data` is True. Time filtering is applied using `start` and `stop` (inclusive). Empty or missing timestamps are treated as the Unix epoch.
647
+
648
+ Parameters:
649
+ account: Account or str
650
+ Account name or Account object whose votes to load.
651
+ start: datetime | str | None
652
+ Inclusive lower bound for vote time. Accepts a timezone-aware datetime or a time string; None disables the lower bound.
653
+ stop: datetime | str | None
654
+ Inclusive upper bound for vote time. Accepts a timezone-aware datetime or a time string; None disables the upper bound.
655
+ raw_data: bool
656
+ If True, return raw vote dictionaries instead of Vote objects.
657
+ lazy: bool
658
+ Passed to Vote when constructing Vote objects; controls lazy loading behavior.
659
+ full: bool
660
+ Passed to Vote when constructing Vote objects; controls whether to fully populate vote data.
661
+ """
521
662
  self.blockchain = blockchain_instance or shared_blockchain_instance()
522
663
  start = addTzInfo(start)
523
664
  stop = addTzInfo(stop)
nectar/wallet.py CHANGED
@@ -22,7 +22,7 @@ class Wallet(object):
22
22
  your accounts. It either uses manually provided private keys
23
23
  or uses a SQLite database managed by storage.py.
24
24
 
25
- :param SteemNodeRPC rpc: RPC connection to a Steem node
25
+ :param Rpc rpc: RPC connection to a Hive node
26
26
  :param keys: Predefine the wif keys to shortcut the
27
27
  wallet database
28
28
  :type keys: array, dict, str
@@ -31,12 +31,12 @@ class Wallet(object):
31
31
 
32
32
  * **Wallet Database**: Here, nectar loads the keys from the
33
33
  locally stored wallet SQLite database (see ``storage.py``).
34
- To use this mode, simply call :class:`nectar.steem.Steem` without the
34
+ To use this mode, simply call :class:`nectar.hive.Hive` without the
35
35
  ``keys`` parameter
36
36
  * **Providing Keys**: Here, you can provide the keys for
37
37
  your accounts manually. All you need to do is add the wif
38
38
  keys for the accounts you want to use as a simple array
39
- using the ``keys`` parameter to :class:`nectar.steem.Steem`.
39
+ using the ``keys`` parameter to :class:`nectar.hive.Hive`.
40
40
  * **Force keys**: This more is for advanced users and
41
41
  requires that you know what you are doing. Here, the
42
42
  ``keys`` parameter is a dictionary that overwrite the
@@ -48,10 +48,10 @@ class Wallet(object):
48
48
 
49
49
  .. code-block:: python
50
50
 
51
- from nectar import Steem
52
- steem = Steem()
53
- steem.wallet.wipe(True)
54
- steem.wallet.create("supersecret-passphrase")
51
+ from nectar import Hive
52
+ hive = Hive()
53
+ hive.wallet.wipe(True)
54
+ hive.wallet.create("supersecret-passphrase")
55
55
 
56
56
  This will raise :class:`nectar.exceptions.WalletExists` if you already have a wallet installed.
57
57
 
@@ -60,9 +60,9 @@ class Wallet(object):
60
60
 
61
61
  .. code-block:: python
62
62
 
63
- from nectar import Steem
64
- steem = Steem()
65
- steem.wallet.unlock("supersecret-passphrase")
63
+ from nectar import Hive
64
+ hive = Hive()
65
+ hive.wallet.unlock("supersecret-passphrase")
66
66
 
67
67
  A private key can be added by using the
68
68
  :func:`addPrivateKey` method that is available
@@ -70,10 +70,10 @@ class Wallet(object):
70
70
 
71
71
  .. code-block:: python
72
72
 
73
- from nectar import Steem
74
- steem = Steem()
75
- steem.wallet.unlock("supersecret-passphrase")
76
- steem.wallet.addPrivateKey("5xxxxxxxxxxxxxxxxxxxx")
73
+ from nectar import Hive
74
+ hive = Hive()
75
+ hive.wallet.unlock("supersecret-passphrase")
76
+ hive.wallet.addPrivateKey("5xxxxxxxxxxxxxxxxxxxx")
77
77
 
78
78
  .. note:: The private key has to be either in hexadecimal or in wallet
79
79
  import format (wif) (starting with a ``5``).
@@ -81,11 +81,18 @@ class Wallet(object):
81
81
  """
82
82
 
83
83
  def __init__(self, blockchain_instance=None, *args, **kwargs):
84
- if blockchain_instance is None:
85
- if kwargs.get("steem_instance"):
86
- blockchain_instance = kwargs["steem_instance"]
87
- elif kwargs.get("hive_instance"):
88
- blockchain_instance = kwargs["hive_instance"]
84
+ """
85
+ Initialize the Wallet, binding it to a blockchain instance and setting up the underlying key store.
86
+
87
+ If a blockchain_instance is provided, it is used; otherwise the shared blockchain instance is used. Accepts legacy "wif" argument (aliased to "keys"). If non-empty "keys" are supplied, an in-memory plain key store is created and populated; otherwise a SQLite-encrypted key store is instantiated (can be overridden via the `key_store` kwarg).
88
+
89
+ Parameters:
90
+ blockchain_instance (optional): Explicit blockchain/RPC wrapper to use; if omitted the module's shared blockchain instance is used.
91
+
92
+ Side effects:
93
+ - Creates and assigns self.store to either an in-memory or persistent key store.
94
+ - Calls setKeys when an in-memory store is selected.
95
+ """
89
96
  self.blockchain = blockchain_instance or shared_blockchain_instance()
90
97
 
91
98
  # Compatibility after name change from wif->keys