Add RPC Builder to Substrate Node Template (#6808)

* Pulled RPC from node and populated the node-template's RPC builder with one example implementation

* surpress build errror

* dead_code

* Fixed module usage, removed copyright, removed rpc builder for light client + some comments

* added a comment for rpc extension

* Update bin/node-template/node/src/rpc.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update rpc.rs

* fix spacing

* more space to tabs

* more space to tabs

* Documenation nitpick

* Documentation nitpick

* Documentation nitpick

* Documentation nitpick

* Documentation nitpick

* pre-format

* Updated transaction payment API implemented for node template

* fix space and commented code

* fix long line

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Dan Forbes <dan@danforbes.dev>
This commit is contained in:
Hamza Tokuchi
2020-08-06 12:31:03 +02:00
committed by GitHub
parent 886d79e0cb
commit 9e438c2fc1
8 changed files with 133 additions and 12 deletions
@@ -12,7 +12,6 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive"] }
aura = { version = "2.0.0-rc5", default-features = false, package = "pallet-aura", path = "../../../frame/aura" }
balances = { version = "2.0.0-rc5", default-features = false, package = "pallet-balances", path = "../../../frame/balances" }
frame-support = { version = "2.0.0-rc5", default-features = false, path = "../../../frame/support" }
@@ -36,6 +35,10 @@ sp-std = { version = "2.0.0-rc5", default-features = false, path = "../../../pri
sp-transaction-pool = { version = "2.0.0-rc5", default-features = false, path = "../../../primitives/transaction-pool" }
sp-version = { version = "2.0.0-rc5", default-features = false, path = "../../../primitives/version" }
# Used for the node template's RPCs
frame-system-rpc-runtime-api = { version = "2.0.0-rc5", default-features = false, path = "../../../frame/system/rpc/runtime-api/" }
pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0-rc5", default-features = false, path = "../../../frame/transaction-payment/rpc/runtime-api/" }
template = { version = "2.0.0-rc5", default-features = false, path = "../pallets/template", package = "pallet-template" }
[build-dependencies]
@@ -67,5 +70,7 @@ std = [
"system/std",
"timestamp/std",
"transaction-payment/std",
"frame-system-rpc-runtime-api/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"template/std",
]
@@ -417,4 +417,19 @@ impl_runtime_apis! {
None
}
}
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
fn account_nonce(account: AccountId) -> Index {
System::account_nonce(account)
}
}
impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
fn query_info(
uxt: <Block as BlockT>::Extrinsic,
len: u32,
) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
TransactionPayment::query_info(uxt, len)
}
}
}