Skip to content

Commit 64c3357

Browse files
authored
Add pallet-score-staking (#2896)
* init * add types * initial version * Add tests * bump versions * introduce score amplifier * add score-staking to rococo * remove comments * change runtime ts * use total_score * small refactor; add user count * add more fields to ScorePayment * bump rococo
1 parent 024e3ff commit 64c3357

File tree

14 files changed

+1262
-8
lines changed

14 files changed

+1262
-8
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ members = [
1313
'pallets/group',
1414
'pallets/identity-management',
1515
'pallets/parachain-staking',
16+
'pallets/score-staking',
1617
'pallets/teebag',
1718
'pallets/vc-management',
1819
'pallets/xcm-asset-manager',
@@ -77,6 +78,7 @@ tokio = { version = "1.38.0", features = ["macros", "sync"] }
7778
strum = { version = "0.26", default-features = false }
7879
strum_macros = { version = "0.26", default-features = false }
7980
num_enum = { version = "0.7.2", default-features = false }
81+
num-integer = { version = "0.1", default-features = false }
8082
rustc-hex = { version = "2.0.1", default-features = false }
8183
x509-cert = { version = "0.1.0", default-features = false, features = ["alloc"] }
8284
ring = { version = "0.16.20", default-features = false, features = ["alloc"] }
@@ -252,6 +254,7 @@ pallet-extrinsic-filter = { path = "pallets/extrinsic-filter", default-features
252254
pallet-group = { path = "pallets/group", default-features = false }
253255
pallet-identity-management = { path = "pallets/identity-management", default-features = false }
254256
pallet-parachain-staking = { path = "pallets/parachain-staking", default-features = false }
257+
pallet-score-staking = { path = "pallets/score-staking", default-features = false }
255258
pallet-teebag = { path = "pallets/teebag", default-features = false }
256259
pallet-vc-management = { path = "pallets/vc-management", default-features = false }
257260
precompile-utils = { path = "precompiles/utils", default-features = false }

node/src/chain_specs/rococo.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,5 +256,6 @@ fn generate_genesis(
256256
mode: TeebagOperationalMode::Development,
257257
},
258258
bitacross: BitacrossConfig { admin: Some(root_key) },
259+
score_staking: Default::default(),
259260
}
260261
}

pallets/parachain-staking/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ pub mod pallet {
521521
#[pallet::storage]
522522
#[pallet::getter(fn delegator_state)]
523523
/// Get delegator state associated with an account if account is delegating else None
524-
pub(crate) type DelegatorState<T: Config> = StorageMap<
524+
pub type DelegatorState<T: Config> = StorageMap<
525525
_,
526526
Twox64Concat,
527527
T::AccountId,
@@ -587,7 +587,7 @@ pub mod pallet {
587587
#[pallet::storage]
588588
#[pallet::getter(fn total)]
589589
/// Total capital locked by this staking pallet
590-
pub(crate) type Total<T: Config> = StorageValue<_, BalanceOf<T>, ValueQuery>;
590+
pub type Total<T: Config> = StorageValue<_, BalanceOf<T>, ValueQuery>;
591591

592592
#[pallet::storage]
593593
#[pallet::getter(fn candidate_pool)]

pallets/score-staking/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-score-staking"
3+
description = 'pallet to stake based on the oracle score'
4+
version = "0.1.0"
5+
edition = "2021"
6+
7+
[dependencies]
8+
num-integer = { workspace = true }
9+
parity-scale-codec = { workspace = true }
10+
scale-info = { workspace = true }
11+
serde = { workspace = true }
12+
serde_json = { workspace = true, features = ["alloc"] }
13+
14+
frame-benchmarking = { workspace = true, optional = true }
15+
frame-support = { workspace = true }
16+
frame-system = { workspace = true }
17+
sp-core = { workspace = true }
18+
sp-runtime = { workspace = true }
19+
sp-std = { workspace = true }
20+
21+
core-primitives = { workspace = true }
22+
pallet-parachain-staking = { workspace = true }
23+
24+
[dev-dependencies]
25+
sp-io = { workspace = true }
26+
pallet-balances = { workspace = true }
27+
sp-keyring = { workspace = true }
28+
29+
[features]
30+
default = ["std"]
31+
std = [
32+
"parity-scale-codec/std",
33+
"serde/std",
34+
"serde_json/std",
35+
"num-integer/std",
36+
"frame-benchmarking?/std",
37+
"frame-support/std",
38+
"frame-system/std",
39+
"scale-info/std",
40+
"sp-core/std",
41+
"sp-io/std",
42+
"sp-runtime/std",
43+
"sp-std/std",
44+
"pallet-balances/std",
45+
"core-primitives/std",
46+
"pallet-parachain-staking/std",
47+
]
48+
runtime-benchmarks = [
49+
"frame-benchmarking/runtime-benchmarks",
50+
"frame-support/runtime-benchmarks",
51+
"frame-system/runtime-benchmarks",
52+
"sp-runtime/runtime-benchmarks",
53+
]
54+
try-runtime = [
55+
"frame-support/try-runtime",
56+
"frame-system/try-runtime",
57+
"sp-runtime/try-runtime",
58+
]

0 commit comments

Comments
 (0)