From 26ed94e66874aa89775640a022e08063b6081179 Mon Sep 17 00:00:00 2001 From: Amiya Behera Date: Sun, 28 Jul 2024 18:42:17 +0530 Subject: [PATCH] rpc update --- Cargo.lock | 205 ++++++++++++++++-- Cargo.toml | 5 + .../department-funding-rpc/src/lib.rs | 66 ++---- .../positive-externality-rpc/src/lib.rs | 74 +++---- .../profile-validation-rpc/src/lib.rs | 76 ++----- .../project-tips/project-tips-rpc/src/lib.rs | 72 +++--- docs/new_code.md | 1 + node/Cargo.toml | 20 ++ node/src/chain_spec.rs | 24 +- node/src/rpc.rs | 15 +- runtime/Cargo.toml | 51 ++++- runtime/src/lib.rs | 192 ++++++++++++++++ 12 files changed, 589 insertions(+), 212 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a8b26c6..7c352b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -383,7 +383,7 @@ dependencies = [ "num-bigint", "num-traits", "paste", - "rustc_version", + "rustc_version 0.4.0", "zeroize", ] @@ -777,9 +777,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitvec" @@ -935,9 +935,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" [[package]] name = "bzip2-sys" @@ -1538,7 +1538,7 @@ dependencies = [ "digest 0.10.7", "fiat-crypto", "platforms", - "rustc_version", + "rustc_version 0.4.0", "subtle 2.5.0", "zeroize", ] @@ -1637,6 +1637,29 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "department-funding-rpc" +version = "0.1.0" +dependencies = [ + "department-funding-runtime-api", + "jsonrpsee", + "parity-scale-codec", + "sc-rpc", + "sp-api", + "sp-blockchain", + "sp-runtime", +] + +[[package]] +name = "department-funding-runtime-api" +version = "0.1.0" +dependencies = [ + "frame-support", + "parity-scale-codec", + "sp-api", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0)", +] + [[package]] name = "der" version = "0.7.8" @@ -1701,7 +1724,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version", + "rustc_version 0.4.0", "syn 1.0.109", ] @@ -2934,6 +2957,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30ed443af458ccb6d81c1e7e661545f94d3176752fb1df2f543b902a1e0f51e2" +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + [[package]] name = "hkdf" version = "0.12.4" @@ -3981,7 +4010,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "libc", "redox_syscall 0.4.1", ] @@ -4620,13 +4649,23 @@ name = "node-template" version = "0.0.0" dependencies = [ "clap", + "department-funding-rpc", + "department-funding-runtime-api", "frame-benchmarking-cli", "frame-system", "futures", + "hex-literal", "jsonrpsee", "node-template-runtime", + "pallet-shared-storage", "pallet-transaction-payment", "pallet-transaction-payment-rpc", + "positive-externality-rpc", + "positive-externality-runtime-api", + "profile-validation-rpc", + "profile-validation-runtime-api", + "project-tips-rpc", + "project-tips-runtime-api", "sc-basic-authorship", "sc-cli", "sc-client-api", @@ -4662,6 +4701,7 @@ dependencies = [ name = "node-template-runtime" version = "0.0.0" dependencies = [ + "department-funding-runtime-api", "frame-benchmarking", "frame-executive", "frame-support", @@ -4671,13 +4711,24 @@ dependencies = [ "frame-try-runtime", "pallet-aura", "pallet-balances", + "pallet-department-funding", "pallet-grandpa", + "pallet-insecure-randomness-collective-flip", + "pallet-positive-externality", + "pallet-profile-validation", + "pallet-project-tips", + "pallet-schelling-game-shared", + "pallet-shared-storage", + "pallet-sortition-sum-game", "pallet-sudo", "pallet-template", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "parity-scale-codec", + "positive-externality-runtime-api", + "profile-validation-runtime-api", + "project-tips-runtime-api", "scale-info", "sp-api", "sp-block-builder", @@ -4977,6 +5028,20 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0)", ] +[[package]] +name = "pallet-insecure-randomness-collective-flip" +version = "16.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0#3c3d6fceb82372a3019b37117aa453d564b212de" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "safe-mix", + "scale-info", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0)", +] + [[package]] name = "pallet-positive-externality" version = "4.0.0-dev" @@ -5675,6 +5740,29 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +[[package]] +name = "positive-externality-rpc" +version = "0.1.0" +dependencies = [ + "jsonrpsee", + "parity-scale-codec", + "positive-externality-runtime-api", + "sc-rpc", + "sp-api", + "sp-blockchain", + "sp-runtime", +] + +[[package]] +name = "positive-externality-runtime-api" +version = "0.1.0" +dependencies = [ + "frame-support", + "parity-scale-codec", + "sp-api", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0)", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -5823,6 +5911,52 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "profile-validation-rpc" +version = "0.1.0" +dependencies = [ + "jsonrpsee", + "parity-scale-codec", + "profile-validation-runtime-api", + "sc-rpc", + "sp-api", + "sp-blockchain", + "sp-runtime", +] + +[[package]] +name = "profile-validation-runtime-api" +version = "0.1.0" +dependencies = [ + "frame-support", + "parity-scale-codec", + "sp-api", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0)", +] + +[[package]] +name = "project-tips-rpc" +version = "0.1.0" +dependencies = [ + "jsonrpsee", + "parity-scale-codec", + "project-tips-runtime-api", + "sc-rpc", + "sp-api", + "sp-blockchain", + "sp-runtime", +] + +[[package]] +name = "project-tips-runtime-api" +version = "0.1.0" +dependencies = [ + "frame-support", + "parity-scale-codec", + "sp-api", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0)", +] + [[package]] name = "prometheus" version = "0.13.3" @@ -6097,7 +6231,7 @@ version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", ] [[package]] @@ -6392,6 +6526,15 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + [[package]] name = "rustc_version" version = "0.4.0" @@ -6430,7 +6573,7 @@ version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys 0.4.13", @@ -6470,7 +6613,7 @@ dependencies = [ "log", "ring 0.17.7", "rustls-pki-types", - "rustls-webpki 0.102.2", + "rustls-webpki 0.102.6", "subtle 2.5.0", "zeroize", ] @@ -6521,9 +6664,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.4.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-webpki" @@ -6537,9 +6680,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.2" +version = "0.102.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" dependencies = [ "ring 0.17.7", "rustls-pki-types", @@ -6569,6 +6712,15 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +[[package]] +name = "safe-mix" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" +dependencies = [ + "rustc_version 0.2.3", +] + [[package]] name = "safe_arch" version = "0.7.1" @@ -7675,11 +7827,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.2" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "core-foundation", "core-foundation-sys", "libc", @@ -7688,9 +7840,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" dependencies = [ "core-foundation-sys", "libc", @@ -7705,6 +7857,15 @@ dependencies = [ "semver-parser", ] +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + [[package]] name = "semver" version = "1.0.21" @@ -7924,7 +8085,7 @@ dependencies = [ "curve25519-dalek 4.1.2", "rand_core 0.6.4", "ring 0.17.7", - "rustc_version", + "rustc_version 0.4.0", "sha2 0.10.8", "subtle 2.5.0", ] @@ -9415,7 +9576,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "bytes", "futures-core", "futures-util", diff --git a/Cargo.toml b/Cargo.toml index 8f2305b..a7bcee2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,6 +96,10 @@ frame-support-test = { git = "https://github.com/paritytech/polkadot-sdk.git", t pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false } sp-npos-elections = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false} log = { version = "0.4.17", default-features = false } +jsonrpsee = { version = "0.22", features = ["client-core", "macros", "server"] } +sc-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false } +sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false } +hex-literal = { version= " 0.4.1" } ## New end parity-scale-codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = [ @@ -116,3 +120,4 @@ pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", tag sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false } sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false} sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false } +sp-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false } diff --git a/custom-pallets/department-funding/department-funding-rpc/src/lib.rs b/custom-pallets/department-funding/department-funding-rpc/src/lib.rs index cc0349d..ec6873f 100644 --- a/custom-pallets/department-funding/department-funding-rpc/src/lib.rs +++ b/custom-pallets/department-funding/department-funding-rpc/src/lib.rs @@ -1,8 +1,8 @@ use department_funding_runtime_api::DepartmentFundingApi as DepartmentFundingRuntimeApi; use jsonrpsee::{ - core::{Error as JsonRpseeError, RpcResult}, - proc_macros::rpc, - types::error::{CallError, ErrorCode, ErrorObject}, + core::RpcResult, + proc_macros::rpc, + types::{ErrorObject, ErrorObjectOwned}, }; use parity_scale_codec::Codec; use sp_api::ProvideRuntimeApi; @@ -109,13 +109,9 @@ where self.client.info().best_hash); let runtime_api_result = api.get_evidence_period_end_block(at, department_required_fund_id); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -130,13 +126,9 @@ where self.client.info().best_hash); let runtime_api_result = api.get_staking_period_end_block(at, department_required_fund_id); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -151,13 +143,9 @@ where self.client.info().best_hash); let runtime_api_result = api.get_drawing_period_end(at, department_required_fund_id); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -173,13 +161,9 @@ where self.client.info().best_hash); let runtime_api_result = api.get_commit_period_end_block(at, department_required_fund_id); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -195,13 +179,9 @@ where self.client.info().best_hash); let runtime_api_result = api.get_vote_period_end_block(at, department_required_fund_id); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -218,13 +198,9 @@ where self.client.info().best_hash); let runtime_api_result = api.selected_as_juror(at, department_required_fund_id, who); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } diff --git a/custom-pallets/positive-externality/positive-externality-rpc/src/lib.rs b/custom-pallets/positive-externality/positive-externality-rpc/src/lib.rs index 35527e4..24550ce 100644 --- a/custom-pallets/positive-externality/positive-externality-rpc/src/lib.rs +++ b/custom-pallets/positive-externality/positive-externality-rpc/src/lib.rs @@ -1,7 +1,7 @@ use jsonrpsee::{ - core::{Error as JsonRpseeError, RpcResult}, - proc_macros::rpc, - types::error::{CallError, ErrorCode, ErrorObject}, + core::RpcResult, + proc_macros::rpc, + types::{ErrorObject, ErrorObjectOwned}, }; use parity_scale_codec::Codec; use positive_externality_runtime_api::PositiveExternalityApi as PositiveExternalityRuntimeApi; @@ -107,13 +107,10 @@ where self.client.info().best_hash); let runtime_api_result = api.get_evidence_period_end_block(at, user_to_calculate); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -126,15 +123,14 @@ where let at = at.unwrap_or_else(|| // If the block hash is not supplied assume the best block. self.client.info().best_hash); + + + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let runtime_api_result = api.get_staking_period_end_block(at, user_to_calculate); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -149,13 +145,10 @@ where self.client.info().best_hash); let runtime_api_result = api.get_drawing_period_end(at, user_to_calculate); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -171,13 +164,10 @@ where self.client.info().best_hash); let runtime_api_result = api.get_commit_period_end_block(at, user_to_calculate); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -193,13 +183,10 @@ where self.client.info().best_hash); let runtime_api_result = api.get_vote_period_end_block(at, user_to_calculate); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -216,13 +203,10 @@ where self.client.info().best_hash); let runtime_api_result = api.selected_as_juror(at, user_to_calculate, who); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } diff --git a/custom-pallets/profile-validation/profile-validation-rpc/src/lib.rs b/custom-pallets/profile-validation/profile-validation-rpc/src/lib.rs index 2e8c557..d990609 100644 --- a/custom-pallets/profile-validation/profile-validation-rpc/src/lib.rs +++ b/custom-pallets/profile-validation/profile-validation-rpc/src/lib.rs @@ -1,7 +1,7 @@ use jsonrpsee::{ - core::{Error as JsonRpseeError, RpcResult}, - proc_macros::rpc, - types::error::{CallError, ErrorCode, ErrorObject}, + core::RpcResult, + proc_macros::rpc, + types::{ErrorObject, ErrorObjectOwned}, }; use parity_scale_codec::Codec; use profile_validation_runtime_api::ProfileValidationApi as ProfileValidationRuntimeApi; @@ -121,13 +121,9 @@ where let runtime_api_result = api.get_challengers_evidence(at, profile_user_account, offset, limit); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -143,13 +139,9 @@ where self.client.info().best_hash); let runtime_api_result = api.get_evidence_period_end_block(at, profile_user_account); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -164,13 +156,9 @@ where self.client.info().best_hash); let runtime_api_result = api.get_staking_period_end_block(at, profile_user_account); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -185,13 +173,9 @@ where self.client.info().best_hash); let runtime_api_result = api.get_drawing_period_end(at, profile_user_account); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -207,13 +191,9 @@ where self.client.info().best_hash); let runtime_api_result = api.get_commit_period_end_block(at, profile_user_account); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -229,13 +209,9 @@ where self.client.info().best_hash); let runtime_api_result = api.get_vote_period_end_block(at, profile_user_account); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -252,13 +228,9 @@ where self.client.info().best_hash); let runtime_api_result = api.selected_as_juror(at, profile_user_account, who); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } diff --git a/custom-pallets/project-tips/project-tips-rpc/src/lib.rs b/custom-pallets/project-tips/project-tips-rpc/src/lib.rs index 0bdcf77..8be6b27 100644 --- a/custom-pallets/project-tips/project-tips-rpc/src/lib.rs +++ b/custom-pallets/project-tips/project-tips-rpc/src/lib.rs @@ -1,7 +1,7 @@ use jsonrpsee::{ - core::{Error as JsonRpseeError, RpcResult}, - proc_macros::rpc, - types::error::{CallError, ErrorCode, ErrorObject}, + core::RpcResult, + proc_macros::rpc, + types::{ErrorObject, ErrorObjectOwned}, }; use parity_scale_codec::Codec; use project_tips_runtime_api::ProjectTipsApi as ProjectTipsRuntimeApi; @@ -109,13 +109,10 @@ where self.client.info().best_hash); let runtime_api_result = api.get_evidence_period_end_block(at, project_id); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -130,13 +127,10 @@ where self.client.info().best_hash); let runtime_api_result = api.get_staking_period_end_block(at, project_id); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -151,13 +145,10 @@ where self.client.info().best_hash); let runtime_api_result = api.get_drawing_period_end(at, project_id); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -173,13 +164,10 @@ where self.client.info().best_hash); let runtime_api_result = api.get_commit_period_end_block(at, project_id); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -195,13 +183,10 @@ where self.client.info().best_hash); let runtime_api_result = api.get_vote_period_end_block(at, project_id); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } @@ -218,13 +203,10 @@ where self.client.info().best_hash); let runtime_api_result = api.selected_as_juror(at, project_id, who); - fn map_err(error: impl ToString, desc: &'static str) -> CallError { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - desc, - Some(error.to_string()), - )) - } + + fn map_err(error: impl ToString, desc: &'static str) -> ErrorObjectOwned { + ErrorObject::owned(Error::RuntimeError.into(), desc, Some(error.to_string())) + } let res = runtime_api_result.map_err(|e| map_err(e, "Unable to query dispatch info."))?; Ok(res) } diff --git a/docs/new_code.md b/docs/new_code.md index cca1e02..ff6bfb7 100644 --- a/docs/new_code.md +++ b/docs/new_code.md @@ -192,6 +192,7 @@ impl pallet_department_funding::Config for Runtime { type SharedStorageSource = SharedStorage; type Currency = Balances; type SchellingGameSharedSource = SchellingGameShared; + type Reward = (); } impl pallet_project_tips::Config for Runtime { diff --git a/node/Cargo.toml b/node/Cargo.toml index 1faca74..f17e752 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -67,6 +67,26 @@ node-template-runtime = { path = "../runtime" } # CLI-specific dependencies try-runtime-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", optional = true } +hex-literal = { workspace = true } +pallet-shared-storage = { workspace = true } + +# profile valdiation rpc +profile-validation-runtime-api = { workspace = true } +profile-validation-rpc = { workspace = true } + + +# Department funding rpc +department-funding-runtime-api = { workspace = true } +department-funding-rpc= {workspace = true } + +# Postive exterality rpc +positive-externality-runtime-api = { workspace = true } +positive-externality-rpc= { workspace = true } + +# Project tip rpc +project-tips-runtime-api = { workspace = true } +project-tips-rpc= { workspace = true } + [build-dependencies] substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0" } diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 6e0d78f..9eac47f 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -4,7 +4,7 @@ use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_consensus_grandpa::AuthorityId as GrandpaId; use sp_core::{sr25519, Pair, Public}; use sp_runtime::traits::{IdentifyAccount, Verify}; - +use hex_literal::hex; // The URL for the telemetry server. // const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; @@ -52,6 +52,17 @@ pub fn development_config() -> Result { get_account_id_from_seed::("Bob"), get_account_id_from_seed::("Alice//stash"), get_account_id_from_seed::("Bob//stash"), + hex!("2e778beae3cc11fd7ea694f4ff8b54922d67e0599c356f393277ed9711d6364b").into(), + hex!("2e1c14cd13a2b090a62203809d8ce3eaac7417a4a0272438568eb04cae330669").into(), + hex!("ba0ce278d82ef9a686cb60a801125a8d11b32caa2456ebdcfe7ff687bb9bf540").into(), + hex!("600f10bdbf233ac6614eea62ae45d269b43c759e4ddf0bc1a70ffcbc95499c6c").into(), + hex!("c2da35a7aed402249295971abe8f10e0b03d861a0571e56115bcc6f8828dd939").into(), + hex!("186863b612097dec4ce7b9772381935baa7fc6dc7c44695f0384174f1b131156").into(), + hex!("70c3f87a26743fed9194f8fc67bfdd9a211f3b00f5c80459107022d096dbf928").into(), + hex!("cab4abef5dda97cc98eb0f3a5e0329bd2c1b892b5f442021a634c7e79e6f6e29").into(), + hex!("ac926b4e81989ca51c9ac6f0ef9c7db08d5334bb0a5c3b0194bf92d215b50f3f").into(), + hex!("186c72f04de9c1a74cee6836c08b6d56a88e90ab5a6127693a55379e8e03d919").into(), + hex!("b02de28c52fe59f9a3d8779cd8c6ee7439cba45e48e7ee582f5cc939c7b5946c").into(), ], true, )) @@ -85,6 +96,17 @@ pub fn local_testnet_config() -> Result { get_account_id_from_seed::("Dave//stash"), get_account_id_from_seed::("Eve//stash"), get_account_id_from_seed::("Ferdie//stash"), + hex!("2e778beae3cc11fd7ea694f4ff8b54922d67e0599c356f393277ed9711d6364b").into(), + hex!("2e1c14cd13a2b090a62203809d8ce3eaac7417a4a0272438568eb04cae330669").into(), + hex!("ba0ce278d82ef9a686cb60a801125a8d11b32caa2456ebdcfe7ff687bb9bf540").into(), + hex!("600f10bdbf233ac6614eea62ae45d269b43c759e4ddf0bc1a70ffcbc95499c6c").into(), + hex!("c2da35a7aed402249295971abe8f10e0b03d861a0571e56115bcc6f8828dd939").into(), + hex!("186863b612097dec4ce7b9772381935baa7fc6dc7c44695f0384174f1b131156").into(), + hex!("70c3f87a26743fed9194f8fc67bfdd9a211f3b00f5c80459107022d096dbf928").into(), + hex!("cab4abef5dda97cc98eb0f3a5e0329bd2c1b892b5f442021a634c7e79e6f6e29").into(), + hex!("ac926b4e81989ca51c9ac6f0ef9c7db08d5334bb0a5c3b0194bf92d215b50f3f").into(), + hex!("186c72f04de9c1a74cee6836c08b6d56a88e90ab5a6127693a55379e8e03d919").into(), + hex!("b02de28c52fe59f9a3d8779cd8c6ee7439cba45e48e7ee582f5cc939c7b5946c").into(), ], true, )) diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 246391a..186d8d9 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -38,15 +38,28 @@ where C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BlockBuilder, P: TransactionPool + 'static, + C::Api: profile_validation_runtime_api::ProfileValidationApi, + C::Api: department_funding_runtime_api::DepartmentFundingApi, + C::Api: positive_externality_runtime_api::PositiveExternalityApi, + C::Api: project_tips_runtime_api::ProjectTipsApi, { use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use substrate_frame_rpc_system::{System, SystemApiServer}; + use department_funding_rpc::{DepartmentFunding, DepartmentFundingApiServer}; + use positive_externality_rpc::{PositiveExternality, PositiveExternalityApiServer}; + use profile_validation_rpc::{ProfileValidation, ProfileValidationApiServer}; + use project_tips_rpc::{ProjectTips, ProjectTipsApiServer}; + let mut module = RpcModule::new(()); let FullDeps { client, pool, deny_unsafe } = deps; module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; - module.merge(TransactionPayment::new(client).into_rpc())?; + module.merge(TransactionPayment::new(client.clone()).into_rpc())?; + module.merge(ProfileValidation::new(client.clone()).into_rpc())?; + module.merge(DepartmentFunding::new(client.clone()).into_rpc())?; + module.merge(PositiveExternality::new(client.clone()).into_rpc())?; + module.merge(ProjectTips::new(client.clone()).into_rpc())?; // Extend this RPC with a custom API by using the following syntax. // `YourRpcStruct` should have a reference to a client, which is needed diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index d7d348a..fe19176 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -25,7 +25,9 @@ scale-info = { version = "2.10.0", default-features = false, features = [ ] } # frame -frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false, features = ["experimental"] } +frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false, features = [ + "experimental", +] } frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false } frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false, optional = true } frame-executive = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false } @@ -75,6 +77,27 @@ frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk. # The pallet in this template. pallet-template = { path = "../pallets/template", default-features = false } +pallet-insecure-randomness-collective-flip = { workspace = true } + + +pallet-sortition-sum-game = { workspace = true } +# pallet-election={ workspace = true } +# # election-runtime-api={ workspace = true } +# pallet-posts = { workspace = true } +# pallet-spaces = { workspace = true } +pallet-schelling-game-shared = { workspace = true } +pallet-profile-validation = { workspace = true } +# profile-validation-runtime-api = { workspace = true } +pallet-shared-storage = { workspace = true } +pallet-positive-externality = { workspace = true } +pallet-department-funding = { workspace = true } +pallet-project-tips = { workspace = true } + +profile-validation-runtime-api = { workspace = true } +positive-externality-runtime-api = { workspace = true } +department-funding-runtime-api = { workspace = true } +project-tips-runtime-api = { workspace = true } + [build-dependencies] substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", optional = true } @@ -118,6 +141,18 @@ std = [ "sp-version/std", "substrate-wasm-builder", + "pallet-insecure-randomness-collective-flip/std", + "pallet-sortition-sum-game/std", + "pallet-schelling-game-shared/std", + "pallet-profile-validation/std", + "pallet-shared-storage/std", + "pallet-positive-externality/std", + "pallet-department-funding/std", + "pallet-project-tips/std", + "profile-validation-runtime-api/std", + "positive-externality-runtime-api/std", + "department-funding-runtime-api/std", + "project-tips-runtime-api/std", ] runtime-benchmarks = [ @@ -131,6 +166,13 @@ runtime-benchmarks = [ "pallet-template/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "sp-runtime/runtime-benchmarks", + "pallet-sortition-sum-game/runtime-benchmarks", + "pallet-schelling-game-shared/runtime-benchmarks", + "pallet-profile-validation/runtime-benchmarks", + "pallet-shared-storage/runtime-benchmarks", + "pallet-positive-externality/runtime-benchmarks", + "pallet-department-funding/runtime-benchmarks", + "pallet-project-tips/runtime-benchmarks", ] try-runtime = [ @@ -146,6 +188,13 @@ try-runtime = [ "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", "sp-runtime/try-runtime", + "pallet-sortition-sum-game/try-runtime", + "pallet-schelling-game-shared/try-runtime", + "pallet-profile-validation/try-runtime", + "pallet-shared-storage/try-runtime", + "pallet-positive-externality/try-runtime", + "pallet-department-funding/try-runtime", + "pallet-project-tips/try-runtime", ] experimental = ["pallet-aura/experimental"] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index a8a5b78..41f2e72 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -63,6 +63,12 @@ pub type Nonce = u32; /// A hash of some data used by the chain. pub type Hash = sp_core::H256; +pub type ChallengePostId = u64; + +pub type DepartmentRequiredFundId = u64; + +pub type ProjectId = u64; + /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know /// the specifics of the runtime. They can then be made to be agnostic over specific formats /// of data like extrinsics, allowing for them to continue syncing the network through upgrades @@ -251,6 +257,67 @@ impl pallet_template::Config for Runtime { type WeightInfo = pallet_template::weights::SubstrateWeight; } +impl pallet_insecure_randomness_collective_flip::Config for Runtime {} + + +impl pallet_sortition_sum_game::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_sortition_sum_game::weights::SubstrateWeight; +} + +impl pallet_schelling_game_shared::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_schelling_game_shared::weights::SubstrateWeight; + type Currency = Balances; + type RandomnessSource = RandomnessCollectiveFlip; + type Slash = (); + type Reward = (); + type SortitionSumGameSource = SortitionSumGame; +} + +impl pallet_profile_validation::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_profile_validation::weights::SubstrateWeight; + type Currency = Balances; + type SchellingGameSharedSource = SchellingGameShared; + type Slash = (); + type Reward = (); +} + + +impl pallet_shared_storage::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_shared_storage::weights::SubstrateWeight; +} + +impl pallet_positive_externality::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_positive_externality::weights::SubstrateWeight; + type SharedStorageSource = SharedStorage; + type Currency = Balances; + type SchellingGameSharedSource = SchellingGameShared; + type Reward = (); +} + +impl pallet_department_funding::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_department_funding::weights::SubstrateWeight; + type SharedStorageSource = SharedStorage; + type Currency = Balances; + type SchellingGameSharedSource = SchellingGameShared; + type Reward = (); +} + +impl pallet_project_tips::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_project_tips::weights::SubstrateWeight; + type SharedStorageSource = SharedStorage; + type Currency = Balances; + type Reward = (); + type SchellingGameSharedSource = SchellingGameShared; +} + + // Create the runtime by composing the FRAME pallets that were previously configured. #[frame_support::runtime] mod runtime { @@ -292,6 +359,31 @@ mod runtime { // Include the custom logic from the pallet-template in the runtime. #[runtime::pallet_index(7)] pub type TemplateModule = pallet_template; + + #[runtime::pallet_index(8)] + pub type SortitionSumGame = pallet_sortition_sum_game; + + #[runtime::pallet_index(9)] + pub type SchellingGameShared = pallet_schelling_game_shared; + + #[runtime::pallet_index(10)] + pub type ProfileValidation = pallet_profile_validation; + + #[runtime::pallet_index(11)] + pub type SharedStorage = pallet_shared_storage; + + #[runtime::pallet_index(12)] + pub type PositiveExternality = pallet_positive_externality; + + #[runtime::pallet_index(13)] + pub type DepartmentFunding = pallet_department_funding; + + #[runtime::pallet_index(14)] + pub type ProjectTips = pallet_project_tips; + + #[runtime::pallet_index(15)] + pub type RandomnessCollectiveFlip = pallet_insecure_randomness_collective_flip; + } /// The address format for describing accounts. @@ -513,6 +605,106 @@ impl_runtime_apis! { } } + impl profile_validation_runtime_api::ProfileValidationApi for Runtime { + + fn get_challengers_evidence(profile_user_account: AccountId, offset: u64, limit: u16) -> Vec { + ProfileValidation::get_challengers_evidence(profile_user_account, offset, limit) + } + + fn get_evidence_period_end_block(profile_user_account: AccountId) -> Option { + ProfileValidation::get_evidence_period_end_block(profile_user_account) + } + + fn get_staking_period_end_block(profile_user_account: AccountId) -> Option { + ProfileValidation::get_staking_period_end_block(profile_user_account) + } + fn get_drawing_period_end(profile_user_account: AccountId) -> (u64, u64, bool) { + ProfileValidation::get_drawing_period_end(profile_user_account) + } + fn get_commit_period_end_block(profile_user_account: AccountId) -> Option { + ProfileValidation::get_commit_period_end_block(profile_user_account) + } + + fn get_vote_period_end_block(profile_user_account: AccountId) -> Option { + ProfileValidation::get_vote_period_end_block(profile_user_account) + } + fn selected_as_juror(profile_user_account: AccountId, who: AccountId) -> bool { + ProfileValidation::selected_as_juror(profile_user_account, who) + } + } + + impl department_funding_runtime_api::DepartmentFundingApi for Runtime { + + fn get_evidence_period_end_block(department_required_fund_id: DepartmentRequiredFundId) -> Option { + DepartmentFunding::get_evidence_period_end_block(department_required_fund_id) + } + + fn get_staking_period_end_block(department_required_fund_id: DepartmentRequiredFundId) -> Option { + DepartmentFunding::get_staking_period_end_block(department_required_fund_id) + } + fn get_drawing_period_end(department_required_fund_id: DepartmentRequiredFundId) -> (u64, u64, bool) { + DepartmentFunding::get_drawing_period_end(department_required_fund_id) + } + fn get_commit_period_end_block(department_required_fund_id: DepartmentRequiredFundId) -> Option { + DepartmentFunding::get_commit_period_end_block(department_required_fund_id) + } + + fn get_vote_period_end_block(department_required_fund_id: DepartmentRequiredFundId) -> Option { + DepartmentFunding::get_vote_period_end_block(department_required_fund_id) + } + fn selected_as_juror(department_required_fund_id: DepartmentRequiredFundId, who: AccountId) -> bool { + DepartmentFunding::selected_as_juror(department_required_fund_id, who) + } + } + + impl positive_externality_runtime_api::PositiveExternalityApi for Runtime { + + fn get_evidence_period_end_block(user_to_calculate: AccountId) -> Option { + PositiveExternality::get_evidence_period_end_block(user_to_calculate) + } + + fn get_staking_period_end_block(user_to_calculate: AccountId) -> Option { + PositiveExternality::get_staking_period_end_block(user_to_calculate) + } + fn get_drawing_period_end(user_to_calculate: AccountId) -> (u64, u64, bool) { + PositiveExternality::get_drawing_period_end(user_to_calculate) + } + fn get_commit_period_end_block(user_to_calculate: AccountId) -> Option { + PositiveExternality::get_commit_period_end_block(user_to_calculate) + } + + fn get_vote_period_end_block(user_to_calculate: AccountId) -> Option { + PositiveExternality::get_vote_period_end_block(user_to_calculate) + } + fn selected_as_juror(user_to_calculate: AccountId, who: AccountId) -> bool { + PositiveExternality::selected_as_juror(user_to_calculate, who) + } + } + + impl project_tips_runtime_api::ProjectTipsApi for Runtime { + + fn get_evidence_period_end_block(project_id: ProjectId) -> Option { + ProjectTips::get_evidence_period_end_block(project_id) + } + + fn get_staking_period_end_block(project_id: ProjectId) -> Option { + ProjectTips::get_staking_period_end_block(project_id) + } + fn get_drawing_period_end(project_id: ProjectId) -> (u64, u64, bool) { + ProjectTips::get_drawing_period_end(project_id) + } + fn get_commit_period_end_block(project_id: ProjectId) -> Option { + ProjectTips::get_commit_period_end_block(project_id) + } + + fn get_vote_period_end_block(project_id: ProjectId) -> Option { + ProjectTips::get_vote_period_end_block(project_id) + } + fn selected_as_juror(project_id: ProjectId, who: AccountId) -> bool { + ProjectTips::selected_as_juror(project_id, who) + } + } + #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { fn benchmark_metadata(extra: bool) -> (