-
Notifications
You must be signed in to change notification settings - Fork 0
/
CrcOrganisationSignupDetailExtractor.cs
37 lines (32 loc) · 1.34 KB
/
CrcOrganisationSignupDetailExtractor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;
using System.Linq;
using CirclesLand.BlockchainIndexer.TransactionDetailModels;
using Nethereum.RPC.Eth.DTOs;
namespace CirclesLand.BlockchainIndexer.DetailExtractors
{
public static class CrcOrganisationSignupDetailExtractor
{
public static IEnumerable<IDetail> Extract(Transaction transactionData, TransactionReceipt receipt)
{
var log = receipt.Logs
.FirstOrDefault(o => TransactionClassifier.GetTopics(o).Contains(Settings.CrcOrganisationSignupEventTopic));
if (log == null)
{
throw new Exception("The supplied transaction is not a valid CRC 'organization signup' " +
"transaction because it misses a log entry with " +
$"topic {Settings.CrcOrganisationSignupEventTopic}.");
}
var isCrcOrganisationSignup =
TransactionClassifier.IsCrcOrganisationSignup(log, out var organisationAddress);
if (!isCrcOrganisationSignup)
{
throw new Exception("The supplied transaction and receipt is not a CrcOrganisationSignup.");
}
yield return new CrcOrganisationSignup
{
Organization = organisationAddress
};
}
}
}