Skip to content

Commit 87551ec

Browse files
committed
dump to update 1.0.5
1 parent 351c81b commit 87551ec

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
py_version = platform.python_version()
1212

13-
_TRON_VERSION = '1.0.4'
13+
_TRON_VERSION = '1.0.5'
1414

1515
REQUIRED = [
1616
'urllib3'

tronapi/crypto/utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
def compat_bytes(item, encoding=None):
2+
"""Этот метод требуется, потому что Python 2.7 `bytes`
3+
является просто псевдонимом для` str`. Без этого метода,
4+
5+
:param item:
6+
:param encoding:
7+
:return:
8+
"""
9+
if hasattr(item, '__bytes__'):
10+
return item.__bytes__()
11+
else:
12+
if encoding:
13+
return bytes(item, encoding)
14+
else:
15+
return bytes(item)
16+
117

218
def is_integer(var):
319
try:

tronapi/tron.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(self, full_node, solidity_node=None, event_server=None, private_key
2525
self.full_node = full_node
2626
self.solidity_node = solidity_node
2727
self.event_server = event_server
28+
self.data = None
2829

2930
if private_key:
3031
self.private_key = private_key
@@ -241,6 +242,9 @@ def _sign_transaction(self, transaction):
241242
if 'signature' in transaction:
242243
exit('Transaction is already signed')
243244

245+
if self.data is not None:
246+
transaction['raw_data']['data'] = self.string_utf8_to_hex(self.data)
247+
244248
return self.full_node.request('/wallet/gettransactionsign', {
245249
'transaction': transaction,
246250
'privateKey': self.private_key
@@ -447,7 +451,7 @@ def to_tron(amount):
447451
amount (float): Сумма
448452
449453
"""
450-
return abs(amount) * pow(10, 6)
454+
return math.floor(amount * 1e6)
451455

452456
@staticmethod
453457
def from_tron(amount):

0 commit comments

Comments
 (0)