diff --git a/Cargo.lock b/Cargo.lock
index d6f149ab..4b7edf8c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3338,6 +3338,7 @@ dependencies = [
"pallet-im-online",
"pallet-indices",
"pallet-lottery",
+ "pallet-mapped-assets",
"pallet-membership",
"pallet-multisig",
"pallet-preimage",
@@ -5989,6 +5990,7 @@ dependencies = [
"log",
"pallet-balances",
"pallet-fruniques",
+ "pallet-mapped-assets",
"pallet-rbac",
"pallet-timestamp",
"pallet-uniques",
diff --git a/pallets/afloat/fruniquesImplementation.drawio b/pallets/afloat/fruniquesImplementation.drawio
new file mode 100644
index 00000000..56263978
--- /dev/null
+++ b/pallets/afloat/fruniquesImplementation.drawio
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/pallets/afloat/src/functions.rs b/pallets/afloat/src/functions.rs
index bb51d0a9..3574f740 100644
--- a/pallets/afloat/src/functions.rs
+++ b/pallets/afloat/src/functions.rs
@@ -4,47 +4,45 @@ use crate::types::*;
use frame_support::traits::UnixTime;
use frame_system::pallet_prelude::*;
use pallet_gated_marketplace::types::MarketplaceRole;
-use pallet_fruniques::types::CollectionDescription;
-use pallet_fruniques::types::FruniqueRole;
+use pallet_fruniques::types::{CollectionDescription, FruniqueRole, Attributes, ParentInfo};
use frame_support::pallet_prelude::*;
// use frame_support::traits::OriginTrait;
+use pallet_rbac::types::IdOrVec;
+use pallet_rbac::types::RoleBasedAccessControl;
+use pallet_rbac::types::RoleId;
+use scale_info::prelude::vec;
+use frame_support::sp_io::hashing::blake2_256;
+use sp_runtime::sp_std::str;
+use sp_runtime::sp_std::vec::Vec;
+use sp_runtime::traits::StaticLookup;
impl Pallet {
pub fn do_initial_setup(creator: T::AccountId, admin: T::AccountId) -> DispatchResult {
+
+ Self::initialize_rbac()?;
+
let creator_user: User = User {
- first_name: ShortString::try_from(b"Afloat".to_vec()).unwrap(),
- last_name: ShortString::try_from(b"Creator".to_vec()).unwrap(),
- email: LongString::try_from(b"".to_vec()).unwrap(),
- lang_key: ShortString::try_from(b"en".to_vec()).unwrap(),
+ cid: ShortString::try_from(b"5HeWymtD558YYKHaZvipqysBHR6PCWgvy96Hg2oah2x7CEH5".to_vec()).unwrap(),
+ group: ShortString::try_from(b"HCD:QmZcSrTcqBdHck73xYw2WHgEQ9tchPrwNq6hM3a3rvXAAV".to_vec()).unwrap(),
created_by: Some(creator.clone()),
created_date: Some(T::TimeProvider::now().as_secs()),
last_modified_by: Some(creator.clone()),
last_modified_date: Some(T::TimeProvider::now().as_secs()),
- phone: None,
- credits_needed: 0,
- cpa_id: ShortString::try_from(b"0".to_vec()).unwrap(),
- tax_authority_id: 1,
- lock_expiration_date: None,
};
>::insert(creator.clone(), creator_user);
+ Self::give_role_to_user(creator.clone(), AfloatRole::Owner)?;
if admin != creator {
let admin_user: User = User {
- first_name: ShortString::try_from(b"Afloat".to_vec()).unwrap(),
- last_name: ShortString::try_from(b"Admin".to_vec()).unwrap(),
- email: LongString::try_from(b"".to_vec()).unwrap(),
- lang_key: ShortString::try_from(b"en".to_vec()).unwrap(),
+ cid: ShortString::try_from(b"5E7RDXG1e98KFsY6qtjRsdnArSMPyRe8fYH9BWPLeLtFMA2w".to_vec()).unwrap(),
+ group: ShortString::try_from(b"HCD:QmbhAm22mGMVrTmAfkjUzbtZrSXVSLV28Xah5ca5NtwQ3U".to_vec()).unwrap(),
created_by: Some(admin.clone()),
created_date: Some(T::TimeProvider::now().as_secs()),
last_modified_by: Some(admin.clone()),
last_modified_date: Some(T::TimeProvider::now().as_secs()),
- phone: None,
- credits_needed: 0,
- cpa_id: ShortString::try_from(b"0".to_vec()).unwrap(),
- tax_authority_id: 1,
- lock_expiration_date: None,
};
- >::insert(admin, admin_user);
+ >::insert(admin.clone(), admin_user);
+ Self::give_role_to_user(admin, AfloatRole::Admin)?;
}
Ok(())
@@ -78,42 +76,30 @@ impl Pallet {
) -> DispatchResult {
ensure!(!>::contains_key(user_address.clone()), Error::::UserAlreadyExists);
match args {
- SignUpArgs::BuyerOrSeller { first_name, last_name, email, state } => {
+ SignUpArgs::BuyerOrSeller { cid, group } => {
let user: User = User {
- first_name,
- last_name,
- email,
- lang_key: ShortString::try_from(b"en".to_vec()).unwrap(),
+ cid: cid,
+ group: group,
created_by: Some(actor.clone()),
created_date: Some(T::TimeProvider::now().as_secs()),
last_modified_by: Some(actor.clone()),
last_modified_date: Some(T::TimeProvider::now().as_secs()),
- phone: None,
- credits_needed: 0,
- cpa_id: ShortString::try_from(b"0".to_vec()).unwrap(),
- tax_authority_id: state,
- lock_expiration_date: None,
};
>::insert(user_address.clone(), user);
+ Self::give_role_to_user(user_address.clone(), AfloatRole::BuyerOrSeller)?;
Self::deposit_event(Event::NewUser(user_address.clone()));
},
- SignUpArgs::CPA { first_name, last_name, email, license_number, state } => {
+ SignUpArgs::CPA { cid, group } => {
let user: User = User {
- first_name,
- last_name,
- email,
- lang_key: ShortString::try_from(b"en".to_vec()).unwrap(),
- created_by: Some(user_address.clone()),
+ cid: cid,
+ group: group,
+ created_by: Some(actor.clone()),
created_date: Some(T::TimeProvider::now().as_secs()),
- last_modified_by: Some(user_address.clone()),
+ last_modified_by: Some(actor.clone()),
last_modified_date: Some(T::TimeProvider::now().as_secs()),
- phone: None,
- credits_needed: 0,
- cpa_id: license_number,
- tax_authority_id: state,
- lock_expiration_date: None,
};
>::insert(user_address.clone(), user);
+ Self::give_role_to_user(user_address.clone(), AfloatRole::CPA)?;
Self::deposit_event(Event::NewUser(user_address.clone()));
},
}
@@ -122,6 +108,7 @@ impl Pallet {
Self::add_to_afloat_collection(user_address.clone(),FruniqueRole::Collaborator)?;
pallet_gated_marketplace::Pallet::::self_enroll(user_address, marketplace_id)?;
+
Ok(())
}
/// Function for editing user information.
@@ -148,52 +135,42 @@ impl Pallet {
pub fn do_edit_user(
actor: T::AccountId,
user_address: T::AccountId,
- first_name: Option,
- last_name: Option,
- email: Option,
- lang_key: Option,
- phone: Option