public object Get(GetBond request) { // Get the contract for the Bond by specifying the bond address var contract = AppServices.web3.Eth.GetContract(AppModelConfig.BOND.abi, AppServices.GetEcosystemAdr(request.ContractAdr).BondContractAdr); // BondListEntry entry = contract.GetFunction("get").CallDeserializingToObjectAsync<BondListEntry>(i).Result; // If no bond hash has been provided as part of the request get the corresponding hash that belongs to the provided idx if (request.Hash.IsEmpty() == true) request.Hash = AppModelConfig.convertToHex(contract.GetFunction("get").CallAsync<byte[]>(request.Idx).Result); // Retrieve the bond details from the Blockchain BondDetail bond = contract.GetFunction("dataStorage").CallDeserializingToObjectAsync<BondDetail>(request.Hash.HexToByteArray()).Result; // Set the bond hash to the requested has as specified in the request bond.Hash = request.Hash; bond.EventLogs = new List<BondEventLog>(); // If bond hash is set retrieve the logs for the bond if (AppModelConfig.isEmptyHash(bond.Hash) == false) { bond.EventLogs = ((BondLogs)this.Get( new GetBondLogs {ContractAdr = request.ContractAdr, Hash = request.Hash})).EventLogs; // Just for the Bond specific event logs reverse the order to have the events in ascending order bond.EventLogs.Reverse(); } // Return the bond return bond; }
public object Get(GetAdjustorList request) { // Get the contract for the Adjustor by specifying the adjustor address var contract = AppServices.web3.Eth.GetContract(AppModelConfig.BOND, AppServices.GetEcosystemAdr(request.ContractAdr).AdjustorContractAdr); // Create the adjustor list object and initialise AdjustorList list = new AdjustorList() { Items = new List <AdjustorDetail>() }; // Get the metadata info for the first, next and count of Adjustors list.Info = contract.GetFunction("hashMap").CallDeserializingToObjectAsync <ListInfo>().Result; // Create the idx to continue the search from int lastIdx = (request.FromIdx != 0 ? (int)request.FromIdx :(int)list.Info.CountAllItems); // Define the lower bound int lowerBoundIdx = Math.Max(0, lastIdx - (request.MaxEntries != 0 ? (int)request.MaxEntries : (int)AppModelConfig.defaultNumberEntriesForLazyLoading)); // Iterate through all the possilbe adjustor entries for (int i = lastIdx; i > lowerBoundIdx; i--) { string adjustorHash = AppModelConfig.convertToHex(contract.GetFunction("get").CallAsync <byte[]>(i).Result); // Add the adjustorDetails to the list if a valid hash has been returned if (AppModelConfig.isEmptyHash(adjustorHash) == false) { var adjustor = contract.GetFunction("dataStorage").CallDeserializingToObjectAsync <AdjustorDetail>(adjustorHash.HexToByteArray()).Result; adjustor.Hash = adjustorHash; list.Items.Add(adjustor); } } // Return the adjustor list return(list); }
public object Get(GetAdjustor request) { // Get the contract for the Adjustor by specifying the adjustor address var contract = AppServices.web3.Eth.GetContract(AppModelConfig.BOND, AppServices.GetEcosystemAdr(request.ContractAdr).AdjustorContractAdr); // AdjustorListEntry entry = contract.GetFunction("get").CallDeserializingToObjectAsync<AdjustorListEntry>(i).Result; // If no adjustor hash has been provided as part of the request get the corresponding hash that belongs to the provided idx if (request.Hash.IsEmpty() == true) { request.Hash = AppModelConfig.convertToHex(contract.GetFunction("get").CallAsync <byte[]>(request.Idx).Result); } // Retrieve the adjustor details from the Blockchain AdjustorDetail adjustor = contract.GetFunction("dataStorage").CallDeserializingToObjectAsync <AdjustorDetail>(request.Hash.HexToByteArray()).Result; // Set the adjustor hash to the requested has as specified in the request adjustor.Hash = request.Hash; adjustor.Logs = new List <AdjustorLog>(); // If adjustor hash is set retrieve the logs for the adjustor if (AppModelConfig.isEmptyHash(adjustor.Hash) == false) { adjustor.Logs = ((AdjustorLogs)this.Get( new GetAdjustorLogs { ContractAdr = request.ContractAdr, Hash = request.Hash })).Logs; // Just for the Adjustor specific event logs reverse the order to have the events in ascending order adjustor.Logs.Reverse(); } // Return the adjustor return(adjustor); }
public object Put(AdjustDaylightSaving request) { // Submit and return the transaction hash of the broadcasted transaction return(AppServices.createSignPublishTransaction( AppModelConfig.TRUST.abi, AppServices.GetEcosystemAdr(request.ContractAdr).TrustContractAdr, request.SigningPrivateKey, "adjustDaylightSaving" )); }
public object Get(GetBondList request) { // Get the contract for the Bond by specifying the bond address var contract = AppServices.web3.Eth.GetContract(AppModelConfig.BOND.abi, AppServices.GetEcosystemAdr(request.ContractAdr).BondContractAdr); // Create the bond list object and initialise BondList list = new BondList() { Items = new List <BondDetail>() }; // If no Bond Owner Address has been specified return all the bonds starting from lastIdx in decending order if (request.Owner.IsEmpty() == true) { // Get the metadata info for the first, next and count of Bonds list.Info = contract.GetFunction("hashMap").CallDeserializingToObjectAsync <ListInfo>().Result; // Create the idx to continue the search from int lastIdx = (request.FromIdx != 0 ? (int)request.FromIdx :(int)list.Info.CountAllItems); // Define the lower bound int lowerBoundIdx = Math.Max(0, lastIdx - (request.MaxEntries != 0 ? (int)request.MaxEntries : (int)AppModelConfig.defaultNumberEntriesForLazyLoading)); // Iterate through all the possilbe bond entries for (int i = lastIdx; i > lowerBoundIdx; i--) { string bondHash = AppModelConfig.convertToHex(contract.GetFunction("get").CallAsync <byte[]>(i).Result); // Add the bondDetails to the list if a valid hash has been returned if (AppModelConfig.isEmptyHash(bondHash) == false) { var bond = contract.GetFunction("dataStorage").CallDeserializingToObjectAsync <BondDetail>(bondHash.HexToByteArray()).Result; bond.Hash = bondHash; list.Items.Add(bond); } } } else { // Get all the log files that match the bond owner's address specified List <BondEventLog> logs = ((BondLogs)this.Get( new GetBondLogs { ContractAdr = request.ContractAdr, Owner = request.Owner })).EventLogs; // Filter the list only for Created state entries and sort it with timestamp desc var filteredList = logs.GroupBy(x => x.Hash).Select(x => x.FirstOrDefault()).ToList().OrderByDescending(o => o.Timestamp).ToList(); // Iterate through the list for (int i = 0; i < filteredList.Count; i++) { var bond = contract.GetFunction("dataStorage").CallDeserializingToObjectAsync <BondDetail>(filteredList[i].Hash.HexToByteArray()).Result; bond.Hash = filteredList[i].Hash; list.Items.Add(bond); } } // Return the bond list return(list); }
// ******************************************************************************************** // *** ECOSYSTEM TRANSACTIONS - Set Working Capital expenses, Adjust daylight saving, etc. // ******************************************************************************************** public object Put(SetWcExpenses request) { // Submit and return the transaction hash of the broadcasted transaction return(AppServices.createSignPublishTransaction( AppModelConfig.TRUST.abi, AppServices.GetEcosystemAdr(request.ContractAdr).TrustContractAdr, request.SigningPrivateKey, "setWcExpenses", request.Amount )); }
public object Put(RetirePolicy request) { // Submit and return the transaction hash of the broadcasted transaction return(AppServices.createSignPublishTransaction( AppModelConfig.POLICY.abi, AppServices.GetEcosystemAdr(request.ContractAdr).PolicyContractAdr, request.SigningPrivateKey, "retirePolicy", request.PolicyHash.HexToByteArray() )); }
public object Put(RetireAdjustor request) { // Submit and return the transaction hash of the broadcasted transaction return(AppServices.createSignPublishTransaction( AppModelConfig.TRUST, AppServices.GetEcosystemAdr(request.ContractAdr).TrustContractAdr, request.SigningPrivateKey, "retireAdjustor", request.AdjustorHash.HexToByteArray() )); }
public object Post(CreateBond request) { // Submit and return the transaction hash of the broadcasted transaction return AppServices.createSignPublishTransaction( AppModelConfig.BOND.abi, AppServices.GetEcosystemAdr(request.ContractAdr).BondContractAdr, request.SigningPrivateKey, "createBond", request.Principal, (AppModelConfig.isEmptyHash(request.SecurityReferenceHash) ? AppModelConfig.EMPTY_HASH.HexToByteArray() : request.SecurityReferenceHash.HexToByteArray()) ); }
public object Post(ProcessBankPaymentAdvice request) { // Submit and return the transaction hash of the broadcasted transaction return(AppServices.createSignPublishTransaction( AppModelConfig.BANK.abi, AppServices.GetEcosystemAdr(request.ContractAdr).BankContractAdr, request.SigningPrivateKey, "processPaymentAdvice", request.AdviceIdx, request.BankTransactionIdx )); }
public object Put(SetExpectedSettlementAmount request) { // Submit and return the transaction hash of the broadcasted transaction return(AppServices.createSignPublishTransaction( AppModelConfig.SETTLEMENT.abi, AppServices.GetEcosystemAdr(request.ContractAdr).SettlementContractAdr, request.SigningPrivateKey, "setExpectedSettlementAmount", request.SettlementHash.HexToByteArray(), request.AdjustorHash.HexToByteArray(), request.ExpectedSettlementAmount )); }
public object Post(CreateSettlement request) { // Submit and return the transaction hash of the broadcasted transaction return(AppServices.createSignPublishTransaction( AppModelConfig.SETTLEMENT.abi, AppServices.GetEcosystemAdr(request.ContractAdr).SettlementContractAdr, request.SigningPrivateKey, "createSettlement", request.AdjustorHash.HexToByteArray(), (AppModelConfig.isEmptyHash(request.PolicyHash) ? AppModelConfig.EMPTY_HASH.HexToByteArray() : request.PolicyHash.HexToByteArray()), (AppModelConfig.isEmptyHash(request.DocumentHash) ? AppModelConfig.EMPTY_HASH.HexToByteArray() : request.DocumentHash.HexToByteArray()) )); }
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 Put(UpdatePolicy request) { // Submit and return the transaction hash of the broadcasted transaction return(AppServices.createSignPublishTransaction( AppModelConfig.POLICY.abi, AppServices.GetEcosystemAdr(request.ContractAdr).PolicyContractAdr, request.SigningPrivateKey, "updatePolicy", request.AdjustorHash.HexToByteArray(), request.PolicyHash.HexToByteArray(), request.DocumentHash.HexToByteArray(), request.RiskPoints )); }
public object Put(PingTimer request) { string timerContractAdr = AppServices.GetEcosystemAdr(request.ContractAdr).TimerContractAdr; // Activate or deactivate the auto ping scheduling functionality AppServices.configureTimerPing(timerContractAdr, request.SigningPrivateKey, request.AutoSchedulePingDuration); // Submit and return the transaction hash of the broadcasted ping transaction return(AppServices.createSignPublishTransaction( AppModelConfig.TIMER.abi, timerContractAdr, request.SigningPrivateKey, "ping" )); }
public object Post(CreateAdjustor request) { // Submit and return the transaction hash of the broadcasted transaction return(AppServices.createSignPublishTransaction( AppModelConfig.TRUST, AppServices.GetEcosystemAdr(request.ContractAdr).TrustContractAdr, request.SigningPrivateKey, "createAdjustor", request.Owner, request.SettlementApprovalAmount, request.PolicyRiskPointLimit, request.ServiceAgreementHash.HexToByteArray() )); }
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) { // Return the requested log file entries return(new SettlementLogs() { Logs = new LogParser <SettlementLog>().parseLogs( AppModelConfig.SETTLEMENT, AppServices.GetEcosystemAdr(request.ContractAdr).SettlementContractAdr, "LogSettlement", (request.SettlementHash.IsEmpty() == true ? null : new object[] { request.SettlementHash.HexToByteArray() }), (request.AdjustorHash.IsEmpty() == true ? null : new object[] { request.AdjustorHash.HexToByteArray() }), (request.Info.IsEmpty() == true ? null : new object[] { request.Info.HexToByteArray() }), request.FromBlock, request.ToBlock, (request.SettlementHash.IsEmpty() == true) && (request.AdjustorHash.IsEmpty() == true) && (request.Info.IsEmpty() == true) ) }); }
// ******************************************************************************************** // *** TRUST // ******************************************************************************************** public object Get(GetTrustLogs request) { // Return the requested log file entries return(new TrustLogs() { Logs = new LogParser <TrustLog>().parseLogs( AppModelConfig.TRUST, AppServices.GetEcosystemAdr(request.ContractAdr).TrustContractAdr, "LogTrust", (request.Subject.IsEmpty() == true ? null : new object[] { AppModelConfig.convertToHex64(request.Subject).HexToByteArray() }), (request.Address.IsEmpty() == true ? null : new object[] { request.Address }), (request.Info.IsEmpty() == true ? null : new object[] { AppModelConfig.convertToHex64(request.Info).HexToByteArray() }), request.FromBlock, request.ToBlock, (request.Subject.IsEmpty() == true) && (request.Address.IsEmpty() == true) && (request.Info.IsEmpty() == true) ) }); }
public object Get(GetEcosystemLogs request) { // Return the requested log file entries return(new EcosystemLogs() { Logs = new LogParser <EcosystemLog>().parseLogs( AppModelConfig.POOL, AppServices.GetEcosystemAdr(request.ContractAdr).PoolContractAdr, "LogPool", (request.Subject.IsEmpty() == true ? null : new object[] { AppModelConfig.convertToHex64(request.Subject).HexToByteArray() }), (request.Day == 0 ? null : new object[] { request.Day }), (request.Value == 0 ? null : new object[] { request.Value }), request.FromBlock, request.ToBlock, (request.Subject.IsEmpty() == true) && (request.Day == 0) && (request.Value == 0) ) }); }
public object Get(GetAdjustorLogs request) { // Return the requested log file entries return(new AdjustorLogs() { Logs = new LogParser <AdjustorLog>().parseLogs( AppModelConfig.ADJUSTOR, AppServices.GetEcosystemAdr(request.ContractAdr).AdjustorContractAdr, "LogAdjustor", (request.Hash.IsEmpty() == true ? null : new object[] { request.Hash.HexToByteArray() }), (request.Owner.IsEmpty() == true ? null : new object[] { request.Owner }), (request.Info.IsEmpty() == true ? null : new object[1]), request.FromBlock, request.ToBlock, (request.Hash.IsEmpty() == true) && (request.Owner.IsEmpty() == true) && (request.Info.IsEmpty() == true) ) }); }
public object Get(GetBankLogs request) { // Return the requested log file entries return(new BankLogs() { Logs = new LogParser <BankLog>().parseLogs( AppModelConfig.BANK, AppServices.GetEcosystemAdr(request.ContractAdr).BankContractAdr, "LogBank", (request.InternalReferenceHash.IsEmpty() == true ? null : new object[] { request.InternalReferenceHash.HexToByteArray() }), new object[] { (uint)request.AccountType }, (request.Success == SuccessFilter.All ? null : (request.Success == SuccessFilter.Positive ? new object[] { true } : new object[] { false })), request.FromBlock, request.ToBlock, (request.Success == SuccessFilter.All) && (request.InternalReferenceHash.IsEmpty() == true) ) }); }
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); }
public object Post(ProcessBankAccountCredit request) { // Convert the payment subject to a hash if it is a valid number if (uint.TryParse(request.PaymentSubject, out uint val) == true) { request.PaymentSubject = val.ToString("X64").EnsureHexPrefix(); } // Submit and return the transaction hash of the broadcasted transaction return(AppServices.createSignPublishTransaction( AppModelConfig.BANK.abi, AppServices.GetEcosystemAdr(request.ContractAdr).BankContractAdr, request.SigningPrivateKey, "processAccountCredit", request.BankTransactionIdx, (ulong)request.AccountType, request.PaymentAccountHashSender.HexToByteArray(), request.PaymentSubject.HexToByteArray(), request.CreditAmount )); }
public object Get(GetBankPaymentAdviceList request) { // Get the contract for the Bank by specifying the bank address var contract = AppServices.web3.Eth.GetContract(AppModelConfig.BANK.abi, AppServices.GetEcosystemAdr(request.ContractAdr).BankContractAdr); // Create a new return instance for Bank Metadata and set the Bank contract address uint countPaymentAdvice = contract.GetFunction("countPaymentAdviceEntries").CallAsync <uint>().Result; // Create the bond list object and initialise PaymentAdviceList list = new PaymentAdviceList() { Items = new List <PaymentAdviceDetail>() }; // Iterate through all the payment advice entries available according to count for (uint i = 0; i < countPaymentAdvice; i++) { // Call the payment advice from the specified idx PaymentAdviceDetail advice = contract.GetFunction("bankPaymentAdvice").CallDeserializingToObjectAsync <PaymentAdviceDetail>(i).Result; // Verify the payment advice returned has not already been processed (check the payment amount) if (advice.Amount > 0) { // Set the Advice index advice.Idx = i; // Convert the payment subject if applicable if (advice.PaymentSubject.StartsWith("0x000000") == true) { advice.PaymentSubject = Convert.ToUInt64(advice.PaymentSubject.RemoveHexPrefix(), 16).ToString(); } // Add advice to the list list.Items.Add(advice); } } // Return the list of all outstanding payment advice return(list); }
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(GetSettlement request) { // Get the contract for the Settlement by specifying the settlement address var contract = AppServices.web3.Eth.GetContract(AppModelConfig.SETTLEMENT.abi, AppServices.GetEcosystemAdr(request.ContractAdr).SettlementContractAdr); // SettlementListEntry entry = contract.GetFunction("get").CallDeserializingToObjectAsync<SettlementListEntry>(i).Result; // If no settlement hash has been provided as part of the request get the corresponding hash that belongs to the provided idx if (request.Hash.IsEmpty() == true) { request.Hash = AppModelConfig.convertToHex(contract.GetFunction("get").CallAsync <byte[]>(request.Idx).Result); } // Retrieve the settlement details from the Blockchain SettlementDetail settlement = contract.GetFunction("dataStorage").CallDeserializingToObjectAsync <SettlementDetail>(request.Hash.HexToByteArray()).Result; // Set the settlement hash to the requested has as specified in the request settlement.Hash = request.Hash; settlement.EventLogs = new List <SettlementEventLog>(); // If settlement hash is set retrieve the logs for the settlement if (AppModelConfig.isEmptyHash(settlement.Hash) == false) { settlement.EventLogs = ((SettlementLogs)this.Get( new GetSettlementLogs { ContractAdr = request.ContractAdr, SettlementHash = request.Hash })).EventLogs; // Just for the Settlement specific event logs reverse the order to have the events in ascending order settlement.EventLogs.Reverse(); } // Return the settlement return(settlement); }
public object Get(GetEcosystemContractAddresses request) { return(AppServices.GetEcosystemAdr(request.ContractAdr)); }
// ******************************************************************************************** // *** ECOSYSTEM // ******************************************************************************************** public object Get(GetEcosystemStatus request) { // Using the request's contract address provided, retrieve all the ecosystem's addresses to get the pool address EcosystemContractAddresses adr = AppServices.GetEcosystemAdr(request.ContractAdr); // Create the return instance EcosystemStatus status = new EcosystemStatus(); // Load the trust contract to retrieve the external access interface duration for pre-authorisation var contract = AppServices.web3.Eth.GetContract(AppModelConfig.POOL.abi, adr.PoolContractAdr); status.currentPoolDay = contract.GetFunction("currentPoolDay").CallAsync <ulong>().Result; status.isWinterTime = contract.GetFunction("isWinterTime").CallAsync <bool>().Result; status.daylightSavingScheduled = contract.GetFunction("daylightSavingScheduled").CallAsync <bool>().Result; // Bank account balances status.WC_Bal_FA_Cu = contract.GetFunction("WC_Bal_FA_Cu").CallAsync <ulong>().Result; status.WC_Bal_BA_Cu = contract.GetFunction("WC_Bal_BA_Cu").CallAsync <ulong>().Result; status.WC_Bal_PA_Cu = contract.GetFunction("WC_Bal_PA_Cu").CallAsync <ulong>().Result; // Variables used by the Insurance Pool during overnight processing only status.overwriteWcExpenses = contract.GetFunction("overwriteWcExpenses").CallAsync <bool>().Result; status.WC_Exp_Cu = contract.GetFunction("WC_Exp_Cu").CallAsync <ulong>().Result; // Pool variables as defined in the model status.WC_Locked_Cu = contract.GetFunction("WC_Locked_Cu").CallAsync <ulong>().Result; status.WC_Bond_Cu = contract.GetFunction("WC_Bond_Cu").CallAsync <ulong>().Result; status.WC_Transit_Cu = contract.GetFunction("WC_Transit_Cu").CallAsync <ulong>().Result; status.B_Yield_Ppb = contract.GetFunction("B_Yield_Ppb").CallAsync <ulong>().Result; status.B_Gradient_Ppq = contract.GetFunction("B_Gradient_Ppq").CallAsync <ulong>().Result; // Flag to indicate if the bond yield accelleration is operational (and scheduled by the timer) status.bondYieldAccellerationScheduled = contract.GetFunction("bondYieldAccellerationScheduled").CallAsync <bool>().Result; status.bondYieldAccelerationThreshold = contract.GetFunction("bondYieldAccelerationThreshold").CallAsync <ulong>().Result; // Load the bond contract contract = AppServices.web3.Eth.GetContract(AppModelConfig.BOND.abi, adr.BondContractAdr); status.BondListInfo = contract.GetFunction("hashMap").CallDeserializingToObjectAsync <ListInfo>().Result; // Load the policy contract contract = AppServices.web3.Eth.GetContract(AppModelConfig.POLICY.abi, adr.PolicyContractAdr); status.totalIssuedPolicyRiskPoints = contract.GetFunction("totalIssuedPolicyRiskPoints").CallAsync <ulong>().Result; status.PolicyListInfo = contract.GetFunction("hashMap").CallDeserializingToObjectAsync <ListInfo>().Result; // Load the adjustor contract contract = AppServices.web3.Eth.GetContract(AppModelConfig.ADJUSTOR.abi, adr.AdjustorContractAdr); status.AdjustorListInfo = contract.GetFunction("hashMap").CallDeserializingToObjectAsync <ListInfo>().Result; // Load the settlement contract contract = AppServices.web3.Eth.GetContract(AppModelConfig.SETTLEMENT.abi, adr.SettlementContractAdr); status.SettlementListInfo = contract.GetFunction("hashMap").CallDeserializingToObjectAsync <ListInfo>().Result; // Load the bank contract contract = AppServices.web3.Eth.GetContract(AppModelConfig.BANK.abi, adr.BankContractAdr); status.fundingAccountPaymentsTracking_Cu = contract.GetFunction("fundingAccountPaymentsTracking_Cu").CallAsync <ulong>().Result; // Load the timer contract contract = AppServices.web3.Eth.GetContract(AppModelConfig.TIMER.abi, adr.TimerContractAdr); status.lastPingExececution = contract.GetFunction("lastPingExec_10_S").CallAsync <ulong>().Result * 10; return(status); }
public object Get(GetPolicy request) { // Get the contract for the Policy by specifying the Policy address var contract = AppServices.web3.Eth.GetContract(AppModelConfig.POLICY.abi, AppServices.GetEcosystemAdr(request.ContractAdr).PolicyContractAdr); // PolicyListEntry entry = contract.GetFunction("get").CallDeserializingToObjectAsync<PolicyListEntry>(i).Result; // If no Policy hash has been provided as part of the request get the corresponding hash that belongs to the provided idx if (request.Hash.IsEmpty() == true) { request.Hash = AppModelConfig.convertToHex(contract.GetFunction("get").CallAsync <byte[]>(request.Idx).Result); } // Retrieve the Policy details from the Blockchain PolicyDetail Policy = contract.GetFunction("dataStorage").CallDeserializingToObjectAsync <PolicyDetail>(request.Hash.HexToByteArray()).Result; // Set the Policy hash to the requested has as specified in the request Policy.Hash = request.Hash; Policy.EventLogs = new List <PolicyEventLog>(); // If Policy hash is set retrieve the logs for the Policy if (AppModelConfig.isEmptyHash(Policy.Hash) == false) { Policy.EventLogs = ((PolicyLogs)this.Get( new GetPolicyLogs { ContractAdr = request.ContractAdr, Hash = request.Hash })).EventLogs; // Just for the Policy specific event logs reverse the order to have the events in ascending order Policy.EventLogs.Reverse(); } // Return the Policy return(Policy); }