Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBC gRPC fix #278

Merged
merged 3 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
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
51 changes: 51 additions & 0 deletions src/ibc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,57 @@
Ok(self.transfer_mut().incoming_transfer_mut().take())
}

pub fn update_client_from_header(
&mut self,
client_index: u64,
rev_number: u64,
header_json: &str,
) -> crate::Result<()> {
let client_id: ClientId = ClientId::new("07-tendermint", client_index).unwrap();
let header: orga::cosmrs::tendermint::block::Header = serde_json::from_str(header_json)?;
let mut client = self
.ctx
.clients
.get_mut(client_id.into())?
.ok_or(Error::Ibc("Client not found".to_string()))?;
let height = Height::new(rev_number, header.height.value()).unwrap();
client.updates.insert(
height.into(),
(
WrappedTimestamp {
inner: header.time.try_into().unwrap(),
},
height.into(),
),
)?;

Check warning on line 229 in src/ibc/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/ibc/mod.rs#L207-L229

Added lines #L207 - L229 were not covered by tests

let consensus_state = WrappedConsensusState {
inner: header.into(),
};

Check warning on line 233 in src/ibc/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/ibc/mod.rs#L231-L233

Added lines #L231 - L233 were not covered by tests

let mut client_state = client
.client_state
.get(Default::default())?
.ok_or(Error::Ibc("Client not found".to_string()))?

Check warning on line 238 in src/ibc/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/ibc/mod.rs#L235-L238

Added lines #L235 - L238 were not covered by tests
.inner
.inner()
.clone();

client_state.latest_height = height;
client.client_state.insert(
Default::default(),
WrappedClientState {
inner: client_state.into(),
},
)?;

Check warning on line 249 in src/ibc/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/ibc/mod.rs#L240-L249

Added lines #L240 - L249 were not covered by tests

client
.consensus_states
.insert(height.into(), consensus_state)?;

Check warning on line 253 in src/ibc/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/ibc/mod.rs#L251-L253

Added lines #L251 - L253 were not covered by tests

Ok(())
}

Check warning on line 256 in src/ibc/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/ibc/mod.rs#L255-L256

Added lines #L255 - L256 were not covered by tests

fn signer(&mut self) -> crate::Result<Address> {
self.context::<Signer>()
.ok_or_else(|| Error::Coins("No Signer context available".into()))?
Expand Down
Loading
Loading