public static TransactionReceipt Create(UInt64 id, CreatePaymentPattern 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.CreatePayment, req.Gas, new object[] { id, req.Value }); } 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 Create(UInt64 id, [FromBody] CreatePaymentPattern req) { TransactionReceipt result; try { result = TokenFunctionsResults <int, CreatePaymentPattern> .InvokeByTransaction(req, FunctionNames.CreatePayment, req.Gas, new object[] { id, req.Value }); } catch (Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.OK, new HttpError(e, false))); } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public JsonResult Create(UInt64 id, [FromForm] CreatePaymentPattern req) { var user = _userManager.GetUserAsync(HttpContext.User).Result; TransactionReceipt result; try { result = TokenFunctionsResults <int> .InvokeByTransaction(user, FunctionNames.CreatePayment, req.Gas, new object[] { id, req.Value }); } catch (Exception e) { return(Json(e.Message)); } return(Json(result)); }
public static string Create(UInt64 id, CreatePaymentPattern req, User user) { user.PublicKey = EthECKey.GetPublicAddress(user.PrivateKey); TransactionReceipt result; try { result = TokenFunctionsResults <int> .InvokeByTransaction(user, FunctionNames.CreatePayment, req.Gas, new object[] { id, req.Value }); } catch (Exception e) { return(JsonConvert.SerializeObject(e.Message)); } return(JsonConvert.SerializeObject(result)); }