diff --git a/chia/data_layer/data_layer_wallet.py b/chia/data_layer/data_layer_wallet.py index 97d111629482..97373913f10a 100644 --- a/chia/data_layer/data_layer_wallet.py +++ b/chia/data_layer/data_layer_wallet.py @@ -1159,7 +1159,7 @@ async def make_update_offer( tx_config: TXConfig, fee: uint64 = uint64(0), extra_conditions: Tuple[Condition, ...] = tuple(), - ) -> Offer: + ) -> Tuple[Offer, List[TransactionRecord]]: dl_wallet = None for wallet in wallet_state_manager.wallets.values(): if wallet.type() == WalletType.DATA_LAYER.value: @@ -1171,6 +1171,7 @@ async def make_update_offer( offered_launchers: List[bytes32] = [k for k, v in offer_dict.items() if v < 0 and k is not None] fee_left_to_pay: uint64 = fee all_bundles: List[SpendBundle] = [] + all_transactions: List[TransactionRecord] = [] for launcher in offered_launchers: try: this_solver: Solver = solver[launcher.hex()] @@ -1213,7 +1214,16 @@ async def make_update_offer( txs[0].spend_bundle, coin_spends=all_other_spends, ) - all_bundles.append(SpendBundle.aggregate([signed_bundle, new_bundle])) + agg_bundle: SpendBundle = SpendBundle.aggregate([signed_bundle, new_bundle]) + all_bundles.append(agg_bundle) + all_transactions.append( + dataclasses.replace( + txs[0], + spend_bundle=agg_bundle, + name=agg_bundle.name(), + ) + ) + all_transactions.extend(txs[1:]) # create some dummy requested payments requested_payments = { @@ -1221,7 +1231,7 @@ async def make_update_offer( for k, v in offer_dict.items() if v > 0 } - return Offer(requested_payments, SpendBundle.aggregate(all_bundles), driver_dict) + return Offer(requested_payments, SpendBundle.aggregate(all_bundles), driver_dict), all_transactions @staticmethod async def finish_graftroot_solutions(offer: Offer, solver: Solver) -> Offer: diff --git a/chia/rpc/wallet_rpc_api.py b/chia/rpc/wallet_rpc_api.py index c36a9dfb40f6..4ef9a5e33d53 100644 --- a/chia/rpc/wallet_rpc_api.py +++ b/chia/rpc/wallet_rpc_api.py @@ -695,7 +695,7 @@ async def create_new_wallet( if not push: raise ValueError("Test CAT minting must be pushed automatically") # pragma: no cover async with self.service.wallet_state_manager.lock: - cat_wallet: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet, txs = await CATWallet.create_new_cat_wallet( wallet_state_manager, main_wallet, {"identifier": "genesis_by_id"}, @@ -706,7 +706,12 @@ async def create_new_wallet( ) asset_id = cat_wallet.get_asset_id() self.service.wallet_state_manager.state_changed("wallet_created") - return {"type": cat_wallet.type(), "asset_id": asset_id, "wallet_id": cat_wallet.id()} + return { + "type": cat_wallet.type(), + "asset_id": asset_id, + "wallet_id": cat_wallet.id(), + "transactions": [tx.to_json_dict_convenience(self.service.config) for tx in txs], + } else: raise ValueError( "Support for this RPC mode has been dropped." @@ -1847,10 +1852,11 @@ async def create_offer_for_ids( extra_conditions=extra_conditions, ) if result[0]: - success, trade_record, error = result + success, trade_record, tx_records, error = result return { "offer": Offer.from_bytes(trade_record.offer).to_bech32(), "trade_record": trade_record.to_json_dict_convenience(), + "transactions": [tx.to_json_dict_convenience(self.service.config) for tx in tx_records], } raise ValueError(result[2]) diff --git a/chia/wallet/cat_wallet/cat_wallet.py b/chia/wallet/cat_wallet/cat_wallet.py index 4830016aa88e..a2b5c8643493 100644 --- a/chia/wallet/cat_wallet/cat_wallet.py +++ b/chia/wallet/cat_wallet/cat_wallet.py @@ -116,7 +116,7 @@ async def create_new_cat_wallet( tx_config: TXConfig, fee: uint64 = uint64(0), name: Optional[str] = None, - ) -> CATWallet: + ) -> Tuple[CATWallet, List[TransactionRecord]]: self = CATWallet() self.standard_wallet = wallet self.log = logging.getLogger(__name__) @@ -201,7 +201,7 @@ async def create_new_cat_wallet( ) chia_tx = dataclasses.replace(chia_tx, spend_bundle=spend_bundle, name=spend_bundle.name()) await self.wallet_state_manager.add_pending_transactions([chia_tx, cat_record]) - return self + return self, [chia_tx, cat_record] @staticmethod async def get_or_create_wallet_for_cat( diff --git a/chia/wallet/dao_wallet/dao_wallet.py b/chia/wallet/dao_wallet/dao_wallet.py index 3c814a10db2b..f84b7b2793c1 100644 --- a/chia/wallet/dao_wallet/dao_wallet.py +++ b/chia/wallet/dao_wallet/dao_wallet.py @@ -685,7 +685,7 @@ async def generate_new_dao( "treasury_id": launcher_coin.name(), "coins": different_coins, } - new_cat_wallet = await CATWallet.create_new_cat_wallet( + new_cat_wallet, _ = await CATWallet.create_new_cat_wallet( self.wallet_state_manager, self.standard_wallet, cat_tail_info, diff --git a/chia/wallet/nft_wallet/nft_wallet.py b/chia/wallet/nft_wallet/nft_wallet.py index 3366c90296d0..277c70b1c1e6 100644 --- a/chia/wallet/nft_wallet/nft_wallet.py +++ b/chia/wallet/nft_wallet/nft_wallet.py @@ -794,7 +794,7 @@ async def make_nft1_offer( tx_config: TXConfig, fee: uint64, extra_conditions: Tuple[Condition, ...], - ) -> Offer: + ) -> Tuple[Offer, List[TransactionRecord]]: # First, let's take note of all the royalty enabled NFTs royalty_nft_asset_dict: Dict[bytes32, int] = {} for asset, amount in offer_dict.items(): @@ -1087,7 +1087,7 @@ async def make_nft1_offer( txs_bundle = SpendBundle.aggregate([tx.spend_bundle for tx in all_transactions if tx.spend_bundle is not None]) aggregate_bundle = SpendBundle.aggregate([txs_bundle, *additional_bundles]) offer = Offer(notarized_payments, aggregate_bundle, driver_dict) - return offer + return offer, all_transactions async def set_bulk_nft_did( self, diff --git a/chia/wallet/trade_manager.py b/chia/wallet/trade_manager.py index 52a20acb1314..bd1b179eb48e 100644 --- a/chia/wallet/trade_manager.py +++ b/chia/wallet/trade_manager.py @@ -5,7 +5,7 @@ import time from typing import Any, Dict, List, Optional, Set, Tuple, Union, cast -from typing_extensions import Literal +from typing_extensions import Literal, Never from chia.data_layer.data_layer_wallet import DataLayerWallet from chia.protocols.wallet_protocol import CoinState @@ -374,7 +374,9 @@ async def create_offer_for_ids( validate_only: bool = False, extra_conditions: Tuple[Condition, ...] = tuple(), taking: bool = False, - ) -> Union[Tuple[Literal[True], TradeRecord, None], Tuple[Literal[False], None, str]]: + ) -> Union[ + Tuple[Literal[True], TradeRecord, List[TransactionRecord], None], Tuple[Literal[False], None, List[Never], str] + ]: if driver_dict is None: driver_dict = {} if solver is None: @@ -391,7 +393,7 @@ async def create_offer_for_ids( if not result[0] or result[1] is None: raise Exception(f"Error creating offer: {result[2]}") - success, created_offer, error = result + success, created_offer, tx_records, error = result now = uint64(int(time.time())) trade_offer: TradeRecord = TradeRecord( @@ -412,7 +414,7 @@ async def create_offer_for_ids( if success is True and trade_offer is not None and not validate_only: await self.save_trade(trade_offer, created_offer) - return success, trade_offer, error + return success, trade_offer, tx_records, error async def _create_offer_for_ids( self, @@ -423,7 +425,9 @@ async def _create_offer_for_ids( fee: uint64 = uint64(0), extra_conditions: Tuple[Condition, ...] = tuple(), taking: bool = False, - ) -> Union[Tuple[Literal[True], Offer, None], Tuple[Literal[False], None, str]]: + ) -> Union[ + Tuple[Literal[True], Offer, List[TransactionRecord], None], Tuple[Literal[False], None, List[Never], str] + ]: """ Offer is dictionary of wallet ids and amount """ @@ -512,7 +516,9 @@ async def _create_offer_for_ids( requested_payments, driver_dict, taking ) - potential_special_offer: Optional[Offer] = await self.check_for_special_offer_making( + potential_special_offer: Optional[ + Tuple[Offer, List[TransactionRecord]] + ] = await self.check_for_special_offer_making( offer_dict_no_ints, driver_dict, tx_config, @@ -522,7 +528,7 @@ async def _create_offer_for_ids( ) if potential_special_offer is not None: - return True, potential_special_offer, None + return True, potential_special_offer[0], potential_special_offer[1], None all_coins: List[Coin] = [c for coins in coins_to_offer.values() for c in coins] notarized_payments: Dict[Optional[bytes32], List[NotarizedPayment]] = Offer.notarize_payments( @@ -586,11 +592,11 @@ async def _create_offer_for_ids( ) offer = Offer(notarized_payments, total_spend_bundle, driver_dict) - return True, offer, None + return True, offer, all_transactions, None except Exception as e: self.log.exception("Error creating trade offer") - return False, None, str(e) + return False, None, [], str(e) async def maybe_create_wallets_for_offer(self, offer: Offer) -> None: for key in offer.arbitrage(): @@ -786,7 +792,7 @@ async def respond_to_offer( if not result[0] or result[1] is None: raise ValueError(result[2]) - success, take_offer, error = result + success, take_offer, _, error = result complete_offer, valid_spend_solver = await self.check_for_final_modifications( Offer.aggregate([offer, take_offer]), solver, tx_config @@ -848,7 +854,7 @@ async def check_for_special_offer_making( solver: Solver, fee: uint64 = uint64(0), extra_conditions: Tuple[Condition, ...] = tuple(), - ) -> Optional[Offer]: + ) -> Optional[Tuple[Offer, List[TransactionRecord]]]: for puzzle_info in driver_dict.values(): if ( puzzle_info.check_type([AssetType.SINGLETON.value, AssetType.METADATA.value, AssetType.OWNERSHIP.value]) diff --git a/chia/wallet/vc_wallet/cr_cat_wallet.py b/chia/wallet/vc_wallet/cr_cat_wallet.py index 01d1e5506730..4feea953f150 100644 --- a/chia/wallet/vc_wallet/cr_cat_wallet.py +++ b/chia/wallet/vc_wallet/cr_cat_wallet.py @@ -88,7 +88,7 @@ async def create_new_cat_wallet( tx_config: TXConfig, fee: uint64 = uint64(0), name: Optional[str] = None, - ) -> CATWallet: # pragma: no cover + ) -> Tuple[CATWallet, List[TransactionRecord]]: # pragma: no cover raise NotImplementedError("create_new_cat_wallet is a legacy method and is not available on CR-CAT wallets") @staticmethod diff --git a/tests/wallet/cat_wallet/test_cat_wallet.py b/tests/wallet/cat_wallet/test_cat_wallet.py index 7fa8e00430d4..6c8cca4ab424 100644 --- a/tests/wallet/cat_wallet/test_cat_wallet.py +++ b/tests/wallet/cat_wallet/test_cat_wallet.py @@ -71,7 +71,7 @@ async def test_cat_creation(self_hostname: str, two_wallet_nodes: OldSimulatorsA await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20) async with wallet_node.wallet_state_manager.lock: - cat_wallet = await CATWallet.create_new_cat_wallet( + cat_wallet, tx_records = await CATWallet.create_new_cat_wallet( wallet_node.wallet_state_manager, wallet, {"identifier": "genesis_by_id"}, @@ -83,9 +83,7 @@ async def test_cat_creation(self_hostname: str, two_wallet_nodes: OldSimulatorsA cat_wallet = await CATWallet.create(wallet_node.wallet_state_manager, wallet, cat_wallet.wallet_info) await wallet_node.wallet_state_manager.add_new_wallet(cat_wallet) - tx_queue = await wallet_node.wallet_state_manager.tx_store.get_not_sent() - tx_record = tx_queue[0] - await full_node_api.process_transaction_records(records=[tx_record]) + await full_node_api.process_transaction_records(records=tx_records) await time_out_assert(20, cat_wallet.get_confirmed_balance, 100) await time_out_assert(20, cat_wallet.get_spendable_balance, 100) @@ -140,10 +138,10 @@ async def test_cat_creation_unique_lineage_store(self_hostname: str, two_wallet_ await full_node_api.wait_for_wallet_synced(wallet_node=wallet_node, timeout=20) async with wallet_node.wallet_state_manager.lock: - cat_wallet_1 = await CATWallet.create_new_cat_wallet( + cat_wallet_1, _ = await CATWallet.create_new_cat_wallet( wallet_node.wallet_state_manager, wallet, {"identifier": "genesis_by_id"}, uint64(100), DEFAULT_TX_CONFIG ) - cat_wallet_2 = await CATWallet.create_new_cat_wallet( + cat_wallet_2, _ = await CATWallet.create_new_cat_wallet( wallet_node.wallet_state_manager, wallet, {"identifier": "genesis_by_id"}, uint64(200), DEFAULT_TX_CONFIG ) @@ -188,12 +186,10 @@ async def test_cat_spend(self_hostname: str, two_wallet_nodes: OldSimulatorsAndW await time_out_assert(20, wallet.get_confirmed_balance, funds) async with wallet_node.wallet_state_manager.lock: - cat_wallet = await CATWallet.create_new_cat_wallet( + cat_wallet, tx_records = await CATWallet.create_new_cat_wallet( wallet_node.wallet_state_manager, wallet, {"identifier": "genesis_by_id"}, uint64(100), DEFAULT_TX_CONFIG ) - tx_queue = await wallet_node.wallet_state_manager.tx_store.get_not_sent() - tx_record = tx_queue[0] - await full_node_api.process_transaction_records(records=[tx_record]) + await full_node_api.process_transaction_records(records=tx_records) await time_out_assert(20, cat_wallet.get_confirmed_balance, 100) await time_out_assert(20, cat_wallet.get_unconfirmed_balance, 100) @@ -293,12 +289,10 @@ async def test_cat_reuse_address(self_hostname: str, two_wallet_nodes: OldSimula await time_out_assert(20, wallet.get_confirmed_balance, funds) async with wallet_node.wallet_state_manager.lock: - cat_wallet = await CATWallet.create_new_cat_wallet( + cat_wallet, tx_records = await CATWallet.create_new_cat_wallet( wallet_node.wallet_state_manager, wallet, {"identifier": "genesis_by_id"}, uint64(100), DEFAULT_TX_CONFIG ) - tx_queue = await wallet_node.wallet_state_manager.tx_store.get_not_sent() - tx_record = tx_queue[0] - await full_node_api.process_transaction_records(records=[tx_record]) + await full_node_api.process_transaction_records(records=tx_records) await time_out_assert(20, cat_wallet.get_confirmed_balance, 100) await time_out_assert(20, cat_wallet.get_unconfirmed_balance, 100) @@ -390,7 +384,7 @@ async def test_get_wallet_for_asset_id( await time_out_assert(20, wallet.get_confirmed_balance, funds) async with wallet_node.wallet_state_manager.lock: - cat_wallet = await CATWallet.create_new_cat_wallet( + cat_wallet, _ = await CATWallet.create_new_cat_wallet( wallet_node.wallet_state_manager, wallet, {"identifier": "genesis_by_id"}, uint64(100), DEFAULT_TX_CONFIG ) @@ -444,10 +438,9 @@ async def test_cat_doesnt_see_eve(self_hostname: str, two_wallet_nodes: OldSimul await time_out_assert(20, wallet.get_confirmed_balance, funds) async with wallet_node.wallet_state_manager.lock: - cat_wallet = await CATWallet.create_new_cat_wallet( + cat_wallet, tx_records = await CATWallet.create_new_cat_wallet( wallet_node.wallet_state_manager, wallet, {"identifier": "genesis_by_id"}, uint64(100), DEFAULT_TX_CONFIG ) - tx_records = await wallet_node.wallet_state_manager.tx_store.get_not_sent() await full_node_api.process_transaction_records(records=tx_records) await time_out_assert(20, cat_wallet.get_confirmed_balance, 100) @@ -535,14 +528,13 @@ async def test_cat_spend_multiple( await time_out_assert(20, wallet_0.get_confirmed_balance, funds) async with wallet_node_0.wallet_state_manager.lock: - cat_wallet_0 = await CATWallet.create_new_cat_wallet( + cat_wallet_0, tx_records = await CATWallet.create_new_cat_wallet( wallet_node_0.wallet_state_manager, wallet_0, {"identifier": "genesis_by_id"}, uint64(100), DEFAULT_TX_CONFIG, ) - tx_records = await wallet_node_0.wallet_state_manager.tx_store.get_not_sent() await full_node_api.process_transaction_records(records=tx_records) await time_out_assert(20, cat_wallet_0.get_confirmed_balance, 100) @@ -652,10 +644,9 @@ async def test_cat_max_amount_send( await time_out_assert(20, wallet.get_confirmed_balance, funds) async with wallet_node.wallet_state_manager.lock: - cat_wallet = await CATWallet.create_new_cat_wallet( + cat_wallet, tx_records = await CATWallet.create_new_cat_wallet( wallet_node.wallet_state_manager, wallet, {"identifier": "genesis_by_id"}, uint64(100000), DEFAULT_TX_CONFIG ) - tx_records = await wallet_node.wallet_state_manager.tx_store.get_not_sent() await full_node_api.process_transaction_records(records=tx_records) await time_out_assert(20, cat_wallet.get_confirmed_balance, 100000) @@ -751,10 +742,9 @@ async def test_cat_hint( await time_out_assert(20, wallet.get_confirmed_balance, funds) async with wallet_node.wallet_state_manager.lock: - cat_wallet = await CATWallet.create_new_cat_wallet( + cat_wallet, tx_records = await CATWallet.create_new_cat_wallet( wallet_node.wallet_state_manager, wallet, {"identifier": "genesis_by_id"}, uint64(100), DEFAULT_TX_CONFIG ) - tx_records = await wallet_node.wallet_state_manager.tx_store.get_not_sent() await full_node_api.process_transaction_records(records=tx_records) await time_out_assert(20, cat_wallet.get_confirmed_balance, 100) diff --git a/tests/wallet/cat_wallet/test_trades.py b/tests/wallet/cat_wallet/test_trades.py index ede2a1bdd2ba..46b86ea1a91c 100644 --- a/tests/wallet/cat_wallet/test_trades.py +++ b/tests/wallet/cat_wallet/test_trades.py @@ -304,7 +304,7 @@ async def test_cat_trades( # Mint some standard CATs async with wallet_node_maker.wallet_state_manager.lock: - cat_wallet_maker = await CATWallet.create_new_cat_wallet( + cat_wallet_maker, _ = await CATWallet.create_new_cat_wallet( wallet_node_maker.wallet_state_manager, wallet_maker, {"identifier": "genesis_by_id"}, @@ -313,7 +313,7 @@ async def test_cat_trades( ) async with wallet_node_taker.wallet_state_manager.lock: - new_cat_wallet_taker = await CATWallet.create_new_cat_wallet( + new_cat_wallet_taker, _ = await CATWallet.create_new_cat_wallet( wallet_node_taker.wallet_state_manager, wallet_taker, {"identifier": "genesis_by_id"}, @@ -451,7 +451,7 @@ async def test_cat_trades( taker_unused_index = taker_unused_dr.index # Execute all of the trades # chia_for_cat - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( chia_for_cat, wallet_environments.tx_config, fee=uint64(1) ) assert error is None @@ -655,7 +655,7 @@ async def assert_trade_tx_number(wallet_node, trade_id, number): ) # cat_for_chia - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( cat_for_chia, wallet_environments.tx_config ) assert error is None @@ -779,7 +779,7 @@ async def assert_trade_tx_number(wallet_node, trade_id, number): ) assert taker_unused_dr is not None taker_unused_index = taker_unused_dr.index - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( cat_for_cat, wallet_environments.tx_config ) assert error is None @@ -965,7 +965,7 @@ async def assert_trade_tx_number(wallet_node, trade_id, number): assert taker_unused_index < taker_unused_dr.index # chia_for_multiple_cat - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( chia_for_multiple_cat, wallet_environments.tx_config, driver_dict=driver_dict, @@ -1207,7 +1207,7 @@ async def assert_trade_tx_number(wallet_node, trade_id, number): ) # multiple_cat_for_chia - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( multiple_cat_for_chia, wallet_environments.tx_config, ) @@ -1332,7 +1332,7 @@ async def assert_trade_tx_number(wallet_node, trade_id, number): await time_out_assert(15, get_trade_and_status, TradeStatus.CONFIRMED, trade_manager_taker, trade_take) # chia_and_cat_for_cat - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( chia_and_cat_for_cat, wallet_environments.tx_config, ) @@ -1536,7 +1536,7 @@ async def test_trade_cancellation(wallets_prefarm): xch_to_cat_amount = uint64(100) async with wallet_node_maker.wallet_state_manager.lock: - cat_wallet_maker: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet_maker, tx_records = await CATWallet.create_new_cat_wallet( wallet_node_maker.wallet_state_manager, wallet_maker, {"identifier": "genesis_by_id"}, @@ -1544,8 +1544,6 @@ async def test_trade_cancellation(wallets_prefarm): DEFAULT_TX_CONFIG, ) - tx_records: List[TransactionRecord] = await wallet_node_maker.wallet_state_manager.tx_store.get_not_sent() - await full_node.process_transaction_records(records=tx_records) await time_out_assert(15, cat_wallet_maker.get_confirmed_balance, xch_to_cat_amount) @@ -1566,7 +1564,7 @@ async def test_trade_cancellation(wallets_prefarm): trade_manager_maker = wallet_node_maker.wallet_state_manager.trade_manager trade_manager_taker = wallet_node_taker.wallet_state_manager.trade_manager - success, trade_make, error = await trade_manager_maker.create_offer_for_ids(cat_for_chia, DEFAULT_TX_CONFIG) + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids(cat_for_chia, DEFAULT_TX_CONFIG) assert error is None assert success is True assert trade_make is not None @@ -1626,7 +1624,7 @@ async def test_trade_cancellation(wallets_prefarm): await trade_manager_taker.respond_to_offer(Offer.from_bytes(trade_make.offer), peer, DEFAULT_TX_CONFIG) # Now we're going to create the other way around for test coverage sake - success, trade_make, error = await trade_manager_maker.create_offer_for_ids(chia_for_cat, DEFAULT_TX_CONFIG) + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids(chia_for_cat, DEFAULT_TX_CONFIG) assert error is None assert success is True assert trade_make is not None @@ -1661,7 +1659,7 @@ async def test_trade_cancellation_balance_check(wallets_prefarm): xch_to_cat_amount = uint64(100) async with wallet_node_maker.wallet_state_manager.lock: - cat_wallet_maker: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet_maker, tx_records = await CATWallet.create_new_cat_wallet( wallet_node_maker.wallet_state_manager, wallet_maker, {"identifier": "genesis_by_id"}, @@ -1669,8 +1667,6 @@ async def test_trade_cancellation_balance_check(wallets_prefarm): DEFAULT_TX_CONFIG, ) - tx_records: List[TransactionRecord] = await wallet_node_maker.wallet_state_manager.tx_store.get_not_sent() - await full_node.process_transaction_records(records=tx_records) await time_out_assert(15, cat_wallet_maker.get_confirmed_balance, xch_to_cat_amount) @@ -1685,7 +1681,7 @@ async def test_trade_cancellation_balance_check(wallets_prefarm): trade_manager_maker = wallet_node_maker.wallet_state_manager.trade_manager - success, trade_make, error = await trade_manager_maker.create_offer_for_ids(chia_for_cat, DEFAULT_TX_CONFIG) + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids(chia_for_cat, DEFAULT_TX_CONFIG) await time_out_assert(10, get_trade_and_status, TradeStatus.PENDING_ACCEPT, trade_manager_maker, trade_make) assert error is None assert success is True @@ -1714,7 +1710,7 @@ async def test_trade_conflict(three_wallets_prefarm): xch_to_cat_amount = uint64(100) async with wallet_node_maker.wallet_state_manager.lock: - cat_wallet_maker: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet_maker, tx_records = await CATWallet.create_new_cat_wallet( wallet_node_maker.wallet_state_manager, wallet_maker, {"identifier": "genesis_by_id"}, @@ -1722,8 +1718,6 @@ async def test_trade_conflict(three_wallets_prefarm): DEFAULT_TX_CONFIG, ) - tx_records: List[TransactionRecord] = await wallet_node_maker.wallet_state_manager.tx_store.get_not_sent() - await full_node.process_transaction_records(records=tx_records) await time_out_assert(15, cat_wallet_maker.get_confirmed_balance, xch_to_cat_amount) @@ -1740,7 +1734,7 @@ async def test_trade_conflict(three_wallets_prefarm): trade_manager_taker = wallet_node_taker.wallet_state_manager.trade_manager trade_manager_trader = wallet_node_trader.wallet_state_manager.trade_manager - success, trade_make, error = await trade_manager_maker.create_offer_for_ids(chia_for_cat, DEFAULT_TX_CONFIG) + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids(chia_for_cat, DEFAULT_TX_CONFIG) await time_out_assert(10, get_trade_and_status, TradeStatus.PENDING_ACCEPT, trade_manager_maker, trade_make) assert error is None assert success is True @@ -1774,7 +1768,7 @@ async def test_trade_bad_spend(wallets_prefarm): xch_to_cat_amount = uint64(100) async with wallet_node_maker.wallet_state_manager.lock: - cat_wallet_maker: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet_maker, tx_records = await CATWallet.create_new_cat_wallet( wallet_node_maker.wallet_state_manager, wallet_maker, {"identifier": "genesis_by_id"}, @@ -1782,8 +1776,6 @@ async def test_trade_bad_spend(wallets_prefarm): DEFAULT_TX_CONFIG, ) - tx_records: List[TransactionRecord] = await wallet_node_maker.wallet_state_manager.tx_store.get_not_sent() - await full_node.process_transaction_records(records=tx_records) await time_out_assert(15, cat_wallet_maker.get_confirmed_balance, xch_to_cat_amount) @@ -1799,7 +1791,7 @@ async def test_trade_bad_spend(wallets_prefarm): trade_manager_maker = wallet_node_maker.wallet_state_manager.trade_manager trade_manager_taker = wallet_node_taker.wallet_state_manager.trade_manager - success, trade_make, error = await trade_manager_maker.create_offer_for_ids(chia_for_cat, DEFAULT_TX_CONFIG) + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids(chia_for_cat, DEFAULT_TX_CONFIG) await time_out_assert(30, get_trade_and_status, TradeStatus.PENDING_ACCEPT, trade_manager_maker, trade_make) assert error is None assert success is True @@ -1835,7 +1827,7 @@ async def test_trade_high_fee(wallets_prefarm): xch_to_cat_amount = uint64(100) async with wallet_node_maker.wallet_state_manager.lock: - cat_wallet_maker: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet_maker, tx_records = await CATWallet.create_new_cat_wallet( wallet_node_maker.wallet_state_manager, wallet_maker, {"identifier": "genesis_by_id"}, @@ -1843,8 +1835,6 @@ async def test_trade_high_fee(wallets_prefarm): DEFAULT_TX_CONFIG, ) - tx_records: List[TransactionRecord] = await wallet_node_maker.wallet_state_manager.tx_store.get_not_sent() - await full_node.process_transaction_records(records=tx_records) await time_out_assert(15, cat_wallet_maker.get_confirmed_balance, xch_to_cat_amount) @@ -1860,7 +1850,7 @@ async def test_trade_high_fee(wallets_prefarm): trade_manager_maker = wallet_node_maker.wallet_state_manager.trade_manager trade_manager_taker = wallet_node_taker.wallet_state_manager.trade_manager - success, trade_make, error = await trade_manager_maker.create_offer_for_ids(chia_for_cat, DEFAULT_TX_CONFIG) + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids(chia_for_cat, DEFAULT_TX_CONFIG) await time_out_assert(10, get_trade_and_status, TradeStatus.PENDING_ACCEPT, trade_manager_maker, trade_make) assert error is None assert success is True @@ -1885,7 +1875,7 @@ async def test_aggregated_trade_state(wallets_prefarm): xch_to_cat_amount = uint64(100) async with wallet_node_maker.wallet_state_manager.lock: - cat_wallet_maker: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet_maker, tx_records = await CATWallet.create_new_cat_wallet( wallet_node_maker.wallet_state_manager, wallet_maker, {"identifier": "genesis_by_id"}, @@ -1893,8 +1883,6 @@ async def test_aggregated_trade_state(wallets_prefarm): DEFAULT_TX_CONFIG, ) - tx_records: List[TransactionRecord] = await wallet_node_maker.wallet_state_manager.tx_store.get_not_sent() - await full_node.process_transaction_records(records=tx_records) await time_out_assert(15, cat_wallet_maker.get_confirmed_balance, xch_to_cat_amount) @@ -1914,12 +1902,12 @@ async def test_aggregated_trade_state(wallets_prefarm): trade_manager_maker = wallet_node_maker.wallet_state_manager.trade_manager trade_manager_taker = wallet_node_taker.wallet_state_manager.trade_manager - success, trade_make_1, error = await trade_manager_maker.create_offer_for_ids(chia_for_cat, DEFAULT_TX_CONFIG) + success, trade_make_1, _, error = await trade_manager_maker.create_offer_for_ids(chia_for_cat, DEFAULT_TX_CONFIG) await time_out_assert(10, get_trade_and_status, TradeStatus.PENDING_ACCEPT, trade_manager_maker, trade_make_1) assert error is None assert success is True assert trade_make_1 is not None - success, trade_make_2, error = await trade_manager_maker.create_offer_for_ids(cat_for_chia, DEFAULT_TX_CONFIG) + success, trade_make_2, _, error = await trade_manager_maker.create_offer_for_ids(cat_for_chia, DEFAULT_TX_CONFIG) await time_out_assert(10, get_trade_and_status, TradeStatus.PENDING_ACCEPT, trade_manager_maker, trade_make_2) assert error is None assert success is True diff --git a/tests/wallet/db_wallet/test_dl_offers.py b/tests/wallet/db_wallet/test_dl_offers.py index b181b67fa140..c35bf4f33d4e 100644 --- a/tests/wallet/db_wallet/test_dl_offers.py +++ b/tests/wallet/db_wallet/test_dl_offers.py @@ -104,7 +104,7 @@ async def test_dl_offers(wallets_prefarm: Any, trusted: bool) -> None: fee = uint64(2_000_000_000_000) - success, offer_maker, error = await trade_manager_maker.create_offer_for_ids( + success, offer_maker, _, error = await trade_manager_maker.create_offer_for_ids( {launcher_id_maker: -1, launcher_id_taker: 1}, DEFAULT_TX_CONFIG, solver=Solver( @@ -266,7 +266,7 @@ async def test_dl_offer_cancellation(wallets_prefarm: Any, trusted: bool) -> Non ROWS.append(addition) root, proofs = build_merkle_tree(ROWS) - success, offer, error = await trade_manager.create_offer_for_ids( + success, offer, _, error = await trade_manager.create_offer_for_ids( {launcher_id: -1, launcher_id_2: 1}, DEFAULT_TX_CONFIG, solver=Solver( @@ -386,7 +386,7 @@ async def test_multiple_dl_offers(wallets_prefarm: Any, trusted: bool) -> None: fee = uint64(2_000_000_000_000) - success, offer_maker, error = await trade_manager_maker.create_offer_for_ids( + success, offer_maker, _, error = await trade_manager_maker.create_offer_for_ids( {launcher_id_maker_1: -1, launcher_id_taker_1: 1, launcher_id_maker_2: -1, launcher_id_taker_2: 1}, DEFAULT_TX_CONFIG, solver=Solver( diff --git a/tests/wallet/nft_wallet/test_nft_1_offers.py b/tests/wallet/nft_wallet/test_nft_1_offers.py index e3920e7015c0..ce81cff18104 100644 --- a/tests/wallet/nft_wallet/test_nft_1_offers.py +++ b/tests/wallet/nft_wallet/test_nft_1_offers.py @@ -169,7 +169,7 @@ async def test_nft_offer_sell_nft( offer_did_nft_for_xch = {nft_to_offer_asset_id: -1, wallet_maker.id(): xch_requested} - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_did_nft_for_xch, DEFAULT_TX_CONFIG, {}, fee=maker_fee ) assert success is True @@ -312,7 +312,7 @@ async def test_nft_offer_request_nft( offer_dict = {nft_to_request_asset_id: 1, wallet_maker.id(): -xch_offered} - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_dict, DEFAULT_TX_CONFIG, driver_dict, fee=maker_fee ) assert success is True @@ -466,7 +466,7 @@ async def test_nft_offer_sell_did_to_did( offer_did_nft_for_xch = {nft_to_offer_asset_id: -1, wallet_maker.id(): xch_requested} - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_did_nft_for_xch, DEFAULT_TX_CONFIG, {}, fee=maker_fee ) assert success is True @@ -607,7 +607,7 @@ async def test_nft_offer_sell_nft_for_cat( cats_to_trade = uint64(10000) async with wallet_node_maker.wallet_state_manager.lock: full_node_api.full_node.log.warning(f"Mempool size: {full_node_api.full_node.mempool_manager.mempool.size()}") - cat_wallet_maker: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet_maker, _ = await CATWallet.create_new_cat_wallet( wallet_node_maker.wallet_state_manager, wallet_maker, {"identifier": "genesis_by_id"}, @@ -650,7 +650,7 @@ async def test_nft_offer_sell_nft_for_cat( offer_did_nft_for_xch = {nft_to_offer_asset_id: -1, cat_wallet_maker.id(): cats_requested} - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_did_nft_for_xch, DEFAULT_TX_CONFIG, {}, fee=maker_fee ) @@ -788,7 +788,7 @@ async def test_nft_offer_request_nft_for_cat( cats_to_mint = 100000 cats_to_trade = uint64(20000) async with wallet_node_maker.wallet_state_manager.lock: - cat_wallet_maker: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet_maker, _ = await CATWallet.create_new_cat_wallet( wallet_node_maker.wallet_state_manager, wallet_maker, {"identifier": "genesis_by_id"}, @@ -842,7 +842,7 @@ async def test_nft_offer_request_nft_for_cat( offer_dict = {nft_to_request_asset_id: 1, cat_wallet_maker.id(): -cats_requested} - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_dict, DEFAULT_TX_CONFIG, driver_dict, fee=maker_fee ) assert success is True @@ -976,7 +976,7 @@ async def test_nft_offer_sell_cancel( offer_did_nft_for_xch = {nft_to_offer_asset_id: -1, wallet_maker.id(): xch_requested} - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_did_nft_for_xch, DEFAULT_TX_CONFIG, {}, fee=maker_fee ) @@ -1097,7 +1097,7 @@ async def test_nft_offer_sell_cancel_in_batch( offer_did_nft_for_xch = {nft_to_offer_asset_id: -1, wallet_maker.id(): xch_requested} - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_did_nft_for_xch, DEFAULT_TX_CONFIG, {}, fee=maker_fee ) @@ -1173,11 +1173,11 @@ async def test_complex_nft_offer( CAT_AMOUNT = uint64(100000000) async with wsm_maker.lock: - cat_wallet_maker: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet_maker, _ = await CATWallet.create_new_cat_wallet( wsm_maker, wallet_maker, {"identifier": "genesis_by_id"}, CAT_AMOUNT, DEFAULT_TX_CONFIG ) async with wsm_maker.lock: - cat_wallet_taker: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet_taker, _ = await CATWallet.create_new_cat_wallet( wsm_taker, wallet_taker, {"identifier": "genesis_by_id"}, CAT_AMOUNT, DEFAULT_TX_CONFIG ) cat_spend_bundle_maker = ( @@ -1362,7 +1362,7 @@ async def test_complex_nft_offer( ), } - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( complex_nft_offer, DEFAULT_TX_CONFIG, driver_dict=driver_dict, fee=FEE ) assert error is None @@ -1475,7 +1475,7 @@ async def get_cat_wallet_and_check_balance(asset_id: str, wsm: Any) -> uint128: ), } - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( complex_nft_offer, DEFAULT_TX_CONFIG, driver_dict=driver_dict, fee=uint64(0) ) assert error is None diff --git a/tests/wallet/nft_wallet/test_nft_offers.py b/tests/wallet/nft_wallet/test_nft_offers.py index 9554d85a2c04..8d5159c989ec 100644 --- a/tests/wallet/nft_wallet/test_nft_offers.py +++ b/tests/wallet/nft_wallet/test_nft_offers.py @@ -135,7 +135,7 @@ async def test_nft_offer_with_fee( await wallet_taker.wallet_state_manager.puzzle_store.get_current_derivation_record_for_wallet(uint32(1)) ).index - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_nft_for_xch, tx_config, driver_dict, fee=maker_fee ) assert success is True @@ -207,7 +207,7 @@ async def test_nft_offer_with_fee( maker_fee = uint64(10) offer_xch_for_nft = {wallet_maker.id(): -xch_offered, nft_to_buy_asset_id: 1} - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_xch_for_nft, tx_config, driver_dict_to_buy, fee=maker_fee ) assert success is True @@ -325,7 +325,7 @@ async def test_nft_offer_cancellations( maker_fee = uint64(10) offer_nft_for_xch = {wallet_maker.id(): xch_request, nft_asset_id: -1} - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_nft_for_xch, DEFAULT_TX_CONFIG, driver_dict, fee=maker_fee ) assert success is True @@ -469,7 +469,7 @@ async def test_nft_offer_with_metadata_update( maker_fee = uint64(10) offer_nft_for_xch = {wallet_maker.id(): xch_request, nft_asset_id: -1} - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_nft_for_xch, DEFAULT_TX_CONFIG, driver_dict, fee=maker_fee ) assert success is True @@ -585,7 +585,7 @@ async def test_nft_offer_nft_for_cat( # Create two new CATs and wallets for maker and taker cats_to_mint = 10000 async with wallet_node_0.wallet_state_manager.lock: - cat_wallet_maker: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet_maker, _ = await CATWallet.create_new_cat_wallet( wallet_node_0.wallet_state_manager, wallet_maker, {"identifier": "genesis_by_id"}, @@ -597,7 +597,7 @@ async def test_nft_offer_nft_for_cat( await full_node_api.wait_for_wallets_synced(wallet_nodes=[wallet_node_0, wallet_node_1], timeout=20) async with wallet_node_1.wallet_state_manager.lock: - cat_wallet_taker: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet_taker, _ = await CATWallet.create_new_cat_wallet( wallet_node_1.wallet_state_manager, wallet_taker, {"identifier": "genesis_by_id"}, @@ -644,7 +644,7 @@ async def test_nft_offer_nft_for_cat( await wallet_taker.wallet_state_manager.puzzle_store.get_current_derivation_record_for_wallet(uint32(1)) ).index - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_nft_for_cat, tx_config, driver_dict, fee=maker_fee ) assert success is True @@ -728,7 +728,7 @@ async def test_nft_offer_nft_for_cat( cat_wallet_maker.id(): -maker_cat_amount, } - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_multi_cats_for_nft, tx_config, driver_dict_to_buy, fee=maker_fee ) assert success is True @@ -878,7 +878,7 @@ async def test_nft_offer_nft_for_nft( maker_fee = uint64(10) offer_nft_for_nft = {nft_to_take_asset_id: 1, nft_to_offer_asset_id: -1} - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_nft_for_nft, DEFAULT_TX_CONFIG, driver_dict, fee=maker_fee ) assert success is True @@ -994,7 +994,7 @@ async def test_nft_offer_nft0_and_xch_for_cat( # Create two new CATs and wallets for maker and taker cats_to_mint = 10000 async with wallet_node_0.wallet_state_manager.lock: - cat_wallet_maker: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet_maker, _ = await CATWallet.create_new_cat_wallet( wallet_node_0.wallet_state_manager, wallet_maker, {"identifier": "genesis_by_id"}, @@ -1006,7 +1006,7 @@ async def test_nft_offer_nft0_and_xch_for_cat( await full_node_api.wait_for_wallets_synced(wallet_nodes=[wallet_node_0, wallet_node_1], timeout=20) async with wallet_node_1.wallet_state_manager.lock: - cat_wallet_taker: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet_taker, _ = await CATWallet.create_new_cat_wallet( wallet_node_1.wallet_state_manager, wallet_taker, {"identifier": "genesis_by_id"}, @@ -1059,7 +1059,7 @@ async def test_nft_offer_nft0_and_xch_for_cat( await wallet_taker.wallet_state_manager.puzzle_store.get_current_derivation_record_for_wallet(uint32(1)) ).index - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_nft_for_cat, tx_config, driver_dict, fee=maker_fee ) assert success is True @@ -1150,7 +1150,7 @@ async def test_nft_offer_nft0_and_xch_for_cat( cat_wallet_maker.id(): -maker_cat_amount, } - success, trade_make, error = await trade_manager_maker.create_offer_for_ids( + success, trade_make, _, error = await trade_manager_maker.create_offer_for_ids( offer_multi_cats_for_nft, tx_config, driver_dict_to_buy, fee=maker_fee ) assert success is True diff --git a/tests/wallet/rpc/test_wallet_rpc.py b/tests/wallet/rpc/test_wallet_rpc.py index 187c5057ab80..febdc934cf8d 100644 --- a/tests/wallet/rpc/test_wallet_rpc.py +++ b/tests/wallet/rpc/test_wallet_rpc.py @@ -377,7 +377,7 @@ async def test_get_balance(wallet_rpc_environment: WalletRpcTestEnvironment): wallet_rpc_client = env.wallet_1.rpc_client await full_node_api.farm_blocks_to_wallet(2, wallet) async with wallet_node.wallet_state_manager.lock: - cat_wallet: CATWallet = await CATWallet.create_new_cat_wallet( + cat_wallet, _ = await CATWallet.create_new_cat_wallet( wallet_node.wallet_state_manager, wallet, {"identifier": "genesis_by_id"}, uint64(100), DEFAULT_TX_CONFIG ) await assert_get_balance(wallet_rpc_client, wallet_node, wallet)