Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions core/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -56,15 +59,11 @@ pub enum DefuseEvent<'a> {

#[cfg(feature = "imt")]
#[event_version("0.3.0")]
ImtMint(
Cow<'a, [IntentEvent<AccountEvent<'a, Cow<'a, crate::intents::tokens::imt::ImtMint>>>]>,
),
ImtMint(Cow<'a, [IntentEvent<AccountEvent<'a, Cow<'a, ImtMint>>>]>),

#[cfg(feature = "imt")]
#[event_version("0.3.0")]
ImtBurn(
Cow<'a, [IntentEvent<AccountEvent<'a, Cow<'a, crate::intents::tokens::imt::ImtBurn>>>]>,
),
ImtBurn(Cow<'a, [IntentEvent<AccountEvent<'a, Cow<'a, ImtBurn>>>]>),
#[event_version("0.3.0")]
#[from(skip)]
AccountLocked(AccountEvent<'a, ()>),
Expand Down
7 changes: 5 additions & 2 deletions core/src/intents/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions defuse/src/contract/accounts/force.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand All @@ -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);
}
}
}
Expand Down
16 changes: 12 additions & 4 deletions defuse/src/contract/accounts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ 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]
fn remove_public_key(&mut self, public_key: PublicKey) {
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<Nonce>) -> bool {
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down
Loading