From 71d980dd82e9bcbbd483d1ec13abf0965f18bd49 Mon Sep 17 00:00:00 2001 From: markuspluna <59978114+markuspluna@users.noreply.github.com> Date: Thu, 21 Dec 2023 17:31:43 -0600 Subject: [PATCH] Pool: added new_admin auth requirement for admin swaps --- pool/src/contract.rs | 1 + pool/src/pool/submit.rs | 2 +- test-suites/tests/test_pool.rs | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pool/src/contract.rs b/pool/src/contract.rs index 8876d7e7..eaa561f4 100644 --- a/pool/src/contract.rs +++ b/pool/src/contract.rs @@ -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); diff --git a/pool/src/pool/submit.rs b/pool/src/pool/submit.rs index a809bbb8..4b93a4ec 100644 --- a/pool/src/pool/submit.rs +++ b/pool/src/pool/submit.rs @@ -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); diff --git a/test-suites/tests/test_pool.rs b/test-suites/tests/test_pool.rs index 61d0cc95..9f76c99d 100644 --- a/test-suites/tests/test_pool.rs +++ b/test-suites/tests/test_pool.rs @@ -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,