diff --git a/Cargo.lock b/Cargo.lock
index 9ce298d..854d911 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1736,6 +1736,8 @@ dependencies = [
"cumulus-relay-chain-interface",
"dc-orchestrator-chain-interface",
"dc-orchestrator-chain-rpc-interface",
+ "department-funding-rpc",
+ "department-funding-runtime-api",
"dp-core",
"flume 0.10.14",
"frame-benchmarking",
@@ -1754,6 +1756,12 @@ dependencies = [
"polkadot-parachain-primitives",
"polkadot-primitives",
"polkadot-service",
+ "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-chain-spec",
"sc-cli",
@@ -3154,6 +3162,19 @@ dependencies = [
"url",
]
+[[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"
@@ -11336,6 +11357,19 @@ 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"
@@ -11576,6 +11610,19 @@ 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"
@@ -11586,6 +11633,19 @@ dependencies = [
"sp-std",
]
+[[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"
diff --git a/container-chains/nodes/simple/Cargo.toml b/container-chains/nodes/simple/Cargo.toml
index 6faf7d6..93f5ca0 100644
--- a/container-chains/nodes/simple/Cargo.toml
+++ b/container-chains/nodes/simple/Cargo.toml
@@ -101,6 +101,23 @@ cumulus-relay-chain-interface = { 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 = { workspace = true }
diff --git a/container-chains/nodes/simple/src/chain_spec.rs b/container-chains/nodes/simple/src/chain_spec.rs
index 51124b6..a5df4a5 100644
--- a/container-chains/nodes/simple/src/chain_spec.rs
+++ b/container-chains/nodes/simple/src/chain_spec.rs
@@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Tanssi. If not, see .
+use hex_literal::hex;
use {
container_chain_template_simple_runtime::{
AccountId, MaintenanceModeConfig, MigrationsConfig, PolkadotXcmConfig, Signature,
@@ -208,5 +209,16 @@ pub fn pre_funded_accounts() -> Vec {
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(),
]
}
diff --git a/container-chains/nodes/simple/src/rpc.rs b/container-chains/nodes/simple/src/rpc.rs
index a65afce..573c559 100644
--- a/container-chains/nodes/simple/src/rpc.rs
+++ b/container-chains/nodes/simple/src/rpc.rs
@@ -71,8 +71,16 @@ where
C::Api: substrate_frame_rpc_system::AccountNonceApi,
C::Api: BlockBuilder,
P: TransactionPool + Sync + Send + '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 substrate_frame_rpc_system::{System, SystemApiServer};
+ use department_funding_rpc::DepartmentFundingApiServer;
+ use positive_externality_rpc::PositiveExternalityApiServer;
+ use profile_validation_rpc::ProfileValidationApiServer;
+ use project_tips_rpc::ProjectTipsApiServer;
let mut module = RpcExtension::new(());
let FullDeps {
@@ -83,7 +91,7 @@ where
xcm_senders,
} = deps;
- module.merge(System::new(client, pool, deny_unsafe).into_rpc())?;
+ module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
// Manual seal
if let Some(command_sink) = command_sink {
@@ -104,5 +112,10 @@ where
)?;
}
+ module.merge(profile_validation_rpc::ProfileValidation::new(client.clone()).into_rpc())?;
+ module.merge(department_funding_rpc::DepartmentFunding::new(client.clone()).into_rpc())?;
+ module.merge(positive_externality_rpc::PositiveExternality::new(client.clone()).into_rpc())?;
+ module.merge(project_tips_rpc::ProjectTips::new(client.clone()).into_rpc())?;
+
Ok(module)
}
diff --git a/container-chains/runtime-templates/simple/src/lib.rs b/container-chains/runtime-templates/simple/src/lib.rs
index 93c76fe..7991216 100644
--- a/container-chains/runtime-templates/simple/src/lib.rs
+++ b/container-chains/runtime-templates/simple/src/lib.rs
@@ -116,6 +116,13 @@ pub type SignedBlock = generic::SignedBlock;
/// BlockId type as expected by this runtime.
pub type BlockId = generic::BlockId;
+
+pub type ChallengePostId = u64;
+
+pub type DepartmentRequiredFundId = u64;
+
+pub type ProjectId = u64;
+
/// The SignedExtension to the basic transaction logic.
pub type SignedExtra = (
frame_system::CheckNonZeroSender,
@@ -779,6 +786,106 @@ mod benches {
}
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)
+ }
+ }
+
impl sp_api::Core for Runtime {
fn version() -> RuntimeVersion {
VERSION
diff --git a/custom-pallets/department-funding/department-funding-rpc/Cargo.toml b/custom-pallets/department-funding/department-funding-rpc/Cargo.toml
index 5310aa2..89fa224 100644
--- a/custom-pallets/department-funding/department-funding-rpc/Cargo.toml
+++ b/custom-pallets/department-funding/department-funding-rpc/Cargo.toml
@@ -11,4 +11,5 @@ sc-rpc = { workspace = true}
sp-api = { workspace = true }
sp-blockchain = {workspace = true }
sp-runtime = { workspace = true }
+parity-scale-codec = { workspace = true }
department-funding-runtime-api = { workspace = true}
\ No newline at end of file
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 ba1e12d..ea134fe 100644
--- a/custom-pallets/department-funding/department-funding-rpc/src/lib.rs
+++ b/custom-pallets/department-funding/department-funding-rpc/src/lib.rs
@@ -4,7 +4,7 @@ use jsonrpsee::{
proc_macros::rpc,
types::error::{CallError, ErrorCode, ErrorObject},
};
-use sp_api::codec::Codec;
+use parity_scale_codec::Codec;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_runtime::traits::Block as BlockT;
diff --git a/custom-pallets/positive-externality/positive-externality-rpc/Cargo.toml b/custom-pallets/positive-externality/positive-externality-rpc/Cargo.toml
index b7a0241..b7cff31 100644
--- a/custom-pallets/positive-externality/positive-externality-rpc/Cargo.toml
+++ b/custom-pallets/positive-externality/positive-externality-rpc/Cargo.toml
@@ -11,4 +11,5 @@ sc-rpc = { workspace = true }
sp-api = { workspace = true }
sp-blockchain = { workspace = true }
sp-runtime = { workspace = true }
+parity-scale-codec = { workspace = true }
positive-externality-runtime-api = { workspace = true}
\ No newline at end of file
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 60d9331..5de7fda 100644
--- a/custom-pallets/positive-externality/positive-externality-rpc/src/lib.rs
+++ b/custom-pallets/positive-externality/positive-externality-rpc/src/lib.rs
@@ -4,7 +4,7 @@ use jsonrpsee::{
types::error::{CallError, ErrorCode, ErrorObject},
};
use positive_externality_runtime_api::PositiveExternalityApi as PositiveExternalityRuntimeApi;
-use sp_api::codec::Codec;
+use parity_scale_codec::Codec;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_runtime::traits::Block as BlockT;
diff --git a/custom-pallets/profile-validation/profile-validation-rpc/Cargo.toml b/custom-pallets/profile-validation/profile-validation-rpc/Cargo.toml
index 225bf41..bcd67c5 100644
--- a/custom-pallets/profile-validation/profile-validation-rpc/Cargo.toml
+++ b/custom-pallets/profile-validation/profile-validation-rpc/Cargo.toml
@@ -11,4 +11,5 @@ sc-rpc = { workspace = true }
sp-api = { workspace = true }
sp-blockchain = { workspace = true }
sp-runtime = { workspace = true }
+parity-scale-codec = { workspace = true }
profile-validation-runtime-api = { workspace = true }
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 87a3fc2..d566f97 100644
--- a/custom-pallets/profile-validation/profile-validation-rpc/src/lib.rs
+++ b/custom-pallets/profile-validation/profile-validation-rpc/src/lib.rs
@@ -4,7 +4,7 @@ use jsonrpsee::{
types::error::{CallError, ErrorCode, ErrorObject},
};
use profile_validation_runtime_api::ProfileValidationApi as ProfileValidationRuntimeApi;
-use sp_api::codec::Codec;
+use parity_scale_codec::Codec;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_runtime::traits::Block as BlockT;
diff --git a/custom-pallets/project-tips/project-tips-rpc/Cargo.toml b/custom-pallets/project-tips/project-tips-rpc/Cargo.toml
index 026c604..078bd56 100644
--- a/custom-pallets/project-tips/project-tips-rpc/Cargo.toml
+++ b/custom-pallets/project-tips/project-tips-rpc/Cargo.toml
@@ -11,4 +11,5 @@ sc-rpc = { workspace = true }
sp-api = { workspace = true }
sp-blockchain = { workspace = true }
sp-runtime = { workspace = true }
+parity-scale-codec = { workspace = true }
project-tips-runtime-api = { workspace = true }
\ No newline at end of file
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 32bff04..d360516 100644
--- a/custom-pallets/project-tips/project-tips-rpc/src/lib.rs
+++ b/custom-pallets/project-tips/project-tips-rpc/src/lib.rs
@@ -4,7 +4,7 @@ use jsonrpsee::{
types::error::{CallError, ErrorCode, ErrorObject},
};
use project_tips_runtime_api::ProjectTipsApi as ProjectTipsRuntimeApi;
-use sp_api::codec::Codec;
+use parity_scale_codec::Codec;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_runtime::traits::Block as BlockT;
diff --git a/docs/new_code.md b/docs/new_code.md
index 3167ef6..344f710 100644
--- a/docs/new_code.md
+++ b/docs/new_code.md
@@ -55,7 +55,7 @@ strum = { version = "0.26.2", default-features = false, features = ["derive"] }
num-integer = {default-features = false, version= "0.1.44"}
frame-support-test ={ git = "https://github.com/moondance-labs/polkadot-sdk", branch = "tanssi-polkadot-v1.6.0", default-features = false}
pallet-insecure-randomness-collective-flip = { git = "https://github.com/moondance-labs/polkadot-sdk", branch = "tanssi-polkadot-v1.6.0", default-features = false}
-
+sp-npos-elections = { git = "https://github.com/moondance-labs/polkadot-sdk", branch = "tanssi-polkadot-v1.6.0", default-features = false }
## New end
@@ -220,6 +220,120 @@ construct_runtime!(
```
+## Runtime apis
+*runtime-templates/simple/src/lib.rs*
+
+```rust
+
+pub type ChallengePostId = u64;
+
+pub type DepartmentRequiredFundId = u64;
+
+pub type ProjectId = u64;
+
+
+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)
+ }
+ }
+```
+
### **nodes/simple/src/chain_spec.rs**
```rust
@@ -238,3 +352,180 @@ fn testnet_genesis(
```toml
pallet-shared-storage = { workspace = true }
```
+
+## node rpc
+
+*container-chains/nodes/simple/rpc.rs*
+
+
+```rust
+/// Instantiate all full RPC extensions.
+pub fn create_full(
+ deps: FullDeps,
+) -> Result, Box>
+where
+ C: ProvideRuntimeApi,
+ C: HeaderBackend + HeaderMetadata + 'static,
+ C: Send + Sync + 'static,
+ C::Api: substrate_frame_rpc_system::AccountNonceApi,
+ C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi,
+ 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,
+ C::Api: BlockBuilder,
+ P: TransactionPool + 'static,
+{
+ use department_funding_rpc::DepartmentFundingApiServer;
+ use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
+ use positive_externality_rpc::PositiveExternalityApiServer;
+ use profile_validation_rpc::ProfileValidationApiServer;
+ use project_tips_rpc::ProjectTipsApiServer;
+ use substrate_frame_rpc_system::{System, SystemApiServer};
+
+ let mut module = RpcModule::new(());
+ let FullDeps { client, pool, deny_unsafe } = deps;
+
+ module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?;
+ module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
+ module.merge(profile_validation_rpc::ProfileValidation::new(client.clone()).into_rpc())?;
+ module.merge(department_funding_rpc::DepartmentFunding::new(client.clone()).into_rpc())?;
+ module.merge(positive_externality_rpc::PositiveExternality::new(client.clone()).into_rpc())?;
+ module.merge(project_tips_rpc::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
+ // to call into the runtime.
+ // `module.merge(YourRpcTrait::into_rpc(YourRpcStruct::new(ReferenceToClient, ...)))?;`
+
+ Ok(module)
+}
+
+```
+
+## Node rpc new code
+
+```rust
+/// Instantiate all RPC extensions.
+pub fn create_full(
+ deps: FullDeps,
+) -> Result>
+where
+ C: ProvideRuntimeApi
+ + HeaderBackend
+ + AuxStore
+ + HeaderMetadata
+ + Send
+ + Sync
+ + 'static,
+ C::Api: substrate_frame_rpc_system::AccountNonceApi,
+ C::Api: BlockBuilder,
+ P: TransactionPool + Sync + Send + '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 substrate_frame_rpc_system::{System, SystemApiServer};
+ use department_funding_rpc::DepartmentFundingApiServer;
+ use positive_externality_rpc::PositiveExternalityApiServer;
+ use profile_validation_rpc::ProfileValidationApiServer;
+ use project_tips_rpc::ProjectTipsApiServer;
+
+ let mut module = RpcExtension::new(());
+ let FullDeps {
+ client,
+ pool,
+ deny_unsafe,
+ command_sink,
+ xcm_senders,
+ } = deps;
+
+ module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
+
+ // Manual seal
+ if let Some(command_sink) = command_sink {
+ module.merge(
+ // We provide the rpc handler with the sending end of the channel to allow the rpc
+ // send EngineCommands to the background block authorship task.
+ ManualSeal::new(command_sink).into_rpc(),
+ )?;
+ };
+
+ if let Some((downward_message_channel, hrmp_message_channel)) = xcm_senders {
+ module.merge(
+ ManualXcm {
+ downward_message_channel,
+ hrmp_message_channel,
+ }
+ .into_rpc(),
+ )?;
+ }
+
+ module.merge(profile_validation_rpc::ProfileValidation::new(client.clone()).into_rpc())?;
+ module.merge(department_funding_rpc::DepartmentFunding::new(client.clone()).into_rpc())?;
+ module.merge(positive_externality_rpc::PositiveExternality::new(client.clone()).into_rpc())?;
+ module.merge(project_tips_rpc::ProjectTips::new(client.clone()).into_rpc())?;
+
+ Ok(module)
+}
+```
+
+*container-chains/nodes/simple/Cargo.toml*
+
+```toml
+# 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 }
+```
+
+## Chain spec
+
+*container-chains/nodes/simple/chain_spec.rs*
+
+
+```rust
+/// Get pre-funded accounts
+pub fn pre_funded_accounts() -> Vec {
+ vec![
+ get_account_id_from_seed::("Alice"),
+ get_account_id_from_seed::("Bob"),
+ get_account_id_from_seed::("Charlie"),
+ get_account_id_from_seed::("Dave"),
+ get_account_id_from_seed::("Eve"),
+ get_account_id_from_seed::("Ferdie"),
+ get_account_id_from_seed::("Alice//stash"),
+ get_account_id_from_seed::("Bob//stash"),
+ get_account_id_from_seed::("Charlie//stash"),
+ 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(),
+ ]
+}
+```
+
+