Skip to main content

sp_messenger_host_functions/
lib.rs

1// Copyright (C) 2021 Subspace Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// 	http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16//! Host functions for Messenger.
17
18#![cfg_attr(not(feature = "std"), no_std)]
19
20#[cfg(feature = "std")]
21mod host_functions;
22mod runtime_interface;
23
24#[cfg(not(feature = "std"))]
25extern crate alloc;
26
27#[cfg(feature = "std")]
28pub use host_functions::{MessengerApi, MessengerExtension, MessengerHostFunctionsImpl};
29use parity_scale_codec::{Decode, Encode};
30#[cfg(feature = "std")]
31pub use runtime_interface::messenger_runtime_interface::HostFunctions;
32pub use runtime_interface::messenger_runtime_interface::get_storage_key;
33use scale_info::TypeInfo;
34use sp_domains::DomainId;
35use sp_messenger::messages::{ChainId, MessageKey};
36#[derive(Debug, Decode, Encode, TypeInfo, PartialEq, Eq, Clone)]
37pub enum StorageKeyRequest {
38    /// Request to get confirmed domain block storage key for given domain.
39    ConfirmedDomainBlockStorageKey(DomainId),
40    /// Request to get Outbox storage key for given chain and message.
41    OutboxStorageKey {
42        chain_id: ChainId,
43        message_key: MessageKey,
44    },
45    /// Request to get Inbox response storage key for given chain and message.
46    InboxResponseStorageKey {
47        chain_id: ChainId,
48        message_key: MessageKey,
49    },
50}