Skip to content

Commit

Permalink
more less default root path
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky committed Dec 11, 2024
1 parent 3ab83f0 commit debbbad
Show file tree
Hide file tree
Showing 8 changed files with 380 additions and 125 deletions.
5 changes: 2 additions & 3 deletions chia/cmds/cmd_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,8 @@ async def wallet_rpc(self, **kwargs: Any) -> AsyncIterator[WalletClientInfo]:
if self.client_info is not None:
yield self.client_info
else:
if "root_path" not in kwargs:
kwargs["root_path"] = self.context["root_path"]
async with get_wallet_client(self.wallet_rpc_port, self.fingerprint, **kwargs) as (
root_path = kwargs.get("root_path", self.context["root_path"])
async with get_wallet_client(root_path, self.wallet_rpc_port, self.fingerprint, **kwargs) as (
wallet_client,
fp,
config,
Expand Down
2 changes: 1 addition & 1 deletion chia/cmds/cmds_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ async def get_wallet(root_path: Path, wallet_client: WalletRpcClient, fingerprin

@asynccontextmanager
async def get_wallet_client(
root_path: Path,
wallet_rpc_port: Optional[int] = None,
fingerprint: Optional[int] = None,
root_path: Path = DEFAULT_ROOT_PATH,
consume_errors: bool = True,
) -> AsyncIterator[tuple[WalletRpcClient, int, dict[str, Any]]]:
async with get_any_service_client(WalletRpcClient, wallet_rpc_port, root_path, consume_errors) as (
Expand Down
10 changes: 7 additions & 3 deletions chia/cmds/coin_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import dataclasses
import sys
from collections.abc import Sequence
from pathlib import Path
from typing import Optional

from chia.cmds.cmds_util import CMDCoinSelectionConfigLoader, CMDTXConfigLoader, cli_confirm, get_wallet_client
Expand All @@ -21,6 +22,7 @@

async def async_list(
*,
root_path: Path,
wallet_rpc_port: Optional[int],
fingerprint: Optional[int],
wallet_id: int,
Expand All @@ -31,7 +33,7 @@ async def async_list(
show_unconfirmed: bool,
paginate: Optional[bool],
) -> None:
async with get_wallet_client(wallet_rpc_port, fingerprint) as (wallet_client, _, config):
async with get_wallet_client(root_path, wallet_rpc_port, fingerprint) as (wallet_client, _, config):
addr_prefix = selected_network_address_prefix(config)
if paginate is None:
paginate = sys.stdout.isatty()
Expand Down Expand Up @@ -114,6 +116,7 @@ def print_coins(

async def async_combine(
*,
root_path: Path,
wallet_rpc_port: Optional[int],
fingerprint: Optional[int],
wallet_id: int,
Expand All @@ -131,7 +134,7 @@ async def async_combine(
condition_valid_times: ConditionValidTimes,
override: bool,
) -> list[TransactionRecord]:
async with get_wallet_client(wallet_rpc_port, fingerprint) as (wallet_client, fingerprint, config):
async with get_wallet_client(root_path, wallet_rpc_port, fingerprint) as (wallet_client, fingerprint, config):
try:
wallet_type = await get_wallet_type(wallet_id=wallet_id, wallet_client=wallet_client)
mojo_per_unit = get_mojo_per_unit(wallet_type)
Expand Down Expand Up @@ -194,6 +197,7 @@ async def async_combine(

async def async_split(
*,
root_path: Path,
wallet_rpc_port: Optional[int],
fingerprint: Optional[int],
wallet_id: int,
Expand All @@ -209,7 +213,7 @@ async def async_split(
push: bool,
condition_valid_times: ConditionValidTimes,
) -> list[TransactionRecord]:
async with get_wallet_client(wallet_rpc_port, fingerprint) as (wallet_client, fingerprint, config):
async with get_wallet_client(root_path, wallet_rpc_port, fingerprint) as (wallet_client, fingerprint, config):
try:
wallet_type = await get_wallet_type(wallet_id=wallet_id, wallet_client=wallet_client)
mojo_per_unit = get_mojo_per_unit(wallet_type)
Expand Down
7 changes: 7 additions & 0 deletions chia/cmds/coins.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def list_cmd(

asyncio.run(
async_list(
root_path=ctx.obj["root_path"],
wallet_rpc_port=wallet_rpc_port,
fingerprint=fingerprint,
wallet_id=id,
Expand Down Expand Up @@ -111,7 +112,9 @@ def list_cmd(
)
@click.option("--override", help="Submits transaction without checking for unusual values", is_flag=True, default=False)
@tx_out_cmd()
@click.pass_context
def combine_cmd(
ctx: click.Context,
wallet_rpc_port: Optional[int],
fingerprint: int,
id: int,
Expand All @@ -133,6 +136,7 @@ def combine_cmd(

return asyncio.run(
async_combine(
root_path=ctx.obj["root_path"],
wallet_rpc_port=wallet_rpc_port,
fingerprint=fingerprint,
wallet_id=id,
Expand Down Expand Up @@ -183,7 +187,9 @@ def combine_cmd(
)
@tx_config_args
@tx_out_cmd()
@click.pass_context
def split_cmd(
ctx: click.Context,
wallet_rpc_port: Optional[int],
fingerprint: int,
id: int,
Expand All @@ -203,6 +209,7 @@ def split_cmd(

return asyncio.run(
async_split(
root_path=ctx.obj["root_path"],
wallet_rpc_port=wallet_rpc_port,
fingerprint=fingerprint,
wallet_id=id,
Expand Down
Loading

0 comments on commit debbbad

Please sign in to comment.