Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
contract rpc fix
  • Loading branch information
kostekIV committed Nov 21, 2022
commit 223a5145b36dfccd75545632429be353b973e2c7
26 changes: 26 additions & 0 deletions aleph-client/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions aleph-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ serde = { version = "1.0", features = ["derive"] }
frame-support = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.28" }
sp-core = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.28", features = ["full_crypto"] }
sp-runtime = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.28" }
pallet-contracts-primitives = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.28" }
primitives = { path = "../primitives" }
1 change: 1 addition & 0 deletions aleph-client/src/contract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl ContractInstance {
value: 0,
gas_limit: Self::MAX_READ_GAS,
input_data: payload,
storage_deposit_limit: None,
};
conn.call_and_get(args)
.await
Expand Down
20 changes: 14 additions & 6 deletions aleph-client/src/pallets/contract.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
use codec::{Compact, Decode};
use codec::{Compact, Decode, Encode};
use pallet_contracts_primitives::ContractExecResult;
use primitives::Balance;
use serde::Serialize;
use subxt::{ext::sp_runtime::MultiAddress, rpc_params};
use subxt::{
ext::{sp_core::Bytes, sp_runtime::MultiAddress},
rpc_params,
};

use crate::{
api, pallet_contracts::wasm::OwnerInfo, AccountId, BlockHash, Connection, SignedConnection,
TxStatus,
};

#[derive(Serialize)]
#[derive(Encode)]
pub struct ContractCallArgs {
pub origin: AccountId,
pub dest: AccountId,
pub value: Balance,
pub gas_limit: u64,
pub storage_deposit_limit: Option<Balance>,
pub input_data: Vec<u8>,
}

Expand Down Expand Up @@ -180,8 +184,12 @@ impl ContractsUserApi for SignedConnection {
#[async_trait::async_trait]
impl ContractRpc for Connection {
async fn call_and_get<T: Decode>(&self, args: ContractCallArgs) -> anyhow::Result<T> {
let params = rpc_params![args];
let params = rpc_params!["ContractsApi_call", Bytes(args.encode())];

let res: ContractExecResult<Balance> =
self.rpc_call("state_call".to_string(), params).await?;
let res = T::decode(&mut (res.result.unwrap().data.0.as_slice()))?;

self.rpc_call("contracts_call".to_string(), params).await
Ok(res)
}
}
26 changes: 26 additions & 0 deletions bin/cliain/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/cliain/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct ContractOptions {
#[clap(long, default_value = "0")]
pub balance: u128,
/// The gas limit enforced when executing the constructor
#[clap(long, default_value = "1_000_000_000")]
#[clap(long, default_value = "1000000000")]
pub gas_limit: u64,
/// The maximum amount of balance that can be charged/reserved from the caller to pay for the storage consumed
#[clap(long)]
Expand Down