Skip to content

Commit

Permalink
Update getCommittee epoch query parameter (#2179)
Browse files Browse the repository at this point in the history
* Update getCommittee epoch query parameter

* Update client method handler
  • Loading branch information
Thoralf-M authored Mar 14, 2024
1 parent 89d20d3 commit 9c36a7c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions bindings/core/src/method/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,9 @@ pub enum ClientMethod {
},
/// Return the information of committee members at the given epoch index. If epoch index is not provided, the
/// current committee members are returned.
#[serde(rename_all = "camelCase")]
GetCommittee {
/// The epoch index to query.
epoch_index: Option<EpochIndex>,
epoch: Option<EpochIndex>,
},
/// Get issuance
GetIssuance,
Expand Down
2 changes: 1 addition & 1 deletion bindings/core/src/method_handler/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pub(crate) async fn call_client_method_internal(
Response::Validators(client.get_validators(page_size, cursor).await?)
}
ClientMethod::GetValidator { account_id } => Response::Validator(client.get_validator(&account_id).await?),
ClientMethod::GetCommittee { epoch_index } => Response::Committee(client.get_committee(epoch_index).await?),
ClientMethod::GetCommittee { epoch } => Response::Committee(client.get_committee(epoch).await?),
ClientMethod::GetIssuance => Response::Issuance(client.get_issuance().await?),
ClientMethod::PostBlockRaw { block_bytes } => Response::BlockId(
client
Expand Down
6 changes: 3 additions & 3 deletions bindings/nodejs/lib/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,13 @@ export class Client {
/**
* Returns the information of committee members at the given epoch index. If epoch index is not provided, the
* current committee members are returned.
* GET /api/core/v3/committee/?epochIndex
* GET /api/core/v3/committee/?epoch
*/
async getCommittee(epochIndex?: EpochIndex): Promise<CommitteeResponse> {
async getCommittee(epoch?: EpochIndex): Promise<CommitteeResponse> {
const response = await this.methodHandler.callMethod({
name: 'getCommittee',
data: {
epochIndex,
epoch,
},
});

Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/lib/types/client/bridge/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export interface __GetValidatorMethod__ {
export interface __GetCommitteeMethod__ {
name: 'getCommittee';
data: {
epochIndex?: EpochIndex;
epoch?: EpochIndex;
};
}

Expand Down
6 changes: 3 additions & 3 deletions bindings/python/iota_sdk/client/_node_core_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ def get_validator(self, account_id: HexStr) -> ValidatorResponse:
# Committee routes.

def get_committee(
self, epoch_index: Optional[EpochIndex] = None) -> CommitteeResponse:
self, epoch: Optional[EpochIndex] = None) -> CommitteeResponse:
"""Returns the information of committee members at the given epoch index. If epoch index is not provided, the
current committee members are returned.
GET /api/core/v3/committee/?epochIndex
GET /api/core/v3/committee/?epoch
"""
return CommitteeResponse.from_dict(self._call_method('getCommittee', {
'epochIndex': epoch_index
'epoch': epoch
}))

# Block routes.
Expand Down
6 changes: 3 additions & 3 deletions sdk/src/client/node_api/core/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ impl Client {

/// Returns the information of committee members at the given epoch index. If epoch index is not provided, the
/// current committee members are returned.
/// GET /api/core/v3/committee/?epochIndex
/// GET /api/core/v3/committee/?epoch
pub async fn get_committee(
&self,
epoch_index: impl Into<Option<EpochIndex>> + Send,
epoch: impl Into<Option<EpochIndex>> + Send,
) -> Result<CommitteeResponse, ClientError> {
const PATH: &str = "api/core/v3/committee";
let query = query_tuples_to_query_string([epoch_index.into().map(|i| ("epochIndex", i.to_string()))]);
let query = query_tuples_to_query_string([epoch.into().map(|i| ("epoch", i.to_string()))]);

self.get_request(PATH, query.as_deref(), false).await
}
Expand Down

0 comments on commit 9c36a7c

Please sign in to comment.