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
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ version = "0.1.0"
edition = "2024"

[dependencies]
miden-client = { version = "0.13", features = ["testing", "tonic"] }
miden-standards = { version = "0.13", default-features = false }
miden-protocol = { version = "0.13", default-features = false, features = ["testing"] }
miden-client = { version = "0.13.1", features = ["testing", "tonic"] }
miden-standards = { version = "0.13.3", default-features = false }
miden-protocol = { version = "0.13.3", default-features = false, features = ["testing"] }
miden-crypto = { version = "0.19", features = ["executable"] }
miden-assembly = "0.20"
miden-testing = "0.13"
miden-testing = "0.13.3"
rand = { version = "0.9" }
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1.0", features = ["raw_value"] }
tokio = { version = "1.46", features = ["rt-multi-thread", "net", "macros", "fs"] }
rand_chacha = "0.9.0"
miden-client-sqlite-store = "0.13"
miden-client-sqlite-store = "0.13.1"
chrono = "0.4"
anyhow = "1"
dotenvy = "0.15"
Expand Down
46 changes: 32 additions & 14 deletions src/notes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use miden_client::{
},
};
use miden_standards::code_builder::CodeBuilder;
use miden_standards::note::NetworkAccountTarget;
use miden_protocol::transaction::TransactionKernel;
use miden_protocol::note::NoteExecutionHint;
use miden_crypto::{Felt, Word};
use rand::{Rng, RngCore};
use std::{fs, path::Path, sync::Arc};
Expand All @@ -21,9 +23,10 @@ pub async fn create_note_for_naming_with_client(
name: String,
inputs: NoteInputs,
sender: AccountId,
_target_id: AccountId,
target_id: AccountId,
assets: NoteAssets,
client: &mut Client<FilesystemKeyStore>,
is_network_account: bool,
) -> anyhow::Result<Note> {
let note_code = fs::read_to_string(Path::new(&format!("./masm/notes/{}.masm", name)))?;
let naming_code = fs::read_to_string(Path::new("./masm/accounts/naming_unsafe.masm")).unwrap();
Expand All @@ -41,12 +44,19 @@ pub async fn create_note_for_naming_with_client(
.compile_note_script(note_code)?;

let recipient = NoteRecipient::new(serial_num, note_script, inputs.clone());
let tag = NoteTag::with_account_target(_target_id);
let metadata = NoteMetadata::new(
sender,
NoteType::Public,
tag,
);
let tag = NoteTag::with_account_target(target_id);

let metadata = if is_network_account {
// For network accounts, attach NetworkAccountTarget so the network can consume the note
let network_target = NetworkAccountTarget::new(target_id, NoteExecutionHint::Always)
.map_err(|e| anyhow::anyhow!("Failed to create NetworkAccountTarget: {}", e))?;
NoteMetadata::new(sender, NoteType::Public, tag)
.with_attachment(network_target.into())
} else {
// For public accounts, no attachment needed
NoteMetadata::new(sender, NoteType::Public, tag)
};

let note = Note::new(assets, metadata, recipient);
Ok(note)
}
Expand All @@ -55,8 +65,9 @@ pub async fn create_note_for_naming(
name: String,
inputs: NoteInputs,
sender: AccountId,
_target_id: AccountId,
target_id: AccountId,
assets: NoteAssets,
is_network_account: bool,
) -> anyhow::Result<Note> {
let note_code = fs::read_to_string(Path::new(&format!("./masm/notes/{}.masm", name)))?;
let naming_code = fs::read_to_string(Path::new("./masm/accounts/naming.masm")).unwrap();
Expand All @@ -68,12 +79,19 @@ pub async fn create_note_for_naming(
.compile_note_script(note_code)?;

let recipient = NoteRecipient::new(serial, note_script, inputs.clone());
let tag = NoteTag::with_account_target(_target_id);
let metadata = NoteMetadata::new(
sender,
NoteType::Public,
tag,
);
let tag = NoteTag::with_account_target(target_id);

let metadata = if is_network_account {
// For network accounts, attach NetworkAccountTarget so the network can consume the note
let network_target = NetworkAccountTarget::new(target_id, NoteExecutionHint::Always)
.map_err(|e| anyhow::anyhow!("Failed to create NetworkAccountTarget: {}", e))?;
NoteMetadata::new(sender, NoteType::Public, tag)
.with_attachment(network_target.into())
} else {
// For public accounts, no attachment needed
NoteMetadata::new(sender, NoteType::Public, tag)
};

let note = Note::new(assets, metadata, recipient);
Ok(note)
}
Expand Down
3 changes: 3 additions & 0 deletions src/scripts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ pub async fn deploy(is_network: bool, use_testnet: bool) -> anyhow::Result<()> {
naming_account.id(),
NoteAssets::new(vec![]).unwrap(),
&mut client,
is_network,
)
.await?;

Expand Down Expand Up @@ -155,6 +156,7 @@ pub async fn deploy(is_network: bool, use_testnet: bool) -> anyhow::Result<()> {
naming_account.id(),
NoteAssets::new(vec![]).unwrap(),
&mut client,
is_network,
)
.await?;

Expand Down Expand Up @@ -405,6 +407,7 @@ pub async fn send_register_note(
naming_account,
register_asset,
&mut client,
is_network,
)
.await?;

Expand Down