diff --git a/silkaj/commands.py b/silkaj/commands.py index e7b7e0f08f788afa648d54e255cae0389080b697..1c050d57d7d08f3cd0e4e48f8a434a193b957ea5 100644 --- a/silkaj/commands.py +++ b/silkaj/commands.py @@ -27,7 +27,7 @@ from websocket._exceptions import WebSocketConnectionClosedException from silkaj.blockchain_tools import HeadBlock from silkaj.constants import ALL, HOUR from silkaj.network_tools import ClientInstance, determine_endpoint -from silkaj.tools import CurrencySymbol +from silkaj.tools import get_currency_symbol from silkaj.wot_tools import identity_of @@ -44,7 +44,7 @@ def currency_info(): "\nCurrent block number:", head_block["number"], "\nCurrency name:", - CurrencySymbol().symbol, + get_currency_symbol(), "\nNumber of members:", head_block["membersCount"], "\nMinimal Proof-of-Work:", @@ -197,7 +197,7 @@ def list_blocks(number, detailed): @command("argos", help="Display currency information formatted for Argos or BitBar") def argos_info(): head_block = HeadBlock().head_block - currency_symbol = CurrencySymbol().symbol + currency_symbol = get_currency_symbol() print(currency_symbol, "|") print("---") ep = determine_endpoint() diff --git a/silkaj/money.py b/silkaj/money.py index 9baa33d22ed420f56baa353cc9d8c52104f74a16..ddc566ee517d16cb86eaa9054e021ed42077e569 100644 --- a/silkaj/money.py +++ b/silkaj/money.py @@ -29,7 +29,7 @@ from silkaj.crypto_tools import ( validate_checksum, ) from silkaj.network_tools import ClientInstance -from silkaj.tools import CurrencySymbol +from silkaj.tools import get_currency_symbol from silkaj.tui import display_amount, display_pubkey_and_checksum @@ -78,7 +78,7 @@ def show_amount_from_pubkey(label, inputs_balance): """ totalAmountInput = inputs_balance[0] balance = inputs_balance[1] - currency_symbol = CurrencySymbol().symbol + currency_symbol = get_currency_symbol() ud_value = UDValue().ud_value average, monetary_mass = get_average() member = False diff --git a/silkaj/tools.py b/silkaj/tools.py index d3cf793adb2fb4cfbcf30ffc83f2265deccdd8eb..d0a366910b0bf30e2745857fb236a097090c3e06 100644 --- a/silkaj/tools.py +++ b/silkaj/tools.py @@ -21,24 +21,13 @@ from silkaj.constants import FAILURE_EXIT_STATUS, G1_SYMBOL, GTEST_SYMBOL from silkaj.network_tools import ClientInstance -class CurrencySymbol: - __instance = None - - def __new__(cls): - if CurrencySymbol.__instance is None: - CurrencySymbol.__instance = object.__new__(cls) - return CurrencySymbol.__instance - - def __init__(self): - self.symbol = self.get_symbol() - - def get_symbol(self): - client = ClientInstance().client - params = client(blockchain.parameters) - if params["currency"] == "g1": - return G1_SYMBOL - elif params["currency"] == "g1-test": - return GTEST_SYMBOL +def get_currency_symbol(): + client = ClientInstance().client + params = client(blockchain.parameters) + if params["currency"] == "g1": + return G1_SYMBOL + elif params["currency"] == "g1-test": + return GTEST_SYMBOL def message_exit(message): diff --git a/silkaj/tx.py b/silkaj/tx.py index 65702fa8079cd2835b33f1f6976797565e7f631f..62c4d584f26cc95b31cd0f405066ce710ffac506 100644 --- a/silkaj/tx.py +++ b/silkaj/tx.py @@ -312,7 +312,7 @@ def gen_confirmation_table( Generate transaction confirmation """ - currency_symbol = tools.CurrencySymbol().symbol + currency_symbol = tools.get_currency_symbol() ud_value = money.UDValue().ud_value total_tx_amount = sum(tx_amounts) tx = list() diff --git a/silkaj/tx_history.py b/silkaj/tx_history.py index d84130dbfb4a586fa5ef97a76ce82d49b867b462..a8bdcd587c4e59d6be9a7e9a8d7c6e75ad712d2f 100644 --- a/silkaj/tx_history.py +++ b/silkaj/tx_history.py @@ -28,7 +28,7 @@ from silkaj.constants import ALL, ALL_DIGITAL from silkaj.crypto_tools import check_pubkey_format, validate_checksum from silkaj.money import UDValue, amount_in_current_base, get_amount_from_pubkey from silkaj.network_tools import ClientInstance -from silkaj.tools import CurrencySymbol +from silkaj.tools import get_currency_symbol from silkaj.tui import display_pubkey_and_checksum @@ -42,7 +42,7 @@ def transaction_history(pubkey, uids, full_pubkey): client = ClientInstance().client ud_value = UDValue().ud_value - currency_symbol = CurrencySymbol().symbol + currency_symbol = get_urrency_symbol() header = generate_header(pubkey, currency_symbol, ud_value) received_txs, sent_txs = list(), list() diff --git a/tests/patched/tools.py b/tests/patched/tools.py index dba0c6e90640724cdb7ad3b94d9f9ccd8ed8a40b..c37e13ff842bd0637647388eb9916862bd7c2f5a 100644 --- a/tests/patched/tools.py +++ b/tests/patched/tools.py @@ -16,6 +16,6 @@ from silkaj.constants import G1_SYMBOL -# mock CurrencySymbol().symbol -def patched_currency_symbol(self): +# mock get_currency_symbol().symbol +def patched_get_currency_symbol(): return G1_SYMBOL diff --git a/tests/test_unit_tx.py b/tests/test_unit_tx.py index abd83674e6e1b4c30c09138815a809873ca9be51..6a05d12ce9906314e25d10a01bc7d50333f9d397 100644 --- a/tests/test_unit_tx.py +++ b/tests/test_unit_tx.py @@ -30,7 +30,7 @@ from patched.auth import patched_auth_method from patched.blockchain_tools import fake_block_id, patched_head_block from patched.money import patched_get_sources, patched_ud_value from patched.test_constants import mock_ud_value -from patched.tools import patched_currency_symbol +from patched.tools import patched_get_currency_symbol from patched.tx import ( patched_gen_confirmation_table, patched_handle_intermediaries_transactions, @@ -124,7 +124,7 @@ def test_gen_confirmation_table( # patched functions monkeypatch.setattr(wot_tools, "is_member", patched_is_member) monkeypatch.setattr(money.UDValue, "get_ud_value", patched_ud_value) - monkeypatch.setattr(tools.CurrencySymbol, "get_symbol", patched_currency_symbol) + monkeypatch.setattr(tools, "get_currency_symbol", patched_get_currency_symbol) # creating expected list expected = list()