using System.Threading.Tasks; using FrostFS.Accounting; namespace FrostFS.SDK.ClientV2; internal sealed class AccountingServiceProvider : ContextAccessor { private readonly AccountingService.AccountingServiceClient? _accountingServiceClient; internal AccountingServiceProvider( AccountingService.AccountingServiceClient? accountingServiceClient, EnvironmentContext context) : base(context) { _accountingServiceClient = accountingServiceClient; } internal async Task GetBallance(PrmBalance args) { var ctx = args.Context!; BalanceRequest request = new() { Body = new() { OwnerId = ctx.OwnerId!.OwnerID } }; request.AddMetaHeader(args.XHeaders); request.Sign(ctx.Key!); var response = await _accountingServiceClient!.BalanceAsync(request, null, ctx.Deadline, ctx.CancellationToken); Verifier.CheckResponse(response); return response.Body.Balance; } }