Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add system api #351

Merged
merged 2 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions node/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
jsonrpc-core = "15.1.0"
node-primitives = { path = "../primitives" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
bifrost-flexible-fee-rpc = { path = "../../pallets/flexible-fee/rpc" }
bifrost-flexible-fee-rpc-runtime-api = { path = "../../pallets/flexible-fee/rpc/runtime-api" }
bifrost-salp-rpc-api = { path = "../../pallets/salp/rpc" }
Expand Down
27 changes: 18 additions & 9 deletions node/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ use bifrost_liquidity_mining_rpc_api::{LiquidityMiningRpcApi, LiquidityMiningRpc
use bifrost_liquidity_mining_rpc_runtime_api::LiquidityMiningRuntimeApi;
use bifrost_salp_rpc_api::{SalpRpcApi, SalpRpcWrapper};
use bifrost_salp_rpc_runtime_api::SalpRuntimeApi;
use node_primitives::{AccountId, Balance, Block, ParaId, PoolId};
use node_primitives::{AccountId, Balance, Block, Nonce, ParaId, PoolId};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
pub use sc_rpc_api::DenyUnsafe;
use sc_client_api::AuxStore;
use sc_rpc_api::DenyUnsafe;
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use substrate_frame_rpc_system::{FullSystem, SystemApi};
use zenlink_protocol_rpc::{ZenlinkProtocol, ZenlinkProtocolApi};
use zenlink_protocol_runtime_api::ZenlinkProtocolApi as ZenlinkProtocolRuntimeApi;

Expand All @@ -67,20 +70,26 @@ pub type RpcExtension = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
#[allow(non_snake_case)]
pub fn create_full<C, P>(deps: FullDeps<C, P>) -> RpcExtension
where
C: ProvideRuntimeApi<Block>,
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError>,
C: Send + Sync + 'static,
C: ProvideRuntimeApi<Block>
+ HeaderBackend<Block>
+ AuxStore
+ HeaderMetadata<Block, Error = BlockChainError>
+ Send
+ Sync
+ 'static,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: FeeRuntimeApi<Block, AccountId>,
C::Api: SalpRuntimeApi<Block, ParaId, AccountId>,
C::Api: LiquidityMiningRuntimeApi<Block, AccountId, PoolId>,
C::Api: ZenlinkProtocolRuntimeApi<Block, AccountId>,
P: TransactionPool + 'static,
C::Api: BlockBuilder<Block>,
P: TransactionPool + Sync + Send + 'static,
{
let FullDeps { client, .. } = deps;

let mut io = RpcExtension::default();
let mut io = jsonrpc_core::IoHandler::default();
let FullDeps { client, pool, deny_unsafe } = deps;

io.extend_with(SystemApi::to_delegate(FullSystem::new(client.clone(), pool, deny_unsafe)));
io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(client.clone())));

io.extend_with(FeeRpcApi::to_delegate(FlexibleFeeStruct::new(client.clone())));
Expand Down
5 changes: 4 additions & 1 deletion node/service/src/collator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ use cumulus_client_service::{
};
use cumulus_primitives_core::ParaId;
use node_primitives::PoolId;
pub use node_primitives::{AccountId, Block, BlockNumber, Hash, Header, ParaId as BifrostParaId};
pub use node_primitives::{
AccountId, Block, BlockNumber, Hash, Header, Nonce, ParaId as BifrostParaId,
};
use sc_client_api::ExecutorProvider;
use sc_consensus::LongestChain;
use sc_executor::NativeExecutionDispatch;
Expand Down Expand Up @@ -190,6 +192,7 @@ where
RuntimeApi::RuntimeApi:
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
RuntimeApi::RuntimeApi: sp_consensus_aura::AuraApi<Block, AuraId>,
RuntimeApi::RuntimeApi: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
RuntimeApi::RuntimeApi: FeeRuntimeApi<Block, AccountId>,
RuntimeApi::RuntimeApi: SalpRuntimeApi<Block, BifrostParaId, AccountId>,
RuntimeApi::RuntimeApi: LiquidityMiningRuntimeApi<Block, AccountId, PoolId>,
Expand Down
1 change: 0 additions & 1 deletion pallets/minter-reward/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ pub mod pallet {

#[pallet::event]
#[pallet::metadata(BalanceOf<T> = "Balance", CurrencyIdOf<T> = "CurrencyId")]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {}

#[pallet::pallet]
Expand Down