From c553c09f5bd7e306867beca171f6ec757b89d1cc Mon Sep 17 00:00:00 2001
From: Hugo Trentesaux <hugo@trentesaux.fr>
Date: Tue, 14 Jan 2025 17:19:21 +0100
Subject: [PATCH] use mint instead of deposit

---
 pallets/universal-dividend/src/lib.rs   | 5 +++--
 pallets/universal-dividend/src/tests.rs | 5 +++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/pallets/universal-dividend/src/lib.rs b/pallets/universal-dividend/src/lib.rs
index 70518f7fd..6fda9a68c 100644
--- a/pallets/universal-dividend/src/lib.rs
+++ b/pallets/universal-dividend/src/lib.rs
@@ -331,10 +331,11 @@ pub mod pallet {
                             core::num::NonZeroU16::new(current_ud_index)
                                 .expect("unreachable because current_ud_index is never zero."),
                         );
-                        let _ = T::Currency::deposit(who, uds_total, Precision::Exact);
+                        // Currency is issued here
+                        let actual_total = T::Currency::mint_into(who, uds_total)?;
                         Self::deposit_event(Event::UdsClaimed {
                             count: uds_count,
-                            total: uds_total,
+                            total: actual_total,
                             who: who.clone(),
                         });
                         Ok(().into())
diff --git a/pallets/universal-dividend/src/tests.rs b/pallets/universal-dividend/src/tests.rs
index 3240e9b5f..56c683de1 100644
--- a/pallets/universal-dividend/src/tests.rs
+++ b/pallets/universal-dividend/src/tests.rs
@@ -62,6 +62,11 @@ fn test_claim_uds() {
             total: 1_000,
             who: 1,
         }));
+        // the expected event form pallet balances is "minted"
+        System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Minted {
+            who: 1,
+            amount: 1000,
+        }));
         assert_eq!(Balances::free_balance(1), 1_000);
         // Others members should not receive any UDs with Alice claim
         assert_eq!(Balances::free_balance(2), 0);
-- 
GitLab