From 3ffeee35e468d8ce1e1fd90bd594620e253b59fa Mon Sep 17 00:00:00 2001 From: "terry.tu" Date: Wed, 13 Jan 2021 12:06:00 +0800 Subject: [PATCH] fix api bug --- Cargo.lock | 21 +++++++++++++++++++++ node/Cargo.toml | 1 + node/src/rpc.rs | 6 +++++- runtime/src/lib.rs | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cbc8708..a615047 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3641,6 +3641,26 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-contracts-rpc" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef28f226cba2527ee19b23501072d277d2cd8add5b8cdc055b7a4344503a696c" +dependencies = [ + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "pallet-contracts-primitives", + "pallet-contracts-rpc-runtime-api", + "parity-scale-codec", + "serde", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-rpc", + "sp-runtime", +] + [[package]] name = "pallet-contracts-rpc-runtime-api" version = "0.8.0" @@ -7782,6 +7802,7 @@ dependencies = [ "jsonrpc-core", "log", "pallet-contracts", + "pallet-contracts-rpc", "pallet-staking-rpc", "pallet-transaction-payment-rpc", "sc-basic-authorship", diff --git a/node/Cargo.toml b/node/Cargo.toml index 4dce8d3..356fa0a 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -55,6 +55,7 @@ frame-benchmarking-cli = { version = "2.0.0" } uart-runtime = { path = "../runtime" } pallet-staking-rpc = { path = "../pallets/staking/rpc" } pallet-contracts = { version = "2.0.0" } +pallet-contracts-rpc = { version = "0.8.0" } [build-dependencies] substrate-build-script-utils = { version = "2.0.0" } diff --git a/node/src/rpc.rs b/node/src/rpc.rs index d1add08..81ae0f9 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -7,7 +7,7 @@ use std::sync::Arc; -use uart_runtime::{opaque::Block, AccountId, Balance, Index}; +use uart_runtime::{opaque::Block, AccountId, Balance, Index, BlockNumber}; use sp_api::ProvideRuntimeApi; use sp_blockchain::{Error as BlockChainError, HeaderMetadata, HeaderBackend}; use sp_block_builder::BlockBuilder; @@ -35,12 +35,14 @@ pub fn create_full( C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: pallet_staking_rpc::StakingRuntimeApi, + C::Api: pallet_contracts_rpc::ContractsRuntimeApi, C::Api: BlockBuilder, P: TransactionPool + 'static, { use substrate_frame_rpc_system::{FullSystem, SystemApi}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; use pallet_staking_rpc::{Staking, StakingApi}; + use pallet_contracts_rpc::{Contracts, ContractsApi}; let mut io = jsonrpc_core::IoHandler::default(); let FullDeps { @@ -57,6 +59,8 @@ pub fn create_full( TransactionPaymentApi::to_delegate(TransactionPayment::new(client.clone())) ); + io.extend_with(ContractsApi::to_delegate(Contracts::new(client.clone()))); + io.extend_with( StakingApi::to_delegate(Staking::new(client.clone())) ); diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 91f05dc..40e3018 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -102,7 +102,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("uart"), impl_name: create_runtime_str!("uart"), authoring_version: 1, - spec_version: 20, + spec_version: 21, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1,