File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -600,6 +600,14 @@ impl CreatorKeysContract {
600600 env. storage ( ) . persistent ( ) . get ( & DataKey :: AdminAddress )
601601 }
602602
603+ /// Read-only view: returns whether protocol configuration has been initialized.
604+ ///
605+ /// Returns `true` once a protocol fee configuration has been stored and `false`
606+ /// otherwise. Does not mutate contract state.
607+ pub fn is_protocol_config_initialized ( env : Env ) -> bool {
608+ read_protocol_fee_config ( & env) . is_some ( )
609+ }
610+
603611 /// Read-only view: returns the current protocol fee configuration.
604612 ///
605613 /// Returns a stable [`ProtocolFeeView`] regardless of whether a fee config has been set.
Original file line number Diff line number Diff line change 1+ //! Tests for the is_protocol_config_initialized read-only method.
2+
3+ use creator_keys:: { CreatorKeysContract , CreatorKeysContractClient } ;
4+ use soroban_sdk:: { testutils:: Address as _, Env } ;
5+
6+ #[ test]
7+ fn test_is_protocol_config_initialized_returns_true_after_fee_config_is_set ( ) {
8+ let env = Env :: default ( ) ;
9+ env. mock_all_auths ( ) ;
10+
11+ let contract_id = env. register ( CreatorKeysContract , ( ) ) ;
12+ let client = CreatorKeysContractClient :: new ( & env, & contract_id) ;
13+ let admin = soroban_sdk:: Address :: generate ( & env) ;
14+
15+ client. set_fee_config ( & admin, & 9000u32 , & 1000u32 ) ;
16+
17+ assert ! ( client. is_protocol_config_initialized( ) ) ;
18+ }
19+
20+ #[ test]
21+ fn test_is_protocol_config_initialized_is_read_only ( ) {
22+ let env = Env :: default ( ) ;
23+ env. mock_all_auths ( ) ;
24+
25+ let contract_id = env. register ( CreatorKeysContract , ( ) ) ;
26+ let client = CreatorKeysContractClient :: new ( & env, & contract_id) ;
27+ let admin = soroban_sdk:: Address :: generate ( & env) ;
28+
29+ client. set_fee_config ( & admin, & 8000u32 , & 2000u32 ) ;
30+
31+ let first_read = client. is_protocol_config_initialized ( ) ;
32+ let second_read = client. is_protocol_config_initialized ( ) ;
33+
34+ assert_eq ! ( first_read, second_read) ;
35+ assert ! ( first_read) ;
36+ }
You can’t perform that action at this time.
0 commit comments