Skip to content

Commit 2069e3e

Browse files
authored
move networkid to constants (#62)
1 parent a32ef72 commit 2069e3e

File tree

2 files changed

+6
-34
lines changed

2 files changed

+6
-34
lines changed

pallets/multisig-verifier/src/lib.rs

+4-33
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ pub mod pallet {
101101
type MaxPeers: Get<u32>;
102102

103103
type WeightInfo: WeightInfo;
104+
105+
#[pallet::constant]
106+
type ThisNetworkId: Get<GenericNetworkId>;
104107
}
105108

106109
#[pallet::pallet]
@@ -117,16 +120,6 @@ pub mod pallet {
117120
OptionQuery,
118121
>;
119122

120-
#[pallet::type_value]
121-
pub fn DefaultForThisNetworkId() -> GenericNetworkId {
122-
GenericNetworkId::Sub(SubNetworkId::Mainnet)
123-
}
124-
125-
#[pallet::storage]
126-
#[pallet::getter(fn this_network_id)]
127-
pub type ThisNetworkId<T> =
128-
StorageValue<_, GenericNetworkId, ValueQuery, DefaultForThisNetworkId>;
129-
130123
#[pallet::event]
131124
#[pallet::generate_deposit(pub(super) fn deposit_event)]
132125
pub enum Event<T: Config> {
@@ -154,28 +147,6 @@ pub mod pallet {
154147
#[pallet::hooks]
155148
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
156149

157-
#[pallet::genesis_config]
158-
pub struct GenesisConfig {
159-
/// Network id for current network
160-
pub network_id: GenericNetworkId,
161-
}
162-
163-
#[cfg(feature = "std")]
164-
impl Default for GenesisConfig {
165-
fn default() -> Self {
166-
Self {
167-
network_id: GenericNetworkId::Sub(SubNetworkId::Mainnet),
168-
}
169-
}
170-
}
171-
172-
#[pallet::genesis_build]
173-
impl<T: Config> GenesisBuild<T> for GenesisConfig {
174-
fn build(&self) {
175-
ThisNetworkId::<T>::put(self.network_id);
176-
}
177-
}
178-
179150
#[pallet::call]
180151
impl<T: Config> Pallet<T> {
181152
#[pallet::call_index(0)]
@@ -321,7 +292,7 @@ impl<T: Config> bridge_types::traits::Verifier for Pallet<T> {
321292
commitment_hash: H256,
322293
proof: &Self::Proof,
323294
) -> DispatchResult {
324-
let this_network_id = ThisNetworkId::<T>::get();
295+
let this_network_id = T::ThisNetworkId::get();
325296
let digest_hash = Keccak256::hash_of(&proof.digest);
326297
Self::verify_signatures(network_id, digest_hash, &proof.proof)?;
327298
let count = proof

pallets/multisig-verifier/src/mock.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ frame_support::construct_runtime!(
5656
parameter_types! {
5757
pub const BlockHashCount: u64 = 250;
5858
pub const SS58Prefix: u8 = 42;
59-
pub const SidechainRandomnessNetwork: SubNetworkId = SubNetworkId::Mainnet;
6059
pub const BridgeMaxPeers: u32 = 50;
60+
pub const ThisNetworkId: bridge_types::GenericNetworkId = bridge_types::GenericNetworkId::Sub(bridge_types::SubNetworkId::Mainnet);
6161
}
6262

6363
pub type AccountId = u64;
@@ -95,6 +95,7 @@ impl trusted_verifier::Config for Test {
9595
type OutboundChannel = TestOutboundChannel;
9696
type MaxPeers = BridgeMaxPeers;
9797
type WeightInfo = ();
98+
type ThisNetworkId = ThisNetworkId;
9899
}
99100

100101
pub struct TestOutboundChannel;

0 commit comments

Comments
 (0)