From 0677a2bc53bbd93f00548daea4d8ac295415b8c9 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 31 Oct 2024 09:50:37 -0700 Subject: [PATCH] Fix chia/_tests/wallet/test_wallet.py --- chia/_tests/wallet/test_wallet.py | 4 ++-- chia/rpc/wallet_request_types.py | 6 ++++-- chia/rpc/wallet_rpc_api.py | 7 +------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/chia/_tests/wallet/test_wallet.py b/chia/_tests/wallet/test_wallet.py index 5cb4753f09a0..9aad369c0722 100644 --- a/chia/_tests/wallet/test_wallet.py +++ b/chia/_tests/wallet/test_wallet.py @@ -393,7 +393,7 @@ async def test_wallet_clawback_clawback(self, wallet_environments: WalletTestFra assert len(txs["transactions"]) == 1 assert not txs["transactions"][0]["confirmed"] assert txs["transactions"][0]["metadata"]["recipient_puzzle_hash"][2:] == normal_puzhash.hex() - assert txs["transactions"][0]["metadata"]["coin_id"] == merkle_coin.name().hex() + assert txs["transactions"][0]["metadata"]["coin_id"][2:] == merkle_coin.name().hex() with pytest.raises(ValueError): await api_0.spend_clawback_coins({}) @@ -577,7 +577,7 @@ async def test_wallet_clawback_sent_self(self, wallet_environments: WalletTestFr assert txs["transactions"][0]["confirmed"] assert txs["transactions"][1]["confirmed"] assert txs["transactions"][0]["memos"] != txs["transactions"][1]["memos"] - assert list(txs["transactions"][0]["memos"].values())[0] == b"Test".hex() + assert list(txs["transactions"][0]["memos"].values())[0][2:] == b"Test".hex() @pytest.mark.parametrize( "wallet_environments", diff --git a/chia/rpc/wallet_request_types.py b/chia/rpc/wallet_request_types.py index f6b30467ab48..1a7df6d6b837 100644 --- a/chia/rpc/wallet_request_types.py +++ b/chia/rpc/wallet_request_types.py @@ -14,6 +14,7 @@ from chia.util.streamable import Streamable, streamable from chia.wallet.conditions import Condition, ConditionValidTimes from chia.wallet.notification_store import Notification +from chia.wallet.puzzles.clawback.metadata import ClawbackMetadata from chia.wallet.signer_protocol import ( SignedTransaction, SigningInstructions, @@ -351,14 +352,15 @@ def __post_init__(self) -> None: raise ValueError(f"There is no known sort {self.sort_key}") -# utilities for GetTransactionsResponse +# utility for GetTransactionsResponse @streamable @dataclass(frozen=True) -class TransactionRecordMetadata(Streamable): +class TransactionRecordMetadata(ClawbackMetadata): coin_id: bytes32 spent: bool +# utility for GetTransactionsResponse @streamable @dataclass(frozen=True) class UserFriendlyTransactionRecordWithMetadata(UserFriendlyTransactionRecord): diff --git a/chia/rpc/wallet_rpc_api.py b/chia/rpc/wallet_rpc_api.py index 9bc7a70716b6..9c5ff1d65b3a 100644 --- a/chia/rpc/wallet_rpc_api.py +++ b/chia/rpc/wallet_rpc_api.py @@ -1320,12 +1320,7 @@ async def get_transactions(self, request: GetTransactions) -> GetTransactionsRes tx["metadata"]["coin_id"] = coin.name().hex() tx["metadata"]["spent"] = record.spent return GetTransactionsResponse( - transactions=[ - UserFriendlyTransactionRecordWithMetadata.from_transaction_record( - TransactionRecord.from_json_dict_convenience(tx), self.service.config - ) - for tx in tx_list - ], + transactions=[UserFriendlyTransactionRecordWithMetadata.from_json_dict(tx) for tx in tx_list], wallet_id=request.wallet_id, )