Skip to content

Commit

Permalink
removed default template code
Browse files Browse the repository at this point in the history
  • Loading branch information
amiyatulu committed Sep 10, 2024
1 parent 7c85a9c commit 83e3e1f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 171 deletions.
30 changes: 3 additions & 27 deletions custom-pallets/project-tips/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,6 @@ pub mod pallet {
type Reward: OnUnbalanced<PositiveImbalanceOf<Self>>;
}

// The pallet's runtime storage items.
// https://docs.substrate.io/main-docs/build/runtime-storage/
#[pallet::storage]
#[pallet::getter(fn something)]
// Learn more about declaring storage items:
// https://docs.substrate.io/main-docs/build/runtime-storage/#declaring-storage-items
pub type Something<T> = StorageValue<_, u32>;

#[pallet::type_value]
pub fn MinimumDepartmentStake<T: Config>() -> BalanceOf<T> {
10000u128.saturated_into::<BalanceOf<T>>()
Expand Down Expand Up @@ -157,25 +149,9 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Event documentation should end with an array that provides descriptive names for event
/// parameters. [something, who]
SomethingStored {
something: u32,
who: T::AccountId,
},
ProjectCreated {
account: T::AccountId,
project_id: ProjectId,
},
StakinPeriodStarted {
project_id: ProjectId,
block_number: BlockNumberOf<T>,
},
ApplyJurors {
project_id: ProjectId,
block_number: BlockNumberOf<T>,
account: T::AccountId,
},
ProjectCreated { account: T::AccountId, project_id: ProjectId },
StakinPeriodStarted { project_id: ProjectId, block_number: BlockNumberOf<T> },
ApplyJurors { project_id: ProjectId, block_number: BlockNumberOf<T>, account: T::AccountId },
}

// Errors inform users that something went wrong.
Expand Down
55 changes: 1 addition & 54 deletions custom-pallets/schelling-game-shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,6 @@ pub mod pallet {
type Slash: OnUnbalanced<NegativeImbalanceOf<Self>>;
}

// The pallet's runtime storage items.
// https://docs.substrate.io/main-docs/build/runtime-storage/
#[pallet::storage]
#[pallet::getter(fn something)]
// Learn more about declaring storage items:
// https://docs.substrate.io/main-docs/build/runtime-storage/#declaring-storage-items
pub type Something<T> = StorageValue<_, u32>;

#[pallet::storage]
pub type Nonce<T> = StorageValue<_, u64, ValueQuery>;

Expand Down Expand Up @@ -145,7 +137,7 @@ pub mod pallet {
CommitVote,
>;

/// Vote Commits for Score Schelling
/// Vote Commits for Score Schelling
#[pallet::storage]
#[pallet::getter(fn vote_commits_score)]
pub type ScoreVoteCommits<T: Config> = StorageDoubleMap<
Expand Down Expand Up @@ -234,49 +226,4 @@ pub mod pallet {
TimeForStakingNotOver,
NewMeanNotInserted,
}

// Dispatchable functions allows users to interact with the pallet and invoke state changes.
// These functions materialize as "extrinsics", which are often compared to transactions.
// Dispatchable functions must be annotated with a weight and must return a DispatchResult.
#[pallet::call]
impl<T: Config> Pallet<T> {
/// An example dispatchable that takes a singles value as a parameter, writes the value to
/// storage and emits an event. This function must be dispatched by a signed extrinsic.
#[pallet::call_index(0)]
#[pallet::weight(0)]
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
// Check that the extrinsic was signed and get the signer.
// This function will return an error if the extrinsic is not signed.
// https://docs.substrate.io/main-docs/build/origins/
let who = ensure_signed(origin)?;

// Update storage.
<Something<T>>::put(something);

// Emit an event.
Self::deposit_event(Event::SomethingStored { something, who });
// Return a successful DispatchResultWithPostInfo
Ok(())
}

/// An example dispatchable that may throw a custom error.
#[pallet::call_index(1)]
#[pallet::weight(0)]
pub fn cause_error(origin: OriginFor<T>) -> DispatchResult {
let _who = ensure_signed(origin)?;

// Read a value from storage.
match <Something<T>>::get() {
// Return an error if the value has not been set.
None => return Err(Error::<T>::NoneValue.into()),
Some(old) => {
// Increment the value read from storage; will error in the event of overflow.
let new = old.checked_add(1).ok_or(Error::<T>::StorageOverflow)?;
// Update the value in storage with the incremented result.
<Something<T>>::put(new);
Ok(())
},
}
}
}
}
53 changes: 0 additions & 53 deletions custom-pallets/shared-storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ pub mod pallet {
type WeightInfo: WeightInfo;
}

