Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "pallet-proxy"
name = "pallet-proxy-financial"
version = "4.0.0-dev"
description = "Proxy migration pallet"
description = "Proxy Financial Pallet"
authors = ["Hashed <https://github.com/hashed-io"]
homepage = "https://hashed.io"
edition = "2021"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,9 @@ impl<T: Config> Pallet<T> {
//Add expenditures
Self::do_create_expenditure(admin.clone(), project_id, expenditures)?;

match users {
Some(users) => {
//Add users
Self::do_assign_user(admin.clone(), project_id, users)?;
},
None => {}
// Add users
if let Some(users) = users {
Self::do_assign_user(admin.clone(), project_id, users)?;
}

//Initialize drawdowns
Expand Down Expand Up @@ -375,10 +372,8 @@ impl<T: Config> Pallet<T> {
ensure!(<UsersByProject<T>>::get(project_id).contains(&user.clone()), Error::<T>::UserNotAssignedToProject);
ensure!(<ProjectsByUser<T>>::get(user.clone()).contains(&project_id), Error::<T>::UserNotAssignedToProject);

// Ensure user has roles assigned to the project
// TODO: catch error and return custom error
//ensure!(T::Rbac::has_role(user.clone(), Self::pallet_id(), &project_id, [role.id()].to_vec()).is_ok(), Error::<T>::UserDoesNotHaveRole);
T::Rbac::has_role(user.clone(), Self::pallet_id(), &project_id, [role.id()].to_vec())?;
// Ensure user has the specified role assigned in the selected project
ensure!(T::Rbac::has_role(user.clone(), Self::pallet_id(), &project_id, [role.id()].to_vec()).is_ok(), Error::<T>::UserDoesNotHaveRole);

// Update project data depending on the role unassigned
Self::remove_project_role(project_id, user.clone(), role)?;
Expand Down Expand Up @@ -1319,7 +1314,7 @@ impl<T: Config> Pallet<T> {
// Ensure user is registered & get user data
let user_data = UsersInfo::<T>::get(user.clone()).ok_or(Error::<T>::UserNotRegistered)?;

// Check if the user role trying to be assigned matchs the actual user role from UsersInfo storage
// Check if the user role trying to be assigned matches the actual user role from UsersInfo storage
if user_data.role != role {
return Err(Error::<T>::UserCannotHaveMoreThanOneRole.into());
}
Expand Down
14 changes: 14 additions & 0 deletions pallets/proxy/src/lib.rs → pallets/proxy-financial/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ pub mod pallet {
ValueQuery,
>;

#[pallet::storage]
#[pallet::getter(fn drawdowns_by_project_by_type)]
pub(super) type DrawdownsByProjectByType<T: Config> = StorageDoubleMap<
_,
Identity,
[u8;32], // Key project_id
Identity,
DrawdownType, // Key drawdown type
BoundedVec<[u8;32], T::MaxDrawdownsPerProject>, // Value Drawdowns
ValueQuery,
>;

#[pallet::storage]
#[pallet::getter(fn transactions)]
pub(super) type TransactionsInfo<T: Config> = StorageMap<
Expand Down Expand Up @@ -431,6 +443,8 @@ pub mod pallet {
TransactionIsAlreadyCompleted,
/// Expenditure type does not match project type
InvalidExpenditureType,
/// User does not have the specified role
UserDoesNotHaveRole,

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate as pallet_proxy;
use crate as pallet_proxy_financial;
use frame_support::parameter_types;
use frame_system as system;
use sp_core::H256;
Expand All @@ -20,7 +20,7 @@ frame_support::construct_runtime!(
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>},
Proxy: pallet_proxy_financial::{Pallet, Call, Storage, Event<T>},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
RBAC: pallet_rbac::{Pallet, Call, Storage, Event<T>},
}
Expand Down Expand Up @@ -81,7 +81,7 @@ parameter_types! {

}

impl pallet_proxy::Config for Test {
impl pallet_proxy_financial::Config for Test {
type Event = Event;
type RemoveOrigin = EnsureRoot<Self::AccountId>;
type ProjectNameMaxLen = ProjectNameMaxLen;
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pallet-bitcoin-vaults = { default-features = false, path = "../pallets/bitcoin-v
pallet-gated-marketplace = { default-features = false, path = "../pallets/gated-marketplace" }
pallet-rbac = { default-features = false, path = "../pallets/rbac" }
pallet-confidential-docs = { default-features = false, path = "../pallets/confidential-docs" }
pallet-proxy = { default-features = false, path = "../pallets/proxy" }
pallet-proxy-financial = { default-features = false, path = "../pallets/proxy-financial" }


[build-dependencies]
Expand Down Expand Up @@ -107,7 +107,7 @@ std = [
"pallet-gated-marketplace/std",
"pallet-rbac/std",
"pallet-confidential-docs/std",
"pallet-proxy/std",
"pallet-proxy-financial/std",
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ parameter_types! {


}
impl pallet_proxy::Config for Runtime {
impl pallet_proxy_financial::Config for Runtime {
type Event = Event;
type Timestamp = Timestamp;
type Moment = Moment;
Expand Down Expand Up @@ -802,7 +802,7 @@ construct_runtime!(
BitcoinVaults: pallet_bitcoin_vaults,
RBAC: pallet_rbac,
ConfidentialDocs: pallet_confidential_docs,
Proxy: pallet_proxy,
Proxy: pallet_proxy_financial,
}
);

Expand Down