near¶
In [ ]:
open rust
open rust.rust_operators
In [ ]:
//// test
open testing
near¶
vector¶
In [ ]:
nominal vector t =
`(
global "#if FABLE_COMPILER\n[<Fable.Core.Erase; Fable.Core.Emit(\"near_sdk::store::vec::Vector<$0>\")>]\n#endif\ntype near_sdk_store_vec_Vector<'T> = class end"
$'' : $'near_sdk_store_vec_Vector<`t>'
)
lookup_map¶
In [ ]:
nominal lookup_map k v =
`(
global "#if FABLE_COMPILER\n[<Fable.Core.Erase; Fable.Core.Emit(\"near_sdk::store::LookupMap<$0, $1>\")>]\n#endif\ntype near_sdk_store_LookupMap<'K, 'V> = class end"
$'' : $'near_sdk_store_LookupMap<`k, `v>'
)
iterable_set¶
In [ ]:
nominal iterable_set t =
`(
global "#if FABLE_COMPILER\n[<Fable.Core.Erase; Fable.Core.Emit(\"near_sdk::store::IterableSet<$0>\")>]\n#endif\ntype near_sdk_store_IterableSet<'T> = class end"
$'' : $'near_sdk_store_IterableSet<`t>'
)
account_id¶
In [ ]:
nominal account_id =
`(
global "#if FABLE_COMPILER\n[<Fable.Core.Erase; Fable.Core.Emit(\"near_sdk::AccountId\")>]\n#endif\ntype near_sdk_AccountId = class end"
$'' : $'near_sdk_AccountId'
)
new_lookup_map¶
In [ ]:
inl new_lookup_map prefix =
!\($'"near_sdk::store::LookupMap::new(!prefix)"')
new_iterable_set¶
In [ ]:
inl new_iterable_set prefix =
!\($'"near_sdk::store::IterableSet::new(!prefix)"')
new_vector¶
In [ ]:
inl new_vector prefix =
!\\(prefix, $'"near_sdk::store::vec::Vector::new($0)"')
vector_extend¶
In [ ]:
inl vector_extend forall t. (vec : am'.vec t) (vector : rust.ref (rust.mut' (vector t))) : () =
(!\\(vec, $'"true; !vector.extend($0); //"') : bool) |> ignore
vector_to_vec¶
In [ ]:
inl vector_to_vec forall (t : * -> *) u. (vector : t (vector u)) : am'.vec u =
!\($'$"!vector.iter().map(|x| *x).collect::<Vec<_>>()"')
keccak512¶
In [ ]:
inl keccak512 (entropy : am'.vec u8) : am'.vec u8 =
!\\(entropy, $'$"near_sdk::env::keccak512(&$0)"')
log¶
In [ ]:
inl log text : () =
(!\\(text, $'$"true; near_sdk::log\!(\\\"{{}}\\\", $0)"') : bool) |> ignore
panic_str¶
In [ ]:
inl panic_str (text : string) : () =
(!\\(text, $'$"true; near_sdk::env::panic_str(&*$0); //"') : bool) |> ignore
lookup_get¶
In [ ]:
inl lookup_get forall k v.
(key : k)
(map : rust.ref (rust.mut' (lookup_map k v)))
: optionm'.option' (rust.ref v)
=
!\\(key, $'$"!map.get(&$0)"')
lookup_insert¶
In [ ]:
inl lookup_insert forall k v.
(key : k)
(value : v)
(map : rust.ref (rust.mut' (lookup_map k v)))
: ()
=
(!\\((key, value), $'$"true; !map.insert(&$0, $1); //"') : bool) |> ignore
iterable_set_insert¶
In [ ]:
inl iterable_set_insert forall t.
(x : t)
(set : rust.ref (rust.mut' (iterable_set t)))
: bool
=
!\\(x, $'$"!set.insert($0)"')
iterable_set_remove¶
In [ ]:
inl iterable_set_remove forall t.
(x : rust.ref t)
(set : rust.ref (rust.mut' (iterable_set t)))
: bool
=
!\\(x, $'$"!set.remove($0)"')
iterable_set_contains¶
In [ ]:
inl iterable_set_contains forall t.
(x : rust.ref t)
(set : rust.ref (rust.mut' (iterable_set t)))
: bool
=
!\\(x, $'$"!set.contains($0)"')
near_token¶
In [ ]:
nominal near_token =
`(
global "#if FABLE_COMPILER\n[<Fable.Core.Erase; Fable.Core.Emit(\"near_token::NearToken\")>]\n#endif\ntype near_token_NearToken = class end"
$'' : $'near_token_NearToken'
)
near_token_sdk¶
In [ ]:
nominal near_token_sdk =
`(
global "#if FABLE_COMPILER\n[<Fable.Core.Erase; Fable.Core.Emit(\"near_sdk::NearToken\")>]\n#endif\ntype near_sdk_NearToken = class end"
$'' : $'near_sdk_NearToken'
)
random_seed¶
In [ ]:
inl random_seed () : am'.vec u8 =
!\($'$"near_sdk::env::random_seed()"')
block_timestamp¶
In [ ]:
inl block_timestamp () : u64 =
!\($'$"near_sdk::env::block_timestamp()"')
block_height¶
In [ ]:
inl block_height () : u64 =
!\($'$"near_sdk::env::block_height()"')
epoch_height¶
In [ ]:
inl epoch_height () : u64 =
!\($'$"near_sdk::env::epoch_height()"')
account_balance¶
In [ ]:
inl account_balance () : near_token =
!\($'$"near_sdk::env::account_balance()"')
predecessor_account_id¶
In [ ]:
inl predecessor_account_id () : account_id =
!\($'$"near_sdk::env::predecessor_account_id()"')
signer_account_id¶
In [ ]:
inl signer_account_id () : account_id =
!\($'$"near_sdk::env::signer_account_id()"')
as_yoctonear¶
In [ ]:
inl as_yoctonear forall t. (gas : t) : rust.u128 =
!\\(gas, $'"$0.as_yoctonear()"')
near_price_in_usd¶
In [ ]:
inl near_price_in_usd () =
6.68f64
gas_to_usd¶
In [ ]:
inl gas_to_usd (gas : u64) =
(gas |> f64) / 10_000_000_000_000_000 * near_price_in_usd ()
tokens_to_usd¶
In [ ]:
inl tokens_to_usd (tokens : rust.u128) =
(tokens |> rust.f64) / 1_000_000_000_000_000_000_000_000 * near_price_in_usd ()