Skip to content

Commit b5306d4

Browse files
Complete usage of ProducerOrigin in pallet_rmrk_core::Config
1 parent 22add24 commit b5306d4

File tree

6 files changed

+22
-14
lines changed

6 files changed

+22
-14
lines changed

pallets/rmrk-core/src/functions.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ impl<T: Config>
4646
priority_index += 1;
4747
}
4848
Self::deposit_event(Event::PrioritySet { collection_id, nft_id });
49-
Ok(Some(<T as pallet::Config>::WeightInfo::set_priority(priority_index, T::NestingBudget::get())).into())
49+
Ok(Some(<T as pallet::Config>::WeightInfo::set_priority(
50+
priority_index,
51+
T::NestingBudget::get(),
52+
))
53+
.into())
5054
}
5155
}
5256

pallets/rmrk-core/src/lib.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
use frame_support::{
1010
dispatch::{DispatchResult, DispatchResultWithPostInfo},
1111
ensure,
12-
traits::tokens::{nonfungibles::*, Locker},
12+
traits::{
13+
tokens::{nonfungibles::*, Locker},
14+
EnsureOrigin, IsType,
15+
},
1316
transactional, BoundedVec,
1417
};
15-
use frame_system::ensure_signed;
18+
use frame_system::{ensure_signed, RawOrigin};
1619

1720
use sp_runtime::{traits::StaticLookup, DispatchError, Permill};
1821
use sp_std::convert::TryInto;
@@ -122,7 +125,7 @@ pub mod pallet {
122125
pub trait Config: frame_system::Config + pallet_uniques::Config {
123126
/// Because this pallet emits events, it depends on the runtime's definition of an event.
124127
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
125-
type ProtocolOrigin: EnsureOrigin<Self::RuntimeOrigin>;
128+
type ProtocolOrigin: EnsureOrigin<Self::RuntimeOrigin, Success = Self::AccountId>;
126129

127130
/// The maximum resource symbol length
128131
#[pallet::constant]
@@ -443,7 +446,7 @@ pub mod pallet {
443446
transferable: bool,
444447
resources: Option<BoundedResourceInfoTypeOf<T>>,
445448
) -> DispatchResult {
446-
let sender = ensure_signed(origin)?;
449+
let sender = T::ProtocolOrigin::ensure_origin(origin)?;
447450
if let Some(collection_issuer) =
448451
pallet_uniques::Pallet::<T>::collection_owner(collection_id)
449452
{
@@ -483,7 +486,7 @@ pub mod pallet {
483486
/// - `recipient`: Receiver of the royalty
484487
/// - `royalty`: Permillage reward from each trade for the Recipient
485488
/// - `metadata`: Arbitrary data about an nft, e.g. IPFS hash
486-
#[pallet::call_index(1)]
489+
#[pallet::call_index(1)]
487490
#[pallet::weight(<T as pallet::Config>::WeightInfo::mint_nft_directly_to_nft(T::NestingBudget::get()))]
488491
#[transactional]
489492
pub fn mint_nft_directly_to_nft(
@@ -497,7 +500,7 @@ pub mod pallet {
497500
transferable: bool,
498501
resources: Option<BoundedResourceInfoTypeOf<T>>,
499502
) -> DispatchResult {
500-
let sender = ensure_signed(origin.clone())?;
503+
let sender = T::ProtocolOrigin::ensure_origin(origin.clone())?;
501504

502505
// Collection must exist and sender must be issuer of collection
503506
if let Some(collection_issuer) =
@@ -535,7 +538,7 @@ pub mod pallet {
535538
max: Option<u32>,
536539
symbol: BoundedCollectionSymbolOf<T>,
537540
) -> DispatchResult {
538-
let sender = ensure_signed(origin)?;
541+
let sender = T::ProtocolOrigin::ensure_origin(origin)?;
539542

540543
Self::collection_create(sender, collection_id, metadata, max, symbol)?;
541544

pallets/rmrk-core/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use frame_support::{
99
parameter_types,
1010
traits::{AsEnsureOriginWithArg, ConstU32, Everything},
1111
};
12-
use frame_system::EnsureRoot;
12+
use frame_system::{EnsureRoot, EnsureSigned};
1313
use sp_core::{crypto::AccountId32, H256};
1414
use sp_runtime::{
1515
testing::Header,
@@ -60,7 +60,7 @@ use pallet_rmrk_core::RmrkBenchmark;
6060
impl pallet_rmrk_core::Config for Test {
6161
// type Currency = Balances;
6262
type RuntimeEvent = RuntimeEvent;
63-
type ProtocolOrigin = EnsureRoot<AccountId>;
63+
type ProtocolOrigin = EnsureSigned<AccountId>;
6464
type ResourceSymbolLimit = ResourceSymbolLimit;
6565
type PartsLimit = PartsLimit;
6666
type MaxPriorities = MaxPriorities;

pallets/rmrk-equip/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use frame_support::{
88
traits::{AsEnsureOriginWithArg, ConstU32, Everything},
99
weights::Weight,
1010
};
11-
use frame_system::EnsureRoot;
11+
use frame_system::{EnsureRoot, EnsureSigned};
1212
use sp_core::{crypto::AccountId32, H256};
1313
use sp_runtime::{
1414
testing::Header,
@@ -71,7 +71,7 @@ use pallet_rmrk_core::RmrkBenchmark;
7171

7272
impl pallet_rmrk_core::Config for Test {
7373
type RuntimeEvent = RuntimeEvent;
74-
type ProtocolOrigin = EnsureRoot<AccountId>;
74+
type ProtocolOrigin = EnsureSigned<AccountId>;
7575
type ResourceSymbolLimit = ResourceSymbolLimit;
7676
type PartsLimit = PartsLimit;
7777
type MaxPriorities = MaxPriorities;

pallets/rmrk-market/src/mock.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,11 @@ parameter_types! {
106106

107107
#[cfg(feature = "runtime-benchmarks")]
108108
use pallet_rmrk_core::RmrkBenchmark;
109+
use system::EnsureSigned;
109110

110111
impl pallet_rmrk_core::Config for Test {
111112
type RuntimeEvent = RuntimeEvent;
112-
type ProtocolOrigin = EnsureRoot<AccountId>;
113+
type ProtocolOrigin = EnsureSigned<AccountId>;
113114
type ResourceSymbolLimit = ResourceSymbolLimit;
114115
type PartsLimit = PartsLimit;
115116
type MaxPriorities = MaxPriorities;

runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ use pallet_rmrk_core::RmrkBenchmark;
362362

363363
impl pallet_rmrk_core::Config for Runtime {
364364
type RuntimeEvent = RuntimeEvent;
365-
type ProtocolOrigin = frame_system::EnsureRoot<AccountId>;
365+
type ProtocolOrigin = frame_system::EnsureSigned<AccountId>;
366366
type ResourceSymbolLimit = ResourceSymbolLimit;
367367
type PartsLimit = PartsLimit;
368368
type MaxPriorities = MaxPriorities;

0 commit comments

Comments
 (0)