Merge release/1.4.0's d2dbb12 into main

This commit is contained in:
Amine Khaldi
2022-06-19 12:05:21 +01:00
2 changed files with 13 additions and 7 deletions
+9 -6
View File
@@ -1152,19 +1152,22 @@ class WalletRpcApi:
async def did_update_metadata(self, request):
wallet_id = int(request["wallet_id"])
wallet: DIDWallet = self.service.wallet_state_manager.wallets[wallet_id]
if wallet.type() != WalletType.DISTRIBUTED_ID.value:
return {"success": False, "error": f"Wallet with id {wallet_id} is not a DID one"}
metadata: Dict[str, str] = {}
success: bool = False
if "metadata" in request:
if type(request["metadata"]) is dict:
metadata = request["metadata"]
if "metadata" in request and type(request["metadata"]) is dict:
metadata = request["metadata"]
async with self.service.wallet_state_manager.lock:
update_success = await wallet.update_metadata(metadata)
# Update coin with new ID info
if update_success:
spend_bundle = await wallet.create_update_spend()
if spend_bundle is not None:
success = True
return {"success": success}
return {"wallet_id": wallet_id, "success": True, "spend_bundle": spend_bundle}
else:
return {"success": False, "error": "Couldn't create an update spend bundle."}
else:
return {"success": False, "error": f"Couldn't update metadata with input: {metadata}"}
async def did_get_did(self, request):
wallet_id = int(request["wallet_id"])
+4 -1
View File
@@ -745,6 +745,7 @@ async def test_did_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment):
wallet_2_node: WalletNode = env.wallet_2.node
wallet_1_rpc: WalletRpcClient = env.wallet_1.rpc_client
full_node_api: FullNodeSimulator = env.full_node.api
wallet_1_id = wallet_1.id()
await generate_funds(env.full_node.api, env.wallet_1, 5)
@@ -767,7 +768,7 @@ async def test_did_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment):
assert res["success"]
assert res["name"] == new_wallet_name
with pytest.raises(ValueError, match="Wallet id 1 is not a DID wallet"):
await wallet_1_rpc.did_set_wallet_name(wallet_1.id(), new_wallet_name)
await wallet_1_rpc.did_set_wallet_name(wallet_1_id, new_wallet_name)
# Check DID ID
res = await wallet_1_rpc.get_did_id(did_wallet_id_0)
@@ -791,6 +792,8 @@ async def test_did_endpoints(wallet_rpc_environment: WalletRpcTestEnvironment):
await farm_transaction_block(full_node_api, wallet_1_node)
# Update metadata
with pytest.raises(ValueError, match="Wallet with id 1 is not a DID one"):
await wallet_1_rpc.update_did_metadata(wallet_1_id, {"Twitter": "Https://test"})
res = await wallet_1_rpc.update_did_metadata(did_wallet_id_0, {"Twitter": "Https://test"})
assert res["success"]