fix manifest run bug

This commit is contained in:
collin 2022-07-20 15:56:48 -07:00
parent 92f97a4428
commit f8582c398d
4 changed files with 48 additions and 5 deletions

View File

@ -1,2 +1 @@
outputs/ outputs/
build/

View File

@ -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;

View File

@ -0,0 +1,10 @@
{
"program": "token.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkpBqRv2cwkSiR4hQ3Tb4AZFD3XzdwPqV9QsEykTKBV1YKT",
"address": "aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7"
},
"license": "MIT"
}

View File

@ -19,6 +19,8 @@ use leo_errors::{CliError, PackageError, Result};
use snarkvm::file::Manifest; use snarkvm::file::Manifest;
use leo_package::build::{BuildDirectory, BUILD_DIRECTORY_NAME}; use leo_package::build::{BuildDirectory, BUILD_DIRECTORY_NAME};
use std::fs::File;
use std::io::Write;
use std::{ use std::{
env::current_dir, env::current_dir,
path::{Path, PathBuf}, path::{Path, PathBuf},
@ -53,7 +55,7 @@ impl Context {
let manifest = Manifest::<Network>::open(&path).map_err(PackageError::failed_to_open_manifest)?; let manifest = Manifest::<Network>::open(&path).map_err(PackageError::failed_to_open_manifest)?;
// Lookup the program id. // 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. // Create the Leo build/ directory if it doesn't exist.
let build_path = path.join(Path::new(BUILD_DIRECTORY_NAME)); 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. // Mirror the program.json file in the Leo build/ directory for Aleo SDK compilation.
if !Manifest::<Network>::exists_at(&build_path) {
Manifest::<Network>::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::<Network>::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. // Get package name from program id.
Ok(manifest) Ok(manifest)