Skip to content

Commit 92a1140

Browse files
committed
adds marketplace type aliases
1 parent 6c1e122 commit 92a1140

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

pallets/gated-marketplace/src/functions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ impl<T: Config> Pallet<T> {
447447

448448
pub fn set_up_application(
449449
fields : Fields<T>,
450-
custodian_fields: Option<(T::AccountId, BoundedVec<BoundedVec<u8,ConstU32<100>>, T::MaxFiles> )>
450+
custodian_fields: Option<CustodianFields<T>>
451451
)-> (Option<T::AccountId>, BoundedVec<ApplicationField, T::MaxFiles> ){
452452
let mut f: Vec<ApplicationField>= fields.iter().map(|tuple|{
453453
ApplicationField{

pallets/gated-marketplace/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ pub mod pallet {
336336
marketplace_id: [u8;32],
337337
// Getting encoding errors from polkadotjs if an object vector have optional fields
338338
fields : Fields<T>,
339-
custodian_fields: Option<(T::AccountId, BoundedVec<BoundedVec<u8,ConstU32<100>>, T::MaxFiles> )>
339+
custodian_fields: Option<CustodianFields<T>>
340340
) -> DispatchResult {
341341
let who = ensure_signed(origin)?;
342342

@@ -374,7 +374,7 @@ pub mod pallet {
374374
marketplace_id: [u8;32],
375375
// Getting encoding errors from polkadotjs if an object vector have optional fields
376376
fields : Fields<T>,
377-
custodian_fields: Option<(T::AccountId, BoundedVec<BoundedVec<u8,ConstU32<100>>, T::MaxFiles> )>
377+
custodian_fields: Option<CustodianFields<T>>
378378
) -> DispatchResult {
379379
let who = ensure_signed(origin)?;
380380

pallets/gated-marketplace/src/types.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ use frame_support::pallet_prelude::*;
55
use sp_runtime::sp_std::vec::Vec;
66
use frame_support::sp_io::hashing::blake2_256;
77

8-
pub type Fields<T> = BoundedVec<(BoundedVec<u8,ConstU32<100> >,BoundedVec<u8,ConstU32<100>> ), <T as Config>::MaxFiles>;
9-
10-
//Todo: fix AccountId import
11-
//pub type CustodianFields<T> = Option<(RawOrigin<T>, BoundedVec<BoundedVec<u8,ConstU32<100>>, <T as Config>::MaxFiles>)>;
8+
pub type Fields<T> = BoundedVec<(FieldName,Cid), <T as Config>::MaxFiles>;
9+
type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
10+
pub type FieldName = BoundedVec<u8,ConstU32<100>>;
11+
pub type Cid = BoundedVec<u8,ConstU32<100>>;
12+
pub type Cids<Len> = BoundedVec<Cid, Len>;
13+
pub type CustodianFields<T> = ( AccountIdOf<T>, Cids<<T as Config>::MaxFiles>);
1214

1315
#[derive(CloneNoBound,Encode, Decode, RuntimeDebugNoBound, Default, TypeInfo, MaxEncodedLen,)]
1416
#[scale_info(skip_type_params(T))]
@@ -148,8 +150,8 @@ impl Default for ApplicationStatus{
148150
#[derive(CloneNoBound, Encode ,Decode, Eq, RuntimeDebugNoBound, Default, TypeInfo, MaxEncodedLen)]
149151
pub struct ApplicationField{
150152
pub display_name: BoundedVec<u8,ConstU32<100> >,
151-
pub cid: BoundedVec<u8, ConstU32<100> >,
152-
pub custodian_cid: Option<BoundedVec<u8, ConstU32<100> > >,
153+
pub cid: Cid,
154+
pub custodian_cid: Option<Cid>,
153155
}
154156
// Eq macro didnt work (binary operation `==` cannot be applied to type...)
155157
impl PartialEq for ApplicationField{

0 commit comments

Comments
 (0)