Skip to content

Commit

Permalink
Add --verbose option to data create_data_store and limit default …
Browse files Browse the repository at this point in the history
…output to the store id (#16110)

* Cleanup create_data_store.

* Use indent.

* Typo.

* Lint.

* Call tests with verbose.

* add back in fingerprint from cross-merge stuff

---------

Co-authored-by: Earle Lowe <[email protected]>
Co-authored-by: Earle Lowe <[email protected]>
  • Loading branch information
3 people authored Sep 6, 2023
1 parent 8cc32ed commit 9071480
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion chia/cmds/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,17 @@ def create_fee_option() -> Callable[[FC], FC]:
@data_cmd.command("create_data_store", help="Create a new data store")
@create_rpc_port_option()
@create_fee_option()
@click.option("--verbose", is_flag=True, help="Enable verbose output.")
@options.create_fingerprint()
def create_data_store(
data_rpc_port: int,
fee: Optional[str],
verbose: bool,
fingerprint: Optional[int],
) -> None:
from chia.cmds.data_funcs import create_data_store_cmd

run(create_data_store_cmd(data_rpc_port, fee, fingerprint=fingerprint))
run(create_data_store_cmd(data_rpc_port, fee, verbose, fingerprint=fingerprint))


@data_cmd.command("get_value", help="Get the value for a given key and store")
Expand Down
3 changes: 2 additions & 1 deletion chia/cmds/data_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ async def wallet_log_in_cmd(
async def create_data_store_cmd(
rpc_port: Optional[int],
fee: Optional[str],
verbose: bool,
fingerprint: Optional[int],
) -> None:
final_fee = None if fee is None else uint64(int(Decimal(fee) * units["chia"]))
async with get_client(rpc_port=rpc_port, fingerprint=fingerprint) as (client, _):
res = await client.create_data_store(fee=final_fee)
res = await client.create_data_store(fee=final_fee, verbose=verbose)
print(json.dumps(res, indent=4, sort_keys=True))


Expand Down
6 changes: 5 additions & 1 deletion chia/rpc/data_layer_rpc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ async def create_data_store(self, request: Dict[str, Any]) -> EndpointResult:
if self.service is None:
raise Exception("Data layer not created")
fee = get_fee(self.service.config, request)
verbose = request.get("verbose", False)
txs, value = await self.service.create_store(uint64(fee))
return {"txs": txs, "id": value.hex()}
if verbose:
return {"txs": txs, "id": value.hex()}
else:
return {"id": value.hex()}

async def get_owned_stores(self, request: Dict[str, Any]) -> EndpointResult:
if self.service is None:
Expand Down
4 changes: 2 additions & 2 deletions chia/rpc/data_layer_rpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


class DataLayerRpcClient(RpcClient):
async def create_data_store(self, fee: Optional[uint64]) -> Dict[str, Any]:
response = await self.fetch("create_data_store", {"fee": fee})
async def create_data_store(self, fee: Optional[uint64], verbose: bool) -> Dict[str, Any]:
response = await self.fetch("create_data_store", {"fee": fee, "verbose": verbose})
return response

async def wallet_log_in(self, fingerprint: int) -> Dict[str, Any]:
Expand Down
2 changes: 1 addition & 1 deletion tests/core/data_layer/test_data_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ async def offer_setup_fixture(
)
data_rpc_api = DataLayerRpcApi(data_layer)

create_response = await data_rpc_api.create_data_store({})
create_response = await data_rpc_api.create_data_store({"verbose": True})
await full_node_api.process_transaction_records(records=create_response["txs"])

store_setups.append(
Expand Down

0 comments on commit 9071480

Please sign in to comment.