This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Get rid of hashbuiltin * Fix WARP_USED_STORAGE * Cleanup * Fix WARP_NAMEGEN * Fix storage consts * Fix LegacyMap issues * Fix uint256 serialization and construction * Add missing condition * Fix structs serialization * Change `get_caller_address`path * Transform `get_caller_address` output to felt * Remove unused import * Warplib import (#985) * create u256 from 2 felts (#975) * proposed sol: warplib import * Add warplib::integer to corelib * Add warplib::integer to x64 * Add integer functions to warplib.cairo --------- Co-authored-by: Alejandro Labourdette <66191544+AlejandroLabourdette@users.noreply.github.com> Co-authored-by: Piotr Piwoński <piwonskp@gmail.com> Co-authored-by: Piotr Piwoński <piwonskp> * Revert using `::` in generated functions not ported to cairo 1 yet * Revert `WARP_USED_STORAGE::` in cairo 0.x scripts * Remove unused import * follow import convention * Fix warplib errors * Add missing math imports to arm warplib.cairo * Rename UINT256 to GET_U128 * Create ADDRESS_INTO_FELT import directly * Revert "Create ADDRESS_INTO_FELT import directly" This reverts commit f388dc6. * Replace `get_u128_try_from_felt_result` with corelib implementation * Add newlines --------- Co-authored-by: Piotr Piwoński <piwonskp> Co-authored-by: Rohit Ranjan <rohitrjn629@gmail.com> Co-authored-by: Alejandro Labourdette <66191544+AlejandroLabourdette@users.noreply.github.com>
- Loading branch information
1 parent
6e0651d
commit 46c082c
Showing
153 changed files
with
47,667 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
mod integer; | ||
use integer::get_u128_try_from_felt_result; | ||
use integer::u256_from_felts; | ||
|
||
mod maths; | ||
use maths::warp_add256; | ||
use maths::warp_external_input_check_address; | ||
use maths::warp_external_input_check_int256; | ||
use maths::warp_ge256; | ||
use maths::warp_sub_unsafe256; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use integer::u128_try_from_felt; | ||
use option::OptionTrait; | ||
|
||
fn u256_from_felts(low_felt: felt, high_felt: felt) -> u256 { | ||
let low_u128: u128 = get_u128_try_from_felt_result(low_felt); | ||
let high_u128: u128 = get_u128_try_from_felt_result(high_felt); | ||
return u256{ low: low_u128, high: high_u128 }; | ||
} | ||
|
||
fn get_u128_try_from_felt_result(value: felt) -> u128 { | ||
let resp = u128_try_from_felt(value); | ||
assert(resp.is_some(), 'Felts too large for u256'); | ||
return resp.unwrap(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
mod add; | ||
use add::warp_add256; | ||
mod external_input_check_address; | ||
use external_input_check_address::warp_external_input_check_address; | ||
mod external_input_check_ints; | ||
use external_input_check_ints::warp_external_input_check_int256; | ||
mod ge; | ||
use ge::warp_ge256; | ||
mod sub_unsafe; | ||
use sub_unsafe::warp_sub_unsafe256; |
192 changes: 192 additions & 0 deletions
192
cairo1/darwin_arm64/corelib/src/warplib/maths/add.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
//AUTO-GENERATED | ||
|
||
|
||
fn warp_add8(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add16(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add24(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add32(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add40(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add48(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add56(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add64(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add72(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add80(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add88(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add96(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add104(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add112(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add120(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add128(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add136(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add144(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add152(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add160(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add168(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add176(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add184(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add192(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add200(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add208(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add216(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add224(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add232(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add240(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add248(lhs: felt, rhs: felt) -> felt{ | ||
let res = lhs + rhs; | ||
let max: felt = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; | ||
assert (res <= max, 'Value out of bounds'); | ||
return res; | ||
} | ||
fn warp_add256(lhs: u256, rhs: u256) -> u256{ | ||
return lhs + rhs; | ||
} |
Oops, something went wrong.