git.delta.rocks / unique-network / refs/commits / 6ec64feddc4d

difftreelog

Contracts rpc runtime added

str-mv2020-07-10parent: #dc1cc2f.patch.diff
in: master

4 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2553,6 +2553,7 @@
  "pallet-balances",
  "pallet-contracts",
  "pallet-contracts-primitives",
+ "pallet-contracts-rpc-runtime-api",
  "pallet-grandpa",
  "pallet-nft",
  "pallet-randomness-collective-flip",
modifiednode/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()
modifiedruntime/Cargo.tomldiffbeforeafterboth
24package = 'pallet-contracts-primitives'24package = 'pallet-contracts-primitives'
25version = '2.0.0-alpha.6'25version = '2.0.0-alpha.6'
26
27[dependencies.contracts-rpc-runtime-api]
28default-features = false
29package = 'pallet-contracts-rpc-runtime-api'
30version = '0.8.0-alpha.6'
2631
27[dependencies.frame-executive]32[dependencies.frame-executive]
28default-features = false33default-features = false
143 'aura/std',148 'aura/std',
144 'balances/std',149 'balances/std',
145 'codec/std',150 'codec/std',
146 'contracts/std',151 "contracts/std",
147 'contracts-primitives/std',152 "contracts-primitives/std",
153 "contracts-rpc-runtime-api/std",
148 'frame-executive/std',154 'frame-executive/std',
149 'frame-support/std',155 'frame-support/std',
150 'grandpa/std',156 'grandpa/std',
modifiedruntime/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)
+		}
+	}
 }