Skip to content

Commit 0cda3ef

Browse files
feat: new method is_operator_set_quorum (#296)
### What Changed? Add new method `is_operator_set_quorum` to `avsregistry/reader` as this method was missing in the SDK. Closes #272 ### Reviewer Checklist - [ ] New features are tested and documented - [ ] PR updates the changelog with a description of changes - [ ] PR has one of the `changelog-X` labels (if applies) - [ ] Code deprecates any old functionality before removing it --------- Co-authored-by: Tomás Grüner <[email protected]>
1 parent f717f43 commit 0cda3ef

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ Those changes in added, changed or breaking changes, should include usage exampl
7474
.await
7575
.unwrap();
7676
```
77+
* Added new method `is_operator_set_quorum` in `avsregistry/writer` in [#296](https://github.com/Layr-Labs/eigensdk-rs/pull/296).
78+
```rust
79+
let operator_set_quourm = avs_reader.is_operator_set_quorum(0).await.unwrap();
80+
```
7781

7882
### Changed
7983
* Changes in the way bindings are generated in [#243](https://github.com/Layr-Labs/eigensdk-rs/pull/243).

crates/chainio/clients/avsregistry/src/reader.rs

+36-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use eigen_crypto_bls::{
1111
};
1212
use eigen_logging::logger::SharedLogger;
1313
use eigen_types::operator::{
14-
bitmap_to_quorum_ids, bitmap_to_quorum_ids_from_u192, OperatorPubKeys,
14+
bitmap_to_quorum_ids, bitmap_to_quorum_ids_from_u192, OperatorPubKeys, QuorumNum,
1515
};
1616

1717
use eigen_utils::slashing::middleware::blsapkregistry::BLSApkRegistry;
@@ -627,6 +627,31 @@ impl AvsRegistryChainReader {
627627
}
628628
Ok(operator_id_to_socket)
629629
}
630+
631+
/// Check if a quorum is an operator set quorum
632+
///
633+
/// # Arguments
634+
/// * `quorum_number` - The quorum number to query.
635+
///
636+
/// # Returns
637+
/// [`true`] if the quorum is an operator set quorum, [`false`] otherwise.
638+
pub async fn is_operator_set_quorum(
639+
&self,
640+
quorum_number: QuorumNum,
641+
) -> Result<bool, AvsRegistryError> {
642+
let provider = get_provider(&self.provider);
643+
644+
let contract_stake_registry = StakeRegistry::new(self.stake_registry_addr, &provider);
645+
646+
let quorum_status = contract_stake_registry
647+
.isOperatorSetQuorum(quorum_number)
648+
.call()
649+
.await?;
650+
651+
let StakeRegistry::isOperatorSetQuorumReturn { _0: quorum_status } = quorum_status;
652+
653+
Ok(quorum_status)
654+
}
630655
}
631656

632657
#[cfg(test)]
@@ -824,4 +849,14 @@ mod tests {
824849
.unwrap();
825850
assert!(!is_registered);
826851
}
852+
853+
#[tokio::test]
854+
async fn test_is_operator_set_quorum() {
855+
let (_container, http_endpoint, _ws_endpoint) = start_anvil_container().await;
856+
let avs_reader = build_avs_registry_chain_reader(http_endpoint.clone()).await;
857+
858+
let operator_set_quourm = avs_reader.is_operator_set_quorum(0).await.unwrap();
859+
860+
assert!(operator_set_quourm);
861+
}
827862
}

0 commit comments

Comments
 (0)