using System; using System.Collections.Generic; using System.Threading.Tasks; using Nethereum.ABI.FunctionEncoding.Attributes; using Nethereum.ABI.Model; using Nethereum.Contracts.Extensions; using Nethereum.Hex.HexTypes; using Nethereum.JsonRpc.Client; using Nethereum.RPC.Eth.DTOs; using Newtonsoft.Json.Linq; namespace Nethereum.Contracts { /// /// Event handler for a typed EventMessage to create filters and access to logs /// /// public class Event : EventBase where TEventMessage : IEventDTO, new() { public Event(Contract contract) : this(contract.Eth.Client, contract.Address) { } public Event(IClient client, string contractAddress) : base(client, contractAddress, typeof(TEventMessage)) { } public Event(IClient client) : this(client, null) { } public List> DecodeAllEventsForEvent(JArray logs) { return EventABI.DecodeAllEvents(logs); } public List> DecodeAllEventsForEvent(FilterLog[] logs) { return EventABI.DecodeAllEvents(logs); } public static List> DecodeAllEvents(FilterLog[] logs) { return DecodeAllEvents(logs); } public static EventLog DecodeEvent(FilterLog log) { return GetEventABI().DecodeEvent(log); } public static EventABI GetEventABI() { return EventExtensions.GetEventABI(); } #if !DOTNET35 public async Task>> GetAllChangesAsync(NewFilterInput filterInput) { if (!EventABI.IsFilterInputForEvent(ContractAddress, filterInput)) throw new FilterInputNotForEventException(); var logs = await EthGetLogs.SendRequestAsync(filterInput).ConfigureAwait(false); return DecodeAllEvents(logs); } public async Task>> GetAllChangesAsync(HexBigInteger filterId) { var logs = await EthFilterLogs.SendRequestAsync(filterId).ConfigureAwait(false); return DecodeAllEvents(logs); } public async Task>> GetFilterChangesAsync(HexBigInteger filterId) { var logs = await EthGetFilterChanges.SendRequestAsync(filterId).ConfigureAwait(false); return DecodeAllEvents(logs); } #endif } }