diff --git a/chia/cmds/wallet.py b/chia/cmds/wallet.py index 61ecab9371e6..7aa5d1b2d416 100644 --- a/chia/cmds/wallet.py +++ b/chia/cmds/wallet.py @@ -1164,10 +1164,12 @@ def nft_transfer_cmd( ) @click.option("-f", "--fingerprint", help="Set the fingerprint to specify which key to use", type=int) @click.option("-i", "--id", help="Id of the NFT wallet to use", type=int, required=True) -def nft_list_cmd(wallet_rpc_port: Optional[int], fingerprint: int, id: int) -> None: +@click.option("--num", help="Number of NFTs to return", type=int, default=50) +@click.option("--start-index", help="Which starting index to start listing NFTs from", type=int, default=0) +def nft_list_cmd(wallet_rpc_port: Optional[int], fingerprint: int, id: int, num: int, start_index: int) -> None: from .wallet_funcs import list_nfts - asyncio.run(list_nfts(wallet_rpc_port, fingerprint, id)) + asyncio.run(list_nfts(wallet_rpc_port, fingerprint, id, num, start_index)) @nft_cmd.command("set_did", help="Set a DID on an NFT") diff --git a/chia/cmds/wallet_funcs.py b/chia/cmds/wallet_funcs.py index f8ddc9c78f45..b79e1a83c827 100644 --- a/chia/cmds/wallet_funcs.py +++ b/chia/cmds/wallet_funcs.py @@ -1183,10 +1183,12 @@ def print_nft_info(nft: NFTInfo, *, config: Dict[str, Any]) -> None: print(f"{indent}{license_uri}") -async def list_nfts(wallet_rpc_port: Optional[int], fp: Optional[int], wallet_id: int) -> None: +async def list_nfts( + wallet_rpc_port: Optional[int], fp: Optional[int], wallet_id: int, num: int, start_index: int +) -> None: async with get_wallet_client(wallet_rpc_port, fp) as (wallet_client, fingerprint, config): try: - response = await wallet_client.list_nfts(wallet_id) + response = await wallet_client.list_nfts(wallet_id, num, start_index) nft_list = response["nft_list"] if len(nft_list) > 0: for n in nft_list: diff --git a/chia/rpc/wallet_rpc_client.py b/chia/rpc/wallet_rpc_client.py index 4e5cdf9d5c73..22408a44c098 100644 --- a/chia/rpc/wallet_rpc_client.py +++ b/chia/rpc/wallet_rpc_client.py @@ -1007,8 +1007,8 @@ async def count_nfts(self, wallet_id: Optional[int]): response = await self.fetch("nft_count_nfts", request) return response - async def list_nfts(self, wallet_id) -> dict[str, Any]: - request: Dict[str, Any] = {"wallet_id": wallet_id, "num": 100_000} + async def list_nfts(self, wallet_id, num: int = 50, start_index: int = 0): + request: Dict[str, Any] = {"wallet_id": wallet_id, "num": num, "start_index": start_index} response = await self.fetch("nft_get_nfts", request) return response