29
29
from chia .types .blockchain_format .program import Program
30
30
from chia .types .signing_mode import SigningMode
31
31
from chia .util .bech32m import encode_puzzle_hash
32
- from chia .wallet .conditions import ConditionValidTimes
32
+ from chia .wallet .conditions import Condition , ConditionValidTimes
33
33
from chia .wallet .trade_record import TradeRecord
34
34
from chia .wallet .trading .offer import Offer
35
35
from chia .wallet .trading .trade_status import TradeStatus
44
44
BalanceResponse ,
45
45
CancelOfferResponse ,
46
46
CATSpendResponse ,
47
+ ClawbackPuzzleDecoratorOverride ,
47
48
CreateOfferForIDsResponse ,
49
+ DeleteUnconfirmedTransactions ,
50
+ ExtendDerivationIndex ,
51
+ ExtendDerivationIndexResponse ,
48
52
FungibleAsset ,
53
+ GetCurrentDerivationIndexResponse ,
49
54
GetHeightInfoResponse ,
55
+ GetNextAddress ,
56
+ GetNextAddressResponse ,
50
57
GetTransaction ,
51
58
GetTransactions ,
52
59
GetTransactionsResponse ,
58
65
NFTGetWalletDID ,
59
66
NFTGetWalletDIDResponse ,
60
67
RoyaltyAsset ,
68
+ SendTransaction ,
61
69
SendTransactionResponse ,
70
+ SpendClawbackCoins ,
71
+ SpendClawbackCoinsResponse ,
62
72
TakeOfferResponse ,
63
73
TransactionRecordWithMetadata ,
64
74
WalletInfoResponse ,
@@ -327,19 +337,24 @@ def test_send(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Path])
327
337
class SendWalletRpcClient (TestWalletRpcClient ):
328
338
async def send_transaction (
329
339
self ,
330
- wallet_id : int ,
331
- amount : uint64 ,
332
- address : str ,
340
+ request : SendTransaction ,
333
341
tx_config : TXConfig ,
334
- fee : uint64 = uint64 (0 ),
335
- memos : Optional [list [str ]] = None ,
336
- puzzle_decorator_override : Optional [list [dict [str , Union [str , int , bool ]]]] = None ,
337
- push : bool = True ,
342
+ extra_conditions : tuple [Condition , ...] = tuple (),
338
343
timelock_info : ConditionValidTimes = ConditionValidTimes (),
339
344
) -> SendTransactionResponse :
340
345
self .add_to_log (
341
346
"send_transaction" ,
342
- (wallet_id , amount , address , tx_config , fee , memos , puzzle_decorator_override , push , timelock_info ),
347
+ (
348
+ request .wallet_id ,
349
+ request .amount ,
350
+ request .address ,
351
+ tx_config ,
352
+ request .fee ,
353
+ request .memos ,
354
+ request .puzzle_decorator ,
355
+ request .push ,
356
+ timelock_info ,
357
+ ),
343
358
)
344
359
name = get_bytes32 (2 )
345
360
tx_rec = TransactionRecord (
@@ -457,7 +472,7 @@ async def cat_spend(
457
472
),
458
473
500000000000 ,
459
474
["0x6262626262626262626262626262626262626262626262626262626262626262" ],
460
- [{ " decorator" : " CLAWBACK" , " clawback_timelock" : 60 } ],
475
+ [ClawbackPuzzleDecoratorOverride ( decorator = " CLAWBACK" , clawback_timelock = uint64 ( 60 )) ],
461
476
True ,
462
477
test_condition_valid_times ,
463
478
)
@@ -493,11 +508,11 @@ def test_get_address(capsys: object, get_test_cli_clients: tuple[TestRpcClients,
493
508
494
509
# set RPC Client
495
510
class GetAddressWalletRpcClient (TestWalletRpcClient ):
496
- async def get_next_address (self , wallet_id : int , new_address : bool ) -> str :
497
- self .add_to_log ("get_next_address" , (wallet_id , new_address ))
498
- if new_address :
499
- return encode_puzzle_hash (get_bytes32 (3 ), "xch" )
500
- return encode_puzzle_hash (get_bytes32 (4 ), "xch" )
511
+ async def get_next_address (self , request : GetNextAddress ) -> GetNextAddressResponse :
512
+ self .add_to_log ("get_next_address" , (request . wallet_id , request . new_address ))
513
+ if request . new_address :
514
+ return GetNextAddressResponse ( request . wallet_id , encode_puzzle_hash (get_bytes32 (3 ), "xch" ) )
515
+ return GetNextAddressResponse ( request . wallet_id , encode_puzzle_hash (get_bytes32 (4 ), "xch" ) )
501
516
502
517
inst_rpc_client = GetAddressWalletRpcClient ()
503
518
test_rpc_clients .wallet_rpc_client = inst_rpc_client
@@ -526,23 +541,25 @@ def test_clawback(capsys: object, get_test_cli_clients: tuple[TestRpcClients, Pa
526
541
class ClawbackWalletRpcClient (TestWalletRpcClient ):
527
542
async def spend_clawback_coins (
528
543
self ,
529
- coin_ids : list [bytes32 ],
530
- fee : int = 0 ,
531
- force : bool = False ,
532
- push : bool = True ,
544
+ request : SpendClawbackCoins ,
545
+ tx_config : TXConfig ,
546
+ extra_conditions : tuple [Condition , ...] = tuple (),
533
547
timelock_info : ConditionValidTimes = ConditionValidTimes (),
534
- ) -> dict [str , Any ]:
535
- self .add_to_log ("spend_clawback_coins" , (coin_ids , fee , force , push , timelock_info ))
536
- tx_hex_list = [get_bytes32 (6 ).hex (), get_bytes32 (7 ).hex (), get_bytes32 (8 ).hex ()]
537
- return {
538
- "transaction_ids" : tx_hex_list ,
539
- "transactions" : [STD_TX .to_json_dict ()],
540
- }
548
+ ) -> SpendClawbackCoinsResponse :
549
+ self .add_to_log (
550
+ "spend_clawback_coins" , (request .coin_ids , request .fee , request .force , request .push , timelock_info )
551
+ )
552
+ tx_list = [get_bytes32 (6 ), get_bytes32 (7 ), get_bytes32 (8 )]
553
+ return SpendClawbackCoinsResponse (
554
+ transaction_ids = tx_list ,
555
+ transactions = [STD_TX ],
556
+ unsigned_transactions = [STD_UTX ],
557
+ )
541
558
542
559
inst_rpc_client = ClawbackWalletRpcClient ()
543
560
test_rpc_clients .wallet_rpc_client = inst_rpc_client
544
561
tx_ids = [get_bytes32 (3 ), get_bytes32 (4 ), get_bytes32 (5 )]
545
- r_tx_ids_hex = [get_bytes32 (6 ).hex (), get_bytes32 (7 ).hex (), get_bytes32 (8 ).hex ()]
562
+ r_tx_ids_hex = ["0x" + get_bytes32 (6 ).hex (), "0x" + get_bytes32 (7 ).hex (), "0x" + get_bytes32 (8 ).hex ()]
546
563
command_args = [
547
564
"wallet" ,
548
565
"clawback" ,
@@ -556,7 +573,7 @@ async def spend_clawback_coins(
556
573
"--expires-at" ,
557
574
"150" ,
558
575
]
559
- run_cli_command_and_assert (capsys , root_dir , command_args , ["transaction_ids" , str ( r_tx_ids_hex ) ])
576
+ run_cli_command_and_assert (capsys , root_dir , command_args , ["transaction_ids" , * r_tx_ids_hex ])
560
577
# these are various things that should be in the output
561
578
expected_calls : logType = {
562
579
"spend_clawback_coins" : [(tx_ids , 500000000000 , False , True , test_condition_valid_times )],
@@ -569,8 +586,8 @@ def test_del_unconfirmed_tx(capsys: object, get_test_cli_clients: tuple[TestRpcC
569
586
570
587
# set RPC Client
571
588
class UnconfirmedTxRpcClient (TestWalletRpcClient ):
572
- async def delete_unconfirmed_transactions (self , wallet_id : int ) -> None :
573
- self .add_to_log ("delete_unconfirmed_transactions" , (wallet_id ,))
589
+ async def delete_unconfirmed_transactions (self , request : DeleteUnconfirmedTransactions ) -> None :
590
+ self .add_to_log ("delete_unconfirmed_transactions" , (request . wallet_id ,))
574
591
575
592
inst_rpc_client = UnconfirmedTxRpcClient ()
576
593
test_rpc_clients .wallet_rpc_client = inst_rpc_client
@@ -594,9 +611,9 @@ def test_get_derivation_index(capsys: object, get_test_cli_clients: tuple[TestRp
594
611
595
612
# set RPC Client
596
613
class GetDerivationIndexRpcClient (TestWalletRpcClient ):
597
- async def get_current_derivation_index (self ) -> str :
614
+ async def get_current_derivation_index (self ) -> GetCurrentDerivationIndexResponse :
598
615
self .add_to_log ("get_current_derivation_index" , ())
599
- return str ( 520 )
616
+ return GetCurrentDerivationIndexResponse ( uint32 ( 520 ) )
600
617
601
618
inst_rpc_client = GetDerivationIndexRpcClient ()
602
619
test_rpc_clients .wallet_rpc_client = inst_rpc_client
@@ -625,8 +642,9 @@ def test_sign_message(capsys: object, get_test_cli_clients: tuple[TestRpcClients
625
642
# these are various things that should be in the output
626
643
assert_list = [
627
644
f"Message: { message .hex ()} " ,
628
- f"Public Key: { bytes ([3 ] * 48 ).hex ()} " ,
629
- f"Signature: { bytes ([6 ] * 576 ).hex ()} " ,
645
+ "Public Key: b5acf3599bc5fa5da1c00f6cc3d5bcf1560def67778b7f50a8c373a83f78761505b6250ab776e38a292e26628009aec4" ,
646
+ "Signature: c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
647
+ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ,
630
648
f"Signing Mode: { SigningMode .CHIP_0002 .value } " ,
631
649
]
632
650
run_cli_command_and_assert (capsys , root_dir , [* command_args , f"-a{ xch_addr } " ], assert_list )
@@ -641,9 +659,9 @@ def test_update_derivation_index(capsys: object, get_test_cli_clients: tuple[Tes
641
659
642
660
# set RPC Client
643
661
class UpdateDerivationIndexRpcClient (TestWalletRpcClient ):
644
- async def extend_derivation_index (self , index : int ) -> str :
645
- self .add_to_log ("extend_derivation_index" , (index ,))
646
- return str ( index )
662
+ async def extend_derivation_index (self , request : ExtendDerivationIndex ) -> ExtendDerivationIndexResponse :
663
+ self .add_to_log ("extend_derivation_index" , (request . index ,))
664
+ return ExtendDerivationIndexResponse ( request . index )
647
665
648
666
inst_rpc_client = UpdateDerivationIndexRpcClient ()
649
667
test_rpc_clients .wallet_rpc_client = inst_rpc_client
0 commit comments