evm/Token/Interface

examples/evm/Token/Interface.omg

examples/evm/Token/Interface.omg37 lines
1-- Constructor, signals and operation boundaries. No storage or handlers.
2let S = std:EVM/Solidity
3let Events =
4      < Transfer : { from : S.Indexed S.Address, to : S.Indexed S.Address, value : Word 256 }
5      | Approval : { owner : S.Indexed S.Address, spender : S.Indexed S.Address, value : Word 256 }
6      >
7let Errors =
8      < InsufficientBalance : { have : Word 256, want : Word 256 }
9      | InsufficientAllowance : { have : Word 256, want : Word 256 }
10      | Unauthorized
11      | Panic : { code : Word 256 }
12      >
13let Imm = { owner : Word 160, decimals : Word 8 }
14let Args = { supply : Word 256, decimals : Word 8 }
15let O = std:EVM/Operations
16let operations
17    : O.Schema
18    = O.interface
19        { mint = O.writing { Args = { to : S.Address, amount : Word 256 }, Result = {} }
20        , transfer = O.writing { Args = { to : S.Address, amount : Word 256 }, Result = Bool }
21        , approve = O.writing { Args = { spender : S.Address, amount : Word 256 }, Result = Bool }
22        , transferFrom =
23            O.writing
24              { Args = { from : S.Address, to : S.Address, amount : Word 256 }, Result = Bool }
25        , balanceOf = O.reading { Args = { owner : S.Address }, Result = Word 256 }
26        , allowance =
27            O.reading { Args = { owner : S.Address, spender : S.Address }, Result = Word 256 }
28        , totalSupply = O.reading { Args = {}, Result = Word 256 }
29        , decimals = O.reading { Args = {}, Result = Word 8 }
30        , name = O.reading { Args = {}, Result = Text }
31        , symbol = O.reading { Args = {}, Result = Text }
32        , transferRaw =
33            O.on
34              (O.Routes.Native O.Name.Field)
35              (O.writing { Args = { to : S.Address, amount : Word 256 }, Result = {} })
36        }
37in  { Args, Imm, Events, Errors, operations }
Your result
Complete file: examples/evm/Token/Interface.omg · with imports