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.

Files changed (56) hide show
  1. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/METADATA +12 -11
  2. hive_nectar-0.1.1.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 +49 -23
  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.1.dist-info}/WHEEL +0 -0
  55. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/entry_points.txt +0 -0
  56. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/licenses/LICENSE.txt +0 -0
nectar/blurt.py DELETED
@@ -1,562 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- import logging
3
- import math
4
- from datetime import date, datetime, timezone
5
-
6
- from nectar.blockchaininstance import BlockChainInstance
7
- from nectar.constants import STEEM_100_PERCENT, STEEM_VOTE_REGENERATION_SECONDS
8
- from nectargraphenebase.chains import known_chains
9
-
10
- from .amount import Amount
11
- from .utils import formatToTimeStamp
12
-
13
- log = logging.getLogger(__name__)
14
-
15
-
16
- class Blurt(BlockChainInstance):
17
- """Connect to the Blurt network.
18
-
19
- :param str node: Node to connect to *(optional)*
20
- :param str rpcuser: RPC user *(optional)*
21
- :param str rpcpassword: RPC password *(optional)*
22
- :param bool nobroadcast: Do **not** broadcast a transaction!
23
- *(optional)*
24
- :param bool unsigned: Do **not** sign a transaction! *(optional)*
25
- :param bool debug: Enable Debugging *(optional)*
26
- :param keys: Predefine the wif keys to shortcut the
27
- wallet database *(optional)*
28
- :type keys: array, dict, string
29
- :param wif: Predefine the wif keys to shortcut the
30
- wallet database *(optional)*
31
- :type wif: array, dict, string
32
- :param bool offline: Boolean to prevent connecting to network (defaults
33
- to ``False``) *(optional)*
34
- :param int expiration: Delay in seconds until transactions are supposed
35
- to expire *(optional)* (default is 30)
36
- :param str blocking: Wait for broadcasted transactions to be included
37
- in a block and return full transaction (can be "head" or
38
- "irreversible")
39
- :param bool bundle: Do not broadcast transactions right away, but allow
40
- to bundle operations. It is not possible to send out more than one
41
- vote operation and more than one comment operation in a single broadcast *(optional)*
42
- :param bool appbase: Use the new appbase rpc protocol on nodes with version
43
- 0.19.4 or higher. The settings has no effect on nodes with version of 0.19.3 or lower.
44
- :param int num_retries: Set the maximum number of reconnects to the nodes before
45
- NumRetriesReached is raised. Disabled for -1. (default is -1)
46
- :param int num_retries_call: Repeat num_retries_call times a rpc call on node error (default is 5)
47
- :param int timeout: Timeout setting for https nodes (default is 60)
48
- :param bool use_sc2: When True, a steemconnect object is created. Can be used for
49
- broadcast posting op or creating hot_links (default is False)
50
- :param SteemConnect steemconnect: A SteemConnect object can be set manually, set use_sc2 to True
51
- :param dict custom_chains: custom chain which should be added to the known chains
52
-
53
- Three wallet operation modes are possible:
54
-
55
- * **Wallet Database**: Here, the steemlibs load the keys from the
56
- locally stored wallet SQLite database (see ``storage.py``).
57
- To use this mode, simply call ``Steem()`` without the
58
- ``keys`` parameter
59
- * **Providing Keys**: Here, you can provide the keys for
60
- your accounts manually. All you need to do is add the wif
61
- keys for the accounts you want to use as a simple array
62
- using the ``keys`` parameter to ``Steem()``.
63
- * **Force keys**: This more is for advanced users and
64
- requires that you know what you are doing. Here, the
65
- ``keys`` parameter is a dictionary that overwrite the
66
- ``active``, ``owner``, ``posting`` or ``memo`` keys for
67
- any account. This mode is only used for *foreign*
68
- signatures!
69
-
70
- If no node is provided, it will connect to default nodes of
71
- http://geo.steem.pl. Default settings can be changed with:
72
-
73
- .. code-block:: python
74
-
75
- blurt = Blurt(<host>)
76
-
77
- where ``<host>`` starts with ``https://``, ``ws://`` or ``wss://``.
78
-
79
- The purpose of this class it to simplify interaction with
80
- Blurt.
81
-
82
- The idea is to have a class that allows to do this:
83
-
84
- .. code-block:: python
85
-
86
- >>> from nectar import Blurt
87
- >>> blurt = Blurt()
88
- >>> print(blurt.get_blockchain_version()) # doctest: +SKIP
89
-
90
- This class also deals with edits, votes and reading content.
91
-
92
- Example for adding a custom chain:
93
-
94
- .. code-block:: python
95
-
96
- from nectar import Steem
97
- stm = Steem(node=["https://mytstnet.com"], custom_chains={"MYTESTNET":
98
- {'chain_assets': [{'asset': 'SBD', 'id': 0, 'precision': 3, 'symbol': 'SBD'},
99
- {'asset': 'STEEM', 'id': 1, 'precision': 3, 'symbol': 'STEEM'},
100
- {'asset': 'VESTS', 'id': 2, 'precision': 6, 'symbol': 'VESTS'}],
101
- 'chain_id': '79276aea5d4877d9a25892eaa01b0adf019d3e5cb12a97478df3298ccdd01674',
102
- 'min_version': '0.0.0',
103
- 'prefix': 'MTN'}
104
- }
105
- )
106
-
107
- """
108
-
109
- def get_network(self, use_stored_data=True, config=None):
110
- """Identify the network
111
-
112
- :param bool use_stored_data: if True, stored data will be returned. If stored data are
113
- empty or old, refresh_data() is used.
114
-
115
- :returns: Network parameters
116
- :rtype: dictionary
117
- """
118
- if use_stored_data:
119
- self.refresh_data("config")
120
- return self.data["network"]
121
-
122
- if self.rpc is None:
123
- return known_chains["BLURT"]
124
- try:
125
- return self.rpc.get_network(props=config)
126
- except Exception:
127
- return known_chains["BLURT"]
128
-
129
- def rshares_to_token_backed_dollar(
130
- self, rshares, not_broadcasted_vote=False, use_stored_data=True
131
- ):
132
- return self.rshares_to_bbd(
133
- rshares, not_broadcasted_vote=not_broadcasted_vote, use_stored_data=use_stored_data
134
- )
135
-
136
- def rshares_to_bbd(self, rshares, not_broadcasted_vote=False, use_stored_data=True):
137
- """Calculates the current SBD value of a vote"""
138
- payout = float(rshares) * self.get_bbd_per_rshares(
139
- use_stored_data=use_stored_data,
140
- not_broadcasted_vote_rshares=rshares if not_broadcasted_vote else 0,
141
- )
142
- return payout
143
-
144
- def get_bbd_per_rshares(self, not_broadcasted_vote_rshares=0, use_stored_data=True):
145
- """Returns the current rshares to SBD ratio"""
146
- reward_fund = self.get_reward_funds(use_stored_data=use_stored_data)
147
- reward_balance = float(Amount(reward_fund["reward_balance"], blockchain_instance=self))
148
- recent_claims = float(reward_fund["recent_claims"]) + not_broadcasted_vote_rshares
149
-
150
- fund_per_share = reward_balance / (recent_claims)
151
- median_price = self.get_median_price(use_stored_data=use_stored_data)
152
- if median_price is None:
153
- return 0
154
- return fund_per_share
155
-
156
- def get_blurt_per_mvest(self, time_stamp=None, use_stored_data=True):
157
- """Returns the MVEST to BLURT ratio
158
-
159
- :param int time_stamp: (optional) if set, return an estimated
160
- BLURT per MVEST ratio for the given time stamp. If unset the
161
- current ratio is returned (default). (can also be a datetime object)
162
- """
163
- if self.offline and time_stamp is None:
164
- time_stamp = datetime.now(timezone.utc)
165
-
166
- if time_stamp is not None:
167
- if isinstance(time_stamp, (datetime, date)):
168
- time_stamp = formatToTimeStamp(time_stamp)
169
- a = 2.1325476281078992e-05
170
- b = -31099.685481490847
171
- a2 = 2.9019227739473682e-07
172
- b2 = 48.41432402074669
173
-
174
- if time_stamp < (b2 - b) / (a - a2):
175
- return a * time_stamp + b
176
- else:
177
- return a2 * time_stamp + b2
178
- global_properties = self.get_dynamic_global_properties(use_stored_data=use_stored_data)
179
-
180
- return float(
181
- Amount(global_properties["total_vesting_fund_blurt"], blockchain_instance=self)
182
- ) / (
183
- float(Amount(global_properties["total_vesting_shares"], blockchain_instance=self)) / 1e6
184
- )
185
-
186
- def vests_to_bp(self, vests, timestamp=None, use_stored_data=True):
187
- """Converts vests to BP
188
-
189
- :param amount.Amount vests/float vests: Vests to convert
190
- :param int timestamp: (Optional) Can be used to calculate
191
- the conversion rate from the past
192
-
193
- """
194
- if isinstance(vests, Amount):
195
- vests = float(vests)
196
- return (
197
- float(vests)
198
- / 1e6
199
- * self.get_blurt_per_mvest(timestamp, use_stored_data=use_stored_data)
200
- )
201
-
202
- def bp_to_vests(self, sp, timestamp=None, use_stored_data=True):
203
- """Converts BP to vests
204
-
205
- :param float bp: Blurt power to convert
206
- :param datetime timestamp: (Optional) Can be used to calculate
207
- the conversion rate from the past
208
- """
209
- return sp * 1e6 / self.get_blurt_per_mvest(timestamp, use_stored_data=use_stored_data)
210
-
211
- def vests_to_token_power(self, vests, timestamp=None, use_stored_data=True):
212
- return self.vests_to_bp(vests, timestamp=timestamp, use_stored_data=use_stored_data)
213
-
214
- def token_power_to_vests(self, token_power, timestamp=None, use_stored_data=True):
215
- return self.bp_to_vests(token_power, timestamp=timestamp, use_stored_data=use_stored_data)
216
-
217
- def get_token_per_mvest(self, time_stamp=None, use_stored_data=True):
218
- return self.get_blurt_per_mvest(time_stamp=time_stamp, use_stored_data=use_stored_data)
219
-
220
- def token_power_to_token_backed_dollar(
221
- self,
222
- token_power,
223
- post_rshares=0,
224
- voting_power=STEEM_100_PERCENT,
225
- vote_pct=STEEM_100_PERCENT,
226
- not_broadcasted_vote=True,
227
- use_stored_data=True,
228
- ):
229
- return self.bp_to_bbd(
230
- token_power,
231
- post_rshares=post_rshares,
232
- voting_power=voting_power,
233
- vote_pct=vote_pct,
234
- not_broadcasted_vote=not_broadcasted_vote,
235
- use_stored_data=use_stored_data,
236
- )
237
-
238
- def bp_to_bbd(
239
- self,
240
- sp,
241
- post_rshares=0,
242
- voting_power=STEEM_100_PERCENT,
243
- vote_pct=STEEM_100_PERCENT,
244
- not_broadcasted_vote=True,
245
- use_stored_data=True,
246
- ):
247
- """Obtain the resulting equivalent BBD vote value from Blurt power
248
-
249
- :param number steem_power: Blurt Power
250
- :param int post_rshares: rshares of post which is voted
251
- :param int voting_power: voting power (100% = 10000)
252
- :param int vote_pct: voting percentage (100% = 10000)
253
- :param bool not_broadcasted_vote: not_broadcasted or already broadcasted vote (True = not_broadcasted vote).
254
-
255
- Only impactful for very big votes. Slight modification to the value calculation, as the not_broadcasted
256
- vote rshares decreases the reward pool.
257
- """
258
- vesting_shares = int(self.bp_to_vests(sp, use_stored_data=use_stored_data))
259
- return self.vests_to_bbd(
260
- vesting_shares,
261
- post_rshares=post_rshares,
262
- voting_power=voting_power,
263
- vote_pct=vote_pct,
264
- not_broadcasted_vote=not_broadcasted_vote,
265
- use_stored_data=use_stored_data,
266
- )
267
-
268
- def vests_to_bbd(
269
- self,
270
- vests,
271
- post_rshares=0,
272
- voting_power=STEEM_100_PERCENT,
273
- vote_pct=STEEM_100_PERCENT,
274
- not_broadcasted_vote=True,
275
- use_stored_data=True,
276
- ):
277
- """Obtain the resulting BBD vote value from vests
278
-
279
- :param number vests: vesting shares
280
- :param int post_rshares: rshares of post which is voted
281
- :param int voting_power: voting power (100% = 10000)
282
- :param int vote_pct: voting percentage (100% = 10000)
283
- :param bool not_broadcasted_vote: not_broadcasted or already broadcasted vote (True = not_broadcasted vote).
284
-
285
- Only impactful for very big votes. Slight modification to the value calculation, as the not_broadcasted
286
- vote rshares decreases the reward pool.
287
- """
288
- vote_rshares = self.vests_to_rshares(
289
- vests, post_rshares=post_rshares, voting_power=voting_power, vote_pct=vote_pct
290
- )
291
- return self.rshares_to_bbd(
292
- vote_rshares, not_broadcasted_vote=not_broadcasted_vote, use_stored_data=use_stored_data
293
- )
294
-
295
- def _max_vote_denom(self, use_stored_data=True):
296
- # get props
297
- global_properties = self.get_dynamic_global_properties(use_stored_data=use_stored_data)
298
- vote_power_reserve_rate = global_properties["vote_power_reserve_rate"]
299
- max_vote_denom = vote_power_reserve_rate * STEEM_VOTE_REGENERATION_SECONDS
300
- return max_vote_denom
301
-
302
- def _calc_resulting_vote(
303
- self, voting_power=STEEM_100_PERCENT, vote_pct=STEEM_100_PERCENT, use_stored_data=True
304
- ):
305
- # determine voting power used
306
- used_power = int((voting_power * abs(vote_pct)) / STEEM_100_PERCENT * (60 * 60 * 24))
307
- max_vote_denom = self._max_vote_denom(use_stored_data=use_stored_data)
308
- used_power = int((used_power + max_vote_denom - 1) / max_vote_denom)
309
- return used_power
310
-
311
- def bp_to_rshares(
312
- self,
313
- steem_power,
314
- post_rshares=0,
315
- voting_power=STEEM_100_PERCENT,
316
- vote_pct=STEEM_100_PERCENT,
317
- use_stored_data=True,
318
- ):
319
- """Obtain the r-shares from Steem power
320
-
321
- :param number steem_power: Steem Power
322
- :param int post_rshares: rshares of post which is voted
323
- :param int voting_power: voting power (100% = 10000)
324
- :param int vote_pct: voting percentage (100% = 10000)
325
-
326
- """
327
- # calculate our account voting shares (from vests)
328
- vesting_shares = int(self.bp_to_vests(steem_power, use_stored_data=use_stored_data))
329
- return self.vests_to_rshares(
330
- vesting_shares,
331
- post_rshares=post_rshares,
332
- voting_power=voting_power,
333
- vote_pct=vote_pct,
334
- use_stored_data=use_stored_data,
335
- )
336
-
337
- def vests_to_rshares(
338
- self,
339
- vests,
340
- post_rshares=0,
341
- voting_power=STEEM_100_PERCENT,
342
- vote_pct=STEEM_100_PERCENT,
343
- subtract_dust_threshold=True,
344
- use_stored_data=True,
345
- ):
346
- """Obtain the r-shares from vests
347
-
348
- :param number vests: vesting shares
349
- :param int post_rshares: rshares of post which is voted
350
- :param int voting_power: voting power (100% = 10000)
351
- :param int vote_pct: voting percentage (100% = 10000)
352
-
353
- """
354
- used_power = self._calc_resulting_vote(
355
- voting_power=voting_power, vote_pct=vote_pct, use_stored_data=use_stored_data
356
- )
357
- # calculate vote rshares
358
- rshares = int(math.copysign(vests * 1e6 * used_power / STEEM_100_PERCENT, vote_pct))
359
- if subtract_dust_threshold:
360
- if abs(rshares) <= self.get_dust_threshold(use_stored_data=use_stored_data):
361
- return 0
362
- rshares -= math.copysign(
363
- self.get_dust_threshold(use_stored_data=use_stored_data), vote_pct
364
- )
365
- rshares = self._calc_vote_claim(rshares, post_rshares)
366
- return rshares
367
-
368
- def bbd_to_rshares(self, sbd, not_broadcasted_vote=False, use_stored_data=True):
369
- """Obtain the r-shares from SBD
370
-
371
- :param sbd: SBD
372
- :type sbd: str, int, amount.Amount
373
- :param bool not_broadcasted_vote: not_broadcasted or already broadcasted vote (True = not_broadcasted vote).
374
- Only impactful for very high amounts of SBD. Slight modification to the value calculation, as the not_broadcasted
375
- vote rshares decreases the reward pool.
376
-
377
- """
378
- if isinstance(sbd, Amount):
379
- sbd = Amount(sbd, blockchain_instance=self)
380
- elif isinstance(sbd, str):
381
- sbd = Amount(sbd, blockchain_instance=self)
382
- else:
383
- sbd = Amount(sbd, self.token_symbol, blockchain_instance=self)
384
- if sbd["symbol"] != self.token_symbol:
385
- raise AssertionError("Should input Blurt, not any other asset!")
386
-
387
- # If the vote was already broadcasted we can assume the blockchain values to be true
388
- if not not_broadcasted_vote:
389
- return int(float(sbd) / self.get_bbd_per_rshares(use_stored_data=use_stored_data))
390
-
391
- # If the vote wasn't broadcasted (yet), we have to calculate the rshares while considering
392
- # the change our vote is causing to the recent_claims. This is more important for really
393
- # big votes which have a significant impact on the recent_claims.
394
- reward_fund = self.get_reward_funds(use_stored_data=use_stored_data)
395
- median_price = self.get_median_price(use_stored_data=use_stored_data)
396
- recent_claims = int(reward_fund["recent_claims"])
397
- reward_balance = Amount(reward_fund["reward_balance"], blockchain_instance=self)
398
- reward_pool_sbd = median_price * reward_balance
399
- if sbd > reward_pool_sbd:
400
- raise ValueError("Provided more SBD than available in the reward pool.")
401
-
402
- # This is the formula we can use to determine the "true" rshares.
403
- # We get this formula by some math magic using the previous used formulas
404
- # FundsPerShare = (balance / (claims + newShares)) * Price
405
- # newShares = amount / FundsPerShare
406
- # We can now resolve both formulas for FundsPerShare and set the formulas to be equal
407
- # (balance / (claims + newShares)) * price = amount / newShares
408
- # Now we resolve for newShares resulting in:
409
- # newShares = claims * amount / (balance * price - amount)
410
- rshares = (
411
- recent_claims
412
- * float(sbd)
413
- / ((float(reward_balance) * float(median_price)) - float(sbd))
414
- )
415
- return int(rshares)
416
-
417
- def rshares_to_vote_pct(
418
- self,
419
- rshares,
420
- post_rshares=0,
421
- steem_power=None,
422
- vests=None,
423
- voting_power=STEEM_100_PERCENT,
424
- use_stored_data=True,
425
- ):
426
- """Obtain the voting percentage for a desired rshares value
427
- for a given Steem Power or vesting shares and voting_power
428
- Give either steem_power or vests, not both.
429
- When the output is greater than 10000 or less than -10000,
430
- the given absolute rshares are too high
431
-
432
- Returns the required voting percentage (100% = 10000)
433
-
434
- :param number rshares: desired rshares value
435
- :param number steem_power: Steem Power
436
- :param number vests: vesting shares
437
- :param int voting_power: voting power (100% = 10000)
438
-
439
- """
440
- if steem_power is None and vests is None:
441
- raise ValueError("Either steem_power or vests has to be set!")
442
- if steem_power is not None and vests is not None:
443
- raise ValueError("Either steem_power or vests has to be set. Not both!")
444
- if steem_power is not None:
445
- vests = int(self.bp_to_vests(steem_power, use_stored_data=use_stored_data) * 1e6)
446
-
447
- if self.hardfork >= 20:
448
- rshares += math.copysign(
449
- self.get_dust_threshold(use_stored_data=use_stored_data), rshares
450
- )
451
-
452
- if post_rshares >= 0 and rshares > 0:
453
- rshares = math.copysign(
454
- self._calc_revert_vote_claim(abs(rshares), post_rshares), rshares
455
- )
456
- elif post_rshares < 0 and rshares < 0:
457
- rshares = math.copysign(
458
- self._calc_revert_vote_claim(abs(rshares), abs(post_rshares)), rshares
459
- )
460
- elif post_rshares < 0 and rshares > 0:
461
- rshares = math.copysign(self._calc_revert_vote_claim(abs(rshares), 0), rshares)
462
- elif post_rshares > 0 and rshares < 0:
463
- rshares = math.copysign(
464
- self._calc_revert_vote_claim(abs(rshares), post_rshares), rshares
465
- )
466
-
467
- max_vote_denom = self._max_vote_denom(use_stored_data=use_stored_data)
468
-
469
- used_power = int(math.ceil(abs(rshares) * STEEM_100_PERCENT / vests))
470
- used_power = used_power * max_vote_denom
471
-
472
- vote_pct = used_power * STEEM_100_PERCENT / (60 * 60 * 24) / voting_power
473
- return int(math.copysign(vote_pct, rshares))
474
-
475
- def bbd_to_vote_pct(
476
- self,
477
- sbd,
478
- post_rshares=0,
479
- steem_power=None,
480
- vests=None,
481
- voting_power=STEEM_100_PERCENT,
482
- not_broadcasted_vote=True,
483
- use_stored_data=True,
484
- ):
485
- """Obtain the voting percentage for a desired SBD value
486
- for a given Steem Power or vesting shares and voting power
487
- Give either Steem Power or vests, not both.
488
- When the output is greater than 10000 or smaller than -10000,
489
- the SBD value is too high.
490
-
491
- Returns the required voting percentage (100% = 10000)
492
-
493
- :param sbd: desired SBD value
494
- :type sbd: str, int, amount.Amount
495
- :param number steem_power: Steem Power
496
- :param number vests: vesting shares
497
- :param bool not_broadcasted_vote: not_broadcasted or already broadcasted vote (True = not_broadcasted vote).
498
- Only impactful for very high amounts of SBD. Slight modification to the value calculation, as the not_broadcasted
499
- vote rshares decreases the reward pool.
500
-
501
- """
502
- if isinstance(sbd, Amount):
503
- sbd = Amount(sbd, blockchain_instance=self)
504
- elif isinstance(sbd, str):
505
- sbd = Amount(sbd, blockchain_instance=self)
506
- else:
507
- sbd = Amount(sbd, self.token_symbol, blockchain_instance=self)
508
- if sbd["symbol"] != self.token_symbol:
509
- raise AssertionError()
510
- rshares = self.bbd_to_rshares(
511
- sbd, not_broadcasted_vote=not_broadcasted_vote, use_stored_data=use_stored_data
512
- )
513
- return self.rshares_to_vote_pct(
514
- rshares,
515
- post_rshares=post_rshares,
516
- steem_power=steem_power,
517
- vests=vests,
518
- voting_power=voting_power,
519
- use_stored_data=use_stored_data,
520
- )
521
-
522
- @property
523
- def chain_params(self):
524
- if self.offline or self.rpc is None:
525
- return known_chains["BLURT"]
526
- else:
527
- return self.get_network()
528
-
529
- @property
530
- def hardfork(self):
531
- if self.offline or self.rpc is None:
532
- versions = known_chains["BLURT"]["min_version"]
533
- else:
534
- hf_prop = self.get_hardfork_properties()
535
- if "current_hardfork_version" in hf_prop:
536
- versions = hf_prop["current_hardfork_version"]
537
- else:
538
- versions = self.get_blockchain_version()
539
- return int(versions.split(".")[1])
540
-
541
- @property
542
- def is_blurt(self):
543
- config = self.get_config()
544
- if config is None:
545
- return True
546
- return "BLURT_CHAIN_ID" in self.get_config()
547
-
548
- @property
549
- def bbd_symbol(self):
550
- """get the current chains symbol for SBD (e.g. "TBD" on testnet)"""
551
- # some networks (e.g. whaleshares) do not have SBD
552
- return None
553
-
554
- @property
555
- def steem_symbol(self):
556
- """get the current chains symbol for STEEM (e.g. "TESTS" on testnet)"""
557
- return self._get_asset_symbol(1)
558
-
559
- @property
560
- def vests_symbol(self):
561
- """get the current chains symbol for VESTS"""
562
- return self._get_asset_symbol(2)