Example #1
0
        public static EventLogQueueMessage ToQueueMessage(this DecodedEvent decodedEvent)
        {
            var msg = new EventLogQueueMessage
            {
                Key             = decodedEvent.Key,
                Event           = decodedEvent.DecodedEventDto,
                State           = decodedEvent.State,
                Transaction     = decodedEvent.Transaction,
                Log             = decodedEvent.Log,
                ParameterValues = decodedEvent.Event.Select(p => new EventParameterValue {
                    Order   = p.Parameter.Order,
                    AbiType = p.Parameter.ABIType.Name,
                    Name    = p.Parameter.Name,
                    Value   = p.Result,
                    Indexed = p.Parameter.Indexed
                }).ToList()
            };

            return(msg);
        }
Example #2
0
        public static TEventDto GetDecodedEventDto <TEventDto>(this EventLogQueueMessage msg) where TEventDto : class, new()
        {
            if (msg.Event == null)
            {
                return(null);
            }
            if (msg.Event is TEventDto dto)
            {
                return(dto);
            }
            if (msg.Event is JObject jObject)
            {
                return(jObject.ToObject <TEventDto>());
            }
            if (msg.Log != null)
            {
                return(msg.Log.DecodeEvent <TEventDto>()?.Event);
            }

            return(null);
        }