Skip to content
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
271 changes: 232 additions & 39 deletions Cargo.lock

Large diffs are not rendered by default.

129 changes: 127 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ lib-profile-release = "wasm-release"

[dependencies]
itertools = "0.13.0"
#simplicityhl = "0.2.0"
simplicityhl = { package = "simfony", git = "https://github.com/BlockstreamResearch/simplicityhl", rev = "d5284014e9f67593e50b272f1f676ea8d09f6ec8" }
simplicityhl = { version = "0.3.0" }
leptos = { version = "0.6.14", features = ["csr"] }
leptos_router = { version = "0.6.15", features = ["csr"] }
console_error_panic_hook = "0.1.7"
Expand All @@ -34,3 +33,129 @@ serde_json = "1.0"

[dev-dependencies]
wasm-bindgen-test = "0.3.50"

[lints.clippy]
# Exclude lints we don't think are valuable.
needless_question_mark = "allow" # https://github.com/rust-bitcoin/rust-bitcoin/pull/2134
manual_range_contains = "allow" # More readable than clippy's format.
needless_raw_string_hashes = "allow" # No reason not to use raw strings
uninlined_format_args = "allow" # This is a subjective style choice.
float_cmp = "allow" # Bitcoin floats are typically limited to 8 decimal places and we want them exact.
manual_let_else = "allow" # unsure about this one on stylistic grounds
map_unwrap_or = "allow" # encourages use of `map_or_else` which takes two closures that the reader can't really distinguish
match_bool = "allow" # Adds extra indentation and LOC.
match_same_arms = "allow" # Collapses things that are conceptually unrelated to each other.
must_use_candidate = "allow" # Useful for audit but many false positives.
similar_names = "allow" # Too many (subjectively) false positives.
single_match_else = "allow" # bad style; creates long lines and extra lines
# Exhaustive list of pedantic clippy lints
assigning_clones = "warn"
bool_to_int_with_if = "warn"
borrow_as_ptr = "warn"
case_sensitive_file_extension_comparisons = "warn"
cast_lossless = "warn"
cast_possible_truncation = "allow" # All casts should include a code comment (except test code).
cast_possible_wrap = "allow" # Same as above re code comment.
cast_precision_loss = "warn"
cast_ptr_alignment = "warn"
cast_sign_loss = "allow" # All casts should include a code comment (except in test code).
checked_conversions = "warn"
cloned_instead_of_copied = "warn"
copy_iterator = "warn"
default_trait_access = "warn"
doc_link_with_quotes = "warn"
doc_markdown = "warn"
empty_enum = "warn"
enum_glob_use = "warn"
expl_impl_clone_on_copy = "warn"
explicit_deref_methods = "warn"
explicit_into_iter_loop = "warn"
explicit_iter_loop = "warn"
filter_map_next = "warn"
flat_map_option = "warn"
fn_params_excessive_bools = "warn"
from_iter_instead_of_collect = "warn"
if_not_else = "warn"
ignored_unit_patterns = "warn"
implicit_clone = "warn"
implicit_hasher = "warn"
inconsistent_struct_constructor = "warn"
index_refutable_slice = "warn"
inefficient_to_string = "warn"
inline_always = "warn"
into_iter_without_iter = "warn"
invalid_upcast_comparisons = "warn"
items_after_statements = "warn"
iter_filter_is_ok = "warn"
iter_filter_is_some = "warn"
iter_not_returning_iterator = "warn"
iter_without_into_iter = "warn"
large_digit_groups = "warn"
large_futures = "warn"
large_stack_arrays = "warn"
large_types_passed_by_value = "warn"
linkedlist = "warn"
macro_use_imports = "warn"
manual_assert = "warn"
manual_instant_elapsed = "warn"
manual_is_power_of_two = "warn"
manual_is_variant_and = "warn"
manual_ok_or = "warn"
manual_string_new = "warn"
many_single_char_names = "warn"
match_wildcard_for_single_variants = "warn"
maybe_infinite_iter = "warn"
mismatching_type_param_order = "warn"
missing_errors_doc = "allow" # FIXME this triggers 184 times; we should fix most
missing_fields_in_debug = "warn"
missing_panics_doc = "allow" # FIXME this one has 40 triggers
mut_mut = "warn"
naive_bytecount = "warn"
needless_bitwise_bool = "warn"
needless_continue = "warn"
needless_for_each = "warn"
needless_pass_by_value = "warn"
no_effect_underscore_binding = "warn"
no_mangle_with_rust_abi = "warn"
option_as_ref_cloned = "warn"
option_option = "warn"
ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
pub_underscore_fields = "warn"
range_minus_one = "warn"
range_plus_one = "warn"
redundant_closure_for_method_calls = "warn"
redundant_else = "warn"
ref_as_ptr = "warn"
ref_binding_to_reference = "warn"
ref_option = "warn"
ref_option_ref = "warn"
return_self_not_must_use = "warn"
same_functions_in_if_condition = "warn"
semicolon_if_nothing_returned = "warn"
should_panic_without_expect = "warn"
single_char_pattern = "warn"
stable_sort_primitive = "warn"
str_split_at_newline = "warn"
string_add_assign = "warn"
struct_excessive_bools = "warn"
struct_field_names = "warn"
too_many_lines = "allow" # FIXME 14 triggers for this lint; probably most should be fixed
transmute_ptr_to_ptr = "warn"
trivially_copy_pass_by_ref = "warn"
unchecked_duration_subtraction = "warn"
unicode_not_nfc = "warn"
unnecessary_box_returns = "warn"
unnecessary_join = "warn"
unnecessary_literal_bound = "warn"
unnecessary_wraps = "warn"
unnested_or_patterns = "warn"
unreadable_literal = "warn"
unsafe_derive_deserialize = "warn"
unused_async = "warn"
unused_self = "warn"
used_underscore_binding = "warn"
used_underscore_items = "warn"
verbose_bit_mask = "warn"
wildcard_imports = "warn"
zero_sized_map_values = "warn"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ SimplicityHL looks and feels like [Rust](https://www.rust-lang.org). Just how Ru

[A live demo is running](https://ide.simplicity-lang.org).

This project should build on Rust **1.78.0**.

## Develop the project

### Using Docker
Expand Down
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
msrv = "1.78.0"
2 changes: 1 addition & 1 deletion src/components/analysis.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use leptos::*;
use leptos::{component, view, IntoView, ReadSignal, Signal, SignalGet};
use std::str::FromStr;
use std::sync::Arc;

Expand Down
2 changes: 1 addition & 1 deletion src/components/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn App() -> impl IntoView {
provide_context(ActiveRunTab::default());

if program.is_empty() {
select_example(examples::get("✍️️ P2PK").expect("P2PK example should exist"))
select_example(examples::get("✍️️ P2PK").expect("P2PK example should exist"));
}

view! {
Expand Down
4 changes: 2 additions & 2 deletions src/components/footer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use leptos::{component, create_signal, view, IntoView, SignalGet, SignalSet, *};
use leptos::{component, create_signal, view, wasm_bindgen, IntoView, SignalGet, SignalSet};
use wasm_bindgen::JsCast;

#[cfg(target_arch = "wasm32")]
Expand Down Expand Up @@ -69,7 +69,7 @@ fn NewsletterForm() -> impl IntoView {

spawn_local(async move {
match subscribe_to_newsletter(email_value).await {
Ok(_) => {
Ok(()) => {
set_status.set(FormStatus::Success);
set_message
.set("Thank you for subscribing! We'll keep you updated.".to_string());
Expand Down
94 changes: 0 additions & 94 deletions src/components/merkle.rs

This file was deleted.

2 changes: 2 additions & 0 deletions src/components/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::needless_pass_by_value)] // leptos has broken lifetime parsing

mod analysis;
mod app;
mod copy_to_clipboard;
Expand Down
2 changes: 1 addition & 1 deletion src/components/navbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn Navbar(
match child {
TabView::Tab { name, children } => {
tabs_content.push((name, children));
button_bar.push(view! {<TabButton tab_name=name active_tab=active_tab />})
button_bar.push(view! {<TabButton tab_name=name active_tab=active_tab />});
}
TabView::Button { children } => button_bar.push(children().into_view()),
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/program_window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ pub fn ProgramWindow() -> impl IntoView {
class:hamburger-active=mobile_open
on:click=move |_| set_mobile_open.set(!mobile_open.get())
>
{move || if !mobile_open.get() {
view! { <i class="fa-solid fa-bars"></i>}
} else {
{move || if mobile_open.get() {
view! { <i class="fa-solid fa-xmark"></i> }
} else {
view! { <i class="fa-solid fa-bars"></i>}
}}
</div>
</Toolbar>
Expand Down
22 changes: 14 additions & 8 deletions src/components/program_window/program_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ impl Program {
pub fn new(text: String) -> Self {
let program = Self {
text: create_rw_signal(text),
cached_text: create_rw_signal("".to_string()),
lazy_cmr: create_rw_signal(Err("".to_string())),
lazy_satisfied: create_rw_signal(Err("".to_string())),
cached_text: create_rw_signal(String::new()),
lazy_cmr: create_rw_signal(Err(String::new())),
lazy_satisfied: create_rw_signal(Err(String::new())),
};
program.update_on_read();
program
Expand Down Expand Up @@ -66,7 +66,13 @@ impl Program {
self.cached_text.set(text.clone());
let compiled = simplicityhl::Arguments::parse_from_str(text)
.map_err(|error| error.to_string())
.and_then(|args| CompiledProgram::new(text.as_str(), args));
.and_then(|args| {
CompiledProgram::new(
text.as_str(),
args,
false, /* include debug symbols */
)
});
let cmr = compiled
.as_ref()
.map(|x| x.commit().cmr())
Expand Down Expand Up @@ -109,9 +115,9 @@ impl Runtime {
Self {
program,
env,
run_succeeded: Default::default(),
debug_output: Default::default(),
error_output: Default::default(),
run_succeeded: RwSignal::default(),
debug_output: RwSignal::default(),
error_output: RwSignal::default(),
}
}

Expand Down Expand Up @@ -140,7 +146,7 @@ impl Runtime {
return;
}
};
let mut runner = Runner::for_program(satisfied_program);
let mut runner = Runner::for_program(&satisfied_program);
let success = self.env.with(|env| match runner.run(env) {
Ok(..) => {
self.error_output.update(String::clear);
Expand Down
4 changes: 2 additions & 2 deletions src/components/run_window/execution_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ pub fn ExecutionTab() -> impl IntoView {
let success_string = move || {
runtime.error_output.with(|error| match error.is_empty() {
true => format!("{}: Success.", get_local_datetime()),
false => "".to_string(),
false => String::new(),
})
};
let failure_string = move || {
runtime.error_output.with(|error| match error.is_empty() {
true => "".to_string(),
true => String::new(),
false => format!("{}:\n{error}", get_local_datetime()),
})
};
Expand Down
17 changes: 8 additions & 9 deletions src/components/run_window/key_store_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,21 +296,20 @@ fn SelectSignedData() -> impl IntoView {
thirty_two_bytes_is_insane.set(true);
}
};
let update_hash_preimage_bytes = move |event: ev::Event| match <Vec<u8>>::from_hex(
event_target_value(&event)
.as_str()
.trim()
.trim_start_matches("0x"),
) {
Ok(bytes) => {
let update_hash_preimage_bytes = move |event: ev::Event| {
if let Ok(bytes) = <Vec<u8>>::from_hex(
event_target_value(&event)
.as_str()
.trim()
.trim_start_matches("0x"),
) {
signed_data.hash_preimage_bytes.set(bytes);
hash_preimage_bytes_text_ref
.get()
.expect("<input> should be mounted")
.set_custom_validity("");
hash_preimage_bytes_is_insane.set(false);
}
Err(..) => {
} else {
sighash_all_radio_ref
.get()
.expect("<input> should be mounted")
Expand Down
Loading
Loading