-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
14 changed files
with
7,498 additions
and
7,304 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 |
---|---|---|
|
@@ -9,7 +9,8 @@ modules: | |
nearblocks | ||
state | ||
components/ | ||
history | ||
transaction | ||
transactions | ||
settings | ||
menu_tabs | ||
content | ||
|
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
This file was deleted.
Oops, something went wrong.
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
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,171 @@ | ||
open rust_operators | ||
open model.near.nearblocks | ||
|
||
inl render (index : i64) (transaction : txn) : _ leptos.div = | ||
print_static "<transaction.render>" | ||
|
||
inl global_state : state.global_state = leptos.use_context () |> optionm'.unwrap | ||
|
||
leptos.div [ | ||
$'"class=\\\"flex flex-1 flex-col\\\""' | ||
] fun () => :>(;[ | ||
leptos.divider fun () => | ||
$'"Transaction " + string (!index + 1L) + ""' |> leptos.text_fragment | ||
|> leptos.element_to_view | ||
|
||
leptos.div [ | ||
$'"class=\\\"grid flex-1 divide-y-[1px] divide-gray-500/[.10]\\\""' | ||
] fun () => :>(;[ | ||
leptos.grid_pair | ||
{ padding = Some ""; cols = None; class = "items-center py-[4px]" } | ||
fun () => "Block Timestamp" |> leptos.text_fragment | ||
fun () => | ||
transaction.block_timestamp | ||
|> fun x => !\($'"!x.parse().unwrap()"') : i64 | ||
|> date_time.from_timestamp' | ||
|> optionm.map fun x => | ||
x | ||
|> date_time.to_local | ||
|> date_time.format'' "%Y-%m-%d %H:%M:%S" | ||
|> sm'.from_std_string | ||
|> resultm.from_option | ||
|> to_string | ||
|> leptos.text_fragment | ||
|> leptos.element_to_view | ||
|
||
leptos.grid_pair | ||
{ padding = Some ""; cols = None; class = "items-center py-[4px]" } | ||
fun () => "Predecessor" |> leptos.text_fragment | ||
fun () => | ||
transaction.predecessor_account_id | ||
|> to_string | ||
|> leptos.text_fragment | ||
|> leptos.element_to_view | ||
|
||
leptos.grid_pair | ||
{ padding = Some ""; cols = None; class = "items-center py-[4px]" } | ||
fun () => "Receiver" |> leptos.text_fragment | ||
fun () => | ||
transaction.receiver_account_id | ||
|> to_string | ||
|> leptos.text_fragment | ||
|> leptos.element_to_view | ||
|
||
leptos.grid_pair | ||
{ padding = Some "sm:pr-[10px]"; cols = None; class = "items-center py-[4px]" } | ||
fun () => "Actions" |> leptos.text_fragment | ||
fun () => | ||
a transaction.actions | ||
|> am'.map_vec fun { action method } => | ||
leptos.grid_pair | ||
{ padding = Some "items-center"; cols = Some ""; class = "" } | ||
fun () => | ||
match action |> sm'.from_std_string with | ||
| "FUNCTION_CALL" => "Function Call:" | ||
| "DEPLOY_CONTRACT" => "Contract Deploy:" | ||
| "TRANSFER" => "Transfer:" | ||
| action => action | ||
|> leptos.text_fragment | ||
fun () => | ||
leptos.div [ | ||
$'"class=\\\"flex flex-1 flex-col\\\""' | ||
] fun () => :>(;[ | ||
leptos.grid_pair | ||
{ padding = Some ""; cols = None; class = "" } | ||
fun () => "Method" |> leptos.text_fragment | ||
fun () => | ||
match method with | ||
| Some method => | ||
method | ||
|> to_string | ||
|> leptos.text_fragment | ||
| None => | ||
"None" |> leptos.text_fragment | ||
|> leptos.element_to_view | ||
]) | ||
|> leptos.element_to_fragment | ||
|> fun (a x : _ i32 _) => :>x | ||
|> leptos.element_to_view | ||
|
||
leptos.grid_pair | ||
{ padding = Some ""; cols = None; class = "items-center py-[4px]" } | ||
fun () => "Deposit" |> leptos.text_fragment | ||
fun () => | ||
transaction.actions_agg.deposit | ||
|> sm'.obj_to_string | ||
|> leptos.text_fragment | ||
|> leptos.element_to_view | ||
|
||
leptos.grid_pair | ||
{ padding = Some ""; cols = None; class = "items-center py-[4px]" } | ||
fun () => "Outcome Status" |> leptos.text_fragment | ||
fun () => | ||
transaction.outcomes.status | ||
|> sm'.obj_to_string | ||
|> leptos.text_fragment | ||
|> leptos.element_to_view | ||
|
||
leptos.grid_pair | ||
{ padding = Some ""; cols = None; class = "items-center py-[4px]" } | ||
fun () => "Fee" |> leptos.text_fragment | ||
fun () => | ||
transaction.outcomes_agg.transaction_fee | ||
|> sm'.obj_to_string | ||
|> leptos.text_fragment | ||
|> leptos.element_to_view | ||
|
||
leptos.grid_pair | ||
{ padding = Some ""; cols = None; class = "items-center py-[4px]" } | ||
fun () => "Block Height" |> leptos.text_fragment | ||
fun () => | ||
transaction.block.block_height | ||
|> sm'.obj_to_string | ||
|> leptos.text_fragment | ||
|> leptos.element_to_view | ||
|
||
leptos.grid_pair | ||
{ padding = Some ""; cols = None; class = "items-center py-[4px]" } | ||
fun () => "Hash" |> leptos.text_fragment | ||
fun () => | ||
transaction.transaction_hash | ||
|> to_string | ||
|> leptos.text_fragment | ||
|> leptos.element_to_view | ||
|
||
leptos.grid_pair | ||
{ padding = Some ""; cols = None; class = "items-center py-[4px]" } | ||
fun () => "Block Hash" |> leptos.text_fragment | ||
fun () => | ||
transaction.included_in_block_hash | ||
|> to_string | ||
|> leptos.text_fragment | ||
|> leptos.element_to_view | ||
|
||
leptos.grid_pair | ||
{ padding = Some ""; cols = None; class = "items-center py-[4px]" } | ||
fun () => "Receipt ID" |> leptos.text_fragment | ||
fun () => | ||
transaction.receipt_id | ||
|> to_string | ||
|> leptos.text_fragment | ||
|> leptos.element_to_view | ||
|
||
if leptos.rw_signal_get_untracked global_state.core_state .debug |> leptos.rw_signal_get then | ||
match transaction.logs with | ||
| ;[] => ;[] |> leptos.views_to_view | ||
| _ => | ||
leptos.grid_pair | ||
{ padding = Some ""; cols = None; class = "items-center py-[4px]" } | ||
fun () => "Logs" |> leptos.text_fragment | ||
fun () => | ||
(a transaction.logs : _ i32 _) | ||
|> am'.map_vec sm'.from_std_string | ||
|> sm'.concat "\n" | ||
|> sm'.replace "\\n" "\n" | ||
|> leptos.text_block_pre "[max-height:20vh]" | ||
|> leptos.element_to_fragment | ||
|> leptos.element_to_view | ||
else ;[] |> leptos.views_to_view | ||
]) | ||
|> leptos.element_to_view | ||
]) |
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,93 @@ | ||
open rust_operators | ||
|
||
|
||
inl render () = | ||
print_static "<transactions.render>" | ||
leptos.log $'"transactions.render ()"' | ||
|
||
inl global_state : state.global_state = leptos.use_context () |> optionm'.unwrap | ||
|
||
inl url = leptos.create_memo fun () => | ||
inl account = "i574n.near" | ||
|
||
$'"https://api2.nearblocks.io/v1/account/" + !account + "/txns?&order=desc&page=1&per_page=25"' | ||
|> Some | ||
|> optionm'.box | ||
|> fun x => | ||
inl x_log = x |> sm'.format_debug | ||
leptos.log $'"transactions.render () / url create_memo / result: " + string !x_log + ""' | ||
x | ||
|
||
inl root : rust.func0 (option (result model.near.nearblocks.root string)) = | ||
leptos.use_request (fun () => url |> leptos.memo_get) model.near.nearblocks.root_unbox | ||
|
||
inl txns : rust.func0 (option (result (array_base (unativeint * heap model.near.nearblocks.txn)) string)) = | ||
rust.move fun () => | ||
root | ||
|> rust.func0_get | ||
|> optionm.map fun result => | ||
result | ||
|> resultm.map fun result => | ||
(a result.txns : _ i32 _) | ||
|> am'.enumerate | ||
|> am'.map_vec fun i, x => i, heap x | ||
|> fun (a x : _ i32 _) => x | ||
|> Some | ||
|> resultm.flatten_option | ||
|> fun x => | ||
inl x_log = x |> sm'.format_debug | ||
leptos.log $'"transactions.render () / txns move / result length: " + (!x_log |> string |> String.length |> string) + ""' | ||
x | ||
|
||
;[ | ||
leptos.accordion "Transactions" true fun () => | ||
match txns |> rust.func0_get with | ||
| Some (Ok transactions) => | ||
leptos.div [ | ||
$'"class=\\\"grid flex-1 py-[10px] px-[12px] [gap:15px] sm:[grid-template-columns:repeat(auto-fill,minmax(500px,1fr))]\\\""' | ||
] fun () => | ||
leptos.for | ||
transactions | ||
fun _, transaction => transaction.transaction_hash | ||
fun index, transaction' => | ||
!transaction' | ||
|> transaction.render (index |> i64) | ||
|> leptos.element_to_fragment | ||
|> leptos.view_to_fragment | ||
|> leptos.element_to_fragment | ||
| Some (Error error) => | ||
:>(;[ | ||
leptos.x_red_svg () |> leptos.element_to_view | ||
error |> leptos.text_view | ||
]) | ||
| _ => | ||
leptos.div [ | ||
$'"class=\\\"grid place-content-center py-[10vh]\\\""' | ||
] fun () => | ||
leptos.div [ | ||
$'"class=\\\"flex flex-1 [gap:4px] items-center\\\""' | ||
] fun () => :>(;[ | ||
leptos.loading_svg () |> leptos.element_to_view | ||
$'"Loading..."' |> leptos.text_view | ||
]) | ||
|> leptos.element_to_fragment | ||
|> leptos.element_to_fragment | ||
|> leptos.element_to_view | ||
|
||
if leptos.rw_signal_get_untracked global_state.core_state .debug |> leptos.rw_signal_get then | ||
leptos.accordion "Debug" true fun () => | ||
:>(;[ | ||
leptos.grid_pair | ||
{ padding = None; cols = None; class = "" } | ||
fun () => "Transactions" |> leptos.text_fragment | ||
fun () => | ||
txns | ||
|> rust.func0_get | ||
|> sm'.format_pretty' | ||
|> sm'.from_std_string | ||
|> leptos.text_block_pre "[max-height:70vh]" | ||
|> leptos.element_to_fragment | ||
]) | ||
|> leptos.element_to_view | ||
else ;[] |> leptos.views_to_view | ||
] |
Oops, something went wrong.