GetStatus API endpoint
MODIFY
WalletWasabi.Backend/Controllers/WabiSabiController.cs
WalletWasabi.Backend/Controllers/WabiSabiController.cs
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using WalletWasabi.WabiSabi.Backend.PostRequests;
using WalletWasabi.WabiSabi.Models;
+using WalletWasabi.Backend.Filters;
namespace WalletWasabi.Backend.Controllers
{
- [Produces("application/json")]
[ApiController]
+ [ExceptionTranslate]
[Route("[controller]")]
+ [Produces("application/json")]
public class WabiSabiController : ControllerBase
{
private ArenaRequestHandler handler;
@@ -55,9 +56,10 @@ namespace WalletWasabi.Backend.Controllers
return handler.SignTransactionAsync(request, cancellableToken);
}
- public IEnumerable<RoundState> GetStatusAsync(CancellationToken cancellableToken)
+ [HttpGet("status")]
+ public RoundState[] GetStatus()
{
- return handler.Arena.Rounds.Values.Select(x => RoundState.FromRound(x));
+ return handler.Arena.Rounds.Values.Select(x => RoundState.FromRound(x)).ToArray();
}
}
}

MODIFY
WalletWasabi/WabiSabi/Backend/PostRequests/ArenaRequestHandler.cs
WalletWasabi/WabiSabi/Backend/PostRequests/ArenaRequestHandler.cs
@@ -91,6 +91,11 @@ namespace WalletWasabi.WabiSabi.Backend.PostRequests
}
}
+ public Task<RoundState[]> GetStatusAsync(CancellationToken cancellationToken)
+ {
+ throw new NotImplementedException();
+ }
+
public async ValueTask DisposeAsync()
{
lock (DisposeStartedLock)

MODIFY
WalletWasabi/WabiSabi/Backend/PostRequests/IArenaRequestHandler.cs
WalletWasabi/WabiSabi/Backend/PostRequests/IArenaRequestHandler.cs
@@ -17,5 +17,7 @@ namespace WalletWasabi.WabiSabi.Backend.PostRequests
Task SignTransactionAsync(TransactionSignaturesRequest request, CancellationToken cancellationToken);
Task<ReissueCredentialResponse> ReissueCredentialAsync(ReissueCredentialRequest request, CancellationToken cancellationToken);
+
+ Task<RoundState[]> GetStatusAsync(CancellationToken cancellationToken);
}
}

MODIFY
WalletWasabi/WabiSabi/Client/ArenaClient.cs
WalletWasabi/WabiSabi/Client/ArenaClient.cs
@@ -228,5 +228,10 @@ namespace WalletWasabi.WabiSabi.Client
await RequestHandler.SignTransactionAsync(new TransactionSignaturesRequest(roundId, signatures), cancellationToken).ConfigureAwait(false);
}
+
+ public async Task<RoundState[]> GetStatusAsync(CancellationToken cancellationToken)
+ {
+ return await RequestHandler.GetStatusAsync(cancellationToken);
+ }
}
}

MODIFY
WalletWasabi/WabiSabi/Client/WabiSabiHttpApiClient.cs
WalletWasabi/WabiSabi/Client/WabiSabiHttpApiClient.cs
using System;
+using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading;
@@ -28,7 +29,8 @@ namespace WalletWasabi.WabiSabi.Client
ConfirmConnection,
RegisterOutput,
ReissueCredential,
- SignTransaction
+ SignTransaction,
+ GetStatus
}
public Task<InputRegistrationResponse> RegisterInputAsync(InputRegistrationRequest request, CancellationToken cancellationToken) =>
@@ -49,6 +51,18 @@ namespace WalletWasabi.WabiSabi.Client
public Task SignTransactionAsync(TransactionSignaturesRequest request, CancellationToken cancellationToken) =>
SendAndReceiveAsync<TransactionSignaturesRequest>(RemoteAction.SignTransaction, request, cancellationToken);
+ public async Task<RoundState[]> GetStatusAsync(CancellationToken cancellationToken)
+ {
+ using var response = await _client.SendAsync(HttpMethod.Get, GetUriEndPoint(RemoteAction.GetStatus), cancel: cancellationToken).ConfigureAwait(false);
+
+ if (!response.IsSuccessStatusCode)
+ {
+ await response.ThrowRequestExceptionFromContentAsync(cancellationToken).ConfigureAwait(false);
+ }
+ var jsonString = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ return Deserialize<RoundState[]>(jsonString);
+ }
+
private async Task<string> SendAsync<TRequest>(RemoteAction action, TRequest request, CancellationToken cancellationToken) where TRequest : class
{
using var content = Serialize(request);
@@ -93,6 +107,7 @@ namespace WalletWasabi.WabiSabi.Client
RemoteAction.ReissueCredential => "credential-issuance",
RemoteAction.RemoveInput => "input-unregistration",
RemoteAction.SignTransaction => "transaction-signature",
+ RemoteAction.GetStatus => "status",
_ => throw new NotSupportedException($"Action '{action}' is unknown and has no endpoint associated.")
};
}

GetStatus API endpoint