difftreelog
Contracts rpc runtime added
in: master
4 files changed
Cargo.lockdiffbeforeafterboth2553 "pallet-balances",2553 "pallet-balances",2554 "pallet-contracts",2554 "pallet-contracts",2555 "pallet-contracts-primitives",2555 "pallet-contracts-primitives",2556 "pallet-contracts-rpc-runtime-api",2556 "pallet-grandpa",2557 "pallet-grandpa",2557 "pallet-nft",2558 "pallet-nft",2558 "pallet-randomness-collective-flip",2559 "pallet-randomness-collective-flip",node/src/chain_spec.rsdiffbeforeafterboth--- a/node/src/chain_spec.rs
+++ b/node/src/chain_spec.rs
@@ -122,7 +122,7 @@
key: root_key,
}),
contracts: Some(ContractsConfig {
- gas_price: 1_000_000_000,
+ gas_price: 1_000,
current_schedule: ContractsSchedule {
// enable_println,
..Default::default()
runtime/Cargo.tomldiffbeforeafterboth--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -24,6 +24,11 @@
package = 'pallet-contracts-primitives'
version = '2.0.0-alpha.6'
+[dependencies.contracts-rpc-runtime-api]
+default-features = false
+package = 'pallet-contracts-rpc-runtime-api'
+version = '0.8.0-alpha.6'
+
[dependencies.frame-executive]
default-features = false
version = '2.0.0-alpha.6'
@@ -143,8 +148,9 @@
'aura/std',
'balances/std',
'codec/std',
- 'contracts/std',
- 'contracts-primitives/std',
+ "contracts/std",
+ "contracts-primitives/std",
+ "contracts-rpc-runtime-api/std",
'frame-executive/std',
'frame-support/std',
'grandpa/std',
runtime/src/lib.rsdiffbeforeafterboth--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -36,6 +36,9 @@
pub use sp_runtime::{Perbill, Permill};
pub use timestamp::Call as TimestampCall;
pub use contracts::Schedule as ContractsSchedule;
+pub use contracts_rpc_runtime_api::{
+ self as runtime_api, ContractExecResult
+};
/// Importing a template pallet
pub use nft;
@@ -403,4 +406,39 @@
Grandpa::grandpa_authorities()
}
}
+
+ impl contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>
+ for Runtime
+ {
+ fn call(
+ origin: AccountId,
+ dest: AccountId,
+ value: Balance,
+ gas_limit: u64,
+ input_data: Vec<u8>,
+ ) -> ContractExecResult {
+ let exec_result =
+ Contracts::bare_call(origin, dest.into(), value, gas_limit, input_data);
+ match exec_result {
+ Ok(v) => ContractExecResult::Success {
+ status: v.status,
+ data: v.data,
+ },
+ Err(_) => ContractExecResult::Error,
+ }
+ }
+
+ fn get_storage(
+ address: AccountId,
+ key: [u8; 32],
+ ) -> contracts_primitives::GetStorageResult {
+ Contracts::get_storage(address, key)
+ }
+
+ fn rent_projection(
+ address: AccountId,
+ ) -> contracts_primitives::RentProjectionResult<BlockNumber> {
+ Contracts::rent_projection(address)
+ }
+ }
}