mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Restore publish_transaction RPC to Serai
This commit is contained in:
@@ -14,18 +14,16 @@ use borsh::BorshDeserialize;
|
||||
pub use serai_abi as abi;
|
||||
use abi::{
|
||||
primitives::{BlockHash, network_id::ExternalNetworkId},
|
||||
Block, Event,
|
||||
Transaction, Block, Event,
|
||||
};
|
||||
|
||||
use async_lock::RwLock;
|
||||
|
||||
/// RPC client functionality for the coins module.
|
||||
pub mod coins;
|
||||
use coins::*;
|
||||
mod coins;
|
||||
pub use coins::Coins;
|
||||
|
||||
/// RPC client functionality for the validator sets module.
|
||||
pub mod validator_sets;
|
||||
use validator_sets::*;
|
||||
mod validator_sets;
|
||||
pub use validator_sets::ValidatorSets;
|
||||
|
||||
/// An error from the RPC.
|
||||
#[derive(Debug, Error)]
|
||||
@@ -164,6 +162,16 @@ impl Serai {
|
||||
Self::block_internal(self.call("blockchain/block", &format!(r#"{{ "block": {block} }}"#))).await
|
||||
}
|
||||
|
||||
/// Publish a transaction onto the Serai blockchain.
|
||||
pub async fn publish_transaction(&self, transaction: &Transaction) -> Result<(), RpcError> {
|
||||
self
|
||||
.call(
|
||||
"blockchain/publish_transaction",
|
||||
&format!(r#"{{ "transaction": {} }}"#, hex::encode(borsh::to_vec(transaction).unwrap())),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Scope this RPC client to the state as of a specific block.
|
||||
///
|
||||
/// This will yield an error if the block chosen isn't finalized. This ensures, given an honest
|
||||
|
||||
Reference in New Issue
Block a user