From 5f7f2c13a6c0014e0496a1134cebdfe85a51acaf Mon Sep 17 00:00:00 2001 From: ytx1991 Date: Tue, 28 Jun 2022 11:10:16 -0700 Subject: [PATCH] Fix DID ID mismatch --- chia/rpc/wallet_rpc_api.py | 8 +++++++- tests/wallet/nft_wallet/test_nft_wallet.py | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/chia/rpc/wallet_rpc_api.py b/chia/rpc/wallet_rpc_api.py index 45c8e3ec40e3..814dd962dbe9 100644 --- a/chia/rpc/wallet_rpc_api.py +++ b/chia/rpc/wallet_rpc_api.py @@ -1588,11 +1588,17 @@ class WalletRpcApi: # Note: This is not the actual unspent NFT full puzzle. # There is no way to rebuild the full puzzle in a different wallet. # But it shouldn't have impact on generating the NFTInfo, since inner_puzzle is not used there. + if uncurried_nft.supports_did: + inner_puzzle = nft_puzzles.recurry_nft_puzzle( + uncurried_nft, coin_spend.solution.to_program(), uncurried_nft.p2_puzzle + ) + else: + inner_puzzle = uncurried_nft.p2_puzzle full_puzzle = nft_puzzles.create_full_puzzle( uncurried_nft.singleton_launcher_id, metadata, uncurried_nft.metadata_updater_hash, - uncurried_nft.inner_puzzle, + inner_puzzle, ) # Get launcher coin diff --git a/tests/wallet/nft_wallet/test_nft_wallet.py b/tests/wallet/nft_wallet/test_nft_wallet.py index db87dab40cf1..cb7f9f08ef97 100644 --- a/tests/wallet/nft_wallet/test_nft_wallet.py +++ b/tests/wallet/nft_wallet/test_nft_wallet.py @@ -1220,6 +1220,10 @@ async def test_nft_set_did(two_wallet_nodes: Any, trusted: Any) -> None: assert coins[0].owner_did.hex() == hex_did_id nft_coin_id = coins[0].nft_coin_id + resp = await api_0.nft_get_info(dict(coin_id=nft_coin_id.hex(), latest=True)) + assert resp["success"] + assert coins[0] == resp["nft_info"] + # Test set DID1 -> DID2 hex_did_id = did_wallet1.get_my_DID() hmr_did_id = encode_puzzle_hash(bytes32.from_hexstr(hex_did_id), DID_HRP) @@ -1245,6 +1249,9 @@ async def test_nft_set_did(two_wallet_nodes: Any, trusted: Any) -> None: assert len(coins) == 1 assert coins[0].owner_did.hex() == hex_did_id nft_coin_id = coins[0].nft_coin_id + resp = await api_0.nft_get_info(dict(coin_id=nft_coin_id.hex(), latest=True)) + assert resp["success"] + assert coins[0] == resp["nft_info"] # Test set DID2 -> None resp = await api_0.nft_set_nft_did(dict(wallet_id=nft_wallet_2_id, nft_coin_id=nft_coin_id.hex())) await make_new_block_with(resp, full_node_api, ph) @@ -1257,6 +1264,10 @@ async def test_nft_set_did(two_wallet_nodes: Any, trusted: Any) -> None: assert len(coins) == 1 assert coins[0].owner_did is None assert len(wallet_node_0.wallet_state_manager.wallets[nft_wallet_2_id].my_nft_coins) == 0 + nft_coin_id = coins[0].nft_coin_id + resp = await api_0.nft_get_info(dict(coin_id=nft_coin_id.hex(), latest=True)) + assert resp["success"] + assert coins[0] == resp["nft_info"] @pytest.mark.parametrize(