diff --git a/Cargo.lock b/Cargo.lock index 2e2c497a..add547f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5960,7 +5960,6 @@ dependencies = [ "parity-scale-codec", "sp-api", "sp-blockchain", - "sp-core", "sp-rpc", "sp-runtime", ] @@ -12090,7 +12089,6 @@ dependencies = [ "pallet-domains-rpc", "pallet-posts-rpc", "pallet-transaction-payment-rpc", - "parity-scale-codec", "polkadot-cli", "polkadot-primitives", "sc-basic-authorship", @@ -12155,7 +12153,9 @@ dependencies = [ "pallet-balances", "pallet-collator-selection", "pallet-creator-staking", + "pallet-creator-staking-rpc-runtime-api", "pallet-domains", + "pallet-domains-rpc-runtime-api", "pallet-energy", "pallet-evm-addresses", "pallet-free-proxy", @@ -12165,6 +12165,7 @@ dependencies = [ "pallet-permissions", "pallet-post-follows", "pallet-posts", + "pallet-posts-rpc-runtime-api", "pallet-profiles", "pallet-proxy", "pallet-reactions", diff --git a/node/Cargo.toml b/node/Cargo.toml index da70a1c9..232ceb7b 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -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"] } diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 717ac08d..6dfa1ccb 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -48,17 +48,17 @@ where + Sync + 'static, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, - // C::Api: pallet_creator_staking_rpc::CreatorStakingRuntimeApi, - // C::Api: pallet_domains_rpc::DomainsRuntimeApi, - // C::Api: pallet_posts_rpc::PostsRuntimeApi, + C::Api: pallet_creator_staking_rpc::CreatorStakingRuntimeApi, + C::Api: pallet_domains_rpc::DomainsRuntimeApi, + C::Api: pallet_posts_rpc::PostsRuntimeApi, C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: BlockBuilder, 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(()); @@ -66,9 +66,9 @@ where 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) } diff --git a/pallets/domains/rpc/Cargo.toml b/pallets/domains/rpc/Cargo.toml index 55d335be..ac35b8bc 100644 --- a/pallets/domains/rpc/Cargo.toml +++ b/pallets/domains/rpc/Cargo.toml @@ -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" } diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 731ec4be..454ebaa7 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -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 = [ diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 58df8507..b7cf6609 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1099,65 +1099,65 @@ impl_runtime_apis! { } } - // impl pallet_creator_staking_rpc_runtime_api::CreatorStakingApi - // for Runtime - // { - // fn estimated_backer_rewards_by_creators( - // backer: AccountId, - // creators: Vec, - // ) -> 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 { - // CreatorStaking::available_claims_by_creator(creator) - // } - // } - // - // impl pallet_domains_rpc_runtime_api::DomainsApi for Runtime { - // fn calculate_price(subdomain: Vec) -> Option { - // Domains::calculate_price(&subdomain) - // } - // } - // - // impl pallet_posts_rpc_runtime_api::PostsApi for Runtime { - // fn can_create_post( - // account: AccountId, - // space_id: SpaceId, - // content_opt: Option, - // ) -> 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, - // content_opt: Option - // ) -> DispatchResult { - // Posts::can_create_comment(account, root_post_id, parent_id_opt, content_opt) - // } - // } + impl pallet_creator_staking_rpc_runtime_api::CreatorStakingApi + for Runtime + { + fn estimated_backer_rewards_by_creators( + backer: AccountId, + creators: Vec, + ) -> 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 { + CreatorStaking::available_claims_by_creator(creator) + } + } + + impl pallet_domains_rpc_runtime_api::DomainsApi for Runtime { + fn calculate_price(subdomain: Vec) -> Option { + Domains::calculate_price(&subdomain) + } + } + + impl pallet_posts_rpc_runtime_api::PostsApi for Runtime { + fn can_create_post( + account: AccountId, + space_id: SpaceId, + content_opt: Option, + ) -> 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, + content_opt: Option + ) -> DispatchResult { + Posts::can_create_comment(account, root_post_id, parent_id_opt, content_opt) + } + } #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime {