-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
117 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
//! This module implements the processing logic for ICS2 (client abstractions and functions) msgs. | ||
|
||
pub mod create_client; | ||
pub mod provide_counterparty; | ||
pub mod recover_client; | ||
pub mod update_client; | ||
pub mod upgrade_client; |
57 changes: 57 additions & 0 deletions
57
ibc-eureka-core/ics02-client/src/handler/provide_counterparty.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//! Protocol logic specific to processing ICS2 messages of type `MsgProvideCouterparty`. | ||
|
||
use ibc_eureka_core_client_context::prelude::*; | ||
use ibc_eureka_core_client_types::error::ClientError; | ||
use ibc_eureka_core_client_types::msgs::MsgProvideCouterparty; | ||
use ibc_eureka_core_host::{ExecutionContext, ValidationContext}; | ||
use ibc_primitives::prelude::*; | ||
|
||
pub fn validate<Ctx>(ctx: &Ctx, msg: MsgProvideCouterparty) -> Result<(), ClientError> | ||
where | ||
Ctx: ValidationContext, | ||
{ | ||
let MsgProvideCouterparty { | ||
client_id, signer, .. | ||
} = &msg; | ||
|
||
ctx.validate_message_signer(signer)?; | ||
|
||
let client_val_ctx = ctx.get_client_validation_context(); | ||
|
||
// Read client state from the host chain store. The client should already exist. | ||
let client_state = client_val_ctx.client_state(client_id)?; | ||
|
||
client_state | ||
.status(client_val_ctx, client_id)? | ||
.verify_is_active()?; | ||
|
||
if client_val_ctx.counterparty_meta(client_id)?.is_some() { | ||
return Err(ClientError::ClientSpecific { | ||
description: "counterparty is already provided".into(), | ||
}); | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn execute<Ctx>(ctx: &mut Ctx, msg: MsgProvideCouterparty) -> Result<(), ClientError> | ||
where | ||
Ctx: ExecutionContext, | ||
{ | ||
let MsgProvideCouterparty { | ||
client_id, | ||
counterparty_client_id, | ||
counterparty_commitment_prefix, | ||
.. | ||
} = &msg; | ||
|
||
let client_exec_ctx = ctx.get_client_execution_context(); | ||
|
||
client_exec_ctx.store_counterparty_meta( | ||
client_id, | ||
counterparty_client_id, | ||
counterparty_commitment_prefix, | ||
)?; | ||
|
||
Ok(()) | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
ibc-eureka-core/ics02-client/types/src/msgs/provide_counterparty.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//! Definition of domain type message `MsgProvideCouterparty`. | ||
|
||
use ibc_eureka_core_commitment_types::commitment::CommitmentPrefix; | ||
use ibc_eureka_core_host_types::identifiers::ClientId; | ||
use ibc_primitives::prelude::*; | ||
use ibc_primitives::Signer; | ||
|
||
pub const _PROVIDE_COUNTERPARTY_TYPE_URL: &str = "/ibc.core.client.v1.MsgProvideCouterparty"; | ||
|
||
/// A type of message that links an on-chain (IBC) client to its counterparty. | ||
#[cfg_attr( | ||
feature = "borsh", | ||
derive(borsh::BorshSerialize, borsh::BorshDeserialize) | ||
)] | ||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] | ||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
pub struct MsgProvideCouterparty { | ||
pub client_id: ClientId, | ||
pub counterparty_client_id: ClientId, | ||
pub counterparty_commitment_prefix: CommitmentPrefix, | ||
pub signer: Signer, | ||
} | ||
|
||
impl MsgProvideCouterparty { | ||
pub fn new( | ||
client_id: ClientId, | ||
counterparty_client_id: ClientId, | ||
counterparty_commitment_prefix: CommitmentPrefix, | ||
signer: Signer, | ||
) -> Self { | ||
MsgProvideCouterparty { | ||
client_id, | ||
counterparty_client_id, | ||
counterparty_commitment_prefix, | ||
signer, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters