Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused parameter #17598

Merged
merged 6 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions chia/cmds/dao_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:]))
Expand Down Expand Up @@ -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:]))
Expand Down Expand Up @@ -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:]))
Expand Down Expand Up @@ -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:]))
Expand Down Expand Up @@ -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:]))
Expand Down Expand Up @@ -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:]))
Expand Down
4 changes: 2 additions & 2 deletions chia/cmds/plotnft_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
6 changes: 2 additions & 4 deletions chia/cmds/wallet_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions chia/rpc/wallet_rpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down
4 changes: 2 additions & 2 deletions tests/cmds/cmd_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
10 changes: 7 additions & 3 deletions tests/cmds/wallet/test_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())),
Expand Down Expand Up @@ -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())),
Expand Down Expand Up @@ -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())),
Expand Down
8 changes: 4 additions & 4 deletions tests/cmds/wallet/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions tests/core/data_layer/test_data_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions tests/wallet/rpc/test_wallet_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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)
Expand Down
Loading