Merge pull request #11460 from AmineKhaldi/did_get_did_cmd

Initial iteration of the chia wallet did get_did command
This commit is contained in:
William Allen
2022-06-06 15:57:25 -05:00
committed by GitHub
2 changed files with 30 additions and 0 deletions
+18
View File
@@ -455,6 +455,24 @@ def did_wallet_name_cmd(wallet_rpc_port: Optional[int], fingerprint: int, id: in
asyncio.run(execute_with_wallet(wallet_rpc_port, fingerprint, extra_params, did_set_wallet_name))
@did_cmd.command("get_did", short_help="Get DID from wallet")
@click.option(
"-wp",
"--wallet-rpc-port",
help="Set the port where the Wallet is hosting the RPC interface. See the rpc_port under wallet in config.yaml",
type=int,
default=None,
)
@click.option("-f", "--fingerprint", help="Set the fingerprint to specify which wallet to use", type=int)
@click.option("-i", "--id", help="Id of the wallet to use", type=int, required=True)
def did_get_did_cmd(wallet_rpc_port: Optional[int], fingerprint: int, id: int) -> None:
import asyncio
from .wallet_funcs import execute_with_wallet, get_did
extra_params = {"did_wallet_id": id}
asyncio.run(execute_with_wallet(wallet_rpc_port, fingerprint, extra_params, get_did))
@wallet_cmd.group("nft", short_help="NFT related actions")
def nft_cmd():
pass
+12
View File
@@ -669,6 +669,18 @@ async def did_set_wallet_name(args: Dict, wallet_client: WalletRpcClient, finger
print(f"Failed to set DID wallet name: {e}")
async def get_did(args: Dict, wallet_client: WalletRpcClient, fingerprint: int) -> None:
did_wallet_id: int = args["did_wallet_id"]
try:
response = await wallet_client.get_did_id(did_wallet_id)
my_did = response["my_did"]
coin_id = response["coin_id"]
print(f"{'DID:'.ljust(23)} {my_did}")
print(f"{'Coin ID:'.ljust(23)} {coin_id}")
except Exception as e:
print(f"Failed to get DID: {e}")
async def create_nft_wallet(args: Dict, wallet_client: WalletRpcClient, fingerprint: int) -> None:
try:
response = await wallet_client.create_new_nft_wallet(None)