2
2
// Older clippy versions give a false positive on the expansion of [pallet::call].
3
3
// This is fixed in https://github.com/rust-lang/rust-clippy/issues/8321
4
4
#![ allow( clippy:: large_enum_variant) ]
5
-
6
- use frame_support:: { pallet_prelude:: * , traits:: EnsureOrigin , transactional} ;
5
+ use frame_support:: { pallet_prelude:: * , traits:: EnsureOriginWithArg , transactional} ;
7
6
use frame_system:: pallet_prelude:: * ;
8
7
use orml_traits:: asset_registry:: AssetProcessor ;
9
8
use scale_info:: TypeInfo ;
@@ -19,9 +18,12 @@ pub use module::*;
19
18
pub use weights:: WeightInfo ;
20
19
21
20
mod impls;
21
+ mod weights;
22
+
23
+ #[ cfg( test) ]
22
24
mod mock;
25
+ #[ cfg( test) ]
23
26
mod tests;
24
- mod weights;
25
27
26
28
/// Data describing the asset properties.
27
29
#[ derive( scale_info:: TypeInfo , Encode , Decode , Clone , Eq , PartialEq , RuntimeDebug ) ]
@@ -48,8 +50,8 @@ pub mod module {
48
50
/// The type used as a unique asset id,
49
51
type AssetId : Parameter + Member + Default + TypeInfo ;
50
52
51
- /// The origin that is allowed to manipulate metadata.
52
- type AuthorityOrigin : EnsureOrigin < < Self as frame_system :: Config > :: Origin > ;
53
+ /// Checks that an origin has the authority to register/update an asset
54
+ type AuthorityOrigin : EnsureOriginWithArg < Self :: Origin , Option < Self :: AssetId > > ;
53
55
54
56
/// A filter ran upon metadata registration that assigns an is and
55
57
/// potentially modifies the supplied metadata.
@@ -88,10 +90,6 @@ pub mod module {
88
90
asset_id : T :: AssetId ,
89
91
metadata : AssetMetadata < T :: Balance , T :: CustomMetadata > ,
90
92
} ,
91
- SetLocation {
92
- asset_id : T :: AssetId ,
93
- location : Box < VersionedMultiLocation > ,
94
- } ,
95
93
}
96
94
97
95
/// The metadata of an asset, indexed by asset id.
@@ -147,7 +145,7 @@ pub mod module {
147
145
metadata : AssetMetadata < T :: Balance , T :: CustomMetadata > ,
148
146
asset_id : Option < T :: AssetId > ,
149
147
) -> DispatchResult {
150
- T :: AuthorityOrigin :: ensure_origin ( origin) ?;
148
+ T :: AuthorityOrigin :: ensure_origin ( origin, & asset_id . clone ( ) ) ?;
151
149
152
150
Self :: do_register_asset ( metadata, asset_id)
153
151
}
@@ -165,7 +163,7 @@ pub mod module {
165
163
location : Option < Option < VersionedMultiLocation > > ,
166
164
additional : Option < T :: CustomMetadata > ,
167
165
) -> DispatchResult {
168
- T :: AuthorityOrigin :: ensure_origin ( origin) ?;
166
+ T :: AuthorityOrigin :: ensure_origin ( origin, & Some ( asset_id . clone ( ) ) ) ?;
169
167
170
168
Self :: do_update_asset (
171
169
asset_id,
0 commit comments