mirror of
https://github.com/AleoHQ/leo.git
synced 2024-09-11 15:05:33 +03:00
add proper error checking
This commit is contained in:
parent
931698fee3
commit
3564389583
22
Cargo.lock
generated
22
Cargo.lock
generated
@ -1454,7 +1454,6 @@ dependencies = [
|
||||
"rand",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"reqwest",
|
||||
"retriever",
|
||||
"rusty-hook",
|
||||
"self_update 0.39.0",
|
||||
@ -1626,16 +1625,6 @@ version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
||||
|
||||
[[package]]
|
||||
name = "mime_guess"
|
||||
version = "2.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
|
||||
dependencies = [
|
||||
"mime",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
@ -2177,7 +2166,6 @@ dependencies = [
|
||||
"js-sys",
|
||||
"log",
|
||||
"mime",
|
||||
"mime_guess",
|
||||
"native-tls",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
@ -2209,6 +2197,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"tempfile",
|
||||
"toml 0.8.6",
|
||||
"ureq",
|
||||
]
|
||||
@ -3810,15 +3799,6 @@ version = "1.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.13"
|
||||
|
@ -128,10 +128,6 @@ default-features = false
|
||||
[dependencies.rand_core]
|
||||
version = "0.6.4"
|
||||
|
||||
[dependencies.reqwest]
|
||||
version = "0.11.22"
|
||||
features = [ "blocking", "json", "multipart" ]
|
||||
|
||||
[dependencies.self_update]
|
||||
version = "0.39.0"
|
||||
features = [ "archive-zip" ]
|
||||
|
@ -73,3 +73,7 @@ When SnarkVM implements better error codes and messages, we can bubble them up.
|
||||
### State
|
||||
|
||||
The errors for the `leo-state` crate. Its error codes will range from 1_000-1_999 and be prefixed with the characters `STA`.
|
||||
|
||||
### Utils
|
||||
|
||||
The errors related to dependency retrieval in the `utils` crate. Its error codes will range from 10_000-10_999 and be prefixed with the characters `DEP`.
|
||||
|
@ -207,5 +207,11 @@ create_messages!(
|
||||
help: None,
|
||||
}
|
||||
|
||||
@formatted
|
||||
failed_to_retrieve_dependencies {
|
||||
args: (error: impl Display),
|
||||
msg: format!("Failed to retrieve dependencies. {error}"),
|
||||
help: None,
|
||||
}
|
||||
|
||||
);
|
||||
|
@ -134,42 +134,10 @@ pub fn run_with_args(cli: CLI) -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn build_test() -> Result<()> {
|
||||
use leo_span::symbol::create_session_if_not_set_then;
|
||||
const BUILD_DIRECTORY: &str = "utils/tmp/project";
|
||||
|
||||
let cli = CLI {
|
||||
debug: false,
|
||||
quiet: false,
|
||||
command: Commands::Build { command: Build { options: Default::default() } },
|
||||
path: Some(PathBuf::from(BUILD_DIRECTORY)),
|
||||
};
|
||||
create_session_if_not_set_then(|_| {
|
||||
run_with_args(cli).expect("Failed to run build command");
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
#[test]
|
||||
pub fn build_super_simple_test() -> Result<()> {
|
||||
use leo_span::symbol::create_session_if_not_set_then;
|
||||
const BUILD_DIRECTORY: &str = "utils/tmp/super_simple";
|
||||
|
||||
let cli = CLI {
|
||||
debug: false,
|
||||
quiet: false,
|
||||
command: Commands::Build { command: Build { options: Default::default() } },
|
||||
path: Some(PathBuf::from(BUILD_DIRECTORY)),
|
||||
};
|
||||
create_session_if_not_set_then(|_| {
|
||||
run_with_args(cli).expect("Failed to run build command");
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn build_nested_test() -> Result<()> {
|
||||
use leo_span::symbol::create_session_if_not_set_then;
|
||||
use std::env;
|
||||
const BUILD_DIRECTORY: &str = "utils/tmp/nested";
|
||||
|
||||
let cli = CLI {
|
||||
@ -178,8 +146,17 @@ pub fn build_nested_test() -> Result<()> {
|
||||
command: Commands::Build { command: Build { options: Default::default() } },
|
||||
path: Some(PathBuf::from(BUILD_DIRECTORY)),
|
||||
};
|
||||
|
||||
// Set $HOME to tmp directory so that tests do not modify users real home directory
|
||||
let original_home = env::var("HOME").unwrap();
|
||||
env::set_var("HOME", "utils/tmp");
|
||||
|
||||
create_session_if_not_set_then(|_| {
|
||||
run_with_args(cli).expect("Failed to run build command");
|
||||
});
|
||||
|
||||
// Reset $HOME
|
||||
env::set_var("HOME", original_home);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -204,10 +204,15 @@ fn compile_leo_file(
|
||||
});
|
||||
|
||||
// Retrieve dependencies from `program.json`
|
||||
let mut retriever = Retriever::new(package_path);
|
||||
let mut retriever = Retriever::new(package_path)
|
||||
.map_err(|err| CliError::failed_to_retrieve_dependencies(err, Default::default()))?;
|
||||
|
||||
// Only retrieve dependencies for main leo program
|
||||
let stubs: IndexMap<Symbol, Stub> = if is_import { IndexMap::new() } else { retriever.retrieve() };
|
||||
let stubs: IndexMap<Symbol, Stub> = if is_import {
|
||||
IndexMap::new()
|
||||
} else {
|
||||
retriever.retrieve().map_err(|err| CliError::failed_to_retrieve_dependencies(err, Default::default()))?
|
||||
};
|
||||
|
||||
// Create a new instance of the Leo compiler.
|
||||
let mut compiler = Compiler::new(
|
||||
|
@ -5,15 +5,44 @@ edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies.serde]
|
||||
version = "1.0"
|
||||
features = [ "derive"]
|
||||
|
||||
[dependencies.serde_json]
|
||||
version = "1.0"
|
||||
|
||||
[dependencies.leo-errors]
|
||||
path = "../../errors"
|
||||
version = "=1.10.0"
|
||||
|
||||
[dependencies.indexmap]
|
||||
version = "1.9"
|
||||
features = [ "serde-1" ]
|
||||
|
||||
[dependencies.leo-ast]
|
||||
version = "1.9.4"
|
||||
path = "../../compiler/ast"
|
||||
|
||||
[dependencies.toml]
|
||||
version = "0.8.6"
|
||||
|
||||
[dependencies.disassembler]
|
||||
version = "0.1.0"
|
||||
path = "../disassembler"
|
||||
|
||||
[dependencies.sha2]
|
||||
version = "0.10.8"
|
||||
|
||||
[dependencies.leo-span]
|
||||
version = "1.9.4"
|
||||
path = "../../compiler/span"
|
||||
|
||||
[dependencies.ureq]
|
||||
version = "2.7"
|
||||
|
||||
[dependencies.leo-passes]
|
||||
version = "1.9.4"
|
||||
path = "../../compiler/passes"
|
||||
[dependencies]
|
||||
serde = { version = "1.0.188", features = ["derive"] }
|
||||
serde_json = "1.0.107"
|
||||
leo-errors = {version = "1.9.4", path = "../../errors"}
|
||||
indexmap = "1.9"
|
||||
leo-ast = {version = "1.9.4", path = "../../compiler/ast"}
|
||||
toml = "0.8.6"
|
||||
disassembler = {version = "0.1.0", path = "../disassembler"}
|
||||
sha2 = { version = "0.10.8", features = [] }
|
||||
leo-span = {version = "1.9.4", path = "../../compiler/span"}
|
||||
ureq = "2.7"
|
||||
leo-passes = {version = "1.9.4", path = "../../compiler/passes"}
|
||||
tempfile = "3.8.1"
|
@ -17,11 +17,13 @@
|
||||
use disassembler::disassemble_from_str;
|
||||
use indexmap::{IndexMap, IndexSet};
|
||||
use leo_ast::Stub;
|
||||
use leo_errors::UtilError;
|
||||
use leo_passes::{common::DiGraph, DiGraphError};
|
||||
use leo_span::Symbol;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::{
|
||||
env,
|
||||
fmt,
|
||||
fs,
|
||||
fs::File,
|
||||
@ -30,7 +32,6 @@ use std::{
|
||||
};
|
||||
|
||||
const ALEO_EXPLORER_URL: &str = "https://api.explorer.aleo.org/v1";
|
||||
const ALEO_REGISTRY_DIRECTORY: &str = "../tmp/.aleo";
|
||||
|
||||
// Struct representation of program's `program.json` specification
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@ -107,20 +108,21 @@ struct LockFileEntry {
|
||||
|
||||
impl Retriever {
|
||||
// Initialize a new Retriever
|
||||
pub fn new(path: &Path) -> Self {
|
||||
pub fn new(path: &Path) -> Result<Self, UtilError> {
|
||||
let lock_path = path.to_path_buf().join("leo.lock");
|
||||
if !lock_path.exists() {
|
||||
std::fs::create_dir_all(path).expect("Failed to project directory.");
|
||||
File::create(lock_path.clone()).expect("Failed to create `leo.lock`");
|
||||
std::fs::create_dir_all(path).map_err(|err| UtilError::util_file_io_error(err, Default::default()))?; // TODO: How to get rid of requirement for span?
|
||||
File::create(lock_path.clone()).map_err(|err| UtilError::util_file_io_error(err, Default::default()))?;
|
||||
}
|
||||
|
||||
let mut file = File::open(lock_path).expect("Failed to open `leo.lock`.");
|
||||
let mut file = File::open(lock_path).map_err(|err| UtilError::util_file_io_error(err, Default::default()))?;
|
||||
|
||||
// Read `leo.lock` into a string, and deserialize from TOML to a `LockFile` struct.
|
||||
let mut lock_file_contents = String::new();
|
||||
file.read_to_string(&mut lock_file_contents).expect("Failed to read `leo.lock`.");
|
||||
let parsed_lock_file: IndexMap<String, Vec<LockFileEntry>> =
|
||||
toml::from_str(&lock_file_contents).expect("Failed to parse `leo.lock`.");
|
||||
file.read_to_string(&mut lock_file_contents)
|
||||
.map_err(|err| UtilError::util_file_io_error(err, Default::default()))?;
|
||||
let parsed_lock_file: IndexMap<String, Vec<LockFileEntry>> = toml::from_str(&lock_file_contents)
|
||||
.map_err(|err| UtilError::toml_serizalization_error(err, Default::default()))?;
|
||||
|
||||
// Construct a mapping of all programs in the `leo.lock` file to their specification.
|
||||
let mut lock_file_map = IndexMap::new();
|
||||
@ -153,28 +155,29 @@ impl Retriever {
|
||||
}
|
||||
|
||||
// Open `program.json` which is located at `package_path/program.json`.
|
||||
let mut file = File::open(path.join("program.json")).expect("Failed to open `program.json`.");
|
||||
let mut file = File::open(path.join("program.json"))
|
||||
.map_err(|err| UtilError::util_file_io_error(err, Default::default()))?;
|
||||
|
||||
// Read the file content
|
||||
let mut content = String::new();
|
||||
file.read_to_string(&mut content).expect("Failed to read `program.json`.");
|
||||
file.read_to_string(&mut content).map_err(|err| UtilError::util_file_io_error(err, Default::default()))?;
|
||||
|
||||
// Deserialize the content into Program
|
||||
let program_data: ProgramSpecification =
|
||||
serde_json::from_str(&content).expect("Failed to deserialize `program.json`.");
|
||||
let program_data: ProgramSpecification = serde_json::from_str(&content)
|
||||
.map_err(|err| UtilError::json_serialization_error(err, Default::default()))?;
|
||||
|
||||
Self {
|
||||
Ok(Self {
|
||||
programs: program_data.dependencies,
|
||||
path: path.to_path_buf(),
|
||||
stubs: IndexMap::new(),
|
||||
lock_file: lock_file_map,
|
||||
explored: IndexSet::new(),
|
||||
dependency_graph: DiGraph::new(IndexSet::new()),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Retrieve all dependencies for a program
|
||||
pub fn retrieve(&mut self) -> IndexMap<Symbol, Stub> {
|
||||
pub fn retrieve(&mut self) -> Result<IndexMap<Symbol, Stub>, UtilError> {
|
||||
let mut programs_to_retrieve = self.programs.clone();
|
||||
|
||||
while !programs_to_retrieve.is_empty() {
|
||||
@ -186,14 +189,14 @@ impl Retriever {
|
||||
self.path.clone(),
|
||||
program.name.clone(),
|
||||
program.network.clone(),
|
||||
)),
|
||||
)?),
|
||||
Location::Git => panic!("Location::Git is not supported yet"),
|
||||
Location::Local => panic!("Location::Local is not supported yet"),
|
||||
}
|
||||
|
||||
// Mark as visited
|
||||
if !self.explored.insert(program.clone()) {
|
||||
panic!("Should not ever explore same dependency twice.")
|
||||
Err(UtilError::circular_dependency_error(Default::default()))?;
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,11 +212,7 @@ impl Retriever {
|
||||
|
||||
// Add stub to list of stubs
|
||||
if let Some(existing) = self.stubs.insert(stub.stub_id.name.name, stub.clone()) {
|
||||
panic!(
|
||||
"Should never be creating two stubs from the same program name. Existing: {:?}, New: {:?}",
|
||||
existing,
|
||||
stub.clone()
|
||||
)
|
||||
Err(UtilError::duplicate_dependency_name_error(existing.stub_id.name.name, Default::default()))?;
|
||||
}
|
||||
|
||||
// Update lock file
|
||||
@ -226,16 +225,16 @@ impl Retriever {
|
||||
// Check for dependency cycles
|
||||
match self.dependency_graph.post_order() {
|
||||
Ok(_) => (),
|
||||
Err(DiGraphError::CycleDetected(cycle)) => panic!("Dependency cycle detected: {:?}", cycle),
|
||||
Err(DiGraphError::CycleDetected(_)) => Err(UtilError::circular_dependency_error(Default::default()))?,
|
||||
}
|
||||
|
||||
// Write the finalized dependency information to `leo.lock`
|
||||
self.write_lock_file();
|
||||
self.stubs.clone()
|
||||
self.write_lock_file()?;
|
||||
Ok(self.stubs.clone())
|
||||
}
|
||||
|
||||
// Write lock file
|
||||
fn write_lock_file(&self) {
|
||||
fn write_lock_file(&self) -> Result<(), UtilError> {
|
||||
// Create struct representation of lock file
|
||||
let mut lock_file: IndexMap<String, Vec<LockFileEntry>> = IndexMap::new();
|
||||
let packages: Vec<LockFileEntry> = self
|
||||
@ -252,43 +251,55 @@ impl Retriever {
|
||||
lock_file.insert("package".to_string(), packages);
|
||||
|
||||
// Serialize the data to a TOML string
|
||||
let toml_str = toml::to_string(&lock_file).expect("Failed to serialize lock file.");
|
||||
let toml_str =
|
||||
toml::to_string(&lock_file).map_err(|err| UtilError::toml_serizalization_error(err, Default::default()))?;
|
||||
|
||||
// Write the TOML string to a file
|
||||
std::fs::write(self.path.join("leo.lock"), toml_str).expect("Failed to write file to leo.lock");
|
||||
std::fs::write(self.path.join("leo.lock"), toml_str)
|
||||
.map_err(|err| UtilError::util_file_io_error(err, Default::default()))?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve from network
|
||||
fn retrieve_from_network(project_path: PathBuf, name: String, network: Network) -> (Stub, Program, LockContents) {
|
||||
fn retrieve_from_network(
|
||||
project_path: PathBuf,
|
||||
name: String,
|
||||
network: Network,
|
||||
) -> Result<(Stub, Program, LockContents), UtilError> {
|
||||
// Check if the file is already cached in `~/.aleo/registry/{network}/{program}`
|
||||
let path_str = &format!("{}/{}/{}", ALEO_REGISTRY_DIRECTORY, network, name);
|
||||
let registry_directory = &format!("{}/.aleo/registry/{}", env::var("HOME").unwrap(), network);
|
||||
let path_str = &format!("{}/{}", registry_directory, name);
|
||||
let path = Path::new(&path_str);
|
||||
dbg!(path);
|
||||
let mut file_str: String;
|
||||
if !path.exists() {
|
||||
// Create directories along the way if they don't exist
|
||||
std::fs::create_dir_all(Path::new(&format!("{}/{}", ALEO_REGISTRY_DIRECTORY, network)))
|
||||
.expect("Failed to create directory `~/.aleo/registry/{network}`.");
|
||||
std::fs::create_dir_all(Path::new(®istry_directory))
|
||||
.map_err(|err| UtilError::util_file_io_error(err, Default::default()))?;
|
||||
|
||||
// TODO: Refactor this so that we do the match statement here (instead of in `Retriever::retrieve()`)
|
||||
// Fetch from network
|
||||
println!("Retrieving {} from {:?}.", name.clone(), network.clone());
|
||||
file_str = fetch_from_network(name.clone(), network.clone());
|
||||
file_str = fetch_from_network(name.clone(), network.clone())?;
|
||||
file_str = file_str.replace("\\n", "\n").replace('\"', "");
|
||||
println!("Successfully retrieved {} from {:?}!", name, network);
|
||||
|
||||
// Write file to cache
|
||||
std::fs::write(path, file_str.clone().replace("\\n", "\n")).expect("Failed to write file to ~/.aleo");
|
||||
std::fs::write(path, file_str.clone().replace("\\n", "\n"))
|
||||
.map_err(|err| UtilError::util_file_io_error(err, Default::default()))?;
|
||||
} else {
|
||||
// Read file from cache
|
||||
file_str = fs::read_to_string(path).expect("Failed to read file.");
|
||||
file_str = fs::read_to_string(path).map_err(|err| UtilError::util_file_io_error(err, Default::default()))?;
|
||||
}
|
||||
|
||||
// Copy the file into build directory. We can assume build directory exists because of its initialization in `leo/cli/commands/build.rs`.
|
||||
let import_dir = project_path.join("build/imports");
|
||||
let import_dir_path = import_dir.as_path();
|
||||
std::fs::create_dir_all(import_dir_path).expect("Failed to create directory `~/.aleo/registry/{network}`.");
|
||||
std::fs::create_dir_all(import_dir_path).map_err(|err| UtilError::util_file_io_error(err, Default::default()))?;
|
||||
let build_location = PathBuf::from(import_dir_path).join(name.clone());
|
||||
std::fs::write(build_location, file_str.clone()).expect("Failed to write file to build/imports.");
|
||||
std::fs::write(build_location, file_str.clone())
|
||||
.map_err(|err| UtilError::util_file_io_error(err, Default::default()))?;
|
||||
|
||||
// Hash the file contents
|
||||
let mut hasher = Sha256::new();
|
||||
@ -296,10 +307,10 @@ fn retrieve_from_network(project_path: PathBuf, name: String, network: Network)
|
||||
let hash = hasher.finalize();
|
||||
|
||||
// Disassemble into Stub
|
||||
let stub: Stub = disassemble_from_str(file_str);
|
||||
let stub: Stub = disassemble_from_str(file_str)?;
|
||||
|
||||
// Create entry for leo.lock
|
||||
(
|
||||
Ok((
|
||||
stub.clone(),
|
||||
Program { name: name.clone(), location: Location::Network, network: network.clone() },
|
||||
LockContents {
|
||||
@ -315,13 +326,17 @@ fn retrieve_from_network(project_path: PathBuf, name: String, network: Network)
|
||||
.collect(),
|
||||
checksum: format!("{hash:x}"),
|
||||
},
|
||||
)
|
||||
))
|
||||
}
|
||||
|
||||
fn fetch_from_network(program: String, network: Network) -> String {
|
||||
fn fetch_from_network(program: String, network: Network) -> Result<String, UtilError> {
|
||||
let url = format!("{}/{}/program/{}", ALEO_EXPLORER_URL, network.clone(), program);
|
||||
let response = ureq::get(&url.clone()).call().unwrap();
|
||||
if response.status() == 200 { response.into_string().unwrap() } else { panic!("Failed to fetch from {url}") }
|
||||
if response.status() == 200 {
|
||||
Ok(response.into_string().unwrap())
|
||||
} else {
|
||||
Err(UtilError::network_error(url, response.status(), Default::default()))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -330,43 +345,20 @@ mod tests {
|
||||
use leo_span::symbol::create_session_if_not_set_then;
|
||||
|
||||
#[test]
|
||||
fn basic_test() {
|
||||
const BUILD_DIRECTORY: &str = "../tmp/project";
|
||||
create_session_if_not_set_then(|_| {
|
||||
let build_dir = PathBuf::from(BUILD_DIRECTORY);
|
||||
let mut retriever = Retriever::new(&build_dir);
|
||||
retriever.retrieve();
|
||||
});
|
||||
}
|
||||
fn temp_dir_test() {
|
||||
// Set $HOME to tmp directory so that tests do not modify users real home directory
|
||||
let original_home = env::var("HOME").unwrap();
|
||||
env::set_var("HOME", "../tmp");
|
||||
|
||||
#[test]
|
||||
fn simple_test() {
|
||||
const BUILD_DIRECTORY: &str = "../tmp/simple";
|
||||
create_session_if_not_set_then(|_| {
|
||||
let build_dir = PathBuf::from(BUILD_DIRECTORY);
|
||||
let mut retriever = Retriever::new(&build_dir);
|
||||
retriever.retrieve();
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn super_simple_test() {
|
||||
dbg!(std::env::current_dir().unwrap());
|
||||
const BUILD_DIRECTORY: &str = "../tmp/super_simple";
|
||||
create_session_if_not_set_then(|_| {
|
||||
let build_dir = PathBuf::from(BUILD_DIRECTORY);
|
||||
let mut retriever = Retriever::new(&build_dir);
|
||||
retriever.retrieve();
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nested_test() {
|
||||
dbg!(std::env::current_dir().unwrap());
|
||||
// Test pulling nested dependencies from network
|
||||
const BUILD_DIRECTORY: &str = "../tmp/nested";
|
||||
create_session_if_not_set_then(|_| {
|
||||
let build_dir = PathBuf::from(BUILD_DIRECTORY);
|
||||
let mut retriever = Retriever::new(&build_dir);
|
||||
retriever.retrieve();
|
||||
let mut retriever = Retriever::new(&build_dir).expect("Failed to build retriever");
|
||||
retriever.retrieve().expect("failed to retrieve");
|
||||
});
|
||||
|
||||
// Reset $HOME
|
||||
env::set_var("HOME", original_home);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
import nested_example_layer_2.aleo;
|
||||
import nested_example_layer_1.aleo;
|
||||
|
||||
program nested_example_layer_0.aleo;
|
||||
|
||||
function main:
|
||||
input r0 as u32.public;
|
||||
input r1 as u32.private;
|
||||
call nested_example_layer_1.aleo/external_function r0 r1 into r2;
|
||||
output r2 as u32.private;
|
@ -0,0 +1,9 @@
|
||||
import nested_example_layer_2.aleo;
|
||||
|
||||
program nested_example_layer_1.aleo;
|
||||
|
||||
function external_function:
|
||||
input r0 as u32.public;
|
||||
input r1 as u32.private;
|
||||
call nested_example_layer_2.aleo/external_nested_function r0 r1 into r2;
|
||||
output r2 as u32.private;
|
@ -0,0 +1,7 @@
|
||||
program nested_example_layer_2.aleo;
|
||||
|
||||
function external_nested_function:
|
||||
input r0 as u32.public;
|
||||
input r1 as u32.private;
|
||||
add r0 r1 into r2;
|
||||
output r2 as u32.private;
|
@ -1,371 +0,0 @@
|
||||
import credits.aleo;
|
||||
|
||||
program artgo_aigc_v1_3.aleo;
|
||||
|
||||
struct Field2:
|
||||
first as field;
|
||||
second as field;
|
||||
|
||||
struct NftHash:
|
||||
minter as address;
|
||||
prompt as Field2;
|
||||
nonce as field;
|
||||
|
||||
struct NftInfo:
|
||||
holder as address;
|
||||
minter as address;
|
||||
hash as field;
|
||||
uri as Field2;
|
||||
|
||||
struct Order:
|
||||
holder as address;
|
||||
nft_id as field;
|
||||
order_type as u8;
|
||||
amount as u64;
|
||||
status as u8;
|
||||
deadline as field;
|
||||
|
||||
struct Bid:
|
||||
bidder as address;
|
||||
nft_id as field;
|
||||
amount as u64;
|
||||
|
||||
record BidRecord:
|
||||
owner as address.private;
|
||||
bid_type as u8.private;
|
||||
bidder as address.private;
|
||||
nft_id as field.private;
|
||||
amount as u64.private;
|
||||
|
||||
record Nft:
|
||||
owner as address.private;
|
||||
minter as address.private;
|
||||
prompt as Field2.private;
|
||||
nonce as field.private;
|
||||
uri as Field2.private;
|
||||
|
||||
mapping nfts:
|
||||
key as field.public;
|
||||
value as NftInfo.public;
|
||||
|
||||
mapping tokenId:
|
||||
key as boolean.public;
|
||||
value as field.public;
|
||||
|
||||
mapping admin:
|
||||
key as boolean.public;
|
||||
value as address.public;
|
||||
|
||||
mapping fees:
|
||||
key as boolean.public;
|
||||
value as u64.public;
|
||||
|
||||
mapping orders:
|
||||
key as field.public;
|
||||
value as Order.public;
|
||||
|
||||
mapping bids:
|
||||
key as field.public;
|
||||
value as Bid.public;
|
||||
|
||||
function mint_nft:
|
||||
input r0 as Field2.private;
|
||||
input r1 as Field2.public;
|
||||
input r2 as field.public;
|
||||
cast self.caller r0 r2 into r3 as NftHash;
|
||||
hash.bhp256 r3 into r4 as field;
|
||||
cast self.caller self.caller r0 r2 r1 into r5 as Nft.record;
|
||||
async mint_nft self.caller r4 r1 into r6;
|
||||
output r5 as Nft.record;
|
||||
output r6 as artgo_aigc_v1_3.aleo/mint_nft.future;
|
||||
|
||||
finalize mint_nft:
|
||||
input r0 as address.public;
|
||||
input r1 as field.public;
|
||||
input r2 as Field2.public;
|
||||
get.or_use tokenId[true] 1field into r3;
|
||||
add r3 1field into r4;
|
||||
set r4 into tokenId[true];
|
||||
cast r0 r0 r1 r2 into r5 as NftInfo;
|
||||
set r5 into nfts[r3];
|
||||
|
||||
function transfer_private_nft:
|
||||
input r0 as field.private;
|
||||
input r1 as Nft.record;
|
||||
input r2 as address.private;
|
||||
is.eq r1.owner self.caller into r3;
|
||||
assert.eq r3 true ;
|
||||
cast r1.minter r1.prompt r1.nonce into r4 as NftHash;
|
||||
hash.bhp256 r4 into r5 as field;
|
||||
cast r2 r1.minter r1.prompt r1.nonce r1.uri into r6 as Nft.record;
|
||||
async transfer_private_nft r0 r5 r1.uri r2 into r7;
|
||||
output r6 as Nft.record;
|
||||
output r7 as artgo_aigc_v1_3.aleo/transfer_private_nft.future;
|
||||
|
||||
finalize transfer_private_nft:
|
||||
input r0 as field.public;
|
||||
input r1 as field.public;
|
||||
input r2 as Field2.public;
|
||||
input r3 as address.public;
|
||||
get nfts[r0] into r4;
|
||||
assert.eq r4.hash r1 ;
|
||||
assert.eq r4.uri r2 ;
|
||||
cast r3 r4.minter r4.hash r4.uri into r5 as NftInfo;
|
||||
set r5 into nfts[r0];
|
||||
|
||||
function place_order:
|
||||
input r0 as field.public;
|
||||
input r1 as Nft.record;
|
||||
input r2 as u8.public;
|
||||
input r3 as u64.public;
|
||||
input r4 as field.public;
|
||||
input r5 as address.public;
|
||||
is.eq r2 1u8 into r6;
|
||||
assert.eq r6 true ;
|
||||
gt r3 0u64 into r7;
|
||||
lte r3 18446744073709551615u64 into r8;
|
||||
and r7 r8 into r9;
|
||||
assert.eq r9 true ;
|
||||
cast r1.minter r1.prompt r1.nonce into r10 as NftHash;
|
||||
hash.bhp256 r10 into r11 as field;
|
||||
cast self.caller r0 r2 r3 1u8 0field into r12 as Order;
|
||||
cast r5 r1.minter r1.prompt r1.nonce r1.uri into r13 as Nft.record;
|
||||
async place_order r5 r0 r11 r1.uri r12 into r14;
|
||||
output r13 as Nft.record;
|
||||
output r14 as artgo_aigc_v1_3.aleo/place_order.future;
|
||||
|
||||
finalize place_order:
|
||||
input r0 as address.public;
|
||||
input r1 as field.public;
|
||||
input r2 as field.public;
|
||||
input r3 as Field2.public;
|
||||
input r4 as Order.public;
|
||||
contains admin[true] into r5;
|
||||
assert.eq r5 true ;
|
||||
get admin[true] into r6;
|
||||
assert.eq r6 r0 ;
|
||||
get nfts[r1] into r7;
|
||||
assert.eq r7.hash r2 ;
|
||||
assert.eq r7.uri r3 ;
|
||||
contains fees[true] into r8;
|
||||
assert.eq r8 true ;
|
||||
get fees[true] into r9;
|
||||
gte r4.amount r9 into r10;
|
||||
assert.eq r10 true ;
|
||||
contains orders[r1] into r11;
|
||||
not r11 into r12;
|
||||
assert.eq r12 true ;
|
||||
set r4 into orders[r1];
|
||||
|
||||
function update_order:
|
||||
input r0 as field.public;
|
||||
input r1 as u64.public;
|
||||
gt r1 0u64 into r2;
|
||||
lte r1 18446744073709551615u64 into r3;
|
||||
and r2 r3 into r4;
|
||||
assert.eq r4 true ;
|
||||
async update_order self.caller r0 r1 into r5;
|
||||
output r5 as artgo_aigc_v1_3.aleo/update_order.future;
|
||||
|
||||
finalize update_order:
|
||||
input r0 as address.public;
|
||||
input r1 as field.public;
|
||||
input r2 as u64.public;
|
||||
get orders[r1] into r3;
|
||||
is.eq r3.status 1u8 into r4;
|
||||
assert.eq r4 true ;
|
||||
is.eq r0 r3.holder into r5;
|
||||
assert.eq r5 true ;
|
||||
contains fees[true] into r6;
|
||||
assert.eq r6 true ;
|
||||
get fees[true] into r7;
|
||||
gte r2 r7 into r8;
|
||||
assert.eq r8 true ;
|
||||
cast r3.holder r3.nft_id r3.order_type r2 r3.status r3.deadline into r9 as Order;
|
||||
set r9 into orders[r1];
|
||||
|
||||
function cancel_order:
|
||||
input r0 as u64.public;
|
||||
input r1 as field.public;
|
||||
input r2 as address.public;
|
||||
cast r2 2u8 self.caller r1 0u64 into r3 as BidRecord.record;
|
||||
call credits.aleo/transfer_public r2 r0 into r4;
|
||||
async cancel_order r4 self.caller r1 r0 r2 into r5;
|
||||
output r3 as BidRecord.record;
|
||||
output r5 as artgo_aigc_v1_3.aleo/cancel_order.future;
|
||||
|
||||
finalize cancel_order:
|
||||
input r0 as credits.aleo/transfer_public.future;
|
||||
input r1 as address.public;
|
||||
input r2 as field.public;
|
||||
input r3 as u64.public;
|
||||
input r4 as address.public;
|
||||
await r0;
|
||||
contains fees[true] into r5;
|
||||
assert.eq r5 true ;
|
||||
get fees[true] into r6;
|
||||
assert.eq r6 r3 ;
|
||||
get orders[r2] into r7;
|
||||
is.eq r7.status 1u8 into r8;
|
||||
assert.eq r8 true ;
|
||||
is.eq r1 r7.holder into r9;
|
||||
assert.eq r9 true ;
|
||||
contains admin[true] into r10;
|
||||
assert.eq r10 true ;
|
||||
get admin[true] into r11;
|
||||
assert.eq r11 r4 ;
|
||||
cast r7.holder r7.nft_id r7.order_type r7.amount 2u8 r7.deadline into r12 as Order;
|
||||
set r12 into orders[r2];
|
||||
|
||||
function handle_cancel_order:
|
||||
input r0 as field.public;
|
||||
input r1 as Nft.record;
|
||||
input r2 as address.public;
|
||||
cast r2 r1.minter r1.prompt r1.nonce r1.uri into r3 as Nft.record;
|
||||
cast r1.minter r1.prompt r1.nonce into r4 as NftHash;
|
||||
hash.bhp256 r4 into r5 as field;
|
||||
async handle_cancel_order r0 r5 r1.uri r2 self.caller into r6;
|
||||
output r3 as Nft.record;
|
||||
output r6 as artgo_aigc_v1_3.aleo/handle_cancel_order.future;
|
||||
|
||||
finalize handle_cancel_order:
|
||||
input r0 as field.public;
|
||||
input r1 as field.public;
|
||||
input r2 as Field2.public;
|
||||
input r3 as address.public;
|
||||
input r4 as address.public;
|
||||
contains admin[true] into r5;
|
||||
assert.eq r5 true ;
|
||||
get admin[true] into r6;
|
||||
assert.eq r6 r4 ;
|
||||
get nfts[r0] into r7;
|
||||
assert.eq r7.hash r1 ;
|
||||
assert.eq r7.uri r2 ;
|
||||
get orders[r0] into r8;
|
||||
is.eq r8.status 2u8 into r9;
|
||||
assert.eq r9 true ;
|
||||
is.eq r3 r8.holder into r10;
|
||||
assert.eq r10 true ;
|
||||
remove bids[r0];
|
||||
remove orders[r0];
|
||||
|
||||
function bid_order:
|
||||
input r0 as field.public;
|
||||
input r1 as u64.public;
|
||||
input r2 as address.public;
|
||||
gt r1 0u64 into r3;
|
||||
lte r1 18446744073709551615u64 into r4;
|
||||
and r3 r4 into r5;
|
||||
assert.eq r5 true ;
|
||||
cast r2 1u8 self.caller r0 r1 into r6 as BidRecord.record;
|
||||
call credits.aleo/transfer_public r2 r1 into r7;
|
||||
async bid_order r7 self.caller r0 r1 r2 into r8;
|
||||
output r6 as BidRecord.record;
|
||||
output r8 as artgo_aigc_v1_3.aleo/bid_order.future;
|
||||
|
||||
finalize bid_order:
|
||||
input r0 as credits.aleo/transfer_public.future;
|
||||
input r1 as address.public;
|
||||
input r2 as field.public;
|
||||
input r3 as u64.public;
|
||||
input r4 as address.public;
|
||||
await r0;
|
||||
contains admin[true] into r5;
|
||||
assert.eq r5 true ;
|
||||
get admin[true] into r6;
|
||||
assert.eq r6 r4 ;
|
||||
cast r1 r2 r3 into r7 as Bid;
|
||||
set r7 into bids[r2];
|
||||
contains orders[r2] into r8;
|
||||
assert.eq r8 true ;
|
||||
get orders[r2] into r9;
|
||||
is.eq r9.status 1u8 into r10;
|
||||
assert.eq r10 true ;
|
||||
gte r3 r9.amount into r11;
|
||||
assert.eq r11 true ;
|
||||
cast r9.holder r9.nft_id r9.order_type r9.amount 3u8 0field into r12 as Order;
|
||||
set r12 into orders[r2];
|
||||
|
||||
function finish_order:
|
||||
input r0 as field.public;
|
||||
input r1 as Nft.record;
|
||||
input r2 as address.public;
|
||||
input r3 as u64.public;
|
||||
input r4 as address.public;
|
||||
input r5 as u64.public;
|
||||
input r6 as address.public;
|
||||
gte r5 r3 into r7;
|
||||
lte r5 18446744073709551615u64 into r8;
|
||||
and r7 r8 into r9;
|
||||
assert.eq r9 true ;
|
||||
assert.eq self.caller r6 ;
|
||||
sub r5 r3 into r10;
|
||||
call credits.aleo/transfer_public r2 r10 into r11;
|
||||
cast r1.minter r1.prompt r1.nonce into r12 as NftHash;
|
||||
hash.bhp256 r12 into r13 as field;
|
||||
cast r4 r1.minter r1.prompt r1.nonce r1.uri into r14 as Nft.record;
|
||||
async finish_order r11 r0 r2 r13 r1.uri r4 r5 r3 r6 into r15;
|
||||
output r14 as Nft.record;
|
||||
output r15 as artgo_aigc_v1_3.aleo/finish_order.future;
|
||||
|
||||
finalize finish_order:
|
||||
input r0 as credits.aleo/transfer_public.future;
|
||||
input r1 as field.public;
|
||||
input r2 as address.public;
|
||||
input r3 as field.public;
|
||||
input r4 as Field2.public;
|
||||
input r5 as address.public;
|
||||
input r6 as u64.public;
|
||||
input r7 as u64.public;
|
||||
input r8 as address.public;
|
||||
await r0;
|
||||
contains admin[true] into r9;
|
||||
assert.eq r9 true ;
|
||||
get admin[true] into r10;
|
||||
assert.eq r10 r8 ;
|
||||
contains fees[true] into r11;
|
||||
assert.eq r11 true ;
|
||||
get fees[true] into r12;
|
||||
assert.eq r12 r7 ;
|
||||
contains orders[r1] into r13;
|
||||
assert.eq r13 true ;
|
||||
get orders[r1] into r14;
|
||||
assert.eq r14.status 3u8 ;
|
||||
get nfts[r1] into r15;
|
||||
assert.eq r15.hash r3 ;
|
||||
assert.eq r15.uri r4 ;
|
||||
assert.eq r15.holder r2 ;
|
||||
contains bids[r1] into r16;
|
||||
assert.eq r16 true ;
|
||||
get bids[r1] into r17;
|
||||
assert.eq r17.bidder r5 ;
|
||||
is.eq r17.amount r6 into r18;
|
||||
assert.eq r18 true ;
|
||||
cast r5 r15.minter r15.hash r15.uri into r19 as NftInfo;
|
||||
set r19 into nfts[r1];
|
||||
remove bids[r1];
|
||||
remove orders[r1];
|
||||
|
||||
function set_admin:
|
||||
input r0 as address.private;
|
||||
async set_admin self.caller r0 into r1;
|
||||
output r1 as artgo_aigc_v1_3.aleo/set_admin.future;
|
||||
|
||||
finalize set_admin:
|
||||
input r0 as address.public;
|
||||
input r1 as address.public;
|
||||
get.or_use admin[true] aleo12n3kz2wzrljvhp9zkn9zety54wz8mlmlakzzkrs6znaz028wjczqpe8x3j into r2;
|
||||
assert.eq r2 r0 ;
|
||||
set r1 into admin[true];
|
||||
|
||||
function set_fee:
|
||||
input r0 as u64.private;
|
||||
async set_fee self.caller r0 into r1;
|
||||
output r1 as artgo_aigc_v1_3.aleo/set_fee.future;
|
||||
|
||||
finalize set_fee:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
get admin[true] into r2;
|
||||
assert.eq r0 r2 ;
|
||||
set r1 into fees[true];
|
@ -1,312 +0,0 @@
|
||||
program credits.aleo;
|
||||
|
||||
mapping committee:
|
||||
key as address.public;
|
||||
value as committee_state.public;
|
||||
|
||||
struct committee_state:
|
||||
microcredits as u64;
|
||||
is_open as boolean;
|
||||
|
||||
mapping bonded:
|
||||
key as address.public;
|
||||
value as bond_state.public;
|
||||
|
||||
struct bond_state:
|
||||
validator as address;
|
||||
microcredits as u64;
|
||||
|
||||
mapping unbonding:
|
||||
key as address.public;
|
||||
value as unbond_state.public;
|
||||
|
||||
struct unbond_state:
|
||||
microcredits as u64;
|
||||
height as u32;
|
||||
|
||||
mapping account:
|
||||
key as address.public;
|
||||
value as u64.public;
|
||||
|
||||
record credits:
|
||||
owner as address.private;
|
||||
microcredits as u64.private;
|
||||
|
||||
function bond_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
gte r1 1000000u64 into r2;
|
||||
assert.eq r2 true ;
|
||||
async bond_public self.caller r0 r1 into r3;
|
||||
output r3 as credits.aleo/bond_public.future;
|
||||
|
||||
finalize bond_public:
|
||||
input r0 as address.public;
|
||||
input r1 as address.public;
|
||||
input r2 as u64.public;
|
||||
is.eq r0 r1 into r3;
|
||||
branch.eq r3 true to bond_validator;
|
||||
branch.eq r3 false to bond_delegator;
|
||||
position bond_validator;
|
||||
cast 0u64 true into r4 as committee_state;
|
||||
get.or_use committee[r0] r4 into r5;
|
||||
assert.eq r5.is_open true ;
|
||||
add r5.microcredits r2 into r6;
|
||||
cast r6 r5.is_open into r7 as committee_state;
|
||||
cast r1 0u64 into r8 as bond_state;
|
||||
get.or_use bonded[r0] r8 into r9;
|
||||
assert.eq r9.validator r1 ;
|
||||
add r9.microcredits r2 into r10;
|
||||
gte r10 1000000000000u64 into r11;
|
||||
assert.eq r11 true ;
|
||||
cast r1 r10 into r12 as bond_state;
|
||||
get account[r0] into r13;
|
||||
sub r13 r2 into r14;
|
||||
set r7 into committee[r0];
|
||||
set r12 into bonded[r0];
|
||||
set r14 into account[r0];
|
||||
branch.eq true true to end;
|
||||
position bond_delegator;
|
||||
contains committee[r0] into r15;
|
||||
assert.eq r15 false ;
|
||||
get committee[r1] into r16;
|
||||
assert.eq r16.is_open true ;
|
||||
add r16.microcredits r2 into r17;
|
||||
cast r17 r16.is_open into r18 as committee_state;
|
||||
cast r1 0u64 into r19 as bond_state;
|
||||
get.or_use bonded[r0] r19 into r20;
|
||||
assert.eq r20.validator r1 ;
|
||||
add r20.microcredits r2 into r21;
|
||||
gte r21 10000000u64 into r22;
|
||||
assert.eq r22 true ;
|
||||
cast r1 r21 into r23 as bond_state;
|
||||
get account[r0] into r24;
|
||||
sub r24 r2 into r25;
|
||||
set r18 into committee[r1];
|
||||
set r23 into bonded[r0];
|
||||
set r25 into account[r0];
|
||||
position end;
|
||||
|
||||
function unbond_public:
|
||||
input r0 as u64.public;
|
||||
async unbond_public self.caller r0 into r1;
|
||||
output r1 as credits.aleo/unbond_public.future;
|
||||
|
||||
finalize unbond_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
cast 0u64 0u32 into r2 as unbond_state;
|
||||
get.or_use unbonding[r0] r2 into r3;
|
||||
add block.height 360u32 into r4;
|
||||
contains committee[r0] into r5;
|
||||
branch.eq r5 true to unbond_validator;
|
||||
branch.eq r5 false to unbond_delegator;
|
||||
position unbond_validator;
|
||||
get committee[r0] into r6;
|
||||
sub r6.microcredits r1 into r7;
|
||||
get bonded[r0] into r8;
|
||||
assert.eq r8.validator r0 ;
|
||||
sub r8.microcredits r1 into r9;
|
||||
gte r9 1000000000000u64 into r10;
|
||||
branch.eq r10 true to decrement_validator;
|
||||
branch.eq r10 false to remove_validator;
|
||||
position decrement_validator;
|
||||
cast r7 r6.is_open into r11 as committee_state;
|
||||
set r11 into committee[r0];
|
||||
cast r0 r9 into r12 as bond_state;
|
||||
set r12 into bonded[r0];
|
||||
add r3.microcredits r1 into r13;
|
||||
cast r13 r4 into r14 as unbond_state;
|
||||
set r14 into unbonding[r0];
|
||||
branch.eq true true to end;
|
||||
position remove_validator;
|
||||
assert.eq r6.microcredits r8.microcredits ;
|
||||
remove committee[r0];
|
||||
remove bonded[r0];
|
||||
add r3.microcredits r8.microcredits into r15;
|
||||
cast r15 r4 into r16 as unbond_state;
|
||||
set r16 into unbonding[r0];
|
||||
branch.eq true true to end;
|
||||
position unbond_delegator;
|
||||
get bonded[r0] into r17;
|
||||
sub r17.microcredits r1 into r18;
|
||||
gte r18 10000000u64 into r19;
|
||||
branch.eq r19 true to decrement_delegator;
|
||||
branch.eq r19 false to remove_delegator;
|
||||
position decrement_delegator;
|
||||
get committee[r17.validator] into r20;
|
||||
sub r20.microcredits r1 into r21;
|
||||
cast r21 r20.is_open into r22 as committee_state;
|
||||
set r22 into committee[r17.validator];
|
||||
cast r17.validator r18 into r23 as bond_state;
|
||||
set r23 into bonded[r0];
|
||||
add r3.microcredits r1 into r24;
|
||||
cast r24 r4 into r25 as unbond_state;
|
||||
set r25 into unbonding[r0];
|
||||
branch.eq true true to end;
|
||||
position remove_delegator;
|
||||
get committee[r17.validator] into r26;
|
||||
sub r26.microcredits r17.microcredits into r27;
|
||||
cast r27 r26.is_open into r28 as committee_state;
|
||||
set r28 into committee[r17.validator];
|
||||
remove bonded[r0];
|
||||
add r3.microcredits r17.microcredits into r29;
|
||||
cast r29 r4 into r30 as unbond_state;
|
||||
set r30 into unbonding[r0];
|
||||
position end;
|
||||
|
||||
function unbond_delegator_as_validator:
|
||||
input r0 as address.public;
|
||||
async unbond_delegator_as_validator self.caller r0 into r1;
|
||||
output r1 as credits.aleo/unbond_delegator_as_validator.future;
|
||||
|
||||
finalize unbond_delegator_as_validator:
|
||||
input r0 as address.public;
|
||||
input r1 as address.public;
|
||||
get committee[r0] into r2;
|
||||
assert.eq r2.is_open false ;
|
||||
contains committee[r1] into r3;
|
||||
assert.eq r3 false ;
|
||||
get bonded[r1] into r4;
|
||||
assert.eq r4.validator r0 ;
|
||||
sub r2.microcredits r4.microcredits into r5;
|
||||
cast r5 r2.is_open into r6 as committee_state;
|
||||
cast 0u64 0u32 into r7 as unbond_state;
|
||||
get.or_use unbonding[r1] r7 into r8;
|
||||
add r8.microcredits r4.microcredits into r9;
|
||||
add block.height 360u32 into r10;
|
||||
cast r9 r10 into r11 as unbond_state;
|
||||
set r6 into committee[r0];
|
||||
remove bonded[r1];
|
||||
set r11 into unbonding[r1];
|
||||
|
||||
function claim_unbond_public:
|
||||
async claim_unbond_public self.caller into r0;
|
||||
output r0 as credits.aleo/claim_unbond_public.future;
|
||||
|
||||
finalize claim_unbond_public:
|
||||
input r0 as address.public;
|
||||
get unbonding[r0] into r1;
|
||||
gte block.height r1.height into r2;
|
||||
assert.eq r2 true ;
|
||||
get.or_use account[r0] 0u64 into r3;
|
||||
add r1.microcredits r3 into r4;
|
||||
set r4 into account[r0];
|
||||
remove unbonding[r0];
|
||||
|
||||
function set_validator_state:
|
||||
input r0 as boolean.public;
|
||||
async set_validator_state self.caller r0 into r1;
|
||||
output r1 as credits.aleo/set_validator_state.future;
|
||||
|
||||
finalize set_validator_state:
|
||||
input r0 as address.public;
|
||||
input r1 as boolean.public;
|
||||
get committee[r0] into r2;
|
||||
cast r2.microcredits r1 into r3 as committee_state;
|
||||
set r3 into committee[r0];
|
||||
|
||||
function transfer_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
async transfer_public self.caller r0 r1 into r2;
|
||||
output r2 as credits.aleo/transfer_public.future;
|
||||
|
||||
finalize transfer_public:
|
||||
input r0 as address.public;
|
||||
input r1 as address.public;
|
||||
input r2 as u64.public;
|
||||
get account[r0] into r3;
|
||||
sub r3 r2 into r4;
|
||||
set r4 into account[r0];
|
||||
get.or_use account[r1] 0u64 into r5;
|
||||
add r5 r2 into r6;
|
||||
set r6 into account[r1];
|
||||
|
||||
function transfer_private:
|
||||
input r0 as credits.record;
|
||||
input r1 as address.private;
|
||||
input r2 as u64.private;
|
||||
sub r0.microcredits r2 into r3;
|
||||
cast r1 r2 into r4 as credits.record;
|
||||
cast r0.owner r3 into r5 as credits.record;
|
||||
output r4 as credits.record;
|
||||
output r5 as credits.record;
|
||||
|
||||
function transfer_private_to_public:
|
||||
input r0 as credits.record;
|
||||
input r1 as address.public;
|
||||
input r2 as u64.public;
|
||||
sub r0.microcredits r2 into r3;
|
||||
cast r0.owner r3 into r4 as credits.record;
|
||||
async transfer_private_to_public r1 r2 into r5;
|
||||
output r4 as credits.record;
|
||||
output r5 as credits.aleo/transfer_private_to_public.future;
|
||||
|
||||
finalize transfer_private_to_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
get.or_use account[r0] 0u64 into r2;
|
||||
add r1 r2 into r3;
|
||||
set r3 into account[r0];
|
||||
|
||||
function transfer_public_to_private:
|
||||
input r0 as address.private;
|
||||
input r1 as u64.public;
|
||||
cast r0 r1 into r2 as credits.record;
|
||||
async transfer_public_to_private self.caller r1 into r3;
|
||||
output r2 as credits.record;
|
||||
output r3 as credits.aleo/transfer_public_to_private.future;
|
||||
|
||||
finalize transfer_public_to_private:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
get account[r0] into r2;
|
||||
sub r2 r1 into r3;
|
||||
set r3 into account[r0];
|
||||
|
||||
function join:
|
||||
input r0 as credits.record;
|
||||
input r1 as credits.record;
|
||||
add r0.microcredits r1.microcredits into r2;
|
||||
cast r0.owner r2 into r3 as credits.record;
|
||||
output r3 as credits.record;
|
||||
|
||||
function split:
|
||||
input r0 as credits.record;
|
||||
input r1 as u64.private;
|
||||
sub r0.microcredits r1 into r2;
|
||||
sub r2 10000u64 into r3;
|
||||
cast r0.owner r1 into r4 as credits.record;
|
||||
cast r0.owner r3 into r5 as credits.record;
|
||||
output r4 as credits.record;
|
||||
output r5 as credits.record;
|
||||
|
||||
function fee_private:
|
||||
input r0 as credits.record;
|
||||
input r1 as u64.public;
|
||||
input r2 as u64.public;
|
||||
input r3 as field.public;
|
||||
assert.neq r1 0u64 ;
|
||||
assert.neq r3 0field ;
|
||||
add r1 r2 into r4;
|
||||
sub r0.microcredits r4 into r5;
|
||||
cast r0.owner r5 into r6 as credits.record;
|
||||
output r6 as credits.record;
|
||||
|
||||
function fee_public:
|
||||
input r0 as u64.public;
|
||||
input r1 as u64.public;
|
||||
input r2 as field.public;
|
||||
assert.neq r0 0u64 ;
|
||||
assert.neq r2 0field ;
|
||||
add r0 r1 into r3;
|
||||
async fee_public self.caller r3 into r4;
|
||||
output r4 as credits.aleo/fee_public.future;
|
||||
|
||||
finalize fee_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
get account[r0] into r2;
|
||||
sub r2 r1 into r3;
|
||||
set r3 into account[r0];
|
@ -1,633 +0,0 @@
|
||||
import credits.aleo;
|
||||
|
||||
program distrofund_private_transfer.aleo;
|
||||
|
||||
struct Addresses1:
|
||||
address1 as address;
|
||||
|
||||
struct Addresses2:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
|
||||
struct Addresses3:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
|
||||
struct Addresses4:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
|
||||
struct Addresses5:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
|
||||
struct Addresses6:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
|
||||
struct Addresses7:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
|
||||
struct Addresses8:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
|
||||
struct Addresses9:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
address9 as address;
|
||||
|
||||
struct Addresses10:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
address9 as address;
|
||||
address10 as address;
|
||||
|
||||
struct Addresses11:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
address9 as address;
|
||||
address10 as address;
|
||||
address11 as address;
|
||||
|
||||
struct Addresses12:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
address9 as address;
|
||||
address10 as address;
|
||||
address11 as address;
|
||||
address12 as address;
|
||||
|
||||
struct Addresses13:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
address9 as address;
|
||||
address10 as address;
|
||||
address11 as address;
|
||||
address12 as address;
|
||||
address13 as address;
|
||||
|
||||
struct Addresses14:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
address9 as address;
|
||||
address10 as address;
|
||||
address11 as address;
|
||||
address12 as address;
|
||||
address13 as address;
|
||||
address14 as address;
|
||||
|
||||
struct Addresses15:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
address9 as address;
|
||||
address10 as address;
|
||||
address11 as address;
|
||||
address12 as address;
|
||||
address13 as address;
|
||||
address14 as address;
|
||||
address15 as address;
|
||||
|
||||
struct Amount1:
|
||||
amount1 as u64;
|
||||
|
||||
struct Amount2:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
|
||||
struct Amount3:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
|
||||
struct Amount4:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
|
||||
struct Amount5:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
|
||||
struct Amount6:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
|
||||
struct Amount7:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
|
||||
struct Amount8:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
|
||||
struct Amount9:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
amount9 as u64;
|
||||
|
||||
struct Amount10:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
amount9 as u64;
|
||||
amount10 as u64;
|
||||
|
||||
struct Amount11:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
amount9 as u64;
|
||||
amount10 as u64;
|
||||
amount11 as u64;
|
||||
|
||||
struct Amount12:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
amount9 as u64;
|
||||
amount10 as u64;
|
||||
amount11 as u64;
|
||||
amount12 as u64;
|
||||
|
||||
struct Amount13:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
amount9 as u64;
|
||||
amount10 as u64;
|
||||
amount11 as u64;
|
||||
amount12 as u64;
|
||||
amount13 as u64;
|
||||
|
||||
struct Amount14:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
amount9 as u64;
|
||||
amount10 as u64;
|
||||
amount11 as u64;
|
||||
amount12 as u64;
|
||||
amount13 as u64;
|
||||
amount14 as u64;
|
||||
|
||||
struct Amount15:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
amount9 as u64;
|
||||
amount10 as u64;
|
||||
amount11 as u64;
|
||||
amount12 as u64;
|
||||
amount13 as u64;
|
||||
amount14 as u64;
|
||||
amount15 as u64;
|
||||
|
||||
function transfer_one:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses1.public;
|
||||
input r2 as Amount1.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
output r4 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_two:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses2.public;
|
||||
input r2 as Amount2.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
output r6 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_three:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses3.public;
|
||||
input r2 as Amount3.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
output r8 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_four:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses4.public;
|
||||
input r2 as Amount4.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
output r10 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_five:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses5.public;
|
||||
input r2 as Amount5.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
output r12 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_six:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses6.public;
|
||||
input r2 as Amount6.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
output r14 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_seven:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses7.public;
|
||||
input r2 as Amount7.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
output r16 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_eight:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses8.public;
|
||||
input r2 as Amount8.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
output r18 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_nine:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses9.public;
|
||||
input r2 as Amount9.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
call credits.aleo/transfer_private r18 r1.address9 r2.amount9 into r19 r20;
|
||||
output r20 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
output r19 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_ten:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses10.public;
|
||||
input r2 as Amount10.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
call credits.aleo/transfer_private r18 r1.address9 r2.amount9 into r19 r20;
|
||||
call credits.aleo/transfer_private r20 r1.address10 r2.amount10 into r21 r22;
|
||||
output r22 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
output r19 as credits.aleo/credits.record;
|
||||
output r21 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_eleven:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses11.public;
|
||||
input r2 as Amount11.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
call credits.aleo/transfer_private r18 r1.address9 r2.amount9 into r19 r20;
|
||||
call credits.aleo/transfer_private r20 r1.address10 r2.amount10 into r21 r22;
|
||||
call credits.aleo/transfer_private r22 r1.address11 r2.amount11 into r23 r24;
|
||||
output r24 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
output r19 as credits.aleo/credits.record;
|
||||
output r21 as credits.aleo/credits.record;
|
||||
output r23 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_twelve:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses12.public;
|
||||
input r2 as Amount12.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
call credits.aleo/transfer_private r18 r1.address9 r2.amount9 into r19 r20;
|
||||
call credits.aleo/transfer_private r20 r1.address10 r2.amount10 into r21 r22;
|
||||
call credits.aleo/transfer_private r22 r1.address11 r2.amount11 into r23 r24;
|
||||
call credits.aleo/transfer_private r24 r1.address12 r2.amount12 into r25 r26;
|
||||
output r26 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
output r19 as credits.aleo/credits.record;
|
||||
output r21 as credits.aleo/credits.record;
|
||||
output r23 as credits.aleo/credits.record;
|
||||
output r25 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_thirteen:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses13.public;
|
||||
input r2 as Amount13.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
call credits.aleo/transfer_private r18 r1.address9 r2.amount9 into r19 r20;
|
||||
call credits.aleo/transfer_private r20 r1.address10 r2.amount10 into r21 r22;
|
||||
call credits.aleo/transfer_private r22 r1.address11 r2.amount11 into r23 r24;
|
||||
call credits.aleo/transfer_private r24 r1.address12 r2.amount12 into r25 r26;
|
||||
call credits.aleo/transfer_private r26 r1.address13 r2.amount13 into r27 r28;
|
||||
output r28 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
output r19 as credits.aleo/credits.record;
|
||||
output r21 as credits.aleo/credits.record;
|
||||
output r23 as credits.aleo/credits.record;
|
||||
output r25 as credits.aleo/credits.record;
|
||||
output r27 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_fourteen:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses14.public;
|
||||
input r2 as Amount14.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
call credits.aleo/transfer_private r18 r1.address9 r2.amount9 into r19 r20;
|
||||
call credits.aleo/transfer_private r20 r1.address10 r2.amount10 into r21 r22;
|
||||
call credits.aleo/transfer_private r22 r1.address11 r2.amount11 into r23 r24;
|
||||
call credits.aleo/transfer_private r24 r1.address12 r2.amount12 into r25 r26;
|
||||
call credits.aleo/transfer_private r26 r1.address13 r2.amount13 into r27 r28;
|
||||
call credits.aleo/transfer_private r28 r1.address14 r2.amount14 into r29 r30;
|
||||
output r30 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
output r19 as credits.aleo/credits.record;
|
||||
output r21 as credits.aleo/credits.record;
|
||||
output r23 as credits.aleo/credits.record;
|
||||
output r25 as credits.aleo/credits.record;
|
||||
output r27 as credits.aleo/credits.record;
|
||||
output r29 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_fifteen:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses15.public;
|
||||
input r2 as Amount15.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
call credits.aleo/transfer_private r18 r1.address9 r2.amount9 into r19 r20;
|
||||
call credits.aleo/transfer_private r20 r1.address10 r2.amount10 into r21 r22;
|
||||
call credits.aleo/transfer_private r22 r1.address11 r2.amount11 into r23 r24;
|
||||
call credits.aleo/transfer_private r24 r1.address12 r2.amount12 into r25 r26;
|
||||
call credits.aleo/transfer_private r26 r1.address13 r2.amount13 into r27 r28;
|
||||
call credits.aleo/transfer_private r28 r1.address14 r2.amount14 into r29 r30;
|
||||
call credits.aleo/transfer_private r30 r1.address15 r2.amount15 into r31 r32;
|
||||
output r32 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
output r19 as credits.aleo/credits.record;
|
||||
output r21 as credits.aleo/credits.record;
|
||||
output r23 as credits.aleo/credits.record;
|
||||
output r25 as credits.aleo/credits.record;
|
||||
output r27 as credits.aleo/credits.record;
|
||||
output r29 as credits.aleo/credits.record;
|
||||
output r31 as credits.aleo/credits.record;
|
@ -1,371 +0,0 @@
|
||||
import credits.aleo;
|
||||
|
||||
program artgo_aigc_v1_3.aleo;
|
||||
|
||||
struct Field2:
|
||||
first as field;
|
||||
second as field;
|
||||
|
||||
struct NftHash:
|
||||
minter as address;
|
||||
prompt as Field2;
|
||||
nonce as field;
|
||||
|
||||
struct NftInfo:
|
||||
holder as address;
|
||||
minter as address;
|
||||
hash as field;
|
||||
uri as Field2;
|
||||
|
||||
struct Order:
|
||||
holder as address;
|
||||
nft_id as field;
|
||||
order_type as u8;
|
||||
amount as u64;
|
||||
status as u8;
|
||||
deadline as field;
|
||||
|
||||
struct Bid:
|
||||
bidder as address;
|
||||
nft_id as field;
|
||||
amount as u64;
|
||||
|
||||
record BidRecord:
|
||||
owner as address.private;
|
||||
bid_type as u8.private;
|
||||
bidder as address.private;
|
||||
nft_id as field.private;
|
||||
amount as u64.private;
|
||||
|
||||
record Nft:
|
||||
owner as address.private;
|
||||
minter as address.private;
|
||||
prompt as Field2.private;
|
||||
nonce as field.private;
|
||||
uri as Field2.private;
|
||||
|
||||
mapping nfts:
|
||||
key as field.public;
|
||||
value as NftInfo.public;
|
||||
|
||||
mapping tokenId:
|
||||
key as boolean.public;
|
||||
value as field.public;
|
||||
|
||||
mapping admin:
|
||||
key as boolean.public;
|
||||
value as address.public;
|
||||
|
||||
mapping fees:
|
||||
key as boolean.public;
|
||||
value as u64.public;
|
||||
|
||||
mapping orders:
|
||||
key as field.public;
|
||||
value as Order.public;
|
||||
|
||||
mapping bids:
|
||||
key as field.public;
|
||||
value as Bid.public;
|
||||
|
||||
function mint_nft:
|
||||
input r0 as Field2.private;
|
||||
input r1 as Field2.public;
|
||||
input r2 as field.public;
|
||||
cast self.caller r0 r2 into r3 as NftHash;
|
||||
hash.bhp256 r3 into r4 as field;
|
||||
cast self.caller self.caller r0 r2 r1 into r5 as Nft.record;
|
||||
async mint_nft self.caller r4 r1 into r6;
|
||||
output r5 as Nft.record;
|
||||
output r6 as artgo_aigc_v1_3.aleo/mint_nft.future;
|
||||
|
||||
finalize mint_nft:
|
||||
input r0 as address.public;
|
||||
input r1 as field.public;
|
||||
input r2 as Field2.public;
|
||||
get.or_use tokenId[true] 1field into r3;
|
||||
add r3 1field into r4;
|
||||
set r4 into tokenId[true];
|
||||
cast r0 r0 r1 r2 into r5 as NftInfo;
|
||||
set r5 into nfts[r3];
|
||||
|
||||
function transfer_private_nft:
|
||||
input r0 as field.private;
|
||||
input r1 as Nft.record;
|
||||
input r2 as address.private;
|
||||
is.eq r1.owner self.caller into r3;
|
||||
assert.eq r3 true ;
|
||||
cast r1.minter r1.prompt r1.nonce into r4 as NftHash;
|
||||
hash.bhp256 r4 into r5 as field;
|
||||
cast r2 r1.minter r1.prompt r1.nonce r1.uri into r6 as Nft.record;
|
||||
async transfer_private_nft r0 r5 r1.uri r2 into r7;
|
||||
output r6 as Nft.record;
|
||||
output r7 as artgo_aigc_v1_3.aleo/transfer_private_nft.future;
|
||||
|
||||
finalize transfer_private_nft:
|
||||
input r0 as field.public;
|
||||
input r1 as field.public;
|
||||
input r2 as Field2.public;
|
||||
input r3 as address.public;
|
||||
get nfts[r0] into r4;
|
||||
assert.eq r4.hash r1 ;
|
||||
assert.eq r4.uri r2 ;
|
||||
cast r3 r4.minter r4.hash r4.uri into r5 as NftInfo;
|
||||
set r5 into nfts[r0];
|
||||
|
||||
function place_order:
|
||||
input r0 as field.public;
|
||||
input r1 as Nft.record;
|
||||
input r2 as u8.public;
|
||||
input r3 as u64.public;
|
||||
input r4 as field.public;
|
||||
input r5 as address.public;
|
||||
is.eq r2 1u8 into r6;
|
||||
assert.eq r6 true ;
|
||||
gt r3 0u64 into r7;
|
||||
lte r3 18446744073709551615u64 into r8;
|
||||
and r7 r8 into r9;
|
||||
assert.eq r9 true ;
|
||||
cast r1.minter r1.prompt r1.nonce into r10 as NftHash;
|
||||
hash.bhp256 r10 into r11 as field;
|
||||
cast self.caller r0 r2 r3 1u8 0field into r12 as Order;
|
||||
cast r5 r1.minter r1.prompt r1.nonce r1.uri into r13 as Nft.record;
|
||||
async place_order r5 r0 r11 r1.uri r12 into r14;
|
||||
output r13 as Nft.record;
|
||||
output r14 as artgo_aigc_v1_3.aleo/place_order.future;
|
||||
|
||||
finalize place_order:
|
||||
input r0 as address.public;
|
||||
input r1 as field.public;
|
||||
input r2 as field.public;
|
||||
input r3 as Field2.public;
|
||||
input r4 as Order.public;
|
||||
contains admin[true] into r5;
|
||||
assert.eq r5 true ;
|
||||
get admin[true] into r6;
|
||||
assert.eq r6 r0 ;
|
||||
get nfts[r1] into r7;
|
||||
assert.eq r7.hash r2 ;
|
||||
assert.eq r7.uri r3 ;
|
||||
contains fees[true] into r8;
|
||||
assert.eq r8 true ;
|
||||
get fees[true] into r9;
|
||||
gte r4.amount r9 into r10;
|
||||
assert.eq r10 true ;
|
||||
contains orders[r1] into r11;
|
||||
not r11 into r12;
|
||||
assert.eq r12 true ;
|
||||
set r4 into orders[r1];
|
||||
|
||||
function update_order:
|
||||
input r0 as field.public;
|
||||
input r1 as u64.public;
|
||||
gt r1 0u64 into r2;
|
||||
lte r1 18446744073709551615u64 into r3;
|
||||
and r2 r3 into r4;
|
||||
assert.eq r4 true ;
|
||||
async update_order self.caller r0 r1 into r5;
|
||||
output r5 as artgo_aigc_v1_3.aleo/update_order.future;
|
||||
|
||||
finalize update_order:
|
||||
input r0 as address.public;
|
||||
input r1 as field.public;
|
||||
input r2 as u64.public;
|
||||
get orders[r1] into r3;
|
||||
is.eq r3.status 1u8 into r4;
|
||||
assert.eq r4 true ;
|
||||
is.eq r0 r3.holder into r5;
|
||||
assert.eq r5 true ;
|
||||
contains fees[true] into r6;
|
||||
assert.eq r6 true ;
|
||||
get fees[true] into r7;
|
||||
gte r2 r7 into r8;
|
||||
assert.eq r8 true ;
|
||||
cast r3.holder r3.nft_id r3.order_type r2 r3.status r3.deadline into r9 as Order;
|
||||
set r9 into orders[r1];
|
||||
|
||||
function cancel_order:
|
||||
input r0 as u64.public;
|
||||
input r1 as field.public;
|
||||
input r2 as address.public;
|
||||
cast r2 2u8 self.caller r1 0u64 into r3 as BidRecord.record;
|
||||
call credits.aleo/transfer_public r2 r0 into r4;
|
||||
async cancel_order r4 self.caller r1 r0 r2 into r5;
|
||||
output r3 as BidRecord.record;
|
||||
output r5 as artgo_aigc_v1_3.aleo/cancel_order.future;
|
||||
|
||||
finalize cancel_order:
|
||||
input r0 as credits.aleo/transfer_public.future;
|
||||
input r1 as address.public;
|
||||
input r2 as field.public;
|
||||
input r3 as u64.public;
|
||||
input r4 as address.public;
|
||||
await r0;
|
||||
contains fees[true] into r5;
|
||||
assert.eq r5 true ;
|
||||
get fees[true] into r6;
|
||||
assert.eq r6 r3 ;
|
||||
get orders[r2] into r7;
|
||||
is.eq r7.status 1u8 into r8;
|
||||
assert.eq r8 true ;
|
||||
is.eq r1 r7.holder into r9;
|
||||
assert.eq r9 true ;
|
||||
contains admin[true] into r10;
|
||||
assert.eq r10 true ;
|
||||
get admin[true] into r11;
|
||||
assert.eq r11 r4 ;
|
||||
cast r7.holder r7.nft_id r7.order_type r7.amount 2u8 r7.deadline into r12 as Order;
|
||||
set r12 into orders[r2];
|
||||
|
||||
function handle_cancel_order:
|
||||
input r0 as field.public;
|
||||
input r1 as Nft.record;
|
||||
input r2 as address.public;
|
||||
cast r2 r1.minter r1.prompt r1.nonce r1.uri into r3 as Nft.record;
|
||||
cast r1.minter r1.prompt r1.nonce into r4 as NftHash;
|
||||
hash.bhp256 r4 into r5 as field;
|
||||
async handle_cancel_order r0 r5 r1.uri r2 self.caller into r6;
|
||||
output r3 as Nft.record;
|
||||
output r6 as artgo_aigc_v1_3.aleo/handle_cancel_order.future;
|
||||
|
||||
finalize handle_cancel_order:
|
||||
input r0 as field.public;
|
||||
input r1 as field.public;
|
||||
input r2 as Field2.public;
|
||||
input r3 as address.public;
|
||||
input r4 as address.public;
|
||||
contains admin[true] into r5;
|
||||
assert.eq r5 true ;
|
||||
get admin[true] into r6;
|
||||
assert.eq r6 r4 ;
|
||||
get nfts[r0] into r7;
|
||||
assert.eq r7.hash r1 ;
|
||||
assert.eq r7.uri r2 ;
|
||||
get orders[r0] into r8;
|
||||
is.eq r8.status 2u8 into r9;
|
||||
assert.eq r9 true ;
|
||||
is.eq r3 r8.holder into r10;
|
||||
assert.eq r10 true ;
|
||||
remove bids[r0];
|
||||
remove orders[r0];
|
||||
|
||||
function bid_order:
|
||||
input r0 as field.public;
|
||||
input r1 as u64.public;
|
||||
input r2 as address.public;
|
||||
gt r1 0u64 into r3;
|
||||
lte r1 18446744073709551615u64 into r4;
|
||||
and r3 r4 into r5;
|
||||
assert.eq r5 true ;
|
||||
cast r2 1u8 self.caller r0 r1 into r6 as BidRecord.record;
|
||||
call credits.aleo/transfer_public r2 r1 into r7;
|
||||
async bid_order r7 self.caller r0 r1 r2 into r8;
|
||||
output r6 as BidRecord.record;
|
||||
output r8 as artgo_aigc_v1_3.aleo/bid_order.future;
|
||||
|
||||
finalize bid_order:
|
||||
input r0 as credits.aleo/transfer_public.future;
|
||||
input r1 as address.public;
|
||||
input r2 as field.public;
|
||||
input r3 as u64.public;
|
||||
input r4 as address.public;
|
||||
await r0;
|
||||
contains admin[true] into r5;
|
||||
assert.eq r5 true ;
|
||||
get admin[true] into r6;
|
||||
assert.eq r6 r4 ;
|
||||
cast r1 r2 r3 into r7 as Bid;
|
||||
set r7 into bids[r2];
|
||||
contains orders[r2] into r8;
|
||||
assert.eq r8 true ;
|
||||
get orders[r2] into r9;
|
||||
is.eq r9.status 1u8 into r10;
|
||||
assert.eq r10 true ;
|
||||
gte r3 r9.amount into r11;
|
||||
assert.eq r11 true ;
|
||||
cast r9.holder r9.nft_id r9.order_type r9.amount 3u8 0field into r12 as Order;
|
||||
set r12 into orders[r2];
|
||||
|
||||
function finish_order:
|
||||
input r0 as field.public;
|
||||
input r1 as Nft.record;
|
||||
input r2 as address.public;
|
||||
input r3 as u64.public;
|
||||
input r4 as address.public;
|
||||
input r5 as u64.public;
|
||||
input r6 as address.public;
|
||||
gte r5 r3 into r7;
|
||||
lte r5 18446744073709551615u64 into r8;
|
||||
and r7 r8 into r9;
|
||||
assert.eq r9 true ;
|
||||
assert.eq self.caller r6 ;
|
||||
sub r5 r3 into r10;
|
||||
call credits.aleo/transfer_public r2 r10 into r11;
|
||||
cast r1.minter r1.prompt r1.nonce into r12 as NftHash;
|
||||
hash.bhp256 r12 into r13 as field;
|
||||
cast r4 r1.minter r1.prompt r1.nonce r1.uri into r14 as Nft.record;
|
||||
async finish_order r11 r0 r2 r13 r1.uri r4 r5 r3 r6 into r15;
|
||||
output r14 as Nft.record;
|
||||
output r15 as artgo_aigc_v1_3.aleo/finish_order.future;
|
||||
|
||||
finalize finish_order:
|
||||
input r0 as credits.aleo/transfer_public.future;
|
||||
input r1 as field.public;
|
||||
input r2 as address.public;
|
||||
input r3 as field.public;
|
||||
input r4 as Field2.public;
|
||||
input r5 as address.public;
|
||||
input r6 as u64.public;
|
||||
input r7 as u64.public;
|
||||
input r8 as address.public;
|
||||
await r0;
|
||||
contains admin[true] into r9;
|
||||
assert.eq r9 true ;
|
||||
get admin[true] into r10;
|
||||
assert.eq r10 r8 ;
|
||||
contains fees[true] into r11;
|
||||
assert.eq r11 true ;
|
||||
get fees[true] into r12;
|
||||
assert.eq r12 r7 ;
|
||||
contains orders[r1] into r13;
|
||||
assert.eq r13 true ;
|
||||
get orders[r1] into r14;
|
||||
assert.eq r14.status 3u8 ;
|
||||
get nfts[r1] into r15;
|
||||
assert.eq r15.hash r3 ;
|
||||
assert.eq r15.uri r4 ;
|
||||
assert.eq r15.holder r2 ;
|
||||
contains bids[r1] into r16;
|
||||
assert.eq r16 true ;
|
||||
get bids[r1] into r17;
|
||||
assert.eq r17.bidder r5 ;
|
||||
is.eq r17.amount r6 into r18;
|
||||
assert.eq r18 true ;
|
||||
cast r5 r15.minter r15.hash r15.uri into r19 as NftInfo;
|
||||
set r19 into nfts[r1];
|
||||
remove bids[r1];
|
||||
remove orders[r1];
|
||||
|
||||
function set_admin:
|
||||
input r0 as address.private;
|
||||
async set_admin self.caller r0 into r1;
|
||||
output r1 as artgo_aigc_v1_3.aleo/set_admin.future;
|
||||
|
||||
finalize set_admin:
|
||||
input r0 as address.public;
|
||||
input r1 as address.public;
|
||||
get.or_use admin[true] aleo12n3kz2wzrljvhp9zkn9zety54wz8mlmlakzzkrs6znaz028wjczqpe8x3j into r2;
|
||||
assert.eq r2 r0 ;
|
||||
set r1 into admin[true];
|
||||
|
||||
function set_fee:
|
||||
input r0 as u64.private;
|
||||
async set_fee self.caller r0 into r1;
|
||||
output r1 as artgo_aigc_v1_3.aleo/set_fee.future;
|
||||
|
||||
finalize set_fee:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
get admin[true] into r2;
|
||||
assert.eq r0 r2 ;
|
||||
set r1 into fees[true];
|
@ -1,312 +0,0 @@
|
||||
program credits.aleo;
|
||||
|
||||
mapping committee:
|
||||
key as address.public;
|
||||
value as committee_state.public;
|
||||
|
||||
struct committee_state:
|
||||
microcredits as u64;
|
||||
is_open as boolean;
|
||||
|
||||
mapping bonded:
|
||||
key as address.public;
|
||||
value as bond_state.public;
|
||||
|
||||
struct bond_state:
|
||||
validator as address;
|
||||
microcredits as u64;
|
||||
|
||||
mapping unbonding:
|
||||
key as address.public;
|
||||
value as unbond_state.public;
|
||||
|
||||
struct unbond_state:
|
||||
microcredits as u64;
|
||||
height as u32;
|
||||
|
||||
mapping account:
|
||||
key as address.public;
|
||||
value as u64.public;
|
||||
|
||||
record credits:
|
||||
owner as address.private;
|
||||
microcredits as u64.private;
|
||||
|
||||
function bond_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
gte r1 1000000u64 into r2;
|
||||
assert.eq r2 true ;
|
||||
async bond_public self.caller r0 r1 into r3;
|
||||
output r3 as credits.aleo/bond_public.future;
|
||||
|
||||
finalize bond_public:
|
||||
input r0 as address.public;
|
||||
input r1 as address.public;
|
||||
input r2 as u64.public;
|
||||
is.eq r0 r1 into r3;
|
||||
branch.eq r3 true to bond_validator;
|
||||
branch.eq r3 false to bond_delegator;
|
||||
position bond_validator;
|
||||
cast 0u64 true into r4 as committee_state;
|
||||
get.or_use committee[r0] r4 into r5;
|
||||
assert.eq r5.is_open true ;
|
||||
add r5.microcredits r2 into r6;
|
||||
cast r6 r5.is_open into r7 as committee_state;
|
||||
cast r1 0u64 into r8 as bond_state;
|
||||
get.or_use bonded[r0] r8 into r9;
|
||||
assert.eq r9.validator r1 ;
|
||||
add r9.microcredits r2 into r10;
|
||||
gte r10 1000000000000u64 into r11;
|
||||
assert.eq r11 true ;
|
||||
cast r1 r10 into r12 as bond_state;
|
||||
get account[r0] into r13;
|
||||
sub r13 r2 into r14;
|
||||
set r7 into committee[r0];
|
||||
set r12 into bonded[r0];
|
||||
set r14 into account[r0];
|
||||
branch.eq true true to end;
|
||||
position bond_delegator;
|
||||
contains committee[r0] into r15;
|
||||
assert.eq r15 false ;
|
||||
get committee[r1] into r16;
|
||||
assert.eq r16.is_open true ;
|
||||
add r16.microcredits r2 into r17;
|
||||
cast r17 r16.is_open into r18 as committee_state;
|
||||
cast r1 0u64 into r19 as bond_state;
|
||||
get.or_use bonded[r0] r19 into r20;
|
||||
assert.eq r20.validator r1 ;
|
||||
add r20.microcredits r2 into r21;
|
||||
gte r21 10000000u64 into r22;
|
||||
assert.eq r22 true ;
|
||||
cast r1 r21 into r23 as bond_state;
|
||||
get account[r0] into r24;
|
||||
sub r24 r2 into r25;
|
||||
set r18 into committee[r1];
|
||||
set r23 into bonded[r0];
|
||||
set r25 into account[r0];
|
||||
position end;
|
||||
|
||||
function unbond_public:
|
||||
input r0 as u64.public;
|
||||
async unbond_public self.caller r0 into r1;
|
||||
output r1 as credits.aleo/unbond_public.future;
|
||||
|
||||
finalize unbond_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
cast 0u64 0u32 into r2 as unbond_state;
|
||||
get.or_use unbonding[r0] r2 into r3;
|
||||
add block.height 360u32 into r4;
|
||||
contains committee[r0] into r5;
|
||||
branch.eq r5 true to unbond_validator;
|
||||
branch.eq r5 false to unbond_delegator;
|
||||
position unbond_validator;
|
||||
get committee[r0] into r6;
|
||||
sub r6.microcredits r1 into r7;
|
||||
get bonded[r0] into r8;
|
||||
assert.eq r8.validator r0 ;
|
||||
sub r8.microcredits r1 into r9;
|
||||
gte r9 1000000000000u64 into r10;
|
||||
branch.eq r10 true to decrement_validator;
|
||||
branch.eq r10 false to remove_validator;
|
||||
position decrement_validator;
|
||||
cast r7 r6.is_open into r11 as committee_state;
|
||||
set r11 into committee[r0];
|
||||
cast r0 r9 into r12 as bond_state;
|
||||
set r12 into bonded[r0];
|
||||
add r3.microcredits r1 into r13;
|
||||
cast r13 r4 into r14 as unbond_state;
|
||||
set r14 into unbonding[r0];
|
||||
branch.eq true true to end;
|
||||
position remove_validator;
|
||||
assert.eq r6.microcredits r8.microcredits ;
|
||||
remove committee[r0];
|
||||
remove bonded[r0];
|
||||
add r3.microcredits r8.microcredits into r15;
|
||||
cast r15 r4 into r16 as unbond_state;
|
||||
set r16 into unbonding[r0];
|
||||
branch.eq true true to end;
|
||||
position unbond_delegator;
|
||||
get bonded[r0] into r17;
|
||||
sub r17.microcredits r1 into r18;
|
||||
gte r18 10000000u64 into r19;
|
||||
branch.eq r19 true to decrement_delegator;
|
||||
branch.eq r19 false to remove_delegator;
|
||||
position decrement_delegator;
|
||||
get committee[r17.validator] into r20;
|
||||
sub r20.microcredits r1 into r21;
|
||||
cast r21 r20.is_open into r22 as committee_state;
|
||||
set r22 into committee[r17.validator];
|
||||
cast r17.validator r18 into r23 as bond_state;
|
||||
set r23 into bonded[r0];
|
||||
add r3.microcredits r1 into r24;
|
||||
cast r24 r4 into r25 as unbond_state;
|
||||
set r25 into unbonding[r0];
|
||||
branch.eq true true to end;
|
||||
position remove_delegator;
|
||||
get committee[r17.validator] into r26;
|
||||
sub r26.microcredits r17.microcredits into r27;
|
||||
cast r27 r26.is_open into r28 as committee_state;
|
||||
set r28 into committee[r17.validator];
|
||||
remove bonded[r0];
|
||||
add r3.microcredits r17.microcredits into r29;
|
||||
cast r29 r4 into r30 as unbond_state;
|
||||
set r30 into unbonding[r0];
|
||||
position end;
|
||||
|
||||
function unbond_delegator_as_validator:
|
||||
input r0 as address.public;
|
||||
async unbond_delegator_as_validator self.caller r0 into r1;
|
||||
output r1 as credits.aleo/unbond_delegator_as_validator.future;
|
||||
|
||||
finalize unbond_delegator_as_validator:
|
||||
input r0 as address.public;
|
||||
input r1 as address.public;
|
||||
get committee[r0] into r2;
|
||||
assert.eq r2.is_open false ;
|
||||
contains committee[r1] into r3;
|
||||
assert.eq r3 false ;
|
||||
get bonded[r1] into r4;
|
||||
assert.eq r4.validator r0 ;
|
||||
sub r2.microcredits r4.microcredits into r5;
|
||||
cast r5 r2.is_open into r6 as committee_state;
|
||||
cast 0u64 0u32 into r7 as unbond_state;
|
||||
get.or_use unbonding[r1] r7 into r8;
|
||||
add r8.microcredits r4.microcredits into r9;
|
||||
add block.height 360u32 into r10;
|
||||
cast r9 r10 into r11 as unbond_state;
|
||||
set r6 into committee[r0];
|
||||
remove bonded[r1];
|
||||
set r11 into unbonding[r1];
|
||||
|
||||
function claim_unbond_public:
|
||||
async claim_unbond_public self.caller into r0;
|
||||
output r0 as credits.aleo/claim_unbond_public.future;
|
||||
|
||||
finalize claim_unbond_public:
|
||||
input r0 as address.public;
|
||||
get unbonding[r0] into r1;
|
||||
gte block.height r1.height into r2;
|
||||
assert.eq r2 true ;
|
||||
get.or_use account[r0] 0u64 into r3;
|
||||
add r1.microcredits r3 into r4;
|
||||
set r4 into account[r0];
|
||||
remove unbonding[r0];
|
||||
|
||||
function set_validator_state:
|
||||
input r0 as boolean.public;
|
||||
async set_validator_state self.caller r0 into r1;
|
||||
output r1 as credits.aleo/set_validator_state.future;
|
||||
|
||||
finalize set_validator_state:
|
||||
input r0 as address.public;
|
||||
input r1 as boolean.public;
|
||||
get committee[r0] into r2;
|
||||
cast r2.microcredits r1 into r3 as committee_state;
|
||||
set r3 into committee[r0];
|
||||
|
||||
function transfer_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
async transfer_public self.caller r0 r1 into r2;
|
||||
output r2 as credits.aleo/transfer_public.future;
|
||||
|
||||
finalize transfer_public:
|
||||
input r0 as address.public;
|
||||
input r1 as address.public;
|
||||
input r2 as u64.public;
|
||||
get account[r0] into r3;
|
||||
sub r3 r2 into r4;
|
||||
set r4 into account[r0];
|
||||
get.or_use account[r1] 0u64 into r5;
|
||||
add r5 r2 into r6;
|
||||
set r6 into account[r1];
|
||||
|
||||
function transfer_private:
|
||||
input r0 as credits.record;
|
||||
input r1 as address.private;
|
||||
input r2 as u64.private;
|
||||
sub r0.microcredits r2 into r3;
|
||||
cast r1 r2 into r4 as credits.record;
|
||||
cast r0.owner r3 into r5 as credits.record;
|
||||
output r4 as credits.record;
|
||||
output r5 as credits.record;
|
||||
|
||||
function transfer_private_to_public:
|
||||
input r0 as credits.record;
|
||||
input r1 as address.public;
|
||||
input r2 as u64.public;
|
||||
sub r0.microcredits r2 into r3;
|
||||
cast r0.owner r3 into r4 as credits.record;
|
||||
async transfer_private_to_public r1 r2 into r5;
|
||||
output r4 as credits.record;
|
||||
output r5 as credits.aleo/transfer_private_to_public.future;
|
||||
|
||||
finalize transfer_private_to_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
get.or_use account[r0] 0u64 into r2;
|
||||
add r1 r2 into r3;
|
||||
set r3 into account[r0];
|
||||
|
||||
function transfer_public_to_private:
|
||||
input r0 as address.private;
|
||||
input r1 as u64.public;
|
||||
cast r0 r1 into r2 as credits.record;
|
||||
async transfer_public_to_private self.caller r1 into r3;
|
||||
output r2 as credits.record;
|
||||
output r3 as credits.aleo/transfer_public_to_private.future;
|
||||
|
||||
finalize transfer_public_to_private:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
get account[r0] into r2;
|
||||
sub r2 r1 into r3;
|
||||
set r3 into account[r0];
|
||||
|
||||
function join:
|
||||
input r0 as credits.record;
|
||||
input r1 as credits.record;
|
||||
add r0.microcredits r1.microcredits into r2;
|
||||
cast r0.owner r2 into r3 as credits.record;
|
||||
output r3 as credits.record;
|
||||
|
||||
function split:
|
||||
input r0 as credits.record;
|
||||
input r1 as u64.private;
|
||||
sub r0.microcredits r1 into r2;
|
||||
sub r2 10000u64 into r3;
|
||||
cast r0.owner r1 into r4 as credits.record;
|
||||
cast r0.owner r3 into r5 as credits.record;
|
||||
output r4 as credits.record;
|
||||
output r5 as credits.record;
|
||||
|
||||
function fee_private:
|
||||
input r0 as credits.record;
|
||||
input r1 as u64.public;
|
||||
input r2 as u64.public;
|
||||
input r3 as field.public;
|
||||
assert.neq r1 0u64 ;
|
||||
assert.neq r3 0field ;
|
||||
add r1 r2 into r4;
|
||||
sub r0.microcredits r4 into r5;
|
||||
cast r0.owner r5 into r6 as credits.record;
|
||||
output r6 as credits.record;
|
||||
|
||||
function fee_public:
|
||||
input r0 as u64.public;
|
||||
input r1 as u64.public;
|
||||
input r2 as field.public;
|
||||
assert.neq r0 0u64 ;
|
||||
assert.neq r2 0field ;
|
||||
add r0 r1 into r3;
|
||||
async fee_public self.caller r3 into r4;
|
||||
output r4 as credits.aleo/fee_public.future;
|
||||
|
||||
finalize fee_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
get account[r0] into r2;
|
||||
sub r2 r1 into r3;
|
||||
set r3 into account[r0];
|
@ -1,20 +0,0 @@
|
||||
[[package]]
|
||||
name = "distrofund_private_transfer.aleo"
|
||||
network = "testnet3"
|
||||
location = "network"
|
||||
checksum = "5885825ba7350bb57c70baa44730545eb57757fade520217516ace98c9a6c6e4"
|
||||
dependencies = ["credits.aleo"]
|
||||
|
||||
[[package]]
|
||||
name = "credits.aleo"
|
||||
network = "testnet3"
|
||||
location = "network"
|
||||
checksum = "2ac86d83bca4fbf2c021660875ea1e5b4e65c7a192d9bc020ab02a0f32c86f0d"
|
||||
dependencies = []
|
||||
|
||||
[[package]]
|
||||
name = "artgo_aigc_v1_3.aleo"
|
||||
network = "testnet3"
|
||||
location = "network"
|
||||
checksum = "ea21b4f760709e7ab91e824f6e277631cfb2fe8717c996269fd9fbe490ea1501"
|
||||
dependencies = ["credits.aleo"]
|
@ -1,13 +0,0 @@
|
||||
{
|
||||
"program": "transfer.aleo",
|
||||
"version": "0.0.0",
|
||||
"description": "",
|
||||
"license": "MIT",
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "artgo_aigc_v1_3.aleo",
|
||||
"location": "network",
|
||||
"network": "testnet3"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
import artgo_aigc_v1_3.aleo;
|
||||
import credits.aleo;
|
||||
|
||||
program transfer.aleo {
|
||||
|
||||
mapping balances: u64 => u64;
|
||||
|
||||
transition main(arg1: field, arg2: u64, arg3: address) -> artgo_aigc_v1_3.aleo/BidRecord {
|
||||
return artgo_aigc_v1_3.aleo/bid_order(arg1, arg2, arg3) then finalize();
|
||||
}
|
||||
finalize main() {
|
||||
Mapping::set(balances, 1u64, 1u64);
|
||||
}
|
||||
}
|
@ -1,312 +0,0 @@
|
||||
program credits.aleo;
|
||||
|
||||
mapping committee:
|
||||
key as address.public;
|
||||
value as committee_state.public;
|
||||
|
||||
struct committee_state:
|
||||
microcredits as u64;
|
||||
is_open as boolean;
|
||||
|
||||
mapping bonded:
|
||||
key as address.public;
|
||||
value as bond_state.public;
|
||||
|
||||
struct bond_state:
|
||||
validator as address;
|
||||
microcredits as u64;
|
||||
|
||||
mapping unbonding:
|
||||
key as address.public;
|
||||
value as unbond_state.public;
|
||||
|
||||
struct unbond_state:
|
||||
microcredits as u64;
|
||||
height as u32;
|
||||
|
||||
mapping account:
|
||||
key as address.public;
|
||||
value as u64.public;
|
||||
|
||||
record credits:
|
||||
owner as address.private;
|
||||
microcredits as u64.private;
|
||||
|
||||
function bond_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
gte r1 1000000u64 into r2;
|
||||
assert.eq r2 true ;
|
||||
async bond_public self.caller r0 r1 into r3;
|
||||
output r3 as credits.aleo/bond_public.future;
|
||||
|
||||
finalize bond_public:
|
||||
input r0 as address.public;
|
||||
input r1 as address.public;
|
||||
input r2 as u64.public;
|
||||
is.eq r0 r1 into r3;
|
||||
branch.eq r3 true to bond_validator;
|
||||
branch.eq r3 false to bond_delegator;
|
||||
position bond_validator;
|
||||
cast 0u64 true into r4 as committee_state;
|
||||
get.or_use committee[r0] r4 into r5;
|
||||
assert.eq r5.is_open true ;
|
||||
add r5.microcredits r2 into r6;
|
||||
cast r6 r5.is_open into r7 as committee_state;
|
||||
cast r1 0u64 into r8 as bond_state;
|
||||
get.or_use bonded[r0] r8 into r9;
|
||||
assert.eq r9.validator r1 ;
|
||||
add r9.microcredits r2 into r10;
|
||||
gte r10 1000000000000u64 into r11;
|
||||
assert.eq r11 true ;
|
||||
cast r1 r10 into r12 as bond_state;
|
||||
get account[r0] into r13;
|
||||
sub r13 r2 into r14;
|
||||
set r7 into committee[r0];
|
||||
set r12 into bonded[r0];
|
||||
set r14 into account[r0];
|
||||
branch.eq true true to end;
|
||||
position bond_delegator;
|
||||
contains committee[r0] into r15;
|
||||
assert.eq r15 false ;
|
||||
get committee[r1] into r16;
|
||||
assert.eq r16.is_open true ;
|
||||
add r16.microcredits r2 into r17;
|
||||
cast r17 r16.is_open into r18 as committee_state;
|
||||
cast r1 0u64 into r19 as bond_state;
|
||||
get.or_use bonded[r0] r19 into r20;
|
||||
assert.eq r20.validator r1 ;
|
||||
add r20.microcredits r2 into r21;
|
||||
gte r21 10000000u64 into r22;
|
||||
assert.eq r22 true ;
|
||||
cast r1 r21 into r23 as bond_state;
|
||||
get account[r0] into r24;
|
||||
sub r24 r2 into r25;
|
||||
set r18 into committee[r1];
|
||||
set r23 into bonded[r0];
|
||||
set r25 into account[r0];
|
||||
position end;
|
||||
|
||||
function unbond_public:
|
||||
input r0 as u64.public;
|
||||
async unbond_public self.caller r0 into r1;
|
||||
output r1 as credits.aleo/unbond_public.future;
|
||||
|
||||
finalize unbond_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
cast 0u64 0u32 into r2 as unbond_state;
|
||||
get.or_use unbonding[r0] r2 into r3;
|
||||
add block.height 360u32 into r4;
|
||||
contains committee[r0] into r5;
|
||||
branch.eq r5 true to unbond_validator;
|
||||
branch.eq r5 false to unbond_delegator;
|
||||
position unbond_validator;
|
||||
get committee[r0] into r6;
|
||||
sub r6.microcredits r1 into r7;
|
||||
get bonded[r0] into r8;
|
||||
assert.eq r8.validator r0 ;
|
||||
sub r8.microcredits r1 into r9;
|
||||
gte r9 1000000000000u64 into r10;
|
||||
branch.eq r10 true to decrement_validator;
|
||||
branch.eq r10 false to remove_validator;
|
||||
position decrement_validator;
|
||||
cast r7 r6.is_open into r11 as committee_state;
|
||||
set r11 into committee[r0];
|
||||
cast r0 r9 into r12 as bond_state;
|
||||
set r12 into bonded[r0];
|
||||
add r3.microcredits r1 into r13;
|
||||
cast r13 r4 into r14 as unbond_state;
|
||||
set r14 into unbonding[r0];
|
||||
branch.eq true true to end;
|
||||
position remove_validator;
|
||||
assert.eq r6.microcredits r8.microcredits ;
|
||||
remove committee[r0];
|
||||
remove bonded[r0];
|
||||
add r3.microcredits r8.microcredits into r15;
|
||||
cast r15 r4 into r16 as unbond_state;
|
||||
set r16 into unbonding[r0];
|
||||
branch.eq true true to end;
|
||||
position unbond_delegator;
|
||||
get bonded[r0] into r17;
|
||||
sub r17.microcredits r1 into r18;
|
||||
gte r18 10000000u64 into r19;
|
||||
branch.eq r19 true to decrement_delegator;
|
||||
branch.eq r19 false to remove_delegator;
|
||||
position decrement_delegator;
|
||||
get committee[r17.validator] into r20;
|
||||
sub r20.microcredits r1 into r21;
|
||||
cast r21 r20.is_open into r22 as committee_state;
|
||||
set r22 into committee[r17.validator];
|
||||
cast r17.validator r18 into r23 as bond_state;
|
||||
set r23 into bonded[r0];
|
||||
add r3.microcredits r1 into r24;
|
||||
cast r24 r4 into r25 as unbond_state;
|
||||
set r25 into unbonding[r0];
|
||||
branch.eq true true to end;
|
||||
position remove_delegator;
|
||||
get committee[r17.validator] into r26;
|
||||
sub r26.microcredits r17.microcredits into r27;
|
||||
cast r27 r26.is_open into r28 as committee_state;
|
||||
set r28 into committee[r17.validator];
|
||||
remove bonded[r0];
|
||||
add r3.microcredits r17.microcredits into r29;
|
||||
cast r29 r4 into r30 as unbond_state;
|
||||
set r30 into unbonding[r0];
|
||||
position end;
|
||||
|
||||
function unbond_delegator_as_validator:
|
||||
input r0 as address.public;
|
||||
async unbond_delegator_as_validator self.caller r0 into r1;
|
||||
output r1 as credits.aleo/unbond_delegator_as_validator.future;
|
||||
|
||||
finalize unbond_delegator_as_validator:
|
||||
input r0 as address.public;
|
||||
input r1 as address.public;
|
||||
get committee[r0] into r2;
|
||||
assert.eq r2.is_open false ;
|
||||
contains committee[r1] into r3;
|
||||
assert.eq r3 false ;
|
||||
get bonded[r1] into r4;
|
||||
assert.eq r4.validator r0 ;
|
||||
sub r2.microcredits r4.microcredits into r5;
|
||||
cast r5 r2.is_open into r6 as committee_state;
|
||||
cast 0u64 0u32 into r7 as unbond_state;
|
||||
get.or_use unbonding[r1] r7 into r8;
|
||||
add r8.microcredits r4.microcredits into r9;
|
||||
add block.height 360u32 into r10;
|
||||
cast r9 r10 into r11 as unbond_state;
|
||||
set r6 into committee[r0];
|
||||
remove bonded[r1];
|
||||
set r11 into unbonding[r1];
|
||||
|
||||
function claim_unbond_public:
|
||||
async claim_unbond_public self.caller into r0;
|
||||
output r0 as credits.aleo/claim_unbond_public.future;
|
||||
|
||||
finalize claim_unbond_public:
|
||||
input r0 as address.public;
|
||||
get unbonding[r0] into r1;
|
||||
gte block.height r1.height into r2;
|
||||
assert.eq r2 true ;
|
||||
get.or_use account[r0] 0u64 into r3;
|
||||
add r1.microcredits r3 into r4;
|
||||
set r4 into account[r0];
|
||||
remove unbonding[r0];
|
||||
|
||||
function set_validator_state:
|
||||
input r0 as boolean.public;
|
||||
async set_validator_state self.caller r0 into r1;
|
||||
output r1 as credits.aleo/set_validator_state.future;
|
||||
|
||||
finalize set_validator_state:
|
||||
input r0 as address.public;
|
||||
input r1 as boolean.public;
|
||||
get committee[r0] into r2;
|
||||
cast r2.microcredits r1 into r3 as committee_state;
|
||||
set r3 into committee[r0];
|
||||
|
||||
function transfer_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
async transfer_public self.caller r0 r1 into r2;
|
||||
output r2 as credits.aleo/transfer_public.future;
|
||||
|
||||
finalize transfer_public:
|
||||
input r0 as address.public;
|
||||
input r1 as address.public;
|
||||
input r2 as u64.public;
|
||||
get account[r0] into r3;
|
||||
sub r3 r2 into r4;
|
||||
set r4 into account[r0];
|
||||
get.or_use account[r1] 0u64 into r5;
|
||||
add r5 r2 into r6;
|
||||
set r6 into account[r1];
|
||||
|
||||
function transfer_private:
|
||||
input r0 as credits.record;
|
||||
input r1 as address.private;
|
||||
input r2 as u64.private;
|
||||
sub r0.microcredits r2 into r3;
|
||||
cast r1 r2 into r4 as credits.record;
|
||||
cast r0.owner r3 into r5 as credits.record;
|
||||
output r4 as credits.record;
|
||||
output r5 as credits.record;
|
||||
|
||||
function transfer_private_to_public:
|
||||
input r0 as credits.record;
|
||||
input r1 as address.public;
|
||||
input r2 as u64.public;
|
||||
sub r0.microcredits r2 into r3;
|
||||
cast r0.owner r3 into r4 as credits.record;
|
||||
async transfer_private_to_public r1 r2 into r5;
|
||||
output r4 as credits.record;
|
||||
output r5 as credits.aleo/transfer_private_to_public.future;
|
||||
|
||||
finalize transfer_private_to_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
get.or_use account[r0] 0u64 into r2;
|
||||
add r1 r2 into r3;
|
||||
set r3 into account[r0];
|
||||
|
||||
function transfer_public_to_private:
|
||||
input r0 as address.private;
|
||||
input r1 as u64.public;
|
||||
cast r0 r1 into r2 as credits.record;
|
||||
async transfer_public_to_private self.caller r1 into r3;
|
||||
output r2 as credits.record;
|
||||
output r3 as credits.aleo/transfer_public_to_private.future;
|
||||
|
||||
finalize transfer_public_to_private:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
get account[r0] into r2;
|
||||
sub r2 r1 into r3;
|
||||
set r3 into account[r0];
|
||||
|
||||
function join:
|
||||
input r0 as credits.record;
|
||||
input r1 as credits.record;
|
||||
add r0.microcredits r1.microcredits into r2;
|
||||
cast r0.owner r2 into r3 as credits.record;
|
||||
output r3 as credits.record;
|
||||
|
||||
function split:
|
||||
input r0 as credits.record;
|
||||
input r1 as u64.private;
|
||||
sub r0.microcredits r1 into r2;
|
||||
sub r2 10000u64 into r3;
|
||||
cast r0.owner r1 into r4 as credits.record;
|
||||
cast r0.owner r3 into r5 as credits.record;
|
||||
output r4 as credits.record;
|
||||
output r5 as credits.record;
|
||||
|
||||
function fee_private:
|
||||
input r0 as credits.record;
|
||||
input r1 as u64.public;
|
||||
input r2 as u64.public;
|
||||
input r3 as field.public;
|
||||
assert.neq r1 0u64 ;
|
||||
assert.neq r3 0field ;
|
||||
add r1 r2 into r4;
|
||||
sub r0.microcredits r4 into r5;
|
||||
cast r0.owner r5 into r6 as credits.record;
|
||||
output r6 as credits.record;
|
||||
|
||||
function fee_public:
|
||||
input r0 as u64.public;
|
||||
input r1 as u64.public;
|
||||
input r2 as field.public;
|
||||
assert.neq r0 0u64 ;
|
||||
assert.neq r2 0field ;
|
||||
add r0 r1 into r3;
|
||||
async fee_public self.caller r3 into r4;
|
||||
output r4 as credits.aleo/fee_public.future;
|
||||
|
||||
finalize fee_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
get account[r0] into r2;
|
||||
sub r2 r1 into r3;
|
||||
set r3 into account[r0];
|
@ -1,633 +0,0 @@
|
||||
import credits.aleo;
|
||||
|
||||
program distrofund_private_transfer.aleo;
|
||||
|
||||
struct Addresses1:
|
||||
address1 as address;
|
||||
|
||||
struct Addresses2:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
|
||||
struct Addresses3:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
|
||||
struct Addresses4:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
|
||||
struct Addresses5:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
|
||||
struct Addresses6:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
|
||||
struct Addresses7:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
|
||||
struct Addresses8:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
|
||||
struct Addresses9:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
address9 as address;
|
||||
|
||||
struct Addresses10:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
address9 as address;
|
||||
address10 as address;
|
||||
|
||||
struct Addresses11:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
address9 as address;
|
||||
address10 as address;
|
||||
address11 as address;
|
||||
|
||||
struct Addresses12:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
address9 as address;
|
||||
address10 as address;
|
||||
address11 as address;
|
||||
address12 as address;
|
||||
|
||||
struct Addresses13:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
address9 as address;
|
||||
address10 as address;
|
||||
address11 as address;
|
||||
address12 as address;
|
||||
address13 as address;
|
||||
|
||||
struct Addresses14:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
address9 as address;
|
||||
address10 as address;
|
||||
address11 as address;
|
||||
address12 as address;
|
||||
address13 as address;
|
||||
address14 as address;
|
||||
|
||||
struct Addresses15:
|
||||
address1 as address;
|
||||
address2 as address;
|
||||
address3 as address;
|
||||
address4 as address;
|
||||
address5 as address;
|
||||
address6 as address;
|
||||
address7 as address;
|
||||
address8 as address;
|
||||
address9 as address;
|
||||
address10 as address;
|
||||
address11 as address;
|
||||
address12 as address;
|
||||
address13 as address;
|
||||
address14 as address;
|
||||
address15 as address;
|
||||
|
||||
struct Amount1:
|
||||
amount1 as u64;
|
||||
|
||||
struct Amount2:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
|
||||
struct Amount3:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
|
||||
struct Amount4:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
|
||||
struct Amount5:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
|
||||
struct Amount6:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
|
||||
struct Amount7:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
|
||||
struct Amount8:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
|
||||
struct Amount9:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
amount9 as u64;
|
||||
|
||||
struct Amount10:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
amount9 as u64;
|
||||
amount10 as u64;
|
||||
|
||||
struct Amount11:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
amount9 as u64;
|
||||
amount10 as u64;
|
||||
amount11 as u64;
|
||||
|
||||
struct Amount12:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
amount9 as u64;
|
||||
amount10 as u64;
|
||||
amount11 as u64;
|
||||
amount12 as u64;
|
||||
|
||||
struct Amount13:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
amount9 as u64;
|
||||
amount10 as u64;
|
||||
amount11 as u64;
|
||||
amount12 as u64;
|
||||
amount13 as u64;
|
||||
|
||||
struct Amount14:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
amount9 as u64;
|
||||
amount10 as u64;
|
||||
amount11 as u64;
|
||||
amount12 as u64;
|
||||
amount13 as u64;
|
||||
amount14 as u64;
|
||||
|
||||
struct Amount15:
|
||||
amount1 as u64;
|
||||
amount2 as u64;
|
||||
amount3 as u64;
|
||||
amount4 as u64;
|
||||
amount5 as u64;
|
||||
amount6 as u64;
|
||||
amount7 as u64;
|
||||
amount8 as u64;
|
||||
amount9 as u64;
|
||||
amount10 as u64;
|
||||
amount11 as u64;
|
||||
amount12 as u64;
|
||||
amount13 as u64;
|
||||
amount14 as u64;
|
||||
amount15 as u64;
|
||||
|
||||
function transfer_one:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses1.public;
|
||||
input r2 as Amount1.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
output r4 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_two:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses2.public;
|
||||
input r2 as Amount2.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
output r6 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_three:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses3.public;
|
||||
input r2 as Amount3.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
output r8 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_four:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses4.public;
|
||||
input r2 as Amount4.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
output r10 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_five:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses5.public;
|
||||
input r2 as Amount5.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
output r12 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_six:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses6.public;
|
||||
input r2 as Amount6.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
output r14 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_seven:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses7.public;
|
||||
input r2 as Amount7.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
output r16 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_eight:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses8.public;
|
||||
input r2 as Amount8.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
output r18 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_nine:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses9.public;
|
||||
input r2 as Amount9.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
call credits.aleo/transfer_private r18 r1.address9 r2.amount9 into r19 r20;
|
||||
output r20 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
output r19 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_ten:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses10.public;
|
||||
input r2 as Amount10.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
call credits.aleo/transfer_private r18 r1.address9 r2.amount9 into r19 r20;
|
||||
call credits.aleo/transfer_private r20 r1.address10 r2.amount10 into r21 r22;
|
||||
output r22 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
output r19 as credits.aleo/credits.record;
|
||||
output r21 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_eleven:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses11.public;
|
||||
input r2 as Amount11.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
call credits.aleo/transfer_private r18 r1.address9 r2.amount9 into r19 r20;
|
||||
call credits.aleo/transfer_private r20 r1.address10 r2.amount10 into r21 r22;
|
||||
call credits.aleo/transfer_private r22 r1.address11 r2.amount11 into r23 r24;
|
||||
output r24 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
output r19 as credits.aleo/credits.record;
|
||||
output r21 as credits.aleo/credits.record;
|
||||
output r23 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_twelve:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses12.public;
|
||||
input r2 as Amount12.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
call credits.aleo/transfer_private r18 r1.address9 r2.amount9 into r19 r20;
|
||||
call credits.aleo/transfer_private r20 r1.address10 r2.amount10 into r21 r22;
|
||||
call credits.aleo/transfer_private r22 r1.address11 r2.amount11 into r23 r24;
|
||||
call credits.aleo/transfer_private r24 r1.address12 r2.amount12 into r25 r26;
|
||||
output r26 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
output r19 as credits.aleo/credits.record;
|
||||
output r21 as credits.aleo/credits.record;
|
||||
output r23 as credits.aleo/credits.record;
|
||||
output r25 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_thirteen:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses13.public;
|
||||
input r2 as Amount13.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
call credits.aleo/transfer_private r18 r1.address9 r2.amount9 into r19 r20;
|
||||
call credits.aleo/transfer_private r20 r1.address10 r2.amount10 into r21 r22;
|
||||
call credits.aleo/transfer_private r22 r1.address11 r2.amount11 into r23 r24;
|
||||
call credits.aleo/transfer_private r24 r1.address12 r2.amount12 into r25 r26;
|
||||
call credits.aleo/transfer_private r26 r1.address13 r2.amount13 into r27 r28;
|
||||
output r28 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
output r19 as credits.aleo/credits.record;
|
||||
output r21 as credits.aleo/credits.record;
|
||||
output r23 as credits.aleo/credits.record;
|
||||
output r25 as credits.aleo/credits.record;
|
||||
output r27 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_fourteen:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses14.public;
|
||||
input r2 as Amount14.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
call credits.aleo/transfer_private r18 r1.address9 r2.amount9 into r19 r20;
|
||||
call credits.aleo/transfer_private r20 r1.address10 r2.amount10 into r21 r22;
|
||||
call credits.aleo/transfer_private r22 r1.address11 r2.amount11 into r23 r24;
|
||||
call credits.aleo/transfer_private r24 r1.address12 r2.amount12 into r25 r26;
|
||||
call credits.aleo/transfer_private r26 r1.address13 r2.amount13 into r27 r28;
|
||||
call credits.aleo/transfer_private r28 r1.address14 r2.amount14 into r29 r30;
|
||||
output r30 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
output r19 as credits.aleo/credits.record;
|
||||
output r21 as credits.aleo/credits.record;
|
||||
output r23 as credits.aleo/credits.record;
|
||||
output r25 as credits.aleo/credits.record;
|
||||
output r27 as credits.aleo/credits.record;
|
||||
output r29 as credits.aleo/credits.record;
|
||||
|
||||
function transfer_fifteen:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as Addresses15.public;
|
||||
input r2 as Amount15.private;
|
||||
call credits.aleo/transfer_private r0 r1.address1 r2.amount1 into r3 r4;
|
||||
call credits.aleo/transfer_private r4 r1.address2 r2.amount2 into r5 r6;
|
||||
call credits.aleo/transfer_private r6 r1.address3 r2.amount3 into r7 r8;
|
||||
call credits.aleo/transfer_private r8 r1.address4 r2.amount4 into r9 r10;
|
||||
call credits.aleo/transfer_private r10 r1.address5 r2.amount5 into r11 r12;
|
||||
call credits.aleo/transfer_private r12 r1.address6 r2.amount6 into r13 r14;
|
||||
call credits.aleo/transfer_private r14 r1.address7 r2.amount7 into r15 r16;
|
||||
call credits.aleo/transfer_private r16 r1.address8 r2.amount8 into r17 r18;
|
||||
call credits.aleo/transfer_private r18 r1.address9 r2.amount9 into r19 r20;
|
||||
call credits.aleo/transfer_private r20 r1.address10 r2.amount10 into r21 r22;
|
||||
call credits.aleo/transfer_private r22 r1.address11 r2.amount11 into r23 r24;
|
||||
call credits.aleo/transfer_private r24 r1.address12 r2.amount12 into r25 r26;
|
||||
call credits.aleo/transfer_private r26 r1.address13 r2.amount13 into r27 r28;
|
||||
call credits.aleo/transfer_private r28 r1.address14 r2.amount14 into r29 r30;
|
||||
call credits.aleo/transfer_private r30 r1.address15 r2.amount15 into r31 r32;
|
||||
output r32 as credits.aleo/credits.record;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r5 as credits.aleo/credits.record;
|
||||
output r7 as credits.aleo/credits.record;
|
||||
output r9 as credits.aleo/credits.record;
|
||||
output r11 as credits.aleo/credits.record;
|
||||
output r13 as credits.aleo/credits.record;
|
||||
output r15 as credits.aleo/credits.record;
|
||||
output r17 as credits.aleo/credits.record;
|
||||
output r19 as credits.aleo/credits.record;
|
||||
output r21 as credits.aleo/credits.record;
|
||||
output r23 as credits.aleo/credits.record;
|
||||
output r25 as credits.aleo/credits.record;
|
||||
output r27 as credits.aleo/credits.record;
|
||||
output r29 as credits.aleo/credits.record;
|
||||
output r31 as credits.aleo/credits.record;
|
@ -1,45 +0,0 @@
|
||||
import credits.aleo;
|
||||
import distrofund_private_transfer.aleo;program simple.aleo;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function main:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as distrofund_private_transfer.aleo/Addresses1.struct;
|
||||
input r2 as distrofund_private_transfer.aleo/Amount1.struct;
|
||||
call distrofund_private_transfer.aleo/transfer_one r0 r1 r2 into r3 r4;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r4 as credits.aleo/credits.record;
|
@ -1,13 +0,0 @@
|
||||
{
|
||||
"program": "simple.aleo",
|
||||
"version": "0.0.0",
|
||||
"description": "",
|
||||
"license": "MIT",
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "distrofund_private_transfer.aleo",
|
||||
"location": "network",
|
||||
"network": "testnet3"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
[[package]]
|
||||
name = "distrofund_private_transfer.aleo"
|
||||
network = "testnet3"
|
||||
location = "network"
|
||||
checksum = "5885825ba7350bb57c70baa44730545eb57757fade520217516ace98c9a6c6e4"
|
||||
dependencies = ["credits.aleo"]
|
||||
|
||||
[[package]]
|
||||
name = "credits.aleo"
|
||||
network = "testnet3"
|
||||
location = "network"
|
||||
checksum = "2ac86d83bca4fbf2c021660875ea1e5b4e65c7a192d9bc020ab02a0f32c86f0d"
|
||||
dependencies = []
|
@ -1,13 +0,0 @@
|
||||
{
|
||||
"program": "simple.aleo",
|
||||
"version": "0.0.0",
|
||||
"description": "",
|
||||
"license": "MIT",
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "distrofund_private_transfer.aleo",
|
||||
"location": "network",
|
||||
"network": "testnet3"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
import distrofund_private_transfer.aleo;
|
||||
import credits.aleo;
|
||||
|
||||
program simple.aleo {
|
||||
transition main(arg1: credits.aleo/credits, arg2:distrofund_private_transfer.aleo/Addresses1, arg3:distrofund_private_transfer.aleo/Amount1) -> (credits.aleo/credits.record, credits.aleo/credits.record) {
|
||||
return distrofund_private_transfer.aleo/transfer_one(arg1, arg2, arg3);
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,312 +0,0 @@
|
||||
program credits.aleo;
|
||||
|
||||
mapping committee:
|
||||
key as address.public;
|
||||
value as committee_state.public;
|
||||
|
||||
struct committee_state:
|
||||
microcredits as u64;
|
||||
is_open as boolean;
|
||||
|
||||
mapping bonded:
|
||||
key as address.public;
|
||||
value as bond_state.public;
|
||||
|
||||
struct bond_state:
|
||||
validator as address;
|
||||
microcredits as u64;
|
||||
|
||||
mapping unbonding:
|
||||
key as address.public;
|
||||
value as unbond_state.public;
|
||||
|
||||
struct unbond_state:
|
||||
microcredits as u64;
|
||||
height as u32;
|
||||
|
||||
mapping account:
|
||||
key as address.public;
|
||||
value as u64.public;
|
||||
|
||||
record credits:
|
||||
owner as address.private;
|
||||
microcredits as u64.private;
|
||||
|
||||
function bond_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
gte r1 1000000u64 into r2;
|
||||
assert.eq r2 true ;
|
||||
async bond_public self.caller r0 r1 into r3;
|
||||
output r3 as credits.aleo/bond_public.future;
|
||||
|
||||
finalize bond_public:
|
||||
input r0 as address.public;
|
||||
input r1 as address.public;
|
||||
input r2 as u64.public;
|
||||
is.eq r0 r1 into r3;
|
||||
branch.eq r3 true to bond_validator;
|
||||
branch.eq r3 false to bond_delegator;
|
||||
position bond_validator;
|
||||
cast 0u64 true into r4 as committee_state;
|
||||
get.or_use committee[r0] r4 into r5;
|
||||
assert.eq r5.is_open true ;
|
||||
add r5.microcredits r2 into r6;
|
||||
cast r6 r5.is_open into r7 as committee_state;
|
||||
cast r1 0u64 into r8 as bond_state;
|
||||
get.or_use bonded[r0] r8 into r9;
|
||||
assert.eq r9.validator r1 ;
|
||||
add r9.microcredits r2 into r10;
|
||||
gte r10 1000000000000u64 into r11;
|
||||
assert.eq r11 true ;
|
||||
cast r1 r10 into r12 as bond_state;
|
||||
get account[r0] into r13;
|
||||
sub r13 r2 into r14;
|
||||
set r7 into committee[r0];
|
||||
set r12 into bonded[r0];
|
||||
set r14 into account[r0];
|
||||
branch.eq true true to end;
|
||||
position bond_delegator;
|
||||
contains committee[r0] into r15;
|
||||
assert.eq r15 false ;
|
||||
get committee[r1] into r16;
|
||||
assert.eq r16.is_open true ;
|
||||
add r16.microcredits r2 into r17;
|
||||
cast r17 r16.is_open into r18 as committee_state;
|
||||
cast r1 0u64 into r19 as bond_state;
|
||||
get.or_use bonded[r0] r19 into r20;
|
||||
assert.eq r20.validator r1 ;
|
||||
add r20.microcredits r2 into r21;
|
||||
gte r21 10000000u64 into r22;
|
||||
assert.eq r22 true ;
|
||||
cast r1 r21 into r23 as bond_state;
|
||||
get account[r0] into r24;
|
||||
sub r24 r2 into r25;
|
||||
set r18 into committee[r1];
|
||||
set r23 into bonded[r0];
|
||||
set r25 into account[r0];
|
||||
position end;
|
||||
|
||||
function unbond_public:
|
||||
input r0 as u64.public;
|
||||
async unbond_public self.caller r0 into r1;
|
||||
output r1 as credits.aleo/unbond_public.future;
|
||||
|
||||
finalize unbond_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
cast 0u64 0u32 into r2 as unbond_state;
|
||||
get.or_use unbonding[r0] r2 into r3;
|
||||
add block.height 360u32 into r4;
|
||||
contains committee[r0] into r5;
|
||||
branch.eq r5 true to unbond_validator;
|
||||
branch.eq r5 false to unbond_delegator;
|
||||
position unbond_validator;
|
||||
get committee[r0] into r6;
|
||||
sub r6.microcredits r1 into r7;
|
||||
get bonded[r0] into r8;
|
||||
assert.eq r8.validator r0 ;
|
||||
sub r8.microcredits r1 into r9;
|
||||
gte r9 1000000000000u64 into r10;
|
||||
branch.eq r10 true to decrement_validator;
|
||||
branch.eq r10 false to remove_validator;
|
||||
position decrement_validator;
|
||||
cast r7 r6.is_open into r11 as committee_state;
|
||||
set r11 into committee[r0];
|
||||
cast r0 r9 into r12 as bond_state;
|
||||
set r12 into bonded[r0];
|
||||
add r3.microcredits r1 into r13;
|
||||
cast r13 r4 into r14 as unbond_state;
|
||||
set r14 into unbonding[r0];
|
||||
branch.eq true true to end;
|
||||
position remove_validator;
|
||||
assert.eq r6.microcredits r8.microcredits ;
|
||||
remove committee[r0];
|
||||
remove bonded[r0];
|
||||
add r3.microcredits r8.microcredits into r15;
|
||||
cast r15 r4 into r16 as unbond_state;
|
||||
set r16 into unbonding[r0];
|
||||
branch.eq true true to end;
|
||||
position unbond_delegator;
|
||||
get bonded[r0] into r17;
|
||||
sub r17.microcredits r1 into r18;
|
||||
gte r18 10000000u64 into r19;
|
||||
branch.eq r19 true to decrement_delegator;
|
||||
branch.eq r19 false to remove_delegator;
|
||||
position decrement_delegator;
|
||||
get committee[r17.validator] into r20;
|
||||
sub r20.microcredits r1 into r21;
|
||||
cast r21 r20.is_open into r22 as committee_state;
|
||||
set r22 into committee[r17.validator];
|
||||
cast r17.validator r18 into r23 as bond_state;
|
||||
set r23 into bonded[r0];
|
||||
add r3.microcredits r1 into r24;
|
||||
cast r24 r4 into r25 as unbond_state;
|
||||
set r25 into unbonding[r0];
|
||||
branch.eq true true to end;
|
||||
position remove_delegator;
|
||||
get committee[r17.validator] into r26;
|
||||
sub r26.microcredits r17.microcredits into r27;
|
||||
cast r27 r26.is_open into r28 as committee_state;
|
||||
set r28 into committee[r17.validator];
|
||||
remove bonded[r0];
|
||||
add r3.microcredits r17.microcredits into r29;
|
||||
cast r29 r4 into r30 as unbond_state;
|
||||
set r30 into unbonding[r0];
|
||||
position end;
|
||||
|
||||
function unbond_delegator_as_validator:
|
||||
input r0 as address.public;
|
||||
async unbond_delegator_as_validator self.caller r0 into r1;
|
||||
output r1 as credits.aleo/unbond_delegator_as_validator.future;
|
||||
|
||||
finalize unbond_delegator_as_validator:
|
||||
input r0 as address.public;
|
||||
input r1 as address.public;
|
||||
get committee[r0] into r2;
|
||||
assert.eq r2.is_open false ;
|
||||
contains committee[r1] into r3;
|
||||
assert.eq r3 false ;
|
||||
get bonded[r1] into r4;
|
||||
assert.eq r4.validator r0 ;
|
||||
sub r2.microcredits r4.microcredits into r5;
|
||||
cast r5 r2.is_open into r6 as committee_state;
|
||||
cast 0u64 0u32 into r7 as unbond_state;
|
||||
get.or_use unbonding[r1] r7 into r8;
|
||||
add r8.microcredits r4.microcredits into r9;
|
||||
add block.height 360u32 into r10;
|
||||
cast r9 r10 into r11 as unbond_state;
|
||||
set r6 into committee[r0];
|
||||
remove bonded[r1];
|
||||
set r11 into unbonding[r1];
|
||||
|
||||
function claim_unbond_public:
|
||||
async claim_unbond_public self.caller into r0;
|
||||
output r0 as credits.aleo/claim_unbond_public.future;
|
||||
|
||||
finalize claim_unbond_public:
|
||||
input r0 as address.public;
|
||||
get unbonding[r0] into r1;
|
||||
gte block.height r1.height into r2;
|
||||
assert.eq r2 true ;
|
||||
get.or_use account[r0] 0u64 into r3;
|
||||
add r1.microcredits r3 into r4;
|
||||
set r4 into account[r0];
|
||||
remove unbonding[r0];
|
||||
|
||||
function set_validator_state:
|
||||
input r0 as boolean.public;
|
||||
async set_validator_state self.caller r0 into r1;
|
||||
output r1 as credits.aleo/set_validator_state.future;
|
||||
|
||||
finalize set_validator_state:
|
||||
input r0 as address.public;
|
||||
input r1 as boolean.public;
|
||||
get committee[r0] into r2;
|
||||
cast r2.microcredits r1 into r3 as committee_state;
|
||||
set r3 into committee[r0];
|
||||
|
||||
function transfer_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
async transfer_public self.caller r0 r1 into r2;
|
||||
output r2 as credits.aleo/transfer_public.future;
|
||||
|
||||
finalize transfer_public:
|
||||
input r0 as address.public;
|
||||
input r1 as address.public;
|
||||
input r2 as u64.public;
|
||||
get account[r0] into r3;
|
||||
sub r3 r2 into r4;
|
||||
set r4 into account[r0];
|
||||
get.or_use account[r1] 0u64 into r5;
|
||||
add r5 r2 into r6;
|
||||
set r6 into account[r1];
|
||||
|
||||
function transfer_private:
|
||||
input r0 as credits.record;
|
||||
input r1 as address.private;
|
||||
input r2 as u64.private;
|
||||
sub r0.microcredits r2 into r3;
|
||||
cast r1 r2 into r4 as credits.record;
|
||||
cast r0.owner r3 into r5 as credits.record;
|
||||
output r4 as credits.record;
|
||||
output r5 as credits.record;
|
||||
|
||||
function transfer_private_to_public:
|
||||
input r0 as credits.record;
|
||||
input r1 as address.public;
|
||||
input r2 as u64.public;
|
||||
sub r0.microcredits r2 into r3;
|
||||
cast r0.owner r3 into r4 as credits.record;
|
||||
async transfer_private_to_public r1 r2 into r5;
|
||||
output r4 as credits.record;
|
||||
output r5 as credits.aleo/transfer_private_to_public.future;
|
||||
|
||||
finalize transfer_private_to_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
get.or_use account[r0] 0u64 into r2;
|
||||
add r1 r2 into r3;
|
||||
set r3 into account[r0];
|
||||
|
||||
function transfer_public_to_private:
|
||||
input r0 as address.private;
|
||||
input r1 as u64.public;
|
||||
cast r0 r1 into r2 as credits.record;
|
||||
async transfer_public_to_private self.caller r1 into r3;
|
||||
output r2 as credits.record;
|
||||
output r3 as credits.aleo/transfer_public_to_private.future;
|
||||
|
||||
finalize transfer_public_to_private:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
get account[r0] into r2;
|
||||
sub r2 r1 into r3;
|
||||
set r3 into account[r0];
|
||||
|
||||
function join:
|
||||
input r0 as credits.record;
|
||||
input r1 as credits.record;
|
||||
add r0.microcredits r1.microcredits into r2;
|
||||
cast r0.owner r2 into r3 as credits.record;
|
||||
output r3 as credits.record;
|
||||
|
||||
function split:
|
||||
input r0 as credits.record;
|
||||
input r1 as u64.private;
|
||||
sub r0.microcredits r1 into r2;
|
||||
sub r2 10000u64 into r3;
|
||||
cast r0.owner r1 into r4 as credits.record;
|
||||
cast r0.owner r3 into r5 as credits.record;
|
||||
output r4 as credits.record;
|
||||
output r5 as credits.record;
|
||||
|
||||
function fee_private:
|
||||
input r0 as credits.record;
|
||||
input r1 as u64.public;
|
||||
input r2 as u64.public;
|
||||
input r3 as field.public;
|
||||
assert.neq r1 0u64 ;
|
||||
assert.neq r3 0field ;
|
||||
add r1 r2 into r4;
|
||||
sub r0.microcredits r4 into r5;
|
||||
cast r0.owner r5 into r6 as credits.record;
|
||||
output r6 as credits.record;
|
||||
|
||||
function fee_public:
|
||||
input r0 as u64.public;
|
||||
input r1 as u64.public;
|
||||
input r2 as field.public;
|
||||
assert.neq r0 0u64 ;
|
||||
assert.neq r2 0field ;
|
||||
add r0 r1 into r3;
|
||||
async fee_public self.caller r3 into r4;
|
||||
output r4 as credits.aleo/fee_public.future;
|
||||
|
||||
finalize fee_public:
|
||||
input r0 as address.public;
|
||||
input r1 as u64.public;
|
||||
get account[r0] into r2;
|
||||
sub r2 r1 into r3;
|
||||
set r3 into account[r0];
|
@ -1,15 +0,0 @@
|
||||
import credits.aleo;
|
||||
program super_simple.aleo;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function main:
|
||||
input r0 as credits.aleo/credits.record;
|
||||
input r1 as address.private;
|
||||
input r2 as u64.private;
|
||||
call credits.aleo/transfer_private r0 r1 r2 into r3 r4;
|
||||
output r3 as credits.aleo/credits.record;
|
||||
output r4 as credits.aleo/credits.record;
|
@ -1,13 +0,0 @@
|
||||
{
|
||||
"program": "super_simple.aleo",
|
||||
"version": "0.0.0",
|
||||
"description": "",
|
||||
"license": "MIT",
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "credits.aleo",
|
||||
"location": "network",
|
||||
"network": "testnet3"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
[[package]]
|
||||
name = "credits.aleo"
|
||||
network = "testnet3"
|
||||
location = "network"
|
||||
checksum = "2ac86d83bca4fbf2c021660875ea1e5b4e65c7a192d9bc020ab02a0f32c86f0d"
|
||||
dependencies = []
|
@ -1,13 +0,0 @@
|
||||
{
|
||||
"program": "super_simple.aleo",
|
||||
"version": "0.0.0",
|
||||
"description": "",
|
||||
"license": "MIT",
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "credits.aleo",
|
||||
"location": "network",
|
||||
"network": "testnet3"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
import credits.aleo;
|
||||
|
||||
program super_simple.aleo {
|
||||
transition main(arg1: credits.aleo/credits, arg2: address, arg3: u64) -> (credits.aleo/credits.record, credits.aleo/credits.record) {
|
||||
return credits.aleo/transfer_private(arg1, arg2, arg3);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user