Remove contracts RPCs (#12358)

* Remove contracts RPCs

* Remove serde as RPC serialization is no longer needed

* Rename folder to match crate name

* Compile fix

* Remove Byte wrapper
This commit is contained in:
Alexander Theißen
2022-10-02 17:16:45 +02:00
committed by GitHub
parent 54713ca17a
commit bb9d2fa75a
22 changed files with 103 additions and 792 deletions
@@ -0,0 +1,34 @@
[package]
name = "pallet-contracts-runtime-api"
version = "4.0.0-dev"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
license = "Apache-2.0"
homepage = "https://substrate.io"
repository = "https://github.com/paritytech/substrate/"
description = "Runtime API definition used to provide dry-run capabilities"
readme = "README.md"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
# Substrate Dependencies
pallet-contracts-primitives = { version = "6.0.0", default-features = false, path = "../primitives" }
sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/api" }
sp-runtime = { version = "6.0.0", default-features = false, path = "../../../primitives/runtime" }
sp-std = { version = "4.0.0", default-features = false, path = "../../../primitives/std" }
[features]
default = ["std"]
std = [
"sp-api/std",
"codec/std",
"scale-info/std",
"sp-std/std",
"sp-runtime/std",
"pallet-contracts-primitives/std",
]
@@ -0,0 +1,7 @@
Runtime API definition used to provide dry-run capabilities
This API should be imported and implemented by the runtime,
of a node that wants to provide clients with dry-run
capabilities.
License: Apache-2.0
@@ -0,0 +1,85 @@
// This file is part of Substrate.
// Copyright (C) 2019-2022 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Runtime API definition used to provide dry-run capabilities.
//!
//! This API should be imported and implemented by the runtime,
//! of a node that wants to provide clients with dry-run
//! capabilities.
#![cfg_attr(not(feature = "std"), no_std)]
use codec::Codec;
use pallet_contracts_primitives::{
Code, CodeUploadResult, ContractExecResult, ContractInstantiateResult, GetStorageResult,
};
use sp_std::vec::Vec;
sp_api::decl_runtime_apis! {
/// The API to interact with contracts without using executive.
pub trait ContractsApi<AccountId, Balance, BlockNumber, Hash> where
AccountId: Codec,
Balance: Codec,
BlockNumber: Codec,
Hash: Codec,
{
/// Perform a call from a specified account to a given contract.
///
/// See `pallet_contracts::Pallet::call`.
fn call(
origin: AccountId,
dest: AccountId,
value: Balance,
gas_limit: u64,
storage_deposit_limit: Option<Balance>,
input_data: Vec<u8>,
) -> ContractExecResult<Balance>;
/// Instantiate a new contract.
///
/// See `pallet_contracts::Pallet::instantiate`.
fn instantiate(
origin: AccountId,
value: Balance,
gas_limit: u64,
storage_deposit_limit: Option<Balance>,
code: Code<Hash>,
data: Vec<u8>,
salt: Vec<u8>,
) -> ContractInstantiateResult<AccountId, Balance>;
/// Upload new code without instantiating a contract from it.
///
/// See `pallet_contracts::Pallet::upload_code`.
fn upload_code(
origin: AccountId,
code: Vec<u8>,
storage_deposit_limit: Option<Balance>,
) -> CodeUploadResult<Hash, Balance>;
/// Query a given storage key in a given contract.
///
/// Returns `Ok(Some(Vec<u8>))` if the storage value exists under the given key in the
/// specified account and `Ok(None)` if it doesn't. If the account specified by the address
/// doesn't exist, or doesn't have a contract then `Err` is returned.
fn get_storage(
address: AccountId,
key: Vec<u8>,
) -> GetStorageResult;
}
}