hive-nectar 0.0.11__py3-none-any.whl → 0.1.1__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.
- {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/METADATA +12 -11
- hive_nectar-0.1.1.dist-info/RECORD +88 -0
- nectar/__init__.py +1 -4
- nectar/account.py +791 -685
- nectar/amount.py +82 -21
- nectar/asset.py +1 -2
- nectar/block.py +49 -23
- nectar/blockchain.py +111 -143
- nectar/blockchaininstance.py +396 -247
- nectar/blockchainobject.py +33 -5
- nectar/cli.py +1058 -1349
- nectar/comment.py +313 -181
- nectar/community.py +39 -43
- nectar/constants.py +1 -14
- nectar/discussions.py +793 -139
- nectar/hive.py +137 -77
- nectar/hivesigner.py +106 -68
- nectar/imageuploader.py +33 -23
- nectar/instance.py +31 -79
- nectar/market.py +128 -264
- nectar/memo.py +40 -13
- nectar/message.py +23 -10
- nectar/nodelist.py +115 -81
- nectar/price.py +80 -61
- nectar/profile.py +6 -3
- nectar/rc.py +45 -25
- nectar/snapshot.py +285 -163
- nectar/storage.py +16 -5
- nectar/transactionbuilder.py +132 -41
- nectar/utils.py +37 -17
- nectar/version.py +1 -1
- nectar/vote.py +171 -30
- nectar/wallet.py +26 -19
- nectar/witness.py +153 -54
- nectarapi/graphenerpc.py +147 -133
- nectarapi/noderpc.py +12 -6
- nectarapi/rpcutils.py +12 -6
- nectarapi/version.py +1 -1
- nectarbase/ledgertransactions.py +24 -1
- nectarbase/objects.py +17 -6
- nectarbase/operations.py +160 -90
- nectarbase/signedtransactions.py +38 -2
- nectarbase/version.py +1 -1
- nectargraphenebase/account.py +295 -17
- nectargraphenebase/chains.py +0 -135
- nectargraphenebase/ecdsasig.py +152 -176
- nectargraphenebase/types.py +18 -4
- nectargraphenebase/unsignedtransactions.py +1 -1
- nectargraphenebase/version.py +1 -1
- hive_nectar-0.0.11.dist-info/RECORD +0 -91
- nectar/blurt.py +0 -562
- nectar/conveyor.py +0 -308
- nectar/steem.py +0 -581
- {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/WHEEL +0 -0
- {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/entry_points.txt +0 -0
- {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/licenses/LICENSE.txt +0 -0
nectar/amount.py
CHANGED
|
@@ -5,10 +5,15 @@ from nectar.asset import Asset
|
|
|
5
5
|
from nectar.instance import shared_blockchain_instance
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
def check_asset(other, self,
|
|
8
|
+
def check_asset(other, self, hv):
|
|
9
|
+
"""
|
|
10
|
+
Assert that two asset representations refer to the same asset.
|
|
11
|
+
|
|
12
|
+
If both `other` and `self` are dicts containing an "asset" key, each asset id is wrapped in an Asset using the provided blockchain instance and compared for equality. Otherwise the two values are compared directly. Raises AssertionError if the values do not match.
|
|
13
|
+
"""
|
|
9
14
|
if isinstance(other, dict) and "asset" in other and isinstance(self, dict) and "asset" in self:
|
|
10
|
-
if not Asset(other["asset"], blockchain_instance=
|
|
11
|
-
self["asset"], blockchain_instance=
|
|
15
|
+
if not Asset(other["asset"], blockchain_instance=hv) == Asset(
|
|
16
|
+
self["asset"], blockchain_instance=hv
|
|
12
17
|
):
|
|
13
18
|
raise AssertionError()
|
|
14
19
|
else:
|
|
@@ -31,16 +36,16 @@ class Amount(dict):
|
|
|
31
36
|
:param list args: Allows to deal with different representations of an amount
|
|
32
37
|
:param float amount: Let's create an instance with a specific amount
|
|
33
38
|
:param str asset: Let's you create an instance with a specific asset (symbol)
|
|
34
|
-
:param boolean fixed_point_arithmetic: when set to True, all
|
|
39
|
+
:param boolean fixed_point_arithmetic: when set to True, all operations are fixed
|
|
35
40
|
point operations and the amount is always be rounded down to the precision
|
|
36
|
-
:param
|
|
41
|
+
:param Blockchain blockchain_instance: Blockchain instance
|
|
37
42
|
:returns: All data required to represent an Amount/Asset
|
|
38
43
|
:rtype: dict
|
|
39
44
|
:raises ValueError: if the data provided is not recognized
|
|
40
45
|
|
|
41
46
|
Way to obtain a proper instance:
|
|
42
47
|
|
|
43
|
-
* ``args`` can be a string, e.g.: "1
|
|
48
|
+
* ``args`` can be a string, e.g.: "1 HBD"
|
|
44
49
|
* ``args`` can be a dictionary containing ``amount`` and ``asset_id``
|
|
45
50
|
* ``args`` can be a dictionary containing ``amount`` and ``asset``
|
|
46
51
|
* ``args`` can be a list of a ``float`` and ``str`` (symbol)
|
|
@@ -60,9 +65,9 @@ class Amount(dict):
|
|
|
60
65
|
|
|
61
66
|
from nectar.amount import Amount
|
|
62
67
|
from nectar.asset import Asset
|
|
63
|
-
a = Amount("1
|
|
64
|
-
b = Amount(1, "
|
|
65
|
-
c = Amount("20", Asset("
|
|
68
|
+
a = Amount("1 HIVE")
|
|
69
|
+
b = Amount(1, "HIVE")
|
|
70
|
+
c = Amount("20", Asset("HIVE"))
|
|
66
71
|
a + b
|
|
67
72
|
a * 2
|
|
68
73
|
a += b
|
|
@@ -70,8 +75,8 @@ class Amount(dict):
|
|
|
70
75
|
|
|
71
76
|
.. testoutput::
|
|
72
77
|
|
|
73
|
-
2.000
|
|
74
|
-
2.000
|
|
78
|
+
2.000 HIVE
|
|
79
|
+
2.000 HIVE
|
|
75
80
|
|
|
76
81
|
"""
|
|
77
82
|
|
|
@@ -84,15 +89,38 @@ class Amount(dict):
|
|
|
84
89
|
blockchain_instance=None,
|
|
85
90
|
**kwargs,
|
|
86
91
|
):
|
|
92
|
+
"""
|
|
93
|
+
Initialize an Amount object representing a quantity of a specific blockchain asset.
|
|
94
|
+
|
|
95
|
+
The constructor accepts many input formats and normalizes them into internal keys:
|
|
96
|
+
- amount may be another Amount, a three-element list [amount, precision, asset],
|
|
97
|
+
a new appbase-format dict with keys ("amount", "nai", "precision"), a legacy dict
|
|
98
|
+
with ("amount", "asset_id") or ("amount", "asset"), a string like "1.000 HIVE",
|
|
99
|
+
or a numeric value (int, float, Decimal) paired with an `asset` argument.
|
|
100
|
+
- asset may be an Asset instance, an asset dict, or a symbol string; when omitted,
|
|
101
|
+
the asset will be inferred from the provided `amount` representation.
|
|
102
|
+
|
|
103
|
+
After parsing, the instance stores:
|
|
104
|
+
- "amount" as a Decimal (or quantized Decimal when fixed-point mode is enabled),
|
|
105
|
+
- "symbol" as the asset symbol,
|
|
106
|
+
- "asset" as an Asset-like object.
|
|
107
|
+
|
|
108
|
+
Parameters:
|
|
109
|
+
amount: Various accepted formats (see description) representing the quantity.
|
|
110
|
+
asset: Asset instance, asset dict, or asset symbol string used when `amount`
|
|
111
|
+
is a bare numeric value or when explicit asset resolution is required.
|
|
112
|
+
fixed_point_arithmetic (bool): When True, the numeric amount is quantized
|
|
113
|
+
to the asset's precision using floor rounding.
|
|
114
|
+
new_appbase_format (bool): Indicates whether to prefer the new appbase JSON
|
|
115
|
+
format when producing serialized representations.
|
|
116
|
+
|
|
117
|
+
Raises:
|
|
118
|
+
ValueError: If `amount` and `asset` do not match any supported input format.
|
|
119
|
+
"""
|
|
87
120
|
self["asset"] = {}
|
|
88
121
|
self.new_appbase_format = new_appbase_format
|
|
89
122
|
self.fixed_point_arithmetic = fixed_point_arithmetic
|
|
90
123
|
|
|
91
|
-
if blockchain_instance is None:
|
|
92
|
-
if kwargs.get("steem_instance"):
|
|
93
|
-
blockchain_instance = kwargs["steem_instance"]
|
|
94
|
-
elif kwargs.get("hive_instance"):
|
|
95
|
-
blockchain_instance = kwargs["hive_instance"]
|
|
96
124
|
self.blockchain = blockchain_instance or shared_blockchain_instance()
|
|
97
125
|
|
|
98
126
|
if amount and asset is None and isinstance(amount, Amount):
|
|
@@ -221,8 +249,14 @@ class Amount(dict):
|
|
|
221
249
|
|
|
222
250
|
@property
|
|
223
251
|
def asset(self):
|
|
224
|
-
"""
|
|
225
|
-
if
|
|
252
|
+
"""
|
|
253
|
+
Return the Asset object for this Amount, constructing it lazily if missing.
|
|
254
|
+
|
|
255
|
+
If the internal 'asset' entry is falsy, this creates a nectar.asset.Asset using the stored symbol
|
|
256
|
+
and this Amount's blockchain instance, stores it in 'asset', and returns it. Always returns an
|
|
257
|
+
Asset instance.
|
|
258
|
+
"""
|
|
259
|
+
if not isinstance(self["asset"], Asset):
|
|
226
260
|
self["asset"] = Asset(self["symbol"], blockchain_instance=self.blockchain)
|
|
227
261
|
return self["asset"]
|
|
228
262
|
|
|
@@ -381,9 +415,20 @@ class Amount(dict):
|
|
|
381
415
|
return self
|
|
382
416
|
|
|
383
417
|
def __idiv__(self, other):
|
|
418
|
+
"""
|
|
419
|
+
In-place division: divide this Amount by another Amount or numeric value and return self.
|
|
420
|
+
|
|
421
|
+
If `other` is an Amount, asserts asset compatibility and divides this object's internal amount by the other's amount. If `other` is numeric, divides by Decimal(other). When `fixed_point_arithmetic` is enabled, the result is quantized to this asset's precision.
|
|
422
|
+
|
|
423
|
+
Returns:
|
|
424
|
+
self (Amount): The mutated Amount instance.
|
|
425
|
+
|
|
426
|
+
Raises:
|
|
427
|
+
AssertionError: If `other` is an Amount with a different asset (via check_asset).
|
|
428
|
+
"""
|
|
384
429
|
if isinstance(other, Amount):
|
|
385
430
|
check_asset(other["asset"], self["asset"], self.blockchain)
|
|
386
|
-
|
|
431
|
+
self["amount"] = self["amount"] / other["amount"]
|
|
387
432
|
else:
|
|
388
433
|
self["amount"] /= Decimal(other)
|
|
389
434
|
if self.fixed_point_arithmetic:
|
|
@@ -442,18 +487,33 @@ class Amount(dict):
|
|
|
442
487
|
return quant_amount == quantize((other or 0), self["asset"]["precision"])
|
|
443
488
|
|
|
444
489
|
def __ne__(self, other):
|
|
490
|
+
"""
|
|
491
|
+
Return True if this Amount is not equal to `other`.
|
|
492
|
+
|
|
493
|
+
Compares values after quantizing both sides to this amount's asset precision. If `other` is an Amount, its asset must match this Amount's asset (an assertion is raised on mismatch) and the comparison uses both amounts quantized to the shared precision. If `other` is numeric or None, it is treated as a numeric value (None → 0) and compared after quantization.
|
|
494
|
+
|
|
495
|
+
Returns:
|
|
496
|
+
bool: True when the quantized values differ, False otherwise.
|
|
497
|
+
"""
|
|
445
498
|
quant_amount = quantize(self["amount"], self["asset"]["precision"])
|
|
446
499
|
if isinstance(other, Amount):
|
|
447
500
|
check_asset(other["asset"], self["asset"], self.blockchain)
|
|
448
|
-
return
|
|
501
|
+
return quantize(self["amount"], self["asset"]["precision"]) != quantize(
|
|
502
|
+
other["amount"], self["asset"]["precision"]
|
|
503
|
+
)
|
|
449
504
|
else:
|
|
450
505
|
return quant_amount != quantize((other or 0), self["asset"]["precision"])
|
|
451
506
|
|
|
452
507
|
def __ge__(self, other):
|
|
508
|
+
"""
|
|
509
|
+
Return True if this Amount is greater than or equal to `other`.
|
|
510
|
+
|
|
511
|
+
Performs comparison after quantizing both values to this Amount's asset precision. If `other` is an Amount, its asset must match this Amount's asset (an AssertionError is raised on mismatch). If `other` is None, it is treated as zero. Returns a boolean.
|
|
512
|
+
"""
|
|
453
513
|
quant_amount = quantize(self["amount"], self["asset"]["precision"])
|
|
454
514
|
if isinstance(other, Amount):
|
|
455
515
|
check_asset(other["asset"], self["asset"], self.blockchain)
|
|
456
|
-
return
|
|
516
|
+
return quant_amount >= quantize(other["amount"], self["asset"]["precision"])
|
|
457
517
|
else:
|
|
458
518
|
return quant_amount >= quantize((other or 0), self["asset"]["precision"])
|
|
459
519
|
|
|
@@ -467,4 +527,5 @@ class Amount(dict):
|
|
|
467
527
|
|
|
468
528
|
__repr__ = __str__
|
|
469
529
|
__truediv__ = __div__
|
|
530
|
+
__itruediv__ = __idiv__
|
|
470
531
|
__truemul__ = __mul__
|
nectar/asset.py
CHANGED
|
@@ -9,8 +9,7 @@ class Asset(BlockchainObject):
|
|
|
9
9
|
:param str Asset: Symbol name or object id of an asset
|
|
10
10
|
:param bool lazy: Lazy loading
|
|
11
11
|
:param bool full: Also obtain bitasset-data and dynamic asset dat
|
|
12
|
-
:param
|
|
13
|
-
instance
|
|
12
|
+
:param Blockchain blockchain_instance: Blockchain instance
|
|
14
13
|
:returns: All data of an asset
|
|
15
14
|
|
|
16
15
|
.. note:: This class comes with its own caching function to reduce the
|
nectar/block.py
CHANGED
|
@@ -14,7 +14,7 @@ class Block(BlockchainObject):
|
|
|
14
14
|
"""Read a single block from the chain
|
|
15
15
|
|
|
16
16
|
:param int block: block number
|
|
17
|
-
:param
|
|
17
|
+
:param Hive blockchain_instance: Hive
|
|
18
18
|
instance
|
|
19
19
|
:param bool lazy: Use lazy loading
|
|
20
20
|
:param bool only_ops: Includes only operations, when set to True (default: False)
|
|
@@ -51,15 +51,16 @@ class Block(BlockchainObject):
|
|
|
51
51
|
blockchain_instance=None,
|
|
52
52
|
**kwargs,
|
|
53
53
|
):
|
|
54
|
-
"""
|
|
54
|
+
"""
|
|
55
|
+
Initialize a Block object representing a single blockchain block.
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
:
|
|
58
|
-
|
|
59
|
-
:
|
|
60
|
-
|
|
61
|
-
:param bool only_virtual_ops: Includes only virtual operations (default: False)
|
|
57
|
+
block may be an integer (block number), a float (will be converted to int), or a dict containing block data (which will be parsed). Controls:
|
|
58
|
+
- only_ops: load only operations from the block.
|
|
59
|
+
- only_virtual_ops: load only virtual operations.
|
|
60
|
+
- full: if True, populate full block data; if False, keep a minimal representation.
|
|
61
|
+
- lazy: if True, defer fetching full data until needed.
|
|
62
62
|
|
|
63
|
+
If no identifier is present after initialization, the block's identifier is set to its numeric block number.
|
|
63
64
|
"""
|
|
64
65
|
self.full = full
|
|
65
66
|
self.lazy = lazy
|
|
@@ -317,7 +318,7 @@ class BlockHeader(BlockchainObject):
|
|
|
317
318
|
"""Read a single block header from the chain
|
|
318
319
|
|
|
319
320
|
:param int block: block number
|
|
320
|
-
:param
|
|
321
|
+
:param Hive blockchain_instance: Hive
|
|
321
322
|
instance
|
|
322
323
|
:param bool lazy: Use lazy loading
|
|
323
324
|
|
|
@@ -333,13 +334,19 @@ class BlockHeader(BlockchainObject):
|
|
|
333
334
|
"""
|
|
334
335
|
|
|
335
336
|
def __init__(self, block, full=True, lazy=False, blockchain_instance=None, **kwargs):
|
|
336
|
-
"""
|
|
337
|
+
"""
|
|
338
|
+
Initialize a BlockHeader.
|
|
339
|
+
|
|
340
|
+
One-line summary:
|
|
341
|
+
Create a BlockHeader wrapper for a block header, optionally in lazy or full mode.
|
|
337
342
|
|
|
338
|
-
:
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
343
|
+
Parameters:
|
|
344
|
+
block (int | float | dict): Block number (floats are converted to int) or a header dict.
|
|
345
|
+
full (bool): If True, populate the object with full header data; otherwise keep a minimal representation.
|
|
346
|
+
lazy (bool): If True, delay API fetching until data is accessed.
|
|
342
347
|
|
|
348
|
+
Notes:
|
|
349
|
+
If no blockchain_instance is provided, the module's shared blockchain instance is used.
|
|
343
350
|
"""
|
|
344
351
|
self.full = full
|
|
345
352
|
self.lazy = lazy
|
|
@@ -410,8 +417,8 @@ class Blocks(list):
|
|
|
410
417
|
:param list name_list: list of accounts to fetch
|
|
411
418
|
:param int count: (optional) maximum number of accounts
|
|
412
419
|
to fetch per call, defaults to 100
|
|
413
|
-
:param
|
|
414
|
-
accessing
|
|
420
|
+
:param Hive blockchain_instance: Hive() instance to use when
|
|
421
|
+
accessing RPC
|
|
415
422
|
"""
|
|
416
423
|
|
|
417
424
|
def __init__(
|
|
@@ -420,14 +427,23 @@ class Blocks(list):
|
|
|
420
427
|
count=1000,
|
|
421
428
|
lazy=False,
|
|
422
429
|
full=True,
|
|
430
|
+
only_ops=False,
|
|
431
|
+
only_virtual_ops=False,
|
|
423
432
|
blockchain_instance=None,
|
|
424
|
-
**kwargs,
|
|
425
433
|
):
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
434
|
+
"""
|
|
435
|
+
Initialize a Blocks collection by fetching a contiguous range of blocks from the chain and populating the list with Block objects.
|
|
436
|
+
|
|
437
|
+
If a blockchain_instance is provided it is used; otherwise the shared blockchain instance is used. If the chosen instance is not connected, the initializer returns early and the Blocks object remains empty.
|
|
438
|
+
|
|
439
|
+
Parameters:
|
|
440
|
+
starting_block_num (int): First block number to retrieve.
|
|
441
|
+
count (int, optional): Number of consecutive blocks to fetch. Defaults to 1000.
|
|
442
|
+
lazy (bool, optional): If True, create Block objects in lazy mode (defer full parsing). Defaults to False.
|
|
443
|
+
full (bool, optional): If True, create Block objects with full data loaded (subject to lazy). Defaults to True.
|
|
444
|
+
only_ops (bool, optional): If True, blocks will contain only regular operations (no block metadata). Defaults to False.
|
|
445
|
+
only_virtual_ops (bool, optional): If True, blocks will contain only virtual operations. Defaults to False.
|
|
446
|
+
"""
|
|
431
447
|
self.blockchain = blockchain_instance or shared_blockchain_instance()
|
|
432
448
|
|
|
433
449
|
if not self.blockchain.is_connected():
|
|
@@ -441,5 +457,15 @@ class Blocks(list):
|
|
|
441
457
|
)["blocks"]
|
|
442
458
|
|
|
443
459
|
super(Blocks, self).__init__(
|
|
444
|
-
[
|
|
460
|
+
[
|
|
461
|
+
Block(
|
|
462
|
+
x,
|
|
463
|
+
lazy=lazy,
|
|
464
|
+
full=full,
|
|
465
|
+
only_ops=only_ops,
|
|
466
|
+
only_virtual_ops=only_virtual_ops,
|
|
467
|
+
blockchain_instance=self.blockchain,
|
|
468
|
+
)
|
|
469
|
+
for x in blocks
|
|
470
|
+
]
|
|
445
471
|
)
|