diff --git a/examples/token/.gitignore b/examples/token/.gitignore index b28696155d..17aa483ab4 100644 --- a/examples/token/.gitignore +++ b/examples/token/.gitignore @@ -1,2 +1 @@ outputs/ -build/ diff --git a/examples/token/build/main.aleo b/examples/token/build/main.aleo new file mode 100644 index 0000000000..4f149f202a --- /dev/null +++ b/examples/token/build/main.aleo @@ -0,0 +1,22 @@ +program token.aleo; + +record token: + owner as address.private; + gates as u64.private; + amount as u64.private; + +function mint: + input r0 as address.private; + input r1 as u64.private; + cast r0 0u64 r1 into r2 as token.record; + output r2 as token.record; + +function transfer: + input r0 as token.record; + input r1 as address.private; + input r2 as u64.private; + sub r0.amount r2 into r3; + cast r0.owner r0.gates r3 into r4 as token.record; + cast r1 0u64 r2 into r5 as token.record; + output r4 as token.record; + output r5 as token.record; diff --git a/examples/token/build/program.json b/examples/token/build/program.json new file mode 100644 index 0000000000..fc619581eb --- /dev/null +++ b/examples/token/build/program.json @@ -0,0 +1,10 @@ +{ + "program": "token.aleo", + "version": "0.0.0", + "description": "", + "development": { + "private_key": "APrivateKey1zkpBqRv2cwkSiR4hQ3Tb4AZFD3XzdwPqV9QsEykTKBV1YKT", + "address": "aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7" + }, + "license": "MIT" +} diff --git a/leo/context.rs b/leo/context.rs index b3c164c7ba..3b79cfd0e6 100644 --- a/leo/context.rs +++ b/leo/context.rs @@ -19,6 +19,8 @@ use leo_errors::{CliError, PackageError, Result}; use snarkvm::file::Manifest; use leo_package::build::{BuildDirectory, BUILD_DIRECTORY_NAME}; +use std::fs::File; +use std::io::Write; use std::{ env::current_dir, path::{Path, PathBuf}, @@ -53,7 +55,7 @@ impl Context { let manifest = Manifest::::open(&path).map_err(PackageError::failed_to_open_manifest)?; // Lookup the program id. - let program_id = manifest.program_id(); + // let program_id = manifest.program_id(); // Create the Leo build/ directory if it doesn't exist. let build_path = path.join(Path::new(BUILD_DIRECTORY_NAME)); @@ -62,9 +64,19 @@ impl Context { } // Mirror the program.json file in the Leo build/ directory for Aleo SDK compilation. - if !Manifest::::exists_at(&build_path) { - Manifest::::create(&build_path, program_id).map_err(PackageError::failed_to_open_manifest)?; - } + + // Read the manifest file to string. + let manifest_string = + std::fs::read_to_string(&manifest.path()).map_err(PackageError::failed_to_open_manifest)?; + + // Construct the file path. + let build_manifest_path = build_path.join(Manifest::::file_name()); + + // Write the file. + File::create(&build_manifest_path) + .map_err(PackageError::failed_to_open_manifest)? + .write_all(manifest_string.as_bytes()) + .map_err(PackageError::failed_to_open_manifest)?; // Get package name from program id. Ok(manifest)