Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the additional check #223

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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