@@ -25,7 +25,6 @@ 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
2928
3029 if private_key :
3130 self .private_key = private_key
@@ -55,7 +54,7 @@ def get_block(self, block=None):
5554
5655 """
5756 if block is None :
58- exit ('No block identifier provided' )
57+ raise Exception ('No block identifier provided' )
5958
6059 if block == 'latest' :
6160 return self .get_current_block ()
@@ -84,7 +83,7 @@ def get_block_by_number(self, block_id):
8483
8584 """
8685 if not utils .is_integer (block_id ) or block_id < 0 :
87- exit ('Invalid block number provided' )
86+ raise Exception ('Invalid block number provided' )
8887
8988 return self .full_node .request ('/wallet/getblockbynum' , {
9089 'num' : int (block_id )
@@ -113,12 +112,12 @@ def get_transaction_from_block(self, block=None, index=0):
113112
114113 """
115114 if not utils .is_integer (index ) or index < 0 :
116- exit ('Invalid transaction index provided' )
115+ raise Exception ('Invalid transaction index provided' )
117116
118117 transactions = self .get_block (block )['transactions' ]
119118
120119 if not transactions or len (transactions ) < index :
121- exit ('Transaction not found in block' )
120+ raise Exception ('Transaction not found in block' )
122121
123122 return transactions [index ]
124123
@@ -134,7 +133,7 @@ def get_transaction(self, transaction_id):
134133 }, 'post' )
135134
136135 if not response :
137- exit ('Transaction not found' )
136+ raise Exception ('Transaction not found' )
138137
139138 return response
140139
@@ -201,7 +200,7 @@ def send_transaction(self, from_address, to_address, amount):
201200
202201 """
203202 if not self .private_key :
204- exit ('Missing private key' )
203+ raise Exception ('Missing private key' )
205204
206205 transaction = self ._create_transaction (from_address , to_address , amount )
207206 sign = self ._sign_transaction (transaction )
@@ -240,10 +239,7 @@ def _sign_transaction(self, transaction):
240239
241240 """
242241 if 'signature' in transaction :
243- exit ('Transaction is already signed' )
244-
245- if self .data is not None :
246- transaction ['raw_data' ]['data' ] = self .string_utf8_to_hex (self .data )
242+ raise Exception ('Transaction is already signed' )
247243
248244 return self .full_node .request ('/wallet/gettransactionsign' , {
249245 'transaction' : transaction ,
@@ -260,10 +256,10 @@ def _send_raw_transaction(self, signed):
260256
261257 """
262258 if not type ({}) is dict :
263- exit ('Invalid transaction provided' )
259+ raise Exception ('Invalid transaction provided' )
264260
265261 if 'signature' not in signed :
266- exit ('Transaction is not signed' )
262+ raise Exception ('Transaction is not signed' )
267263
268264 return self .full_node .request ('/wallet/broadcasttransaction' , signed , 'post' )
269265
@@ -350,10 +346,10 @@ def get_block_range(self, start, end):
350346
351347 """
352348 if not utils .is_integer (start ) or start < 0 :
353- exit ('Invalid start of range provided' )
349+ raise Exception ('Invalid start of range provided' )
354350
355351 if not utils .is_integer (end ) or end <= start :
356- exit ('Invalid end of range provided' )
352+ raise Exception ('Invalid end of range provided' )
357353
358354 return self .full_node .request ('/wallet/getblockbylimitnext' , {
359355 'startNum' : int (start ),
@@ -368,7 +364,7 @@ def get_latest_blocks(self, limit=1):
368364
369365 """
370366 if not utils .is_integer (limit ) or limit <= 0 :
371- exit ('Invalid limit provided' )
367+ raise Exception ('Invalid limit provided' )
372368
373369 return self .full_node .request ('/wallet/getblockbylatestnum' , {
374370 'limit' : limit
@@ -392,10 +388,10 @@ def list_tokens(self, limit=0, offset=0):
392388
393389 """
394390 if not utils .is_integer (limit ) or (limit and offset < 1 ):
395- exit ('Invalid limit provided' )
391+ raise Exception ('Invalid limit provided' )
396392
397393 if not utils .is_integer (offset ) or offset < 0 :
398- exit ('Invalid offset provided' )
394+ raise Exception ('Invalid offset provided' )
399395
400396 if not limit :
401397 return self .full_node .request ('/wallet/getassetissuelist' )['assetIssue' ]
0 commit comments