Merge pull request #11991 from AmineKhaldi/minting_cli_did_ownership

Make the minting CLI default to an empty DID and allow the user to explicitly turn off DID ownership support
This commit is contained in:
Amine Khaldi
2022-06-22 13:00:37 +01:00
committed by GitHub
2 changed files with 19 additions and 0 deletions
+3
View File
@@ -511,6 +511,7 @@ def nft_wallet_create_cmd(
@click.option("-i", "--id", help="Id of the NFT wallet to use", type=int, required=True)
@click.option("-ra", "--royalty-address", help="Royalty address", type=str)
@click.option("-ta", "--target-address", help="Target address", type=str)
@click.option("--no-did-ownership", help="Disable DID ownership support", is_flag=True, default=False)
@click.option("-nh", "--hash", help="NFT content hash", type=str, required=True)
@click.option("-u", "--uris", help="Comma separated list of URIs", type=str, required=True)
@click.option("-mh", "--metadata-hash", help="NFT metadata hash", type=str, default="")
@@ -542,6 +543,7 @@ def nft_mint_cmd(
id: int,
royalty_address: Optional[str],
target_address: Optional[str],
no_did_ownership: bool,
hash: str,
uris: str,
metadata_hash: Optional[str],
@@ -570,6 +572,7 @@ def nft_mint_cmd(
"wallet_id": id,
"royalty_address": royalty_address,
"target_address": target_address,
"no_did_ownership": no_did_ownership,
"hash": hash,
"uris": [u.strip() for u in uris.split(",")],
"metadata_hash": metadata_hash,
+16
View File
@@ -708,6 +708,7 @@ async def mint_nft(args: Dict, wallet_client: WalletRpcClient, fingerprint: int)
wallet_id = args["wallet_id"]
royalty_address = args["royalty_address"]
target_address = args["target_address"]
no_did_ownership = args["no_did_ownership"]
hash = args["hash"]
uris = args["uris"]
metadata_hash = args["metadata_hash"]
@@ -719,6 +720,20 @@ async def mint_nft(args: Dict, wallet_client: WalletRpcClient, fingerprint: int)
fee: int = int(Decimal(args["fee"]) * units["chia"])
royalty_percentage = args["royalty_percentage"]
try:
response = await wallet_client.get_nft_wallet_did(wallet_id)
wallet_did = response["did_id"]
wallet_has_did = wallet_did is not None
did_id: Optional[str] = wallet_did
# Handle the case when the user wants to disable DID ownership
if no_did_ownership:
if wallet_has_did:
raise ValueError("Disabling DID ownership is not supported for this NFT wallet, it does have a DID")
else:
did_id = None
else:
if not wallet_has_did:
did_id = ""
response = await wallet_client.mint_nft(
wallet_id,
royalty_address,
@@ -733,6 +748,7 @@ async def mint_nft(args: Dict, wallet_client: WalletRpcClient, fingerprint: int)
series_number,
fee,
royalty_percentage,
did_id,
)
spend_bundle = response["spend_bundle"]
print(f"NFT minted Successfully with spend bundle: {spend_bundle}")