|
1 | 1 | //! Extensions for unsigned general extrinsics |
2 | 2 |
|
3 | 3 | use crate::pallet::Call as DomainsCall; |
| 4 | +use crate::weights::WeightInfo; |
4 | 5 | use crate::{Config, FraudProofFor, OpaqueBundleOf, Origin, Pallet as Domains, SingletonReceiptOf}; |
5 | 6 | use frame_support::pallet_prelude::{PhantomData, TypeInfo}; |
| 7 | +use frame_support::weights::Weight; |
6 | 8 | use frame_system::pallet_prelude::RuntimeCallFor; |
7 | 9 | use parity_scale_codec::{Decode, Encode}; |
8 | 10 | use scale_info::prelude::fmt; |
@@ -175,6 +177,23 @@ where |
175 | 177 | type Val = (); |
176 | 178 | type Pre = (); |
177 | 179 |
|
| 180 | + fn weight(&self, call: &Runtime::RuntimeCall) -> Weight { |
| 181 | + // This extension only apply to the following 3 calls thus only return weight for them. |
| 182 | + match call.maybe_domains_call() { |
| 183 | + Some(DomainsCall::submit_bundle { .. }) => { |
| 184 | + <Runtime as Config>::WeightInfo::validate_submit_bundle() |
| 185 | + } |
| 186 | + Some(DomainsCall::submit_fraud_proof { .. }) => { |
| 187 | + // FIXME: proper weight |
| 188 | + Weight::zero() |
| 189 | + } |
| 190 | + Some(DomainsCall::submit_receipt { .. }) => { |
| 191 | + <Runtime as Config>::WeightInfo::validate_singleton_receipt() |
| 192 | + } |
| 193 | + _ => Weight::zero(), |
| 194 | + } |
| 195 | + } |
| 196 | + |
178 | 197 | fn validate( |
179 | 198 | &self, |
180 | 199 | origin: DispatchOriginOf<RuntimeCallFor<Runtime>>, |
@@ -212,7 +231,4 @@ where |
212 | 231 | } |
213 | 232 |
|
214 | 233 | impl_tx_ext_default!(RuntimeCallFor<Runtime>; prepare); |
215 | | - |
216 | | - // TODO: need benchmarking for this extension. |
217 | | - impl_tx_ext_default!(RuntimeCallFor<Runtime>; weight); |
218 | 234 | } |
0 commit comments