Skip to content

Commit

Permalink
Uncomment custom RPCs
Browse files Browse the repository at this point in the history
  • Loading branch information
F3Joule committed Dec 25, 2024
1 parent ab15a64 commit 98f0b0a
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 75 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ categories = ["cryptography::cryptocurrencies"]
[dependencies]
clap = { version = "4.3.12", features = ["derive"] }
log = "0.4.19"
codec = { package = "parity-scale-codec", version = "3.0.0" }
serde = { version = "1.0.171", features = ["derive"] }
hex-literal = "0.4.1"
jsonrpsee = { version = "0.16.2", features = ["server"] }
Expand Down
18 changes: 9 additions & 9 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,27 @@ where
+ Sync
+ 'static,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
// C::Api: pallet_creator_staking_rpc::CreatorStakingRuntimeApi<Block, AccountId, Balance>,
// C::Api: pallet_domains_rpc::DomainsRuntimeApi<Block, Balance>,
// C::Api: pallet_posts_rpc::PostsRuntimeApi<Block, AccountId>,
C::Api: pallet_creator_staking_rpc::CreatorStakingRuntimeApi<Block, AccountId, Balance>,
C::Api: pallet_domains_rpc::DomainsRuntimeApi<Block, Balance>,
C::Api: pallet_posts_rpc::PostsRuntimeApi<Block, AccountId>,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: BlockBuilder<Block>,
P: TransactionPool + Sync + Send + 'static,
{
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
// use pallet_creator_staking_rpc::{CreatorStaking, CreatorStakingApiServer};
// use pallet_domains_rpc::{Domains, DomainsApiServer};
// use pallet_posts_rpc::{Posts, PostsApiServer};
use pallet_creator_staking_rpc::{CreatorStaking, CreatorStakingApiServer};
use pallet_domains_rpc::{Domains, DomainsApiServer};
use pallet_posts_rpc::{Posts, PostsApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};

let mut module = RpcExtension::new(());
let FullDeps { client, pool, deny_unsafe } = deps;

module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
// module.merge(CreatorStaking::new(client.clone()).into_rpc())?;
// module.merge(Domains::new(client.clone()).into_rpc())?;
// module.merge(Posts::new(client).into_rpc())?;
module.merge(CreatorStaking::new(client.clone()).into_rpc())?;
module.merge(Domains::new(client.clone()).into_rpc())?;
module.merge(Posts::new(client).into_rpc())?;

Ok(module)
}
1 change: 0 additions & 1 deletion pallets/domains/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"]
pallet-domains-rpc-runtime-api = { path = "./runtime-api" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
6 changes: 3 additions & 3 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", def
parachain-info = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v1.0.0" }

# Custom Runtime API
#pallet-creator-staking-rpc-runtime-api = { path = "../pallets/creator-staking/rpc/runtime-api", default-features = false }
#pallet-domains-rpc-runtime-api = { path = "../pallets/domains/rpc/runtime-api", default-features = false }
#pallet-posts-rpc-runtime-api = { path = "../pallets/posts/rpc/runtime-api", default-features = false }
pallet-creator-staking-rpc-runtime-api = { path = "../pallets/creator-staking/rpc/runtime-api", default-features = false }
pallet-domains-rpc-runtime-api = { path = "../pallets/domains/rpc/runtime-api", default-features = false }
pallet-posts-rpc-runtime-api = { path = "../pallets/posts/rpc/runtime-api", default-features = false }

[features]
default = [
Expand Down
118 changes: 59 additions & 59 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,65 +1099,65 @@ impl_runtime_apis! {
}
}

// impl pallet_creator_staking_rpc_runtime_api::CreatorStakingApi<Block, AccountId, Balance>
// for Runtime
// {
// fn estimated_backer_rewards_by_creators(
// backer: AccountId,
// creators: Vec<CreatorId>,
// ) -> Vec<(CreatorId, Balance)> {
// CreatorStaking::estimated_backer_rewards_by_creators(backer, creators)
// }
//
// fn withdrawable_amounts_from_inactive_creators(
// backer: AccountId,
// ) -> Vec<(CreatorId, Balance)> {
// CreatorStaking::withdrawable_amounts_from_inactive_creators(backer)
// }
//
// fn available_claims_by_backer(
// backer: AccountId,
// ) -> Vec<(CreatorId, u32)> {
// CreatorStaking::available_claims_by_backer(backer)
// }
//
// fn estimated_creator_rewards(
// creator: CreatorId,
// ) -> Balance {
// CreatorStaking::estimated_creator_rewards(creator)
// }
//
// fn available_claims_by_creator(
// creator: CreatorId,
// ) -> Vec<EraIndex> {
// CreatorStaking::available_claims_by_creator(creator)
// }
// }
//
// impl pallet_domains_rpc_runtime_api::DomainsApi<Block, Balance> for Runtime {
// fn calculate_price(subdomain: Vec<u8>) -> Option<Balance> {
// Domains::calculate_price(&subdomain)
// }
// }
//
// impl pallet_posts_rpc_runtime_api::PostsApi<Block, AccountId> for Runtime {
// fn can_create_post(
// account: AccountId,
// space_id: SpaceId,
// content_opt: Option<Content>,
// ) -> DispatchResult {
// Posts::can_create_regular_post(account, space_id, content_opt)
// }
//
// fn can_create_comment(
// account: AccountId,
// root_post_id: PostId,
// parent_id_opt: Option<PostId>,
// content_opt: Option<Content>
// ) -> DispatchResult {
// Posts::can_create_comment(account, root_post_id, parent_id_opt, content_opt)
// }
// }
impl pallet_creator_staking_rpc_runtime_api::CreatorStakingApi<Block, AccountId, Balance>
for Runtime
{
fn estimated_backer_rewards_by_creators(
backer: AccountId,
creators: Vec<CreatorId>,
) -> Vec<(CreatorId, Balance)> {
CreatorStaking::estimated_backer_rewards_by_creators(backer, creators)
}

fn withdrawable_amounts_from_inactive_creators(
backer: AccountId,
) -> Vec<(CreatorId, Balance)> {
CreatorStaking::withdrawable_amounts_from_inactive_creators(backer)
}

fn available_claims_by_backer(
backer: AccountId,
) -> Vec<(CreatorId, u32)> {
CreatorStaking::available_claims_by_backer(backer)
}

fn estimated_creator_rewards(
creator: CreatorId,
) -> Balance {
CreatorStaking::estimated_creator_rewards(creator)
}

fn available_claims_by_creator(
creator: CreatorId,
) -> Vec<EraIndex> {
CreatorStaking::available_claims_by_creator(creator)
}
}

impl pallet_domains_rpc_runtime_api::DomainsApi<Block, Balance> for Runtime {
fn calculate_price(subdomain: Vec<u8>) -> Option<Balance> {
Domains::calculate_price(&subdomain)
}
}

impl pallet_posts_rpc_runtime_api::PostsApi<Block, AccountId> for Runtime {
fn can_create_post(
account: AccountId,
space_id: SpaceId,
content_opt: Option<Content>,
) -> DispatchResult {
Posts::can_create_regular_post(account, space_id, content_opt)
}

fn can_create_comment(
account: AccountId,
root_post_id: PostId,
parent_id_opt: Option<PostId>,
content_opt: Option<Content>
) -> DispatchResult {
Posts::can_create_comment(account, root_post_id, parent_id_opt, content_opt)
}
}

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
Expand Down

0 comments on commit 98f0b0a

Please sign in to comment.