mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Replace substrate/client's use of Payload with usage of RuntimeCall
Gains explicit typing.
This commit is contained in:
@@ -3,8 +3,6 @@ use serai_runtime::primitives::{Coin, Amount};
|
||||
use serai_client::{Serai, SeraiDex, PairSigner};
|
||||
use sp_core::{sr25519::Pair, Pair as PairTrait};
|
||||
|
||||
use subxt::config::extrinsic_params::BaseExtrinsicParamsBuilder;
|
||||
|
||||
use crate::common::tx::publish_tx;
|
||||
|
||||
#[allow(dead_code)]
|
||||
@@ -18,14 +16,12 @@ pub async fn add_liquidity(
|
||||
) -> [u8; 32] {
|
||||
let address = pair.public();
|
||||
|
||||
let tx = serai
|
||||
.sign(
|
||||
&PairSigner::new(pair),
|
||||
&SeraiDex::add_liquidity(coin, coin_amount, sri_amount, Amount(1), Amount(1), address.into()),
|
||||
nonce,
|
||||
BaseExtrinsicParamsBuilder::new(),
|
||||
)
|
||||
.unwrap();
|
||||
let tx = serai.sign(
|
||||
&PairSigner::new(pair),
|
||||
&SeraiDex::add_liquidity(coin, coin_amount, sri_amount, Amount(1), Amount(1), address.into()),
|
||||
nonce,
|
||||
Default::default(),
|
||||
);
|
||||
|
||||
publish_tx(serai, &tx).await
|
||||
}
|
||||
@@ -42,14 +38,12 @@ pub async fn swap(
|
||||
) -> [u8; 32] {
|
||||
let address = pair.public();
|
||||
|
||||
let tx = serai
|
||||
.sign(
|
||||
&PairSigner::new(pair),
|
||||
&SeraiDex::swap(from_coin, to_coin, amount_in, amount_out_min, address.into()),
|
||||
nonce,
|
||||
BaseExtrinsicParamsBuilder::new(),
|
||||
)
|
||||
.unwrap();
|
||||
let tx = serai.sign(
|
||||
&PairSigner::new(pair),
|
||||
&SeraiDex::swap(from_coin, to_coin, amount_in, amount_out_min, address.into()),
|
||||
nonce,
|
||||
Default::default(),
|
||||
);
|
||||
|
||||
publish_tx(serai, &tx).await
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ use core::time::Duration;
|
||||
|
||||
use tokio::time::sleep;
|
||||
|
||||
use serai_client::{subxt::utils::Encoded, Serai};
|
||||
use serai_client::Serai;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn publish_tx(serai: &Serai, tx: &Encoded) -> [u8; 32] {
|
||||
pub async fn publish_tx(serai: &Serai, tx: &[u8]) -> [u8; 32] {
|
||||
let mut latest =
|
||||
serai.block(serai.latest_block_hash().await.unwrap()).await.unwrap().unwrap().number();
|
||||
|
||||
@@ -34,7 +34,7 @@ pub async fn publish_tx(serai: &Serai, tx: &Encoded) -> [u8; 32] {
|
||||
};
|
||||
|
||||
for transaction in block.transactions() {
|
||||
if transaction.0 == tx.0[2 ..] {
|
||||
if transaction.0 == tx[2 ..] {
|
||||
return block.hash();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user