From 35bedb6296ee5b025ad5ffa6e8fc9b326c00be5e Mon Sep 17 00:00:00 2001 From: Peter White Date: Fri, 13 Sep 2024 11:59:34 -0600 Subject: [PATCH] refactor: event Approve -> Approval --- pallets/api/src/fungibles/mod.rs | 8 ++++---- pallets/api/src/fungibles/tests.rs | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pallets/api/src/fungibles/mod.rs b/pallets/api/src/fungibles/mod.rs index c045fb84..bdfe30db 100644 --- a/pallets/api/src/fungibles/mod.rs +++ b/pallets/api/src/fungibles/mod.rs @@ -134,7 +134,7 @@ pub mod pallet { #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { /// Event emitted when allowance by `owner` to `spender` changes. - Approve { + Approval { /// The token. token: TokenIdOf, /// The owner providing the allowance. @@ -278,7 +278,7 @@ pub mod pallet { } }, }; - Self::deposit_event(Event::Approve { token, owner, spender, value }); + Self::deposit_event(Event::Approval { token, owner, spender, value }); Ok(Some(weight).into()) } @@ -306,7 +306,7 @@ pub mod pallet { ) .map_err(|e| e.with_weight(AssetsWeightInfoOf::::approve_transfer()))?; let value = AssetsOf::::allowance(token.clone(), &owner, &spender); - Self::deposit_event(Event::Approve { token, owner, spender, value }); + Self::deposit_event(Event::Approval { token, owner, spender, value }); Ok(().into()) } @@ -352,7 +352,7 @@ pub mod pallet { )?; WeightOf::::approve(1, 1) }; - Self::deposit_event(Event::Approve { token, owner, spender, value: new_allowance }); + Self::deposit_event(Event::Approval { token, owner, spender, value: new_allowance }); Ok(Some(weight).into()) } diff --git a/pallets/api/src/fungibles/tests.rs b/pallets/api/src/fungibles/tests.rs index 92a3c8ed..b1913cec 100644 --- a/pallets/api/src/fungibles/tests.rs +++ b/pallets/api/src/fungibles/tests.rs @@ -195,7 +195,7 @@ mod approve { Ok(Some(WeightInfo::approve(1, 0)).into()) ); assert_eq!(Assets::allowance(token, &owner, &spender), value); - System::assert_last_event(Event::Approve { token, owner, spender, value }.into()); + System::assert_last_event(Event::Approval { token, owner, spender, value }.into()); // Approves a value to spend that is lower than the current allowance. assert_eq!( Fungibles::approve(signed(owner), token, spender, value / 2), @@ -203,7 +203,7 @@ mod approve { ); assert_eq!(Assets::allowance(token, &owner, &spender), value / 2); System::assert_last_event( - Event::Approve { token, owner, spender, value: value / 2 }.into(), + Event::Approval { token, owner, spender, value: value / 2 }.into(), ); // Approves a value to spend that is equal to the current allowance. assert_eq!( @@ -212,7 +212,7 @@ mod approve { ); assert_eq!(Assets::allowance(token, &owner, &spender), value / 2); System::assert_last_event( - Event::Approve { token, owner, spender, value: value / 2 }.into(), + Event::Approval { token, owner, spender, value: value / 2 }.into(), ); // Sets allowance to zero. assert_eq!( @@ -220,7 +220,7 @@ mod approve { Ok(Some(WeightInfo::approve(0, 1)).into()) ); assert_eq!(Assets::allowance(token, &owner, &spender), 0); - System::assert_last_event(Event::Approve { token, owner, spender, value: 0 }.into()); + System::assert_last_event(Event::Approval { token, owner, spender, value: 0 }.into()); }); } } @@ -248,12 +248,12 @@ fn increase_allowance_works() { assert_eq!(0, Assets::allowance(token, &owner, &spender)); assert_ok!(Fungibles::increase_allowance(signed(owner), token, spender, value)); assert_eq!(Assets::allowance(token, &owner, &spender), value); - System::assert_last_event(Event::Approve { token, owner, spender, value }.into()); + System::assert_last_event(Event::Approval { token, owner, spender, value }.into()); // Additive. assert_ok!(Fungibles::increase_allowance(signed(owner), token, spender, value)); assert_eq!(Assets::allowance(token, &owner, &spender), value * 2); System::assert_last_event( - Event::Approve { token, owner, spender, value: value * 2 }.into(), + Event::Approval { token, owner, spender, value: value * 2 }.into(), ); }); } @@ -293,7 +293,7 @@ fn decrease_allowance_works() { ); assert_eq!(Assets::allowance(token, &owner, &spender), value / 2); System::assert_last_event( - Event::Approve { token, owner, spender, value: value / 2 }.into(), + Event::Approval { token, owner, spender, value: value / 2 }.into(), ); // Saturating if current allowance is decreased more than the owner balance. assert_eq!( @@ -301,7 +301,7 @@ fn decrease_allowance_works() { Ok(Some(WeightInfo::approve(0, 1)).into()) ); assert_eq!(Assets::allowance(token, &owner, &spender), 0); - System::assert_last_event(Event::Approve { token, owner, spender, value: 0 }.into()); + System::assert_last_event(Event::Approval { token, owner, spender, value: 0 }.into()); }); }