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

Check model exists on sozo auth #1644

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Update bin/sozo/src/ops/auth.rs
Co-authored-by: glihm <dev@glihm.net>
  • Loading branch information
remybar and glihm authored Mar 13, 2024
commit 1ab0372227caeb372996ef090b85626b56f284df
2 changes: 1 addition & 1 deletion bin/sozo/src/ops/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,36 @@

let account = account.account(&provider, env_metadata.as_ref()).await?;
let world = WorldContract::new(world_address, &account);
let world_reader = WorldContractReader::new(world_address, &provider)
.with_block(BlockId::Tag(BlockTag::Pending));

Check warning on line 23 in bin/sozo/src/ops/auth.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/ops/auth.rs#L22-L23

Added lines #L22 - L23 were not covered by tests

let mut calls = Vec::new();

for mc in models_contracts {
let model_name = parse_cairo_short_string(&mc.model)?;

Check warning on line 28 in bin/sozo/src/ops/auth.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/ops/auth.rs#L28

Added line #L28 was not covered by tests

if world_reader.model_reader(&model_name).await.is_ok() {
let contract = get_contract_address(&world, mc.contract).await?;
calls.push(world.grant_writer_getcall(&mc.model, &contract.into()));
} else {
println!("[WARN] Unknown model '{}' => IGNORED", model_name);
println!("Unknown model '{}' => IGNORED", model_name);
}

Check warning on line 35 in bin/sozo/src/ops/auth.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/ops/auth.rs#L30-L35

Added lines #L30 - L35 were not covered by tests
}

if !calls.is_empty() {
let res = account
.execute(calls)
.send()
.await
.with_context(|| "Failed to send transaction")?;

Check warning on line 43 in bin/sozo/src/ops/auth.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/ops/auth.rs#L38-L43

Added lines #L38 - L43 were not covered by tests

if transaction.wait {
let receipt =
TransactionWaiter::new(res.transaction_hash, &provider).await?;
println!("{}", serde_json::to_string_pretty(&receipt)?);
} else {
println!("Transaction hash: {:#x}", res.transaction_hash);
}

Check warning on line 51 in bin/sozo/src/ops/auth.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/ops/auth.rs#L45-L51

Added lines #L45 - L51 were not covered by tests
}
}
AuthKind::Owner { owners_resources } => {
Expand Down
Loading