Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion admin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct Contract;

#[contractimpl]
impl Contract {
pub fn __constructor(env: &Env, admin: Address) {
pub fn __constructor(env: &Env, admin: &Address) {
Self::set_admin(env, admin);
}
}
Expand Down
4 changes: 2 additions & 2 deletions admin_sep/src/administratable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ pub trait Administratable {
unsafe { admin_from_storage(env).unwrap_unchecked() }
}

fn set_admin(env: &Env, new_admin: soroban_sdk::Address) {
fn set_admin(env: &Env, new_admin: &soroban_sdk::Address) {
if let Some(owner) = admin_from_storage(env) {
owner.require_auth();
}
env.storage().instance().set(STORAGE_KEY, &new_admin);
env.storage().instance().set(STORAGE_KEY, new_admin);
}
}

Expand Down
5 changes: 3 additions & 2 deletions admin_sep/src/upgradable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use soroban_sdk::contracttrait;
pub trait Upgradable: AdministratableExtension {
/// Upgrades the contract to a new hash.
/// Admin Only.
fn upgrade(env: &soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>) {
fn upgrade(env: &soroban_sdk::Env, new_wasm_hash: &soroban_sdk::BytesN<32>) {
Self::require_admin(env);
env.deployer().update_current_contract_wasm(new_wasm_hash);
env.deployer()
.update_current_contract_wasm(new_wasm_hash.clone());
}
}
2 changes: 1 addition & 1 deletion admin_v2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct Contract;

#[contractimpl]
impl Contract {
pub fn __constructor(env: &Env, admin: Address) {
pub fn __constructor(env: &Env, admin: &Address) {
Self::set_admin(env, admin);
}

Expand Down
4 changes: 2 additions & 2 deletions admin_v2/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use soroban_sdk::{Address, Env, testutils::Address as _};
#[test]
fn test() {
let env = Env::default();
let admin = Address::generate(&env);
let contract_id = env.register(Contract, (admin.clone(),));
let admin = &Address::generate(&env);
let contract_id = env.register(Contract, (admin,));
let _client = ContractClient::new(&env, &contract_id);

// assert_eq!(client.increment(), 2);
Expand Down