-
Notifications
You must be signed in to change notification settings - Fork 116
membership module #3
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
Changes from 1 commit
43376ab
216e694
a7d4aac
6923186
1237df8
918868e
cb1a3a7
6e202d9
54738e7
e99cb53
6f46ad1
ac0c928
f095b67
1d63f67
7ae24d0
2d3329a
da0a072
31fd1de
95e4cd3
478fbe0
a227fa3
27b7841
5ba5f86
74531d2
3328650
bf2f5d5
c8b70cc
c7326e1
53e54b6
3fab73d
9f07751
3e43d9e
75d835d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,109 @@ | ||||||
| #![cfg_attr(not(feature = "std"), no_std)] | ||||||
|
|
||||||
| use rstd::prelude::*; | ||||||
| use parity_codec::Codec; | ||||||
| use parity_codec_derive::{Encode, Decode}; | ||||||
| use srml_support::{StorageMap, dispatch::Result, decl_module, decl_storage, decl_event, ensure, Parameter}; | ||||||
| use srml_support::traits::{Currency}; | ||||||
| use runtime_primitives::traits::{Zero, SimpleArithmetic, As, Member, MaybeSerializeDebug}; | ||||||
| use system::{self, ensure_signed}; | ||||||
| use crate::governance::{GovernanceCurrency, BalanceOf }; | ||||||
|
|
||||||
| pub trait Trait: system::Trait + GovernanceCurrency { | ||||||
| type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>; | ||||||
|
|
||||||
| type MemberId: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + As<usize> + As<u64> + MaybeSerializeDebug; | ||||||
|
|
||||||
| type PaidTermId: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + As<usize> + As<u32> + MaybeSerializeDebug; | ||||||
|
|
||||||
| type SubscriptionId: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + As<usize> + As<u32> + MaybeSerializeDebug; | ||||||
| } | ||||||
|
|
||||||
| #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))] | ||||||
| #[derive(Encode, Decode)] | ||||||
| pub struct Profile<T: Trait> { | ||||||
| id: T::MemberId, // is it necessary to have the id in the struct? | ||||||
| handle: u32, | ||||||
| avatarUri: Vec<u8>, | ||||||
|
||||||
| avatarUri: Vec<u8>, | |
| avatarUri: Option<Vec<u8>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decided on default empty vector == empty string to represent same as not setting avatar or about text. Also makes the batch updating logic simpler.. how to differentiate between user wanting to pass None to 'unset' avatar, or None as in they don't want to update the avatar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. In such case, it should be Option<Option<Vec<u8>>> and then if you want to set avatar_uri to None you will pass it with UserInfo as Some(None). And if you don't want to update it, then just None.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest naming this field as about such as description is a better word for items, but not a person
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Option for a case if a user has not set their about - this is not required, yes?
| description: Vec<u8>, | |
| about: Option<Vec<u8>>, |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| added: T::BlockNumber, | |
| registeredAt: T::BlockNumber, |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistency in naming: FIRST_ vs INITIAL_
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| MembersById get(members_by_id) : map T::MemberId => T::AccountId; | |
| AccountIdByMemberId get(account_id_by_member_id) : map T::MemberId => T::AccountId; |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| MemberByAccount get(members_by_account) : map T::AccountId => T::MemberId; | |
| MemberIdByAccountId get(member_id_by_account_id) : map T::AccountId => T::MemberId; |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is option redundant here? If this map has no member id as a key, then there is no profile for this member id.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| PlatformAcceptingNewMemberships get(platform_accepting_new_memberships) : bool = true; | |
| NewMembershipsAllowed get(new_memberships_allowed) : bool = true; |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename to MemberRegistered? Registered sounds better when we think about users and social networks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.