Skip to content

Commit 3c44e0d

Browse files
authored
Merge pull request #192 from hashed-io/develop
Develop
2 parents d704cf7 + 9f35818 commit 3c44e0d

File tree

11 files changed

+49
-40
lines changed

11 files changed

+49
-40
lines changed

Cargo.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
2-
name = "pallet-proxy"
2+
name = "pallet-proxy-financial"
33
version = "4.0.0-dev"
4-
description = "Proxy migration pallet"
4+
description = "Proxy Financial Pallet"
55
authors = ["Hashed <https://github.com/hashed-io"]
66
homepage = "https://hashed.io"
77
edition = "2021"
File renamed without changes.
File renamed without changes.
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,9 @@ impl<T: Config> Pallet<T> {
151151
//Add expenditures
152152
Self::do_create_expenditure(admin.clone(), project_id, expenditures)?;
153153

154-
match users {
155-
Some(users) => {
156-
//Add users
157-
Self::do_assign_user(admin.clone(), project_id, users)?;
158-
},
159-
None => {}
154+
// Add users
155+
if let Some(users) = users {
156+
Self::do_assign_user(admin.clone(), project_id, users)?;
160157
}
161158

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

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

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

1322-
// Check if the user role trying to be assigned matchs the actual user role from UsersInfo storage
1317+
// Check if the user role trying to be assigned matches the actual user role from UsersInfo storage
13231318
if user_data.role != role {
13241319
return Err(Error::<T>::UserCannotHaveMoreThanOneRole.into());
13251320
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,18 @@ pub mod pallet {
233233
ValueQuery,
234234
>;
235235

236+
#[pallet::storage]
237+
#[pallet::getter(fn drawdowns_by_project_by_type)]
238+
pub(super) type DrawdownsByProjectByType<T: Config> = StorageDoubleMap<
239+
_,
240+
Identity,
241+
[u8;32], // Key project_id
242+
Identity,
243+
DrawdownType, // Key drawdown type
244+
BoundedVec<[u8;32], T::MaxDrawdownsPerProject>, // Value Drawdowns
245+
ValueQuery,
246+
>;
247+
236248
#[pallet::storage]
237249
#[pallet::getter(fn transactions)]
238250
pub(super) type TransactionsInfo<T: Config> = StorageMap<
@@ -431,6 +443,8 @@ pub mod pallet {
431443
TransactionIsAlreadyCompleted,
432444
/// Expenditure type does not match project type
433445
InvalidExpenditureType,
446+
/// User does not have the specified role
447+
UserDoesNotHaveRole,
434448

435449
}
436450

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate as pallet_proxy;
1+
use crate as pallet_proxy_financial;
22
use frame_support::parameter_types;
33
use frame_system as system;
44
use sp_core::H256;
@@ -20,7 +20,7 @@ frame_support::construct_runtime!(
2020
UncheckedExtrinsic = UncheckedExtrinsic,
2121
{
2222
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
23-
Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>},
23+
Proxy: pallet_proxy_financial::{Pallet, Call, Storage, Event<T>},
2424
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
2525
RBAC: pallet_rbac::{Pallet, Call, Storage, Event<T>},
2626
}
@@ -81,7 +81,7 @@ parameter_types! {
8181

8282
}
8383

84-
impl pallet_proxy::Config for Test {
84+
impl pallet_proxy_financial::Config for Test {
8585
type Event = Event;
8686
type RemoveOrigin = EnsureRoot<Self::AccountId>;
8787
type ProjectNameMaxLen = ProjectNameMaxLen;

runtime/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pallet-bitcoin-vaults = { default-features = false, path = "../pallets/bitcoin-v
6767
pallet-gated-marketplace = { default-features = false, path = "../pallets/gated-marketplace" }
6868
pallet-rbac = { default-features = false, path = "../pallets/rbac" }
6969
pallet-confidential-docs = { default-features = false, path = "../pallets/confidential-docs" }
70-
pallet-proxy = { default-features = false, path = "../pallets/proxy" }
70+
pallet-proxy-financial = { default-features = false, path = "../pallets/proxy-financial" }
7171

7272

7373
[build-dependencies]
@@ -107,7 +107,7 @@ std = [
107107
"pallet-gated-marketplace/std",
108108
"pallet-rbac/std",
109109
"pallet-confidential-docs/std",
110-
"pallet-proxy/std",
110+
"pallet-proxy-financial/std",
111111
"sp-api/std",
112112
"sp-block-builder/std",
113113
"sp-consensus-aura/std",

0 commit comments

Comments
 (0)