use miden_protocol::account::AccountId;
use miden_protocol::crypto::rand::FeltRng;
use miden_protocol::errors::NoteError;
use miden_protocol::note::{Note, NoteScript, NoteScriptRoot};
use miden_standards::note::costs::NoteConsumptionCost;
use miden_utils_sync::LazyLock;
use crate::costs::REMOVE_GER_CONSUMPTION_CYCLES;
use crate::ger_note::create_ger_note;
use crate::{ExitRoot, note_script};
const REMOVE_GER_SCRIPT_PATH: &str = "::agglayer::notes::remove_ger::main";
static REMOVE_GER_SCRIPT: LazyLock<NoteScript> =
LazyLock::new(|| note_script(REMOVE_GER_SCRIPT_PATH));
pub struct RemoveGerNote;
impl RemoveGerNote {
pub const NUM_STORAGE_ITEMS: usize = 8;
pub fn script() -> NoteScript {
REMOVE_GER_SCRIPT.clone()
}
pub fn script_root() -> NoteScriptRoot {
REMOVE_GER_SCRIPT.root()
}
pub fn create<R: FeltRng>(
ger: ExitRoot,
sender_account_id: AccountId,
target_account_id: AccountId,
rng: &mut R,
) -> Result<Note, NoteError> {
create_ger_note(ger, sender_account_id, target_account_id, Self::script(), rng)
}
}
impl NoteConsumptionCost for RemoveGerNote {
fn consumption_cycles() -> u32 {
REMOVE_GER_CONSUMPTION_CYCLES
}
}