public List <T> parseLogs( string abi, string contractAddress, string eventName, object[] ft1, object[] ft2, object[] ft3, ulong fromBlock, ulong toBlock, bool useDefaultBlockParameterSetting) { // Get the block parameters for searching log files (BlockParameter fBlock, BlockParameter tBlock) = AppServices.getBlockParameterConfiguration(fromBlock, toBlock, useDefaultBlockParameterSetting); // Create list containing the returned list of log files List <T> logs = new List <T>(); // Create the filter input to extract the requested log entries var filterInput = AppServices.web3.Eth.GetContract(abi, contractAddress).GetEvent(eventName).CreateFilterInput(filterTopic1: ft1, filterTopic2: ft2, filterTopic3: ft3, fromBlock: fBlock, toBlock: tBlock); // Add all the returned logs to the log list foreach (FilterLog log in AppServices.web3.Eth.Filters.GetLogs.SendRequestAsync(filterInput).Result.Reverse()) { // Create a new Log Item T logItem = new T(); // Parse the log into the logItem logItem.parseLog(log); // Add the log item to the list logs.Add(logItem); } // Return the list of log files return(logs); }
public object Get(GetBondLogs request) { // Retrieve the block parameters (BlockParameter fromBlock, BlockParameter toBlock) = AppServices.getBlockParameterConfiguration(request.FromBlock, request.ToBlock, (request.Hash.IsEmpty() == true) && (request.Owner.IsEmpty() == true) && (request.Info.IsEmpty() == true)); // Create the filter variables for selecting only the requested log entries object[] ft1 = (request.Hash.IsEmpty() == true ? null : new object[]{ request.Hash.HexToByteArray() }); object[] ft2 = (request.Owner.IsEmpty() == true ? null : new object[]{ request.Owner }); object[] ft3 = (request.Info.IsEmpty() == true ? null : new object[1]); // Adjust the filterinpu for ft3 if a value has been provided if (request.Info.IsEmpty() == false) { if (request.Info.HasHexPrefix() == true) ft3[0] = request.Info.HexToByteArray(); else if (uint.TryParse(request.Info, out uint val) == true) ft3[0] = val.ToString("X64").EnsureHexPrefix().HexToByteArray(); else ft3[0] = AppModelConfig.convertToHex64(request.Info).HexToByteArray(); } // Retrieve the contract info var contract = AppServices.web3.Eth.GetContract(AppModelConfig.BOND.abi, AppServices.GetEcosystemAdr(request.ContractAdr).BondContractAdr); // Create the filter input to extract the requested log entries var filterInput = contract.GetEvent("LogBond").CreateFilterInput(filterTopic1: ft1, filterTopic2: ft2, filterTopic3: ft3, fromBlock: fromBlock, toBlock: toBlock); // Extract all the logs as specified by the filter input var res = AppServices.web3.Eth.Filters.GetLogs.SendRequestAsync(filterInput).Result; // Create the return instance var logs = new BondLogs() { EventLogs = new List<BondEventLog>() }; // Interate through all the returned logs and add them to the logs list for (int i=res.Length - 1; i>=0; i--) { var log = new BondEventLog(); log.BlockNumber = Convert.ToUInt64(res[i].BlockNumber.HexValue, 16); log.Hash = res[i].Topics[1].ToString(); log.Owner = AppModelConfig.getAdrFromString32(res[i].Topics[2].ToString()); log.Timestamp = Convert.ToUInt64(res[i].Data.Substring(2 + 0 * 64, 64), 16); log.State = (BondState)Convert.ToInt32(res[i].Data.Substring(2 + 1 * 64,64), 16); if (AppModelConfig.isEmptyHash(log.Hash)) log.Info = AppModelConfig.FromHexString(res[i].Topics[3].ToString()); else if ((log.State == BondState.SecuredReferenceBond) || (log.State == BondState.LockedReferenceBond)) log.Info = res[i].Topics[3].ToString().EnsureHexPrefix(); else log.Info = Convert.ToInt64(res[i].Topics[3].ToString(), 16).ToString(); logs.EventLogs.Add(log); } // Return the list of bond logs return logs; }
public object Get(GetBankLogs request) { // Retrieve the block parameters (BlockParameter fromBlock, BlockParameter toBlock) = AppServices.getBlockParameterConfiguration(request.FromBlock, request.ToBlock, (request.Success == SuccessFilter.All) && (request.InternalReferenceHash.IsEmpty() == true)); // Create the filter variables for selecting only the requested log entries object[] ft1 = (request.InternalReferenceHash.IsEmpty() == true ? null : new object[] { request.InternalReferenceHash.HexToByteArray() }); object[] ft2 = { (uint)request.AccountType }; object[] ft3 = (request.Success == SuccessFilter.All ? null : (request.Success == SuccessFilter.Positive ? new object[] { true } : new object[] { false })); // Retrieve the contract info var contract = AppServices.web3.Eth.GetContract(AppModelConfig.BANK.abi, AppServices.GetEcosystemAdr(request.ContractAdr).BankContractAdr); // Create the filter input to extract the requested log entries var filterInput = contract.GetEvent("LogBank").CreateFilterInput(filterTopic1: ft1, filterTopic2: ft2, filterTopic3: ft3, fromBlock: fromBlock, toBlock: toBlock); // Extract all the logs as specified by the filter input var res = AppServices.web3.Eth.Filters.GetLogs.SendRequestAsync(filterInput).Result; // Create the return instance var logs = new BankLogs() { EventLogs = new List <BankEventLog>() }; // Interate through all the returned logs and add them to the logs list for (int i = res.Length - 1; i >= 0; i--) { var log = new BankEventLog(); log.BlockNumber = Convert.ToUInt64(res[i].BlockNumber.HexValue, 16); log.InternalReferenceHash = res[i].Topics[1].ToString(); log.AccountType = (AccountType)Convert.ToUInt64(res[i].Topics[2].ToString(), 16); log.Success = res[i].Topics[3].ToString().EndsWith("1"); log.PaymentAccountHash = res[i].Data.Substring(2 + 0 * 64, 64).EnsureHexPrefix(); log.PaymentSubject = res[i].Data.Substring(2 + 1 * 64, 64).EnsureHexPrefix().StartsWith("0x000000") ? Convert.ToUInt64(res[i].Data.Substring(2 + 1 * 64, 64), 16).ToString() : res[i].Data.Substring(2 + 1 * 64, 64).EnsureHexPrefix(); log.Info = AppModelConfig.isEmptyHash(res[i].Data.Substring(2 + 2 * 64, 64).EnsureHexPrefix()) ? "0x0" : AppModelConfig.FromHexString(res[i].Data.Substring(2 + 2 * 64, 64)); log.Timestamp = Convert.ToUInt64(res[i].Data.Substring(2 + 3 * 64, 64), 16); log.TransactionType = (TransactionType)Convert.ToUInt64(res[i].Data.Substring(2 + 4 * 64, 64), 16); log.Amount = Convert.ToUInt64(res[i].Data.Substring(2 + 5 * 64, 64), 16); logs.EventLogs.Add(log); } // Return the list of bond logs return(logs); }
public object Get(GetSettlementLogs request) { // Retrieve the block parameters (BlockParameter fromBlock, BlockParameter toBlock) = AppServices.getBlockParameterConfiguration(request.FromBlock, request.ToBlock, (request.SettlementHash.IsEmpty() == true) && (request.AdjustorHash.IsEmpty() == true) && (request.Info.IsEmpty() == true)); // Create the filter variables for selecting only the requested log entries object[] ft1 = (request.SettlementHash.IsEmpty() == true ? null : new object[] { request.SettlementHash.HexToByteArray() }); object[] ft2 = (request.AdjustorHash.IsEmpty() == true ? null : new object[] { request.AdjustorHash.HexToByteArray() }); object[] ft3 = (request.Info.IsEmpty() == true ? null : new object[] { request.Info.HexToByteArray() }); // Retrieve the contract info var contract = AppServices.web3.Eth.GetContract(AppModelConfig.SETTLEMENT.abi, AppServices.GetEcosystemAdr(request.ContractAdr).SettlementContractAdr); // Create the filter input to extract the requested log entries var filterInput = contract.GetEvent("LogSettlement").CreateFilterInput(filterTopic1: ft1, filterTopic2: ft2, filterTopic3: ft3, fromBlock: fromBlock, toBlock: toBlock); // Extract all the logs as specified by the filter input var res = AppServices.web3.Eth.Filters.GetLogs.SendRequestAsync(filterInput).Result; // Create the return instance var logs = new SettlementLogs() { EventLogs = new List <SettlementEventLog>() }; // Interate through all the returned logs and add them to the logs list for (int i = res.Length - 1; i >= 0; i--) { var log = new SettlementEventLog(); log.BlockNumber = Convert.ToUInt64(res[i].BlockNumber.HexValue, 16); log.SettlementHash = res[i].Topics[1].ToString(); log.AdjustorHash = res[i].Topics[2].ToString(); log.Info = res[i].Topics[3].ToString(); log.Timestamp = Convert.ToUInt64(res[i].Data.Substring(2 + 0 * 64, 64), 16); log.State = (SettlementState)Convert.ToInt32(res[i].Data.Substring(2 + 1 * 64, 64), 16); logs.EventLogs.Add(log); } // Return the list of settlement logs return(logs); }
public object Get(GetEcosystemLogs request) { // Retrieve the block parameters (BlockParameter fromBlock, BlockParameter toBlock) = AppServices.getBlockParameterConfiguration(request.FromBlock, request.ToBlock, (request.Subject.IsEmpty() == true) && (request.Day == 0) && (request.Value == 0)); // Create the filter variables for selecting only the requested log entries object[] ft1 = (request.Subject.IsEmpty() == true ? null : new object[] { AppModelConfig.convertToHex64(request.Subject).HexToByteArray() }); object[] ft2 = (request.Day == 0 ? null : new object[] { request.Day }); object[] ft3 = (request.Value == 0 ? null : new object[] { request.Value }); // Retrieve the contract info var contract = AppServices.web3.Eth.GetContract(AppModelConfig.POOL.abi, AppServices.GetEcosystemAdr(request.ContractAdr).PoolContractAdr); // Create the filter input to extract the requested log entries var filterInput = contract.GetEvent("LogPool").CreateFilterInput(filterTopic1: ft1, filterTopic2: ft2, filterTopic3: ft3, fromBlock: fromBlock, toBlock: toBlock); // Extract all the logs as specified by the filter input var res = AppServices.web3.Eth.Filters.GetLogs.SendRequestAsync(filterInput).Result; // Create the return instance var logs = new EcosystemLogs() { EventLogs = new List <EcosystemEventLog>() }; // Interate through all the returned logs and add them to the logs list for (int i = res.Length - 1; i >= 0; i--) { logs.EventLogs.Add(new EcosystemEventLog() { BlockNumber = Convert.ToUInt64(res[i].BlockNumber.HexValue, 16), Subject = AppModelConfig.FromHexString(res[i].Topics[1].ToString()), Day = Convert.ToUInt64(res[i].Topics[2].ToString(), 16), Value = Convert.ToUInt64(res[i].Topics[3].ToString(), 16), Timestamp = Convert.ToUInt64(res[i].Data.Substring(2 + 0 * 64, 64), 16) }); } // Return the list of bond logs return(logs); }