Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cryptnox_cli/command/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def _handle_execution(self, serial_number: int = None) -> int:
try:
self.serial_number = self.data.serial
except AttributeError:
# No serial provided in arguments; keep the passed-in serial_number
pass
try:
card = self._cards[self.serial_number]
Expand All @@ -67,6 +68,8 @@ def _handle_execution(self, serial_number: int = None) -> int:

self.run_execute(card)

return None

def run_execute(self, card) -> int:
print(f"Using card with serial number {card.serial_number}")
origin = card.origin
Expand Down
6 changes: 3 additions & 3 deletions cryptnox_cli/command/erc_token/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import gzip
import json
import urllib
import urllib.error
import urllib.parse
from argparse import Namespace
from typing import List
from urllib import parse

import cryptnox_sdk_py
import requests
Expand Down Expand Up @@ -202,7 +202,7 @@ def _token_slots() -> list[str]:
def _abi() -> str:
def uri_validator(x):
try:
result = parse.urlparse(x)
result = urllib.parse.urlparse(x)
return all([result.scheme, result.netloc])
except Exception:
return False
Expand Down
10 changes: 10 additions & 0 deletions cryptnox_cli/command/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ def logs(self):
endpoint.block_number
save_to_config(self.card, self.config)

return None

@staticmethod
def _get_logs(event) -> List[Dict[str, Any]]:
min_offset = 0
Expand Down Expand Up @@ -256,6 +258,8 @@ def _execute(self, card):
print(error)
return -1

return None

def _get_endpoint(self, card):
config = get_configuration(card)

Expand Down Expand Up @@ -311,6 +315,8 @@ def _add(self, card):
print(f"Contract added to application. Use it with alias:"
f" {self.data.alias}")

return None

@staticmethod
def _list(card) -> int:
config = get_configuration(card)
Expand Down Expand Up @@ -356,6 +362,8 @@ def _functions(self, card):

print(tabulate(tabulate_table, headers=tabulate_header, tablefmt="grid"))

return None

def _call(self, card):
config = get_configuration(card)
try:
Expand Down Expand Up @@ -645,3 +653,5 @@ def _send_token(self, card):
contract.transfer(card, config["endpoint"], config["network"], config["api_key"],
self.data.contract, self.data.address, self.data.amount, self.data.price,
self.data.limit, derivation)

return None
2 changes: 1 addition & 1 deletion cryptnox_cli/command/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def command(data: Namespace, cards: CardManager = None) -> Command:
'btc', 'card_configuration', 'change_pin', 'change_puk', 'config',
'eth', 'history', 'info', 'initialize', 'seed', 'cards', 'server',
'reset', 'unlock_pin', 'user_key', 'transfer', 'get_xpub',
'get_clearpubkey', 'decrypt', 'manufacturer_certificate'
'get_clearpubkey', 'decrypt', 'manufacturer_certificate', 'musig2'
]

for module_name in command_modules:
Expand Down
1 change: 1 addition & 0 deletions cryptnox_cli/command/get_clearpubkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def _execute(self, card) -> int:
else:
card.derive(key_type, "m/44'/0'/0'")
except Exception:
# Best-effort derivation; clear pubkey read below handles failures
pass
pubkey_bytes = card.get_public_key_clear(derivation, path, compressed)
self._print_pubkey_info(key_type, compressed, pubkey_bytes)
Expand Down
3 changes: 2 additions & 1 deletion cryptnox_cli/command/helper/cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def refresh(self, remote: bool = False) -> None:
except cryptnox_sdk_py.exceptions.ReaderException:
break
except cryptnox_sdk_py.exceptions.CryptnoxException:
# Card at this index is unreadable; skip it and continue scanning
pass

index += 1
Expand Down Expand Up @@ -194,7 +195,7 @@ def _open_card(self, index: int, remote: bool = False) -> cryptnox_sdk_py.Card:
if test_response:
if index in self._cards_by_index:
return self._cards_by_index[index]
except (BaseException, cryptnox_sdk_py.exceptions.ConnectionException):
except (Exception, cryptnox_sdk_py.exceptions.ConnectionException):
# Connection is stale, remove it and create new one
del _GLOBAL_CONNECTIONS[index]
if index in self._cards_by_index:
Expand Down
1 change: 1 addition & 0 deletions cryptnox_cli/command/helper/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def write_config(card: cryptnox_sdk_py.Card, section: str, key: str, value: str)
print(error)
return 1
except AttributeError:
# Key not present on the validator instance; fall through to config handling
pass

try:
Expand Down
1 change: 1 addition & 0 deletions cryptnox_cli/command/helper/helper_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@ def try_eval(value: str) -> Any:
try:
value = ast.literal_eval(value)
except ValueError:
# Not a literal; keep the original string value
pass
return value
1 change: 1 addition & 0 deletions cryptnox_cli/command/helper/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def check(card, check_seed: bool = True) -> bool:
try:
result = user_keys.authenticate(card)
except NotImplementedError:
# User-key auth unsupported here; fall back to PIN authentication below
pass

if not result:
Expand Down
Loading
Loading