mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
Use Option<Weight> for contract dry-runs (#12429)
This commit is contained in:
committed by
GitHub
parent
9e423925f6
commit
261c5fd6dd
@@ -105,7 +105,7 @@ use crate::{
|
||||
wasm::{OwnerInfo, PrefabWasmModule},
|
||||
weights::WeightInfo,
|
||||
};
|
||||
use codec::{Encode, HasCompact};
|
||||
use codec::{Codec, Encode, HasCompact};
|
||||
use frame_support::{
|
||||
dispatch::{Dispatchable, GetDispatchInfo, Pays, PostDispatchInfo},
|
||||
ensure,
|
||||
@@ -1171,3 +1171,58 @@ where
|
||||
Weight::from(gas_limit).set_proof_size(u64::from(T::MaxCodeLen::get()) * 2)
|
||||
}
|
||||
}
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
/// The API used to dry-run contract interactions.
|
||||
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 [`crate::Pallet::bare_call`].
|
||||
fn call(
|
||||
origin: AccountId,
|
||||
dest: AccountId,
|
||||
value: Balance,
|
||||
gas_limit: Option<Weight>,
|
||||
storage_deposit_limit: Option<Balance>,
|
||||
input_data: Vec<u8>,
|
||||
) -> ContractExecResult<Balance>;
|
||||
|
||||
/// Instantiate a new contract.
|
||||
///
|
||||
/// See `[crate::Pallet::bare_instantiate]`.
|
||||
fn instantiate(
|
||||
origin: AccountId,
|
||||
value: Balance,
|
||||
gas_limit: Option<Weight>,
|
||||
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 [`crate::Pallet::bare_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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user