Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

Commit

Permalink
refactor requirements as description
Browse files Browse the repository at this point in the history
  • Loading branch information
stojanov-igor committed Feb 28, 2022
1 parent 73fd333 commit 01febd0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions task/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
//!
//! When Tasks are created, there is some associated metadata that shall be defined.
//! This includes the following:
//! - Task Requirements (Defining the Task Requirements)
//! - Task Description (Defining the Task description)
//! - Task Budget (The cost of completion for the Task)
//! - Task Deadline (The specified time until which the task should be completed)
//!
Expand Down Expand Up @@ -97,10 +97,10 @@ pub mod pallet {
#[scale_info(skip_type_params(T))]
pub struct Task<T: Config> {
pub title: Vec<u8>,
pub description: Vec<u8>,
pub initiator: AccountOf<T>,
pub volunteer: AccountOf<T>,
pub current_owner: AccountOf<T>,
pub requirements: Vec<u8>,
pub status: TaskStatus,
pub budget: BalanceOf<T>,
pub deadline: u32,
Expand Down Expand Up @@ -191,15 +191,15 @@ pub mod pallet {
// Dispatchable functions must be annotated with a weight and must return a DispatchResult.
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Function call that creates tasks. [ origin, requirements, budget, deadline]
/// Function call that creates tasks. [ origin, description, budget, deadline]
#[pallet::weight(10_000 + T::DbWeight::get().writes(1))]
pub fn create_task(origin: OriginFor<T>, title: Vec<u8>, requirements: Vec<u8>, budget: BalanceOf<T>, deadline: u32) -> DispatchResultWithPostInfo {
pub fn create_task(origin: OriginFor<T>, title: Vec<u8>, description: Vec<u8>, budget: BalanceOf<T>, deadline: u32) -> DispatchResultWithPostInfo {

// Check that the extrinsic was signed and get the signer.
let signer = ensure_signed(origin)?;

// Update storage.
let task_id = Self::new_task(&signer, &title, &requirements, &budget, &deadline)?;
let task_id = Self::new_task(&signer, &title, &description, &budget, &deadline)?;

// TODO: Check if user has balance to create task
// T::Currency::reserve(&signer, budget).map_err(|_| "locker can't afford to lock the amount requested")?;
Expand Down Expand Up @@ -263,17 +263,17 @@ pub mod pallet {
// *** Helper functions *** //
impl<T:Config> Pallet<T> {

pub fn new_task(from_initiator: &T::AccountId, title: &[u8], requirements: &[u8], budget: &BalanceOf<T>, deadline: &u32) -> Result<T::Hash, Error<T>> {
pub fn new_task(from_initiator: &T::AccountId, title: &[u8], description: &[u8], budget: &BalanceOf<T>, deadline: &u32) -> Result<T::Hash, Error<T>> {

// Ensure user has a profile before creating a task
ensure!(pallet_profile::Pallet::<T>::has_profile(from_initiator).unwrap(), <Error<T>>::NoProfile);

// Init Task Object
let task = Task::<T> {
title: title.to_owned(),
description: description.to_owned(),
initiator: from_initiator.clone(),
volunteer: from_initiator.clone(),
requirements: requirements.to_owned(),
status: Created,
budget: *budget,
current_owner: from_initiator.clone(),
Expand Down

0 comments on commit 01febd0

Please sign in to comment.