diff --git a/.gitignore b/.gitignore index eb941c1cec9..0d645a96019 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Generated by Cargo # will have compiled files and executables **/*/target/ +**/*/json_abi_output.json target # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries diff --git a/Cargo.lock b/Cargo.lock index 92b0a32c84b..0579158bfe9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -800,17 +800,20 @@ name = "core_lang" version = "0.1.0" dependencies = [ "Inflector 0.11.4 (git+https://github.com/sezna/Inflector.git)", + "core-types", "derivative", "either", "fuel-asm", "fuel-vm", "hex", "lazy_static 1.4.0", + "line-col", "pest 2.1.3 (git+https://github.com/sezna/pest.git?rev=0ee8d107923f8979897efbd12e16a0eb99ea98b3)", "pest_derive", "petgraph", "sha2", "smallvec", + "source-span", "structopt 0.3.25", "thiserror", "uuid-b64", @@ -1213,6 +1216,7 @@ version = "0.1.0" dependencies = [ "annotate-snippets", "anyhow", + "core-types", "core_lang", "curl", "dirs 3.0.2", @@ -1230,6 +1234,8 @@ dependencies = [ "reqwest", "semver 1.0.4", "serde", + "serde_json", + "source-span", "structopt 0.3.25", "tar", "term-table", @@ -2159,6 +2165,12 @@ dependencies = [ "libc", ] +[[package]] +name = "numtoa" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" + [[package]] name = "object" version = "0.27.1" @@ -2627,6 +2639,15 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_termios" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8440d8acb4fd3d277125b4bd01a6f38aee8d814b3b5fc09b3f2b825d37d3fe8f" +dependencies = [ + "redox_syscall 0.2.10", +] + [[package]] name = "redox_users" version = "0.3.5" @@ -3056,6 +3077,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "source-span" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3afeb8b7a1ae2e8721f2193cc2291c9e00dd68511907fd8b807e2c8d42caa3c" +dependencies = [ + "termion", +] + [[package]] name = "spin" version = "0.9.2" @@ -3339,6 +3369,18 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "termion" +version = "1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "077185e2eac69c3f8379a4298e1e07cd36beb962290d4a51199acf0fdc10607e" +dependencies = [ + "libc", + "numtoa", + "redox_syscall 0.2.10", + "redox_termios", +] + [[package]] name = "test" version = "0.1.0" @@ -3349,6 +3391,7 @@ dependencies = [ "fuel-vm", "rand 0.8.4", "regex", + "serde_json", "tokio", ] diff --git a/Cargo.toml b/Cargo.toml index 0c7a76e9b2e..d5207af4e9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,8 +6,7 @@ members = [ "docstrings", "forc", "formatter", - "parser" -, + "parser", "sway-server", "test"] diff --git a/core_lang/Cargo.toml b/core_lang/Cargo.toml index b811f945cba..6d10cf280c9 100644 --- a/core_lang/Cargo.toml +++ b/core_lang/Cargo.toml @@ -24,6 +24,10 @@ smallvec = "1.7" structopt = { version = "0.3", default-features = false, optional = true } thiserror = "1.0" uuid-b64 = "0.1" +line-col = "0.2" +source-span = "2.4" +core-types = { path = "../core-types" } + [[bin]] name = "selector-debug" diff --git a/core_lang/src/error.rs b/core_lang/src/error.rs index 43b884a9bfe..ffed9afd06e 100644 --- a/core_lang/src/error.rs +++ b/core_lang/src/error.rs @@ -5,6 +5,11 @@ use crate::span::Span; use crate::style::{to_screaming_snake_case, to_snake_case, to_upper_camel_case}; use crate::type_engine::*; use crate::type_engine::{IntegerBits, TypeInfo}; +use line_col::LineColLookup; +use source_span::{ + fmt::{Formatter, Style}, + Position, +}; use std::fmt; use thiserror::Error; @@ -184,6 +189,34 @@ impl<'sc> CompileWarning<'sc> { self.span.end_pos().line_col().into(), ) } + + pub fn format(&self, fmt: &mut Formatter) -> source_span::fmt::Formatted { + let input = self.span.input(); + let chars = input.chars().map(|x| -> Result<_, ()> { Ok(x) }); + + let metrics = source_span::DEFAULT_METRICS; + let buffer = source_span::SourceBuffer::new(chars, Position::default(), metrics); + + for c in buffer.iter() { + let _ = c.unwrap(); // report eventual errors. + } + + let (start_pos, end_pos) = self.span(); + let lookup = LineColLookup::new(input); + let (start_line, start_col) = lookup.get(start_pos); + let (end_line, end_col) = lookup.get(end_pos - 1); + + let err_start = Position::new(start_line - 1, start_col - 1); + let err_end = Position::new(end_line - 1, end_col - 1); + let err_span = source_span::Span::new(err_start, err_end, err_end.next_column()); + fmt.add( + err_span, + Some(self.to_friendly_warning_string()), + Style::Warning, + ); + + fmt.render(buffer.iter(), buffer.span(), &metrics).unwrap() + } } #[derive(Debug, Clone, PartialEq, Hash)] @@ -977,4 +1010,32 @@ impl<'sc> CompileError<'sc> { self.internal_span().end_pos().line_col().into(), ) } + + pub fn format(&self, fmt: &mut Formatter) -> source_span::fmt::Formatted { + let input = self.internal_span().input(); + let chars = input.chars().map(Result::<_, String>::Ok); + + let metrics = source_span::DEFAULT_METRICS; + let buffer = source_span::SourceBuffer::new(chars, Position::default(), metrics); + + for c in buffer.iter() { + let _ = c.unwrap(); // report eventual errors. + } + + let (start_pos, end_pos) = self.span(); + let lookup = LineColLookup::new(input); + let (start_line, start_col) = lookup.get(start_pos); + let (end_line, end_col) = lookup.get(if end_pos == 0 { 0 } else { end_pos - 1 }); + + let err_start = Position::new(start_line - 1, start_col - 1); + let err_end = Position::new(end_line - 1, end_col - 1); + let err_span = source_span::Span::new(err_start, err_end, err_end.next_column()); + fmt.add( + err_span, + Some(self.to_friendly_error_string()), + Style::Error, + ); + + fmt.render(buffer.iter(), buffer.span(), &metrics).unwrap() + } } diff --git a/core_lang/src/lib.rs b/core_lang/src/lib.rs index 0c7d87b30e2..abac3bed634 100644 --- a/core_lang/src/lib.rs +++ b/core_lang/src/lib.rs @@ -29,7 +29,7 @@ use pest::Parser; use std::collections::{HashMap, HashSet}; pub use semantic_analysis::TreeType; -use semantic_analysis::TypedParseTree; +pub use semantic_analysis::TypedParseTree; pub mod types; pub(crate) mod utils; pub use crate::parse_tree::{Declaration, Expression, UseStatement, WhileLoop}; @@ -177,6 +177,18 @@ pub enum CompilationResult<'sc> { }, } +pub enum CompileAstResult<'sc> { + Success { + parse_tree: TypedParseTree<'sc>, + tree_type: TreeType<'sc>, + warnings: Vec>, + }, + Failure { + warnings: Vec>, + errors: Vec>, + }, +} + /// Represents the result of compiling Sway code via `compile_to_bytecode`. /// Contains the compiled bytecode in byte form, or, resulting errors, and any warnings generated. pub enum BytecodeCompilationResult<'sc> { @@ -297,19 +309,17 @@ pub(crate) fn compile_inner_dependency<'sc>( ) } -/// Given input Sway source code, compile to a [CompilationResult] which contains the asm in opcode -/// form (not raw bytes/bytecode). -pub fn compile_to_asm<'sc>( +pub fn compile_to_ast<'sc>( input: &'sc str, initial_namespace: &Namespace<'sc>, - build_config: BuildConfig, + build_config: &BuildConfig, dependency_graph: &mut HashMap>, -) -> CompilationResult<'sc> { +) -> CompileAstResult<'sc> { let mut warnings = Vec::new(); let mut errors = Vec::new(); let parse_tree = check!( - parse(input, Some(&build_config)), - return CompilationResult::Failure { errors, warnings }, + parse(input, Some(build_config)), + return CompileAstResult::Failure { errors, warnings }, warnings, errors ); @@ -328,7 +338,7 @@ pub fn compile_to_asm<'sc>( &mut dead_code_graph, dependency_graph, ), - return CompilationResult::Failure { errors, warnings }, + return CompileAstResult::Failure { errors, warnings }, warnings, errors ); @@ -345,26 +355,54 @@ pub fn compile_to_asm<'sc>( warnings = dedup_unsorted(warnings); if !errors.is_empty() { - return CompilationResult::Failure { errors, warnings }; + return CompileAstResult::Failure { errors, warnings }; } - match parse_tree.tree_type { - TreeType::Contract | TreeType::Script | TreeType::Predicate => { - let asm = check!( - compile_ast_to_asm(typed_parse_tree, &build_config), - return CompilationResult::Failure { errors, warnings }, - warnings, - errors - ); - if !errors.is_empty() { - return CompilationResult::Failure { errors, warnings }; + + CompileAstResult::Success { + parse_tree: typed_parse_tree, + tree_type: parse_tree.tree_type, + warnings, + } +} + +/// Given input Sway source code, compile to a [CompilationResult] which contains the asm in opcode +/// form (not raw bytes/bytecode). +pub fn compile_to_asm<'sc>( + input: &'sc str, + initial_namespace: &Namespace<'sc>, + build_config: BuildConfig, + dependency_graph: &mut HashMap>, +) -> CompilationResult<'sc> { + match compile_to_ast(input, initial_namespace, &build_config, dependency_graph) { + CompileAstResult::Failure { warnings, errors } => { + CompilationResult::Failure { warnings, errors } + } + CompileAstResult::Success { + parse_tree, + tree_type, + mut warnings, + } => { + let mut errors = vec![]; + match tree_type { + TreeType::Contract | TreeType::Script | TreeType::Predicate => { + let asm = check!( + compile_ast_to_asm(parse_tree, &build_config), + return CompilationResult::Failure { errors, warnings }, + warnings, + errors + ); + if !errors.is_empty() { + return CompilationResult::Failure { errors, warnings }; + } + CompilationResult::Success { asm, warnings } + } + TreeType::Library { name } => CompilationResult::Library { + warnings, + name, + namespace: parse_tree.into_namespace(), + }, } - CompilationResult::Success { asm, warnings } } - TreeType::Library { name } => CompilationResult::Library { - warnings, - name, - namespace: typed_parse_tree.into_namespace(), - }, } } diff --git a/core_lang/src/parse_tree/declaration/function.rs b/core_lang/src/parse_tree/declaration/function.rs index 848c8c159b4..bd942a9d1b6 100644 --- a/core_lang/src/parse_tree/declaration/function.rs +++ b/core_lang/src/parse_tree/declaration/function.rs @@ -5,6 +5,7 @@ use crate::span::Span; use crate::style::is_snake_case; use crate::type_engine::TypeInfo; use crate::{CodeBlock, Ident, Rule}; +use core_types::{Function, Property}; use pest::iterators::Pair; #[derive(Debug, Clone)] @@ -187,6 +188,27 @@ impl<'sc> FunctionDeclaration<'sc> { errors, ) } + + pub fn parse_json_abi(&self) -> Function { + Function { + name: self.name.primary_name.to_string(), + type_field: "function".to_string(), + inputs: self + .parameters + .iter() + .map(|x| Property { + name: x.name.primary_name.to_string(), + type_field: x.r#type.friendly_type_str(), + components: None, + }) + .collect(), + outputs: vec![Property { + name: "".to_string(), + type_field: self.return_type.friendly_type_str(), + components: None, + }], + } + } } #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/core_lang/src/semantic_analysis.rs b/core_lang/src/semantic_analysis.rs index 608b79eab49..1d047f214ba 100644 --- a/core_lang/src/semantic_analysis.rs +++ b/core_lang/src/semantic_analysis.rs @@ -7,6 +7,6 @@ pub(crate) use ast_node::{TypedAstNode, TypedAstNodeContent, TypedExpression}; pub use ast_node::{TypedConstantDeclaration, TypedDeclaration, TypedFunctionDeclaration}; pub use namespace::Namespace; pub use syntax_tree::TreeType; -pub(crate) use syntax_tree::TypedParseTree; +pub use syntax_tree::TypedParseTree; const ERROR_RECOVERY_DECLARATION: TypedDeclaration = TypedDeclaration::ErrorRecovery; diff --git a/core_lang/src/semantic_analysis/ast_node/declaration.rs b/core_lang/src/semantic_analysis/ast_node/declaration.rs index a33aca12e74..820a1a2da4c 100644 --- a/core_lang/src/semantic_analysis/ast_node/declaration.rs +++ b/core_lang/src/semantic_analysis/ast_node/declaration.rs @@ -2,12 +2,14 @@ use super::impl_trait::Mode; use super::{ IsConstant, TypedCodeBlock, TypedExpression, TypedExpressionVariant, TypedReturnStatement, }; -use crate::control_flow_analysis::ControlFlowGraph; use crate::parse_tree::*; use crate::semantic_analysis::Namespace; use crate::span::Span; use crate::type_engine::*; +use crate::ControlFlowGraph; use crate::{build_config::BuildConfig, error::*, Ident}; + +use core_types::{Function, Property}; use sha2::{Digest, Sha256}; use std::collections::{HashMap, HashSet}; @@ -278,6 +280,14 @@ impl OwnedTypedStructField { span: span.clone(), } } + + pub fn generate_json_abi(&self) -> Property { + Property { + name: self.name.clone(), + type_field: self.r#type.friendly_type_str(), + components: self.r#type.generate_json_abi(), + } + } } impl TypedStructField<'_> { @@ -365,6 +375,16 @@ pub struct OwnedTypedEnumVariant { pub(crate) tag: usize, } +impl OwnedTypedEnumVariant { + pub fn generate_json_abi(&self) -> Property { + Property { + name: self.name.clone(), + type_field: self.r#type.friendly_type_str(), + components: self.r#type.generate_json_abi(), + } + } +} + #[derive(Clone, Debug)] pub struct TypedConstantDeclaration<'sc> { pub(crate) name: Ident<'sc>, @@ -579,6 +599,27 @@ impl<'sc> TypedFunctionDeclaration<'sc> { errors, ) } + + pub fn generate_json_abi(&self) -> Function { + Function { + name: self.name.primary_name.to_string(), + type_field: "function".to_string(), + inputs: self + .parameters + .iter() + .map(|x| Property { + name: x.name.primary_name.to_string(), + type_field: x.r#type.friendly_type_str(), + components: x.r#type.generate_json_abi(), + }) + .collect(), + outputs: vec![Property { + name: "".to_string(), + type_field: self.return_type.friendly_type_str(), + components: self.return_type.generate_json_abi(), + }], + } + } } #[test] @@ -868,7 +909,7 @@ impl<'sc> TypedFunctionDeclaration<'sc> { self_type, build_config, dead_code_graph, - dependency_graph + dependency_graph, ), ( TypedCodeBlock { diff --git a/core_lang/src/semantic_analysis/ast_node/expression/enum_instantiation.rs b/core_lang/src/semantic_analysis/ast_node/expression/enum_instantiation.rs index 0ce975f816c..4e37a4b3e17 100644 --- a/core_lang/src/semantic_analysis/ast_node/expression/enum_instantiation.rs +++ b/core_lang/src/semantic_analysis/ast_node/expression/enum_instantiation.rs @@ -73,7 +73,7 @@ pub(crate) fn instantiate_enum<'n, 'sc>( self_type, build_config, dead_code_graph, - dependency_graph + dependency_graph, ), return err(warnings, errors), warnings, diff --git a/core_lang/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs b/core_lang/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs index fe97b08e41f..8556d91c9ee 100644 --- a/core_lang/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs +++ b/core_lang/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs @@ -32,7 +32,7 @@ pub(crate) fn type_check_method_application<'n, 'sc>( self_type, build_config, dead_code_graph, - dependency_graph + dependency_graph, ), error_recovery_expr(span.clone()), warnings, @@ -253,7 +253,7 @@ pub(crate) fn type_check_method_application<'n, 'sc>( crate_namespace, self_type, dead_code_graph, - dependency_graph + dependency_graph, ), return err(warnings, errors), warnings, diff --git a/core_lang/src/semantic_analysis/ast_node/impl_trait.rs b/core_lang/src/semantic_analysis/ast_node/impl_trait.rs index 7e3caac29ef..6b380d88b80 100644 --- a/core_lang/src/semantic_analysis/ast_node/impl_trait.rs +++ b/core_lang/src/semantic_analysis/ast_node/impl_trait.rs @@ -69,7 +69,7 @@ pub(crate) fn implementation_of_trait<'n, 'sc>( type_implementing_for_id, &type_implementing_for_span, Mode::NonAbi, - dependency_graph + dependency_graph, ), return err(warnings, errors), warnings, @@ -129,7 +129,7 @@ pub(crate) fn implementation_of_trait<'n, 'sc>( type_implementing_for_id, &type_implementing_for_span, Mode::ImplAbiFn, - dependency_graph + dependency_graph, ), return err(warnings, errors), warnings, @@ -214,7 +214,7 @@ fn type_check_trait_implementation<'n, 'sc>( build_config, dead_code_graph, mode, - dependency_graph + dependency_graph, ), continue, warnings, @@ -379,7 +379,7 @@ fn type_check_trait_implementation<'n, 'sc>( build_config, dead_code_graph, mode, - dependency_graph + dependency_graph, ), continue, warnings, diff --git a/core_lang/src/semantic_analysis/syntax_tree.rs b/core_lang/src/semantic_analysis/syntax_tree.rs index f7cf3e40b6d..0c3100428c4 100644 --- a/core_lang/src/semantic_analysis/syntax_tree.rs +++ b/core_lang/src/semantic_analysis/syntax_tree.rs @@ -7,6 +7,7 @@ use crate::semantic_analysis::Namespace; use crate::span::Span; use crate::{error::*, type_engine::*}; use crate::{AstNode, ParseTree}; + use std::collections::{HashMap, HashSet}; #[derive(Clone, Debug, PartialEq, Eq)] @@ -17,8 +18,8 @@ pub enum TreeType<'sc> { Library { name: Ident<'sc> }, } -#[derive(Debug)] -pub(crate) enum TypedParseTree<'sc> { +#[derive(Debug, Clone)] +pub enum TypedParseTree<'sc> { Script { main_function: TypedFunctionDeclaration<'sc>, namespace: Namespace<'sc>, @@ -57,7 +58,7 @@ impl<'sc> TypedParseTree<'sc> { } } - pub(crate) fn into_namespace(self) -> Namespace<'sc> { + pub fn into_namespace(self) -> Namespace<'sc> { use TypedParseTree::*; match self { Library { namespace, .. } => namespace, @@ -91,7 +92,7 @@ impl<'sc> TypedParseTree<'sc> { &mut new_namespace, build_config, dead_code_graph, - dependency_graph + dependency_graph, ), return err(warnings, errors), warnings, diff --git a/core_lang/src/type_engine.rs b/core_lang/src/type_engine.rs index d37e6f49086..a90770b2add 100644 --- a/core_lang/src/type_engine.rs +++ b/core_lang/src/type_engine.rs @@ -5,6 +5,7 @@ use std::iter::FromIterator; mod engine; mod integer_bits; mod type_info; +use core_types::Property; pub(crate) use engine::*; pub use integer_bits::*; pub use type_info::*; @@ -22,6 +23,27 @@ impl FriendlyTypeString for TypeId { } } +pub(crate) trait ToJsonAbi { + fn generate_json_abi(&self) -> Option>; +} + +impl ToJsonAbi for TypeId { + fn generate_json_abi(&self) -> Option> { + match look_up_type_id(*self) { + TypeInfo::Struct { fields, .. } => { + Some(fields.iter().map(|x| x.generate_json_abi()).collect()) + } + TypeInfo::Enum { variant_types, .. } => Some( + variant_types + .iter() + .map(|x| x.generate_json_abi()) + .collect(), + ), + _ => None, + } + } +} + #[test] fn basic_numeric_unknown() { let engine = Engine::default(); diff --git a/forc/Cargo.toml b/forc/Cargo.toml index ea5213176b5..030d116ade2 100644 --- a/forc/Cargo.toml +++ b/forc/Cargo.toml @@ -24,7 +24,9 @@ pest = { git = "https://github.com/sezna/pest.git", rev = "8aa58791f759daf4caee2 prettydiff = "0.4.0" reqwest = { version = "0.11.4", features = ["json"] } semver = "1.0.3" -serde = { version = "1.0", features = ["derive"] } +serde = {version = "1.0", features = ["derive"]} +serde_json = "*" +source-span = "2.4" structopt = "0.3" tar = "0.4.35" term-table = "1.3" @@ -32,6 +34,7 @@ termcolor = "1.1" tokio = { version = "1.8.0", features = ["macros", "rt-multi-thread", "process"] } toml = "0.5" whoami = "1.1" +core-types = { path = "../core-types" } [features] default = [] diff --git a/forc/src/cli/commands/json_abi.rs b/forc/src/cli/commands/json_abi.rs new file mode 100644 index 00000000000..c799020ba2b --- /dev/null +++ b/forc/src/cli/commands/json_abi.rs @@ -0,0 +1,25 @@ +use crate::ops::forc_abi_json; +use structopt::{self, StructOpt}; + +/// Output the JSON associated with the ABI. +#[derive(Debug, StructOpt)] +pub struct Command { + /// Path to the project, if not specified, current working directory will be used. + #[structopt(short, long)] + pub path: Option, + /// If set, outputs a json file representing the output json abi. + #[structopt(short = "o")] + pub json_outfile: Option, + /// Offline mode, prevents Forc from using the network when managing dependencies. + /// Meaning it will only try to use previously downloaded dependencies. + #[structopt(long = "offline")] + pub offline_mode: bool, + /// Silent mode. Don't output any warnings or errors to the command line. + #[structopt(long = "silent", short = "s")] + pub silent_mode: bool, +} + +pub(crate) fn exec(command: Command) -> Result<(), String> { + forc_abi_json::build(command)?; + Ok(()) +} diff --git a/forc/src/cli/commands/mod.rs b/forc/src/cli/commands/mod.rs index 6b1eb6861d9..0e188a7aca9 100644 --- a/forc/src/cli/commands/mod.rs +++ b/forc/src/cli/commands/mod.rs @@ -2,6 +2,7 @@ pub mod build; pub mod deploy; pub mod format; pub mod init; +pub mod json_abi; pub mod parse_bytecode; pub mod run; pub mod test; diff --git a/forc/src/cli/mod.rs b/forc/src/cli/mod.rs index a7310c3c487..4d33852fcae 100644 --- a/forc/src/cli/mod.rs +++ b/forc/src/cli/mod.rs @@ -1,12 +1,13 @@ use structopt::StructOpt; mod commands; -use self::commands::{build, deploy, format, init, parse_bytecode, run, test, update}; +use self::commands::{build, deploy, format, init, json_abi, parse_bytecode, run, test, update}; pub use build::Command as BuildCommand; pub use deploy::Command as DeployCommand; pub use format::Command as FormatCommand; use init::Command as InitCommand; +pub use json_abi::Command as JsonAbiCommand; use parse_bytecode::Command as ParseBytecodeCommand; pub use run::Command as RunCommand; use test::Command as TestCommand; @@ -31,6 +32,7 @@ enum Forc { Run(RunCommand), Test(TestCommand), Update(UpdateCommand), + JsonAbi(JsonAbiCommand), } pub(crate) async fn run_cli() -> Result<(), String> { @@ -44,6 +46,7 @@ pub(crate) async fn run_cli() -> Result<(), String> { Forc::Run(command) => run::exec(command).await, Forc::Test(command) => test::exec(command), Forc::Update(command) => update::exec(command).await, + Forc::JsonAbi(command) => json_abi::exec(command), }?; Ok(()) diff --git a/forc/src/lib.rs b/forc/src/lib.rs index 9ff686e68e4..b8cabdf4d1d 100644 --- a/forc/src/lib.rs +++ b/forc/src/lib.rs @@ -5,8 +5,8 @@ mod utils; #[cfg(feature = "test")] pub mod test { - pub use crate::cli::{BuildCommand, DeployCommand, RunCommand}; - pub use crate::ops::{forc_build, forc_deploy, forc_run}; + pub use crate::cli::{BuildCommand, DeployCommand, JsonAbiCommand, RunCommand}; + pub use crate::ops::{forc_abi_json, forc_build, forc_deploy, forc_run}; } #[cfg(feature = "util")] diff --git a/forc/src/ops/forc_abi_json.rs b/forc/src/ops/forc_abi_json.rs new file mode 100644 index 00000000000..6a771c3dbe6 --- /dev/null +++ b/forc/src/ops/forc_abi_json.rs @@ -0,0 +1,298 @@ +use crate::utils::dependency::{Dependency, DependencyDetails}; +use crate::{ + cli::JsonAbiCommand, + utils::dependency, + utils::helpers::{ + find_file_name, find_main_path, find_manifest_dir, get_main_file, print_on_failure, + print_on_success, read_manifest, + }, +}; + +use core_types::{Function, JsonABI}; + +use anyhow::Result; +use core_lang::{BuildConfig, CompileAstResult, Namespace, TreeType, TypedParseTree}; +use serde_json::{json, Value}; +use std::collections::{HashMap, HashSet}; +use std::fs::File; +use std::path::{Path, PathBuf}; + +pub fn build(command: JsonAbiCommand) -> Result { + // find manifest directory, even if in subdirectory + let this_dir = if let Some(ref path) = command.path { + PathBuf::from(path) + } else { + std::env::current_dir().map_err(|e| format!("{:?}", e))? + }; + + let JsonAbiCommand { + json_outfile, + offline_mode, + silent_mode, + .. + } = command; + + let manifest_dir = match find_manifest_dir(&this_dir) { + Some(dir) => dir, + None => { + return Err(format!( + "No manifest file found in this directory or any parent directories of it: {:?}", + this_dir + )) + } + }; + let mut manifest = read_manifest(&manifest_dir)?; + let main_path = find_main_path(&manifest_dir, &manifest); + let file_name = find_file_name(&manifest_dir, &main_path)?; + + let build_config = BuildConfig::root_from_file_name_and_manifest_path( + file_name.to_owned(), + manifest_dir.clone(), + ); + + let mut dependency_graph = HashMap::new(); + let mut json_abi = vec![]; + + let mut namespace: Namespace = Default::default(); + if let Some(ref mut deps) = manifest.dependencies { + for (dependency_name, dependency_details) in deps.iter_mut() { + // Check if dependency is a git-based dependency. + let dep = match dependency_details { + Dependency::Simple(..) => { + return Err( + "Not yet implemented: Simple version-spec dependencies require a registry." + .into(), + ); + } + Dependency::Detailed(dep_details) => dep_details, + }; + + // Download a non-local dependency if the `git` property is set in this dependency. + if let Some(git) = &dep.git { + let downloaded_dep_path = match dependency::download_github_dep( + dependency_name, + git, + &dep.branch, + &dep.version, + offline_mode.into(), + ) { + Ok(path) => path, + Err(e) => { + return Err(format!( + "Couldn't download dependency ({:?}): {:?}", + dependency_name, e + )) + } + }; + + // Mutate this dependency's path to hold the newly downloaded dependency's path. + dep.path = Some(downloaded_dep_path); + } + + json_abi.append(&mut compile_dependency_lib( + &this_dir, + dependency_name, + dependency_details, + &mut namespace, + &mut dependency_graph, + silent_mode, + )?); + } + } + + // now, compile this program with all of its dependencies + let main_file = get_main_file(&manifest, &manifest_dir)?; + + json_abi.append(&mut compile( + main_file, + &manifest.project.name, + &namespace, + build_config, + &mut dependency_graph, + silent_mode, + )?); + + let output_json = json!(json_abi); + + if let Some(outfile) = json_outfile { + let file = File::create(outfile).map_err(|e| e.to_string())?; + serde_json::to_writer(&file, &output_json.clone()).map_err(|e| e.to_string())?; + } else { + println!("{}", output_json); + } + + Ok(output_json) +} + +/// Takes a dependency and returns a namespace of exported things from that dependency +/// trait implementations are included as well +fn compile_dependency_lib<'source, 'manifest>( + project_file_path: &Path, + dependency_name: &'manifest str, + dependency_lib: &Dependency, + namespace: &mut Namespace<'source>, + dependency_graph: &mut HashMap>, + silent_mode: bool, +) -> Result, String> { + let dep_path = match dependency_lib { + Dependency::Simple(..) => { + return Err( + "Not yet implemented: Simple version-spec dependencies require a registry.".into(), + ) + } + Dependency::Detailed(DependencyDetails { path, .. }) => path, + }; + + let dep_path = + match dep_path { + Some(p) => p, + None => return Err( + "Only simple path imports are supported right now. Please supply a path relative \ + to the manifest file." + .into(), + ), + }; + + // dependency paths are relative to the path of the project being compiled + let mut project_path = PathBuf::from(project_file_path); + project_path.push(dep_path); + + // compile the dependencies of this dependency + // this should detect circular dependencies + let manifest_dir = match find_manifest_dir(&project_path) { + Some(o) => o, + None => { + return Err(format!( + "Manifest not found for dependency {:?}.", + project_path + )) + } + }; + let manifest_of_dep = read_manifest(&manifest_dir)?; + let main_path = find_main_path(&manifest_dir, &manifest_of_dep); + let file_name = find_file_name(&manifest_dir, &main_path)?; + + let build_config = BuildConfig::root_from_file_name_and_manifest_path( + file_name.to_owned(), + manifest_dir.clone(), + ); + let mut dep_namespace = namespace.clone(); + + // The part below here is just a massive shortcut to get the standard library working + if let Some(ref deps) = manifest_of_dep.dependencies { + for dep in deps { + // to do this properly, iterate over list of dependencies make sure there are no + // circular dependencies + //return Err("Unimplemented: dependencies that have dependencies".into()); + compile_dependency_lib( + &manifest_dir, + dep.0, + dep.1, + // give it a cloned namespace, which we then merge with this namespace + &mut dep_namespace, + dependency_graph, + silent_mode, + )?; + } + } + + let main_file = get_main_file(&manifest_of_dep, &manifest_dir)?; + + let (compiled, json_abi) = compile_library( + main_file, + &manifest_of_dep.project.name, + &dep_namespace, + build_config.clone(), + dependency_graph, + silent_mode, + )?; + + namespace.insert_dependency_module(dependency_name.to_string(), compiled); + + // nothing is returned from this method since it mutates the hashmaps it was given + Ok(json_abi) +} + +fn compile_library<'source, 'manifest>( + source: &'source str, + proj_name: &str, + namespace: &Namespace<'source>, + build_config: BuildConfig, + dependency_graph: &mut HashMap>, + silent_mode: bool, +) -> Result<(Namespace<'source>, Vec), String> { + let res = core_lang::compile_to_ast(source, namespace, &build_config, dependency_graph); + match res { + CompileAstResult::Success { + parse_tree, + tree_type, + warnings, + } => { + let errors = vec![]; + match tree_type { + TreeType::Library { name } => { + print_on_success( + silent_mode, + proj_name, + warnings, + TreeType::Library { name: name.clone() }, + ); + let json_abi = generate_json_abi(&Some(parse_tree.clone())); + Ok((parse_tree.into_namespace(), json_abi)) + } + _ => { + print_on_failure(silent_mode, warnings, errors); + Err(format!("Failed to compile {}", proj_name)) + } + } + } + CompileAstResult::Failure { warnings, errors } => { + print_on_failure(silent_mode, warnings, errors); + Err(format!("Failed to compile {}", proj_name)) + } + } +} + +fn compile<'source, 'manifest>( + source: &'source str, + proj_name: &str, + namespace: &Namespace<'source>, + build_config: BuildConfig, + dependency_graph: &mut HashMap>, + silent_mode: bool, +) -> Result, String> { + let res = core_lang::compile_to_ast(&source, namespace, &build_config, dependency_graph); + match res { + CompileAstResult::Success { + parse_tree, + tree_type, + warnings, + } => { + let errors = vec![]; + match tree_type { + TreeType::Library { .. } => { + print_on_failure(silent_mode, warnings, errors); + Err(format!("Failed to compile {}", proj_name)) + } + typ => { + print_on_success(silent_mode, proj_name, warnings, typ); + let json_abi = generate_json_abi(&Some(parse_tree)); + Ok(json_abi) + } + } + } + CompileAstResult::Failure { warnings, errors } => { + print_on_failure(silent_mode, warnings, errors); + Err(format!("Failed to compile {}", proj_name)) + } + } +} + +fn generate_json_abi(ast: &Option) -> JsonABI { + match ast { + Some(TypedParseTree::Contract { abi_entries, .. }) => { + abi_entries.iter().map(|x| x.generate_json_abi()).collect() + } + _ => vec![], + } +} diff --git a/forc/src/ops/forc_build.rs b/forc/src/ops/forc_build.rs index 44d9385602e..c4e88af5fa4 100644 --- a/forc/src/ops/forc_build.rs +++ b/forc/src/ops/forc_build.rs @@ -3,21 +3,18 @@ use crate::{ cli::BuildCommand, utils::dependency, utils::helpers::{ - find_manifest_dir, get_main_file, println_green_err, println_red_err, println_yellow_err, - read_manifest, + find_manifest_dir, get_main_file, print_on_failure, print_on_success, + print_on_success_library, read_manifest, }, }; -use annotate_snippets::{ - display_list::{DisplayList, FormatOptions}, - snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation}, -}; -use core_lang::FinalizedAsm; +use core_lang::{FinalizedAsm, TreeType}; use std::fs::File; use std::io::Write; -use anyhow::Result; use core_lang::{BuildConfig, BytecodeCompilationResult, CompilationResult, Namespace}; + +use anyhow::Result; use std::collections::{HashMap, HashSet}; use std::path::{Path, PathBuf}; @@ -255,40 +252,11 @@ fn compile_library<'source>( warnings, .. } => { - if !silent_mode { - warnings.iter().for_each(format_warning); - } - - if warnings.is_empty() { - let _ = println_green_err(&format!(" Compiled library {:?}.", proj_name)); - } else { - let _ = println_yellow_err(&format!( - " Compiled library {:?} with {} {}.", - proj_name, - warnings.len(), - if warnings.len() > 1 { - "warnings" - } else { - "warning" - } - )); - } + print_on_success_library(silent_mode, proj_name, warnings); Ok(namespace) } CompilationResult::Failure { errors, warnings } => { - let e_len = errors.len(); - - if !silent_mode { - warnings.iter().for_each(format_warning); - errors.iter().for_each(format_err); - } - - println_red_err(&format!( - " Aborting due to {} {}.", - e_len, - if e_len > 1 { "errors" } else { "error" } - )) - .unwrap(); + print_on_failure(silent_mode, warnings, errors); Err(format!("Failed to compile {}", proj_name)) } _ => { @@ -311,198 +279,41 @@ fn compile<'n, 'source>( let res = core_lang::compile_to_bytecode(source, namespace, build_config, dependency_graph); match res { BytecodeCompilationResult::Success { bytes, warnings } => { - if !silent_mode { - warnings.iter().for_each(format_warning); - } - - if warnings.is_empty() { - let _ = println_green_err(&format!(" Compiled script {:?}.", proj_name)); - } else { - let _ = println_yellow_err(&format!( - " Compiled script {:?} with {} {}.", - proj_name, - warnings.len(), - if warnings.len() > 1 { - "warnings" - } else { - "warning" - } - )); - } - Ok(bytes) + print_on_success(silent_mode, proj_name, warnings, TreeType::Script {}); + return Ok(bytes); } BytecodeCompilationResult::Library { warnings } => { - if !silent_mode { - warnings.iter().for_each(format_warning); - } - - if warnings.is_empty() { - let _ = println_green_err(&format!(" Compiled library {:?}.", proj_name)); - } else { - let _ = println_yellow_err(&format!( - " Compiled library {:?} with {} {}.", - proj_name, - warnings.len(), - if warnings.len() > 1 { - "warnings" - } else { - "warning" - } - )); - } - Ok(vec![]) + print_on_success_library(silent_mode, proj_name, warnings); + return Ok(vec![]); } BytecodeCompilationResult::Failure { errors, warnings } => { - let e_len = errors.len(); - - if !silent_mode { - warnings.iter().for_each(|warning| format_warning(warning)); - errors.iter().for_each(|error| format_err(error)); - } - - println_red_err(&format!( - " Aborting due to {} {}.", - e_len, - if e_len > 1 { "errors" } else { "error" } - )) - .unwrap(); - Err(format!("Failed to compile {}", proj_name)) + print_on_failure(silent_mode, warnings, errors); + return Err(format!("Failed to compile {}", proj_name)); } } } -fn format_warning(err: &core_lang::CompileWarning) { - let input = err.span.input(); - let path = err.path(); - - let (start_pos, mut end_pos) = err.span(); - let friendly_str = err.to_friendly_warning_string(); - if start_pos == end_pos { - // if start/pos are same we will not get that arrow pointing to code, so we add +1. - end_pos += 1; - } - let snippet = Snippet { - title: Some(Annotation { - label: None, - id: None, - annotation_type: AnnotationType::Warning, - }), - footer: vec![], - slices: vec![Slice { - source: input, - line_start: 0, - origin: Some(&path), - fold: true, - annotations: vec![SourceAnnotation { - label: &friendly_str, - annotation_type: AnnotationType::Warning, - range: (start_pos, end_pos), - }], - }], - opt: FormatOptions { - color: true, - ..Default::default() - }, - }; - eprintln!("{}", DisplayList::from(snippet)) -} - -fn format_err(err: &core_lang::CompileError) { - let input = err.internal_span().input(); - let path = err.path(); - - let (start_pos, mut end_pos) = err.span(); - if start_pos == end_pos { - // if start/pos are same we will not get that arrow pointing to code, so we add +1. - end_pos += 1; - } - let friendly_str = err.to_friendly_error_string(); - let snippet = Snippet { - title: Some(Annotation { - label: None, - id: None, - annotation_type: AnnotationType::Error, - }), - footer: vec![], - slices: vec![Slice { - source: input, - line_start: 0, - origin: Some(&path), - fold: true, - annotations: vec![SourceAnnotation { - label: &friendly_str, - annotation_type: AnnotationType::Error, - range: (start_pos, end_pos), - }], - }], - opt: FormatOptions { - color: true, - ..Default::default() - }, - }; - eprintln!("{}", DisplayList::from(snippet)) -} - -fn compile_to_asm<'n, 'source>( - source: &'source str, +fn compile_to_asm<'sc>( + source: &'sc str, proj_name: &str, - namespace: &Namespace<'source>, + namespace: &Namespace<'sc>, build_config: BuildConfig, dependency_graph: &mut HashMap>, -) -> Result, String> { + silent_mode: bool, +) -> Result, String> { let res = core_lang::compile_to_asm(source, namespace, build_config, dependency_graph); match res { CompilationResult::Success { asm, warnings } => { - warnings.iter().for_each(|warning| format_warning(warning)); - - if warnings.is_empty() { - let _ = println_green_err(&format!(" Compiled script {:?}.", proj_name)); - } else { - let _ = println_yellow_err(&format!( - " Compiled script {:?} with {} {}.", - proj_name, - warnings.len(), - if warnings.len() > 1 { - "warnings" - } else { - "warning" - } - )); - } + print_on_success(silent_mode, proj_name, warnings, TreeType::Script {}); Ok(asm) } CompilationResult::Library { warnings, .. } => { - warnings.iter().for_each(|warning| format_warning(warning)); - - if warnings.is_empty() { - let _ = println_green_err(&format!(" Compiled library {:?}.", proj_name)); - } else { - let _ = println_yellow_err(&format!( - " Compiled library {:?} with {} {}.", - proj_name, - warnings.len(), - if warnings.len() > 1 { - "warnings" - } else { - "warning" - } - )); - } + print_on_success_library(silent_mode, proj_name, warnings); Ok(FinalizedAsm::Library) } CompilationResult::Failure { errors, warnings } => { - let e_len = errors.len(); - - warnings.iter().for_each(format_warning); - errors.iter().for_each(format_err); - - println_red_err(&format!( - " Aborting due to {} {}.", - e_len, - if e_len > 1 { "errors" } else { "error" } - )) - .unwrap(); - Err(format!("Failed to compile {}", proj_name)) + print_on_failure(silent_mode, warnings, errors); + return Err(format!("Failed to compile {}", proj_name)); } } } diff --git a/forc/src/ops/mod.rs b/forc/src/ops/mod.rs index 72c9f18de0e..86bc785834d 100644 --- a/forc/src/ops/mod.rs +++ b/forc/src/ops/mod.rs @@ -1,3 +1,4 @@ +pub mod forc_abi_json; pub mod forc_build; pub mod forc_dep_check; pub mod forc_deploy; diff --git a/forc/src/utils/helpers.rs b/forc/src/utils/helpers.rs index 0b01f7224f8..dbc74afa67f 100644 --- a/forc/src/utils/helpers.rs +++ b/forc/src/utils/helpers.rs @@ -1,5 +1,10 @@ use super::constants::{SRC_DIR, SWAY_EXTENSION}; use super::manifest::Manifest; +use annotate_snippets::{ + display_list::{DisplayList, FormatOptions}, + snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation}, +}; +use core_lang::{CompileError, CompileWarning, TreeType}; use std::ffi::OsStr; use std::io::{self, Write}; use std::path::{Path, PathBuf}; @@ -49,6 +54,26 @@ pub fn find_manifest_dir(starter_path: &Path) -> Option { None } +pub fn find_main_path(manifest_dir: &PathBuf, manifest: &Manifest) -> PathBuf { + let mut code_dir = manifest_dir.clone(); + code_dir.push(crate::utils::constants::SRC_DIR); + code_dir.push(&manifest.project.entry); + code_dir +} + +pub fn find_file_name<'sc>( + manifest_dir: &'sc PathBuf, + main_path: &'sc PathBuf, +) -> Result<&'sc Path, String> { + let mut file_path = manifest_dir.clone(); + file_path.pop(); + let file_name = match main_path.strip_prefix(file_path.clone()) { + Ok(o) => o, + Err(err) => return Err(err.to_string()), + }; + Ok(file_name) +} + pub fn read_manifest(manifest_dir: &Path) -> Result { let manifest_path = { let mut man = PathBuf::from(manifest_dir); @@ -89,6 +114,85 @@ pub fn get_main_file( Ok(main_file) } +pub fn print_on_success<'sc>( + silent_mode: bool, + proj_name: &str, + warnings: Vec, + tree_type: TreeType<'sc>, +) { + let type_str = match tree_type { + TreeType::Script {} => "script", + TreeType::Contract {} => "contract", + TreeType::Predicate {} => "predicate", + TreeType::Library { .. } => "library", + }; + + if !silent_mode { + warnings.iter().for_each(|warning| format_warning(warning)); + } + + if warnings.is_empty() { + let _ = println_green_err(&format!(" Compiled {} {:?}.", type_str, proj_name)); + } else { + let _ = println_yellow_err(&format!( + " Compiled {} {:?} with {} {}.", + type_str, + proj_name, + warnings.len(), + if warnings.len() > 1 { + "warnings" + } else { + "warning" + } + )); + } +} + +pub fn print_on_success_library<'sc>( + silent_mode: bool, + proj_name: &str, + warnings: Vec, +) { + if !silent_mode { + warnings.iter().for_each(|warning| format_warning(warning)); + } + + if warnings.is_empty() { + let _ = println_green_err(&format!(" Compiled library {:?}.", proj_name)); + } else { + let _ = println_yellow_err(&format!( + " Compiled library {:?} with {} {}.", + proj_name, + warnings.len(), + if warnings.len() > 1 { + "warnings" + } else { + "warning" + } + )); + } +} + +pub fn print_on_failure( + silent_mode: bool, + warnings: Vec, + errors: Vec, +) { + let e_len = errors.len(); + + if !silent_mode { + warnings.iter().for_each(|warning| format_warning(warning)); + errors.into_iter().for_each(|error| format_err(&error)); + } + + println_red_err(&format!( + " Aborting due to {} {}.", + e_len, + if e_len > 1 { "errors" } else { "error" } + )) + .unwrap(); +} + pub fn println_red(txt: &str) -> io::Result<()> { println_std_out(txt, TermColor::Red) } @@ -148,3 +252,75 @@ fn println_with_color(txt: &str, color: TermColor, stream: StandardStream) -> io stream.reset()?; Ok(()) } + +fn format_err(err: &core_lang::CompileError) { + let input = err.internal_span().input(); + let path = err.path(); + + let (start_pos, mut end_pos) = err.span(); + if start_pos == end_pos { + // if start/pos are same we will not get that arrow pointing to code, so we add +1. + end_pos += 1; + } + let friendly_str = err.to_friendly_error_string(); + let snippet = Snippet { + title: Some(Annotation { + label: None, + id: None, + annotation_type: AnnotationType::Error, + }), + footer: vec![], + slices: vec![Slice { + source: input, + line_start: 0, + origin: Some(&path), + fold: true, + annotations: vec![SourceAnnotation { + label: &friendly_str, + annotation_type: AnnotationType::Error, + range: (start_pos, end_pos), + }], + }], + opt: FormatOptions { + color: true, + ..Default::default() + }, + }; + eprintln!("{}", DisplayList::from(snippet)) +} + +fn format_warning(err: &core_lang::CompileWarning) { + let input = err.span.input(); + let path = err.path(); + + let (start_pos, mut end_pos) = err.span(); + let friendly_str = err.to_friendly_warning_string(); + if start_pos == end_pos { + // if start/pos are same we will not get that arrow pointing to code, so we add +1. + end_pos += 1; + } + let snippet = Snippet { + title: Some(Annotation { + label: None, + id: None, + annotation_type: AnnotationType::Warning, + }), + footer: vec![], + slices: vec![Slice { + source: input, + line_start: 0, + origin: Some(&path), + fold: true, + annotations: vec![SourceAnnotation { + label: &friendly_str, + annotation_type: AnnotationType::Warning, + range: (start_pos, end_pos), + }], + }], + opt: FormatOptions { + color: true, + ..Default::default() + }, + }; + eprintln!("{}", DisplayList::from(snippet)) +} diff --git a/test/Cargo.toml b/test/Cargo.toml index afdd017708e..e31e698068c 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -13,3 +13,4 @@ fuel-vm = { git = "ssh://git@github.com/FuelLabs/fuel-vm.git", features = ["rand rand = "0.8" regex = "1" tokio = "1.12" +serde_json = "*" diff --git a/test/src/e2e_vm_tests/harness.rs b/test/src/e2e_vm_tests/harness.rs index 9eff141b8ef..728c1b4b4ea 100644 --- a/test/src/e2e_vm_tests/harness.rs +++ b/test/src/e2e_vm_tests/harness.rs @@ -1,9 +1,14 @@ -use forc::test::{forc_build, forc_deploy, forc_run, BuildCommand, DeployCommand, RunCommand}; +use forc::test::{ + forc_abi_json, forc_build, forc_deploy, forc_run, BuildCommand, DeployCommand, JsonAbiCommand, + RunCommand, +}; use fuel_tx::{Input, Output, Transaction}; use fuel_vm::interpreter::Interpreter; use fuel_vm::prelude::*; use rand::rngs::StdRng; use rand::{Rng, SeedableRng}; +use serde_json::Value; +use std::fs; pub(crate) fn deploy_contract(file_name: &str) { // build the contract @@ -153,3 +158,47 @@ pub(crate) fn compile_to_bytes(file_name: &str) -> Result, String> { silent_mode: true, }) } + +pub(crate) fn test_json_abi(file_name: &str) -> Result<(), String> { + let _script = compile_to_json_abi(file_name)?; + let manifest_dir = env!("CARGO_MANIFEST_DIR"); + let oracle_path = format!( + "{}/src/e2e_vm_tests/test_programs/{}/{}", + manifest_dir, file_name, "json_abi_oracle.json" + ); + let output_path = format!( + "{}/src/e2e_vm_tests/test_programs/{}/{}", + manifest_dir, file_name, "json_abi_output.json" + ); + if fs::metadata(oracle_path.clone()).is_err() { + return Err("JSON ABI oracle file does not exist for this test.".to_string()); + } + if fs::metadata(output_path.clone()).is_err() { + return Err("JSON ABI output file does not exist for this test.".to_string()); + } + let oracle_contents = + fs::read_to_string(oracle_path).expect("Something went wrong reading the file."); + let output_contents = + fs::read_to_string(output_path).expect("Something went wrong reading the file."); + if oracle_contents != output_contents { + return Err("Mismatched ABI JSON output.".to_string()); + } + Ok(()) +} + +fn compile_to_json_abi(file_name: &str) -> Result { + println!(" ABI gen {}", file_name); + let manifest_dir = env!("CARGO_MANIFEST_DIR"); + forc_abi_json::build(JsonAbiCommand { + path: Some(format!( + "{}/src/e2e_vm_tests/test_programs/{}", + manifest_dir, file_name + )), + json_outfile: Some(format!( + "{}/src/e2e_vm_tests/test_programs/{}/{}", + manifest_dir, file_name, "json_abi_output.json" + )), + offline_mode: false, + silent_mode: false, + }) +} diff --git a/test/src/e2e_vm_tests/mod.rs b/test/src/e2e_vm_tests/mod.rs index 0dea5458d54..43765691b5d 100644 --- a/test/src/e2e_vm_tests/mod.rs +++ b/test/src/e2e_vm_tests/mod.rs @@ -74,6 +74,7 @@ pub fn run(filter_regex: Option) { project_names.into_iter().for_each(|(name, res)| { if filter(name) { assert_eq!(crate::e2e_vm_tests::harness::runs_in_vm(name), res); + assert_eq!(crate::e2e_vm_tests::harness::test_json_abi(name), Ok(())); } }); diff --git a/test/src/e2e_vm_tests/test_programs/address_test/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/address_test/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/address_test/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/aliased_imports/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/aliased_imports/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/aliased_imports/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/array_bad_index/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/array_bad_index/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/array_bad_index/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/array_basics/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/array_basics/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/array_basics/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/array_dynamic_oob/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/array_dynamic_oob/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/array_dynamic_oob/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/array_generics/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/array_generics/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/array_generics/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/array_oob/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/array_oob/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/array_oob/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/asm_expr_basic/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/asm_expr_basic/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/asm_expr_basic/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/asm_missing_return/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/asm_missing_return/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/asm_missing_return/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/asm_should_not_have_return/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/asm_should_not_have_return/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/asm_should_not_have_return/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/asm_without_return/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/asm_without_return/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/asm_without_return/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/assert_test/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/assert_test/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/assert_test/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/auth_testing_abi/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/auth_testing_abi/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/auth_testing_abi/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/auth_testing_contract/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/auth_testing_contract/json_abi_oracle.json new file mode 100644 index 00000000000..ff991774640 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/auth_testing_contract/json_abi_oracle.json @@ -0,0 +1 @@ +[{"inputs":[{"components":null,"name":"gas","type":"u64"},{"components":null,"name":"coins","type":"u64"},{"components":null,"name":"color","type":"b256"},{"components":null,"name":"input","type":"()"}],"name":"returns_gm_one","outputs":[{"components":null,"name":"","type":"bool"}],"type":"function"}] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/b256_bad_jumps/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/b256_bad_jumps/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/b256_bad_jumps/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/b256_ops/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/b256_ops/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/b256_ops/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/b512_struct_alignment/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/b512_struct_alignment/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/b512_struct_alignment/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/b512_test/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/b512_test/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/b512_test/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/bad_generic_annotation/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/bad_generic_annotation/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/bad_generic_annotation/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/bad_generic_var_annotation/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/bad_generic_var_annotation/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/bad_generic_var_annotation/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/basic_func_decl/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/basic_func_decl/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/basic_func_decl/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/basic_storage/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/basic_storage/json_abi_oracle.json new file mode 100644 index 00000000000..7c74cc14963 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/basic_storage/json_abi_oracle.json @@ -0,0 +1 @@ +[{"inputs":[{"components":null,"name":"gas_to_forward","type":"u64"},{"components":null,"name":"coins_to_forward","type":"u64"},{"components":null,"name":"color_of_coins","type":"b256"},{"components":[{"components":null,"name":"key","type":"b256"},{"components":null,"name":"value","type":"u64"}],"name":"storage","type":"struct StoreU64Request"}],"name":"store_u64","outputs":[{"components":null,"name":"","type":"()"}],"type":"function"},{"inputs":[{"components":null,"name":"gas_to_forward","type":"u64"},{"components":null,"name":"coins_to_forward","type":"u64"},{"components":null,"name":"color_of_coins","type":"b256"},{"components":null,"name":"storage_key","type":"b256"}],"name":"get_u64","outputs":[{"components":null,"name":"","type":"u64"}],"type":"function"}] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/basic_storage_abi/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/basic_storage_abi/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/basic_storage_abi/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/block_height/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/block_height/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/block_height/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/bool_and_or/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/bool_and_or/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/bool_and_or/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/call_basic_storage/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/call_basic_storage/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/call_basic_storage/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/call_increment_contract/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/call_increment_contract/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/call_increment_contract/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/caller_auth_test/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/caller_auth_test/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/caller_auth_test/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/caller_context_test/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/caller_context_test/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/caller_context_test/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/const_decl/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/const_decl/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/const_decl/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/const_decl_in_library/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/const_decl_in_library/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/const_decl_in_library/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/context_testing_abi/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/context_testing_abi/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/context_testing_abi/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/context_testing_contract/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/context_testing_contract/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/context_testing_contract/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/contract_abi_impl/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/contract_abi_impl/json_abi_oracle.json new file mode 100644 index 00000000000..11fe497ffb3 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/contract_abi_impl/json_abi_oracle.json @@ -0,0 +1 @@ +[{"inputs":[{"components":null,"name":"gas","type":"u64"},{"components":null,"name":"coin","type":"u64"},{"components":null,"name":"color","type":"b256"},{"components":[{"components":null,"name":"field_1","type":"bool"},{"components":null,"name":"field_2","type":"u64"}],"name":"input","type":"struct InputStruct"}],"name":"foo","outputs":[{"components":[{"components":null,"name":"field_1","type":"bool"},{"components":null,"name":"field_2","type":"u64"}],"name":"","type":"struct InputStruct"}],"type":"function"},{"inputs":[{"components":null,"name":"gas","type":"u64"},{"components":null,"name":"coin","type":"u64"},{"components":null,"name":"color","type":"b256"},{"components":null,"name":"input","type":"bool"}],"name":"baz","outputs":[{"components":null,"name":"","type":"()"}],"type":"function"}] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/contract_call/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/contract_call/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/contract_call/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/contract_id_test/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/contract_id_test/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/contract_id_test/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/dependencies/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/dependencies/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/dependencies/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/dependencies_parsing_error/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/dependencies_parsing_error/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/dependencies_parsing_error/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/disallowed_gm/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/disallowed_gm/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/disallowed_gm/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/doc_strings/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/doc_strings/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/doc_strings/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/empty_impl/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/empty_impl/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/empty_impl/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/empty_method_initializer/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/empty_method_initializer/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/empty_method_initializer/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/enum_in_fn_decl/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/enum_in_fn_decl/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/enum_in_fn_decl/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/eq_4_test/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/eq_4_test/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/eq_4_test/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/excess_fn_arguments/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/excess_fn_arguments/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/excess_fn_arguments/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/fix_opcode_bug/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/fix_opcode_bug/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/fix_opcode_bug/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/generic_enum/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/generic_enum/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/generic_enum/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/generic_functions/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/generic_functions/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/generic_functions/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/generic_struct/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/generic_struct/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/generic_struct/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/generic_structs/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/generic_structs/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/generic_structs/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/if_elseif_enum/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/if_elseif_enum/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/if_elseif_enum/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/import_method_from_other_file/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/import_method_from_other_file/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/import_method_from_other_file/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/increment_abi/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/increment_abi/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/increment_abi/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/increment_contract/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/increment_contract/json_abi_oracle.json new file mode 100644 index 00000000000..0d1d365536f --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/increment_contract/json_abi_oracle.json @@ -0,0 +1 @@ +[{"inputs":[{"components":null,"name":"gas","type":"u64"},{"components":null,"name":"amt","type":"u64"},{"components":null,"name":"color","type":"b256"},{"components":null,"name":"initial_value","type":"u64"}],"name":"initialize","outputs":[{"components":null,"name":"","type":"u64"}],"type":"function"},{"inputs":[{"components":null,"name":"gas","type":"u64"},{"components":null,"name":"amt","type":"u64"},{"components":null,"name":"color","type":"b256"},{"components":null,"name":"increment_by","type":"u64"}],"name":"increment","outputs":[{"components":null,"name":"","type":"u64"}],"type":"function"}] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/infinite_dependencies/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/infinite_dependencies/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/infinite_dependencies/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/local_impl_for_ord/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/local_impl_for_ord/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/local_impl_for_ord/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/main_returns_unit/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/main_returns_unit/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/main_returns_unit/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/missing_fn_arguments/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/missing_fn_arguments/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/missing_fn_arguments/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/missing_type_parameters/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/missing_type_parameters/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/missing_type_parameters/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/neq_4_test/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/neq_4_test/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/neq_4_test/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/op_precedence/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/op_precedence/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/op_precedence/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/out_of_order_decl/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/out_of_order_decl/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/out_of_order_decl/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/recursive_calls/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/recursive_calls/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/recursive_calls/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/retd_b256/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/retd_b256/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/retd_b256/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/retd_struct/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/retd_struct/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/retd_struct/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/struct_field_access/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/struct_field_access/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/struct_field_access/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/struct_field_reassignment/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/struct_field_reassignment/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/struct_field_reassignment/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/top_level_vars/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/top_level_vars/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/top_level_vars/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/unary_not_basic/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/unary_not_basic/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/unary_not_basic/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/unary_not_basic_2/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/unary_not_basic_2/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/unary_not_basic_2/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/unify_identical_unknowns/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/unify_identical_unknowns/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/unify_identical_unknowns/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/zero_field_types/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/zero_field_types/json_abi_oracle.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/zero_field_types/json_abi_oracle.json @@ -0,0 +1 @@ +[] \ No newline at end of file