Skip to content

Commit

Permalink
Pool: added new_admin auth requirement for admin swaps
Browse files Browse the repository at this point in the history
  • Loading branch information
markuspluna committed Dec 21, 2023
1 parent 8f41dff commit 71d980d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions pool/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ impl Pool for PoolContract {
storage::extend_instance(&e);
let admin = storage::get_admin(&e);
admin.require_auth();
new_admin.require_auth();

storage::set_admin(&e, &new_admin);

Expand Down
2 changes: 1 addition & 1 deletion pool/src/pool/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ mod tests {
let (reserve_config, reserve_data) = testutils::default_reserve_meta();
testutils::create_reserve(&e, &pool, &underlying_0, &reserve_config, &reserve_data);

let (underlying_1, underlying_1_client) = testutils::create_token_contract(&e, &bombadil);
let (underlying_1, _) = testutils::create_token_contract(&e, &bombadil);
let (reserve_config, reserve_data) = testutils::default_reserve_meta();
testutils::create_reserve(&e, &pool, &underlying_1, &reserve_config, &reserve_data);

Expand Down
14 changes: 14 additions & 0 deletions test-suites/tests/test_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,20 @@ fn test_pool_config() {
}
)
);
assert_eq!(
fixture.env.auths()[1],
(
new_admin.clone(),
AuthorizedInvocation {
function: AuthorizedFunction::Contract((
pool_fixture.pool.address.clone(),
Symbol::new(&fixture.env, "set_admin"),
vec![&fixture.env, new_admin.to_val(),]
)),
sub_invocations: std::vec![]
}
)
);
let event = vec![&fixture.env, fixture.env.events().all().last_unchecked()];
assert_eq!(
event,
Expand Down

0 comments on commit 71d980d

Please sign in to comment.