Skip to content

Commit

Permalink
Merge pull request #10 from 0xPolygonMiden/greenhat/program-i32
Browse files Browse the repository at this point in the history
fix: switch program template to i32
  • Loading branch information
bitwalker authored Feb 19, 2025
2 parents c746b24 + 0f49220 commit 6061509
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions account/template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
static ALLOC: BumpAlloc = miden::BumpAlloc::new();

// Required for no-std crates
#[cfg(not(test))]
#[panic_handler]
fn my_panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
Expand Down
2 changes: 2 additions & 0 deletions program/inputs.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[inputs]
stack = [2, 3]
13 changes: 6 additions & 7 deletions program/template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,24 @@
// use alloc::vec::Vec;

// // Global allocator to use heap memory in no-std environment
#[global_allocator]
static ALLOC: BumpAlloc = miden::BumpAlloc::new();
// #[global_allocator]
// static ALLOC: miden::BumpAlloc = miden::BumpAlloc::new();

// Required for no-std crates
#[cfg(not(test))]
#[panic_handler]
fn my_panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}

use miden::*;

// Pass up to 16 Felt inputs as entrypoint function parameters.
// The output is temporarely limited to 1 Felt value
// Pass up to 16 i32 inputs as entrypoint function parameters.
// The output is temporarely limited to 1 i32 value
//
// NOTE:
// The name of the entrypoint function is expected to be `entrypoint`. Do not remove the
// `#[no_mangle]` attribute, otherwise, the rustc will mangle the name and it'll not be recognized
// by the Miden compiler.
#[no_mangle]
pub fn entrypoint(a: Felt, b: Felt) -> Felt {
pub fn entrypoint(a: i32, b: i32) -> i32 {
a + b
}

0 comments on commit 6061509

Please sign in to comment.