evm/Token/Queries
examples/evm/Token/Queries.omg
examples/evm/Token/Queries.omg32 lines
1-- Run several Token views on one snapshot. There are no selectors here:
2-- the bound group's local calls run the bodies used by its wire routes.
3let T = ./Implementation.omg
4let H = T.storage.bind T.implement
5let I = ./Interface.omg
6let Input = \{A B : Type} (_ : T.C.Method T.C.Errors A B) -> A
7let remote = (T.C.use I.operations).solidity
8let Query =
9 < Balance : Input remote.balanceOf
10 | Allowance : Input remote.allowance
11 | Supply
12 >
13let query
14 : Query -> T.C.Action T.State T.C.Mode.View (Word 256)
15 = \request {extra} ->
16 merge
17 { Balance = \p -> (H.methods.local.balanceOf p).call @extra
18 , Allowance = \p -> (H.methods.local.allowance p).call @extra
19 , Supply = (H.methods.local.totalSupply {=}).call @extra
20 }
21 request
22let run
23 : List Query -> T.C.Action T.State T.C.Mode.View (List (Word 256))
24 = std:Monad.traverse
25 @0
26 @(T.C.Action T.State T.C.Mode.View)
27 (T.C.monad @T.State T.C.Mode.View)
28 @0
29 @Query
30 @(Word 256)
31 query
32in { Query, run }