Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly determine proxy contract when joining #995

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions crates/context/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,6 @@ impl ContextManager {
PrivateKey::random(&mut rand::thread_rng())
}

async fn get_proxy_contract(&self, context_id: ContextId) -> EyreResult<String> {
let proxy_contract = self
.config_client
.query::<ContextConfigEnv>(
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(),
)
.get_proxy_contract(context_id.rt().expect("infallible conversion"))
.await?;
Ok(proxy_contract)
}

pub fn create_context(
&self,
seed: Option<[u8; 32]>,
Expand Down Expand Up @@ -253,7 +240,15 @@ impl ContextManager {
.send(*context_secret)
.await?;

let proxy_contract = this.get_proxy_contract(context.id).await?;
let proxy_contract = this
.config_client
.query::<ContextConfigEnv>(
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(),
)
.get_proxy_contract(context.id.rt().expect("infallible conversion"))
.await?;

let key = ContextConfigKey::new(context.id);
let mut config = handle.get(&key)?.ok_or_eyre("expected config to exist")?;
Expand Down Expand Up @@ -355,7 +350,16 @@ impl ContextManager {

let context_exists = handle.has(&ContextMetaKey::new(context_id))?;
let mut config = if !context_exists {
let proxy_contract = self.get_proxy_contract(context_id).await?;
let proxy_contract = self
.config_client
.query::<ContextConfigEnv>(
protocol.as_str().into(),
network_id.as_str().into(),
contract_id.as_str().into(),
)
.get_proxy_contract(context_id.rt().expect("infallible conversion"))
.await?;

Some(ContextConfigParams {
protocol: protocol.into(),
network_id: network_id.into(),
Expand Down