3 个稳定版本

1.6.2 2024 年 5 月 10 日
1.6.1 2024 年 5 月 6 日
1.6.0 2024 年 5 月 2 日

#2524魔法豆

Download history 290/week @ 2024-05-01 194/week @ 2024-05-08 12/week @ 2024-05-15 17/week @ 2024-05-22 1/week @ 2024-05-29 2/week @ 2024-06-05 15/week @ 2024-06-12

每月 125 次下载
用于 2 crate

Apache-2.0

195KB
3.5K SLoC

托盘 ISMP 运行时 API

此库导出客户端子系统(如 RPC)所需的运行时 API 定义。

用法

所需的方法已在 pallet_ismp::Pallet<T> 中实现。


sp_api::impl_runtime_apis! {
    impl pallet_ismp_runtime_api::IsmpRuntimeApi<Block, <Block as BlockT>::Hash> for Runtime {
        fn host_state_machine() -> StateMachine {
            <Runtime as pallet_ismp::Config>::HostStateMachine::get()
        }

        fn challenge_period(consensus_state_id: [u8; 4]) -> Option<u64> {
            pallet_ismp::Pallet::<Runtime>::challenge_period(consensus_state_id)
        }

        /// Generate a proof for the provided leaf indices
        fn generate_proof(
            keys: ProofKeys
        ) -> Result<(Vec<Leaf>, Proof<<Block as BlockT>::Hash>), sp_mmr_primitives::Error> {
            pallet_ismp::Pallet::<Runtime>::generate_proof(keys)
        }

        /// Fetch all ISMP events and their extrinsic metadata, should only be called from runtime-api.
        fn block_events() -> Vec<ismp::events::Event> {
            pallet_ismp::Pallet::<Runtime>::block_events()
        }

        /// Fetch all ISMP events and their extrinsic metadata
        fn block_events_with_metadata() -> Vec<(ismp::events::Event, u32)> {
            pallet_ismp::Pallet::<Runtime>::block_events_with_metadata()
        }

        /// Return the scale encoded consensus state
        fn consensus_state(id: ConsensusClientId) -> Option<Vec<u8>> {
            pallet_ismp::Pallet::<Runtime>::consensus_states(id)
        }

        /// Return the timestamp this client was last updated in seconds
        fn consensus_update_time(id: ConsensusClientId) -> Option<u64> {
            pallet_ismp::Pallet::<Runtime>::consensus_update_time(id)
        }

        /// Return the latest height of the state machine
        fn latest_state_machine_height(id: StateMachineId) -> Option<u64> {
            pallet_ismp::Pallet::<Runtime>::latest_state_machine_height(id)
        }


        /// Get actual requests
        fn get_requests(commitments: Vec<H256>) -> Vec<Request> {
            pallet_ismp::Pallet::<Runtime>::requests(commitments)
        }

        /// Get actual requests
        fn get_responses(commitments: Vec<H256>) -> Vec<Response> {
            pallet_ismp::Pallet::<Runtime>::responses(commitments)
        }
    }
}

许可

此库受 Apache 2.0 许可证的许可,版权所有 (c) 2024 Polytope Labs。

依赖项

~17–35MB
~580K SLoC