diff --git a/silkaj/blockchain/blocks.py b/silkaj/blockchain/blocks.py index 07092dd82d141694154afed9c41b3d0a4026ee39..e70f9fd5ab0a5b244fd594e5436ba508955e7df8 100644 --- a/silkaj/blockchain/blocks.py +++ b/silkaj/blockchain/blocks.py @@ -23,7 +23,7 @@ from duniterpy.api import bma from pendulum import from_timestamp from silkaj import tui -from silkaj.blockchain_tools import get_head_block +from silkaj.blockchain.tools import get_head_block from silkaj.constants import ALL from silkaj.network_tools import client_instance from silkaj.wot_tools import identity_of diff --git a/silkaj/blockchain/information.py b/silkaj/blockchain/information.py index 6ca4b577897637ec3ac89209d12a8621acf4d7f7..093f060b86f0898e6afd5d8790a5e78a7525b2d7 100644 --- a/silkaj/blockchain/information.py +++ b/silkaj/blockchain/information.py @@ -16,7 +16,7 @@ import click from pendulum import from_timestamp -from silkaj.blockchain_tools import get_head_block +from silkaj.blockchain.tools import get_head_block from silkaj.constants import ALL from silkaj.network_tools import determine_endpoint from silkaj.tools import get_currency_symbol diff --git a/silkaj/blockchain_tools.py b/silkaj/blockchain/tools.py similarity index 100% rename from silkaj/blockchain_tools.py rename to silkaj/blockchain/tools.py diff --git a/silkaj/cert.py b/silkaj/cert.py index 42ac159e0a724d46e47075d1ba48ec10123cd050..614022a8839c8e4c40e5040e543cbd02a8ea3625 100644 --- a/silkaj/cert.py +++ b/silkaj/cert.py @@ -26,7 +26,7 @@ from pendulum import from_timestamp, now from silkaj import tui, wot from silkaj import wot_tools as wt from silkaj.auth import auth_method -from silkaj.blockchain_tools import get_blockchain_parameters, get_head_block +from silkaj.blockchain import tools as bc_tools from silkaj.constants import ALL, DATE from silkaj.crypto_tools import is_pubkey_and_check from silkaj.g1_monetary_license import license_approval @@ -55,7 +55,7 @@ def send_certification(ctx: click.Context, uid_pubkey_to_certify: str) -> None: issuer = pre_checks(client, issuer_pubkey, pubkey_to_certify) # Display license and ask for confirmation - head = get_head_block() + head = bc_tools.get_head_block() currency = head["currency"] license_approval(currency) @@ -92,7 +92,7 @@ def pre_checks(client: Client, issuer_pubkey: str, pubkey_to_certify: str) -> Di sys.exit("You can’t certify yourself!") # Check if the certification can be renewed - params = get_blockchain_parameters() + params = bc_tools.get_blockchain_parameters() requirements = client(bma.wot.requirements, pubkey_to_certify) req = requirements["identities"][0] # type: Dict for cert in req["certifications"]: @@ -134,7 +134,7 @@ def certification_confirmation( tui.gen_pubkey_checksum(pubkey_to_certify), ] ) - params = get_blockchain_parameters() + params = bc_tools.get_blockchain_parameters() cert_ends = now().add(seconds=params["sigValidity"]).format(DATE) cert.append(["Valid", now().format(DATE), "—>", cert_ends]) diff --git a/silkaj/membership.py b/silkaj/membership.py index 27db510aacc7293af471c49495a7927288fe6aa7..50882a2cc5c29ed0df8ecaada1ef2218bc16bff8 100644 --- a/silkaj/membership.py +++ b/silkaj/membership.py @@ -23,7 +23,7 @@ from duniterpy.documents import BlockID, Membership, get_block_id from duniterpy.key import SigningKey from silkaj import auth, tui, wot -from silkaj.blockchain_tools import get_blockchain_parameters, get_head_block +from silkaj.blockchain import tools as bc_tools from silkaj.constants import DATE, SUCCESS_EXIT_STATUS from silkaj.g1_monetary_license import license_approval from silkaj.network_tools import client_instance, send_document @@ -42,7 +42,7 @@ def send_membership(ctx: click.Context) -> None: key = auth.auth_method() # Get the identity information - head_block = get_head_block() + head_block = bc_tools.get_head_block() membership_block_id = BlockID(head_block["number"], head_block["hash"]) identity = (wot.choose_identity(key.pubkey))[0] identity_uid = identity["uid"] @@ -136,7 +136,7 @@ def display_confirmation_table( ] ) - params = get_blockchain_parameters() + params = bc_tools.get_blockchain_parameters() table.append( [ "Expiration date of new membership", diff --git a/silkaj/money.py b/silkaj/money.py index 1d10fc1a4ecf6d88fe6721645db856d0ec7b5581..0237de0852404f88318a53e7b8c48e6b28446104 100644 --- a/silkaj/money.py +++ b/silkaj/money.py @@ -24,7 +24,7 @@ from duniterpy.documents.transaction import InputSource, OutputSource from silkaj import tui from silkaj import wot_tools as wt from silkaj.auth import auth_method, has_auth_method -from silkaj.blockchain_tools import get_head_block +from silkaj.blockchain.tools import get_head_block from silkaj.crypto_tools import is_pubkey_and_check from silkaj.network_tools import client_instance from silkaj.tools import get_currency_symbol diff --git a/silkaj/revocation.py b/silkaj/revocation.py index f7cb09691be05c3ba4f8f3e7dc6a55c2e2a0bc09..f0a0ae2f34c36595579153c5ff872b39bb4e67e8 100644 --- a/silkaj/revocation.py +++ b/silkaj/revocation.py @@ -27,7 +27,7 @@ from duniterpy.documents.revocation import Revocation from duniterpy.key.verifying_key import VerifyingKey from silkaj import auth, idty_tools, tui, wot -from silkaj.blockchain_tools import get_currency +from silkaj.blockchain.tools import get_currency from silkaj.constants import FAILURE_EXIT_STATUS, SUCCESS_EXIT_STATUS from silkaj.network_tools import send_document diff --git a/silkaj/tools.py b/silkaj/tools.py index 70e8f85f07d2f8880d4e17bbb198664d2dba8bfc..99b31f2f34a3a65a550c1ba6d33e0129f0660bde 100644 --- a/silkaj/tools.py +++ b/silkaj/tools.py @@ -16,7 +16,7 @@ import functools import sys -from silkaj.blockchain_tools import get_blockchain_parameters +from silkaj.blockchain.tools import get_blockchain_parameters from silkaj.constants import FAILURE_EXIT_STATUS, G1_SYMBOL, GTEST_SYMBOL diff --git a/silkaj/tx.py b/silkaj/tx.py index b731776b75d2e60c9ac003e24f8cf73dd926c9bc..9c791461016c99d31e17756e32bdfaa318f3a4ea 100644 --- a/silkaj/tx.py +++ b/silkaj/tx.py @@ -31,13 +31,12 @@ from duniterpy.documents import ( ) from duniterpy.key import SigningKey -from silkaj import auth -from silkaj import blockchain_tools as bt -from silkaj import cli_tools +from silkaj import auth, cli_tools from silkaj import crypto_tools as ct from silkaj import money from silkaj import network_tools as nt from silkaj import tools, tui +from silkaj.blockchain import tools as bc_tools from silkaj.constants import ( CENT_MULT_TO_UNIT, MINIMAL_ABSOLUTE_TX_AMOUNT, @@ -508,7 +507,7 @@ def generate_transaction_document( totalAmountInput = listinput_and_amount[1] total_tx_amount = sum(tx_amounts) - head_block = bt.get_head_block() + head_block = bc_tools.get_head_block() if not OutputbackChange: OutputbackChange = issuers diff --git a/silkaj/wot.py b/silkaj/wot.py index afedd551166c4285c212b85523c949ae17817e7f..240692308a7bdcc59da648a590ec99d8711dd057 100644 --- a/silkaj/wot.py +++ b/silkaj/wot.py @@ -22,7 +22,7 @@ from duniterpy.api.bma import blockchain, wot from pendulum import from_timestamp, now from silkaj import wot_tools as wt -from silkaj.blockchain_tools import get_blockchain_parameters +from silkaj.blockchain.tools import get_blockchain_parameters from silkaj.constants import DATE from silkaj.crypto_tools import is_pubkey_and_check from silkaj.network_tools import client_instance, exit_on_http_error diff --git a/tests/test_membership.py b/tests/test_membership.py index 7cb0df38a61a4f6d7fedbf3b7c239ef32eebf200..4b287e5aa50bdd396515ee577f1b7e674c85a64d 100644 --- a/tests/test_membership.py +++ b/tests/test_membership.py @@ -33,8 +33,8 @@ from patched.wot import ( patched_wot_requirements_no_pending, patched_wot_requirements_one_pending, ) -from silkaj import auth, blockchain_tools, membership, tui, wot -from silkaj.blockchain_tools import get_blockchain_parameters +from silkaj import auth, membership, tui, wot +from silkaj.blockchain import tools as bc_tools from silkaj.cli import cli from silkaj.constants import DATE from silkaj.network_tools import client_instance @@ -73,7 +73,7 @@ def patched_choose_identity(pubkey): def test_membership_cmd(dry_run, display, confirmation, monkeypatch): # Monkeypatch and Mock monkeypatch.setattr(auth, "auth_method", patched_auth_method) - monkeypatch.setattr(blockchain_tools, "get_head_block", patched_get_head_block) + monkeypatch.setattr(bc_tools, "get_head_block", patched_get_head_block) monkeypatch.setattr(wot, "choose_identity", patched_choose_identity) patched_display_confirmation_table = Mock() @@ -177,7 +177,7 @@ def test_display_confirmation_table(patched_wot_requirements, monkeypatch, capsy ], ) - params = get_blockchain_parameters() + params = bc_tools.get_blockchain_parameters() table.append( [ "Expiration date of new membership", diff --git a/tests/test_revocation.py b/tests/test_revocation.py index d81085111f7f0e427c4d07a05b2508ebf2c8bfb4..10e7a86599b3d05bca94b4fec177740c2da1f1ff 100644 --- a/tests/test_revocation.py +++ b/tests/test_revocation.py @@ -27,7 +27,8 @@ from duniterpy.documents.revocation import Revocation from patched.auth import patched_auth_method from patched.blockchain_tools import patched_get_head_block_gtest from patched.idty_tools import idty1, idty2, idty_block, lookup_one, lookup_two -from silkaj import auth, blockchain_tools, idty_tools, revocation, wot +from silkaj import auth, idty_tools, revocation, wot +from silkaj.blockchain import tools as bc_tools from silkaj.cli import cli from silkaj.constants import FAILURE_EXIT_STATUS, SUCCESS_EXIT_STATUS from silkaj.network_tools import client_instance @@ -163,9 +164,7 @@ def test_revocation_cli_dry_run(subcommand, expected_warn, monkeypatch): Tests dry-run option behavior when associated with other options """ monkeypatch.setattr(auth, "auth_method", patched_auth_method_Claude) - monkeypatch.setattr( - blockchain_tools, "get_head_block", patched_get_head_block_gtest - ) + monkeypatch.setattr(bc_tools, "get_head_block", patched_get_head_block_gtest) monkeypatch.setattr(wot, "choose_identity", patched_choose_identity) monkeypatch.setattr(bma.blockchain, "block", patch_get_id_block) monkeypatch.setattr( @@ -286,9 +285,7 @@ def test_revocation_cli_dry_run(subcommand, expected_warn, monkeypatch): ) def test_revocation_cli_save(display, dry_run, file, user_input, expected, monkeypatch): monkeypatch.setattr(auth, "auth_method", patched_auth_method_Claude) - monkeypatch.setattr( - blockchain_tools, "get_head_block", patched_get_head_block_gtest - ) + monkeypatch.setattr(bc_tools, "get_head_block", patched_get_head_block_gtest) monkeypatch.setattr(wot, "choose_identity", patched_choose_identity) monkeypatch.setattr(bma.blockchain, "block", patch_get_id_block) patched_save_doc = Mock() @@ -412,9 +409,7 @@ def test_revocation_cli_verify( monkeypatch.setattr(bma.wot, "lookup", patched_lookup) monkeypatch.setattr(bma.blockchain, "block", patch_get_id_block) - monkeypatch.setattr( - blockchain_tools, "get_head_block", patched_get_head_block_gtest - ) + monkeypatch.setattr(bc_tools, "get_head_block", patched_get_head_block_gtest) # prepare command command = display_dry_options(display, dry_run) @@ -676,9 +671,7 @@ def test_revocation_cli_publish( return lookup monkeypatch.setattr(bma.wot, "lookup", patched_lookup) - monkeypatch.setattr( - blockchain_tools, "get_head_block", patched_get_head_block_gtest - ) + monkeypatch.setattr(bc_tools, "get_head_block", patched_get_head_block_gtest) monkeypatch.setattr(bma.blockchain, "block", patch_get_id_block) patched_send_bma_revoke = Mock() @@ -763,9 +756,7 @@ def test_revocation_cli_publish_send_errors( return lookup_one monkeypatch.setattr(bma.wot, "lookup", patched_lookup) - monkeypatch.setattr( - blockchain_tools, "get_head_block", patched_get_head_block_gtest - ) + monkeypatch.setattr(bc_tools, "get_head_block", patched_get_head_block_gtest) monkeypatch.setattr(bma.blockchain, "block", patch_get_id_block) monkeypatch.setattr(bma.wot, "revoke", patched_send_bma_revoke_error) @@ -851,9 +842,7 @@ def test_revocation_cli_revoke( display, dry_run, user_input, doc, expected, monkeypatch ): monkeypatch.setattr(auth, "auth_method", patched_auth_method_Claude) - monkeypatch.setattr( - blockchain_tools, "get_head_block", patched_get_head_block_gtest - ) + monkeypatch.setattr(bc_tools, "get_head_block", patched_get_head_block_gtest) monkeypatch.setattr(wot, "choose_identity", patched_choose_identity) monkeypatch.setattr(bma.blockchain, "block", patch_get_id_block) patched_send_bma_revoke = Mock() @@ -902,9 +891,7 @@ def test_revocation_cli_revoke( def test_revocation_cli_revoke_errors(display, user_input, doc, expected, monkeypatch): monkeypatch.setattr(auth, "auth_method", patched_auth_method_Claude) - monkeypatch.setattr( - blockchain_tools, "get_head_block", patched_get_head_block_gtest - ) + monkeypatch.setattr(bc_tools, "get_head_block", patched_get_head_block_gtest) monkeypatch.setattr(wot, "choose_identity", patched_choose_identity) monkeypatch.setattr(bma.blockchain, "block", patch_get_id_block) monkeypatch.setattr(bma.wot, "revoke", patched_send_bma_revoke_error) diff --git a/tests/test_unit_tx.py b/tests/test_unit_tx.py index 47814aca0a9c8bfdf671b25feed6bacb7cb5b58c..30bafcd0b392e1de408de7c48e292c5f93d9569f 100644 --- a/tests/test_unit_tx.py +++ b/tests/test_unit_tx.py @@ -32,7 +32,8 @@ from patched.money import Counter, patched_get_sources, patched_get_ud_value from patched.test_constants import mock_ud_value from patched.tools import patched_get_currency_symbol from patched.wot import patched_is_member -from silkaj import auth, blockchain_tools, money, network_tools, tools, tx, wot_tools +from silkaj import auth, money, network_tools, tools, tx, wot_tools +from silkaj.blockchain import tools as bc_tools from silkaj.cli import cli from silkaj.constants import CENT_MULT_TO_UNIT, G1_SYMBOL from silkaj.tui import display_amount, display_pubkey @@ -294,7 +295,7 @@ def test_generate_transaction_document( monkeypatch, ): # patch Head_block - monkeypatch.setattr(blockchain_tools, "get_head_block", patched_get_head_block) + monkeypatch.setattr(bc_tools, "get_head_block", patched_get_head_block) assert result == tx.generate_transaction_document( issuers, @@ -1218,7 +1219,7 @@ def test_generate_and_send_transaction( network_tools.send_document = Mock() # patched functions - monkeypatch.setattr(blockchain_tools, "get_head_block", patched_get_head_block) + monkeypatch.setattr(bc_tools, "get_head_block", patched_get_head_block) # monkeypatch.setattr(network_tools, "client_instance", patched_client_instance) tx.generate_and_send_transaction(