Coins pallet (#399)

* 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>
This commit is contained in:
akildemir
2023-10-19 13:22:21 +03:00
committed by GitHub
parent 3255c0ace5
commit fdfce9e207
32 changed files with 535 additions and 445 deletions

View File

@@ -15,7 +15,7 @@ use serai_client::{
},
validator_sets::primitives::{Session, ValidatorSet},
in_instructions::primitives::Shorthand,
coins::primitives::OutInstruction,
coins::primitives::{OutInstruction, OutInstructionWithBalance},
PairTrait, PairSigner, SeraiCoins,
};
@@ -236,12 +236,13 @@ async fn mint_and_burn_test() {
let address = SeraiAddress::from(pair.public());
// Fund the new account to pay for fees
let balance = Balance { coin: Coin::Serai, amount: Amount(1_000_000_000) };
serai
.publish(
&serai
.sign(
&PairSigner::new(insecure_pair_from_name("Ferdie")),
&SeraiCoins::transfer_sri(address, Amount(1_000_000_000)),
&SeraiCoins::transfer(address, balance),
0,
Default::default(),
)
@@ -488,17 +489,15 @@ async fn mint_and_burn_test() {
let serai = &serai;
let serai_pair = &serai_pair;
move |nonce, coin, amount, address| async move {
let out_instruction = OutInstruction { address, data: None };
let out_instruction = OutInstructionWithBalance {
balance: Balance { coin, amount: Amount(amount) },
instruction: OutInstruction { address, data: None },
};
serai
.publish(
&serai
.sign(
serai_pair,
&SeraiCoins::burn(Balance { coin, amount: Amount(amount) }, out_instruction),
nonce,
Default::default(),
)
.sign(serai_pair, &SeraiCoins::burn(out_instruction), nonce, Default::default())
.unwrap(),
)
.await