/** * <summary> * Executes transaction command <paramref name="cmd" /> with params <paramref name="data" /> of type * <paramref name="type" />. * Function contains auto-retry algorithm with auto sequence error fix. Maximum retries set via * <paramref name="retries" /> * </summary> * <param name="data">Transaction data</param> * <param name="type">HTTP-style transaction request type</param> * <param name="cmd">Transaction command</param> * <param name="gasInfo">Gas used to execute transaction</param> * <param name="retries"> * Maximum retries count. Retries runs with delay of <see cref="RetryInterval" />ms plus transaction * execution time * </param> * <returns>JObject contains decoded transaction result</returns> * <exception cref="Exceptions.InvalidChainIdException"></exception> * <exception cref="Exceptions.TransactionExecutionException"></exception> * <exception cref="Exceptions.InsufficientFundsException"></exception> * <exception cref="KeyNotFoundException"></exception> */ private async Task <JObject> ExecuteTransaction( JObject data, string type, string cmd, GasInfo gasInfo = null, int retries = MaxRetries) { // Update user request with transaction-specific data and gas information data.Merge(new JObject { ["BaseReq"] = new JObject { ["from"] = _sessionAddress, ["chain_id"] = _chainId }, ["UUID"] = NamespaceId, ["Owner"] = _sessionAddress }); if (gasInfo != null) { data.Merge(gasInfo.Obj); } // Decoding transaction type from string var methodValid = Enum.TryParse <Method>(type, true, out var httpMethod); if (!methodValid) { throw new Exception($"HTTP method {type} is unsupported"); } // Run request for retrieving transaction base part (template) var request = new RestRequest($"{CrudServicePrefix}/{cmd}", httpMethod) .AddParameter("application/x-www-form-urlencoded", data, ParameterType.RequestBody); var resp = _restClient.ExecuteAsync <JObject>(request).Result; if (resp.StatusCode != HttpStatusCode.OK) { throw new Exceptions.TransactionExecutionException(resp.Content); } var tx = resp.Data; gasInfo?.UpdateTransaction(tx); // Calculate tx signature and insert it into transaction template tx["value"] !["memo"] = MakeRandomString(32);