80
80
from chia .wallet .derive_keys import master_sk_to_wallet_sk , master_sk_to_wallet_sk_unhardened
81
81
from chia .wallet .did_wallet .did_wallet import DIDWallet
82
82
from chia .wallet .nft_wallet .nft_wallet import NFTWallet
83
+ from chia .wallet .puzzle_drivers import PuzzleInfo
83
84
from chia .wallet .puzzles .clawback .metadata import AutoClaimSettings
84
85
from chia .wallet .puzzles .p2_delegated_puzzle_or_hidden_puzzle import puzzle_hash_for_pk
85
86
from chia .wallet .signer_protocol import UnsignedTransaction
113
114
CheckOfferValidity ,
114
115
ClawbackPuzzleDecoratorOverride ,
115
116
CombineCoins ,
117
+ CreateOfferForIDs ,
116
118
DefaultCAT ,
117
119
DeleteKey ,
118
120
DeleteNotifications ,
@@ -1546,28 +1548,29 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
1546
1548
)
1547
1549
# Create an offer of 5 chia for one CAT
1548
1550
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 ,
1550
1553
)
1551
1554
all_offers = await env_1 .rpc_client .get_all_offers ()
1552
1555
assert len (all_offers ) == 0
1553
1556
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
+ )
1564
1569
}
1565
1570
1566
1571
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 ,
1571
1574
)
1572
1575
offer = create_res .offer
1573
1576
@@ -1578,7 +1581,7 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
1578
1581
assert summary == {
1579
1582
"offered" : {"xch" : 5 },
1580
1583
"requested" : {cat_asset_id .hex (): 1 },
1581
- "infos" : driver_dict ,
1584
+ "infos" : { key . hex (): info . info for key , info in driver_dict . items ()} ,
1582
1585
"fees" : 1 ,
1583
1586
"additions" : [c .name ().hex () for c in offer .additions ()],
1584
1587
"removals" : [c .name ().hex () for c in offer .removals ()],
@@ -1622,7 +1625,8 @@ async def test_offer_endpoints(wallet_environments: WalletTestFramework, wallet_
1622
1625
assert TradeStatus (trade_record .status ) == TradeStatus .PENDING_CANCEL
1623
1626
1624
1627
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 ,
1626
1630
)
1627
1631
all_offers = await env_1 .rpc_client .get_all_offers ()
1628
1632
assert len (all_offers ) == 2
@@ -1736,9 +1740,8 @@ def only_ids(trades: list[TradeRecord]) -> list[bytes32]:
1736
1740
assert len (all_offers ) == 2
1737
1741
1738
1742
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 ,
1742
1745
)
1743
1746
assert (
1744
1747
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]:
1774
1777
)
1775
1778
1776
1779
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 ,
1780
1782
)
1781
1783
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 ,
1785
1786
)
1786
1787
assert (
1787
1788
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]:
1828
1829
)
1829
1830
1830
1831
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 ,
1834
1834
)
1835
1835
assert (
1836
1836
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]:
1846
1846
1847
1847
with pytest .raises (ValueError , match = "not currently supported" ):
1848
1848
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
+ ),
1850
1853
wallet_environments .tx_config ,
1851
- driver_dict = driver_dict ,
1852
1854
timelock_info = ConditionValidTimes (min_secs_since_created = uint64 (1 )),
1853
1855
)
1854
1856
0 commit comments