Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
proposed sol: warplib import
Browse files Browse the repository at this point in the history
  • Loading branch information
rjnrohit committed Mar 10, 2023
1 parent 14ee59a commit ad8f82b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cairo1/darwin_arm64/corelib/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,6 @@ mod test;
// Modules for testing only.
mod testing;
mod starknet_testing;

mod warplib;
use warplib::warp_add;
2 changes: 2 additions & 0 deletions cairo1/darwin_arm64/corelib/src/warplib.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod add;
use add::warp_add;
6 changes: 6 additions & 0 deletions cairo1/darwin_arm64/corelib/src/warplib/add.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

use integer::u128_from_felt;

fn warp_add(num: u128, num2: felt) -> u128 {
num + u128_from_felt(num2)
}
3 changes: 3 additions & 0 deletions cairo1/linux_64/corelib/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,6 @@ use zeroable::Zeroable;

#[cfg(test)]
mod test;

mod warplib;
use warplib::warp_add;
2 changes: 2 additions & 0 deletions cairo1/linux_64/corelib/src/warplib.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod add;
use add::warp_add;
6 changes: 6 additions & 0 deletions cairo1/linux_64/corelib/src/warplib/add.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

use integer::u128_from_felt;

fn warp_add(num: u128, num2: felt) -> u128 {
num + u128_from_felt(num2)
}
12 changes: 12 additions & 0 deletions test.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#[contract]

mod co{
use integer::u128_to_felt;
use warplib::warp_add;

#[view]
fn f(num: u128){
let x = warp_add(num, 1);
}
}

0 comments on commit ad8f82b

Please sign in to comment.