-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d4cfb9
commit b0c7edb
Showing
3 changed files
with
53 additions
and
1 deletion.
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,30 @@ | ||
use elements::pset::serialize::Serialize; | ||
use hex_conservative::DisplayHex; | ||
use leptos::{component, use_context, view, IntoView, SignalWith}; | ||
use simfony::elements; | ||
|
||
use crate::components::copy_to_clipboard::CopyToClipboard; | ||
use crate::components::program_window::Program; | ||
use crate::components::run_window::TxEnv; | ||
|
||
#[component] | ||
pub fn TransactionButton() -> impl IntoView { | ||
let program = use_context::<Program>().expect("program should exist in context"); | ||
let tx_env = use_context::<TxEnv>().expect("transaction environment should exist in context"); | ||
|
||
let transaction = move || { | ||
tx_env.params.with(|params| match program.satisfied() { | ||
Ok(satisfied) => params | ||
.transaction(&satisfied) | ||
.serialize() | ||
.to_lower_hex_string(), | ||
Err(..) => "Invalid program".to_string(), | ||
}) | ||
}; | ||
view! { | ||
<CopyToClipboard content=transaction class="button" tooltip_below=true> | ||
<i class="fa-solid fa-right-left"></i> | ||
" Transaction" | ||
</CopyToClipboard> | ||
} | ||
} |
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