Skip to content

Commit 748a9df

Browse files
committed
fix: add hidden ChainDisplayName field to EVM server config form
The form was missing a hidden input for ChainDisplayName, causing model validation to fail with 'The ChainDisplayName field is required' when saving EVM server settings (e.g. Polygon RPC URL). Also consolidates Tron and EVM nav extensions into unified USDt views.
1 parent 04e0beb commit 748a9df

8 files changed

Lines changed: 125 additions & 135 deletions

File tree

BTCPayServer.Plugins.USDt/USDtPlugin.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ private void RegisterServices(IServiceCollection services)
7474

7575
// For future usages (multiple TRC20)
7676
//services.AddSingleton<IUIExtension>(new UIExtension("TronUSDt/StoreNavTronUSDtExtension", "store-integrations-nav"));
77-
services.AddUIExtension("server-nav","TronUSDtLike/ServerNavTronUSDtExtension");
78-
services.AddUIExtension("store-wallets-nav", "TronUSDtLike/StoreWalletsNavTronUSDtExtension");
7977
services.AddUIExtension("store-invoices-payments", "TronUSDtLike/ViewTronUSDtLikePaymentData");
80-
services.AddUIExtension("checkout-payment-method", "EmptyCheckoutPaymentMethodExtension");
8178
services.AddSingleton<ISyncSummaryProvider, TronUSDtSyncSummaryProvider>();
8279

8380
services.AddSingleton<EVMUSDtRPCProvider>();
@@ -91,10 +88,10 @@ private void RegisterServices(IServiceCollection services)
9188

9289
services.AddSingleton<ISyncSummaryProvider, EVMUSDtSyncSummaryProvider>();
9390

94-
// Store UI extensions for all EVM chains (addresses management, checkout, server nav)
95-
services.AddUIExtension("store-wallets-nav", "EVMUSDtLike/StoreWalletsNavEVMUSDtExtension");
91+
// Combined UI extensions for all chains (store wallets nav, server nav, checkout)
92+
services.AddUIExtension("store-wallets-nav", "USDt/StoreWalletsNavUSDtExtension");
93+
services.AddUIExtension("server-nav", "USDt/ServerNavUSDtExtension");
9694
services.AddUIExtension("checkout-payment-method", "EmptyCheckoutPaymentMethodExtension");
97-
services.AddUIExtension("server-nav", "EVMUSDtLike/ServerNavEVMUSDtExtension");
9895

9996
services.AddSingleton<ISwaggerProvider, SwaggerProvider>();
10097
}

BTCPayServer.Plugins.USDt/Views/Shared/EVMUSDtLike/ServerNavEVMUSDtExtension.cshtml

Lines changed: 0 additions & 28 deletions
This file was deleted.

BTCPayServer.Plugins.USDt/Views/Shared/EVMUSDtLike/StoreWalletsNavEVMUSDtExtension.cshtml

Lines changed: 0 additions & 40 deletions
This file was deleted.

BTCPayServer.Plugins.USDt/Views/Shared/TronUSDtLike/ServerNavTronUSDtExtension.cshtml

Lines changed: 0 additions & 21 deletions
This file was deleted.

