mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-12 05:59:23 +00:00
* initial implementation * add function to get a balance of an account * add support for multiple coins * rename pallet to "coins-pallet" * replace balances, assets and tokens pallet with coins pallet in runtime * add total supply info * update client side for new Coins pallet * handle fees * bug fixes * Update FeeAccount test * Fmt * fix pr comments * remove extraneous Imbalance type * Minor tweaks --------- Co-authored-by: Luke Parker <lukeparker5132@gmail.com>
52 lines
1.3 KiB
Rust
52 lines
1.3 KiB
Rust
#![cfg_attr(docsrs, feature(doc_cfg))]
|
|
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
|
#![cfg_attr(not(feature = "std"), no_std)]
|
|
|
|
#[cfg(feature = "std")]
|
|
use zeroize::Zeroize;
|
|
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
use scale::{Encode, Decode, MaxEncodedLen};
|
|
use scale_info::TypeInfo;
|
|
|
|
use serai_primitives::{Balance, SeraiAddress, ExternalAddress, Data, system_address};
|
|
|
|
pub const FEE_ACCOUNT: SeraiAddress = system_address(b"FeeAccount");
|
|
|
|
#[derive(
|
|
Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Encode, Decode, MaxEncodedLen, TypeInfo,
|
|
)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize))]
|
|
pub struct OutInstruction {
|
|
pub address: ExternalAddress,
|
|
pub data: Option<Data>,
|
|
}
|
|
|
|
#[derive(
|
|
Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Encode, Decode, MaxEncodedLen, TypeInfo,
|
|
)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize))]
|
|
pub struct OutInstructionWithBalance {
|
|
pub instruction: OutInstruction,
|
|
pub balance: Balance,
|
|
}
|
|
|
|
#[derive(
|
|
Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Encode, Decode, MaxEncodedLen, TypeInfo,
|
|
)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize))]
|
|
pub enum Destination {
|
|
Native(SeraiAddress),
|
|
External(OutInstruction),
|
|
}
|
|
|
|
#[test]
|
|
fn address() {
|
|
use sp_runtime::traits::TrailingZeroInput;
|
|
assert_eq!(
|
|
FEE_ACCOUNT,
|
|
SeraiAddress::decode(&mut TrailingZeroInput::new(b"FeeAccount")).unwrap()
|
|
);
|
|
}
|