Skip to content

Commit

Permalink
Preserve the recording auth settings when temporarily switching to re…
Browse files Browse the repository at this point in the history
…cording auth.

Previously this didn't matter as we've only switched for the contract instantiation, but now the contract instantiation may run custom logic due to constructors, so we need to preserve the settings (currently only dissallowing non-root auth).
  • Loading branch information
dmkozh committed Dec 12, 2024
1 parent 31b2892 commit 3b9575c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ soroban-ledger-snapshot = { version = "22.0.2", path = "soroban-ledger-snapshot"
soroban-token-sdk = { version = "22.0.2", path = "soroban-token-sdk" }

[workspace.dependencies.soroban-env-common]
version = "=22.1.0"
version = "=22.1.1"
#git = "https://github.com/stellar/rs-soroban-env"
#rev = "bd0c80a1fe171e75f8d745f17975a73927d44ecd"

[workspace.dependencies.soroban-env-guest]
version = "=22.1.0"
version = "=22.1.1"
#git = "https://github.com/stellar/rs-soroban-env"
#rev = "bd0c80a1fe171e75f8d745f17975a73927d44ecd"

[workspace.dependencies.soroban-env-host]
version = "=22.1.0"
version = "=22.1.1"
#git = "https://github.com/stellar/rs-soroban-env"
#rev = "bd0c80a1fe171e75f8d745f17975a73927d44ecd"

Expand Down
8 changes: 6 additions & 2 deletions soroban-sdk/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,9 @@ impl Env {
.unwrap();

let prev_auth_manager = self.env_impl.snapshot_auth_manager().unwrap();
self.env_impl.switch_to_recording_auth(true).unwrap();
self.env_impl
.switch_to_recording_auth_inherited_from_snapshot(&prev_auth_manager)
.unwrap();
self.invoke_contract::<()>(
&token_id,
&soroban_sdk_macros::internal_symbol_short!("set_admin"),
Expand Down Expand Up @@ -1014,7 +1016,9 @@ impl Env {
constructor_args: Vec<Val>,
) -> Address {
let prev_auth_manager = self.env_impl.snapshot_auth_manager().unwrap();
self.env_impl.switch_to_recording_auth(true).unwrap();
self.env_impl
.switch_to_recording_auth_inherited_from_snapshot(&prev_auth_manager)
.unwrap();
let args_vec: std::vec::Vec<xdr::ScVal> =
constructor_args.iter().map(|v| v.into_val(self)).collect();
let contract_id: Address = self
Expand Down

0 comments on commit 3b9575c

Please sign in to comment.