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

@@ -16,7 +16,7 @@ use serai_client::{
ValidatorSetsEvent,
},
in_instructions::InInstructionsEvent,
coins::{primitives::OutInstructionWithBalance, TokensEvent},
coins::CoinsEvent,
};
use serai_db::DbTxn;
@@ -209,12 +209,12 @@ async fn handle_batch_and_burns<D: Db, Pro: Processors>(
}
for burn in serai.coins().burn_events().await? {
if let TokensEvent::Burn { address: _, balance, instruction } = burn {
let network = balance.coin.network();
if let CoinsEvent::Burn { address: _, instruction } = burn {
let network = instruction.balance.coin.network();
network_had_event(&mut burns, &mut batches, network);
// network_had_event should register an entry in burns
burns.get_mut(&network).unwrap().push(OutInstructionWithBalance { balance, instruction });
burns.get_mut(&network).unwrap().push(instruction);
} else {
panic!("Burn event wasn't Burn: {burn:?}");
}