Skip to content
Draft
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
446 changes: 285 additions & 161 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ arbitrary = { version = "1", optional = true, features = ["derive"] }
clap = "4.5.37"
chumsky = "0.11.2"

[dev-dependencies]
tempfile = "3"

[target.wasm32-unknown-unknown.dependencies]
getrandom = { version = "0.2", features = ["js"] }

Expand Down Expand Up @@ -68,7 +71,7 @@ copy_iterator = "warn"
default_trait_access = "warn"
doc_link_with_quotes = "warn"
doc_markdown = "warn"
empty_enum = "warn"
empty_enums = "warn"
enum_glob_use = "allow"
expl_impl_clone_on_copy = "warn"
explicit_deref_methods = "warn"
Expand Down Expand Up @@ -152,7 +155,7 @@ struct_field_names = "warn"
too_many_lines = "allow"
transmute_ptr_to_ptr = "warn"
trivially_copy_pass_by_ref = "warn"
unchecked_duration_subtraction = "warn"
unchecked_time_subtraction = "warn"
unicode_not_nfc = "warn"
unnecessary_box_returns = "warn"
unnecessary_join = "warn"
Expand Down
16 changes: 16 additions & 0 deletions examples/multiple_libs/main.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use merkle::build_root::{get_root, hash as and_hash};
use base_math::simple_op::hash as or_hash;

pub fn get_block_value_hash(prev_hash: u32, tx1: u32, tx2: u32) -> u32 {
let root: u32 = get_root(tx1, tx2);
or_hash(prev_hash, root)
}

fn main() {
let block_val_hash: u32 = get_block_value_hash(5, 10, 20);
assert!(jet::eq_32(block_val_hash, 27));

let first_value: u32 = 15;
let second_value: u32 = 22;
assert!(jet::eq_32(and_hash(first_value, second_value), 6));
}
3 changes: 3 additions & 0 deletions examples/multiple_libs/math/simple_op.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn hash(x: u32, y: u32) -> u32 {
jet::xor_32(x, y)
}
9 changes: 9 additions & 0 deletions examples/multiple_libs/merkle/build_root.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use math::simple_op::hash as temp_hash;

pub fn get_root(tx1: u32, tx2: u32) -> u32 {
temp_hash(tx1, tx2)
}

pub fn hash(tx1: u32, tx2: u32) -> u32 {
jet::and_32(tx1, tx2)
}
5 changes: 5 additions & 0 deletions examples/simple_multilib/crypto/hashes.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub fn sha256(data: u32) -> u256 {
let ctx: Ctx8 = jet::sha_256_ctx_8_init();
let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, data);
jet::sha_256_ctx_8_finalize(ctx)
}
7 changes: 7 additions & 0 deletions examples/simple_multilib/main.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use math::arithmetic::add;
use crypto::hashes::sha256;

fn main() {
let sum: u32 = add(2, 3);
let hash: u256 = sha256(sum);
}
4 changes: 4 additions & 0 deletions examples/simple_multilib/math/arithmetic.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub fn add(a: u32, b: u32) -> u32 {
let (_, res): (bool, u32) = jet::add_32(a, b);
res
}
11 changes: 11 additions & 0 deletions examples/single_lib/main.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pub use temp::constants::utils::two as smth;
use temp::funcs::{get_five, Smth};

fn seven() -> u32 {
7
}

fn main() {
let (_, temp): (bool, u32) = jet::add_32(smth(), get_five());
assert!(jet::eq_32(temp, seven()));
}
5 changes: 5 additions & 0 deletions examples/single_lib/temp/constants/utils.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub use temp::funcs::Smth;

pub fn two() -> Smth {
2
}
5 changes: 5 additions & 0 deletions examples/single_lib/temp/funcs.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub type Smth = u32;

pub fn get_five() -> u32 {
5
}
1 change: 1 addition & 0 deletions examples/temp/libs/lib/math.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn add(a: u32, b: u32) {}
1 change: 1 addition & 0 deletions examples/temp/main.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use lib::math::add;
2 changes: 2 additions & 0 deletions functional-tests/error-test-cases/cross-wire/lib/b.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use lib::x::TypeX;
use lib::y::TypeY;
2 changes: 2 additions & 0 deletions functional-tests/error-test-cases/cross-wire/lib/c.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use lib::y::TypeY;
use lib::x::TypeX;
1 change: 1 addition & 0 deletions functional-tests/error-test-cases/cross-wire/lib/x.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type TypeX = u32;
1 change: 1 addition & 0 deletions functional-tests/error-test-cases/cross-wire/lib/y.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type TypeY = u64;
4 changes: 4 additions & 0 deletions functional-tests/error-test-cases/cross-wire/main.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use lib::b::TypeX;
use lib::c::TypeY;

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub use lib::module_b::TypeB;
pub type TypeA = u32;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub use lib::module_a::TypeA;
pub type TypeB = u32;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use lib::module_a::TypeA;

