Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fc1943s committed Sep 19, 2024
1 parent eeb4759 commit 32aba7c
Show file tree
Hide file tree
Showing 85 changed files with 9,227 additions and 7,691 deletions.
64 changes: 43 additions & 21 deletions apps/chat/contract/chat_contract.dib
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,42 @@ trace Debug (fun () => "") id

#!markdown

### get_account_info

#!spiral

inl get_account_info
(state : rust.ref state)
(account_id : near.account_id)
: optionm'.option' (sm'.std_string * (u64 * u32))
=
inl account_map : rust.ref (near.lookup_map near.account_id sm'.std_string) =
!\($'$"&!state.2"')

inl alias_map : rust.ref (near.lookup_map sm'.std_string (mapm.hash_map near.account_id (u64 * u32))) =
!\($'$"&!state.1"')

!\\(account_id, $'"let result = !account_map.get(&$0).and_then(|alias| { //"') : ()
!\($'" !alias_map //"') : ()
!\($'" .get(alias) //"') : ()
!\($'" .map(|accounts| { //"') : ()
!\($'" let result = (alias.clone(), *accounts.get(&!account_id).unwrap()); //"') : ()
!\($'" (result.0, result.1.0, result.1.1) //"') : ()
!\($'" }) //"') : ()
!\($'"}); //"') : ()

inl result = !\($'"result"')

trace Debug
fun () => $'$"chat_contract.get_account_info"'
fun () => { account_id result }

trace Debug (fun () => "") id

result

#!markdown

### main

#!spiral
Expand Down Expand Up @@ -368,31 +404,17 @@ inl main () =
!\($'"pub fn get_account_info( //"') : ()
!\($'" &self, //"') : ()
!\($'" account_id: near_sdk::AccountId, //"') : ()
!\($'") -> Option<(String, (u64, u32))> { //"') : ()

inl account_map : rust.ref (near.lookup_map near.account_id sm'.std_string) =
!\($'$"&self.0.2"')

inl alias_map : rust.ref (near.lookup_map sm'.std_string (mapm.hash_map near.account_id (u64 * u32))) =
!\($'$"&self.0.1"')
!\($'") -> Option<(String, u64, u32)> { //"') : ()

inl state = !\($'$"&self.0"')
inl account_id : near.account_id = !\($'$"account_id"')

trace Debug
fun () => $'$"chat_contract.get_account_info"'
fun () => { account_id }
inl result = account_id |> get_account_info state
$'let _result = !result in _result |> (fun x -> Fable.Core.RustInterop.emitRustExpr x "$0 } // 4") // 3' : ()

trace Debug (fun () => "") id

!\\(account_id, $'" !account_map.get(&$0).and_then(|alias| { //"') : ()
!\($'" !alias_map //"') : ()
!\($'" .get(alias) //"') : ()
!\($'" .map(|accounts| (alias.clone(), *accounts.get(&!account_id).unwrap())) //"') : ()
!\($'" }) //"') : ()
!\($'"} // 2"') : ()

!\($'"} //"') : ()

!\($'"} //"') : ()
!\($'"} // 1"') : ()

2

Expand Down Expand Up @@ -466,7 +488,7 @@ inl main () =
// !\($'"} // b"') : ()

!\($'"fn _main() //"') : ()
!\($'"{ //"') : ()
!\($'"{ { //"') : ()

inl rec loop' i' =
if i' <= n
Expand Down
Loading

0 comments on commit 32aba7c

Please sign in to comment.