Skip to content

Commit e8e060b

Browse files
authored
[CHIA-3419] Remove TransactionRecord.*_json_dict_convenience (#19860)
* Change `TransactionRecord` to use dict instead of list of tuples for memos * Update streamable and fix tests * Update test to accidentally fixed memos generation * Remove `TransactionRecord.*_json_dict_convenience` * Fix test * Use AddressType library in WSM method * Use AddressType library in transaction_store method
1 parent 72de196 commit e8e060b

24 files changed

+138
-124
lines changed

chia/_tests/cmds/cmd_test_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ async def get_transaction(self, transaction_id: bytes32) -> TransactionRecord:
121121
confirmed_at_height=uint32(1),
122122
created_at_time=uint64(1234),
123123
to_puzzle_hash=bytes32([1] * 32),
124+
to_address=encode_puzzle_hash(bytes32([1] * 32), "xch"),
124125
amount=uint64(12345678),
125126
fee_amount=uint64(1234567),
126127
confirmed=False,
@@ -271,6 +272,7 @@ async def send_transaction_multi(
271272
confirmed_at_height=uint32(1),
272273
created_at_time=uint64(1234),
273274
to_puzzle_hash=bytes32([1] * 32),
275+
to_address=encode_puzzle_hash(bytes32([1] * 32), "xch"),
274276
amount=uint64(12345678),
275277
fee_amount=uint64(1234567),
276278
confirmed=False,

chia/_tests/cmds/wallet/test_consts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from chia_rs.sized_bytes import bytes32
55
from chia_rs.sized_ints import uint32, uint64
66

7+
from chia.util.bech32m import encode_puzzle_hash
78
from chia.wallet.conditions import ConditionValidTimes
89
from chia.wallet.signer_protocol import KeyHints, SigningInstructions, TransactionInfo, UnsignedTransaction
910
from chia.wallet.transaction_record import TransactionRecord
@@ -27,6 +28,7 @@ def get_bytes32(bytes_index: int) -> bytes32:
2728
confirmed_at_height=uint32(1),
2829
created_at_time=uint64(1234),
2930
to_puzzle_hash=get_bytes32(1),
31+
to_address=encode_puzzle_hash(get_bytes32(1), "xch"),
3032
amount=uint64(12345678),
3133
fee_amount=uint64(1234567),
3234
confirmed=False,

chia/_tests/cmds/wallet/test_did.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from chia.types.blockchain_format.program import NIL, Program
1414
from chia.types.signing_mode import SigningMode
1515
from chia.util.bech32m import encode_puzzle_hash
16-
from chia.util.config import load_config
1716
from chia.wallet.conditions import Condition, ConditionValidTimes, CreateCoinAnnouncement, CreatePuzzleAnnouncement
1817
from chia.wallet.did_wallet.did_info import did_recovery_is_nil
1918
from chia.wallet.util.curry_and_treehash import NIL_TREEHASH
@@ -421,14 +420,10 @@ async def did_transfer_did(
421420
"150",
422421
]
423422
# these are various things that should be in the output
424-
config = load_config(
425-
root_dir,
426-
"config.yaml",
427-
)
428423
assert_list = [
429424
f"Successfully transferred DID to {t_address}",
430425
f"Transaction ID: {get_bytes32(2).hex()}",
431-
f"Transaction: {STD_TX.to_json_dict_convenience(config)}",
426+
f"Transaction: {STD_TX.to_json_dict()}",
432427
]
433428
run_cli_command_and_assert(capsys, root_dir, command_args, assert_list)
434429
expected_calls: logType = {

chia/_tests/cmds/wallet/test_wallet.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ async def get_transactions(
131131
confirmed_at_height=uint32(1 + i),
132132
created_at_time=uint64(1234 + i),
133133
to_puzzle_hash=bytes32([1 + i] * 32),
134+
to_address=encode_puzzle_hash(bytes32([1 + i] * 32), "xch"),
134135
amount=uint64(12345678 + i),
135136
fee_amount=uint64(1234567 + i),
136137
confirmed=False,
@@ -340,6 +341,7 @@ async def send_transaction(
340341
confirmed_at_height=uint32(1),
341342
created_at_time=uint64(1234),
342343
to_puzzle_hash=get_bytes32(1),
344+
to_address=encode_puzzle_hash(get_bytes32(1), "xch"),
343345
amount=uint64(12345678),
344346
fee_amount=uint64(1234567),
345347
confirmed=False,
@@ -529,14 +531,7 @@ async def spend_clawback_coins(
529531
tx_hex_list = [get_bytes32(6).hex(), get_bytes32(7).hex(), get_bytes32(8).hex()]
530532
return {
531533
"transaction_ids": tx_hex_list,
532-
"transactions": [
533-
STD_TX.to_json_dict_convenience(
534-
{
535-
"selected_network": "mainnet",
536-
"network_overrides": {"config": {"mainnet": {"address_prefix": "xch"}}},
537-
}
538-
)
539-
],
534+
"transactions": [STD_TX.to_json_dict()],
540535
}
541536

542537
inst_rpc_client = ClawbackWalletRpcClient()

chia/_tests/core/data_layer/test_data_rpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ async def is_transaction_confirmed(api: WalletRpcApi, tx_id: bytes32) -> bool:
190190
except ValueError: # pragma: no cover
191191
return False
192192

193-
return True if TransactionRecord.from_json_dict_convenience(val["transaction"]).confirmed else False # mypy
193+
return True if TransactionRecord.from_json_dict(val["transaction"]).confirmed else False # mypy
194194

195195

196196
async def farm_block_with_spend(

chia/_tests/wallet/rpc/test_wallet_rpc.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ async def test_send_transaction(wallet_rpc_environment: WalletRpcTestEnvironment
406406
},
407407
)
408408
assert response["success"]
409-
tx = TransactionRecord.from_json_dict_convenience(response["transactions"][0])
409+
tx = TransactionRecord.from_json_dict(response["transactions"][0])
410410
[
411411
byte_deserialize_clvm_streamable(
412412
bytes.fromhex(utx), UnsignedTransaction, translation_layer=BLIND_SIGNER_TRANSLATION
@@ -458,9 +458,7 @@ async def test_push_transactions(wallet_rpc_environment: WalletRpcTestEnvironmen
458458
PushTransactions(transactions=[tx], fee=uint64(10)),
459459
DEFAULT_TX_CONFIG,
460460
)
461-
resp = await client.fetch(
462-
"push_transactions", {"transactions": [tx.to_json_dict_convenience(wallet_node.config)], "fee": 10}
463-
)
461+
resp = await client.fetch("push_transactions", {"transactions": [tx.to_json_dict()], "fee": 10})
464462
assert resp["success"]
465463
resp = await client.fetch("push_transactions", {"transactions": [bytes(tx).hex()], "fee": 10})
466464
assert resp["success"]
@@ -914,7 +912,7 @@ async def test_spend_clawback_coins(wallet_rpc_environment: WalletRpcTestEnviron
914912
assert resp["success"]
915913
assert len(resp["transaction_ids"]) == 2
916914
for _tx in resp["transactions"]:
917-
clawback_tx = TransactionRecord.from_json_dict_convenience(_tx)
915+
clawback_tx = TransactionRecord.from_json_dict(_tx)
918916
if clawback_tx.spend_bundle is not None:
919917
await time_out_assert_not_none(
920918
10, full_node_api.full_node.mempool_manager.get_spendbundle, clawback_tx.spend_bundle.name()

0 commit comments

Comments
 (0)