From 68f24e47cd48741f831004b355d109afda5276af Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 7 Oct 2024 21:14:37 +0900 Subject: [PATCH] Rename more legacy fields --- BTCPayServer.Tests/AltcoinTests/AltcoinTests.cs | 6 +++--- BTCPayServer/Controllers/UIInvoiceController.UI.cs | 4 ++-- BTCPayServer/Models/InvoicingModels/CheckoutModel.cs | 4 ++-- BTCPayServer/Plugins/NFC/NFCPlugin.cs | 9 +++------ BTCPayServer/Views/Shared/NFC/CheckoutEnd.cshtml | 2 +- BTCPayServer/Views/UIInvoice/Checkout.cshtml | 2 +- BTCPayServer/Views/UIInvoice/CheckoutNoScript.cshtml | 1 - BTCPayServer/wwwroot/checkout/checkout.js | 2 +- 8 files changed, 13 insertions(+), 17 deletions(-) diff --git a/BTCPayServer.Tests/AltcoinTests/AltcoinTests.cs b/BTCPayServer.Tests/AltcoinTests/AltcoinTests.cs index 34530a2bd..5ec8f80e9 100644 --- a/BTCPayServer.Tests/AltcoinTests/AltcoinTests.cs +++ b/BTCPayServer.Tests/AltcoinTests/AltcoinTests.cs @@ -322,7 +322,7 @@ namespace BTCPayServer.Tests var checkout = (Models.InvoicingModels.CheckoutModel)((JsonResult)controller.GetStatus(invoice.Id) .GetAwaiter().GetResult()).Value; - Assert.Single(checkout.AvailableCryptos); + Assert.Single(checkout.AvailablePaymentMethods); Assert.Equal("LTC", checkout.PaymentMethodCurrency); ////////////////////// @@ -477,7 +477,7 @@ namespace BTCPayServer.Tests var checkout = (Models.InvoicingModels.CheckoutModel)((JsonResult)controller.GetStatus(invoice.Id, null) .GetAwaiter().GetResult()).Value; - Assert.Single(checkout.AvailableCryptos); + Assert.Single(checkout.AvailablePaymentMethods); Assert.Equal("BTC", checkout.PaymentMethodCurrency); Assert.Single(invoice.PaymentCodes); @@ -538,7 +538,7 @@ namespace BTCPayServer.Tests controller = tester.PayTester.GetController(null); checkout = (Models.InvoicingModels.CheckoutModel)((JsonResult)controller.GetStatus(invoice.Id, "LTC") .GetAwaiter().GetResult()).Value; - Assert.Equal(2, checkout.AvailableCryptos.Count); + Assert.Equal(2, checkout.AvailablePaymentMethods.Count); Assert.Equal("LTC", checkout.PaymentMethodCurrency); Assert.Equal(2, invoice.PaymentCodes.Count()); diff --git a/BTCPayServer/Controllers/UIInvoiceController.UI.cs b/BTCPayServer/Controllers/UIInvoiceController.UI.cs index 8706918e4..e795f3c1b 100644 --- a/BTCPayServer/Controllers/UIInvoiceController.UI.cs +++ b/BTCPayServer/Controllers/UIInvoiceController.UI.cs @@ -910,11 +910,11 @@ namespace BTCPayServer.Controllers // The Tweak is part of the PaymentMethodFee, but let's not show it in the UI as it's negligible. NetworkFee = prompt.PaymentMethodFee - prompt.TweakFee, StoreId = store.Id, - AvailableCryptos = invoice.GetPaymentPrompts() + AvailablePaymentMethods = invoice.GetPaymentPrompts() .Select(kv => { var handler = _handlers[kv.PaymentMethodId]; - return new CheckoutModel.AvailableCrypto + return new CheckoutModel.AvailablePaymentMethod { Displayed = displayedPaymentMethods.Contains(kv.PaymentMethodId), PaymentMethodId = kv.PaymentMethodId, diff --git a/BTCPayServer/Models/InvoicingModels/CheckoutModel.cs b/BTCPayServer/Models/InvoicingModels/CheckoutModel.cs index c060b3fd9..bd60cb635 100644 --- a/BTCPayServer/Models/InvoicingModels/CheckoutModel.cs +++ b/BTCPayServer/Models/InvoicingModels/CheckoutModel.cs @@ -10,7 +10,7 @@ namespace BTCPayServer.Models.InvoicingModels public class CheckoutModel { public string CheckoutBodyComponentName { get; set; } - public class AvailableCrypto + public class AvailablePaymentMethod { [JsonConverter(typeof(PaymentMethodIdJsonConverter))] public PaymentMethodId PaymentMethodId { get; set; } @@ -29,7 +29,7 @@ namespace BTCPayServer.Models.InvoicingModels public string DefaultLang { get; set; } public bool ShowPayInWalletButton { get; set; } public bool ShowStoreHeader { get; set; } - public List AvailableCryptos { get; set; } = new(); + public List AvailablePaymentMethods { get; set; } = new(); public bool IsModal { get; set; } public bool IsUnsetTopUp { get; set; } public bool OnChainWithLnInvoiceFallback { get; set; } diff --git a/BTCPayServer/Plugins/NFC/NFCPlugin.cs b/BTCPayServer/Plugins/NFC/NFCPlugin.cs index cdbcaa0cc..37d3a8c31 100644 --- a/BTCPayServer/Plugins/NFC/NFCPlugin.cs +++ b/BTCPayServer/Plugins/NFC/NFCPlugin.cs @@ -15,12 +15,9 @@ namespace BTCPayServer.Plugins.NFC public override void Execute(IServiceCollection applicationBuilder) { - applicationBuilder.AddSingleton(new UIExtension("NFC/CheckoutEnd", - "checkout-end")); - applicationBuilder.AddSingleton(new UIExtension("NFC/LNURLNFCPostContent", - "checkout-lightning-post-content")); - applicationBuilder.AddSingleton(new UIExtension("NFC/LNURLNFCPostContent", - "checkout-bitcoin-post-content")); + applicationBuilder.AddUIExtension("checkout-end", "NFC/CheckoutEnd"); + applicationBuilder.AddUIExtension("checkout-lightning-post-content", "NFC/LNURLNFCPostContent"); + applicationBuilder.AddUIExtension("checkout-bitcoin-post-content", "NFC/LNURLNFCPostContent"); base.Execute(applicationBuilder); } } diff --git a/BTCPayServer/Views/Shared/NFC/CheckoutEnd.cshtml b/BTCPayServer/Views/Shared/NFC/CheckoutEnd.cshtml index ea5a4419b..e5aa25bc6 100644 --- a/BTCPayServer/Views/Shared/NFC/CheckoutEnd.cshtml +++ b/BTCPayServer/Views/Shared/NFC/CheckoutEnd.cshtml @@ -19,7 +19,7 @@ Vue.component("lnurl-withdraw-checkout", { const { onChainWithLnInvoiceFallback: isUnified, paymentMethodId: activePaymentMethodId, - availableCryptos: availablePaymentMethods, + availablePaymentMethods: availablePaymentMethods, invoiceBitcoinUrl: paymentUrl } = this.model const lnurlwAvailable = diff --git a/BTCPayServer/Views/UIInvoice/Checkout.cshtml b/BTCPayServer/Views/UIInvoice/Checkout.cshtml index 229455fc1..125b6a898 100644 --- a/BTCPayServer/Views/UIInvoice/Checkout.cshtml +++ b/BTCPayServer/Views/UIInvoice/Checkout.cshtml @@ -12,7 +12,7 @@ ViewData["StoreBranding"] = Model.StoreBranding; Csp.UnsafeEval(); var hasPaymentPlugins = UiExtensions.Any(extension => extension.Location == "checkout-payment-method"); - var displayedPaymentMethods = Model.AvailableCryptos.Where(c => c.Displayed).ToList(); + var displayedPaymentMethods = Model.AvailablePaymentMethods.Where(c => c.Displayed).ToList(); } @functions { private string ToJsValue(object value) diff --git a/BTCPayServer/Views/UIInvoice/CheckoutNoScript.cshtml b/BTCPayServer/Views/UIInvoice/CheckoutNoScript.cshtml index f08589927..abaa0bfe6 100644 --- a/BTCPayServer/Views/UIInvoice/CheckoutNoScript.cshtml +++ b/BTCPayServer/Views/UIInvoice/CheckoutNoScript.cshtml @@ -1,7 +1,6 @@ @model CheckoutModel @{ Layout = null; - var displayedPaymentMethods = Model.AvailableCryptos.Where(a => a.Displayed).ToList(); } diff --git a/BTCPayServer/wwwroot/checkout/checkout.js b/BTCPayServer/wwwroot/checkout/checkout.js index 0f2fc5584..04770cf5d 100644 --- a/BTCPayServer/wwwroot/checkout/checkout.js +++ b/BTCPayServer/wwwroot/checkout/checkout.js @@ -172,7 +172,7 @@ function initApp() { : null; }, paymentMethodIds () { - return this.srvModel.availableCryptos.map(function (c) { return c.paymentMethodId }); + return this.srvModel.availablePaymentMethod.map(function (c) { return c.paymentMethodId }); }, paymentMethodComponent() { return this.isPluginPaymentMethod