Skip to content

Conversation

@herou
Copy link
Contributor

@herou herou commented May 13, 2022

Some time ago all the pallets have been updated from v1 to v2 but the document files were not updated. In this PR I have updated them.

@JoshOrndorff Please take a look and let me know.

@herou
Copy link
Contributor Author

herou commented Jun 19, 2022

@JoshOrndorff Can you please take a look to this PR thnx.

Copy link
Owner

@JoshOrndorff JoshOrndorff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks basically good. Thanks for all the work on this.

My only requests are:

  1. Get the CI passing. There are some broken links that need fixed.
  2. Follow up about clippy.

@@ -1,5 +1,5 @@
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.

#![allow(clippy::needless_borrow)]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? If it is in our code, we should remove the borrow. If this code comes from a Substrate macro, I'm fine with overriding adding this for now. But we should make an upstream PR to make the macro better. Here's an example of one I've done in the past paritytech/substrate#9053

@@ -1,86 +1,111 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::unused_unit)]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment

Comment on lines +19 to +22
#[pallet::config]
pub trait Config: frame_system::Config {
/// The overarching event type.
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, I didn't realize there were pallets actually using the old decl_ macros still. Good catch.

Comment on lines +60 to 80
ensure!(
members.len() < MAX_MEMBERS,
Error::<T>::MembershipLimitReached
);

// We don't want to add duplicate members, so we check whether the potential new
// member is already present in the list. Because the list is always ordered, we can
// leverage the binary search which makes this check O(log n).
match members.binary_search(&new_member) {
// If the search succeeds, the caller is already a member, so just return
Ok(_) => Err(Error::<T>::AlreadyMember.into()),
// If the search fails, the caller is not a member and we learned the index where
// they should be inserted
Err(index) => {
members.insert(index, new_member.clone());
Members::<T>::put(members);
Self::deposit_event(Event::MemberAdded(new_member));
Ok(().into())
}
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the formatting right here? The syntax highlighting is confusing github. Not sure why though. Maybe this is just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants