diff --git a/chia/_tests/cmds/test_cmd_framework.py b/chia/_tests/cmds/test_cmd_framework.py index 1a85d26c89e4..cd09bf983c00 100644 --- a/chia/_tests/cmds/test_cmd_framework.py +++ b/chia/_tests/cmds/test_cmd_framework.py @@ -13,7 +13,7 @@ from chia._tests.environments.wallet import STANDARD_TX_ENDPOINT_ARGS, WalletTestFramework from chia._tests.wallet.conftest import * # noqa from chia.cmds.cmd_classes import ( - _DECORATOR_APPLIED, + _TRANSACTION_ENDPOINT_DECORATOR_APPLIED, ChiaCommand, Context, NeedsCoinSelectionConfig, @@ -55,7 +55,7 @@ def new_run(self: Any) -> None: dict_compare_with_ignore_context(asdict(cmd), asdict(self)) # type: ignore[call-overload] # We hack this in because more robust solutions are harder and probably not worth it - setattr(new_run, _DECORATOR_APPLIED, True) + setattr(new_run, _TRANSACTION_ENDPOINT_DECORATOR_APPLIED, True) setattr(mock_type, "run", new_run) chia_command(_cmd, "_", "", "")(mock_type) diff --git a/chia/cmds/cmd_classes.py b/chia/cmds/cmd_classes.py index 5a691d1bc3b9..3e8585689e67 100644 --- a/chia/cmds/cmd_classes.py +++ b/chia/cmds/cmd_classes.py @@ -408,9 +408,6 @@ def load_tx_config(self, mojo_per_unit: int, config: dict[str, Any], fingerprint ).to_tx_config(mojo_per_unit, config, fingerprint) -_DECORATOR_APPLIED = "_DECORATOR_APPLIED" - - def transaction_endpoint_runner( func: Callable[[_T_TransactionEndpoint], Coroutine[Any, Any, list[TransactionRecord]]], ) -> Callable[[_T_TransactionEndpoint], Coroutine[Any, Any, None]]: @@ -418,10 +415,13 @@ async def wrapped_func(self: _T_TransactionEndpoint) -> None: txs = await func(self) self.transaction_writer.handle_transaction_output(txs) - setattr(wrapped_func, _DECORATOR_APPLIED, True) + setattr(wrapped_func, _TRANSACTION_ENDPOINT_DECORATOR_APPLIED, True) return wrapped_func +_TRANSACTION_ENDPOINT_DECORATOR_APPLIED = f"_{__name__.split('.')}_{transaction_endpoint_runner.__qualname__}_applied" + + @dataclass(frozen=True) class TransactionEndpoint: rpc_info: NeedsWalletRPC @@ -457,7 +457,7 @@ class TransactionEndpoint: ) def __post_init__(self) -> None: - if not hasattr(self.run, "_DECORATOR_APPLIED"): + if not hasattr(self.run, _TRANSACTION_ENDPOINT_DECORATOR_APPLIED): raise TypeError("TransactionEndpoints must utilize @transaction_endpoint_runner on their `run` method") def load_condition_valid_times(self) -> ConditionValidTimes: