Skip to content

Commit

Permalink
departent funding create
Browse files Browse the repository at this point in the history
  • Loading branch information
amiyatulu committed Apr 20, 2024
1 parent da34371 commit eb6d2d9
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ cd shivarthu_client
trunk serve
```

### Substrate explorer

<https://paritytech.github.io/subxt-explorer/#/>

### Multi-Node Local Testnet

If you want to see the multi-node consensus algorithm in action, refer to
Expand Down
2 changes: 2 additions & 0 deletions pallets/department-funding/src/extras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ impl<T: Config> DepartmentRequiredFund<T> {
pub fn new(
department_required_fund_id: DepartmentRequiredFundId,
department_id: DepartmentId,
content: Content,
tipping_name: TippingName,
funding_needed: BalanceOf<T>,
creator: T::AccountId,
) -> Self {
DepartmentRequiredFund {
created: new_who_and_when::<T>(creator.clone()),
department_required_fund_id,
content,
department_id,
tipping_name,
funding_needed,
Expand Down
2 changes: 2 additions & 0 deletions pallets/department-funding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ pub mod pallet {
pub fn create_department_required_fund(
origin: OriginFor<T>,
department_id: DepartmentId,
content: Content,
tipping_name: TippingName,
funding_needed: BalanceOf<T>,
) -> DispatchResult {
Expand All @@ -197,6 +198,7 @@ pub mod pallet {
let new_department_fund: DepartmentRequiredFund<T> = DepartmentRequiredFund::new(
new_department_fund_id,
department_id,
content,
tipping_name,
funding_needed,
who.clone(),
Expand Down
1 change: 1 addition & 0 deletions pallets/department-funding/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct DepartmentRequiredFund<T: Config> {
pub created: WhoAndWhenOf<T>,
pub department_required_fund_id: DepartmentRequiredFundId,
pub department_id: DepartmentId,
pub content: Content,
pub tipping_name: TippingName,
pub funding_needed: BalanceOf<T>,
pub creator: T::AccountId,
Expand Down
2 changes: 1 addition & 1 deletion pallets/project-tips/project-tips-runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use sp_api::codec::Codec;
type ProjectId = u64;

sp_api::decl_runtime_apis! {
pub trait ProjectTipsApi<AccountId> where AccountId: Codec {
pub trait ProjectTipsApi<AccountId> where AccountId: Codec{

fn get_evidence_period_end_block(project_id: ProjectId) -> Option<u32>;
fn get_staking_period_end_block(project_id: ProjectId) -> Option<u32>;
Expand Down
2 changes: 1 addition & 1 deletion pallets/project-tips/src/extras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl<T: Config> Pallet<T> {
input.saturated_into::<BlockNumberOf<T>>()
}

pub(super) fn value_of_tipping_name(tipping: TippingName) -> TippingValue<BalanceOf<T>> {
pub fn value_of_tipping_name(tipping: TippingName) -> TippingValue<BalanceOf<T>> {
match tipping {
TippingName::SmallTipper => TippingValue {
max_tipping_value: 10_000u64.saturated_into::<BalanceOf<T>>(),
Expand Down
2 changes: 1 addition & 1 deletion pallets/project-tips/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ pub mod pallet {
// Check update and discussion time over, only project creator can apply staking period
#[pallet::call_index(1)]
#[pallet::weight(0)]
pub fn apply_staking(origin: OriginFor<T>, project_id: ProjectId) -> DispatchResult {
pub fn apply_staking_period(origin: OriginFor<T>, project_id: ProjectId) -> DispatchResult {
let who = ensure_signed(origin)?;

Self::ensure_user_is_project_creator_and_project_exists(project_id, who.clone())?;
Expand Down
12 changes: 6 additions & 6 deletions pallets/project-tips/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn check_balance_on_staking() {

let balance = Balances::free_balance(1);

assert_ok!(ProjectTips::apply_staking(RuntimeOrigin::signed(1), 1));
assert_ok!(ProjectTips::apply_staking_period(RuntimeOrigin::signed(1), 1));

let after_balance = Balances::free_balance(1);

Expand Down Expand Up @@ -83,7 +83,7 @@ fn check_apply_staking_period_function() {
new_test_ext().execute_with(|| {
System::set_block_number(1);
assert_noop!(
ProjectTips::apply_staking(RuntimeOrigin::signed(1), 2),
ProjectTips::apply_staking_period(RuntimeOrigin::signed(1), 2),
Error::<Test>::ProjectDontExists
);

Expand All @@ -105,18 +105,18 @@ fn check_apply_staking_period_function() {
));

assert_noop!(
ProjectTips::apply_staking(RuntimeOrigin::signed(3), 1),
ProjectTips::apply_staking_period(RuntimeOrigin::signed(3), 1),
Error::<Test>::ProjectCreatorDontMatch
);

assert_ok!(ProjectTips::apply_staking(RuntimeOrigin::signed(1), 1));
assert_ok!(ProjectTips::apply_staking_period(RuntimeOrigin::signed(1), 1));

System::assert_last_event(
Event::StakinPeriodStarted { project_id: 1, block_number: 1 }.into(),
);
System::set_block_number(5);
assert_noop!(
ProjectTips::apply_staking(RuntimeOrigin::signed(1), 1),
ProjectTips::apply_staking_period(RuntimeOrigin::signed(1), 1),
Error::<Test>::ProjectIdStakingPeriodAlreadySet
);
});
Expand Down Expand Up @@ -146,7 +146,7 @@ fn schelling_game_test() {

let balance = Balances::free_balance(1);

assert_ok!(ProjectTips::apply_staking(RuntimeOrigin::signed(1), 1));
assert_ok!(ProjectTips::apply_staking_period(RuntimeOrigin::signed(1), 1));

let after_balance = Balances::free_balance(1);

Expand Down

0 comments on commit eb6d2d9

Please sign in to comment.