aeternity / aesophia

Stand alone compiler for the Sophia smart contract language
https://docs.aeternity.com/aesophia
ISC License
51 stars 19 forks source link

4 values in dataype event lead to error in compiler #374

Closed marc0olo closed 1 year ago

marc0olo commented 2 years ago

the docs say that events can have 0-3 indexed values:

following event definition is producing an error in the compiler:

    datatype event 
        = Transfer(indexed address, indexed address, indexed int)
        | Approval(indexed address, indexed address, indexed int, bool)
        | ApprovalForAll(indexed address, indexed address, bool)

error:

type_error: The event constructor Approval (at line 13, column 11) has too many indexed values (max 3)
At: Line 13, column 11

is 3 the maximum amount of values we can provide to events in general?! is this a bug? we should fix and/or clarify in the docs

hanssv commented 2 years ago

The docs clearly say that A field is indexed if it fits in a 32-byte word, i.e. - bool - int - bits - address - oracle(_, _) - oracle_query(_, _) - contract types - bytes(n) for n ≤ 32, in particular hash - for "convenience" the indexed keyword is just for decoration/documentation - I.e. Approval in your example have 4 indexed fields. This is because of reasons - i.e. that Ethereum/EVM works like this and it was decided doing the same was a good thing.

marc0olo commented 2 years ago

sorry for not reading the docs THAT clearly. I assumed that this as to be set explicitely. my proposal is to remove indexed then completely as it is nonsense IMO.

can you remember or tell me why we have a limit for 3 of those values? just wondering. I guess there is a reason for that

marc0olo commented 2 years ago

@arjanvaneersel here we have it clarified now. sorry for the inconvenience in general. we should have checked the AEX-141 proposal better. my proposal is to just replace "bool" with a "string" in the end