Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
fix alerts from lgtm (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhar-shubhendu authored Nov 15, 2019
1 parent ef57a7a commit e1e2f51
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 28 deletions.
5 changes: 1 addition & 4 deletions aeternity/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ def contract_encode_calldata(contract_file, function_name, arguments, compiler_u
code = fp.read()
c = CompilerClient(compiler_url=compiler_url)
arguments = [] if arguments is None else arguments.split(",")
result = c.encode_calldata(code, function_name, arguments=arguments)
result = c.encode_calldata(code, function_name, *arguments)
_print_object(result, title="contract")
except OpenAPIClientException as e:
_print_object(e.data, title="compiler error")
Expand Down Expand Up @@ -902,7 +902,6 @@ def inspect(obj, height, force, wait, json_):
@online_options
def chain(json_, force, wait):
set_global_options(json_, force, wait)
pass


@chain.command('ttl')
Expand Down Expand Up @@ -1003,8 +1002,6 @@ def chain_play(height, limit, force, wait, json_):
g = cli.get_generation_by_hash(hash=g.key_block.prev_key_hash)
except Exception as e:
_print_error(e)
g = None
pass


# run the client
Expand Down
9 changes: 4 additions & 5 deletions aeternity/contract_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ def __inject_vars(self, t, aci_types):
gen_map = []
for y in gen:
var_name_list = list(map(lambda e: e.name, aci_types['vars']))
index = -1
if y in var_name_list:
index = var_name_list.index(y)
gen_map.append(variant_value[index])
Expand Down Expand Up @@ -249,16 +248,16 @@ def to_sophia_string(self, arg, generic, bindings={}):
return f'\"{arg}\"'

def to_sophia_signature(self, arg, generic, bindings={}):
return self.to_sophia_bytes(arg)
return self.to_sophia_bytes(arg, generic, bindings={})

def from_sophia_signature(self, arg, generic, bindings={}):
return self.from_sophia_bytes(arg)
return self.from_sophia_bytes(arg, generic, bindings={})

def to_sophia_hash(self, arg, generic, bindings={}):
return self.to_sophia_bytes(arg)
return self.to_sophia_bytes(arg, generic, bindings={})

def from_sophia_hash(self, arg, generic, bindings={}):
return self.from_sophia_bytes(arg)
return self.from_sophia_bytes(arg, generic, bindings={})

def to_sophia_bytes(self, arg, generic, bindings={}):
if isinstance(arg, str):
Expand Down
1 change: 1 addition & 0 deletions aeternity/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class TransactionWaitTimeoutExpired(AException):
"""Raised when a transaction hasn't been found after waiting for an amount of time"""

def __init__(self, tx_hash, reason):
AENSException.__init__(self)
self.tx_hash = tx_hash
self.reason = reason

Expand Down
2 changes: 1 addition & 1 deletion aeternity/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def wait_for_transaction(self, tx_hash, max_retries=None, polling_interval=None)
# start polling
n = 1
total_sleep = 0
tx_height = -1
# tx_height = -1
while True:
# query the transaction
try:
Expand Down
35 changes: 17 additions & 18 deletions aeternity/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ def __init__(self,
self.gas_per_byte = gas_per_byte
self.gas_price = gas_price
self.key_block_interval = key_block_interval
pass

@staticmethod
def compute_tx_hash(encoded_tx: str) -> str:
Expand Down Expand Up @@ -731,7 +730,7 @@ def tx_signed(self, signatures: list, tx: TxObject, metadata={}):
)
return self._build_txobject(body, metadata=metadata)

def tx_spend(self, sender_id, recipient_id, amount, payload, fee, ttl, nonce) -> tuple:
def tx_spend(self, sender_id, recipient_id, amount, payload, fee, ttl, nonce) -> TxObject:
"""
create a spend transaction
:param sender_id: the public key of the sender
Expand Down Expand Up @@ -759,7 +758,7 @@ def tx_spend(self, sender_id, recipient_id, amount, payload, fee, ttl, nonce) ->

# NAMING #

def tx_name_preclaim(self, account_id, commitment_id, fee, ttl, nonce) -> tuple:
def tx_name_preclaim(self, account_id, commitment_id, fee, ttl, nonce) -> TxObject:
"""
create a preclaim transaction
:param account_id: the account registering the name
Expand All @@ -780,7 +779,7 @@ def tx_name_preclaim(self, account_id, commitment_id, fee, ttl, nonce) -> tuple:
return self._build_txobject(body)
# return self.api.post_name_preclaim(body=body).tx

def tx_name_claim(self, account_id, name, name_salt, fee, ttl, nonce) -> tuple:
def tx_name_claim(self, account_id, name, name_salt, fee, ttl, nonce) -> TxObject:
"""
create a preclaim transaction
:param account_id: the account registering the name
Expand All @@ -802,13 +801,13 @@ def tx_name_claim(self, account_id, name, name_salt, fee, ttl, nonce) -> tuple:
)
return self._build_txobject(body)

def tx_name_claim_v2(self, account_id, name, name_salt, name_fee, fee, ttl, nonce) -> tuple:
def tx_name_claim_v2(self, account_id, name, name_salt, name_fee, fee, ttl, nonce) -> TxObject:
"""
create a preclaim transaction
:param account_id: the account registering the name
:param name: the actual name to claim
:param name_salt: the salt used to create the commitment_id during preclaim
:param name_fee: the fee bidded to claim the name
:param name_fee: the fee bid to claim the name
:param fee: the fee for the transaction
:param ttl: the ttl for the transaction
:param nonce: the nonce of the account for the transaction
Expand All @@ -826,7 +825,7 @@ def tx_name_claim_v2(self, account_id, name, name_salt, name_fee, fee, ttl, nonc
)
return self._build_txobject(body)

def tx_name_update(self, account_id, name_id, pointers, name_ttl, client_ttl, fee, ttl, nonce) -> tuple:
def tx_name_update(self, account_id, name_id, pointers, name_ttl, client_ttl, fee, ttl, nonce) -> TxObject:
"""
create an update transaction
:param account_id: the account updating the name
Expand All @@ -853,7 +852,7 @@ def tx_name_update(self, account_id, name_id, pointers, name_ttl, client_ttl, fe
return self._build_txobject(body)
# return self.api.post_name_update(body=body).tx

def tx_name_transfer(self, account_id, name_id, recipient_id, fee, ttl, nonce) -> tuple:
def tx_name_transfer(self, account_id, name_id, recipient_id, fee, ttl, nonce) -> TxObject:
"""
create a transfer transaction
:param account_id: the account transferring the name
Expand All @@ -876,7 +875,7 @@ def tx_name_transfer(self, account_id, name_id, recipient_id, fee, ttl, nonce) -
return self._build_txobject(body)
# return self.api.post_name_transfer(body=body).tx

def tx_name_revoke(self, account_id, name_id, fee, ttl, nonce) -> tuple:
def tx_name_revoke(self, account_id, name_id, fee, ttl, nonce) -> TxObject:
"""
create a revoke transaction
:param account_id: the account revoking the name
Expand All @@ -900,14 +899,14 @@ def tx_name_revoke(self, account_id, name_id, fee, ttl, nonce) -> tuple:

# CONTRACTS

def tx_contract_create(self, owner_id, code, call_data, amount, deposit, gas, gas_price, vm_version, abi_version, fee, ttl, nonce) -> tuple:
def tx_contract_create(self, owner_id, code, call_data, amount, deposit, gas, gas_price, vm_version, abi_version, fee, ttl, nonce) -> TxObject:
"""
Create a contract transaction
:param owner_id: the account creating the contract
:param code: the binary code of the contract
:param call_data: the call data for the contract
:param amount: initial amount(balance) of the contract
:param deposit: the deposit bounde to the contract
:param deposit: the deposit bound to the contract
:param gas: the gas limit for the execution of the limit function
:param gas_price: the gas price for the unit of gas
:param vm_version: the vm version of the contract
Expand Down Expand Up @@ -935,7 +934,7 @@ def tx_contract_create(self, owner_id, code, call_data, amount, deposit, gas, ga
return self._build_txobject(body)
# return tx.tx, tx.contract_id

def tx_contract_call(self, caller_id, contract_id, call_data, function, amount, gas, gas_price, abi_version, fee, ttl, nonce) -> tuple:
def tx_contract_call(self, caller_id, contract_id, call_data, function, amount, gas, gas_price, abi_version, fee, ttl, nonce) -> TxObject:
"""
Create a Contract Call transaction
:param caller_id: the account creating the contract
Expand Down Expand Up @@ -973,7 +972,7 @@ def tx_contract_call(self, caller_id, contract_id, call_data, function, amount,
def tx_oracle_register(self, account_id,
query_format, response_format,
query_fee, ttl_type, ttl_value, vm_version,
fee, ttl, nonce) -> tuple:
fee, ttl, nonce) -> TxObject:
"""
Create a register oracle transaction
"""
Expand All @@ -997,7 +996,7 @@ def tx_oracle_register(self, account_id,
def tx_oracle_query(self, oracle_id, sender_id, query,
query_fee, query_ttl_type, query_ttl_value,
response_ttl_type, response_ttl_value,
fee, ttl, nonce) -> tuple:
fee, ttl, nonce) -> TxObject:
"""
Create a oracle query transaction
"""
Expand All @@ -1023,7 +1022,7 @@ def tx_oracle_query(self, oracle_id, sender_id, query,

def tx_oracle_respond(self, oracle_id, query_id, response,
response_ttl_type, response_ttl_value,
fee, ttl, nonce) -> tuple:
fee, ttl, nonce) -> TxObject:
"""
Create a oracle response transaction
"""
Expand All @@ -1045,7 +1044,7 @@ def tx_oracle_respond(self, oracle_id, query_id, response,

def tx_oracle_extend(self, oracle_id,
ttl_type, ttl_value,
fee, ttl, nonce) -> tuple:
fee, ttl, nonce) -> TxObject:
"""
Create a oracle extends transaction
"""
Expand All @@ -1065,7 +1064,7 @@ def tx_oracle_extend(self, oracle_id,

def tx_ga_attach(self, owner_id, nonce, code,
auth_fun, vm_version, abi_version,
fee, ttl, gas, gas_price, call_data):
fee, ttl, gas, gas_price, call_data) -> TxObject:
"""
:param owner_id: the owner of the contra
:param nonce: the transaction nonce
Expand Down Expand Up @@ -1100,7 +1099,7 @@ def tx_ga_meta(self, ga_id,
gas,
gas_price,
ttl,
tx):
tx) -> TxObject:
"""
:param ga_id: the account id
:param auth_data: the authorized data
Expand Down

0 comments on commit e1e2f51

Please sign in to comment.