// The pallet's runtime storage items.
// https://docs.substrate.io/main-docs/build/runtime-storage/
#[pallet::storage]
#[pallet::getter(fn something)]
// Learn more about declaring storage items:
// https://docs.substrate.io/main-docs/build/runtime-storage/#declaring-storage-items
pub type Something<T> = StorageValue<_, u32>;

#[pallet::storage]
#[pallet::getter(fn approved_citizen_address)]
pub type ApprovedCitizenAddress<T: Config> = StorageValue<_, Vec<T::AccountId>, ValueQuery>; // Its set, add element through binary_search
Expand Down Expand Up @@ -106,49 +98,4 @@ pub mod pallet {
StorageOverflow,
CitizenNotApproved,
}

// Dispatchable functions allows users to interact with the pallet and invoke state changes.
// These functions materialize as "extrinsics", which are often compared to transactions.
// Dispatchable functions must be annotated with a weight and must return a DispatchResult.
#[pallet::call]
impl<T: Config> Pallet<T> {
/// An example dispatchable that takes a singles value as a parameter, writes the value to
/// storage and emits an event. This function must be dispatched by a signed extrinsic.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::do_something())]
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
// Check that the extrinsic was signed and get the signer.
// This function will return an error if the extrinsic is not signed.
// https://docs.substrate.io/main-docs/build/origins/
let who = ensure_signed(origin)?;

// Update storage.
<Something<T>>::put(something);

// Emit an event.
Self::deposit_event(Event::SomethingStored { something, who });
// Return a successful DispatchResultWithPostInfo
Ok(())
}

/// An example dispatchable that may throw a custom error.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::cause_error())]
pub fn cause_error(origin: OriginFor<T>) -> DispatchResult {
let _who = ensure_signed(origin)?;

// Read a value from storage.
match <Something<T>>::get() {
// Return an error if the value has not been set.
None => return Err(Error::<T>::NoneValue.into()),
Some(old) => {
// Increment the value read from storage; will error in the event of overflow.
let new = old.checked_add(1).ok_or(Error::<T>::StorageOverflow)?;
// Update the value in storage with the incremented result.
<Something<T>>::put(new);
Ok(())
},
}
}
}
}
37 changes: 0 additions & 37 deletions custom-pallets/sortition-sum-game/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ pub mod pallet {
type WeightInfo: WeightInfo;
}

// The pallet's runtime storage items.
// https://docs.substrate.io/main-docs/build/runtime-storage/
#[pallet::storage]
#[pallet::getter(fn something)]
// Learn more about declaring storage items:
// https://docs.substrate.io/main-docs/build/runtime-storage/#declaring-storage-items
pub type Something<T> = StorageValue<_, u32>;

// Pallets use events to inform users when important changes are made.
// https://docs.substrate.io/main-docs/build/events-errors/
#[pallet::event]
Expand All @@ -76,33 +68,4 @@ pub mod pallet {
TreeAlreadyExists,
TreeDoesnotExist,
}

// Dispatchable functions allows users to interact with the pallet and invoke state changes.
// These functions materialize as "extrinsics", which are often compared to transactions.
// Dispatchable functions must be annotated with a weight and must return a DispatchResult.
#[pallet::call]
impl<T: Config> Pallet<T> {
/// An example dispatchable that takes a singles value as a parameter, writes the value to
/// storage and emits an event. This function must be dispatched by a signed extrinsic.

/// An example dispatchable that may throw a custom error.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::cause_error())]
pub fn cause_error(origin: OriginFor<T>) -> DispatchResult {
let _who = ensure_signed(origin)?;

// Read a value from storage.
match <Something<T>>::get() {
// Return an error if the value has not been set.
None => return Err(Error::<T>::NoneValue.into()),
Some(old) => {
// Increment the value read from storage; will error in the event of overflow.
let new = old.checked_add(1).ok_or(Error::<T>::StorageOverflow)?;
// Update the value in storage with the incremented result.
<Something<T>>::put(new);
Ok(())
},
}
}
}
}

0 comments on commit 83e3e1f

Please sign in to comment.