mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-24 02:31:44 +03:00
fix manifest run bug
This commit is contained in:
parent
92f97a4428
commit
f8582c398d
1
examples/token/.gitignore
vendored
1
examples/token/.gitignore
vendored
@ -1,2 +1 @@
|
||||
outputs/
|
||||
build/
|
||||
|
22
examples/token/build/main.aleo
Normal file
22
examples/token/build/main.aleo
Normal 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;
|
10
examples/token/build/program.json
Normal file
10
examples/token/build/program.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"program": "token.aleo",
|
||||
"version": "0.0.0",
|
||||
"description": "",
|
||||
"development": {
|
||||
"private_key": "APrivateKey1zkpBqRv2cwkSiR4hQ3Tb4AZFD3XzdwPqV9QsEykTKBV1YKT",
|
||||
"address": "aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
@ -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::<Network>::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::<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.
|
||||
Ok(manifest)
|
||||
|
Loading…
Reference in New Issue
Block a user