diff --git a/CHANGELOG.md b/CHANGELOG.md index df6e69122..ec958f569 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,6 +74,10 @@ Those changes in added, changed or breaking changes, should include usage exampl .await .unwrap(); ``` +* Added new method `is_operator_set_quorum` in `avsregistry/writer` in [#296](https://github.com/Layr-Labs/eigensdk-rs/pull/296). + ```rust + let operator_set_quourm = avs_reader.is_operator_set_quorum(0).await.unwrap(); + ``` ### Changed * Changes in the way bindings are generated in [#243](https://github.com/Layr-Labs/eigensdk-rs/pull/243). diff --git a/crates/chainio/clients/avsregistry/src/reader.rs b/crates/chainio/clients/avsregistry/src/reader.rs index 9bf245930..01539caa4 100644 --- a/crates/chainio/clients/avsregistry/src/reader.rs +++ b/crates/chainio/clients/avsregistry/src/reader.rs @@ -11,7 +11,7 @@ use eigen_crypto_bls::{ }; use eigen_logging::logger::SharedLogger; use eigen_types::operator::{ - bitmap_to_quorum_ids, bitmap_to_quorum_ids_from_u192, OperatorPubKeys, + bitmap_to_quorum_ids, bitmap_to_quorum_ids_from_u192, OperatorPubKeys, QuorumNum, }; use eigen_utils::slashing::middleware::blsapkregistry::BLSApkRegistry; @@ -627,6 +627,31 @@ impl AvsRegistryChainReader { } Ok(operator_id_to_socket) } + + /// Check if a quorum is an operator set quorum + /// + /// # Arguments + /// * `quorum_number` - The quorum number to query. + /// + /// # Returns + /// [`true`] if the quorum is an operator set quorum, [`false`] otherwise. + pub async fn is_operator_set_quorum( + &self, + quorum_number: QuorumNum, + ) -> Result { + let provider = get_provider(&self.provider); + + let contract_stake_registry = StakeRegistry::new(self.stake_registry_addr, &provider); + + let quorum_status = contract_stake_registry + .isOperatorSetQuorum(quorum_number) + .call() + .await?; + + let StakeRegistry::isOperatorSetQuorumReturn { _0: quorum_status } = quorum_status; + + Ok(quorum_status) + } } #[cfg(test)] @@ -824,4 +849,14 @@ mod tests { .unwrap(); assert!(!is_registered); } + + #[tokio::test] + async fn test_is_operator_set_quorum() { + let (_container, http_endpoint, _ws_endpoint) = start_anvil_container().await; + let avs_reader = build_avs_registry_chain_reader(http_endpoint.clone()).await; + + let operator_set_quourm = avs_reader.is_operator_set_quorum(0).await.unwrap(); + + assert!(operator_set_quourm); + } }