Move serai-client off serai-runtime, MIT licensing it

Uses a full-fledged serai-abi to do so.

Removes use of UncheckedExtrinsic as a pointlessly (for us) length-prefixed
block with a more complicated signing algorithm than advantageous.

In the future, we should considering consolidating the various primitives
crates. I'm not convinced we benefit from one primitives crate per pallet.
This commit is contained in:
Luke Parker
2023-12-07 02:30:09 -05:00
parent 6416e0079b
commit c511a54d18
38 changed files with 484 additions and 378 deletions

View File

@@ -1,4 +1,4 @@
use serai_runtime::primitives::{Coin, Amount};
use serai_abi::primitives::{Coin, Amount};
use serai_client::{Serai, SeraiDex};
use sp_core::{sr25519::Pair, Pair as PairTrait};
@@ -18,7 +18,7 @@ pub async fn add_liquidity(
let tx = serai.sign(
&pair,
&SeraiDex::add_liquidity(coin, coin_amount, sri_amount, Amount(1), Amount(1), address.into()),
SeraiDex::add_liquidity(coin, coin_amount, sri_amount, Amount(1), Amount(1), address.into()),
nonce,
0,
);
@@ -40,7 +40,7 @@ pub async fn swap(
let tx = serai.sign(
&pair,
&SeraiDex::swap(from_coin, to_coin, amount_in, amount_out_min, address.into()),
SeraiDex::swap(from_coin, to_coin, amount_in, amount_out_min, address.into()),
nonce,
Default::default(),
);

View File

@@ -2,12 +2,10 @@ use core::time::Duration;
use tokio::time::sleep;
use scale::Encode;
use serai_client::Serai;
use serai_client::{Transaction, Serai};
#[allow(dead_code)]
pub async fn publish_tx(serai: &Serai, tx: &[u8]) -> [u8; 32] {
pub async fn publish_tx(serai: &Serai, tx: &Transaction) -> [u8; 32] {
let mut latest = serai
.block(serai.latest_finalized_block_hash().await.unwrap())
.await
@@ -39,8 +37,8 @@ pub async fn publish_tx(serai: &Serai, tx: &[u8]) -> [u8; 32] {
block.unwrap()
};
for transaction in block.transactions() {
if transaction.encode() == tx {
for transaction in &block.transactions {
if transaction == tx {
return block.hash();
}
}