fn main() {}
5 changes: 5 additions & 0 deletions functional-tests/error-test-cases/file-not-found/main.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use lib::module::AssetId;

fn main() {
let my_asset: AssetId = 5;
}
2 changes: 2 additions & 0 deletions functional-tests/error-test-cases/global/lib/module.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub type AssetId = u32;
pub fn get_id() -> AssetId { 1 }
5 changes: 5 additions & 0 deletions functional-tests/error-test-cases/global/main.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use lib::module::*;

fn main() {
let my_asset: AssetId = 5;
}
5 changes: 5 additions & 0 deletions functional-tests/error-test-cases/lib-not-found/main.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use lib::module::AssetId;

fn main() {
let my_asset: AssetId = 5;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn add(a: u32, b: u32) -> (bool, u32) {
jet::add_32(a, b)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub fn add(a: u32, b: u32) -> (bool, u32) {
let (_, c): (bool, u32) = jet::add_32(a, b);
jet::add_32(c, 1)
}
9 changes: 9 additions & 0 deletions functional-tests/error-test-cases/name-collision/main.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use lib::groups::add;
use lib::math::add;

fn main() {
let x: u32 = 5;
let y: u32 = 10;
let (_, result): (bool, u32) = add(x, y);
assert!(jet::eq_32(result, 16));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type SecretType = u32; pub fn ok() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use lib::hidden::SecretType;

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub use lib::level2::CoreSmth;
pub use lib::level2::core_val;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub use lib::level3::CoreSmth;
pub use lib::level3::core_val;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub type CoreSmth = u32;
pub fn core_val() -> CoreSmth { 42 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use lib::level1::CoreSmth;
use lib::level1::core_val;

fn main() {
let val: CoreSmth = core_val();
assert!(jet::eq_32(val, 42));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type BaseType = u32;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub use lib::base::BaseType;
pub fn get_left() -> BaseType { 1 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub use lib::base::BaseType;
pub fn get_right() -> BaseType { 2 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use lib::left::get_left;
use lib::right::get_right;

fn main() {
let a: BaseType = get_left();
let b: BaseType = get_right();
let (_, c): (bool, BaseType) = jet::add_32(a, b);
assert!(jet::eq_32(c, 3));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use types::def::UserId;
use db::store::get_record;

pub fn is_valid(id: UserId) -> UserId {
get_record(id)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use types::def::UserId;
pub fn get_record(id: UserId) -> UserId { id }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use orch::handler::run_system;

fn main() {
assert!(jet::eq_32(run_system(5), 5));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use auth::verify::is_valid;
use db::store::get_record;
use types::def::UserId;

pub fn run_system(id: UserId) -> UserId {
let checked: UserId = is_valid(id);
get_record(checked)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type UserId = u32;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn get_some_value() -> u64 {
1
}
3 changes: 3 additions & 0 deletions functional-tests/valid-test-cases/keyword-as-lib/main.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use r#jet::r#fn::r#let;

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type SecretKey = u64;

pub fn unlock(key: SecretKey) -> u64 {
jet::max_64(key, 0)
}
4 changes: 4 additions & 0 deletions functional-tests/valid-test-cases/leaky-signature/main.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use lib::internal::unlock;

fn main() {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub fn add() {}
2 changes: 2 additions & 0 deletions functional-tests/valid-test-cases/module-simple/main.simf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use lib::module::add;
fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub use crypto::crypto::mock_hash;
pub use math::math::MathInt;
pub use math::math::add_two;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use math::math::MathInt;

pub fn mock_hash(x: MathInt) -> (bool, MathInt) {
jet::add_32(x, 5)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use api::api::{add_two, mock_hash, MathInt};

fn main() {
let val: MathInt = 10;
let (_, step1): (bool, MathInt) = add_two(val);
let (_, step2): (bool, MathInt) = mock_hash(step1);
assert!(jet::eq_32(step2, 17));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub type MathInt = u32;
pub fn add_two(x: MathInt) -> (bool, MathInt) {
jet::add_32(x, 2)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub type Coin = u64;
pub fn mint(val: u64) -> Coin { val }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub use lib::core::Coin;
pub use lib::core::mint;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub use lib::core::Coin;

pub fn burn(c: Coin) -> (bool, Coin) {
jet::subtract_64(c, 1)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use lib::route_a::Coin;
use lib::route_a::mint;
use lib::route_b::burn;

fn main() {
let my_coin: Coin = mint(10);
let (_, remaining): (bool, Coin) = burn(my_coin);
assert!(jet::eq_64(remaining, 9));
}
Loading
Loading