Commit Graph

10 Commits

Author SHA1 Message Date
Ben Bierens 577e02b8a2
enables stylecheck (#36)
* enables stylecheck

* applies style check

* Applying style check

* uses alias to fix ambiguity
2023-03-09 10:58:54 +01:00
Mark Spanbroek d001ee8e01 Use `solidityType()` to check indexed event parameter 2022-09-21 10:27:45 +10:00
Eric Mastro 31ffc8992f Update compile time check to use when 2022-09-21 10:27:45 +10:00
Eric Mastro ae2d33aacd Support 1.2.16 distinctBase compilation error 2022-09-21 10:27:45 +10:00
Eric Mastro 0adf56c65b Support distinct types for Event fields
Add support for indexed (and non-indexed) Event fields types that are distinct `ValueType` or `SmallByteArray`. For example,
```nim
type
  DistinctAlias = distinct array[32, byte]
  MyEvent = object of Event
    a {.indexed.}: DistinctAlias
    b: DistinctAlias # also allowed for non-indexed fields

## The below funcs generally need to be included for ABI
## encoding/decoding purposes when implementing distinct types.

func toArray(value: DistinctAlias): array[32, byte] =
  array[32, byte](value)

func encode*(encoder: var AbiEncoder, value: DistinctAlias) =
  encoder.write(value.toArray)

func decode*(decoder: var AbiDecoder,
             T: type DistinctAlias): ?!T =
  let d = ?decoder.read(type array[32, byte])
  success DistinctAlias(d)
```
2022-09-21 10:27:45 +10:00
Mark Spanbroek e3d5ce5122 Fix decoding of events with dynamic arguments
Such as byte sequences or strings.
2022-04-13 10:10:53 +02:00
Mark Spanbroek c49a9cbae9 Decode indexed event parameters bytes1 up to bytes32 2022-03-29 10:48:00 +02:00
Mark Spanbroek 72ccb57b98 Fix for Nim 1.2.x 2022-02-09 14:50:51 +01:00
Mark Spanbroek ff5a35aac0 Define and subscribe to solidity events 2022-02-09 14:50:51 +01:00
Mark Spanbroek 21f98c4086 Event decoding from data and topics 2022-02-09 14:50:51 +01:00