Expand description
This crate deals with Leo packages on the file system and network.
The main type is Package
, which deals with Leo packages on the local filesystem.
A Leo package directory is intended to have a structure like this:
.
├── .env
├── program.json
├── build
│ ├── imports
│ │ └── credits.aleo
│ └── main.aleo
├── outputs
│ ├── program.TypeChecking.ast
│ └── program.TypeChecking.json
├── src
│ └── main.leo
└── tests
└── test_something.leo
The file program.json
is a manifest containing the program name, version, description,
and license, together with information about its dependencies.
The file .env
contains definitions for the environment variables NETWORK, PRIVATE_KEY,
and ENDPOINT that may be used when deploying or executing the program.
Such a directory structure, together with a .gitignore
file, may be created
on the file system using Package::initialize
.
let path = Package::initialize("my_package", "path/to/parent", NetworkName::TestnetV0, "http://localhost:3030").unwrap();
tests
is where unit test files may be placed.
Given an existing directory with such a structure, a Package
may be created from it with
Package::from_directory
:
let package = Package::from_directory("path/to/package", "/home/me/.aleo", false).unwrap();
This will read the manifest and env file and keep their data in package.manifest
and package.env
.
It will also process dependencies and store them in topological order in package.programs
. This processing
will involve fetching bytecode from the network for network dependencies.
If the no_cache
option (3rd parameter) is set to true
, the package will not use the dependency cache.
If you want to simply read the manifest and env file without processing dependencies, use
Package::from_directory_no_graph
.
Program
generally doesn’t need to be created directly, as Package
will create Program
s
for the main program and all dependencies. However, if you’d like to fetch bytecode for
a program, you can use Program::fetch
.
Structs§
- Dependency
- Information about a dependency, as represented in the
program.json
manifest. - Env
- Manifest
- Struct representation of program’s
program.json
specification. - Package
- A Leo package.
- Program
- Information about an Aleo program.
Enums§
- Location
- Network
Name - Program
Data - Either the bytecode of an Aleo program (if it was a network dependency) or a path to its source (if it was local).
Constants§
- BUILD_
DIRECTORY - ENV_
FILENAME - IMPORTS_
DIRECTORY - MAIN_
FILENAME - MANIFEST_
FILENAME - OUTPUTS_
DIRECTORY - SOURCE_
DIRECTORY - TESTS_
DIRECTORY - TEST_
PRIVATE_ KEY
Functions§
- fetch_
from_ network - fetch_
from_ network_ plain - fetch_
program_ from_ network - Fetch the given program from the network and return the program as a string.
- filename_
no_ aleo_ extension - filename_
no_ leo_ extension - is_
valid_ aleo_ name - Is this a valid name for an Aleo program?
- verify_
valid_ program