Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

update eth2-pallet-init/substrate_pallet_client.rs get_client_mode #46

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions crates/eth2-pallet-init/src/substrate_pallet_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ pub fn convert_typed_chain_ids(
}
}

pub fn convert_mode(t: tangle::runtime_types::eth_types::pallet::ClientMode) -> ClientMode {
match t {
tangle::runtime_types::eth_types::pallet::ClientMode::SubmitLightClientUpdate =>
ClientMode::SubmitLightClientUpdate,
tangle::runtime_types::eth_types::pallet::ClientMode::SubmitHeader =>
ClientMode::SubmitHeader,
}
}

pub async fn setup_api() -> anyhow::Result<OnlineClient<PolkadotConfig>> {
let api: OnlineClient<PolkadotConfig> = OnlineClient::<PolkadotConfig>::new().await?;
Ok(api)
Expand Down Expand Up @@ -357,11 +366,15 @@ impl EthClientPalletTrait for EthClientPallet {
}

async fn get_client_mode(&self) -> anyhow::Result<ClientMode> {
Err(std::io::Error::new(
std::io::ErrorKind::Other,
"Unable to get value for get_client_mode".to_string(),
)
.into())
let addr = tangle::storage()
.eth2_client()
.client_mode_for_chain(convert_typed_chain_ids(self.chain));

if let Some(mode) = self.get_value(&addr).await? {
Ok(convert_mode(mode))
} else {
Ok(ClientMode::SubmitLightClientUpdate)
}
}

async fn get_last_block_number(&self) -> anyhow::Result<u64> {
Expand Down
Loading