Skip to content

Commit 11cb2f5

Browse files
committed
Undo UserFriendlyMemos
1 parent 4f01879 commit 11cb2f5

File tree

3 files changed

+3
-42
lines changed

3 files changed

+3
-42
lines changed

chia/_tests/cmds/cmd_test_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
NFTGetInfo,
4545
NFTGetInfoResponse,
4646
SendTransactionMultiResponse,
47-
UserFriendlyMemos,
4847
UserFriendlyTransactionRecord,
4948
WalletInfoResponse,
5049
)
@@ -138,7 +137,7 @@ async def get_transaction(self, request: GetTransaction) -> GetTransactionRespon
138137
trade_id=None,
139138
type=uint32(TransactionType.OUTGOING_TX.value),
140139
name=bytes32([2] * 32),
141-
memos=UserFriendlyMemos([(bytes32([3] * 32), [bytes([4] * 32)])]),
140+
memos={bytes32([3] * 32): [bytes([4] * 32)]},
142141
valid_times=ConditionValidTimes(),
143142
to_address="",
144143
),

chia/_tests/cmds/wallet/test_wallet.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
RoyaltyAsset,
6161
SendTransactionResponse,
6262
TakeOfferResponse,
63-
UserFriendlyMemos,
6463
UserFriendlyTransactionRecordWithMetadata,
6564
WalletInfoResponse,
6665
)
@@ -140,7 +139,7 @@ async def get_transactions(self, request: GetTransactions) -> GetTransactionsRes
140139
trade_id=None,
141140
type=uint32(t_type.value),
142141
name=bytes32([2 + i] * 32),
143-
memos=UserFriendlyMemos([(bytes32([3 + i] * 32), [bytes([4 + i] * 32)])]),
142+
memos={bytes32([3 + i] * 32): [bytes([4 + i] * 32)]},
144143
valid_times=ConditionValidTimes(),
145144
to_address="",
146145
)

chia/wallet/wallet_request_types.py

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -47,48 +47,11 @@ def default_raise() -> Any: # pragma: no cover
4747
raise RuntimeError("This should be impossible to hit and is just for < 3.10 compatibility")
4848

4949

50-
class UserFriendlyMemos:
51-
unfriendly_memos: list[tuple[bytes32, list[bytes]]]
52-
53-
def __init__(self, unfriendly_memos: list[tuple[bytes32, list[bytes]]]) -> None:
54-
self.unfriendly_memos = unfriendly_memos
55-
56-
def __eq__(self, other: object) -> bool:
57-
if isinstance(other, UserFriendlyMemos) and other.unfriendly_memos == self.unfriendly_memos:
58-
return True
59-
else:
60-
return False
61-
62-
def __bytes__(self) -> bytes:
63-
raise NotImplementedError("Should not be serializing this object as bytes, it's only for RPC")
64-
65-
@classmethod
66-
def parse(cls, f: BinaryIO) -> UserFriendlyMemos:
67-
raise NotImplementedError("Should not be deserializing this object from a stream, it's only for RPC")
68-
69-
def to_json_dict(self) -> dict[str, Any]:
70-
return {
71-
"0x" + coin_id.hex(): "0x" + memo.hex()
72-
for coin_id, memos in self.unfriendly_memos
73-
for memo in memos
74-
if memo is not None
75-
}
76-
77-
@classmethod
78-
def from_json_dict(cls, json_dict: dict[str, Any]) -> UserFriendlyMemos:
79-
return UserFriendlyMemos(
80-
[(bytes32.from_hexstr(coin_id), [hexstr_to_bytes(memo)]) for coin_id, memo in json_dict.items()]
81-
)
82-
83-
8450
@streamable
8551
@dataclass(frozen=True)
8652
class UserFriendlyTransactionRecord(TransactionRecord):
8753
to_address: str
88-
memos: UserFriendlyMemos # type: ignore[assignment]
89-
90-
def get_memos(self) -> dict[bytes32, list[bytes]]:
91-
return {coin_id: ms for coin_id, ms in self.memos.unfriendly_memos}
54+
memos: dict[bytes32, list[bytes]] # type: ignore[assignment]
9255

9356
def to_transaction_record(self) -> TransactionRecord:
9457
return TransactionRecord.from_json_dict_convenience(self.to_json_dict())

0 commit comments

Comments
 (0)