Remove references to cryptoCode in SyncStatus (#6275)

This commit is contained in:
Nicolas Dorier
2024-10-04 16:58:31 +09:00
committed by GitHub
parent 5190c25be0
commit 2e114d7c29
7 changed files with 21 additions and 10 deletions

View File

@@ -12,7 +12,7 @@ namespace BTCPayServer.Abstractions.Contracts
public interface ISyncStatus public interface ISyncStatus
{ {
public string CryptoCode { get; set; } public string PaymentMethodId { get; set; }
public bool Available { get; } public bool Available { get; }
} }
} }

View File

@@ -32,7 +32,7 @@ namespace BTCPayServer.Client.Models
public class SyncStatus public class SyncStatus
{ {
public string CryptoCode { get; set; } public string PaymentMethodId { get; set; }
public virtual bool Available { get; set; } public virtual bool Available { get; set; }
} }

View File

@@ -1979,7 +1979,7 @@ namespace BTCPayServer.Tests
Assert.Contains("BTC-CHAIN", serverInfoData.SupportedPaymentMethods); Assert.Contains("BTC-CHAIN", serverInfoData.SupportedPaymentMethods);
Assert.Contains("BTC-LN", serverInfoData.SupportedPaymentMethods); Assert.Contains("BTC-LN", serverInfoData.SupportedPaymentMethods);
Assert.NotNull(serverInfoData.SyncStatus); Assert.NotNull(serverInfoData.SyncStatus);
Assert.Single(serverInfoData.SyncStatus.Select(s => s.CryptoCode == "BTC")); Assert.Single(serverInfoData.SyncStatus.Select(s => s.PaymentMethodId == "BTC-CHAIN"));
} }
[Fact(Timeout = TestTimeout)] [Fact(Timeout = TestTimeout)]

View File

@@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Abstractions.Contracts;
using BTCPayServer.Client.Models; using BTCPayServer.Client.Models;
using BTCPayServer.Payments;
namespace BTCPayServer.Services.Altcoins.Monero.Services namespace BTCPayServer.Services.Altcoins.Monero.Services
{ {
@@ -24,13 +25,18 @@ namespace BTCPayServer.Services.Altcoins.Monero.Services
{ {
return _moneroRpcProvider.Summaries.Select(pair => new MoneroSyncStatus() return _moneroRpcProvider.Summaries.Select(pair => new MoneroSyncStatus()
{ {
Summary = pair.Value, CryptoCode = pair.Key Summary = pair.Value, PaymentMethodId = PaymentMethodId.Parse(pair.Key)
}); });
} }
} }
public class MoneroSyncStatus: SyncStatus, ISyncStatus public class MoneroSyncStatus: SyncStatus, ISyncStatus
{ {
public new PaymentMethodId PaymentMethodId
{
get => PaymentMethodId.Parse(base.PaymentMethodId);
set => base.PaymentMethodId = value.ToString();
}
public override bool Available public override bool Available
{ {
get get

View File

@@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Abstractions.Contracts;
using BTCPayServer.Client.Models; using BTCPayServer.Client.Models;
using BTCPayServer.Payments;
namespace BTCPayServer.Services.Altcoins.Zcash.Services namespace BTCPayServer.Services.Altcoins.Zcash.Services
{ {
@@ -24,13 +25,18 @@ namespace BTCPayServer.Services.Altcoins.Zcash.Services
{ {
return _ZcashRpcProvider.Summaries.Select(pair => new ZcashSyncStatus() return _ZcashRpcProvider.Summaries.Select(pair => new ZcashSyncStatus()
{ {
Summary = pair.Value, CryptoCode = pair.Key Summary = pair.Value, PaymentMethodId = PaymentMethodId.Parse(pair.Key)
}); });
} }
} }
public class ZcashSyncStatus: SyncStatus, ISyncStatus public class ZcashSyncStatus: SyncStatus, ISyncStatus
{ {
public new PaymentMethodId PaymentMethodId
{
get => PaymentMethodId.Parse(base.PaymentMethodId);
set => base.PaymentMethodId = value.ToString();
}
public override bool Available public override bool Available
{ {
get get

View File

@@ -3,6 +3,7 @@ using System.Linq;
using BTCPayServer.Abstractions.Contracts; using BTCPayServer.Abstractions.Contracts;
using BTCPayServer.Client.Models; using BTCPayServer.Client.Models;
using BTCPayServer.HostedServices; using BTCPayServer.HostedServices;
using BTCPayServer.Payments;
using NBXplorer.Models; using NBXplorer.Models;
namespace BTCPayServer.Services namespace BTCPayServer.Services
@@ -28,7 +29,7 @@ namespace BTCPayServer.Services
.Where(summary => summary.Network.ShowSyncSummary) .Where(summary => summary.Network.ShowSyncSummary)
.Select(summary => new ServerInfoSyncStatusData2 .Select(summary => new ServerInfoSyncStatusData2
{ {
CryptoCode = summary.Network.CryptoCode, PaymentMethodId = PaymentTypes.CHAIN.GetPaymentMethodId(summary.Network.CryptoCode).ToString(),
NodeInformation = summary.Status.BitcoinStatus is BitcoinStatus s ? new ServerInfoNodeData() NodeInformation = summary.Status.BitcoinStatus is BitcoinStatus s ? new ServerInfoNodeData()
{ {
Headers = s.Headers, Headers = s.Headers,

View File

@@ -143,10 +143,8 @@
"type": "object", "type": "object",
"description": "Detailed sync status", "description": "Detailed sync status",
"properties": { "properties": {
"cryptoCode": { "paymentMethodId": {
"type": "string", "$ref": "#/components/schemas/PaymentMethodId"
"description": "The CryptoCode of the crypto currency (eg. BTC)",
"example": "BTC"
}, },
"nodeInformation": { "nodeInformation": {
"$ref": "#/components/schemas/ApplicationServerInfoNodeStatusData" "$ref": "#/components/schemas/ApplicationServerInfoNodeStatusData"