git.delta.rocks / unique-network / refs/commits / b8430d488c9f

difftreelog

Add RuntimeInstance trait

Daniel Shiposha2022-03-11parent: #ddce88d.patch.diff
in: master

5 files changed

modifiedruntime/common/Cargo.tomldiffbeforeafterboth
--- a/runtime/common/Cargo.toml
+++ b/runtime/common/Cargo.toml
@@ -16,6 +16,9 @@
     'codec/std',
     'frame-support/std',
     'frame-system/std',
+    'sp-consensus-aura/std',
+    'pallet-common/std',
+    'fp-rpc/std',
 ]
 runtime-benchmarks = [
     'sp-runtime/runtime-benchmarks',
@@ -53,3 +56,17 @@
 default-features = false
 git = 'https://github.com/paritytech/substrate.git'
 branch = 'polkadot-v0.9.17'
+
+[dependencies.pallet-common]
+default-features = false
+path = "../../pallets/common"
+
+[dependencies.sp-consensus-aura]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
+[dependencies.fp-rpc]
+default-features = false
+git = "https://github.com/uniquenetwork/frontier.git"
+branch = "unique-polkadot-v0.9.17"
modifiedruntime/common/src/types.rsdiffbeforeafterboth
--- a/runtime/common/src/types.rs
+++ b/runtime/common/src/types.rs
@@ -38,3 +38,15 @@
 
 /// Digest item type.
 pub type DigestItem = generic::DigestItem;
+
+pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
+
+pub trait RuntimeInstance {
+	type CrossAccountId: pallet_common::account::CrossAccountId<sp_runtime::AccountId32>
+						+ Send + Sync + 'static;
+
+	type TransactionConverter: fp_rpc::ConvertTransaction<UncheckedExtrinsic>
+						+ Send + Sync + 'static;
+
+	fn get_transaction_converter() -> Self::TransactionConverter;
+}
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -116,8 +116,18 @@
 
 pub const RUNTIME_NAME: &str = "Opal";
 
-pub type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;
+type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;
+
+impl RuntimeInstance for Runtime {
+	type CrossAccountId = self::CrossAccountId;
+
+	type TransactionConverter = self::TransactionConverter;
 
+	fn get_transaction_converter() -> TransactionConverter {
+		TransactionConverter
+	}
+}
+
 /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
 /// the specifics of the runtime. They can then be made to be agnostic over specific formats
 /// of data like extrinsics, allowing for them to continue syncing the network through upgrades
@@ -128,7 +138,6 @@
 	use super::Aura;
 
 	pub use unique_runtime_common::types::*;
-	pub use super::CrossAccountId;
 
 	impl_opaque_keys! {
 		pub struct SessionKeys {
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -116,8 +116,18 @@
 
 pub const RUNTIME_NAME: &str = "Quartz";
 
-pub type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;
+type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;
+
+impl RuntimeInstance for Runtime {
+	type CrossAccountId = self::CrossAccountId;
+
+	type TransactionConverter = self::TransactionConverter;
 
+	fn get_transaction_converter() -> TransactionConverter {
+		TransactionConverter
+	}
+}
+
 /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
 /// the specifics of the runtime. They can then be made to be agnostic over specific formats
 /// of data like extrinsics, allowing for them to continue syncing the network through upgrades
@@ -128,7 +138,6 @@
 	use super::Aura;
 
 	pub use unique_runtime_common::types::*;
-	pub use super::CrossAccountId;
 
 	impl_opaque_keys! {
 		pub struct SessionKeys {
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
85};85};
8686
87// pub use pallet_timestamp::Call as TimestampCall;87// pub use pallet_timestamp::Call as TimestampCall;
88pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
8988
90// Polkadot imports89// Polkadot imports
91use pallet_xcm::XcmPassthrough;90use pallet_xcm::XcmPassthrough;
116115
117pub const RUNTIME_NAME: &str = "Unique";116pub const RUNTIME_NAME: &str = "Unique";
118117
119pub type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;118type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;
119
120impl RuntimeInstance for Runtime {
121 type CrossAccountId = self::CrossAccountId;
122
123 type TransactionConverter = self::TransactionConverter;
124
125 fn get_transaction_converter() -> TransactionConverter {
126 TransactionConverter
127 }
128}
120129
121/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know130/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
122/// the specifics of the runtime. They can then be made to be agnostic over specific formats131/// the specifics of the runtime. They can then be made to be agnostic over specific formats
128 use super::Aura;137 use super::Aura;
129138
130 pub use unique_runtime_common::types::*;139 pub use unique_runtime_common::types::*;
131 pub use super::CrossAccountId;
132140
133 impl_opaque_keys! {141 impl_opaque_keys! {
134 pub struct SessionKeys {142 pub struct SessionKeys {
207 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)215 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
208 .build_or_panic();216 .build_or_panic();
209 pub const Version: RuntimeVersion = VERSION;217 pub const Version: RuntimeVersion = VERSION;
210 pub const SS58Prefix: u8 = 7391;218 pub const SS58Prefix: u16 = 7391;
211}219}
212220
213parameter_types! {221parameter_types! {