diff --git a/chia/cmds/dao_funcs.py b/chia/cmds/dao_funcs.py index c86620ebcdf0..06210ff77775 100644 --- a/chia/cmds/dao_funcs.py +++ b/chia/cmds/dao_funcs.py @@ -160,7 +160,7 @@ async def add_funds_to_treasury(args: Dict[str, Any], wallet_rpc_port: Optional[ start = time.time() while time.time() - start < 10: await asyncio.sleep(0.1) - tx = await wallet_client.get_transaction(wallet_id, bytes32.from_hexstr(tx_id)) + tx = await wallet_client.get_transaction(bytes32.from_hexstr(tx_id)) if len(tx.sent_to) > 0: print(transaction_submitted_msg(tx)) print(transaction_status_msg(fingerprint, tx_id[2:])) @@ -313,7 +313,7 @@ async def vote_on_proposal(args: Dict[str, Any], wallet_rpc_port: Optional[int], start = time.time() while time.time() - start < 10: await asyncio.sleep(0.1) - tx = await wallet_client.get_transaction(wallet_id, bytes32.from_hexstr(tx_id)) + tx = await wallet_client.get_transaction(bytes32.from_hexstr(tx_id)) if len(tx.sent_to) > 0: print(transaction_submitted_msg(tx)) print(transaction_status_msg(fingerprint, tx_id[2:])) @@ -348,7 +348,7 @@ async def close_proposal(args: Dict[str, Any], wallet_rpc_port: Optional[int], f start = time.time() while time.time() - start < 10: await asyncio.sleep(0.1) - tx = await wallet_client.get_transaction(wallet_id, bytes32.from_hexstr(tx_id)) + tx = await wallet_client.get_transaction(bytes32.from_hexstr(tx_id)) if len(tx.sent_to) > 0: print(transaction_submitted_msg(tx)) print(transaction_status_msg(fingerprint, tx_id[2:])) @@ -382,7 +382,7 @@ async def lockup_coins(args: Dict[str, Any], wallet_rpc_port: Optional[int], fp: start = time.time() while time.time() - start < 10: await asyncio.sleep(0.1) - tx = await wallet_client.get_transaction(wallet_id, bytes32.from_hexstr(tx_id)) + tx = await wallet_client.get_transaction(bytes32.from_hexstr(tx_id)) if len(tx.sent_to) > 0: print(transaction_submitted_msg(tx)) print(transaction_status_msg(fingerprint, tx_id[2:])) @@ -413,7 +413,7 @@ async def release_coins(args: Dict[str, Any], wallet_rpc_port: Optional[int], fp start = time.time() while time.time() - start < 10: await asyncio.sleep(0.1) - tx = await wallet_client.get_transaction(wallet_id, bytes32.from_hexstr(tx_id)) + tx = await wallet_client.get_transaction(bytes32.from_hexstr(tx_id)) if len(tx.sent_to) > 0: print(transaction_submitted_msg(tx)) print(transaction_status_msg(fingerprint, tx_id[2:])) @@ -444,7 +444,7 @@ async def exit_lockup(args: Dict[str, Any], wallet_rpc_port: Optional[int], fp: start = time.time() while time.time() - start < 10: await asyncio.sleep(0.1) - tx = await wallet_client.get_transaction(wallet_id, bytes32.from_hexstr(tx_id)) + tx = await wallet_client.get_transaction(bytes32.from_hexstr(tx_id)) if len(tx.sent_to) > 0: print(transaction_submitted_msg(tx)) print(transaction_status_msg(fingerprint, tx_id[2:])) diff --git a/chia/cmds/plotnft_funcs.py b/chia/cmds/plotnft_funcs.py index 75c673528a38..7c7ef7788cb1 100644 --- a/chia/cmds/plotnft_funcs.py +++ b/chia/cmds/plotnft_funcs.py @@ -106,7 +106,7 @@ async def create( start = time.time() while time.time() - start < 10: await asyncio.sleep(0.1) - tx = await wallet_client.get_transaction(1, tx_record.name) + tx = await wallet_client.get_transaction(tx_record.name) if len(tx.sent_to) > 0: print(transaction_submitted_msg(tx)) print(transaction_status_msg(fingerprint, tx_record.name)) @@ -272,7 +272,7 @@ async def submit_tx_with_confirmation( start = time.time() while time.time() - start < 10: await asyncio.sleep(0.1) - tx = await wallet_client.get_transaction(1, tx_record.name) + tx = await wallet_client.get_transaction(tx_record.name) if len(tx.sent_to) > 0: print(transaction_submitted_msg(tx)) print(transaction_status_msg(fingerprint, tx_record.name)) diff --git a/chia/cmds/wallet_funcs.py b/chia/cmds/wallet_funcs.py index 1ff94f5bca79..918cf4a6922d 100644 --- a/chia/cmds/wallet_funcs.py +++ b/chia/cmds/wallet_funcs.py @@ -149,9 +149,7 @@ async def get_transaction( async with get_wallet_client(wallet_rpc_port, fingerprint) as (wallet_client, fingerprint, config): transaction_id = bytes32.from_hexstr(tx_id) address_prefix = selected_network_address_prefix(config) - # The wallet id parameter is required by the client but unused by the RPC. - this_is_unused = 37 - tx: TransactionRecord = await wallet_client.get_transaction(this_is_unused, transaction_id=transaction_id) + tx: TransactionRecord = await wallet_client.get_transaction(transaction_id=transaction_id) try: wallet_type = await get_wallet_type(wallet_id=tx.wallet_id, wallet_client=wallet_client) @@ -345,7 +343,7 @@ async def send( start = time.time() while time.time() - start < 10: await asyncio.sleep(0.1) - tx = await wallet_client.get_transaction(wallet_id, tx_id) + tx = await wallet_client.get_transaction(tx_id) if len(tx.sent_to) > 0: print(transaction_submitted_msg(tx)) print(transaction_status_msg(fingerprint, tx_id)) diff --git a/chia/rpc/wallet_rpc_client.py b/chia/rpc/wallet_rpc_client.py index 4e30c23ca130..313515b07438 100644 --- a/chia/rpc/wallet_rpc_client.py +++ b/chia/rpc/wallet_rpc_client.py @@ -143,8 +143,8 @@ async def get_wallet_balances(self, wallet_ids: Optional[List[int]] = None) -> D # TODO: casting due to lack of type checked deserialization return cast(Dict[str, Dict[str, Any]], response["wallet_balances"]) - async def get_transaction(self, wallet_id: int, transaction_id: bytes32) -> TransactionRecord: - request = {"walled_id": wallet_id, "transaction_id": transaction_id.hex()} + async def get_transaction(self, transaction_id: bytes32) -> TransactionRecord: + request = {"transaction_id": transaction_id.hex()} response = await self.fetch("get_transaction", request) return TransactionRecord.from_json_dict_convenience(response["transaction"]) diff --git a/tests/cmds/cmd_test_utils.py b/tests/cmds/cmd_test_utils.py index 0f1ed67c6440..f935f6534042 100644 --- a/tests/cmds/cmd_test_utils.py +++ b/tests/cmds/cmd_test_utils.py @@ -107,8 +107,8 @@ async def get_wallets(self, wallet_type: Optional[WalletType] = None) -> List[Di raise ValueError(f"Invalid fingerprint: {self.fingerprint}") return [{"id": 1, "type": w_type}] - async def get_transaction(self, wallet_id: int, transaction_id: bytes32) -> TransactionRecord: - self.add_to_log("get_transaction", (wallet_id, transaction_id)) + async def get_transaction(self, transaction_id: bytes32) -> TransactionRecord: + self.add_to_log("get_transaction", (transaction_id,)) return TransactionRecord( confirmed_at_height=uint32(1), created_at_time=uint64(1234), diff --git a/tests/cmds/wallet/test_dao.py b/tests/cmds/wallet/test_dao.py index 4b2a5e6546c1..df2a27840efd 100644 --- a/tests/cmds/wallet/test_dao.py +++ b/tests/cmds/wallet/test_dao.py @@ -6,6 +6,7 @@ from typing import Any, Dict, List, Optional, Tuple, Union import pytest +from typing_extensions import override from chia.types.blockchain_format.sized_bytes import bytes32 from chia.util.bech32m import encode_puzzle_hash @@ -134,7 +135,8 @@ async def dao_get_rules( ) -> Dict[str, Dict[str, int]]: return {"rules": {"proposal_minimum": 100}} - async def get_transaction(self, wallet_id: int, transaction_id: bytes32) -> TransactionRecord: + @override + async def get_transaction(self, transaction_id: bytes32) -> TransactionRecord: return TransactionRecord( confirmed_at_height=uint32(0), created_at_time=uint64(int(time.time())), @@ -296,7 +298,8 @@ async def dao_create_proposal( async def get_wallets(self, wallet_type: Optional[WalletType] = None) -> List[Dict[str, Union[str, int]]]: return [{"id": 1, "type": 0}, {"id": 2, "type": 14}] - async def get_transaction(self, wallet_id: int, transaction_id: bytes32) -> TransactionRecord: + @override + async def get_transaction(self, transaction_id: bytes32) -> TransactionRecord: return TransactionRecord( confirmed_at_height=uint32(0), created_at_time=uint64(int(time.time())), @@ -494,7 +497,8 @@ async def dao_exit_lockup( ) -> Dict[str, Union[str, int]]: return {"success": True, "tx_id": bytes32(b"x" * 32).hex()} - async def get_transaction(self, wallet_id: int, transaction_id: bytes32) -> TransactionRecord: + @override + async def get_transaction(self, transaction_id: bytes32) -> TransactionRecord: return TransactionRecord( confirmed_at_height=uint32(0), created_at_time=uint64(int(time.time())), diff --git a/tests/cmds/wallet/test_wallet.py b/tests/cmds/wallet/test_wallet.py index 0e497328c6d0..57e558088054 100644 --- a/tests/cmds/wallet/test_wallet.py +++ b/tests/cmds/wallet/test_wallet.py @@ -75,9 +75,9 @@ def test_get_transaction(capsys: object, get_test_cli_clients: Tuple[TestRpcClie "get_wallets": [(None,), (None,), (None,)], "get_cat_name": [(1,)], "get_transaction": [ - (37, bytes32.from_hexstr(bytes32_hexstr)), - (37, bytes32.from_hexstr(bytes32_hexstr)), - (37, bytes32.from_hexstr(bytes32_hexstr)), + (bytes32.from_hexstr(bytes32_hexstr),), + (bytes32.from_hexstr(bytes32_hexstr),), + (bytes32.from_hexstr(bytes32_hexstr),), ], } test_rpc_clients.wallet_rpc_client.check_log(expected_calls) @@ -432,7 +432,7 @@ async def cat_spend( None, ) ], - "get_transaction": [(1, get_bytes32(2)), (1, get_bytes32(2))], + "get_transaction": [(get_bytes32(2),), (get_bytes32(2),)], } test_rpc_clients.wallet_rpc_client.check_log(expected_calls) diff --git a/tests/core/data_layer/test_data_rpc.py b/tests/core/data_layer/test_data_rpc.py index 49d6816fdb5f..71d12d822532 100644 --- a/tests/core/data_layer/test_data_rpc.py +++ b/tests/core/data_layer/test_data_rpc.py @@ -142,9 +142,9 @@ async def farm_block_check_singleton( await full_node_api.wait_for_wallet_synced(wallet_node=wallet, timeout=10) -async def is_transaction_confirmed(user_wallet_id: uint32, api: WalletRpcApi, tx_id: bytes32) -> bool: +async def is_transaction_confirmed(api: WalletRpcApi, tx_id: bytes32) -> bool: try: - val = await api.get_transaction({"wallet_id": user_wallet_id, "transaction_id": tx_id.hex()}) + val = await api.get_transaction({"transaction_id": tx_id.hex()}) except ValueError: # pragma: no cover return False @@ -156,7 +156,7 @@ async def farm_block_with_spend( ) -> None: await time_out_assert(10, check_mempool_spend_count, True, full_node_api, 1) await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(ph)) - await time_out_assert(10, is_transaction_confirmed, True, "this is unused", wallet_rpc_api, tx_rec) + await time_out_assert(10, is_transaction_confirmed, True, wallet_rpc_api, tx_rec) def check_mempool_spend_count(full_node_api: FullNodeSimulator, num_of_spends: int) -> bool: diff --git a/tests/wallet/rpc/test_wallet_rpc.py b/tests/wallet/rpc/test_wallet_rpc.py index febdc934cf8d..c25863642e62 100644 --- a/tests/wallet/rpc/test_wallet_rpc.py +++ b/tests/wallet/rpc/test_wallet_rpc.py @@ -265,7 +265,7 @@ async def assert_get_balance(rpc_client: WalletRpcClient, wallet_node: WalletNod async def tx_in_mempool(client: WalletRpcClient, transaction_id: bytes32): - tx = await client.get_transaction(1, transaction_id) + tx = await client.get_transaction(transaction_id) return tx.is_in_mempool() @@ -324,7 +324,7 @@ async def test_send_transaction(wallet_rpc_environment: WalletRpcTestEnvironment await farm_transaction(full_node_api, wallet_node, spend_bundle) # Checks that the memo can be retrieved - tx_confirmed = await client.get_transaction(1, transaction_id) + tx_confirmed = await client.get_transaction(transaction_id) assert tx_confirmed.confirmed assert len(tx_confirmed.get_memos()) == 1 assert [b"this is a basic tx"] in tx_confirmed.get_memos().values() @@ -363,7 +363,7 @@ async def test_push_transactions(wallet_rpc_environment: WalletRpcTestEnvironmen assert spend_bundle is not None await farm_transaction(full_node_api, wallet_node, spend_bundle) - tx = await client.get_transaction(1, transaction_id=tx.name) + tx = await client.get_transaction(transaction_id=tx.name) assert tx.confirmed @@ -826,7 +826,7 @@ async def test_send_transaction_multi(wallet_rpc_environment: WalletRpcTestEnvir await time_out_assert(20, get_confirmed_balance, generated_funds - amount_outputs - amount_fee, client, 1) # Checks that the memo can be retrieved - tx_confirmed = await client.get_transaction(1, send_tx_res.name) + tx_confirmed = await client.get_transaction(send_tx_res.name) assert tx_confirmed.confirmed memos = tx_confirmed.get_memos() assert len(memos) == len(outputs)