Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scarb new/init hello world Cairo code #1169

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions examples/hello_world/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
fn main() -> felt252 {
fn main() -> u32 {
fib(16)
}

fn fib(mut n: felt252) -> felt252 {
let mut a: felt252 = 0;
let mut b: felt252 = 1;
loop {
if n == 0 {
break a;
}
fn fib(mut n: u32) -> u32 {
let mut a: u32 = 0;
let mut b: u32 = 1;
while n != 0 {
n = n - 1;
let temp = b;
b = a + b;
a = temp;
}
};
a
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion extensions/scarb-cairo-run/tests/examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn can_limit_gas() {
Finished release target(s) in [..]
Running hello_world
Run completed successfully, returning [987]
Remaining gas: 68340
Remaining gas: 50760
"#});
}

Expand Down
16 changes: 7 additions & 9 deletions scarb/src/ops/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,20 @@ fn mk(
fsx::write(
source_path,
indoc! {r#"
fn main() -> felt252 {
fn main() -> u32 {
fib(16)
}
fn fib(mut n: felt252) -> felt252 {
let mut a: felt252 = 0;
let mut b: felt252 = 1;
loop {
if n == 0 {
break a;
}
fn fib(mut n: u32) -> u32 {
let mut a: u32 = 0;
let mut b: u32 = 1;
while n != 0 {
n = n - 1;
let temp = b;
b = a + b;
a = temp;
}
};
a
}
#[cfg(test)]
Expand Down
Loading