8181from chia .wallet .derive_keys import master_sk_to_wallet_sk , master_sk_to_wallet_sk_unhardened
8282from chia .wallet .did_wallet .did_wallet import DIDWallet
8383from chia .wallet .nft_wallet .nft_wallet import NFTWallet
84+ from chia .wallet .puzzle_drivers import PuzzleInfo
8485from chia .wallet .puzzles .clawback .metadata import AutoClaimSettings
8586from chia .wallet .puzzles .p2_delegated_puzzle_or_hidden_puzzle import puzzle_hash_for_pk
8687from chia .wallet .signer_protocol import UnsignedTransaction
114115 CheckOfferValidity ,
115116 ClawbackPuzzleDecoratorOverride ,
116117 CombineCoins ,
118+ CreateOfferForIDs ,
117119 DefaultCAT ,
118120 DeleteKey ,
119121 DeleteNotifications ,
@@ -1586,28 +1588,29 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
15861588 )
15871589 # Create an offer of 5 chia for one CAT
15881590 await env_1 .rpc_client .create_offer_for_ids (
1589- {uint32 (1 ): - 5 , cat_asset_id .hex (): 1 }, wallet_environments .tx_config , validate_only = True
1591+ CreateOfferForIDs (offer = {str (1 ): "-5" , cat_asset_id .hex (): "1" }, validate_only = True ),
1592+ tx_config = wallet_environments .tx_config ,
15901593 )
15911594 all_offers = await env_1 .rpc_client .get_all_offers ()
15921595 assert len (all_offers ) == 0
15931596
1594- driver_dict : dict [str , Any ] = {
1595- cat_asset_id .hex (): {
1596- "type" : "CAT" ,
1597- "tail" : "0x" + cat_asset_id .hex (),
1598- ** (
1599- {}
1600- if wallet_type is CATWallet
1601- else {"also" : {"type" : "revocation layer" , "hidden_puzzle_hash" : "0x" + bytes32 .zeros .hex ()}}
1602- ),
1603- }
1597+ driver_dict = {
1598+ cat_asset_id : PuzzleInfo (
1599+ {
1600+ "type" : "CAT" ,
1601+ "tail" : "0x" + cat_asset_id .hex (),
1602+ ** (
1603+ {}
1604+ if wallet_type is CATWallet
1605+ else {"also" : {"type" : "revocation layer" , "hidden_puzzle_hash" : "0x" + bytes32 .zeros .hex ()}}
1606+ ),
1607+ }
1608+ )
16041609 }
16051610
16061611 create_res = await env_1 .rpc_client .create_offer_for_ids (
1607- {uint32 (1 ): - 5 , cat_asset_id .hex (): 1 },
1608- wallet_environments .tx_config ,
1609- driver_dict = driver_dict ,
1610- fee = uint64 (1 ),
1612+ CreateOfferForIDs (offer = {str (1 ): "-5" , cat_asset_id .hex (): "1" }, driver_dict = driver_dict , fee = uint64 (1 )),
1613+ tx_config = wallet_environments .tx_config ,
16111614 )
16121615 offer = create_res .offer
16131616
@@ -1618,7 +1621,7 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
16181621 assert summary == {
16191622 "offered" : {"xch" : 5 },
16201623 "requested" : {cat_asset_id .hex (): 1 },
1621- "infos" : driver_dict ,
1624+ "infos" : { key . hex (): info . info for key , info in driver_dict . items ()} ,
16221625 "fees" : 1 ,
16231626 "additions" : [c .name ().hex () for c in offer .additions ()],
16241627 "removals" : [c .name ().hex () for c in offer .removals ()],
@@ -1662,7 +1665,8 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
16621665 assert TradeStatus (trade_record .status ) == TradeStatus .PENDING_CANCEL
16631666
16641667 create_res = await env_1 .rpc_client .create_offer_for_ids (
1665- {uint32 (1 ): - 5 , cat_wallet_id : 1 }, wallet_environments .tx_config , fee = uint64 (1 )
1668+ CreateOfferForIDs (offer = {str (1 ): "-5" , str (cat_wallet_id ): "1" }, fee = uint64 (1 )),
1669+ tx_config = wallet_environments .tx_config ,
16661670 )
16671671 all_offers = await env_1 .rpc_client .get_all_offers ()
16681672 assert len (all_offers ) == 2
@@ -1776,9 +1780,8 @@ def only_ids(trades: list[TradeRecord]) -> list[bytes32]:
17761780 assert len (all_offers ) == 2
17771781
17781782 await env_1 .rpc_client .create_offer_for_ids (
1779- {uint32 (1 ): - 5 , cat_asset_id .hex (): 1 },
1780- wallet_environments .tx_config ,
1781- driver_dict = driver_dict ,
1783+ CreateOfferForIDs (offer = {str (1 ): "-5" , cat_asset_id .hex (): "1" }, driver_dict = driver_dict ),
1784+ tx_config = wallet_environments .tx_config ,
17821785 )
17831786 assert (
17841787 len ([o for o in await env_1 .rpc_client .get_all_offers () if o .status == TradeStatus .PENDING_ACCEPT .value ]) == 2
@@ -1814,14 +1817,12 @@ def only_ids(trades: list[TradeRecord]) -> list[bytes32]:
18141817 )
18151818
18161819 await env_1 .rpc_client .create_offer_for_ids (
1817- {uint32 (1 ): - 5 , cat_asset_id .hex (): 1 },
1818- wallet_environments .tx_config ,
1819- driver_dict = driver_dict ,
1820+ CreateOfferForIDs (offer = {str (1 ): "-5" , cat_asset_id .hex (): "1" }, driver_dict = driver_dict ),
1821+ tx_config = wallet_environments .tx_config ,
18201822 )
18211823 await env_1 .rpc_client .create_offer_for_ids (
1822- {uint32 (1 ): 5 , cat_asset_id .hex (): - 1 },
1823- wallet_environments .tx_config ,
1824- driver_dict = driver_dict ,
1824+ CreateOfferForIDs (offer = {str (1 ): "5" , cat_asset_id .hex (): "-1" }, driver_dict = driver_dict ),
1825+ tx_config = wallet_environments .tx_config ,
18251826 )
18261827 assert (
18271828 len ([o for o in await env_1 .rpc_client .get_all_offers () if o .status == TradeStatus .PENDING_ACCEPT .value ]) == 2
@@ -1868,9 +1869,8 @@ def only_ids(trades: list[TradeRecord]) -> list[bytes32]:
18681869 )
18691870
18701871 await env_1 .rpc_client .create_offer_for_ids (
1871- {uint32 (1 ): 5 , cat_asset_id .hex (): - 1 },
1872- wallet_environments .tx_config ,
1873- driver_dict = driver_dict ,
1872+ CreateOfferForIDs (offer = {str (1 ): "5" , cat_asset_id .hex (): "-1" }, driver_dict = driver_dict ),
1873+ tx_config = wallet_environments .tx_config ,
18741874 )
18751875 assert (
18761876 len ([o for o in await env_1 .rpc_client .get_all_offers () if o .status == TradeStatus .PENDING_ACCEPT .value ]) == 1
@@ -1886,9 +1886,11 @@ def only_ids(trades: list[TradeRecord]) -> list[bytes32]:
18861886
18871887 with pytest .raises (ValueError , match = "not currently supported" ):
18881888 await env_1 .rpc_client .create_offer_for_ids (
1889- {uint32 (1 ): - 5 , cat_asset_id .hex (): 1 },
1889+ CreateOfferForIDs (
1890+ offer = {str (1 ): "-5" , cat_asset_id .hex (): "1" },
1891+ driver_dict = driver_dict ,
1892+ ),
18901893 wallet_environments .tx_config ,
1891- driver_dict = driver_dict ,
18921894 timelock_info = ConditionValidTimes (min_secs_since_created = uint64 (1 )),
18931895 )
18941896
0 commit comments