diff --git a/crates/context/src/lib.rs b/crates/context/src/lib.rs index e57bf8b7e..48785c3a6 100644 --- a/crates/context/src/lib.rs +++ b/crates/context/src/lib.rs @@ -850,9 +850,7 @@ impl ContextManager { bail!("Context not found") }; - let this = self.clone(); - - let Some(application) = this.get_application(&application_id)? else { + let Some(application) = self.get_application(&application_id)? else { bail!("Application with id {:?} not found", application_id) }; @@ -860,22 +858,18 @@ impl ContextManager { private_key: Some(requester_secret), }) = handle.get(&ContextIdentityKey::new(context_id, signer_id))? else { - bail!( - "Identity {:?} not found in context {:?}", - signer_id, - context_id - ) + bail!("'{}' is not a member of '{}'", signer_id, context_id) }; - let _ = this + let _ = self .config_client .mutate::( - this.client_config.new.protocol.as_str().into(), - this.client_config.new.network.as_str().into(), - this.client_config.new.contract_id.as_str().into(), + self.client_config.new.protocol.as_str().into(), + self.client_config.new.network.as_str().into(), + self.client_config.new.contract_id.as_str().into(), ) .update_application( - context_id.rt().expect("bla"), + context_id.rt().expect("infallible conversion"), ApplicationConfig::new( application.id.rt().expect("infallible conversion"), application.blob.rt().expect("infallible conversion"), diff --git a/crates/meroctl/src/cli/context/create.rs b/crates/meroctl/src/cli/context/create.rs index e4e835a1c..ecca61dcf 100644 --- a/crates/meroctl/src/cli/context/create.rs +++ b/crates/meroctl/src/cli/context/create.rs @@ -1,6 +1,7 @@ use calimero_primitives::application::ApplicationId; use calimero_primitives::context::ContextId; use calimero_primitives::hash::Hash; +use calimero_primitives::identity::PublicKey; use calimero_server_primitives::admin::{ CreateContextRequest, CreateContextResponse, GetApplicationResponse, InstallApplicationResponse, InstallDevApplicationRequest, UpdateContextApplicationRequest, @@ -118,7 +119,7 @@ impl CreateCommand { ) .await?; - let context_id = create_context( + let (context_id, member_public_key) = create_context( environment, &client, multiaddr, @@ -137,6 +138,7 @@ impl CreateCommand { path, metadata, &config.identity, + member_public_key, ) .await?; } @@ -155,7 +157,7 @@ async fn create_context( application_id: ApplicationId, params: Option, keypair: &Keypair, -) -> EyreResult { +) -> EyreResult<(ContextId, PublicKey)> { if !app_installed(base_multiaddr, &application_id, client, keypair).await? { bail!("Application is not installed on node.") } @@ -172,7 +174,7 @@ async fn create_context( environment.output.write(&response); - Ok(response.data.context_id) + Ok((response.data.context_id, response.data.member_public_key)) } async fn watch_app_and_update_context( @@ -183,6 +185,7 @@ async fn watch_app_and_update_context( path: Utf8PathBuf, metadata: Option>, keypair: &Keypair, + member_public_key: PublicKey, ) -> EyreResult<()> { let (tx, mut rx) = mpsc::channel(1); @@ -240,6 +243,7 @@ async fn watch_app_and_update_context( context_id, application_id, keypair, + member_public_key, ) .await?; } @@ -254,15 +258,14 @@ async fn update_context_application( context_id: ContextId, application_id: ApplicationId, keypair: &Keypair, + member_public_key: PublicKey, ) -> EyreResult<()> { let url = multiaddr_to_url( base_multiaddr, &format!("admin-api/dev/contexts/{context_id}/application"), )?; - //How to make conversion from libp2p to public key - let public_key = keypair.public(); - let request = UpdateContextApplicationRequest::new(application_id, public_key); + let request = UpdateContextApplicationRequest::new(application_id, member_public_key); let response: UpdateContextApplicationResponse = do_request(client, url, Some(request), keypair, RequestType::Post).await?;