mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-09-21 00:24:37 +03:00
use WalletStateManager.get_wallet() in wallet_rpc_api (#15334)
This commit is contained in:
parent
c45875d517
commit
526310374f
@ -2385,13 +2385,13 @@ class WalletRpcApi:
|
|||||||
coin_ids = []
|
coin_ids = []
|
||||||
nft_ids = []
|
nft_ids = []
|
||||||
fee = uint64(request.get("fee", 0))
|
fee = uint64(request.get("fee", 0))
|
||||||
|
nft_wallet: NFTWallet
|
||||||
for nft_coin in request["nft_coin_list"]:
|
for nft_coin in request["nft_coin_list"]:
|
||||||
if "nft_coin_id" not in nft_coin or "wallet_id" not in nft_coin:
|
if "nft_coin_id" not in nft_coin or "wallet_id" not in nft_coin:
|
||||||
log.error(f"Cannot set DID for NFT :{nft_coin}, missing nft_coin_id or wallet_id.")
|
log.error(f"Cannot set DID for NFT :{nft_coin}, missing nft_coin_id or wallet_id.")
|
||||||
continue
|
continue
|
||||||
wallet_id = uint32(nft_coin["wallet_id"])
|
wallet_id = uint32(nft_coin["wallet_id"])
|
||||||
nft_wallet = self.service.wallet_state_manager.wallets[wallet_id]
|
nft_wallet = self.service.wallet_state_manager.get_wallet(id=wallet_id, required_type=NFTWallet)
|
||||||
assert isinstance(nft_wallet, NFTWallet)
|
|
||||||
nft_coin_id = nft_coin["nft_coin_id"]
|
nft_coin_id = nft_coin["nft_coin_id"]
|
||||||
if nft_coin_id.startswith(AddressType.NFT.hrp(self.service.config)):
|
if nft_coin_id.startswith(AddressType.NFT.hrp(self.service.config)):
|
||||||
nft_id = decode_puzzle_hash(nft_coin_id)
|
nft_id = decode_puzzle_hash(nft_coin_id)
|
||||||
@ -2413,8 +2413,7 @@ class WalletRpcApi:
|
|||||||
first = True
|
first = True
|
||||||
nft_wallet = None
|
nft_wallet = None
|
||||||
for wallet_id, nft_list in nft_dict.items():
|
for wallet_id, nft_list in nft_dict.items():
|
||||||
nft_wallet = self.service.wallet_state_manager.wallets[wallet_id]
|
nft_wallet = self.service.wallet_state_manager.get_wallet(id=wallet_id, required_type=NFTWallet)
|
||||||
assert isinstance(nft_wallet, NFTWallet)
|
|
||||||
if not first:
|
if not first:
|
||||||
tx_list.extend(await nft_wallet.set_bulk_nft_did(nft_list, did_id))
|
tx_list.extend(await nft_wallet.set_bulk_nft_did(nft_list, did_id))
|
||||||
else:
|
else:
|
||||||
@ -2474,13 +2473,13 @@ class WalletRpcApi:
|
|||||||
tx_list: List[TransactionRecord] = []
|
tx_list: List[TransactionRecord] = []
|
||||||
coin_ids = []
|
coin_ids = []
|
||||||
fee = uint64(request.get("fee", 0))
|
fee = uint64(request.get("fee", 0))
|
||||||
|
nft_wallet: NFTWallet
|
||||||
for nft_coin in request["nft_coin_list"]:
|
for nft_coin in request["nft_coin_list"]:
|
||||||
if "nft_coin_id" not in nft_coin or "wallet_id" not in nft_coin:
|
if "nft_coin_id" not in nft_coin or "wallet_id" not in nft_coin:
|
||||||
log.error(f"Cannot transfer NFT :{nft_coin}, missing nft_coin_id or wallet_id.")
|
log.error(f"Cannot transfer NFT :{nft_coin}, missing nft_coin_id or wallet_id.")
|
||||||
continue
|
continue
|
||||||
wallet_id = uint32(nft_coin["wallet_id"])
|
wallet_id = uint32(nft_coin["wallet_id"])
|
||||||
nft_wallet = self.service.wallet_state_manager.wallets[wallet_id]
|
nft_wallet = self.service.wallet_state_manager.get_wallet(id=wallet_id, required_type=NFTWallet)
|
||||||
assert isinstance(nft_wallet, NFTWallet)
|
|
||||||
nft_coin_id = nft_coin["nft_coin_id"]
|
nft_coin_id = nft_coin["nft_coin_id"]
|
||||||
if nft_coin_id.startswith(AddressType.NFT.hrp(self.service.config)):
|
if nft_coin_id.startswith(AddressType.NFT.hrp(self.service.config)):
|
||||||
nft_id = decode_puzzle_hash(nft_coin_id)
|
nft_id = decode_puzzle_hash(nft_coin_id)
|
||||||
@ -2496,8 +2495,7 @@ class WalletRpcApi:
|
|||||||
first = True
|
first = True
|
||||||
nft_wallet = None
|
nft_wallet = None
|
||||||
for wallet_id, nft_list in nft_dict.items():
|
for wallet_id, nft_list in nft_dict.items():
|
||||||
nft_wallet = self.service.wallet_state_manager.wallets[wallet_id]
|
nft_wallet = self.service.wallet_state_manager.get_wallet(id=wallet_id, required_type=NFTWallet)
|
||||||
assert isinstance(nft_wallet, NFTWallet)
|
|
||||||
if not first:
|
if not first:
|
||||||
tx_list.extend(await nft_wallet.bulk_transfer_nft(nft_list, puzzle_hash))
|
tx_list.extend(await nft_wallet.bulk_transfer_nft(nft_list, puzzle_hash))
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user