Skip to content
Draft
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
1,356 changes: 142 additions & 1,214 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ miden-faucet-lib = { path = "crates/faucet", version = "0.15.0" }
miden-pow-rate-limiter = { path = "crates/pow", version = "0.15.0" }

# Miden dependencies.
cargo-miden = { version = "0.8.1" }
miden = { version = "0.11" }
miden-client = { version = "0.14" }
miden-client-cli = { version = "0.14" }
Expand Down
1 change: 0 additions & 1 deletion crates/faucet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ workspace = true

[dependencies]
# Miden dependencies.
cargo-miden = { workspace = true }
miden-client = { features = ["tonic"], workspace = true }
miden-client-sqlite-store = { workspace = true }
miden-standards = { version = "0.14" }
Expand Down
28 changes: 28 additions & 0 deletions crates/faucet/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use std::path::{Path, PathBuf};
use std::process::Command;

const CONTRACTS: &[&str] = &["mint-tx"];

fn main() {
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let contracts_dir = manifest_dir.join("../contracts");

for contract in CONTRACTS {
let dir = contracts_dir.join(contract);
// println!("cargo:rerun-if-changed={}", dir.display());
compile(&dir);
}
}

fn compile(dir: &Path) {
let manifest_path = dir.join("Cargo.toml");
let status = Command::new("miden")
.arg("build")
.arg("--release")
.arg("--manifest-path")
.arg(&manifest_path)
.status()
.unwrap_or_else(|e| panic!("failed to spawn `miden build` for {}: {e}", dir.display()));

// assert!(status.success(), "`miden build` for {} exited with {status}", dir.display());
}
27 changes: 9 additions & 18 deletions crates/faucet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ use tracing::{Instrument, error, info, info_span, instrument, warn};
use url::Url;

mod note_screener;
mod package;
pub mod requests;
pub mod types;

use miden_client::Deserializable;
use miden_client::vm::Package;

use crate::note_screener::NoteScreener;
use crate::package::{compile_dir_with_libs, write_faucet_component_masl};
use crate::requests::{MintError, MintRequest, MintResponse, MintResponseSender};
use crate::types::AssetAmount;

Expand Down Expand Up @@ -145,17 +146,10 @@ impl Faucet {
}
client.set_setting(DEFAULT_ACCOUNT_ID_SETTING.to_owned(), account.id()).await?;

// Compile the mint tx script from Rust via cargo-miden, linking the official
// BasicFungibleFaucet account component so that `account.mint_and_send()` resolves
// to the correct procedure digest.
let workspace_root = Path::new(env!("CARGO_MANIFEST_DIR"));
let tmp_dir = std::env::temp_dir().join("miden-faucet-build");
let faucet_masl = write_faucet_component_masl(&tmp_dir)?;
let package = compile_dir_with_libs(
&workspace_root.join("../contracts/mint-tx"),
true,
&[&faucet_masl],
)?;
// The mint tx script package is built by build.rs and embedded into the binary.
let package_bytes = include_bytes!(concat!(env!("OUT_DIR"), "/mint_tx.masp"));
let package = Package::read_from_bytes(package_bytes)
.context("failed to deserialize mint tx package")?;
let script = TransactionScript::new(package.unwrap_program());
client.set_setting(MINT_TX_SCRIPT_SETTING.to_string(), script).await?;

Expand Down Expand Up @@ -790,11 +784,8 @@ mod tests {
client.ensure_genesis_in_place().await.unwrap();
client.add_account(&account, false).await.unwrap();

let tmp_dir = temp_dir().join(format!("miden-faucet-build-{}", Uuid::new_v4()));
let faucet_masl = write_faucet_component_masl(&tmp_dir).unwrap();
let package =
compile_dir_with_libs(Path::new("../contracts/mint-tx"), true, &[&faucet_masl])
.unwrap();
let package_bytes = include_bytes!(concat!(env!("OUT_DIR"), "/mint_tx.masp"));
let package = Package::read_from_bytes(package_bytes).unwrap();
let program = package.unwrap_program();
let script =
TransactionScript::from_parts(program.mast_forest().clone(), program.entrypoint());
Expand Down
68 changes: 0 additions & 68 deletions crates/faucet/src/package.rs

This file was deleted.

3 changes: 3 additions & 0 deletions miden-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "0.14.0"
components = ["cargo-miden"]
3 changes: 0 additions & 3 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
[toolchain]
channel = "nightly-2025-12-10"
components = ["clippy", "llvm-tools", "rust-src", "rustfmt"]
profile = "minimal"
targets = ["wasm32-wasip2"]
Loading