mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-08 17:07:21 +00:00
feat: refactor signing in order to more easily be able to dryrun (#547)
* feat: refactor signing in order to more easily be able to dryrun Co-authored-by: Sander Bosma <sanderbosma@gmail.com> Co-authored-by: Daniel Savu <savudani04@yahoo.ro> * chore: move dry_run to rpc file * fix: failing dryrun test * fix: run cargo fmt * chore(dryrun): Replace complex SubmittableExtrinsic type with bytes array * cargo fmt * feat: add dry_run method to signed submittable extrinsic * fmt Co-authored-by: Sander Bosma <sanderbosma@gmail.com>
This commit is contained in:
+21
-3
@@ -146,9 +146,12 @@ use sp_core::{
|
||||
Bytes,
|
||||
U256,
|
||||
};
|
||||
use sp_runtime::generic::{
|
||||
Block,
|
||||
SignedBlock,
|
||||
use sp_runtime::{
|
||||
generic::{
|
||||
Block,
|
||||
SignedBlock,
|
||||
},
|
||||
ApplyExtrinsicResult,
|
||||
};
|
||||
|
||||
/// A number type that can be serialized both as a number or a string that encodes a number in a
|
||||
@@ -643,6 +646,21 @@ impl<T: Config> Rpc<T> {
|
||||
let params = rpc_params![public_key, key_type];
|
||||
Ok(self.client.request("author_hasKey", params).await?)
|
||||
}
|
||||
|
||||
/// Submits the extrinsic to the dry_run RPC, to test if it would succeed.
|
||||
///
|
||||
/// Returns `Ok` with an [`ApplyExtrinsicResult`], which is the result of applying of an extrinsic.
|
||||
pub async fn dry_run(
|
||||
&self,
|
||||
encoded_signed: &[u8],
|
||||
at: Option<T::Hash>,
|
||||
) -> Result<ApplyExtrinsicResult, BasicError> {
|
||||
let params = rpc_params![format!("0x{}", hex::encode(encoded_signed)), at];
|
||||
let result_bytes: Bytes = self.client.request("system_dryRun", params).await?;
|
||||
let data: ApplyExtrinsicResult =
|
||||
codec::Decode::decode(&mut result_bytes.0.as_slice())?;
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
|
||||
/// Build WS RPC client from URL
|
||||
|
||||
Reference in New Issue
Block a user