Skip to content

Commit a8c59c2

Browse files
authored
Merge pull request #264 from jurteam/staging
Release train 3.4.0
2 parents 2739892 + 180a0fd commit a8c59c2

File tree

15 files changed

+1612
-1263
lines changed

15 files changed

+1612
-1263
lines changed

Cargo.lock

Lines changed: 391 additions & 1253 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
resolver = "2"
33
members = [
44
"node",
5+
"pallets/bounties",
6+
"pallets/community",
7+
"pallets/event",
8+
"pallets/passport",
9+
"pallets/proposal",
510
"pallets/token-swap",
611
"runtime",
712
]

node/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "jur-node"
3-
version = "3.3.0"
3+
version = "3.4.0"
44
edition = "2021"
55
license = "Unlicense"
66
publish = false
@@ -16,7 +16,7 @@ name = "jur-node"
1616
clap = { version = "4.4.11", features = ["derive"] }
1717
hex-literal = '0.4.1'
1818
serde = { version = "1.0.192", features = ["derive"] }
19-
futures = { version = "0.3.29", features = ["thread-pool"]}
19+
futures = { version = "0.3.30", features = ["thread-pool"]}
2020
sc-cli = { version = "0.10.0-dev", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
2121
sp-core = { version = "21.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
2222
sc-executor = { version = "0.10.0-dev", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
@@ -58,7 +58,7 @@ frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", bran
5858
frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.2.0" }
5959

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

6464
# CLI-specific dependencies

pallets/event/Cargo.toml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[package]
2+
name = "pallet-events"
3+
version = "1.0.0"
4+
description = "Jur Events Pallet"
5+
authors = ["Jur Team <https://github.com/jurteam>"]
6+
homepage = "https://jur.io/"
7+
edition = "2021"
8+
license = "Unlicense"
9+
publish = false
10+
repository = "https://github.com/jurteam/jur-chain/"
11+
12+
[package.metadata.docs.rs]
13+
targets = ["x86_64-unknown-linux-gnu"]
14+
15+
[dependencies]
16+
codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"], default-features = false }
17+
primitives = { package = 'jur-primitives', path = '../../primitives', default-features = false }
18+
scale-info = { version = "2.9.0", default-features = false, features = ["derive"] }
19+
20+
# Substrate
21+
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, optional = true, branch = "release-polkadot-v1.2.0" }
22+
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
23+
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
24+
pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
25+
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
26+
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
27+
28+
# Jur custom pallets
29+
pallet-community = { package = 'pallet-community', path = '../community', default-features = false }
30+
pallet-passport = { package = 'pallet-passport', path = '../passport', default-features = false }
31+
pallet-whitelist = { package = 'pallet-whitelist', path = '../whitelist', default-features = false }
32+
33+
[dev-dependencies]
34+
serde = { version = "1.0.132" }
35+
36+
# Substrate
37+
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
38+
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.2.0" }
39+
pallet-insecure-randomness-collective-flip = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
40+
41+
42+
[features]
43+
default = ["std"]
44+
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"]
45+
std = [
46+
"codec/std",
47+
"scale-info/std",
48+
"frame-benchmarking/std",
49+
"frame-support/std",
50+
"frame-system/std",
51+
"primitives/std",
52+
"sp-std/std",
53+
"sp-runtime/std",
54+
"pallet-community/std",
55+
"pallet-passport/std",
56+
"pallet-timestamp/std",
57+
]
58+
try-runtime = [ "frame-support/try-runtime" ]

pallets/event/src/benchmarking.rs

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
//! Benchmarking setup for pallet-events
2+
use super::*;
3+
4+
// use crate::Pallet;
5+
use frame_benchmarking::{account, benchmarks, whitelisted_caller};
6+
use frame_support::BoundedVec;
7+
use frame_system::RawOrigin;
8+
use pallet_community::types::{
9+
Category, CommunityMetaData, CommunityType, Customs, Languages, Religions, Territories,
10+
Traditions, Values,
11+
};
12+
use pallet_passport::types::BadgesType;
13+
use sp_std::vec;
14+
use sp_std::vec::Vec;
15+
const SEED: u32 = 0;
16+
17+
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
18+
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
19+
}
20+
21+
fn get_community_metadata<T: Config>() -> CommunityMetaData<T::StringLimit> {
22+
let custom_one: Vec<u8> =
23+
"in public transport young people should leave the seat to elderly or pregnant women"
24+
.into();
25+
let custom_two: Vec<u8> = "name newborns with a name that starts with the letter A".into();
26+
27+
let languages_1: Vec<u8> = "English".into();
28+
let languages_2: Vec<u8> = "German".into();
29+
30+
let religions_1: Vec<u8> = "Christianity".into();
31+
let religions_2: Vec<u8> = "Buddhism".into();
32+
33+
let territories: Vec<u8> = "Mars".into();
34+
35+
let traditions_1: Vec<u8> = "Exchange gifts for Christmas".into();
36+
let traditions_2: Vec<u8> = "Organize one charity event every 100 blocks".into();
37+
38+
let values_1: Vec<u8> = "Peace".into();
39+
let values_2: Vec<u8> = "No gender discrimination".into();
40+
41+
let community_metadata = CommunityMetaData {
42+
customs: Some(vec![
43+
Customs(custom_one.try_into().unwrap()),
44+
Customs(custom_two.try_into().unwrap()),
45+
]),
46+
languages: Some(vec![
47+
Languages(languages_1.try_into().unwrap()),
48+
Languages(languages_2.try_into().unwrap()),
49+
]),
50+
norms: Some(vec![]),
51+
religions: Some(vec![
52+
Religions(religions_1.try_into().unwrap()),
53+
Religions(religions_2.try_into().unwrap()),
54+
]),
55+
territories: Some(vec![Territories(territories.try_into().unwrap())]),
56+
traditions: Some(vec![
57+
Traditions(traditions_1.try_into().unwrap()),
58+
Traditions(traditions_2.try_into().unwrap()),
59+
]),
60+
values: Some(vec![
61+
Values(values_1.try_into().unwrap()),
62+
Values(values_2.try_into().unwrap()),
63+
]),
64+
};
65+
66+
community_metadata
67+
}
68+
69+
fn create_community<T: Config>(caller: T::AccountId) -> T::CommunityId {
70+
let community_id =
71+
pallet_community::NextCommunityId::<T>::get().unwrap_or(T::CommunityId::initial_value());
72+
73+
let members = vec![account("sub", 1, SEED), account("sub", 2, SEED), account("sub", 3, SEED)];
74+
75+
pallet_community::Pallet::<T>::create_community(
76+
RawOrigin::Signed(caller).into(),
77+
// hash of IPFS path of dummy logo
78+
Some("bafkreifec54rzopwm6mvqm3fknmdlsw2yefpdr7xrgtsron62on2nynegq".into()),
79+
"Jur".as_bytes().to_vec(),
80+
Some(
81+
"Jur is the core community of the Jur ecosystem, which includes all the contributors."
82+
.into(),
83+
),
84+
Some(members),
85+
Some(get_community_metadata::<T>()),
86+
Category::Public,
87+
Some("tag".into()),
88+
Some("#222307".into()),
89+
Some("#E76080".into()),
90+
Some(CommunityType::Nation),
91+
)
92+
.unwrap();
93+
94+
community_id
95+
}
96+
97+
pub fn add_founder<T: Config>(caller: T::AccountId) {
98+
pallet_whitelist::Pallet::<T>::add_founder(RawOrigin::Root.into(), caller).unwrap();
99+
}
100+
101+
fn add_badge<T: Config>(caller: T::AccountId, community_id: T::CommunityId) {
102+
let badge_name: Vec<u8> = "DEV MEGA SPOT".into();
103+
let bounded_badge_name: BoundedVec<u8, <T as pallet_passport::Config>::BadgeNameLimit> =
104+
badge_name.try_into().unwrap();
105+
106+
let badge_description: Vec<u8> = "World largest hackathon to built on JUR".into();
107+
let bounded_badge_description: BoundedVec<
108+
u8,
109+
<T as pallet_passport::Config>::DescriptionLimit,
110+
> = badge_description.try_into().unwrap();
111+
112+
let badge_address: Vec<u8> =
113+
"abcdreifec54rzopwm6mvqm3fknmdlsw2yefpdr7xrgtsron62on2nynegq".into();
114+
let bounded_badge_address: BoundedVec<u8, <T as pallet_passport::Config>::AddressLimit> =
115+
badge_address.try_into().unwrap();
116+
117+
pallet_passport::Pallet::<T>::add_badge(
118+
RawOrigin::Signed(caller).into(),
119+
community_id,
120+
bounded_badge_name,
121+
BadgesType::Participation,
122+
bounded_badge_description,
123+
bounded_badge_address,
124+
)
125+
.unwrap();
126+
}
127+
128+
benchmarks! {
129+
create_event {
130+
let caller: T::AccountId = whitelisted_caller();
131+
let member = account("sub", 1, SEED);
132+
add_founder::<T>(caller.clone());
133+
let community_id = create_community::<T>(caller.clone());
134+
pallet_passport::Pallet::<T>::mint(RawOrigin::Signed(member).into(), community_id.clone()).unwrap();
135+
add_badge::<T>(caller.clone(), community_id.clone());
136+
137+
let event_name: Vec<u8> = "Event for developers to built on JUR".into();
138+
let bounded_event_name: BoundedVec<u8, <T as pallet::Config>::NameLimit> = event_name.try_into().unwrap();
139+
140+
let event_description: Vec<u8> = "World largest Event for developers to built on JUR".into();
141+
let bounded_event_description: BoundedVec<u8, <T as pallet::Config>::DescriptionLimit> = event_description.try_into().unwrap();
142+
143+
let badge_name: Vec<u8> = "DEV MEGA SPOT".into();
144+
let bounded_badge_name: BoundedVec<u8, <T as pallet_passport::Config>::BadgeNameLimit> = badge_name.try_into().unwrap();
145+
146+
}: _(
147+
RawOrigin::Signed(caller.clone()),
148+
community_id,
149+
bounded_event_name,
150+
bounded_event_description,
151+
1703745212,
152+
1703831612,
153+
EventType::Virtual,
154+
None,
155+
bounded_badge_name
156+
)
157+
verify {
158+
assert_last_event::<T>(Event::<T>::CreatedEvent(community_id, <T as pallet::Config>::Helper::event(1)).into());
159+
}
160+
161+
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
162+
}

0 commit comments

Comments
 (0)