mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Add SRI balanace/transfer functions to serai_client
This commit is contained in:
@@ -24,7 +24,7 @@ use subxt::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub use serai_runtime::primitives;
|
pub use serai_runtime::primitives;
|
||||||
pub use primitives::{Signature, SeraiAddress};
|
pub use primitives::{SeraiAddress, Signature, Amount};
|
||||||
|
|
||||||
pub use serai_runtime as runtime;
|
pub use serai_runtime as runtime;
|
||||||
use serai_runtime::{
|
use serai_runtime::{
|
||||||
@@ -306,6 +306,30 @@ impl Serai {
|
|||||||
// If we are to return something, it should be block included in and position within block
|
// If we are to return something, it should be block included in and position within block
|
||||||
self.0.rpc().submit_extrinsic(tx).await.map(|_| ()).map_err(SeraiError::RpcError)
|
self.0.rpc().submit_extrinsic(tx).await.map(|_| ()).map_err(SeraiError::RpcError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_sri_balance(
|
||||||
|
&self,
|
||||||
|
block: [u8; 32],
|
||||||
|
address: SeraiAddress,
|
||||||
|
) -> Result<u64, SeraiError> {
|
||||||
|
let data: Option<
|
||||||
|
serai_runtime::system::AccountInfo<u32, serai_runtime::balances::AccountData<u64>>,
|
||||||
|
> = self.storage("System", "Account", Some(vec![scale_value(address)]), block).await?;
|
||||||
|
Ok(data.map(|data| data.data.free).unwrap_or(0))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn transfer_sri(to: SeraiAddress, amount: Amount) -> Payload<Composite<()>> {
|
||||||
|
Payload::new(
|
||||||
|
"Balances",
|
||||||
|
// TODO: Use transfer_allow_death?
|
||||||
|
// TODO: Replace the Balances pallet with something much simpler
|
||||||
|
"transfer",
|
||||||
|
scale_composite(serai_runtime::balances::Call::<Runtime>::transfer {
|
||||||
|
dest: to,
|
||||||
|
value: amount.0,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ fn testnet_genesis(
|
|||||||
system: SystemConfig { code: wasm_binary.to_vec(), _config: PhantomData },
|
system: SystemConfig { code: wasm_binary.to_vec(), _config: PhantomData },
|
||||||
|
|
||||||
balances: BalancesConfig {
|
balances: BalancesConfig {
|
||||||
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
balances: endowed_accounts.into_iter().map(|k| (k, 1 << 60)).collect(),
|
||||||
},
|
},
|
||||||
transaction_payment: Default::default(),
|
transaction_payment: Default::default(),
|
||||||
|
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ impl balances::Config for Runtime {
|
|||||||
|
|
||||||
type DustRemoval = ();
|
type DustRemoval = ();
|
||||||
type ExistentialDeposit = ConstU64<1>;
|
type ExistentialDeposit = ConstU64<1>;
|
||||||
|
// TODO: What's the benefit to this?
|
||||||
type AccountStore = System;
|
type AccountStore = System;
|
||||||
type WeightInfo = balances::weights::SubstrateWeight<Runtime>;
|
type WeightInfo = balances::weights::SubstrateWeight<Runtime>;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user