private async Task <EventABI[]> GetEventAbisAsync(IEventSubscriptionDto eventSubscription) { if (eventSubscription.ContractId == null) { return(null); } if (!eventSubscription.CatchAllContractEvents && eventSubscription.EventSignatures.Count == 0) { return(null); } var contractDto = await SubscriberContractRepository.GetAsync(eventSubscription.SubscriberId, eventSubscription.ContractId.Value).ConfigureAwait(false); ContractABI contractAbi = contractDto.Abi == null ? null : _abiDeserializer.DeserialiseContract(contractDto.Abi); if (contractAbi == null) { return(null); } if (eventSubscription.CatchAllContractEvents) { return(contractAbi.Events); } return(contractAbi.Events.Where(e => eventSubscription.EventSignatures.Contains(e.Sha3Signature)).ToArray()); }
private async Task <EventAddressMatcher> CreateEventAddressMatcherAsync(IEventSubscriptionDto eventSubscription) { var addressDtos = await EventSubscriptionAddressRepository.GetManyAsync(eventSubscription.Id).ConfigureAwait(false); var addressMatcher = new EventAddressMatcher(addressDtos.Select(a => a.Address)); return(addressMatcher); }
private async Task <EventParameterMatcher> CreateParameterMatcherAsync(IEventSubscriptionDto eventSubscription) { var parameterConditionDtos = await ParameterConditionRepository.GetManyAsync(eventSubscription.Id).ConfigureAwait(false); var parameterConditions = parameterConditionDtos.Select(c => ParameterCondition.Create(c.ParameterOrder, c.Operator, c.Value)); var parameterMatcher = new EventParameterMatcher(parameterConditions); return(parameterMatcher); }
public async Task <IEventMatcher> LoadAsync(IEventSubscriptionDto eventSubscription) { var eventAbis = await GetEventAbisAsync(eventSubscription).ConfigureAwait(false); var addressMatcher = await CreateEventAddressMatcherAsync(eventSubscription).ConfigureAwait(false); var parameterMatcher = await CreateParameterMatcherAsync(eventSubscription).ConfigureAwait(false); var matcher = new EventMatcher(eventAbis, addressMatcher, parameterMatcher); return(matcher); }
private async Task <EventSubscription> LoadEventSubscriptionsAsync(IEventSubscriptionDto subscriptionConfig) { var matcher = await EventMatcherFactory.LoadAsync(subscriptionConfig).ConfigureAwait(false); var state = await ConfigurationRepository.EventSubscriptionStates.GetAsync(subscriptionConfig.Id).ConfigureAwait(false); var handlerCoOrdinator = new EventHandlerManager(ConfigurationRepository.EventHandlerHistoryRepo); var subscription = new EventSubscription( subscriptionConfig.Id, subscriptionConfig.SubscriberId, matcher, handlerCoOrdinator, state); await AddEventHandlers(subscription).ConfigureAwait(false); return(subscription); }