simnode_runtime_api/
lib.rs

1// Copyright (C) 2023 Polytope Labs (Caymans) Ltd.
2// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
3
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13// You should have received a copy of the GNU General Public License
14// along with this program. If not, see <https://www.gnu.org/licenses/>.
15#![cfg_attr(not(feature = "std"), no_std)]
16
17//! # simnode-runtime-api
18//!
19//!
20//! Exports a substrate runtime API that allows simnode create extrinsics that are always valid for
21//! the runtime
22
23use polkadot_sdk::*;
24
25use codec::Codec;
26use sp_std::vec::Vec;
27
28sp_api::decl_runtime_apis! {
29	/// Create transaction.
30	/// This trait is meant to be implemented by the runtime and is responsible for constructing
31	/// a transaction to be included in the block.
32	pub trait CreateTransactionApi<RuntimeCall, AccountId>
33		where
34			RuntimeCall: Codec,
35			AccountId: Codec,
36	{
37		/// Attempt to create signed transaction
38		/// Runtime implementation is free to construct the payload to sign in any way it wants.
39		/// Returns a scale encoded extrinsic Should panic if signed transaction cannot be created.
40		fn create_transaction(account: AccountId, call: RuntimeCall) -> Vec<u8>;
41	}
42}