8080from chia .wallet .derive_keys import master_sk_to_wallet_sk , master_sk_to_wallet_sk_unhardened
8181from chia .wallet .did_wallet .did_wallet import DIDWallet
8282from chia .wallet .nft_wallet .nft_wallet import NFTWallet
83+ from chia .wallet .puzzle_drivers import PuzzleInfo
8384from chia .wallet .puzzles .clawback .metadata import AutoClaimSettings
8485from chia .wallet .puzzles .p2_delegated_puzzle_or_hidden_puzzle import puzzle_hash_for_pk
8586from chia .wallet .signer_protocol import UnsignedTransaction
113114 CheckOfferValidity ,
114115 ClawbackPuzzleDecoratorOverride ,
115116 CombineCoins ,
117+ CreateOfferForIDs ,
116118 DefaultCAT ,
117119 DeleteKey ,
118120 DeleteNotifications ,
@@ -1546,28 +1548,29 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
15461548 )
15471549 # Create an offer of 5 chia for one CAT
15481550 await env_1 .rpc_client .create_offer_for_ids (
1549- {uint32 (1 ): - 5 , cat_asset_id .hex (): 1 }, wallet_environments .tx_config , validate_only = True
1551+ CreateOfferForIDs (offer = {str (1 ): "-5" , cat_asset_id .hex (): "1" }, validate_only = True ),
1552+ tx_config = wallet_environments .tx_config ,
15501553 )
15511554 all_offers = await env_1 .rpc_client .get_all_offers ()
15521555 assert len (all_offers ) == 0
15531556
1554- driver_dict : dict [str , Any ] = {
1555- cat_asset_id .hex (): {
1556- "type" : "CAT" ,
1557- "tail" : "0x" + cat_asset_id .hex (),
1558- ** (
1559- {}
1560- if wallet_type is CATWallet
1561- else {"also" : {"type" : "revocation layer" , "hidden_puzzle_hash" : "0x" + bytes32 .zeros .hex ()}}
1562- ),
1563- }
1557+ driver_dict = {
1558+ cat_asset_id : PuzzleInfo (
1559+ {
1560+ "type" : "CAT" ,
1561+ "tail" : "0x" + cat_asset_id .hex (),
1562+ ** (
1563+ {}
1564+ if wallet_type is CATWallet
1565+ else {"also" : {"type" : "revocation layer" , "hidden_puzzle_hash" : "0x" + bytes32 .zeros .hex ()}}
1566+ ),
1567+ }
1568+ )
15641569 }
15651570
15661571 create_res = await env_1 .rpc_client .create_offer_for_ids (
1567- {uint32 (1 ): - 5 , cat_asset_id .hex (): 1 },
1568- wallet_environments .tx_config ,
1569- driver_dict = driver_dict ,
1570- fee = uint64 (1 ),
1572+ CreateOfferForIDs (offer = {str (1 ): "-5" , cat_asset_id .hex (): "1" }, driver_dict = driver_dict , fee = uint64 (1 )),
1573+ tx_config = wallet_environments .tx_config ,
15711574 )
15721575 offer = create_res .offer
15731576
@@ -1578,7 +1581,7 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
15781581 assert summary == {
15791582 "offered" : {"xch" : 5 },
15801583 "requested" : {cat_asset_id .hex (): 1 },
1581- "infos" : driver_dict ,
1584+ "infos" : { key . hex (): info . info for key , info in driver_dict . items ()} ,
15821585 "fees" : 1 ,
15831586 "additions" : [c .name ().hex () for c in offer .additions ()],
15841587 "removals" : [c .name ().hex () for c in offer .removals ()],
@@ -1622,7 +1625,8 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
16221625 assert TradeStatus (trade_record .status ) == TradeStatus .PENDING_CANCEL
16231626
16241627 create_res = await env_1 .rpc_client .create_offer_for_ids (
1625- {uint32 (1 ): - 5 , cat_wallet_id : 1 }, wallet_environments .tx_config , fee = uint64 (1 )
1628+ CreateOfferForIDs (offer = {str (1 ): "-5" , str (cat_wallet_id ): "1" }, fee = uint64 (1 )),
1629+ tx_config = wallet_environments .tx_config ,
16261630 )
16271631 all_offers = await env_1 .rpc_client .get_all_offers ()
16281632 assert len (all_offers ) == 2
@@ -1736,9 +1740,8 @@ def only_ids(trades: list[TradeRecord]) -> list[bytes32]:
17361740 assert len (all_offers ) == 2
17371741
17381742 await env_1 .rpc_client .create_offer_for_ids (
1739- {uint32 (1 ): - 5 , cat_asset_id .hex (): 1 },
1740- wallet_environments .tx_config ,
1741- driver_dict = driver_dict ,
1743+ CreateOfferForIDs (offer = {str (1 ): "-5" , cat_asset_id .hex (): "1" }, driver_dict = driver_dict ),
1744+ tx_config = wallet_environments .tx_config ,
17421745 )
17431746 assert (
17441747 len ([o for o in await env_1 .rpc_client .get_all_offers () if o .status == TradeStatus .PENDING_ACCEPT .value ]) == 2
@@ -1774,14 +1777,12 @@ def only_ids(trades: list[TradeRecord]) -> list[bytes32]:
17741777 )
17751778
17761779 await env_1 .rpc_client .create_offer_for_ids (
1777- {uint32 (1 ): - 5 , cat_asset_id .hex (): 1 },
1778- wallet_environments .tx_config ,
1779- driver_dict = driver_dict ,
1780+ CreateOfferForIDs (offer = {str (1 ): "-5" , cat_asset_id .hex (): "1" }, driver_dict = driver_dict ),
1781+ tx_config = wallet_environments .tx_config ,
17801782 )
17811783 await env_1 .rpc_client .create_offer_for_ids (
1782- {uint32 (1 ): 5 , cat_asset_id .hex (): - 1 },
1783- wallet_environments .tx_config ,
1784- driver_dict = driver_dict ,
1784+ CreateOfferForIDs (offer = {str (1 ): "5" , cat_asset_id .hex (): "-1" }, driver_dict = driver_dict ),
1785+ tx_config = wallet_environments .tx_config ,
17851786 )
17861787 assert (
17871788 len ([o for o in await env_1 .rpc_client .get_all_offers () if o .status == TradeStatus .PENDING_ACCEPT .value ]) == 2
@@ -1828,9 +1829,8 @@ def only_ids(trades: list[TradeRecord]) -> list[bytes32]:
18281829 )
18291830
18301831 await env_1 .rpc_client .create_offer_for_ids (
1831- {uint32 (1 ): 5 , cat_asset_id .hex (): - 1 },
1832- wallet_environments .tx_config ,
1833- driver_dict = driver_dict ,
1832+ CreateOfferForIDs (offer = {str (1 ): "5" , cat_asset_id .hex (): "-1" }, driver_dict = driver_dict ),
1833+ tx_config = wallet_environments .tx_config ,
18341834 )
18351835 assert (
18361836 len ([o for o in await env_1 .rpc_client .get_all_offers () if o .status == TradeStatus .PENDING_ACCEPT .value ]) == 1
@@ -1846,9 +1846,11 @@ def only_ids(trades: list[TradeRecord]) -> list[bytes32]:
18461846
18471847 with pytest .raises (ValueError , match = "not currently supported" ):
18481848 await env_1 .rpc_client .create_offer_for_ids (
1849- {uint32 (1 ): - 5 , cat_asset_id .hex (): 1 },
1849+ CreateOfferForIDs (
1850+ offer = {str (1 ): "-5" , cat_asset_id .hex (): "1" },
1851+ driver_dict = driver_dict ,
1852+ ),
18501853 wallet_environments .tx_config ,
1851- driver_dict = driver_dict ,
18521854 timelock_info = ConditionValidTimes (min_secs_since_created = uint64 (1 )),
18531855 )
18541856
0 commit comments