diff --git a/pallets/oneshot-account/src/lib.rs b/pallets/oneshot-account/src/lib.rs index 6c1b7f72e95dd48d7d4e1ffdfdf5b1da1ef0950f..91d782b56aaa4a91b2855938e7456423c8f301bc 100644 --- a/pallets/oneshot-account/src/lib.rs +++ b/pallets/oneshot-account/src/lib.rs @@ -21,10 +21,12 @@ mod check_nonce; #[cfg(test)] mod mock; mod types; +pub mod weights; pub use check_nonce::CheckNonce; pub use pallet::*; pub use types::*; +pub use weights::WeightInfo; use frame_support::pallet_prelude::*; use frame_support::traits::{ @@ -56,6 +58,8 @@ pub mod pallet { type Currency: Currency<Self::AccountId>; type InnerOnChargeTransaction: OnChargeTransaction<Self>; type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; + /// Type representing the weight of this pallet + type WeightInfo: WeightInfo; } // STORAGE // @@ -127,7 +131,7 @@ pub mod pallet { /// - `balance`: The balance to be transfered to this oneshot account. /// /// Origin account is kept alive. - #[pallet::weight(500_000_000)] + #[pallet::weight(T::WeightInfo::create_oneshot_account())] pub fn create_oneshot_account( origin: OriginFor<T>, dest: <T::Lookup as StaticLookup>::Source, @@ -165,7 +169,7 @@ pub mod pallet { /// - `block_height`: Must be a recent block number. The limit is `BlockHashCount` in the past. (this is to prevent replay attacks) /// - `dest`: The destination account. /// - `dest_is_oneshot`: If set to `true`, then a oneshot account is created at `dest`. Else, `dest` has to be an existing account. - #[pallet::weight(500_000_000)] + #[pallet::weight(T::WeightInfo::consume_oneshot_account())] pub fn consume_oneshot_account( origin: OriginFor<T>, block_height: T::BlockNumber, @@ -223,7 +227,7 @@ pub mod pallet { /// - `dest2`: The second destination account. /// - `dest2_is_oneshot`: If set to `true`, then a oneshot account is created at `dest2`. Else, `dest2` has to be an existing account. /// - `balance1`: The amount transfered to `dest`, the leftover being transfered to `dest2`. - #[pallet::weight(500_000_000)] + #[pallet::weight(T::WeightInfo::consume_oneshot_account_with_remaining())] pub fn consume_oneshot_account_with_remaining( origin: OriginFor<T>, block_height: T::BlockNumber, diff --git a/pallets/oneshot-account/src/mock.rs b/pallets/oneshot-account/src/mock.rs index 89ee71c47ee5cfe2d0c60769453c8a97bb4c76f1..2de61147981ddad8996323d54579d393b42835b0 100644 --- a/pallets/oneshot-account/src/mock.rs +++ b/pallets/oneshot-account/src/mock.rs @@ -104,6 +104,7 @@ impl pallet_oneshot_account::Config for Test { type Currency = Balances; type InnerOnChargeTransaction = CurrencyAdapter<Balances, HandleFees>; type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); } pub struct HandleFees;