Skip to content

Commit

Permalink
Merge pull request #75 from bifrost-finance/add-control-origin
Browse files Browse the repository at this point in the history
Add ControlOrigin
  • Loading branch information
v-van committed Oct 13, 2023
2 parents 6c546a9 + 1b8da47 commit 6094173
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions example/runtime/src/zenlink.rs
Expand Up @@ -33,6 +33,7 @@ impl zenlink_protocol::Config for Runtime {
type TargetChains = ();
type SelfParaId = SelfParaId;
type WeightInfo = ();
type ControlOrigin = EnsureRoot<AccountId>;
}

type MultiAssets = ZenlinkMultiAssets<ZenlinkProtocol, Balances, LocalAssetAdaptor<Tokens>>;
Expand Down
4 changes: 3 additions & 1 deletion zenlink-protocol/src/lib.rs
Expand Up @@ -80,6 +80,8 @@ pub mod pallet {
pub trait Config: frame_system::Config {
/// Because this pallet emits events, it depends on the runtime's definition of an event.
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// The only origin that can create pair.
type ControlOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
/// The assets interface beyond native currency and other assets.
type MultiAssetsHandler: MultiAssetsHandler<Self::AccountId, Self::AssetId>;
/// This pallet id.
Expand Down Expand Up @@ -521,7 +523,7 @@ pub mod pallet {
asset_0: T::AssetId,
asset_1: T::AssetId,
) -> DispatchResult {
ensure_root(origin)?;
T::ControlOrigin::ensure_origin(origin)?;
ensure!(asset_0.is_support() && asset_1.is_support(), Error::<T>::UnsupportedAssetType);

ensure!(asset_0 != asset_1, Error::<T>::DeniedCreatePair);
Expand Down

0 comments on commit 6094173

Please sign in to comment.