Skip to content

Commit

Permalink
scarb struct return
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Apr 25, 2024
1 parent 9562506 commit a44413e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version = "0.1.0"
[workspace.dependencies]
cairo-lang-compiler = { version = "2.5.4", default-features = false }
cairo-lang-sierra = { version = "2.5.4", default-features = false }
cairo-vm = { git = "https://github.com/lambdaclass/cairo-vm", features = ["std"] }
cairo1-run = { git = "https://github.com/lambdaclass/cairo-vm" }
cairo-vm = { git = "https://github.com/Okm165/cairo-vm.git" }
cairo1-run = { git = "https://github.com/Okm165/cairo-vm.git" }
clap = { version = "4.3.10", features = ["derive"] }
serde_json = "1"
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ struct Input {
}

struct Output {
a_2: felt,
b_2: felt,
c_2: felt,
}

Expand Down Expand Up @@ -176,6 +178,8 @@ func execute_tasks{builtin_ptrs: BuiltinData*, self_range_check_ptr}(

let output = cast(builtin_ptrs.output - Output.SIZE, Output*);
%{
print(ids.output.a_2)
print(ids.output.b_2)
print(ids.output.c_2)
%}

Expand Down
8 changes: 6 additions & 2 deletions cairo1/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct Output {
c_2: u32,
}

fn main(input: Array<felt252>) -> u32 {
fn main(input: Array<felt252>) -> Output {
let mut input_span = input.span();
let input = Serde::<Input>::deserialize(ref input_span).unwrap();

Expand All @@ -20,5 +20,9 @@ fn main(input: Array<felt252>) -> u32 {
let c_2 = input.c * input.c;
assert (a_2 + b_2 == c_2, 'invalid value');

c_2*5
Output {
a_2,
b_2,
c_2,
}
}
2 changes: 1 addition & 1 deletion runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn main() -> std::io::Result<()> {
&sierra_program,
Cairo1RunConfig {
args: &args.args.0,
layout: LayoutName::recursive_with_poseidon,
layout: LayoutName::all_cairo,
finalize_builtins: true,
serialize_output: true,
append_return_values: true,
Expand Down

0 comments on commit a44413e

Please sign in to comment.