Skip to content

Commit

Permalink
more comments by @altendky
Browse files Browse the repository at this point in the history
  • Loading branch information
Quexington committed Dec 12, 2024
1 parent 2634e56 commit 5b81208
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions chia/_tests/cmds/test_cmd_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions chia/cmds/cmd_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,20 +408,20 @@ 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]]:
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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 5b81208

Please sign in to comment.