git.delta.rocks / unique-network / refs/commits / e8fdadb89923

difftreelog

source

pallets/contracts/rpc/runtime-api/src/lib.rs2.7 KiBsourcehistory
1// This file is part of Substrate.23// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd.4// SPDX-License-Identifier: Apache-2.056// Licensed under the Apache License, Version 2.0 (the "License");7// you may not use this file except in compliance with the License.8// You may obtain a copy of the License at9//10// 	http://www.apache.org/licenses/LICENSE-2.011//12// Unless required by applicable law or agreed to in writing, software13// distributed under the License is distributed on an "AS IS" BASIS,14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15// See the License for the specific language governing permissions and16// limitations under the License.1718//! Runtime API definition required by Contracts RPC extensions.19//!20//! This API should be imported and implemented by the runtime,21//! of a node that wants to use the custom RPC extension22//! adding Contracts access methods.2324#![cfg_attr(not(feature = "std"), no_std)]2526use codec::Codec;27use sp_std::vec::Vec;28use pallet_contracts_primitives::{29	ContractExecResult, GetStorageResult, RentProjectionResult, Code, ContractInstantiateResult,30};3132sp_api::decl_runtime_apis! {33	/// The API to interact with contracts without using executive.34	pub trait ContractsApi<AccountId, Balance, BlockNumber, Hash> where35		AccountId: Codec,36		Balance: Codec,37		BlockNumber: Codec,38		Hash: Codec,39	{40		/// Perform a call from a specified account to a given contract.41		///42		/// See [`pallet_contracts::Pallet::call`].43		fn call(44			origin: AccountId,45			dest: AccountId,46			value: Balance,47			gas_limit: u64,48			input_data: Vec<u8>,49		) -> ContractExecResult;5051		/// Instantiate a new contract.52		///53		/// See [`pallet_contracts::Pallet::instantiate`].54		fn instantiate(55			origin: AccountId,56			endowment: Balance,57			gas_limit: u64,58			code: Code<Hash>,59			data: Vec<u8>,60			salt: Vec<u8>,61		) -> ContractInstantiateResult<AccountId, BlockNumber>;6263		/// Query a given storage key in a given contract.64		///65		/// Returns `Ok(Some(Vec<u8>))` if the storage value exists under the given key in the66		/// specified account and `Ok(None)` if it doesn't. If the account specified by the address67		/// doesn't exist, or doesn't have a contract or if the contract is a tombstone, then `Err`68		/// is returned.69		fn get_storage(70			address: AccountId,71			key: [u8; 32],72		) -> GetStorageResult;7374		/// Returns the projected time a given contract will be able to sustain paying its rent.75		///76		/// The returned projection is relevant for the current block, i.e. it is as if the contract77		/// was accessed at the current block.78		///79		/// Returns `Err` if the contract is in a tombstone state or doesn't exist.80		fn rent_projection(address: AccountId) -> RentProjectionResult<BlockNumber>;81	}82}