Skip to content
Snippets Groups Projects
Commit 994356be authored by adorda's avatar adorda
Browse files

nueva funcionalidad

parent 4cee6afb
No related branches found
No related tags found
No related merge requests found
......@@ -48,6 +48,10 @@ class NoConnectionException(Exception):
pass
class UnlockAccountException(Exception):
pass
class Gateway:
is_poa = False
......@@ -122,6 +126,20 @@ class Gateway:
logger.debug("Transaction hash: {}".format(tx_hash.hex()))
return tx_hash
def execute_transaction_with_unlock(self, function, passphrase, timeout, transaction_data):
logger.debug("Executing transaction for function {} / tx data {}".format(str(function), str(transaction_data)))
try:
self.w3.personal.unlockAccount(transaction_data['from'], passphrase, timeout)
except Exception as uae:
raise UnlockAccountException("Passphrase is incorrect")
try:
function.call(transaction_data)
except ValueError as ve:
raise InvalidTransactionException(ve.args[0]['message'])
tx_hash = function.transact(transaction_data)
logger.debug("Transaction hash: {}".format(tx_hash.hex()))
return tx_hash
def call_transaction(self, function, transaction_data=None, exception_message=""):
if transaction_data is None:
transaction_data = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment