Pluginify BTCPayNetworkProvider (#5331)

This commit is contained in:
Nicolas Dorier
2023-11-29 18:51:40 +09:00
committed by GitHub
parent 1081eab9db
commit 04292d09e1
139 changed files with 1251 additions and 1075 deletions

View File

@@ -11,6 +11,8 @@ using BTCPayServer.Models.StoreReportsViewModels;
using BTCPayServer.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Internal;
using System.Threading;
using Newtonsoft.Json.Linq;
@@ -21,12 +23,13 @@ namespace BTCPayServer.Controllers;
public partial class UIReportsController : Controller
{
public UIReportsController(
BTCPayNetworkProvider networkProvider,
ApplicationDbContextFactory dbContextFactory,
GreenfieldReportsController api,
ReportService reportService,
DisplayFormatter displayFormatter,
BTCPayServerEnvironment env)
BTCPayServerEnvironment env,
BTCPayNetworkProvider networkProvider,
TransactionLinkProviders transactionLinkProviders)
{
Api = api;
ReportService = reportService;
@@ -34,6 +37,7 @@ public partial class UIReportsController : Controller
DBContextFactory = dbContextFactory;
NetworkProvider = networkProvider;
DisplayFormatter = displayFormatter;
TransactionLinkProviders = transactionLinkProviders;
}
private BTCPayNetworkProvider NetworkProvider { get; }
private DisplayFormatter DisplayFormatter { get; }
@@ -41,6 +45,7 @@ public partial class UIReportsController : Controller
public ReportService ReportService { get; }
public BTCPayServerEnvironment Env { get; }
public ApplicationDbContextFactory DBContextFactory { get; }
public TransactionLinkProviders TransactionLinkProviders { get; }
[HttpPost("stores/{storeId}/reports")]
[AcceptMediaTypeConstraint("application/json")]
@@ -67,7 +72,7 @@ public partial class UIReportsController : Controller
var vm = new StoreReportsViewModel
{
InvoiceTemplateUrl = Url.Action(nameof(UIInvoiceController.Invoice), "UIInvoice", new { invoiceId = "INVOICE_ID" }),
ExplorerTemplateUrls = NetworkProvider.GetAll().ToDictionary(network => network.CryptoCode, network => network.BlockExplorerLink?.Replace("{0}", "TX_ID")),
ExplorerTemplateUrls = TransactionLinkProviders.ToDictionary(p => p.Key.CryptoCode, p => p.Value.BlockExplorerLink?.Replace("{0}", "TX_ID")),
Request = new StoreReportRequest { ViewName = viewName ?? "Payments" },
AvailableViews = ReportService.ReportProviders
.Values