Skip to content

Commit

Permalink
Merge pull request #264 from jurteam/staging
Browse files Browse the repository at this point in the history
Release train 3.4.0
  • Loading branch information
Polkaverse authored Jan 12, 2024
2 parents 2739892 + 180a0fd commit a8c59c2
Show file tree
Hide file tree
Showing 15 changed files with 1,612 additions and 1,263 deletions.
1,644 changes: 391 additions & 1,253 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
resolver = "2"
members = [
"node",
"pallets/bounties",
"pallets/community",
"pallets/event",
"pallets/passport",
"pallets/proposal",
"pallets/token-swap",
"runtime",
]
Expand Down
6 changes: 3 additions & 3 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jur-node"
version = "3.3.0"
version = "3.4.0"
edition = "2021"
license = "Unlicense"
publish = false
Expand All @@ -16,7 +16,7 @@ name = "jur-node"
clap = { version = "4.4.11", features = ["derive"] }
hex-literal = '0.4.1'
serde = { version = "1.0.192", features = ["derive"] }
futures = { version = "0.3.29", features = ["thread-pool"]}
futures = { version = "0.3.30", features = ["thread-pool"]}
sc-cli = { version = "0.10.0-dev", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
sp-core = { version = "21.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
sc-executor = { version = "0.10.0-dev", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
Expand Down Expand Up @@ -58,7 +58,7 @@ frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", bran
frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.2.0" }

# Local Dependencies
jur-node-runtime = { version = "3.3.0", path = "../runtime" }
jur-node-runtime = { version = "3.4.0", path = "../runtime" }
primitives = { package = 'jur-primitives', path = '../primitives' }

# CLI-specific dependencies
Expand Down
58 changes: 58 additions & 0 deletions pallets/event/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[package]
name = "pallet-events"
version = "1.0.0"
description = "Jur Events Pallet"
authors = ["Jur Team <https://github.com/jurteam>"]
homepage = "https://jur.io/"
edition = "2021"
license = "Unlicense"
publish = false
repository = "https://github.com/jurteam/jur-chain/"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"], default-features = false }
primitives = { package = 'jur-primitives', path = '../../primitives', default-features = false }
scale-info = { version = "2.9.0", default-features = false, features = ["derive"] }

# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, optional = true, branch = "release-polkadot-v1.2.0" }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }

# Jur custom pallets
pallet-community = { package = 'pallet-community', path = '../community', default-features = false }
pallet-passport = { package = 'pallet-passport', path = '../passport', default-features = false }
pallet-whitelist = { package = 'pallet-whitelist', path = '../whitelist', default-features = false }

[dev-dependencies]
serde = { version = "1.0.132" }

# Substrate
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
pallet-insecure-randomness-collective-flip = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }


[features]
default = ["std"]
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"]
std = [
"codec/std",
"scale-info/std",
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"primitives/std",
"sp-std/std",
"sp-runtime/std",
"pallet-community/std",
"pallet-passport/std",
"pallet-timestamp/std",
]
try-runtime = [ "frame-support/try-runtime" ]
162 changes: 162 additions & 0 deletions pallets/event/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
//! Benchmarking setup for pallet-events
use super::*;

// use crate::Pallet;
use frame_benchmarking::{account, benchmarks, whitelisted_caller};
use frame_support::BoundedVec;
use frame_system::RawOrigin;
use pallet_community::types::{
Category, CommunityMetaData, CommunityType, Customs, Languages, Religions, Territories,
Traditions, Values,
};
use pallet_passport::types::BadgesType;
use sp_std::vec;
use sp_std::vec::Vec;
const SEED: u32 = 0;

fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
}

fn get_community_metadata<T: Config>() -> CommunityMetaData<T::StringLimit> {
let custom_one: Vec<u8> =
"in public transport young people should leave the seat to elderly or pregnant women"
.into();
let custom_two: Vec<u8> = "name newborns with a name that starts with the letter A".into();

let languages_1: Vec<u8> = "English".into();
let languages_2: Vec<u8> = "German".into();

let religions_1: Vec<u8> = "Christianity".into();
let religions_2: Vec<u8> = "Buddhism".into();

let territories: Vec<u8> = "Mars".into();

let traditions_1: Vec<u8> = "Exchange gifts for Christmas".into();
let traditions_2: Vec<u8> = "Organize one charity event every 100 blocks".into();

let values_1: Vec<u8> = "Peace".into();
let values_2: Vec<u8> = "No gender discrimination".into();

let community_metadata = CommunityMetaData {
customs: Some(vec![
Customs(custom_one.try_into().unwrap()),
Customs(custom_two.try_into().unwrap()),
]),
languages: Some(vec![
Languages(languages_1.try_into().unwrap()),
Languages(languages_2.try_into().unwrap()),
]),
norms: Some(vec![]),
religions: Some(vec![
Religions(religions_1.try_into().unwrap()),
Religions(religions_2.try_into().unwrap()),
]),
territories: Some(vec![Territories(territories.try_into().unwrap())]),
traditions: Some(vec![
Traditions(traditions_1.try_into().unwrap()),
Traditions(traditions_2.try_into().unwrap()),
]),
values: Some(vec![
Values(values_1.try_into().unwrap()),
Values(values_2.try_into().unwrap()),
]),
};

community_metadata
}

fn create_community<T: Config>(caller: T::AccountId) -> T::CommunityId {
let community_id =
pallet_community::NextCommunityId::<T>::get().unwrap_or(T::CommunityId::initial_value());

let members = vec![account("sub", 1, SEED), account("sub", 2, SEED), account("sub", 3, SEED)];

pallet_community::Pallet::<T>::create_community(
RawOrigin::Signed(caller).into(),
// hash of IPFS path of dummy logo
Some("bafkreifec54rzopwm6mvqm3fknmdlsw2yefpdr7xrgtsron62on2nynegq".into()),
"Jur".as_bytes().to_vec(),
Some(
"Jur is the core community of the Jur ecosystem, which includes all the contributors."
.into(),
),
Some(members),
Some(get_community_metadata::<T>()),
Category::Public,
Some("tag".into()),
Some("#222307".into()),
Some("#E76080".into()),
Some(CommunityType::Nation),
)
.unwrap();

community_id
}

pub fn add_founder<T: Config>(caller: T::AccountId) {
pallet_whitelist::Pallet::<T>::add_founder(RawOrigin::Root.into(), caller).unwrap();
}

fn add_badge<T: Config>(caller: T::AccountId, community_id: T::CommunityId) {
let badge_name: Vec<u8> = "DEV MEGA SPOT".into();
let bounded_badge_name: BoundedVec<u8, <T as pallet_passport::Config>::BadgeNameLimit> =
badge_name.try_into().unwrap();

let badge_description: Vec<u8> = "World largest hackathon to built on JUR".into();
let bounded_badge_description: BoundedVec<
u8,
<T as pallet_passport::Config>::DescriptionLimit,
> = badge_description.try_into().unwrap();

let badge_address: Vec<u8> =
"abcdreifec54rzopwm6mvqm3fknmdlsw2yefpdr7xrgtsron62on2nynegq".into();
let bounded_badge_address: BoundedVec<u8, <T as pallet_passport::Config>::AddressLimit> =
badge_address.try_into().unwrap();

pallet_passport::Pallet::<T>::add_badge(
RawOrigin::Signed(caller).into(),
community_id,
bounded_badge_name,
BadgesType::Participation,
bounded_badge_description,
bounded_badge_address,
)
.unwrap();
}

benchmarks! {
create_event {
let caller: T::AccountId = whitelisted_caller();
let member = account("sub", 1, SEED);
add_founder::<T>(caller.clone());
let community_id = create_community::<T>(caller.clone());
pallet_passport::Pallet::<T>::mint(RawOrigin::Signed(member).into(), community_id.clone()).unwrap();
add_badge::<T>(caller.clone(), community_id.clone());

let event_name: Vec<u8> = "Event for developers to built on JUR".into();
let bounded_event_name: BoundedVec<u8, <T as pallet::Config>::NameLimit> = event_name.try_into().unwrap();

let event_description: Vec<u8> = "World largest Event for developers to built on JUR".into();
let bounded_event_description: BoundedVec<u8, <T as pallet::Config>::DescriptionLimit> = event_description.try_into().unwrap();

let badge_name: Vec<u8> = "DEV MEGA SPOT".into();
let bounded_badge_name: BoundedVec<u8, <T as pallet_passport::Config>::BadgeNameLimit> = badge_name.try_into().unwrap();

}: _(
RawOrigin::Signed(caller.clone()),
community_id,
bounded_event_name,
bounded_event_description,
1703745212,
1703831612,
EventType::Virtual,
None,
bounded_badge_name
)
verify {
assert_last_event::<T>(Event::<T>::CreatedEvent(community_id, <T as pallet::Config>::Helper::event(1)).into());
}

impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
}
Loading

0 comments on commit a8c59c2

Please sign in to comment.