mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-12 05:59:23 +00:00
Merge branch 'develop' into HEAD
This commit is contained in:
@@ -3,7 +3,7 @@ use thiserror::Error;
|
||||
use async_lock::RwLock;
|
||||
use simple_request::{hyper, Request, Client};
|
||||
|
||||
use scale::{Compact, Decode, Encode};
|
||||
use scale::{Decode, Encode};
|
||||
use serde::{Serialize, Deserialize, de::DeserializeOwned};
|
||||
|
||||
pub use sp_core::{
|
||||
@@ -43,8 +43,8 @@ impl Block {
|
||||
/// Returns the time of this block, set by its producer, in milliseconds since the epoch.
|
||||
pub fn time(&self) -> Result<u64, SeraiError> {
|
||||
for transaction in &self.transactions {
|
||||
if let Call::Timestamp(timestamp::Call::set { now }) = &transaction.call {
|
||||
return Ok(u64::from(*now));
|
||||
if let Call::Timestamp(timestamp::Call::set { now }) = transaction.call() {
|
||||
return Ok(*now);
|
||||
}
|
||||
}
|
||||
Err(SeraiError::InvalidNode("no time was present in block".to_string()))
|
||||
@@ -162,15 +162,14 @@ impl Serai {
|
||||
}
|
||||
|
||||
fn unsigned(call: Call) -> Transaction {
|
||||
Transaction { call, signature: None }
|
||||
Transaction::new(call, None)
|
||||
}
|
||||
|
||||
pub fn sign(&self, signer: &Pair, call: Call, nonce: u32, tip: u64) -> Transaction {
|
||||
const SPEC_VERSION: u32 = 1;
|
||||
const TX_VERSION: u32 = 1;
|
||||
|
||||
let extra =
|
||||
Extra { era: sp_runtime::generic::Era::Immortal, nonce: Compact(nonce), tip: Compact(tip) };
|
||||
let extra = Extra { era: sp_runtime::generic::Era::Immortal, nonce, tip };
|
||||
let signature_payload = (
|
||||
&call,
|
||||
&extra,
|
||||
@@ -184,7 +183,7 @@ impl Serai {
|
||||
.encode();
|
||||
let signature = signer.sign(&signature_payload);
|
||||
|
||||
Transaction { call, signature: Some((signer.public().into(), signature, extra)) }
|
||||
Transaction::new(call, Some((signer.public().into(), signature, extra)))
|
||||
}
|
||||
|
||||
pub async fn publish(&self, tx: &Transaction) -> Result<(), SeraiError> {
|
||||
@@ -367,7 +366,10 @@ impl<'a> TemporalSerai<'a> {
|
||||
let Some(res) = res else { return Ok(None) };
|
||||
let res = Serai::hex_decode(res)?;
|
||||
Ok(Some(R::decode(&mut res.as_slice()).map_err(|_| {
|
||||
SeraiError::InvalidRuntime("different type present at storage location".to_string())
|
||||
SeraiError::InvalidRuntime(format!(
|
||||
"different type present at storage location, raw value: {}",
|
||||
hex::encode(res)
|
||||
))
|
||||
})?))
|
||||
}
|
||||
|
||||
|
||||
@@ -180,7 +180,10 @@ impl<'a> SeraiValidatorSets<'a> {
|
||||
|
||||
pub fn set_keys(
|
||||
network: NetworkId,
|
||||
removed_participants: Vec<SeraiAddress>,
|
||||
removed_participants: sp_runtime::BoundedVec<
|
||||
SeraiAddress,
|
||||
sp_core::ConstU32<{ primitives::MAX_KEY_SHARES_PER_SET / 3 }>,
|
||||
>,
|
||||
key_pair: KeyPair,
|
||||
signature: Signature,
|
||||
) -> Transaction {
|
||||
|
||||
Reference in New Issue
Block a user