Skip to content

Commit

Permalink
Fix chia/_tests/wallet/test_wallet.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Quexington committed Oct 31, 2024
1 parent 521fa64 commit 0677a2b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions chia/_tests/wallet/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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({})

Expand Down Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions chia/rpc/wallet_request_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down
7 changes: 1 addition & 6 deletions chia/rpc/wallet_rpc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down

0 comments on commit 0677a2b

Please sign in to comment.