BTCPayServer.Plugins.USDt/Views/Shared/TronUSDtLike/StoreWalletsNavTronUSDtExtension.cshtml

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@using BTCPayServer
2+
@using BTCPayServer.Abstractions.Contracts
3+
@using BTCPayServer.Abstractions.Extensions
4+
@using BTCPayServer.Client
5+
@using BTCPayServer.Data
6+
@using BTCPayServer.Plugins.USDt
7+
@using BTCPayServer.Plugins.USDt.Configuration
8+
@using BTCPayServer.Plugins.USDt.Controllers
9+
@using BTCPayServer.Views.Server
10+
@using Microsoft.AspNetCore.Identity
11+
@using Microsoft.AspNetCore.Mvc.TagHelpers
12+
@inject SignInManager<ApplicationUser> SignInManager;
13+
@inject USDtPluginConfiguration USDtPluginConfiguration;
14+
@inject IScopeProvider ScopeProvider
15+
@{
16+
var hasTron = USDtPluginConfiguration.TronUSDtLikeConfigurationItems.Any();
17+
var hasEvm = USDtPluginConfiguration.EVMUSDtLikeConfigurationItems.Any();
18+
}
19+
@if (SignInManager.IsSignedIn(User) && User.IsInRole(Roles.ServerAdmin) && (hasTron || hasEvm))
20+
{
21+
<li class="nav-item nav-item-sub" permission="@Policies.CanModifyServerSettings">
22+
<span class="nav-link">USD₮</span>
23+
</li>
24+
25+
@if (hasTron)
26+
{
27+
<li class="nav-item nav-item-sub" permission="@Policies.CanModifyServerSettings" style="padding-left: calc(3rem + var(--btcpay-space-xs));">
28+
<a asp-controller="UITronUSDtLikeServer" asp-action="GetServerConfig"
29+
class="nav-link @ViewData.ActivePageClass(USDtPlugin.PluginNavKey, typeof(ServerNavPages).ToString(), "TronServer")">TRON</a>
30+
</li>
31+
}
32+
33+
@if (hasEvm)
34+
{
35+
foreach (var item in USDtPluginConfiguration.EVMUSDtLikeConfigurationItems)
36+
{
37+
var activeKey = $"EVM-{item.Key}";
38+
<li class="nav-item nav-item-sub" permission="@Policies.CanModifyServerSettings" style="padding-left: calc(3rem + var(--btcpay-space-xs));">
39+
<a asp-controller="UIEVMUSDtLikeServer" asp-action="GetServerConfig"
40+
asp-route-paymentMethodId="@item.Key"
41+
class="nav-link @ViewData.ActivePageClass(USDtPlugin.PluginNavKey, typeof(ServerNavPages).ToString(), activeKey)">@item.Value.Chain</a>
42+
</li>
43+
}
44+
}
45+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
@using BTCPayServer
2+
@using BTCPayServer.Abstractions.Contracts
3+
@using BTCPayServer.Data
4+
@using BTCPayServer.Payments
5+
@using BTCPayServer.Plugins.USDt.Configuration
6+
@using BTCPayServer.Plugins.USDt.Controllers
7+
@using BTCPayServer.Plugins.USDt.Services
8+
@using Microsoft.AspNetCore.Identity
9+
@using Microsoft.AspNetCore.Mvc.TagHelpers
10+
@inject SignInManager<ApplicationUser> SignInManager;
11+
@inject USDtPluginConfiguration USDtPluginConfiguration;
12+
@inject IScopeProvider ScopeProvider
13+
@inject UITronUSDtLikeStoreController UITronUSDtLikeStore;
14+
@inject TronUSDtRPCProvider TronUSDtRPCProvider;
15+
@inject UIEVMUSDtLikeStoreController UIEvmUsdTLikeStore;
16+
@inject EVMUSDtRPCProvider EvmUsdTRpcProvider;
17+
@{
18+
var storeId = ScopeProvider.GetCurrentStoreId();
19+
var hasTron = USDtPluginConfiguration.TronUSDtLikeConfigurationItems.Any();
20+
var hasEvm = USDtPluginConfiguration.EVMUSDtLikeConfigurationItems.Any();
21+
}
22+
@if (SignInManager.IsSignedIn(User) && (hasTron || hasEvm))
23+
{
24+
<li class="nav-item">
25+
<span class="nav-link">USD₮</span>
26+
</li>
27+
28+
@if (hasTron)
29+
{
30+
var store = Context.GetStoreData();
31+
var tronResult = UITronUSDtLikeStore.GetVM(store);
32+
33+
foreach (var item in tronResult.Items)
34+
{
35+
var isAvailable = TronUSDtRPCProvider.IsAvailable(item.PaymentMethodId);
36+
var isActive = !string.IsNullOrEmpty(storeId) && ViewContext.RouteData.Values.TryGetValue("Controller", out var controller) && controller is not null &&
37+
nameof(UITronUSDtLikeStoreController).StartsWith(controller.ToString() ?? string.Empty, StringComparison.InvariantCultureIgnoreCase) &&
38+
ViewContext.RouteData.Values.TryGetValue("paymentMethodId", out var paymentMethodId) && paymentMethodId is not null && new PaymentMethodId((string)paymentMethodId) == item.PaymentMethodId;
39+
<li class="nav-item nav-item-sub">
40+
<a class="nav-link @(isActive ? "active" : "")"
41+
asp-route-paymentMethodId="@item.PaymentMethodId"
42+
asp-route-storeId="@storeId"
43+
asp-action="GetStoreTronUSDtLikePaymentMethod"
44+
asp-controller="UITronUSDtLikeStore">
45+
<span class="me-2 btcpay-status btcpay-status--@(item.Enabled ? isAvailable ? "enabled" : "disabled" : "pending")"></span>
46+
<span>TRON</span>
47+
</a>
48+
</li>
49+
}
50+
}
51+
52+
@if (hasEvm)
53+
{
54+
var store = Context.GetStoreData();
55+
var evmResult = UIEvmUsdTLikeStore.GetVM(store);
56+
57+
foreach (var item in evmResult.Items)
58+
{
59+
var chainName = USDtPluginConfiguration.EVMUSDtLikeConfigurationItems.TryGetValue(item.PaymentMethodId, out var evmConfig) ? evmConfig.Chain : item.DisplayName;
60+
var isAvailable = EvmUsdTRpcProvider.IsAvailable(item.PaymentMethodId);
61+
var isActive = !string.IsNullOrEmpty(storeId) && ViewContext.RouteData.Values.TryGetValue("Controller", out var controller) && controller is not null &&
62+
nameof(UIEVMUSDtLikeStoreController).StartsWith(controller.ToString() ?? string.Empty, StringComparison.InvariantCultureIgnoreCase) &&
63+
ViewContext.RouteData.Values.TryGetValue("paymentMethodId", out var paymentMethodId) && paymentMethodId is not null && new PaymentMethodId((string)paymentMethodId) == item.PaymentMethodId;
64+
<li class="nav-item nav-item-sub">
65+
<a class="nav-link @(isActive ? "active" : "")"
66+
asp-route-paymentMethodId="@item.PaymentMethodId"
67+
asp-route-storeId="@storeId"
68+
asp-action="GetStoreEVMUSDtLikePaymentMethod"
69+
asp-controller="UIEVMUSDtLikeStore">
70+
<span class="me-2 btcpay-status btcpay-status--@(item.Enabled ? isAvailable ? "enabled" : "disabled" : "pending")"></span>
71+
<span>@chainName</span>
72+
</a>
73+
</li>
74+
}
75+
}
76+
}

BTCPayServer.Plugins.USDt/Views/UIEVMUSDtLikeServer/GetServerConfig.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
<form method="post" enctype="multipart/form-data">
1313
<input type="hidden" asp-for="DisplayName" />
14+
<input type="hidden" asp-for="ChainDisplayName" />
1415
<div class="sticky-header">
1516
<h2>@ViewData.Model.DisplayName server settings</h2>
1617
<button id="SaveButton" type="submit" class="btn btn-primary" name="command" value="Save">Save</button>

0 commit comments

Comments
 (0)