mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 17:28:00 +00:00
Add an RPC method for calling a contract. (#3563)
* Sketch * Some work on docs. * Doc improvements. * More docs. * Some more docs. * Yet another comment. * Bump impl_version. * Accept the block hash * Use NumberOrHex * Update node/rpc/src/contracts.rs Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Move rpc/primitives
This commit is contained in:
@@ -27,7 +27,7 @@ use support::{
|
||||
use primitives::u32_trait::{_1, _2, _3, _4};
|
||||
use node_primitives::{
|
||||
AccountId, AccountIndex, Balance, BlockNumber, Hash, Index,
|
||||
Moment, Signature,
|
||||
Moment, Signature, ContractExecResult,
|
||||
};
|
||||
use babe::{AuthorityId as BabeId};
|
||||
use grandpa::fg_primitives::{self, ScheduledChange};
|
||||
@@ -83,7 +83,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
// implementation changes and behavior does not, then leave spec_version as
|
||||
// is and increment impl_version.
|
||||
spec_version: 156,
|
||||
impl_version: 157,
|
||||
impl_version: 158,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
};
|
||||
|
||||
@@ -654,6 +654,31 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl node_primitives::ContractsApi<Block> 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl substrate_session::SessionKeys<Block> for Runtime {
|
||||
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
||||
let seed = seed.as_ref().map(|s| rstd::str::from_utf8(&s).expect("Seed is an utf8 string"));
|
||||
|
||||
Reference in New Issue
Block a user