Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Ismp-rs Update #92

Merged
merged 3 commits into from
Sep 15, 2023
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
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions ismp-demo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,8 @@ pub mod pallet {
/// Dispatch request to a connected EVM chain.
#[pallet::weight(Weight::from_parts(1_000_000, 0))]
#[pallet::call_index(2)]
pub fn disptach_to_evm(origin: OriginFor<T>, params: EvmParams) -> DispatchResult {
pub fn dispatch_to_evm(origin: OriginFor<T>, params: EvmParams) -> DispatchResult {
ensure_signed(origin)?;

let post = DispatchPost {
dest: StateMachine::Ethereum(params.destination),
from: PALLET_ID.to_bytes(),
Expand All @@ -217,13 +216,13 @@ pub mod pallet {
data: b"Hello from polkadot".to_vec(),
gas_limit: 10_000_000,
};

// dispatch the request
let dispatcher = T::IsmpDispatcher::default();
dispatcher
.dispatch_request(DispatchRequest::Post(post))
.map_err(|_| Error::<T>::TransferFailed)?;

for _ in 0..params.count {
// dispatch the request
dispatcher
.dispatch_request(DispatchRequest::Post(post.clone()))
.map_err(|_| Error::<T>::TransferFailed)?;
}
Ok(())
}
}
Expand Down Expand Up @@ -288,6 +287,9 @@ pub mod pallet {

/// Timeout timestamp on destination chain in seconds
pub timeout: u64,

/// Request count
pub count: u64,
}
}

Expand Down
13 changes: 0 additions & 13 deletions pallet-ismp/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ where
#[method(name = "ismp_queryChallengePeriod")]
fn query_challenge_period(&self, client_id: ConsensusClientId) -> Result<u64>;

/// Query the latest timestamp for chain
#[method(name = "ismp_queryTimestamp")]
fn query_timestamp(&self) -> Result<u64>;

/// Query the latest height for a state machine
#[method(name = "ismp_queryStateMachineLatestHeight")]
fn query_state_machine_latest_height(&self, id: StateMachineId) -> Result<u64>;
Expand Down Expand Up @@ -273,15 +269,6 @@ where
.ok_or_else(|| runtime_error_into_rpc_error("Error fetching Challenge period"))
}

fn query_timestamp(&self) -> Result<u64> {
let api = self.client.runtime_api();
let at = self.client.info().best_hash;
api.timestamp(at)
.ok()
.flatten()
.ok_or_else(|| runtime_error_into_rpc_error("Error fetching latest timestamp"))
}

fn query_state_machine_latest_height(&self, id: StateMachineId) -> Result<u64> {
let api = self.client.runtime_api();
let at = self.client.info().best_hash;
Expand Down
3 changes: 0 additions & 3 deletions pallet-ismp/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ sp_api::decl_runtime_apis! {
/// Return the timestamp this client was last updated in seconds
fn consensus_update_time(id: ConsensusClientId) -> Option<u64>;

/// Return the latest timestamp for the chain
fn timestamp() -> Option<u64>;

/// Return the challenge period timestamp
fn challenge_period(id: ConsensusClientId) -> Option<u64>;

Expand Down