diff --git a/primitives/stability-rpc-api/src/lib.rs b/primitives/stability-rpc-api/src/lib.rs index c7360d3a..044315f6 100644 --- a/primitives/stability-rpc-api/src/lib.rs +++ b/primitives/stability-rpc-api/src/lib.rs @@ -10,6 +10,8 @@ sp_api::decl_runtime_apis! { fn get_validator_list() -> Vec; + fn get_active_validator_list() -> Vec; + fn convert_sponsored_transaction(transaction: fp_ethereum::Transaction, meta_trx_sponsor: H160, meta_trx_sponsor_signature: Vec) -> ::Extrinsic; } } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 135d6ff4..4c4bf59e 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1546,6 +1546,16 @@ impl_runtime_apis! { } fn get_validator_list() -> Vec { + let validators = >::approved_validators(); + validators + .iter() + .map(|v| ::AccountIdMapping::into_evm_address(v)) + .collect() + + } + + + fn get_active_validator_list() -> Vec { let validators = >::validators(); validators .iter() diff --git a/stability-rpc/src/lib.rs b/stability-rpc/src/lib.rs index ba64c341..e93f12bd 100644 --- a/stability-rpc/src/lib.rs +++ b/stability-rpc/src/lib.rs @@ -34,6 +34,12 @@ pub trait StabilityRpcEndpoints { #[method(name = "stability_getValidatorList")] fn get_validator_list(&self, at: Option) -> RpcResult>>; + #[method(name = "stability_getActiveValidatorList")] + fn get_active_validator_list( + &self, + at: Option, + ) -> RpcResult>>; + #[method(name = "stability_sendSponsoredTransaction")] async fn send_sponsored_transaction( &self, @@ -99,6 +105,21 @@ where }) } + fn get_active_validator_list( + &self, + at: Option<::Hash>, + ) -> RpcResult>> { + let api = self.client.runtime_api(); + let at = at.unwrap_or_else(|| self.client.info().best_hash); + let value = api + .get_active_validator_list(at) + .map_err(runtime_error_into_rpc_err); + Ok(StabilityOutput { + code: 200, + value: value.unwrap(), + }) + } + async fn send_sponsored_transaction( &self, transaction: Bytes, @@ -132,7 +153,11 @@ where let transaction_hash = transaction.hash(); self.pool - .submit_one(&BlockId::Hash(block_hash), TransactionSource::Local, extrinsic) + .submit_one( + &BlockId::Hash(block_hash), + TransactionSource::Local, + extrinsic, + ) .map_ok(move |_| transaction_hash) .map_err(|e| { error::Error::Custom(format!("Unable to submit transaction: {:?}", e).into())