Skip to content

Commit

Permalink
Merge pull request #223 from Fair-Squares/222-in-asset_management-=-a…
Browse files Browse the repository at this point in the history
…dditionnal-check-needed-on-launch_tenant_session-extrinsic

Added the additional check
  • Loading branch information
ndkazu committed Dec 3, 2022
2 parents f49fde7 + 7d58305 commit ccf0453
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions pallets/asset_management/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ pub mod pallet {
NotAnAssetAccount,
/// The account is not a representative
NotARepresentative,
/// Not an active Representative
NotAnActiveRepresentative,
/// The asset is not linked to the representative
AssetOutOfControl,
/// The candidate is not a tenant
Expand All @@ -184,19 +186,19 @@ pub mod pallet {
TenantAssetNotLinked,
/// Errors should have helpful documentation associated with them.
StorageOverflow,
///The proposal could not be created
/// The proposal could not be created
FailedToCreateProposal,
///This Preimage already exists
/// This Preimage already exists
DuplicatePreimage,
///Not an owner in the corresponding virtual account
/// Not an owner in the corresponding virtual account
NotAnOwner,
///The Asset Does not Exists
/// The Asset Does not Exists
NotAnAsset,
///This referendum does not exists
/// This referendum does not exists
NotAValidReferendum,
///This referendum is over
/// This referendum is over
ReferendumCompleted,
///Not enough funds in the account
/// Not enough funds in the account
NotEnoughFunds,
}

Expand Down Expand Up @@ -454,17 +456,16 @@ pub mod pallet {
// Ensure that the caller is a representative
let rep = Roles::Pallet::<T>::reps(caller.clone());
ensure!(rep.is_some(), Error::<T>::NotARepresentative);
let rep = rep.unwrap();
ensure!(rep.activated, Error::<T>::NotAnActiveRepresentative);

// Get the asset virtual account if exists
let collection_id: T::NftCollectionId = asset_type.value().into();
let ownership = Share::Pallet::<T>::virtual_acc(collection_id, asset_id);
ensure!(ownership.is_some(), Error::<T>::NotAnAsset);

let asset_account = ownership.unwrap().virtual_account;
ensure!(
rep.unwrap().assets_accounts.contains(&asset_account),
Error::<T>::AssetOutOfControl
);
ensure!(rep.assets_accounts.contains(&asset_account), Error::<T>::AssetOutOfControl);

// Ensure that provided account is a valid tenant
let tenant0 = Roles::Pallet::<T>::tenants(tenant.clone());
Expand Down

0 comments on commit ccf0453

Please sign in to comment.