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
4 changes: 0 additions & 4 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ overgeneral-exceptions=builtins.BaseException,builtins.Exception
# Ignore missing members accessed in mocking
ignored-modules=
cryptnox_sdk_py,
lazy_import,
appdirs,
tabulate,
ecdsa,
Expand All @@ -153,11 +152,8 @@ ignored-modules=
hexbytes,
web3,
requests,
boto3,
botocore,
cryptography,
winsdk,
stdiomask,
smartcard,
Cryptodome
# List of classes names for which member attributes should not be checked
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
Changelog
=========

Unreleased
----------

Changed
^^^^^^^
- Masked PIN, PUK and passphrase input on Linux and macOS is handled by the CLI itself; the ``stdiomask`` dependency is removed
- Ethereum support is loaded only by the commands that use it, so commands such as ``history`` and ``info`` start noticeably faster; the ``lazy-import`` dependency is removed

Fixed
^^^^^
- Windows: PIN, PUK and BIP39 passphrase entry now accepts the full Unicode range. Characters outside ASCII were previously discarded as they were typed, so a passphrase containing them was not the one the user entered. Arrow and function keys are ignored instead of adding characters to the entry, and Ctrl+C cancels the prompt again

`1.0.5 <https://github.com/Cryptnox-Software/cryptnox-cli/compare/ver1.0.4...ver1.0.5>`_
------------------------------------------------------------------------------------------------

Expand Down
9 changes: 3 additions & 6 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@ pytest-pylint = "*"
pytest = "*"

[packages]
argparse = "*"
appdirs = "*"
base58 = "*"
boto3 = "*"
ecdsa = ">=0.19.2"
colander = "*"
cryptnox-sdk-py = ">=1.0.5"
lazy-import = "*"
pytz = "*"
eth-account = "*"
eth-utils = "*"
hexbytes = "*"
requests = ">=2.33.0"
solders = ">=0.27.0"
tabulate = "*"
stdiomask = "*"
web3 = ">=7.15.0"
winsdk = {version = "*", sys_platform = "== 'win32'"}

Expand Down
5 changes: 4 additions & 1 deletion cryptnox_cli/command/card/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from typing import List, Dict

import cryptnox_sdk_py
import web3
from argparse import Namespace
from tabulate import tabulate

Expand Down Expand Up @@ -160,6 +159,8 @@ def _get_btc_info(config, pubkey) -> dict:

@staticmethod
def _get_eth_info(config, public_key) -> dict:
import web3

if public_key is None:
return {"name": "ETH", "address": "Bad derivation type", "network": ""}
network = enums.EthNetwork[config.get("network", "infura").upper()]
Expand Down Expand Up @@ -240,6 +241,8 @@ def _get_solana_info(config, pubkey) -> dict:

@staticmethod
def _get_bnb_info(public_key) -> dict:
import web3

# BNB on Binance Smart Chain (BSC) is EVM-compatible: same secp256k1
# curve, same derivation path, and same address format as Ethereum.
if public_key is None:
Expand Down
6 changes: 5 additions & 1 deletion cryptnox_cli/command/erc_token/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import cryptnox_sdk_py
import requests
import web3
from tabulate import tabulate

from ..helper.helper_methods import sign
Expand Down Expand Up @@ -41,6 +40,8 @@ def abi(value: int):

def gas(gas_price: int, set_price: int, set_limit: int,
default_limit: int = LIMIT["transfer"]) -> Tuple[int, int]:
import web3

if set_price:
price = set_price
else:
Expand All @@ -65,6 +66,7 @@ def gas(gas_price: int, set_price: int, set_limit: int,
def transfer(card, endpoint, network, api_key, contract_address: str, to: str, amount: float,
price: int, limit: int,
derivation: cryptnox_sdk_py.Derivation = cryptnox_sdk_py.Derivation.CURRENT_KEY) -> int:
import web3

try:
endpoint = wallet.Api(endpoint, network, api_key)
Expand Down Expand Up @@ -159,6 +161,8 @@ def transfer(card, endpoint, network, api_key, contract_address: str, to: str, a
def _confirm_token_sending(contract: str, address: str, to: str,
token_balance: float, symbol: str, value: Union[Decimal, int],
balance: int, price: int, limit: float):
import web3

gas_price = web3.Web3.from_wei(price, "ether")
total_gas = Decimal(gas_price * limit)
balance = web3.Web3.from_wei(balance, "ether")
Expand Down
7 changes: 6 additions & 1 deletion cryptnox_cli/command/erc_token/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from cryptography.hazmat.primitives.asymmetric import ec
from eth_typing import ChecksumAddress
from tabulate import tabulate
from web3 import Web3

from ..cards import Cards
from ..helper.cards import CardManager
Expand Down Expand Up @@ -158,6 +157,8 @@ def execute(self, card: cryptnox_sdk_py.Card) -> int:

@staticmethod
def _balance(endpoint, address):
from web3 import Web3

try:
w3 = Web3(Web3.HTTPProvider(endpoint))
print(f"Balance: {Web3.from_wei(w3.eth.get_balance(address), 'ether')} ETH")
Expand Down Expand Up @@ -212,6 +213,8 @@ def _owner(
abi: str,
account: str,
token_id: int) -> None:
from web3 import Web3

print(f"Checking owner on contract: {contract_address}...")
w3 = Web3(Web3.HTTPProvider(endpoint))
try:
Expand All @@ -232,6 +235,8 @@ def _owner(
@staticmethod
def _token_balance(endpoint: str, contract_address: ChecksumAddress, abi: str,
account: str) -> None:
from web3 import Web3

print(f"Checking token on contract: {contract_address}...")
w3 = Web3(Web3.HTTPProvider(endpoint))
try:
Expand Down
13 changes: 12 additions & 1 deletion cryptnox_cli/command/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import cryptnox_sdk_py
import requests
import web3
from argparse import Namespace
from tabulate import tabulate

Expand Down Expand Up @@ -118,6 +117,8 @@ def list(self) -> int:
return 0

def logs(self):
import web3

try:
config_contract = get_configuration(self.card)["hidden"]["eth"]["contract"][self.data.alias]
except KeyError:
Expand Down Expand Up @@ -275,6 +276,8 @@ def _get_endpoint(self, card):
return wallet.Api(config["eth"]["endpoint"], network, config["eth"]["api_key"])

def _add(self, card):
import web3

abi = _get_processed_json_argument(self.data.abi)

try:
Expand Down Expand Up @@ -365,6 +368,8 @@ def _functions(self, card):
return None

def _call(self, card):
import web3

config = get_configuration(card)
try:
config = config["hidden"]["eth"]["contract"][self.data.alias]
Expand Down Expand Up @@ -409,6 +414,8 @@ def _call(self, card):
return 0

def _transact(self, card):
import web3

self._check(card)

config = get_configuration(card)
Expand Down Expand Up @@ -505,6 +512,8 @@ def _transact(self, card):

@staticmethod
def _confirm(public_key, address, balance, value, price, limit):
import web3

gas_price = web3.Web3.from_wei(price, "ether")
gas = Decimal(gas_price * limit)
balance = web3.Web3.from_wei(balance, "ether")
Expand Down Expand Up @@ -595,6 +604,8 @@ def _send(self, card) -> int:

@staticmethod
def _send_funds(card, derivation, endpoint, address, amount, price, limit):
import web3

path = b"" if derivation == cryptnox_sdk_py.Derivation.CURRENT_KEY else wallet.Api.PATH
public_key = card.get_public_key(derivation, path=path, compressed=False)

Expand Down
Loading
Loading