public static TransactionReceipt CompleteOrder(UInt64 id, DefaultControllerPattern req, User user, ModelStateDictionary ModelState) { try { user.PublicKey = EthECKey.GetPublicAddress(user.PrivateKey); } catch { ModelState.AddModelError(nameof(user.PublicKey), "Unable to get public key"); return(null); } TransactionReceipt result; try { result = TokenFunctionsResults <int> .InvokeByTransaction(user, FunctionNames.CompleteOrder, req.Gas, funcParametrs : id); } catch (Exception e) { ModelState.AddModelError(nameof(User), e.Message); return(null); } if (result.Status.Value.IsZero) { ModelState.AddModelError(nameof(User), "Operation failed"); } return(result); }
public HttpResponseMessage Decrypt([FromBody] DefaultControllerPattern req) { Crypto.DecryptTwoStrings(out string senderAddress, req.Sender, out string password, req.Password, req.PassPhrase); CryptoResponsePattern cryptoResponse = new CryptoResponsePattern { PassPhrase = req.PassPhrase, Password = password, Sender = senderAddress }; return(Request.CreateResponse(System.Net.HttpStatusCode.OK, JsonConvert.SerializeObject(cryptoResponse))); }
public HttpResponseMessage Post([FromBody] DefaultControllerPattern req) { Crypto.DecryptTwoStringsAndGetContractFunctions(out string senderAddress, req.Sender, out string password, req.Password, req.PassPhrase, out ContractFunctions contractFunctions); ulong res = 0; try { res = contractFunctions.CallFunctionByName <System.UInt64>(senderAddress, password, FunctionNames.Balance, senderAddress).Result; } catch (Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.OK, new HttpError(e, true))); } return(Request.CreateResponse(HttpStatusCode.OK, res.ToString())); }
public HttpResponseMessage CompleteOrder(UInt64 id, [FromBody] DefaultControllerPattern req) { TransactionReceipt result; try { result = TokenFunctionsResults <int, DefaultControllerPattern> .InvokeByTransaction(req, FunctionNames.CompleteOrder, req.Gas, funcParametrs : id); } catch (Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.OK, new HttpError(e, false))); } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public HttpResponseMessage GetById(UInt64 id, [FromBody] DefaultControllerPattern req) { Crypto.DecryptTwoStringsAndGetContractFunctions(out string senderAddress, req.Sender, out string password, req.Password, req.PassPhrase, out ContractFunctions contractFunctions); Payment res; try { res = contractFunctions.DeserializePaymentById(senderAddress, password, id).Result; } catch (Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.OK, new HttpError(e, false))); } return(Request.CreateResponse(HttpStatusCode.OK, res, new HttpConfiguration())); }
public JsonResult DisApprove(UInt64 id, [FromForm] DefaultControllerPattern req) { var user = _userManager.GetUserAsync(HttpContext.User).Result; TransactionReceipt result; try { result = TokenFunctionsResults <int> .InvokeByTransaction(user, FunctionNames.DisApproveRefund, req.Gas, funcParametrs : id); } catch (Exception e) { return(Json(e.Message)); } return(Json(result)); }
public static string DisApprove(UInt64 id, DefaultControllerPattern req, User user) { user.PublicKey = EthECKey.GetPublicAddress(user.PrivateKey); TransactionReceipt result; try { result = TokenFunctionsResults <int> .InvokeByTransaction(user, FunctionNames.DisApproveRefund, req.Gas, funcParametrs : id); } catch (Exception e) { return(JsonConvert.SerializeObject(e.Message)); } return(JsonConvert.SerializeObject(result)); }
public static async Task <string> DeployContract(DefaultControllerPattern req, User user) { user.PublicKey = EthECKey.GetPublicAddress(user.PrivateKey); TransactionReceipt contractReceipt; ContractFunctions contractFunctions; try { contractFunctions = Globals.GetInstance().ContractFunctions; contractReceipt = await contractFunctions.DeployContract(user.PublicKey, user.PrivateKey, req.Gas); } catch (Exception e) { return(JsonConvert.SerializeObject(e.Message)); } return(JsonConvert.SerializeObject(contractReceipt)); }
public async Task <JsonResult> Post([FromForm] DefaultControllerPattern req) { var user = await _userManager.GetUserAsync(HttpContext.User); object contractReceipt; ContractFunctions contractFunctions; try { contractFunctions = Globals.GetInstance().ContractFunctions; contractReceipt = await contractFunctions.DeployContract(user.PublicKey, user.PrivateKey, req.Gas); } catch (Exception e) { return(Json(e.Message)); } return(Json(contractReceipt)); }