diff --git a/core/src/events.rs b/core/src/events.rs index c1b100e7..15745f4e 100644 --- a/core/src/events.rs +++ b/core/src/events.rs @@ -14,6 +14,9 @@ use crate::{ }, }; +#[cfg(feature = "imt")] +use crate::intents::tokens::imt::{ImtBurn, ImtMint}; + #[must_use = "make sure to `.emit()` this event"] #[near(event_json(standard = "dip4"))] #[derive(Debug, Clone, Deserialize, From)] @@ -56,15 +59,11 @@ pub enum DefuseEvent<'a> { #[cfg(feature = "imt")] #[event_version("0.3.0")] - ImtMint( - Cow<'a, [IntentEvent>>]>, - ), + ImtMint(Cow<'a, [IntentEvent>>]>), #[cfg(feature = "imt")] #[event_version("0.3.0")] - ImtBurn( - Cow<'a, [IntentEvent>>]>, - ), + ImtBurn(Cow<'a, [IntentEvent>>]>), #[event_version("0.3.0")] #[from(skip)] AccountLocked(AccountEvent<'a, ()>), diff --git a/core/src/intents/mod.rs b/core/src/intents/mod.rs index 65611365..43b12d14 100644 --- a/core/src/intents/mod.rs +++ b/core/src/intents/mod.rs @@ -9,6 +9,9 @@ use near_sdk::{AccountIdRef, CryptoHash, near}; use serde_with::serde_as; use tokens::{NativeWithdraw, StorageDeposit}; +#[cfg(feature = "imt")] +use crate::intents::tokens::imt::{ImtBurn, ImtMint}; + use crate::{ Result, engine::{Engine, Inspector, State}, @@ -71,11 +74,11 @@ pub enum Intent { // See [`ImtMint`] #[cfg(feature = "imt")] - ImtMint(crate::intents::tokens::imt::ImtMint), + ImtMint(ImtMint), // See [`ImtBurn`] #[cfg(feature = "imt")] - ImtBurn(crate::intents::tokens::imt::ImtBurn), + ImtBurn(ImtBurn), } pub trait ExecutableIntent { diff --git a/defuse/src/contract/accounts/force.rs b/defuse/src/contract/accounts/force.rs index 3250377e..4a2ddb51 100644 --- a/defuse/src/contract/accounts/force.rs +++ b/defuse/src/contract/accounts/force.rs @@ -94,7 +94,7 @@ impl ForceAccountManager for Contract { for (account_id, pks) in public_keys { for pk in pks { - self.add_public_key(account_id.as_ref(), pk); + self.add_public_key_and_emit_event(account_id.as_ref(), pk); } } } @@ -106,7 +106,7 @@ impl ForceAccountManager for Contract { for (account_id, pks) in public_keys { for pk in pks { - self.remove_public_key(account_id.as_ref(), pk); + self.remove_public_key_and_emit_event(account_id.as_ref(), pk); } } } diff --git a/defuse/src/contract/accounts/mod.rs b/defuse/src/contract/accounts/mod.rs index 7ce23146..262412ad 100644 --- a/defuse/src/contract/accounts/mod.rs +++ b/defuse/src/contract/accounts/mod.rs @@ -42,7 +42,7 @@ impl AccountManager for Contract { assert_one_yocto(); let account_id = self.ensure_auth_predecessor_id(); - self.add_public_key(account_id.as_ref(), public_key); + self.add_public_key_and_emit_event(account_id.as_ref(), public_key); } #[payable] @@ -50,7 +50,7 @@ impl AccountManager for Contract { assert_one_yocto(); let account_id = self.ensure_auth_predecessor_id(); - self.remove_public_key(account_id.as_ref(), public_key); + self.remove_public_key_and_emit_event(account_id.as_ref(), public_key); } fn is_nonce_used(&self, account_id: &AccountId, nonce: AsBase64) -> bool { @@ -79,7 +79,11 @@ impl Contract { predecessor_account_id } - pub fn add_public_key(&mut self, account_id: &AccountIdRef, public_key: PublicKey) { + pub fn add_public_key_and_emit_event( + &mut self, + account_id: &AccountIdRef, + public_key: PublicKey, + ) { State::add_public_key(self, account_id.into(), public_key).unwrap_or_panic(); DefuseEvent::PublicKeyAdded(AccountEvent::new( @@ -91,7 +95,11 @@ impl Contract { .emit(); } - pub fn remove_public_key(&mut self, account_id: &AccountIdRef, public_key: PublicKey) { + pub fn remove_public_key_and_emit_event( + &mut self, + account_id: &AccountIdRef, + public_key: PublicKey, + ) { State::remove_public_key(self, account_id.into(), public_key).unwrap_or_panic(); DefuseEvent::PublicKeyRemoved(AccountEvent::new(