mirror of
https://gitlab.com/pulsechaincom/staking-deposit-cli.git
synced 2025-01-03 09:37:39 +00:00
Adds Makefile + Lint
This commit is contained in:
parent
97350c941c
commit
c89603e9c4
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
# Eth2 specs:
|
||||
eth2.0-specs/
|
||||
|
||||
# Python testing & linting:
|
||||
venv/
|
||||
.pytest_cache
|
||||
.hypothesis
|
||||
.mypy_cache
|
||||
__pycache__
|
17
Makefile
Normal file
17
Makefile
Normal file
@ -0,0 +1,17 @@
|
||||
clean:
|
||||
rm -rf eth2.0-specs/
|
||||
rm -rf venv/
|
||||
find . -name __pycache__ -exec rm -rf {} \;
|
||||
find . -name .mypy_cache -exec rm -rf {} \;
|
||||
find . -name .pytest_cache -exec rm -rf {} \;
|
||||
|
||||
install_test:
|
||||
python3 -m venv venv; . venv/bin/activate; pip3 install -r requirements.txt
|
||||
|
||||
test:
|
||||
. venv/bin/activate; python -m pytest ./src
|
||||
|
||||
lint:
|
||||
. venv/bin/activate; \
|
||||
flake8 --ignore=E252,W504,W503 --max-line-length=120 ./src \
|
||||
&& mypy --follow-imports=skip --ignore-missing-imports src
|
0
src/__init__.py
Normal file
0
src/__init__.py
Normal file
0
src/key_derivation/__init__.py
Normal file
0
src/key_derivation/__init__.py
Normal file
@ -1,14 +1,17 @@
|
||||
from os import walk
|
||||
from secrets import randbits
|
||||
from typing import (
|
||||
List,
|
||||
Optional,
|
||||
)
|
||||
|
||||
from ..utils.crypto import SHA256
|
||||
|
||||
word_lists_path = './src/key_derivation/word_lists/'
|
||||
|
||||
|
||||
def _get_word_list(language: str):
|
||||
return open('%s%s.txt' %(word_lists_path, language)).readlines()
|
||||
return open('%s%s.txt' % (word_lists_path, language)).readlines()
|
||||
|
||||
|
||||
def get_languages(path: str=word_lists_path) -> List[str]:
|
||||
|
@ -26,4 +26,4 @@ def mnemonic_and_path_to_key(*, mnemonic: str, password: str, path: str) -> int:
|
||||
sk = derive_master_SK(seed)
|
||||
for node in path_to_nodes(path):
|
||||
sk = derive_child_SK(parent_SK=sk, index=node)
|
||||
return sk
|
||||
return sk
|
||||
|
0
src/tests/test_key_derivation/__init__.py
Normal file
0
src/tests/test_key_derivation/__init__.py
Normal file
0
src/utils/__init__.py
Normal file
0
src/utils/__init__.py
Normal file
@ -11,6 +11,7 @@ from Crypto.Cipher import (
|
||||
AES as _AES
|
||||
)
|
||||
|
||||
|
||||
def SHA256(x):
|
||||
return _sha256.new(x).digest()
|
||||
|
||||
|
@ -3,15 +3,6 @@ from ssz import (
|
||||
Serializable,
|
||||
)
|
||||
|
||||
from utils.typing import (
|
||||
BLSPubkey,
|
||||
BLSPrivkey,
|
||||
BLSSignature,
|
||||
Domain,
|
||||
DomainType,
|
||||
Version,
|
||||
Root,
|
||||
)
|
||||
from utils.constants import (
|
||||
DOMAIN_DEPOSIT,
|
||||
GENESIS_FORK_VERSION,
|
||||
@ -25,14 +16,14 @@ class SigningRoot(Serializable):
|
||||
]
|
||||
|
||||
|
||||
def compute_domain(domain_type: DomainType=DomainType(DOMAIN_DEPOSIT), fork_version: Version=GENESIS_FORK_VERSION) -> Domain:
|
||||
def compute_domain(domain_type: bytes=DOMAIN_DEPOSIT, fork_version: bytes=GENESIS_FORK_VERSION) -> bytes:
|
||||
"""
|
||||
Return the domain for the ``domain_type`` and ``fork_version``.
|
||||
"""
|
||||
return Domain(domain_type + fork_version)
|
||||
return domain_type + fork_version
|
||||
|
||||
|
||||
def compute_signing_root(ssz_object, domain: Domain) -> Root:
|
||||
def compute_signing_root(ssz_object: Serializable, domain: bytes) -> bytes:
|
||||
"""
|
||||
Return the signing root of an object by calculating the root of the object-domain tree.
|
||||
"""
|
||||
@ -40,4 +31,4 @@ def compute_signing_root(ssz_object, domain: Domain) -> Root:
|
||||
object_root=ssz_object.get_hash_tree_root(),
|
||||
domain=domain,
|
||||
)
|
||||
return domain_wrapped_object.get_hash_tree_root()
|
||||
return domain_wrapped_object.get_hash_tree_root()
|
||||
|
Loading…
Reference in New Issue
Block a user