diff --git a/Cargo.lock b/Cargo.lock index 52c77b496..4742a8d9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -705,6 +705,29 @@ dependencies = [ "serde", ] +[[package]] +name = "cargo-util" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f2d9a9a8d3e0b61b1110c49ab8f6ed7a76ce4f2b1d53ae48a83152d3d5e8f5b" +dependencies = [ + "anyhow", + "core-foundation", + "filetime", + "hex", + "ignore", + "jobserver", + "libc", + "miow", + "same-file", + "sha2", + "shell-escape", + "tempfile", + "tracing", + "walkdir", + "windows-sys 0.52.0", +] + [[package]] name = "cargo_metadata" version = "0.18.1" @@ -1394,6 +1417,18 @@ dependencies = [ "subtle", ] +[[package]] +name = "filetime" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "windows-sys 0.52.0", +] + [[package]] name = "fixedbitset" version = "0.4.2" @@ -2243,9 +2278,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "jobserver" -version = "0.1.27" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +checksum = "685a7d121ee3f65ae4fddd72b25a04bb36b6af81bc0828f7d5434c0fe60fa3a2" dependencies = [ "libc", ] @@ -2766,10 +2801,14 @@ dependencies = [ name = "miden-integration-tests" version = "0.1.0" dependencies = [ + "anyhow", + "cargo-util", "cargo_metadata", "concat-idents", "derive_more", "expect-test", + "filetime", + "glob", "miden-assembly", "miden-codegen-masm", "miden-core", @@ -2784,6 +2823,7 @@ dependencies = [ "proptest", "rustc-demangle", "sha2", + "walkdir", "wasmprinter", ] @@ -2925,6 +2965,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "miow" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "359f76430b20a79f9e20e115b3428614e654f04fab314482fc0fda0ebd3c6044" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "multimap" version = "0.8.3" @@ -4229,6 +4278,12 @@ dependencies = [ "keccak", ] +[[package]] +name = "shell-escape" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" + [[package]] name = "shell-words" version = "1.1.0" diff --git a/tests/integration/Cargo.toml b/tests/integration/Cargo.toml index acbbda4a7..2cd94ab01 100644 --- a/tests/integration/Cargo.toml +++ b/tests/integration/Cargo.toml @@ -28,6 +28,11 @@ sha2 = "0.10" rustc-demangle = { version = "0.1.19", features = ["std"] } cargo_metadata = "0.18" derive_more.workspace = true +anyhow.workspace = true +cargo-util = "0.2" +filetime = "0.2.23" +glob = "0.3.1" +walkdir = "2.5.0" [dev-dependencies] miden-core.workspace = true diff --git a/tests/integration/src/cargo_proj/mod.rs b/tests/integration/src/cargo_proj/mod.rs new file mode 100644 index 000000000..cd0dbff1d --- /dev/null +++ b/tests/integration/src/cargo_proj/mod.rs @@ -0,0 +1,469 @@ +//! Cargo project generation in-place for testing. +//! Based on cargo-test-support v0.2.0 crate code. + +#![allow(dead_code)] + +use std::{ + env, + fmt::Write, + fs, os, + path::{Path, PathBuf}, + sync::OnceLock, + time::{self, Duration}, +}; + +use cargo_util::{is_ci, ProcessBuilder}; + +/// Panics with a formatted message if the expression does not return `Ok`. +#[macro_export] +macro_rules! t { + ($e:expr) => { + match $e { + Ok(e) => e, + Err(e) => { + $crate::cargo_proj::panic_error(&format!("failed running {}", stringify!($e)), e) + } + } + }; +} + +#[track_caller] +pub fn panic_error(what: &str, err: impl Into) -> ! { + let err = err.into(); + pe(what, err); + #[track_caller] + fn pe(what: &str, err: anyhow::Error) -> ! { + let mut result = format!("{}\nerror: {}", what, err); + for cause in err.chain().skip(1) { + let _ = writeln!(result, "\nCaused by:"); + let _ = write!(result, "{}", cause); + } + panic!("\n{}", result); + } +} + +pub mod paths; +use self::paths::CargoPathExt; + +/* + * + * ===== Builders ===== + * + */ + +#[derive(PartialEq, Clone)] +struct FileBuilder { + path: PathBuf, + body: String, + executable: bool, +} + +impl FileBuilder { + pub fn new(path: PathBuf, body: &str, executable: bool) -> FileBuilder { + FileBuilder { + path, + body: body.to_string(), + executable, + } + } + + fn mk(&mut self) { + if self.executable { + let mut path = self.path.clone().into_os_string(); + write!(path, "{}", env::consts::EXE_SUFFIX).unwrap(); + self.path = path.into(); + } + + self.dirname().mkdir_p(); + fs::write(&self.path, &self.body) + .unwrap_or_else(|e| panic!("could not create file {}: {}", self.path.display(), e)); + + #[cfg(unix)] + if self.executable { + use std::os::unix::fs::PermissionsExt; + + let mut perms = fs::metadata(&self.path).unwrap().permissions(); + let mode = perms.mode(); + perms.set_mode(mode | 0o111); + fs::set_permissions(&self.path, perms).unwrap(); + } + } + + fn dirname(&self) -> &Path { + self.path.parent().unwrap() + } +} + +#[derive(PartialEq, Clone)] +struct SymlinkBuilder { + dst: PathBuf, + src: PathBuf, + src_is_dir: bool, +} + +impl SymlinkBuilder { + pub fn new(dst: PathBuf, src: PathBuf) -> SymlinkBuilder { + SymlinkBuilder { + dst, + src, + src_is_dir: false, + } + } + + pub fn new_dir(dst: PathBuf, src: PathBuf) -> SymlinkBuilder { + SymlinkBuilder { + dst, + src, + src_is_dir: true, + } + } + + fn mk(&self) { + self.dirname().mkdir_p(); + t!(os::unix::fs::symlink(&self.dst, &self.src)); + } + + fn dirname(&self) -> &Path { + self.src.parent().unwrap() + } +} + +/// A cargo project to run tests against. +/// +/// See [`ProjectBuilder`] or [`Project::from_template`] to get started. +pub struct Project { + root: PathBuf, +} + +/// Create a project to run tests against +/// +/// The project can be constructed programmatically or from the filesystem with +/// [`Project::from_template`] +#[must_use] +pub struct ProjectBuilder { + root: Project, + files: Vec, + symlinks: Vec, + no_manifest: bool, +} + +impl ProjectBuilder { + /// Root of the project, ex: `/path/to/cargo/target/cit/t0/foo` + pub fn root(&self) -> PathBuf { + self.root.root() + } + + /// Project's debug dir, ex: `/path/to/cargo/target/cit/t0/foo/target/debug` + pub fn target_debug_dir(&self) -> PathBuf { + self.root.target_debug_dir() + } + + pub fn new(root: PathBuf) -> ProjectBuilder { + ProjectBuilder { + root: Project { root }, + files: vec![], + symlinks: vec![], + no_manifest: false, + } + } + + /// Adds a file to the project. + pub fn file>(mut self, path: B, body: &str) -> Self { + self._file(path.as_ref(), body, false); + self + } + + /// Adds an executable file to the project. + pub fn executable>(mut self, path: B, body: &str) -> Self { + self._file(path.as_ref(), body, true); + self + } + + fn _file(&mut self, path: &Path, body: &str, executable: bool) { + self.files.push(FileBuilder::new(self.root.root().join(path), body, executable)); + } + + /// Adds a symlink to a file to the project. + pub fn symlink>(mut self, dst: T, src: T) -> Self { + self.symlinks + .push(SymlinkBuilder::new(self.root.root().join(dst), self.root.root().join(src))); + self + } + + /// Create a symlink to a directory + pub fn symlink_dir>(mut self, dst: T, src: T) -> Self { + self.symlinks + .push(SymlinkBuilder::new_dir(self.root.root().join(dst), self.root.root().join(src))); + self + } + + pub fn no_manifest(mut self) -> Self { + self.no_manifest = true; + self + } + + /// Creates the project. + pub fn build(mut self) -> Project { + // First, clean the directory if it already exists + self.rm_root(); + + // Create the empty directory + self.root.root().mkdir_p(); + + let manifest_path = self.root.root().join("Cargo.toml"); + if !self.no_manifest && self.files.iter().all(|fb| fb.path != manifest_path) { + self._file(Path::new("Cargo.toml"), &basic_manifest("foo", "0.0.1"), false) + } + + let past = time::SystemTime::now() - Duration::new(1, 0); + let ftime = filetime::FileTime::from_system_time(past); + + for file in self.files.iter_mut() { + file.mk(); + if is_coarse_mtime() { + // Place the entire project 1 second in the past to ensure + // that if cargo is called multiple times, the 2nd call will + // see targets as "fresh". Without this, if cargo finishes in + // under 1 second, the second call will see the mtime of + // source == mtime of output and consider it dirty. + filetime::set_file_times(&file.path, ftime, ftime).unwrap(); + } + } + + for symlink in self.symlinks.iter_mut() { + symlink.mk(); + } + + let ProjectBuilder { root, .. } = self; + root + } + + fn rm_root(&self) { + self.root.root().rm_rf() + } +} + +impl Project { + /// Root of the project, ex: `/path/to/cargo/target/cit/t0/foo` + pub fn root(&self) -> PathBuf { + self.root.clone() + } + + /// Project's target dir, ex: `/path/to/cargo/target/cit/t0/foo/target` + pub fn build_dir(&self) -> PathBuf { + self.root().join("target") + } + + /// Project's debug dir, ex: `/path/to/cargo/target/cit/t0/foo/target/debug` + pub fn target_debug_dir(&self) -> PathBuf { + self.build_dir().join("debug") + } + + /// Path to an example built as a library. + /// `kind` should be one of: "lib", "rlib", "staticlib", "dylib", "proc-macro" + /// ex: `/path/to/cargo/target/cit/t0/foo/target/debug/examples/libex.rlib` + pub fn example_lib(&self, name: &str, kind: &str) -> PathBuf { + self.target_debug_dir() + .join("examples") + .join(paths::get_lib_filename(name, kind)) + } + + /// Path to a debug binary. + /// ex: `/path/to/cargo/target/cit/t0/foo/target/debug/foo` + pub fn bin(&self, b: &str) -> PathBuf { + self.build_dir() + .join("debug") + .join(&format!("{}{}", b, env::consts::EXE_SUFFIX)) + } + + /// Path to a release binary. + /// ex: `/path/to/cargo/target/cit/t0/foo/target/release/foo` + pub fn release_bin(&self, b: &str) -> PathBuf { + self.build_dir() + .join("release") + .join(&format!("{}{}", b, env::consts::EXE_SUFFIX)) + } + + /// Path to a debug binary for a specific target triple. + /// ex: `/path/to/cargo/target/cit/t0/foo/target/i686-apple-darwin/debug/foo` + pub fn target_bin(&self, target: &str, b: &str) -> PathBuf { + self.build_dir().join(target).join("debug").join(&format!( + "{}{}", + b, + env::consts::EXE_SUFFIX + )) + } + + /// Returns an iterator of paths matching the glob pattern, which is + /// relative to the project root. + pub fn glob>(&self, pattern: P) -> glob::Paths { + let pattern = self.root().join(pattern); + glob::glob(pattern.to_str().expect("failed to convert pattern to str")) + .expect("failed to glob") + } + + /// Changes the contents of an existing file. + pub fn change_file(&self, path: &str, body: &str) { + FileBuilder::new(self.root().join(path), body, false).mk() + } + + /// Returns the contents of `Cargo.lock`. + pub fn read_lockfile(&self) -> String { + self.read_file("Cargo.lock") + } + + /// Returns the contents of a path in the project root + pub fn read_file(&self, path: &str) -> String { + let full = self.root().join(path); + fs::read_to_string(&full) + .unwrap_or_else(|e| panic!("could not read file {}: {}", full.display(), e)) + } + + /// Modifies `Cargo.toml` to remove all commented lines. + pub fn uncomment_root_manifest(&self) { + let contents = self.read_file("Cargo.toml").replace("#", ""); + fs::write(self.root().join("Cargo.toml"), contents).unwrap(); + } + + pub fn symlink(&self, src: impl AsRef, dst: impl AsRef) { + let src = self.root().join(src.as_ref()); + let dst = self.root().join(dst.as_ref()); + { + if let Err(e) = os::unix::fs::symlink(&src, &dst) { + panic!("failed to symlink {:?} to {:?}: {:?}", src, dst, e); + } + } + } +} + +// Generates a project layout +pub fn project(proj_folder_name: &str) -> ProjectBuilder { + let temp_dir = &std::env::temp_dir(); + let cargo_projects_root = temp_dir.join("miden_test_cargo_projects"); + let cargo_proj_path = cargo_projects_root.join(proj_folder_name); + dbg!(&cargo_proj_path); + ProjectBuilder::new(cargo_proj_path) +} + +/// This is the raw output from the process. +/// +/// This is similar to `std::process::Output`, however the `status` is +/// translated to the raw `code`. This is necessary because `ProcessError` +/// does not have access to the raw `ExitStatus` because `ProcessError` needs +/// to be serializable (for the Rustc cache), and `ExitStatus` does not +/// provide a constructor. +pub struct RawOutput { + pub code: Option, + pub stdout: Vec, + pub stderr: Vec, +} + +pub fn basic_manifest(name: &str, version: &str) -> String { + format!( + r#" + [package] + name = "{}" + version = "{}" + authors = [] + edition = "2015" + "#, + name, version + ) +} + +pub fn basic_bin_manifest(name: &str) -> String { + format!( + r#" + [package] + + name = "{}" + version = "0.5.0" + authors = ["wycats@example.com"] + edition = "2015" + + [[bin]] + + name = "{}" + "#, + name, name + ) +} + +pub fn basic_lib_manifest(name: &str) -> String { + format!( + r#" + [package] + + name = "{}" + version = "0.5.0" + authors = ["wycats@example.com"] + edition = "2015" + + [lib] + + name = "{}" + "#, + name, name + ) +} + +struct RustcInfo { + verbose_version: String, + host: String, +} + +impl RustcInfo { + fn new() -> RustcInfo { + let output = ProcessBuilder::new("rustc") + .arg("-vV") + .exec_with_output() + .expect("rustc should exec"); + let verbose_version = String::from_utf8(output.stdout).expect("utf8 output"); + let host = verbose_version + .lines() + .filter_map(|line| line.strip_prefix("host: ")) + .next() + .expect("verbose version has host: field") + .to_string(); + RustcInfo { + verbose_version, + host, + } + } +} + +fn rustc_info() -> &'static RustcInfo { + static RUSTC_INFO: OnceLock = OnceLock::new(); + RUSTC_INFO.get_or_init(RustcInfo::new) +} + +/// The rustc host such as `x86_64-unknown-linux-gnu`. +pub fn rustc_host() -> &'static str { + &rustc_info().host +} + +/// The host triple suitable for use in a cargo environment variable (uppercased). +pub fn rustc_host_env() -> String { + rustc_host().to_uppercase().replace('-', "_") +} + +pub fn is_nightly() -> bool { + let vv = &rustc_info().verbose_version; + // CARGO_TEST_DISABLE_NIGHTLY is set in rust-lang/rust's CI so that all + // nightly-only tests are disabled there. Otherwise, it could make it + // difficult to land changes which would need to be made simultaneously in + // rust-lang/cargo and rust-lan/rust, which isn't possible. + env::var("CARGO_TEST_DISABLE_NIGHTLY").is_err() + && (vv.contains("-nightly") || vv.contains("-dev")) +} + +/// Returns `true` if the local filesystem has low-resolution mtimes. +pub fn is_coarse_mtime() -> bool { + // If the filetime crate is being used to emulate HFS then + // return `true`, without looking at the actual hardware. + cfg!(emulate_second_only_system) || + // This should actually be a test that `$CARGO_TARGET_DIR` is on an HFS + // filesystem, (or any filesystem with low-resolution mtimes). However, + // that's tricky to detect, so for now just deal with CI. + cfg!(target_os = "macos") && is_ci() +} diff --git a/tests/integration/src/cargo_proj/paths.rs b/tests/integration/src/cargo_proj/paths.rs new file mode 100644 index 000000000..a0af5232d --- /dev/null +++ b/tests/integration/src/cargo_proj/paths.rs @@ -0,0 +1,185 @@ +use std::{ + fs, + io::{self, ErrorKind}, + path::{Path, PathBuf}, +}; + +use filetime::FileTime; + +pub trait CargoPathExt { + fn rm_rf(&self); + fn mkdir_p(&self); + + /// Returns a list of all files and directories underneath the given + /// directory, recursively, including the starting path. + fn ls_r(&self) -> Vec; + + fn move_into_the_past(&self) { + self.move_in_time(|sec, nsec| (sec - 3600, nsec)) + } + + fn move_into_the_future(&self) { + self.move_in_time(|sec, nsec| (sec + 3600, nsec)) + } + + fn move_in_time(&self, travel_amount: F) + where + F: Fn(i64, u32) -> (i64, u32); +} + +impl CargoPathExt for Path { + fn rm_rf(&self) { + let meta = match self.symlink_metadata() { + Ok(meta) => meta, + Err(e) => { + if e.kind() == ErrorKind::NotFound { + return; + } + panic!("failed to remove {:?}, could not read: {:?}", self, e); + } + }; + // There is a race condition between fetching the metadata and + // actually performing the removal, but we don't care all that much + // for our tests. + if meta.is_dir() { + if let Err(e) = fs::remove_dir_all(self) { + panic!("failed to remove {:?}: {:?}", self, e) + } + } else if let Err(e) = fs::remove_file(self) { + panic!("failed to remove {:?}: {:?}", self, e) + } + } + + fn mkdir_p(&self) { + fs::create_dir_all(self) + .unwrap_or_else(|e| panic!("failed to mkdir_p {}: {}", self.display(), e)) + } + + fn ls_r(&self) -> Vec { + walkdir::WalkDir::new(self) + .sort_by_file_name() + .into_iter() + .filter_map(|e| e.map(|e| e.path().to_owned()).ok()) + .collect() + } + + fn move_in_time(&self, travel_amount: F) + where + F: Fn(i64, u32) -> (i64, u32), + { + if self.is_file() { + time_travel(self, &travel_amount); + } else { + recurse(self, &self.join("target"), &travel_amount); + } + + fn recurse(p: &Path, bad: &Path, travel_amount: &F) + where + F: Fn(i64, u32) -> (i64, u32), + { + if p.is_file() { + time_travel(p, travel_amount) + } else if !p.starts_with(bad) { + for f in t!(fs::read_dir(p)) { + let f = t!(f).path(); + recurse(&f, bad, travel_amount); + } + } + } + + fn time_travel(path: &Path, travel_amount: &F) + where + F: Fn(i64, u32) -> (i64, u32), + { + let stat = t!(path.symlink_metadata()); + + let mtime = FileTime::from_last_modification_time(&stat); + + let (sec, nsec) = travel_amount(mtime.unix_seconds(), mtime.nanoseconds()); + let newtime = FileTime::from_unix_time(sec, nsec); + + // Sadly change_file_times has a failure mode where a readonly file + // cannot have its times changed on windows. + do_op(path, "set file times", |path| filetime::set_file_times(path, newtime, newtime)); + } + } +} + +fn do_op(path: &Path, desc: &str, mut f: F) +where + F: FnMut(&Path) -> io::Result<()>, +{ + match f(path) { + Ok(()) => {} + Err(ref e) if e.kind() == ErrorKind::PermissionDenied => { + let mut p = t!(path.metadata()).permissions(); + p.set_readonly(false); + t!(fs::set_permissions(path, p)); + + // Unix also requires the parent to not be readonly for example when + // removing files + let parent = path.parent().unwrap(); + let mut p = t!(parent.metadata()).permissions(); + p.set_readonly(false); + t!(fs::set_permissions(parent, p)); + + f(path).unwrap_or_else(|e| { + panic!("failed to {} {}: {}", desc, path.display(), e); + }) + } + Err(e) => { + panic!("failed to {} {}: {}", desc, path.display(), e); + } + } +} + +/// Get the filename for a library. +/// +/// `kind` should be one of: "lib", "rlib", "staticlib", "dylib", "proc-macro" +/// +/// For example, dynamic library named "foo" would return: +/// - macOS: "libfoo.dylib" +/// - Windows: "foo.dll" +/// - Unix: "libfoo.so" +pub fn get_lib_filename(name: &str, kind: &str) -> String { + let prefix = get_lib_prefix(kind); + let extension = get_lib_extension(kind); + format!("{}{}.{}", prefix, name, extension) +} + +pub fn get_lib_prefix(kind: &str) -> &str { + match kind { + "lib" | "rlib" => "lib", + "staticlib" | "dylib" | "proc-macro" => { + if cfg!(windows) { + "" + } else { + "lib" + } + } + _ => unreachable!(), + } +} + +pub fn get_lib_extension(kind: &str) -> &str { + match kind { + "lib" | "rlib" => "rlib", + "staticlib" => { + if cfg!(windows) { + "lib" + } else { + "a" + } + } + "dylib" | "proc-macro" => { + if cfg!(windows) { + "dll" + } else if cfg!(target_os = "macos") { + "dylib" + } else { + "so" + } + } + _ => unreachable!(), + } +} diff --git a/tests/integration/src/compiler_test.rs b/tests/integration/src/compiler_test.rs index 573f8d047..381fdeb41 100644 --- a/tests/integration/src/compiler_test.rs +++ b/tests/integration/src/compiler_test.rs @@ -4,7 +4,7 @@ use core::panic; use std::{ fs, io::Read, - path::Path, + path::{Path, PathBuf}, process::{Command, Stdio}, sync::Arc, }; @@ -36,7 +36,6 @@ pub enum CompilerTestSource { artifact_name: String, }, RustCargoComponent { - cargo_project_folder_name: String, artifact_name: String, }, } @@ -52,10 +51,7 @@ impl CompilerTestSource { cargo_project_folder_name: _, artifact_name, } => artifact_name.clone(), - CompilerTestSource::RustCargoComponent { - cargo_project_folder_name: _, - artifact_name, - } => artifact_name.clone(), + CompilerTestSource::RustCargoComponent { artifact_name } => artifact_name.clone(), _ => panic!("Not a Rust Cargo project"), } } @@ -113,10 +109,10 @@ pub struct CompilerTest { impl CompilerTest { /// Compile the Wasm component from a Rust Cargo project using cargo-component pub fn rust_source_cargo_component( - cargo_project_folder: &str, + cargo_project_folder: PathBuf, config: WasmTranslationConfig, ) -> Self { - let manifest_path = format!("../rust-apps-wasm/{}/Cargo.toml", cargo_project_folder); + let manifest_path = cargo_project_folder.join("Cargo.toml"); // dbg!(&pwd); let mut cargo_build_cmd = Command::new("cargo"); let compiler_workspace_dir = get_workspace_dir(); @@ -169,10 +165,7 @@ impl CompilerTest { Self { config, session: default_session(), - source: CompilerTestSource::RustCargoComponent { - cargo_project_folder_name: cargo_project_folder.to_string(), - artifact_name, - }, + source: CompilerTestSource::RustCargoComponent { artifact_name }, entrypoint: None, wasm_bytes: fs::read(wasm_artifacts.first().unwrap()).unwrap(), hir: None, diff --git a/tests/integration/src/lib.rs b/tests/integration/src/lib.rs index 29be514f3..9eaf01ea9 100644 --- a/tests/integration/src/lib.rs +++ b/tests/integration/src/lib.rs @@ -3,13 +3,13 @@ #![deny(warnings)] #![deny(missing_docs)] +mod cargo_proj; mod compiler_test; mod exec_emulator; mod exec_vm; pub(crate) mod felt_conversion; -pub use compiler_test::default_session; -pub use compiler_test::CompilerTest; +pub use compiler_test::{default_session, CompilerTest}; pub use exec_emulator::execute_emulator; pub use exec_vm::execute_vm; diff --git a/tests/integration/src/rust_masm_tests/components.rs b/tests/integration/src/rust_masm_tests/components.rs index 6768cbf18..6f6723d3f 100644 --- a/tests/integration/src/rust_masm_tests/components.rs +++ b/tests/integration/src/rust_masm_tests/components.rs @@ -3,20 +3,87 @@ use miden_core::crypto::hash::RpoDigest; use miden_frontend_wasm::{ImportMetadata, WasmTranslationConfig}; use miden_hir::{FunctionType, Ident, InterfaceFunctionIdent, InterfaceIdent, Symbol, Type}; -use crate::CompilerTest; +use crate::{cargo_proj::project, CompilerTest}; #[test] -fn wcm_add() { - // Has no imports +fn wcm_no_imports() { let config = Default::default(); - let mut test = CompilerTest::rust_source_cargo_component("add-comp", config); + + let proj = project("wcm_no_imports") + .file( + "Cargo.toml", + r#" + [package] + name = "add-wasm-component" + version = "0.0.1" + edition = "2015" + authors = [] + + [dependencies] + wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } + wee_alloc = { version = "0.4.5", default-features = false} + + [lib] + crate-type = ["cdylib"] + + [package.metadata.component] + package = "miden:add" + + [profile.release] + panic = "abort" + "#, + ) + .file( + "src/lib.rs", + r#" + #![no_std] + + #[global_allocator] + static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; + + #[panic_handler] + fn my_panic(_info: &core::panic::PanicInfo) -> ! { + loop {} + } + + extern crate wit_bindgen; + + mod bindings; + + use crate::bindings::exports::miden::add_package::add_interface::Guest; + + struct Component; + + impl Guest for Component { + fn add(a: u32, b: u32) -> u32 { + a + b + } + } + "#, + ) + .file( + "wit/add.wit", + r#" + package miden:add-package@1.0.0; + + interface add-interface { + add: func(a: u32, b: u32) -> u32; + } + + world add-world { + export add-interface; + } + "#, + ) + .build(); + let mut test = CompilerTest::rust_source_cargo_component(proj.root(), config); let artifact_name = test.source.artifact_name(); test.expect_wasm(expect_file![format!("../../expected/components/{artifact_name}.wat")]); test.expect_ir(expect_file![format!("../../expected/components/{artifact_name}.hir")]); } #[test] -fn wcm_inc() { +fn wcm_import() { // Imports an add component used in the above test let interface_function_ident = InterfaceFunctionIdent { @@ -38,7 +105,97 @@ fn wcm_inc() { import_metadata, ..Default::default() }; - let mut test = CompilerTest::rust_source_cargo_component("inc-comp", config); + + // Create the add component that will be imported in the wcm_import project + let _add_proj_dep = project("wcm_import_add") + .file( + "wit/add.wit", + r#" + package miden:add-package@1.0.0; + + interface add-interface { + add: func(a: u32, b: u32) -> u32; + } + + world add-world { + export add-interface; + } + "#, + ) + .no_manifest() + .build(); + + let proj = project("wcm_import") + .file( + "Cargo.toml", + r#" + [package] + name = "inc-wasm-component" + version = "0.0.1" + edition = "2015" + authors = [] + + [dependencies] + wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } + wee_alloc = { version = "0.4.5", default-features = false} + + [lib] + crate-type = ["cdylib"] + + [package.metadata.component] + package = "miden:inc" + + [package.metadata.component.target.dependencies] + "miden:add" = { path = "../wcm_import_add/wit" } + + [profile.release] + panic = "abort" + "#, + ) + .file( + "src/lib.rs", + r#" + #![no_std] + + #[global_allocator] + static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; + + #[panic_handler] + fn my_panic(_info: &core::panic::PanicInfo) -> ! { + loop {} + } + + extern crate wit_bindgen; + + mod bindings; + + use crate::bindings::{miden::add_package::add_interface::add, Guest}; + + struct Component; + + impl Guest for Component { + fn inc(a: u32) -> u32 { + add(a, 1) + } + } + "#, + ) + .file( + "wit/inc.wit", + r#" + package miden:inc-package@1.0.0; + + use miden:add-package/add-interface@1.0.0; + + world inc { + import add-interface; + export inc: func(a: u32) -> u32; + } + "#, + ) + .build(); + + let mut test = CompilerTest::rust_source_cargo_component(proj.root(), config); let artifact_name = test.source.artifact_name(); test.expect_wasm(expect_file![format!("../../expected/components/{artifact_name}.wat")]); test.expect_ir(expect_file![format!("../../expected/components/{artifact_name}.hir")]); diff --git a/tests/integration/src/rust_masm_tests/wit_sdk.rs b/tests/integration/src/rust_masm_tests/wit_sdk.rs index 8e3cc9230..f6de90c7a 100644 --- a/tests/integration/src/rust_masm_tests/wit_sdk.rs +++ b/tests/integration/src/rust_masm_tests/wit_sdk.rs @@ -1,4 +1,4 @@ -use std::collections::BTreeMap; +use std::{collections::BTreeMap, path::PathBuf, str::FromStr}; use expect_test::expect_file; use miden_core::crypto::hash::RpoDigest; @@ -9,7 +9,10 @@ use crate::CompilerTest; #[test] fn sdk() { - let test = CompilerTest::rust_source_cargo_component("wit-sdk/sdk", Default::default()); + let test = CompilerTest::rust_source_cargo_component( + PathBuf::from_str("../rust-apps-wasm/wit-sdk/sdk").unwrap(), + Default::default(), + ); let artifact_name = test.source.artifact_name(); test.expect_wasm(expect_file![format!( "../../expected/wit_sdk_basic_wallet/{artifact_name}.wat" @@ -60,7 +63,10 @@ fn sdk_basic_wallet() { import_metadata: import_metadata.clone(), ..Default::default() }; - let mut test = CompilerTest::rust_source_cargo_component("wit-sdk/basic-wallet", config); + let mut test = CompilerTest::rust_source_cargo_component( + PathBuf::from_str("../rust-apps-wasm/wit-sdk/basic-wallet").unwrap(), + config, + ); let artifact_name = test.source.artifact_name(); test.expect_wasm(expect_file![format!( "../../expected/wit_sdk_basic_wallet/{artifact_name}.wat" @@ -138,7 +144,10 @@ fn sdk_basic_wallet_p2id_note() { import_metadata: import_metadata.clone(), ..Default::default() }; - let mut test = CompilerTest::rust_source_cargo_component("wit-sdk/p2id-note", config); + let mut test = CompilerTest::rust_source_cargo_component( + PathBuf::from_str("../rust-apps-wasm/wit-sdk/p2id-note").unwrap(), + config, + ); let artifact_name = test.source.artifact_name(); test.expect_wasm(expect_file![format!( "../../expected/wit_sdk_basic_wallet/{artifact_name}.wat" diff --git a/tests/rust-apps-wasm/add-comp/Cargo.lock b/tests/rust-apps-wasm/add-comp/Cargo.lock deleted file mode 100644 index 7618a41ab..000000000 --- a/tests/rust-apps-wasm/add-comp/Cargo.lock +++ /dev/null @@ -1,78 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "add-wasm-component" -version = "0.1.0" -dependencies = [ - "wee_alloc", - "wit-bindgen", -] - -[[package]] -name = "bitflags" -version = "2.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "libc" -version = "0.2.153" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" - -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - -[[package]] -name = "wee_alloc" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" -dependencies = [ - "cfg-if", - "libc", - "memory_units", - "winapi", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "wit-bindgen" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" -dependencies = [ - "bitflags", -] diff --git a/tests/rust-apps-wasm/add-comp/Cargo.toml b/tests/rust-apps-wasm/add-comp/Cargo.toml deleted file mode 100644 index f2280b8d9..000000000 --- a/tests/rust-apps-wasm/add-comp/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "add-wasm-component" -version = "0.1.0" -authors = ["Miden Team"] -license = "MIT" -edition = "2021" -publish = false - -[dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } -wee_alloc = { version = "0.4.5", default-features = false} - -[lib] -crate-type = ["cdylib"] - -[package.metadata.component] -package = "miden:add" - -[profile.release] -panic = "abort" \ No newline at end of file diff --git a/tests/rust-apps-wasm/add-comp/src/bindings.rs b/tests/rust-apps-wasm/add-comp/src/bindings.rs deleted file mode 100644 index b5ca7dd6d..000000000 --- a/tests/rust-apps-wasm/add-comp/src/bindings.rs +++ /dev/null @@ -1,58 +0,0 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! -pub mod exports { - pub mod miden { - pub mod add_package { - - #[allow(clippy::all)] - pub mod add_interface { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - - #[doc(hidden)] - #[export_name = "miden:add-package/add-interface@1.0.0#add"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_add(arg0: i32,arg1: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::add(arg0 as u32, arg1 as u32); - wit_bindgen::rt::as_i32(result0) - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn add(a: u32,b: u32,) -> u32; - } - - } - - } - } -} - -#[cfg(target_arch = "wasm32")] -#[link_section = "component-type:add-world"] -#[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 327] = [3, 0, 9, 97, 100, 100, 45, 119, 111, 114, 108, 100, 0, 97, 115, 109, 13, 0, 1, 0, 7, 67, 1, 65, 2, 1, 66, 2, 1, 64, 2, 1, 97, 121, 1, 98, 121, 0, 121, 4, 0, 3, 97, 100, 100, 1, 0, 4, 1, 37, 109, 105, 100, 101, 110, 58, 97, 100, 100, 45, 112, 97, 99, 107, 97, 103, 101, 47, 97, 100, 100, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 49, 46, 48, 46, 48, 5, 0, 11, 19, 1, 0, 13, 97, 100, 100, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 3, 0, 0, 7, 108, 1, 65, 2, 1, 65, 2, 1, 66, 2, 1, 64, 2, 1, 97, 121, 1, 98, 121, 0, 121, 4, 0, 3, 97, 100, 100, 1, 0, 4, 1, 37, 109, 105, 100, 101, 110, 58, 97, 100, 100, 45, 112, 97, 99, 107, 97, 103, 101, 47, 97, 100, 100, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 49, 46, 48, 46, 48, 5, 0, 4, 1, 33, 109, 105, 100, 101, 110, 58, 97, 100, 100, 45, 112, 97, 99, 107, 97, 103, 101, 47, 97, 100, 100, 45, 119, 111, 114, 108, 100, 64, 49, 46, 48, 46, 48, 4, 0, 11, 15, 1, 0, 9, 97, 100, 100, 45, 119, 111, 114, 108, 100, 3, 2, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; - -#[inline(never)] -#[doc(hidden)] -#[cfg(target_arch = "wasm32")] -pub fn __link_section() {} diff --git a/tests/rust-apps-wasm/add-comp/src/lib.rs b/tests/rust-apps-wasm/add-comp/src/lib.rs deleted file mode 100644 index d7b0625f6..000000000 --- a/tests/rust-apps-wasm/add-comp/src/lib.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![no_std] - -#[global_allocator] -static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; - -#[panic_handler] -fn my_panic(_info: &core::panic::PanicInfo) -> ! { - loop {} -} - -mod bindings; - -use crate::bindings::exports::miden::add_package::add_interface::Guest; - -struct Component; - -impl Guest for Component { - fn add(a: u32, b: u32) -> u32 { - a + b - } -} diff --git a/tests/rust-apps-wasm/add-comp/wit/add.wit b/tests/rust-apps-wasm/add-comp/wit/add.wit deleted file mode 100644 index b4dca0330..000000000 --- a/tests/rust-apps-wasm/add-comp/wit/add.wit +++ /dev/null @@ -1,9 +0,0 @@ -package miden:add-package@1.0.0; - -interface add-interface { - add: func(a: u32, b: u32) -> u32; -} - -world add-world { - export add-interface; -} diff --git a/tests/rust-apps-wasm/inc-comp/Cargo.lock b/tests/rust-apps-wasm/inc-comp/Cargo.lock deleted file mode 100644 index 375542cfc..000000000 --- a/tests/rust-apps-wasm/inc-comp/Cargo.lock +++ /dev/null @@ -1,78 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "bitflags" -version = "2.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "inc-wasm-component" -version = "0.1.0" -dependencies = [ - "wee_alloc", - "wit-bindgen", -] - -[[package]] -name = "libc" -version = "0.2.153" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" - -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - -[[package]] -name = "wee_alloc" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" -dependencies = [ - "cfg-if", - "libc", - "memory_units", - "winapi", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "wit-bindgen" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6237168d93497b26dacdab157b08ad2787d74cdce10f89735f791b2a225eba4d" -dependencies = [ - "bitflags", -] diff --git a/tests/rust-apps-wasm/inc-comp/Cargo.toml b/tests/rust-apps-wasm/inc-comp/Cargo.toml deleted file mode 100644 index 12874c460..000000000 --- a/tests/rust-apps-wasm/inc-comp/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "inc-wasm-component" -version = "0.1.0" -authors = ["Miden Team"] -license = "MIT" -edition = "2021" -publish = false - -[dependencies] -wit-bindgen = { version = "0.17.0", default-features = false, features = ["realloc"] } -wee_alloc = { version = "0.4.5", default-features = false} - -[lib] -crate-type = ["cdylib"] - -[package.metadata.component] -package = "miden:inc" - -[package.metadata.component.target.dependencies] -"miden:add" = { path = "../add-comp/wit" } - -[profile.release] -panic = "abort" diff --git a/tests/rust-apps-wasm/inc-comp/src/bindings.rs b/tests/rust-apps-wasm/inc-comp/src/bindings.rs deleted file mode 100644 index c235308e5..000000000 --- a/tests/rust-apps-wasm/inc-comp/src/bindings.rs +++ /dev/null @@ -1,76 +0,0 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! -const _: () = { - - #[doc(hidden)] - #[export_name = "inc"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_inc(arg0: i32,) -> i32 { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch="wasm32")] - wit_bindgen::rt::run_ctors_once(); - - let result0 = <_GuestImpl as Guest>::inc(arg0 as u32); - wit_bindgen::rt::as_i32(result0) - } -}; -use super::Component as _GuestImpl; -pub trait Guest { - fn inc(a: u32,) -> u32; -} -pub mod miden { - pub mod add_package { - - #[allow(clippy::all)] - pub mod add_interface { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - #[allow(unused_unsafe, clippy::all)] - pub fn add(a: u32,b: u32,) -> u32{ - - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, vec::Vec, string::String}; - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:add-package/add-interface@1.0.0")] - extern "C" { - #[link_name = "add"] - fn wit_import(_: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(wit_bindgen::rt::as_i32(a), wit_bindgen::rt::as_i32(b)); - ret as u32 - } - } - - } - - } -} - -#[cfg(target_arch = "wasm32")] -#[link_section = "component-type:inc"] -#[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 235] = [3, 0, 3, 105, 110, 99, 0, 97, 115, 109, 13, 0, 1, 0, 7, 118, 1, 65, 2, 1, 65, 4, 1, 66, 2, 1, 64, 2, 1, 97, 121, 1, 98, 121, 0, 121, 4, 0, 3, 97, 100, 100, 1, 0, 3, 1, 37, 109, 105, 100, 101, 110, 58, 97, 100, 100, 45, 112, 97, 99, 107, 97, 103, 101, 47, 97, 100, 100, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 49, 46, 48, 46, 48, 5, 0, 1, 64, 1, 1, 97, 121, 0, 121, 4, 0, 3, 105, 110, 99, 1, 1, 4, 1, 27, 109, 105, 100, 101, 110, 58, 105, 110, 99, 45, 112, 97, 99, 107, 97, 103, 101, 47, 105, 110, 99, 64, 49, 46, 48, 46, 48, 4, 0, 11, 9, 1, 0, 3, 105, 110, 99, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; - -#[inline(never)] -#[doc(hidden)] -#[cfg(target_arch = "wasm32")] -pub fn __link_section() {} diff --git a/tests/rust-apps-wasm/inc-comp/src/lib.rs b/tests/rust-apps-wasm/inc-comp/src/lib.rs deleted file mode 100644 index 78070e7ad..000000000 --- a/tests/rust-apps-wasm/inc-comp/src/lib.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![no_std] - -#[global_allocator] -static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; - -#[panic_handler] -fn my_panic(_info: &core::panic::PanicInfo) -> ! { - loop {} -} - -mod bindings; - -use crate::bindings::{miden::add_package::add_interface::add, Guest}; - -struct Component; - -impl Guest for Component { - fn inc(a: u32) -> u32 { - add(a, 1) - } -} diff --git a/tests/rust-apps-wasm/inc-comp/wit/inc.wit b/tests/rust-apps-wasm/inc-comp/wit/inc.wit deleted file mode 100644 index b63637af8..000000000 --- a/tests/rust-apps-wasm/inc-comp/wit/inc.wit +++ /dev/null @@ -1,8 +0,0 @@ -package miden:inc-package@1.0.0; - -use miden:add-package/add-interface@1.0.0; - -world inc { - import add-interface; - export inc: func(a: u32) -> u32; -} diff --git a/tests/rust-apps-wasm/sdk/p2id-note/src/bindings.rs b/tests/rust-apps-wasm/sdk/p2id-note/src/bindings.rs deleted file mode 100644 index 41e29cbd3..000000000 --- a/tests/rust-apps-wasm/sdk/p2id-note/src/bindings.rs +++ /dev/null @@ -1,1375 +0,0 @@ -// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! -pub mod miden { - pub mod base { - - #[allow(clippy::all)] - pub mod core_types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - /// Represents base field element in the field using Montgomery representation. - /// Internal values represent x * R mod M where R = 2^64 mod M and x in [0, M). - /// The backing type is `f64` but the internal values are always integer in the range - /// [0, M). Field modulus M = 2^64 - 2^32 + 1 - #[repr(C)] - #[derive(Clone, Copy, PartialEq)] - pub struct Felt { - /// We plan to use f64 as the backing type for the field element. It has the size - /// that we need and we don't plan to support floating point - /// arithmetic in programs for Miden VM. - /// - /// For now its u64 - pub inner: u64, - } - impl ::core::fmt::Debug for Felt { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Felt").field("inner", &self.inner).finish() - } - } - /// A group of four field elements in the Miden base field. - pub type Word = (Felt, Felt, Felt, Felt); - /// Unique identifier of an account. - /// - /// Account ID consists of 1 field element (~64 bits). This field element uniquely - /// identifies a single account and also specifies the type of the - /// underlying account. Specifically: - /// - The two most significant bits of the ID specify the type of the account: - /// - 00 - regular account with updatable code. - /// - 01 - regular account with immutable code. - /// - 10 - fungible asset faucet with immutable code. - /// - 11 - non-fungible asset faucet with immutable code. - /// - The third most significant bit of the ID specifies whether the account data is - /// stored on-chain: - /// - 0 - full account data is stored on-chain. - /// - 1 - only the account hash is stored on-chain which serves as a commitment to the - /// account state. - /// As such the three most significant bits fully describes the type of the account. - #[repr(C)] - #[derive(Clone, Copy, PartialEq)] - pub struct AccountId { - pub inner: Felt, - } - impl ::core::fmt::Debug for AccountId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("AccountId").field("inner", &self.inner).finish() - } - } - /// Recipient of the note, i.e., hash(hash(hash(serial_num, [0; 4]), note_script_hash), - /// input_hash) - #[repr(C)] - #[derive(Clone, Copy, PartialEq)] - pub struct Recipient { - pub inner: Word, - } - impl ::core::fmt::Debug for Recipient { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Recipient").field("inner", &self.inner).finish() - } - } - #[repr(C)] - #[derive(Clone, Copy, PartialEq)] - pub struct Tag { - pub inner: Felt, - } - impl ::core::fmt::Debug for Tag { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Tag").field("inner", &self.inner).finish() - } - } - /// A fungible or a non-fungible asset. - /// - /// All assets are encoded using a single word (4 elements) such that it is easy to - /// determine the type of an asset both inside and outside Miden VM. - /// Specifically: Element 1 will be: - /// - ZERO for a fungible asset - /// - non-ZERO for a non-fungible asset - /// The most significant bit will be: - /// - ONE for a fungible asset - /// - ZERO for a non-fungible asset - /// - /// The above properties guarantee that there can never be a collision between a - /// fungible and a non-fungible asset. - /// - /// The methodology for constructing fungible and non-fungible assets is described - /// below. - /// - /// # Fungible assets - /// The most significant element of a fungible asset is set to the ID of the faucet - /// which issued the asset. This guarantees the properties described above - /// (the first bit is ONE). - /// - /// The least significant element is set to the amount of the asset. This amount cannot - /// be greater than 2^63 - 1 and thus requires 63-bits to store. - /// - /// Elements 1 and 2 are set to ZERO. - /// - /// It is impossible to find a collision between two fungible assets issued by different - /// faucets as the faucet_id is included in the description of the asset and - /// this is guaranteed to be different for each faucet as per the faucet - /// creation logic. - /// - /// # Non-fungible assets - /// The 4 elements of non-fungible assets are computed as follows: - /// - First the asset data is hashed. This compresses an asset of an arbitrary length to - /// 4 field - /// elements: [d0, d1, d2, d3]. - /// - d1 is then replaced with the faucet_id which issues the asset: [d0, faucet_id, d2, - /// d3]. - /// - Lastly, the most significant bit of d3 is set to ZERO. - /// - /// It is impossible to find a collision between two non-fungible assets issued by - /// different faucets as the faucet_id is included in the description of the - /// non-fungible asset and this is guaranteed to be different as per the - /// faucet creation logic. Collision resistance for non-fungible assets - /// issued by the same faucet is ~2^95. - #[repr(C)] - #[derive(Clone, Copy, PartialEq)] - pub struct CoreAsset { - pub inner: Word, - } - impl ::core::fmt::Debug for CoreAsset { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("CoreAsset").field("inner", &self.inner).finish() - } - } - /// Account nonce - #[repr(C)] - #[derive(Clone, Copy, PartialEq)] - pub struct Nonce { - pub inner: Felt, - } - impl ::core::fmt::Debug for Nonce { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Nonce").field("inner", &self.inner).finish() - } - } - /// Account hash - #[repr(C)] - #[derive(Clone, Copy, PartialEq)] - pub struct AccountHash { - pub inner: Word, - } - impl ::core::fmt::Debug for AccountHash { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("AccountHash").field("inner", &self.inner).finish() - } - } - /// Block hash - #[repr(C)] - #[derive(Clone, Copy, PartialEq)] - pub struct BlockHash { - pub inner: Word, - } - impl ::core::fmt::Debug for BlockHash { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("BlockHash").field("inner", &self.inner).finish() - } - } - /// Storage value - #[repr(C)] - #[derive(Clone, Copy, PartialEq)] - pub struct StorageValue { - pub inner: Word, - } - impl ::core::fmt::Debug for StorageValue { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("StorageValue").field("inner", &self.inner).finish() - } - } - /// Account storage root - #[repr(C)] - #[derive(Clone, Copy, PartialEq)] - pub struct StorageRoot { - pub inner: Word, - } - impl ::core::fmt::Debug for StorageRoot { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("StorageRoot").field("inner", &self.inner).finish() - } - } - /// Account code root - #[repr(C)] - #[derive(Clone, Copy, PartialEq)] - pub struct AccountCodeRoot { - pub inner: Word, - } - impl ::core::fmt::Debug for AccountCodeRoot { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("AccountCodeRoot").field("inner", &self.inner).finish() - } - } - /// Commitment to the account vault - #[repr(C)] - #[derive(Clone, Copy, PartialEq)] - pub struct VaultCommitment { - pub inner: Word, - } - impl ::core::fmt::Debug for VaultCommitment { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("VaultCommitment").field("inner", &self.inner).finish() - } - } - /// An id of the created note - #[repr(C)] - #[derive(Clone, Copy, PartialEq)] - pub struct NoteId { - pub inner: Felt, - } - impl ::core::fmt::Debug for NoteId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("NoteId").field("inner", &self.inner).finish() - } - } - #[allow(unused_unsafe, clippy::all)] - /// Creates a new account ID from a field element. - pub fn account_id_from_felt(felt: Felt) -> AccountId { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let Felt { inner: inner0 } = felt; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/core-types@1.0.0")] - extern "C" { - #[link_name = "account-id-from-felt"] - fn wit_import(_: i64) -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64) -> i64 { - unreachable!() - } - let ret = wit_import(wit_bindgen::rt::as_i64(inner0)); - AccountId { - inner: Felt { inner: ret as u64 }, - } - } - } - } - - #[allow(clippy::all)] - pub mod tx { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Felt = super::super::super::miden::base::core_types::Felt; - pub type CoreAsset = super::super::super::miden::base::core_types::CoreAsset; - pub type Tag = super::super::super::miden::base::core_types::Tag; - pub type Recipient = super::super::super::miden::base::core_types::Recipient; - pub type BlockHash = super::super::super::miden::base::core_types::BlockHash; - pub type Word = super::super::super::miden::base::core_types::Word; - pub type NoteId = super::super::super::miden::base::core_types::NoteId; - #[allow(unused_unsafe, clippy::all)] - /// Returns the block number of the last known block at the time of transaction - /// execution. - pub fn get_block_number() -> Felt { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/tx@1.0.0")] - extern "C" { - #[link_name = "get-block-number"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64 { - unreachable!() - } - let ret = wit_import(); - super::super::super::miden::base::core_types::Felt { inner: ret as u64 } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Returns the block hash of the last known block at the time of transaction execution. - pub fn get_block_hash() -> BlockHash { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/tx@1.0.0")] - extern "C" { - #[link_name = "get-block-hash"] - fn wit_import(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) { - unreachable!() - } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i64); - let l3 = *((ptr0 + 16) as *const i64); - let l4 = *((ptr0 + 24) as *const i64); - super::super::super::miden::base::core_types::BlockHash { - inner: ( - super::super::super::miden::base::core_types::Felt { inner: l1 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l2 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l3 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l4 as u64 }, - ), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Returns the input notes hash. This is computed as a sequential hash of - /// (nullifier, script_root) tuples over all input notes. - pub fn get_input_notes_hash() -> Word { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/tx@1.0.0")] - extern "C" { - #[link_name = "get-input-notes-hash"] - fn wit_import(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) { - unreachable!() - } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i64); - let l3 = *((ptr0 + 16) as *const i64); - let l4 = *((ptr0 + 24) as *const i64); - ( - super::super::super::miden::base::core_types::Felt { inner: l1 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l2 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l3 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l4 as u64 }, - ) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Returns the output notes hash. This is computed as a sequential hash of - /// (note_hash, note_metadata) tuples over all output notes. - pub fn get_output_notes_hash() -> Word { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/tx@1.0.0")] - extern "C" { - #[link_name = "get-output-notes-hash"] - fn wit_import(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) { - unreachable!() - } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i64); - let l3 = *((ptr0 + 16) as *const i64); - let l4 = *((ptr0 + 24) as *const i64); - ( - super::super::super::miden::base::core_types::Felt { inner: l1 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l2 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l3 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l4 as u64 }, - ) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Creates a new note. - /// asset is the asset to be included in the note. - /// tag is the tag to be included in the note. - /// recipient is the recipient of the note. - /// Returns the id of the created note. - pub fn create_note(asset: CoreAsset, tag: Tag, recipient: Recipient) -> NoteId { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let super::super::super::miden::base::core_types::CoreAsset { inner: inner0 } = - asset; - let (t1_0, t1_1, t1_2, t1_3) = inner0; - let super::super::super::miden::base::core_types::Felt { inner: inner2 } = t1_0; - let super::super::super::miden::base::core_types::Felt { inner: inner3 } = t1_1; - let super::super::super::miden::base::core_types::Felt { inner: inner4 } = t1_2; - let super::super::super::miden::base::core_types::Felt { inner: inner5 } = t1_3; - let super::super::super::miden::base::core_types::Tag { inner: inner6 } = tag; - let super::super::super::miden::base::core_types::Felt { inner: inner7 } = - inner6; - let super::super::super::miden::base::core_types::Recipient { inner: inner8 } = - recipient; - let (t9_0, t9_1, t9_2, t9_3) = inner8; - let super::super::super::miden::base::core_types::Felt { inner: inner10 } = - t9_0; - let super::super::super::miden::base::core_types::Felt { inner: inner11 } = - t9_1; - let super::super::super::miden::base::core_types::Felt { inner: inner12 } = - t9_2; - let super::super::super::miden::base::core_types::Felt { inner: inner13 } = - t9_3; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/tx@1.0.0")] - extern "C" { - #[link_name = "create-note"] - fn wit_import( - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - ) -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import( - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - ) -> i64 { - unreachable!() - } - let ret = wit_import( - wit_bindgen::rt::as_i64(inner2), - wit_bindgen::rt::as_i64(inner3), - wit_bindgen::rt::as_i64(inner4), - wit_bindgen::rt::as_i64(inner5), - wit_bindgen::rt::as_i64(inner7), - wit_bindgen::rt::as_i64(inner10), - wit_bindgen::rt::as_i64(inner11), - wit_bindgen::rt::as_i64(inner12), - wit_bindgen::rt::as_i64(inner13), - ); - super::super::super::miden::base::core_types::NoteId { - inner: super::super::super::miden::base::core_types::Felt { - inner: ret as u64, - }, - } - } - } - } - - #[allow(clippy::all)] - pub mod account { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Felt = super::super::super::miden::base::core_types::Felt; - pub type CoreAsset = super::super::super::miden::base::core_types::CoreAsset; - pub type AccountId = super::super::super::miden::base::core_types::AccountId; - pub type Nonce = super::super::super::miden::base::core_types::Nonce; - pub type AccountHash = super::super::super::miden::base::core_types::AccountHash; - pub type StorageValue = super::super::super::miden::base::core_types::StorageValue; - pub type StorageRoot = super::super::super::miden::base::core_types::StorageRoot; - pub type AccountCodeRoot = - super::super::super::miden::base::core_types::AccountCodeRoot; - pub type VaultCommitment = - super::super::super::miden::base::core_types::VaultCommitment; - #[allow(unused_unsafe, clippy::all)] - /// Get the id of the currently executing account - pub fn get_id() -> AccountId { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/account@1.0.0")] - extern "C" { - #[link_name = "get-id"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64 { - unreachable!() - } - let ret = wit_import(); - super::super::super::miden::base::core_types::AccountId { - inner: super::super::super::miden::base::core_types::Felt { - inner: ret as u64, - }, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Return the account nonce - pub fn get_nonce() -> Nonce { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/account@1.0.0")] - extern "C" { - #[link_name = "get-nonce"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64 { - unreachable!() - } - let ret = wit_import(); - super::super::super::miden::base::core_types::Nonce { - inner: super::super::super::miden::base::core_types::Felt { - inner: ret as u64, - }, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Get the initial hash of the currently executing account - pub fn get_initial_hash() -> AccountHash { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/account@1.0.0")] - extern "C" { - #[link_name = "get-initial-hash"] - fn wit_import(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) { - unreachable!() - } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i64); - let l3 = *((ptr0 + 16) as *const i64); - let l4 = *((ptr0 + 24) as *const i64); - super::super::super::miden::base::core_types::AccountHash { - inner: ( - super::super::super::miden::base::core_types::Felt { inner: l1 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l2 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l3 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l4 as u64 }, - ), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Get the current hash of the account data stored in memory - pub fn get_current_hash() -> AccountHash { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/account@1.0.0")] - extern "C" { - #[link_name = "get-current-hash"] - fn wit_import(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) { - unreachable!() - } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i64); - let l3 = *((ptr0 + 16) as *const i64); - let l4 = *((ptr0 + 24) as *const i64); - super::super::super::miden::base::core_types::AccountHash { - inner: ( - super::super::super::miden::base::core_types::Felt { inner: l1 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l2 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l3 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l4 as u64 }, - ), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Increment the account nonce by the specified value. - /// value can be at most 2^32 - 1 otherwise this procedure panics - pub fn incr_nonce(value: Felt) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let super::super::super::miden::base::core_types::Felt { inner: inner0 } = - value; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/account@1.0.0")] - extern "C" { - #[link_name = "incr-nonce"] - fn wit_import(_: i64); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64) { - unreachable!() - } - wit_import(wit_bindgen::rt::as_i64(inner0)); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Get the value of the specified key in the account storage - pub fn get_item(index: Felt) -> StorageValue { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let super::super::super::miden::base::core_types::Felt { inner: inner0 } = - index; - let ptr1 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/account@1.0.0")] - extern "C" { - #[link_name = "get-item"] - fn wit_import(_: i64, _: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i32) { - unreachable!() - } - wit_import(wit_bindgen::rt::as_i64(inner0), ptr1); - let l2 = *((ptr1 + 0) as *const i64); - let l3 = *((ptr1 + 8) as *const i64); - let l4 = *((ptr1 + 16) as *const i64); - let l5 = *((ptr1 + 24) as *const i64); - super::super::super::miden::base::core_types::StorageValue { - inner: ( - super::super::super::miden::base::core_types::Felt { inner: l2 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l3 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l4 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l5 as u64 }, - ), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Set the value of the specified key in the account storage - /// Returns the old value of the key and the new storage root - pub fn set_item(index: Felt, value: StorageValue) -> (StorageRoot, StorageValue) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 64]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let super::super::super::miden::base::core_types::Felt { inner: inner0 } = - index; - let super::super::super::miden::base::core_types::StorageValue { - inner: inner1, - } = value; - let (t2_0, t2_1, t2_2, t2_3) = inner1; - let super::super::super::miden::base::core_types::Felt { inner: inner3 } = t2_0; - let super::super::super::miden::base::core_types::Felt { inner: inner4 } = t2_1; - let super::super::super::miden::base::core_types::Felt { inner: inner5 } = t2_2; - let super::super::super::miden::base::core_types::Felt { inner: inner6 } = t2_3; - let ptr7 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/account@1.0.0")] - extern "C" { - #[link_name = "set-item"] - fn wit_import(_: i64, _: i64, _: i64, _: i64, _: i64, _: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i64, _: i64, _: i64, _: i32) { - unreachable!() - } - wit_import( - wit_bindgen::rt::as_i64(inner0), - wit_bindgen::rt::as_i64(inner3), - wit_bindgen::rt::as_i64(inner4), - wit_bindgen::rt::as_i64(inner5), - wit_bindgen::rt::as_i64(inner6), - ptr7, - ); - let l8 = *((ptr7 + 0) as *const i64); - let l9 = *((ptr7 + 8) as *const i64); - let l10 = *((ptr7 + 16) as *const i64); - let l11 = *((ptr7 + 24) as *const i64); - let l12 = *((ptr7 + 32) as *const i64); - let l13 = *((ptr7 + 40) as *const i64); - let l14 = *((ptr7 + 48) as *const i64); - let l15 = *((ptr7 + 56) as *const i64); - ( - super::super::super::miden::base::core_types::StorageRoot { - inner: ( - super::super::super::miden::base::core_types::Felt { - inner: l8 as u64, - }, - super::super::super::miden::base::core_types::Felt { - inner: l9 as u64, - }, - super::super::super::miden::base::core_types::Felt { - inner: l10 as u64, - }, - super::super::super::miden::base::core_types::Felt { - inner: l11 as u64, - }, - ), - }, - super::super::super::miden::base::core_types::StorageValue { - inner: ( - super::super::super::miden::base::core_types::Felt { - inner: l12 as u64, - }, - super::super::super::miden::base::core_types::Felt { - inner: l13 as u64, - }, - super::super::super::miden::base::core_types::Felt { - inner: l14 as u64, - }, - super::super::super::miden::base::core_types::Felt { - inner: l15 as u64, - }, - ), - }, - ) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Sets the code of the account the transaction is being executed against. - /// This procedure can only be executed on regular accounts with updatable - /// code. Otherwise, this procedure fails. code is the hash of the code - /// to set. - pub fn set_code(code_root: AccountCodeRoot) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let super::super::super::miden::base::core_types::AccountCodeRoot { - inner: inner0, - } = code_root; - let (t1_0, t1_1, t1_2, t1_3) = inner0; - let super::super::super::miden::base::core_types::Felt { inner: inner2 } = t1_0; - let super::super::super::miden::base::core_types::Felt { inner: inner3 } = t1_1; - let super::super::super::miden::base::core_types::Felt { inner: inner4 } = t1_2; - let super::super::super::miden::base::core_types::Felt { inner: inner5 } = t1_3; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/account@1.0.0")] - extern "C" { - #[link_name = "set-code"] - fn wit_import(_: i64, _: i64, _: i64, _: i64); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i64, _: i64) { - unreachable!() - } - wit_import( - wit_bindgen::rt::as_i64(inner2), - wit_bindgen::rt::as_i64(inner3), - wit_bindgen::rt::as_i64(inner4), - wit_bindgen::rt::as_i64(inner5), - ); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Returns the balance of a fungible asset associated with a account_id. - /// Panics if the asset is not a fungible asset. account_id is the faucet id - /// of the fungible asset of interest. balance is the vault balance of the - /// fungible asset. - pub fn get_balance(account_id: AccountId) -> Felt { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let super::super::super::miden::base::core_types::AccountId { inner: inner0 } = - account_id; - let super::super::super::miden::base::core_types::Felt { inner: inner1 } = - inner0; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/account@1.0.0")] - extern "C" { - #[link_name = "get-balance"] - fn wit_import(_: i64) -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64) -> i64 { - unreachable!() - } - let ret = wit_import(wit_bindgen::rt::as_i64(inner1)); - super::super::super::miden::base::core_types::Felt { inner: ret as u64 } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Returns a boolean indicating whether the non-fungible asset is present - /// in the vault. Panics if the asset is a fungible asset. asset is the - /// non-fungible asset of interest. has_asset is a boolean indicating - /// whether the account vault has the asset of interest. - pub fn has_non_fungible_asset(asset: CoreAsset) -> bool { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let super::super::super::miden::base::core_types::CoreAsset { inner: inner0 } = - asset; - let (t1_0, t1_1, t1_2, t1_3) = inner0; - let super::super::super::miden::base::core_types::Felt { inner: inner2 } = t1_0; - let super::super::super::miden::base::core_types::Felt { inner: inner3 } = t1_1; - let super::super::super::miden::base::core_types::Felt { inner: inner4 } = t1_2; - let super::super::super::miden::base::core_types::Felt { inner: inner5 } = t1_3; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/account@1.0.0")] - extern "C" { - #[link_name = "has-non-fungible-asset"] - fn wit_import(_: i64, _: i64, _: i64, _: i64) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i64, _: i64) -> i32 { - unreachable!() - } - let ret = wit_import( - wit_bindgen::rt::as_i64(inner2), - wit_bindgen::rt::as_i64(inner3), - wit_bindgen::rt::as_i64(inner4), - wit_bindgen::rt::as_i64(inner5), - ); - wit_bindgen::rt::bool_lift(ret as u8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Add the specified asset to the vault. Panics under various conditions. - /// Returns the final asset in the account vault defined as follows: If asset is - /// a non-fungible asset, then returns the same as asset. If asset is a - /// fungible asset, then returns the total fungible asset in the account - /// vault after asset was added to it. - pub fn add_asset(asset: CoreAsset) -> CoreAsset { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let super::super::super::miden::base::core_types::CoreAsset { inner: inner0 } = - asset; - let (t1_0, t1_1, t1_2, t1_3) = inner0; - let super::super::super::miden::base::core_types::Felt { inner: inner2 } = t1_0; - let super::super::super::miden::base::core_types::Felt { inner: inner3 } = t1_1; - let super::super::super::miden::base::core_types::Felt { inner: inner4 } = t1_2; - let super::super::super::miden::base::core_types::Felt { inner: inner5 } = t1_3; - let ptr6 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/account@1.0.0")] - extern "C" { - #[link_name = "add-asset"] - fn wit_import(_: i64, _: i64, _: i64, _: i64, _: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i64, _: i64, _: i32) { - unreachable!() - } - wit_import( - wit_bindgen::rt::as_i64(inner2), - wit_bindgen::rt::as_i64(inner3), - wit_bindgen::rt::as_i64(inner4), - wit_bindgen::rt::as_i64(inner5), - ptr6, - ); - let l7 = *((ptr6 + 0) as *const i64); - let l8 = *((ptr6 + 8) as *const i64); - let l9 = *((ptr6 + 16) as *const i64); - let l10 = *((ptr6 + 24) as *const i64); - super::super::super::miden::base::core_types::CoreAsset { - inner: ( - super::super::super::miden::base::core_types::Felt { inner: l7 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l8 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l9 as u64 }, - super::super::super::miden::base::core_types::Felt { - inner: l10 as u64, - }, - ), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Remove the specified asset from the vault - pub fn remove_asset(asset: CoreAsset) -> CoreAsset { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let super::super::super::miden::base::core_types::CoreAsset { inner: inner0 } = - asset; - let (t1_0, t1_1, t1_2, t1_3) = inner0; - let super::super::super::miden::base::core_types::Felt { inner: inner2 } = t1_0; - let super::super::super::miden::base::core_types::Felt { inner: inner3 } = t1_1; - let super::super::super::miden::base::core_types::Felt { inner: inner4 } = t1_2; - let super::super::super::miden::base::core_types::Felt { inner: inner5 } = t1_3; - let ptr6 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/account@1.0.0")] - extern "C" { - #[link_name = "remove-asset"] - fn wit_import(_: i64, _: i64, _: i64, _: i64, _: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i64, _: i64, _: i32) { - unreachable!() - } - wit_import( - wit_bindgen::rt::as_i64(inner2), - wit_bindgen::rt::as_i64(inner3), - wit_bindgen::rt::as_i64(inner4), - wit_bindgen::rt::as_i64(inner5), - ptr6, - ); - let l7 = *((ptr6 + 0) as *const i64); - let l8 = *((ptr6 + 8) as *const i64); - let l9 = *((ptr6 + 16) as *const i64); - let l10 = *((ptr6 + 24) as *const i64); - super::super::super::miden::base::core_types::CoreAsset { - inner: ( - super::super::super::miden::base::core_types::Felt { inner: l7 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l8 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l9 as u64 }, - super::super::super::miden::base::core_types::Felt { - inner: l10 as u64, - }, - ), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Returns the commitment to the account vault. - pub fn get_vault_commitment() -> VaultCommitment { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(8))] - struct RetArea([u8; 32]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/account@1.0.0")] - extern "C" { - #[link_name = "get-vault-commitment"] - fn wit_import(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) { - unreachable!() - } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i64); - let l2 = *((ptr0 + 8) as *const i64); - let l3 = *((ptr0 + 16) as *const i64); - let l4 = *((ptr0 + 24) as *const i64); - super::super::super::miden::base::core_types::VaultCommitment { - inner: ( - super::super::super::miden::base::core_types::Felt { inner: l1 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l2 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l3 as u64 }, - super::super::super::miden::base::core_types::Felt { inner: l4 as u64 }, - ), - } - } - } - } - - #[allow(clippy::all)] - pub mod note { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type Felt = super::super::super::miden::base::core_types::Felt; - pub type CoreAsset = super::super::super::miden::base::core_types::CoreAsset; - pub type AccountId = super::super::super::miden::base::core_types::AccountId; - #[allow(unused_unsafe, clippy::all)] - /// Get the inputs of the currently executed note - pub fn get_inputs() -> wit_bindgen::rt::vec::Vec { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/note@1.0.0")] - extern "C" { - #[link_name = "get-inputs"] - fn wit_import(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) { - unreachable!() - } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 4) as *const i32); - let len3 = l2 as usize; - Vec::from_raw_parts(l1 as *mut _, len3, len3) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Get the assets of the currently executing note - pub fn get_assets() -> wit_bindgen::rt::vec::Vec { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[repr(align(4))] - struct RetArea([u8; 8]); - let mut ret_area = ::core::mem::MaybeUninit::::uninit(); - let ptr0 = ret_area.as_mut_ptr() as i32; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/note@1.0.0")] - extern "C" { - #[link_name = "get-assets"] - fn wit_import(_: i32); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) { - unreachable!() - } - wit_import(ptr0); - let l1 = *((ptr0 + 0) as *const i32); - let l2 = *((ptr0 + 4) as *const i32); - let len3 = l2 as usize; - Vec::from_raw_parts(l1 as *mut _, len3, len3) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Get the sender of the currently executing note - pub fn get_sender() -> AccountId { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:base/note@1.0.0")] - extern "C" { - #[link_name = "get-sender"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64 { - unreachable!() - } - let ret = wit_import(); - super::super::super::miden::base::core_types::AccountId { - inner: super::super::super::miden::base::core_types::Felt { - inner: ret as u64, - }, - } - } - } - } - } - pub mod basic_wallet { - - #[allow(clippy::all)] - pub mod basic_wallet { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; - pub type CoreAsset = super::super::super::miden::base::core_types::CoreAsset; - pub type Tag = super::super::super::miden::base::core_types::Tag; - pub type Recipient = super::super::super::miden::base::core_types::Recipient; - #[allow(unused_unsafe, clippy::all)] - pub fn receive_asset(core_asset: CoreAsset) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let super::super::super::miden::base::core_types::CoreAsset { inner: inner0 } = - core_asset; - let (t1_0, t1_1, t1_2, t1_3) = inner0; - let super::super::super::miden::base::core_types::Felt { inner: inner2 } = t1_0; - let super::super::super::miden::base::core_types::Felt { inner: inner3 } = t1_1; - let super::super::super::miden::base::core_types::Felt { inner: inner4 } = t1_2; - let super::super::super::miden::base::core_types::Felt { inner: inner5 } = t1_3; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:basic-wallet/basic-wallet@1.0.0")] - extern "C" { - #[link_name = "receive-asset"] - fn wit_import(_: i64, _: i64, _: i64, _: i64); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64, _: i64, _: i64) { - unreachable!() - } - wit_import( - wit_bindgen::rt::as_i64(inner2), - wit_bindgen::rt::as_i64(inner3), - wit_bindgen::rt::as_i64(inner4), - wit_bindgen::rt::as_i64(inner5), - ); - } - } - #[allow(unused_unsafe, clippy::all)] - pub fn send_asset(core_asset: CoreAsset, tag: Tag, recipient: Recipient) { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - unsafe { - let super::super::super::miden::base::core_types::CoreAsset { inner: inner0 } = - core_asset; - let (t1_0, t1_1, t1_2, t1_3) = inner0; - let super::super::super::miden::base::core_types::Felt { inner: inner2 } = t1_0; - let super::super::super::miden::base::core_types::Felt { inner: inner3 } = t1_1; - let super::super::super::miden::base::core_types::Felt { inner: inner4 } = t1_2; - let super::super::super::miden::base::core_types::Felt { inner: inner5 } = t1_3; - let super::super::super::miden::base::core_types::Tag { inner: inner6 } = tag; - let super::super::super::miden::base::core_types::Felt { inner: inner7 } = - inner6; - let super::super::super::miden::base::core_types::Recipient { inner: inner8 } = - recipient; - let (t9_0, t9_1, t9_2, t9_3) = inner8; - let super::super::super::miden::base::core_types::Felt { inner: inner10 } = - t9_0; - let super::super::super::miden::base::core_types::Felt { inner: inner11 } = - t9_1; - let super::super::super::miden::base::core_types::Felt { inner: inner12 } = - t9_2; - let super::super::super::miden::base::core_types::Felt { inner: inner13 } = - t9_3; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "miden:basic-wallet/basic-wallet@1.0.0")] - extern "C" { - #[link_name = "send-asset"] - fn wit_import( - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import( - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - _: i64, - ) { - unreachable!() - } - wit_import( - wit_bindgen::rt::as_i64(inner2), - wit_bindgen::rt::as_i64(inner3), - wit_bindgen::rt::as_i64(inner4), - wit_bindgen::rt::as_i64(inner5), - wit_bindgen::rt::as_i64(inner7), - wit_bindgen::rt::as_i64(inner10), - wit_bindgen::rt::as_i64(inner11), - wit_bindgen::rt::as_i64(inner12), - wit_bindgen::rt::as_i64(inner13), - ); - } - } - } - } -} -pub mod exports { - pub mod miden { - pub mod base { - - #[allow(clippy::all)] - pub mod note_script { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; - const _: () = { - #[doc(hidden)] - #[export_name = "miden:base/note-script@1.0.0#note-script"] - #[allow(non_snake_case)] - unsafe extern "C" fn __export_note_script() { - #[allow(unused_imports)] - use wit_bindgen::rt::{alloc, string::String, vec::Vec}; - - // Before executing any other code, use this function to run all static - // constructors, if they have not yet been run. This is a hack required - // to work around wasi-libc ctors calling import functions to initialize - // the environment. - // - // This functionality will be removed once rust 1.69.0 is stable, at which - // point wasi-libc will no longer have this behavior. - // - // See - // https://github.com/bytecodealliance/preview2-prototyping/issues/99 - // for more details. - #[cfg(target_arch = "wasm32")] - wit_bindgen::rt::run_ctors_once(); - - <_GuestImpl as Guest>::note_script(); - } - }; - use super::super::super::super::super::Component as _GuestImpl; - pub trait Guest { - fn note_script(); - } - } - } - } -} - -#[cfg(target_arch = "wasm32")] -#[link_section = "component-type:notes-world"] -#[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 2438] = [ - 3, 0, 11, 110, 111, 116, 101, 115, 45, 119, 111, 114, 108, 100, 0, 97, 115, 109, 13, 0, 1, 0, - 7, 128, 18, 1, 65, 2, 1, 65, 26, 1, 66, 30, 1, 114, 1, 5, 105, 110, 110, 101, 114, 119, 4, 0, - 4, 102, 101, 108, 116, 3, 0, 0, 1, 111, 4, 1, 1, 1, 1, 4, 0, 4, 119, 111, 114, 100, 3, 0, 2, 1, - 114, 1, 5, 105, 110, 110, 101, 114, 1, 4, 0, 10, 97, 99, 99, 111, 117, 110, 116, 45, 105, 100, - 3, 0, 4, 1, 114, 1, 5, 105, 110, 110, 101, 114, 3, 4, 0, 9, 114, 101, 99, 105, 112, 105, 101, - 110, 116, 3, 0, 6, 1, 114, 1, 5, 105, 110, 110, 101, 114, 1, 4, 0, 3, 116, 97, 103, 3, 0, 8, 1, - 114, 1, 5, 105, 110, 110, 101, 114, 3, 4, 0, 10, 99, 111, 114, 101, 45, 97, 115, 115, 101, 116, - 3, 0, 10, 1, 114, 1, 5, 105, 110, 110, 101, 114, 1, 4, 0, 5, 110, 111, 110, 99, 101, 3, 0, 12, - 1, 114, 1, 5, 105, 110, 110, 101, 114, 3, 4, 0, 12, 97, 99, 99, 111, 117, 110, 116, 45, 104, - 97, 115, 104, 3, 0, 14, 1, 114, 1, 5, 105, 110, 110, 101, 114, 3, 4, 0, 10, 98, 108, 111, 99, - 107, 45, 104, 97, 115, 104, 3, 0, 16, 1, 114, 1, 5, 105, 110, 110, 101, 114, 3, 4, 0, 13, 115, - 116, 111, 114, 97, 103, 101, 45, 118, 97, 108, 117, 101, 3, 0, 18, 1, 114, 1, 5, 105, 110, 110, - 101, 114, 3, 4, 0, 12, 115, 116, 111, 114, 97, 103, 101, 45, 114, 111, 111, 116, 3, 0, 20, 1, - 114, 1, 5, 105, 110, 110, 101, 114, 3, 4, 0, 17, 97, 99, 99, 111, 117, 110, 116, 45, 99, 111, - 100, 101, 45, 114, 111, 111, 116, 3, 0, 22, 1, 114, 1, 5, 105, 110, 110, 101, 114, 3, 4, 0, 16, - 118, 97, 117, 108, 116, 45, 99, 111, 109, 109, 105, 116, 109, 101, 110, 116, 3, 0, 24, 1, 114, - 1, 5, 105, 110, 110, 101, 114, 1, 4, 0, 7, 110, 111, 116, 101, 45, 105, 100, 3, 0, 26, 1, 64, - 1, 4, 102, 101, 108, 116, 1, 0, 5, 4, 0, 20, 97, 99, 99, 111, 117, 110, 116, 45, 105, 100, 45, - 102, 114, 111, 109, 45, 102, 101, 108, 116, 1, 28, 3, 1, 27, 109, 105, 100, 101, 110, 58, 98, - 97, 115, 101, 47, 99, 111, 114, 101, 45, 116, 121, 112, 101, 115, 64, 49, 46, 48, 46, 48, 5, 0, - 2, 3, 0, 0, 4, 102, 101, 108, 116, 2, 3, 0, 0, 10, 99, 111, 114, 101, 45, 97, 115, 115, 101, - 116, 2, 3, 0, 0, 3, 116, 97, 103, 2, 3, 0, 0, 9, 114, 101, 99, 105, 112, 105, 101, 110, 116, 2, - 3, 0, 0, 10, 97, 99, 99, 111, 117, 110, 116, 45, 105, 100, 2, 3, 0, 0, 5, 110, 111, 110, 99, - 101, 2, 3, 0, 0, 12, 97, 99, 99, 111, 117, 110, 116, 45, 104, 97, 115, 104, 2, 3, 0, 0, 13, - 115, 116, 111, 114, 97, 103, 101, 45, 118, 97, 108, 117, 101, 2, 3, 0, 0, 12, 115, 116, 111, - 114, 97, 103, 101, 45, 114, 111, 111, 116, 2, 3, 0, 0, 17, 97, 99, 99, 111, 117, 110, 116, 45, - 99, 111, 100, 101, 45, 114, 111, 111, 116, 2, 3, 0, 0, 16, 118, 97, 117, 108, 116, 45, 99, 111, - 109, 109, 105, 116, 109, 101, 110, 116, 2, 3, 0, 0, 10, 98, 108, 111, 99, 107, 45, 104, 97, - 115, 104, 2, 3, 0, 0, 4, 119, 111, 114, 100, 2, 3, 0, 0, 7, 110, 111, 116, 101, 45, 105, 100, - 1, 66, 37, 2, 3, 2, 1, 1, 4, 0, 4, 102, 101, 108, 116, 3, 0, 0, 2, 3, 2, 1, 2, 4, 0, 10, 99, - 111, 114, 101, 45, 97, 115, 115, 101, 116, 3, 0, 2, 2, 3, 2, 1, 3, 4, 0, 3, 116, 97, 103, 3, 0, - 4, 2, 3, 2, 1, 4, 4, 0, 9, 114, 101, 99, 105, 112, 105, 101, 110, 116, 3, 0, 6, 2, 3, 2, 1, 5, - 4, 0, 10, 97, 99, 99, 111, 117, 110, 116, 45, 105, 100, 3, 0, 8, 2, 3, 2, 1, 6, 4, 0, 5, 110, - 111, 110, 99, 101, 3, 0, 10, 2, 3, 2, 1, 7, 4, 0, 12, 97, 99, 99, 111, 117, 110, 116, 45, 104, - 97, 115, 104, 3, 0, 12, 2, 3, 2, 1, 8, 4, 0, 13, 115, 116, 111, 114, 97, 103, 101, 45, 118, 97, - 108, 117, 101, 3, 0, 14, 2, 3, 2, 1, 9, 4, 0, 12, 115, 116, 111, 114, 97, 103, 101, 45, 114, - 111, 111, 116, 3, 0, 16, 2, 3, 2, 1, 10, 4, 0, 17, 97, 99, 99, 111, 117, 110, 116, 45, 99, 111, - 100, 101, 45, 114, 111, 111, 116, 3, 0, 18, 2, 3, 2, 1, 11, 4, 0, 16, 118, 97, 117, 108, 116, - 45, 99, 111, 109, 109, 105, 116, 109, 101, 110, 116, 3, 0, 20, 2, 3, 2, 1, 12, 4, 0, 10, 98, - 108, 111, 99, 107, 45, 104, 97, 115, 104, 3, 0, 22, 2, 3, 2, 1, 13, 4, 0, 4, 119, 111, 114, - 100, 3, 0, 24, 2, 3, 2, 1, 14, 4, 0, 7, 110, 111, 116, 101, 45, 105, 100, 3, 0, 26, 1, 64, 0, - 0, 1, 4, 0, 16, 103, 101, 116, 45, 98, 108, 111, 99, 107, 45, 110, 117, 109, 98, 101, 114, 1, - 28, 1, 64, 0, 0, 23, 4, 0, 14, 103, 101, 116, 45, 98, 108, 111, 99, 107, 45, 104, 97, 115, 104, - 1, 29, 1, 64, 0, 0, 25, 4, 0, 20, 103, 101, 116, 45, 105, 110, 112, 117, 116, 45, 110, 111, - 116, 101, 115, 45, 104, 97, 115, 104, 1, 30, 4, 0, 21, 103, 101, 116, 45, 111, 117, 116, 112, - 117, 116, 45, 110, 111, 116, 101, 115, 45, 104, 97, 115, 104, 1, 30, 1, 64, 3, 5, 97, 115, 115, - 101, 116, 3, 3, 116, 97, 103, 5, 9, 114, 101, 99, 105, 112, 105, 101, 110, 116, 7, 0, 27, 4, 0, - 11, 99, 114, 101, 97, 116, 101, 45, 110, 111, 116, 101, 1, 31, 3, 1, 19, 109, 105, 100, 101, - 110, 58, 98, 97, 115, 101, 47, 116, 120, 64, 49, 46, 48, 46, 48, 5, 15, 1, 66, 47, 2, 3, 2, 1, - 1, 4, 0, 4, 102, 101, 108, 116, 3, 0, 0, 2, 3, 2, 1, 2, 4, 0, 10, 99, 111, 114, 101, 45, 97, - 115, 115, 101, 116, 3, 0, 2, 2, 3, 2, 1, 3, 4, 0, 3, 116, 97, 103, 3, 0, 4, 2, 3, 2, 1, 4, 4, - 0, 9, 114, 101, 99, 105, 112, 105, 101, 110, 116, 3, 0, 6, 2, 3, 2, 1, 5, 4, 0, 10, 97, 99, 99, - 111, 117, 110, 116, 45, 105, 100, 3, 0, 8, 2, 3, 2, 1, 6, 4, 0, 5, 110, 111, 110, 99, 101, 3, - 0, 10, 2, 3, 2, 1, 7, 4, 0, 12, 97, 99, 99, 111, 117, 110, 116, 45, 104, 97, 115, 104, 3, 0, - 12, 2, 3, 2, 1, 8, 4, 0, 13, 115, 116, 111, 114, 97, 103, 101, 45, 118, 97, 108, 117, 101, 3, - 0, 14, 2, 3, 2, 1, 9, 4, 0, 12, 115, 116, 111, 114, 97, 103, 101, 45, 114, 111, 111, 116, 3, 0, - 16, 2, 3, 2, 1, 10, 4, 0, 17, 97, 99, 99, 111, 117, 110, 116, 45, 99, 111, 100, 101, 45, 114, - 111, 111, 116, 3, 0, 18, 2, 3, 2, 1, 11, 4, 0, 16, 118, 97, 117, 108, 116, 45, 99, 111, 109, - 109, 105, 116, 109, 101, 110, 116, 3, 0, 20, 1, 64, 0, 0, 9, 4, 0, 6, 103, 101, 116, 45, 105, - 100, 1, 22, 1, 64, 0, 0, 11, 4, 0, 9, 103, 101, 116, 45, 110, 111, 110, 99, 101, 1, 23, 1, 64, - 0, 0, 13, 4, 0, 16, 103, 101, 116, 45, 105, 110, 105, 116, 105, 97, 108, 45, 104, 97, 115, 104, - 1, 24, 4, 0, 16, 103, 101, 116, 45, 99, 117, 114, 114, 101, 110, 116, 45, 104, 97, 115, 104, 1, - 24, 1, 64, 1, 5, 118, 97, 108, 117, 101, 1, 1, 0, 4, 0, 10, 105, 110, 99, 114, 45, 110, 111, - 110, 99, 101, 1, 25, 1, 64, 1, 5, 105, 110, 100, 101, 120, 1, 0, 15, 4, 0, 8, 103, 101, 116, - 45, 105, 116, 101, 109, 1, 26, 1, 111, 2, 17, 15, 1, 64, 2, 5, 105, 110, 100, 101, 120, 1, 5, - 118, 97, 108, 117, 101, 15, 0, 27, 4, 0, 8, 115, 101, 116, 45, 105, 116, 101, 109, 1, 28, 1, - 64, 1, 9, 99, 111, 100, 101, 45, 114, 111, 111, 116, 19, 1, 0, 4, 0, 8, 115, 101, 116, 45, 99, - 111, 100, 101, 1, 29, 1, 64, 1, 10, 97, 99, 99, 111, 117, 110, 116, 45, 105, 100, 9, 0, 1, 4, - 0, 11, 103, 101, 116, 45, 98, 97, 108, 97, 110, 99, 101, 1, 30, 1, 64, 1, 5, 97, 115, 115, 101, - 116, 3, 0, 127, 4, 0, 22, 104, 97, 115, 45, 110, 111, 110, 45, 102, 117, 110, 103, 105, 98, - 108, 101, 45, 97, 115, 115, 101, 116, 1, 31, 1, 64, 1, 5, 97, 115, 115, 101, 116, 3, 0, 3, 4, - 0, 9, 97, 100, 100, 45, 97, 115, 115, 101, 116, 1, 32, 4, 0, 12, 114, 101, 109, 111, 118, 101, - 45, 97, 115, 115, 101, 116, 1, 32, 1, 64, 0, 0, 21, 4, 0, 20, 103, 101, 116, 45, 118, 97, 117, - 108, 116, 45, 99, 111, 109, 109, 105, 116, 109, 101, 110, 116, 1, 33, 3, 1, 24, 109, 105, 100, - 101, 110, 58, 98, 97, 115, 101, 47, 97, 99, 99, 111, 117, 110, 116, 64, 49, 46, 48, 46, 48, 5, - 16, 1, 66, 30, 2, 3, 2, 1, 1, 4, 0, 4, 102, 101, 108, 116, 3, 0, 0, 2, 3, 2, 1, 2, 4, 0, 10, - 99, 111, 114, 101, 45, 97, 115, 115, 101, 116, 3, 0, 2, 2, 3, 2, 1, 3, 4, 0, 3, 116, 97, 103, - 3, 0, 4, 2, 3, 2, 1, 4, 4, 0, 9, 114, 101, 99, 105, 112, 105, 101, 110, 116, 3, 0, 6, 2, 3, 2, - 1, 5, 4, 0, 10, 97, 99, 99, 111, 117, 110, 116, 45, 105, 100, 3, 0, 8, 2, 3, 2, 1, 6, 4, 0, 5, - 110, 111, 110, 99, 101, 3, 0, 10, 2, 3, 2, 1, 7, 4, 0, 12, 97, 99, 99, 111, 117, 110, 116, 45, - 104, 97, 115, 104, 3, 0, 12, 2, 3, 2, 1, 8, 4, 0, 13, 115, 116, 111, 114, 97, 103, 101, 45, - 118, 97, 108, 117, 101, 3, 0, 14, 2, 3, 2, 1, 9, 4, 0, 12, 115, 116, 111, 114, 97, 103, 101, - 45, 114, 111, 111, 116, 3, 0, 16, 2, 3, 2, 1, 10, 4, 0, 17, 97, 99, 99, 111, 117, 110, 116, 45, - 99, 111, 100, 101, 45, 114, 111, 111, 116, 3, 0, 18, 2, 3, 2, 1, 11, 4, 0, 16, 118, 97, 117, - 108, 116, 45, 99, 111, 109, 109, 105, 116, 109, 101, 110, 116, 3, 0, 20, 1, 112, 1, 1, 64, 0, - 0, 22, 4, 0, 10, 103, 101, 116, 45, 105, 110, 112, 117, 116, 115, 1, 23, 1, 112, 3, 1, 64, 0, - 0, 24, 4, 0, 10, 103, 101, 116, 45, 97, 115, 115, 101, 116, 115, 1, 25, 1, 64, 0, 0, 9, 4, 0, - 10, 103, 101, 116, 45, 115, 101, 110, 100, 101, 114, 1, 26, 3, 1, 21, 109, 105, 100, 101, 110, - 58, 98, 97, 115, 101, 47, 110, 111, 116, 101, 64, 49, 46, 48, 46, 48, 5, 17, 1, 66, 10, 2, 3, - 2, 1, 2, 4, 0, 10, 99, 111, 114, 101, 45, 97, 115, 115, 101, 116, 3, 0, 0, 2, 3, 2, 1, 3, 4, 0, - 3, 116, 97, 103, 3, 0, 2, 2, 3, 2, 1, 4, 4, 0, 9, 114, 101, 99, 105, 112, 105, 101, 110, 116, - 3, 0, 4, 1, 64, 1, 10, 99, 111, 114, 101, 45, 97, 115, 115, 101, 116, 1, 1, 0, 4, 0, 13, 114, - 101, 99, 101, 105, 118, 101, 45, 97, 115, 115, 101, 116, 1, 6, 1, 64, 3, 10, 99, 111, 114, 101, - 45, 97, 115, 115, 101, 116, 1, 3, 116, 97, 103, 3, 9, 114, 101, 99, 105, 112, 105, 101, 110, - 116, 5, 1, 0, 4, 0, 10, 115, 101, 110, 100, 45, 97, 115, 115, 101, 116, 1, 7, 3, 1, 37, 109, - 105, 100, 101, 110, 58, 98, 97, 115, 105, 99, 45, 119, 97, 108, 108, 101, 116, 47, 98, 97, 115, - 105, 99, 45, 119, 97, 108, 108, 101, 116, 64, 49, 46, 48, 46, 48, 5, 18, 1, 66, 2, 1, 64, 0, 1, - 0, 4, 0, 11, 110, 111, 116, 101, 45, 115, 99, 114, 105, 112, 116, 1, 0, 4, 1, 28, 109, 105, - 100, 101, 110, 58, 98, 97, 115, 101, 47, 110, 111, 116, 101, 45, 115, 99, 114, 105, 112, 116, - 64, 49, 46, 48, 46, 48, 5, 19, 4, 1, 28, 109, 105, 100, 101, 110, 58, 112, 50, 105, 100, 47, - 110, 111, 116, 101, 115, 45, 119, 111, 114, 108, 100, 64, 49, 46, 48, 46, 48, 4, 0, 11, 17, 1, - 0, 11, 110, 111, 116, 101, 115, 45, 119, 111, 114, 108, 100, 3, 0, 0, 0, 16, 12, 112, 97, 99, - 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, - 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, - 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, - 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48, -]; - -#[inline(never)] -#[doc(hidden)] -#[cfg(target_arch = "wasm32")] -pub fn __link_section() {}