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};
30pub use runtime_interface::messenger_runtime_interface::get_storage_key;
31#[cfg(feature = "std")]
32pub use runtime_interface::messenger_runtime_interface::HostFunctions;
33use scale_info::TypeInfo;
34use sp_domains::DomainId;
35use sp_messenger::messages::{ChainId, MessageKey};
36use sp_runtime_interface::pass_by;
37use sp_runtime_interface::pass_by::PassBy;
38
39#[derive(Debug, Decode, Encode, TypeInfo, PartialEq, Eq, Clone)]
40pub enum StorageKeyRequest {
41    /// Request to get confirmed domain block storage key for given domain.
42    ConfirmedDomainBlockStorageKey(DomainId),
43    /// Request to get Outbox storage key for given chain and message.
44    OutboxStorageKey {
45        chain_id: ChainId,
46        message_key: MessageKey,
47    },
48    /// Request to get Inbox response storage key for given chain and message.
49    InboxResponseStorageKey {
50        chain_id: ChainId,
51        message_key: MessageKey,
52    },
53}
54
55impl PassBy for StorageKeyRequest {
56    type PassBy = pass_by::Codec<Self>;
57}