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
before · runtime/common/src/types.rs
1use sp_runtime::{2	traits::{Verify, IdentifyAccount, BlakeTwo256},3	generic, MultiSignature,4};56pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;78/// Opaque block header type.9pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1011/// Opaque block type.12pub type Block = generic::Block<Header, UncheckedExtrinsic>;1314pub type SessionHandlers = ();1516/// An index to a block.17pub type BlockNumber = u32;1819/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.20pub type Signature = MultiSignature;2122/// Some way of identifying an account on the chain. We intentionally make it equivalent23/// to the public key of our transaction signing scheme.24pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;2526/// The type for looking up accounts. We don't expect more than 4 billion of them, but you27/// never know...28pub type AccountIndex = u32;2930/// Balance of an account.31pub type Balance = u128;3233/// Index of a transaction in the chain.34pub type Index = u32;3536/// A hash of some data used by the chain.37pub type Hash = sp_core::H256;3839/// Digest item type.40pub type DigestItem = generic::DigestItem;
after · runtime/common/src/types.rs
1use sp_runtime::{2	traits::{Verify, IdentifyAccount, BlakeTwo256},3	generic, MultiSignature,4};56pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;78/// Opaque block header type.9pub type Header = generic::Header<BlockNumber, BlakeTwo256>;1011/// Opaque block type.12pub type Block = generic::Block<Header, UncheckedExtrinsic>;1314pub type SessionHandlers = ();1516/// An index to a block.17pub type BlockNumber = u32;1819/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.20pub type Signature = MultiSignature;2122/// Some way of identifying an account on the chain. We intentionally make it equivalent23/// to the public key of our transaction signing scheme.24pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;2526/// The type for looking up accounts. We don't expect more than 4 billion of them, but you27/// never know...28pub type AccountIndex = u32;2930/// Balance of an account.31pub type Balance = u128;3233/// Index of a transaction in the chain.34pub type Index = u32;3536/// A hash of some data used by the chain.37pub type Hash = sp_core::H256;3839/// Digest item type.40pub type DigestItem = generic::DigestItem;4142pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;4344pub trait RuntimeInstance {45	type CrossAccountId: pallet_common::account::CrossAccountId<sp_runtime::AccountId32>46						+ Send + Sync + 'static;4748	type TransactionConverter: fp_rpc::ConvertTransaction<UncheckedExtrinsic>49						+ Send + Sync + 'static;5051	fn get_transaction_converter() -> Self::TransactionConverter;52}
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
--- a/runtime/unique/src/lib.rs
+++ b/runtime/unique/src/lib.rs
@@ -85,7 +85,6 @@
 };
 
 // pub use pallet_timestamp::Call as TimestampCall;
-pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
 
 // Polkadot imports
 use pallet_xcm::XcmPassthrough;
@@ -116,7 +115,17 @@
 
 pub const RUNTIME_NAME: &str = "Unique";
 
-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
@@ -128,7 +137,6 @@
 	use super::Aura;
 
 	pub use unique_runtime_common::types::*;
-	pub use super::CrossAccountId;
 
 	impl_opaque_keys! {
 		pub struct SessionKeys {
@@ -207,7 +215,7 @@
 		.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
 		.build_or_panic();
 	pub const Version: RuntimeVersion = VERSION;
-	pub const SS58Prefix: u8 = 7391;
+	pub const SS58Prefix: u16 = 7391;
 }
 
 parameter_types! {