Skip to content

Commit 7118e6b

Browse files
committed
refactor: adjust namespaces
1 parent 073f4da commit 7118e6b

40 files changed

+124
-108
lines changed
+17-17
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
using BTCPayServer.Plugins.TronUSDt.Services;
1+
using BTCPayServer.Plugins.USDt.Services;
2+
using BTCPayServer.Tests;
23
using Xunit;
34
using Xunit.Abstractions;
45

5-
namespace BTCPayServer.Tests
6+
namespace BTCPayServer.Plugins.USDt.Tests;
7+
8+
[Trait("Fast", "Fast")]
9+
public class FastTests : UnitTestBase
610
{
7-
[Trait("Fast", "Fast")]
8-
public class FastTests : UnitTestBase
11+
public FastTests(ITestOutputHelper helper) : base(helper)
912
{
10-
public FastTests(ITestOutputHelper helper) : base(helper)
11-
{
12-
}
13+
}
14+
1315

14-
15-
[Fact]
16-
public void TronConversion()
17-
{
18-
Assert.Equal("TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs",TronUSDtAddressHelper.HexToBase58("0x42a1e39aefa49290f2b3f9ed688d7cecf86cd6e0"));
19-
Assert.Equal("0x42a1e39aefa49290f2b3f9ed688d7cecf86cd6e0",TronUSDtAddressHelper.Base58ToHex("TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs"));
20-
Assert.True(TronUSDtAddressHelper.IsValid("TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs"));
21-
Assert.False(TronUSDtAddressHelper.IsValid("TG2XXyExBkPp9nzdajDZsozEu4BkaSJozs"));
22-
Assert.False(TronUSDtAddressHelper.IsValid("TG3xXyExBkPp9nzdajDZsozEu4BkaSJozs"));
23-
}
16+
[Fact]
17+
public void TronConversion()
18+
{
19+
Assert.Equal("TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs",TronUSDtAddressHelper.HexToBase58("0x42a1e39aefa49290f2b3f9ed688d7cecf86cd6e0"));
20+
Assert.Equal("0x42a1e39aefa49290f2b3f9ed688d7cecf86cd6e0",TronUSDtAddressHelper.Base58ToHex("TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs"));
21+
Assert.True(TronUSDtAddressHelper.IsValid("TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs"));
22+
Assert.False(TronUSDtAddressHelper.IsValid("TG2XXyExBkPp9nzdajDZsozEu4BkaSJozs"));
23+
Assert.False(TronUSDtAddressHelper.IsValid("TG3xXyExBkPp9nzdajDZsozEu4BkaSJozs"));
2424
}
2525
}

BTCPayServer.Plugins.USDt/BTCPayServer.Plugins.USDt.csproj

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
<Configurations>Release;Altcoins-Debug</Configurations>
77
<Platforms>AnyCPU</Platforms>
88
<Nullable>enable</Nullable>
9-
<RootNamespace>BTCPayServer.Plugins.TronUSDt</RootNamespace>
109
</PropertyGroup>
1110
<!-- -->
1211
<!-- Plugin specific properties -->
1312
<PropertyGroup>
14-
<Product>TronUSDt Plugin</Product>
13+
<Product>USDt Plugin</Product>
1514
<Description>Accept USDt on Tron blockchain.</Description>
1615
<Version>0.0.0</Version>
1716
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

BTCPayServer.Plugins.USDt/Configuration/TronUSDtLikeConfiguration.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
2+
using BTCPayServer.Payments;
23

3-
namespace BTCPayServer.Plugins.TronUSDt.Configuration;
4+
namespace BTCPayServer.Plugins.USDt.Configuration;
45

56
public class TronUSDtLikeConfiguration
67
{

BTCPayServer.Plugins.USDt/Configuration/TronUSDtLikeConfigurationItem.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22
using System.ComponentModel.DataAnnotations;
3-
using BTCPayServer.Plugins.TronUSDt.Services;
3+
using BTCPayServer.Plugins.USDt.Services;
44

5-
namespace BTCPayServer.Plugins.TronUSDt.Configuration;
5+
namespace BTCPayServer.Plugins.USDt.Configuration;
66

77
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
88
public class TronBase58Attribute : ValidationAttribute

BTCPayServer.Plugins.USDt/Configuration/TronUSDtLikeServerSettings.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22

3-
namespace BTCPayServer.Plugins.TronUSDt.Configuration;
3+
namespace BTCPayServer.Plugins.USDt.Configuration;
44

55
public class TronUSDtLikeServerSettings
66
{

BTCPayServer.Plugins.USDt/Controllers/UITronUSDtLikeServerController.cs

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
using BTCPayServer.Abstractions.Contracts;
66
using BTCPayServer.Client;
77
using BTCPayServer.Filters;
8-
using BTCPayServer.Plugins.TronUSDt.Configuration;
9-
using BTCPayServer.Plugins.TronUSDt.Controllers.ViewModels;
10-
using BTCPayServer.Plugins.TronUSDt.Services;
11-
using BTCPayServer.Plugins.TronUSDt.Services.Events;
8+
using BTCPayServer.Plugins.USDt.Configuration;
9+
using BTCPayServer.Plugins.USDt.Controllers.ViewModels;
10+
using BTCPayServer.Plugins.USDt.Services;
11+
using BTCPayServer.Plugins.USDt.Services.Events;
1212
using Microsoft.AspNetCore.Authorization;
1313
using Microsoft.AspNetCore.Mvc;
1414
using Microsoft.Extensions.Configuration;
1515

16-
namespace BTCPayServer.Plugins.TronUSDt.Controllers;
16+
namespace BTCPayServer.Plugins.USDt.Controllers;
1717

1818
[Route("server/tronUSDtlike")]
1919
[OnlyIfSupport("TronUSDt")]
@@ -33,12 +33,12 @@ public async Task<IActionResult> GetServerConfig()
3333
if (network is null) return NotFound();
3434

3535
var serverSettings = await settingsRepository.GetSettingAsync<TronUSDtLikeServerSettings>(
36-
TronUSDtPlugin.ServerSettingsKey(network.CryptoCode));
36+
USDtPlugin.ServerSettingsKey(network.CryptoCode));
3737

3838
var viewModel = new TronUSDtLikeServerConfigViewModel()
3939
{
40-
DefaultSmartContractAddress = TronUSDtPlugin.GetDefaultSmartContractAddress(btcPayNetworkProvider.NetworkType, configuration, network),
41-
DefaultJsonRpcUri = TronUSDtPlugin.GetDefaultJsonRpcUri(btcPayNetworkProvider.NetworkType, configuration, network),
40+
DefaultSmartContractAddress = USDtPlugin.GetDefaultSmartContractAddress(btcPayNetworkProvider.NetworkType, configuration, network),
41+
DefaultJsonRpcUri = USDtPlugin.GetDefaultJsonRpcUri(btcPayNetworkProvider.NetworkType, configuration, network),
4242

4343
SmartContractAddress = serverSettings?.SmartContractAddress,
4444
JsonRpcUri = serverSettings?.JsonRpcUri?.AbsoluteUri,
@@ -56,8 +56,8 @@ public async Task<IActionResult> GetServerConfig(TronUSDtLikeServerConfigViewMod
5656

5757
if (!ModelState.IsValid)
5858
{
59-
viewModel.DefaultSmartContractAddress = TronUSDtPlugin.GetDefaultSmartContractAddress(btcPayNetworkProvider.NetworkType, configuration, network);
60-
viewModel.DefaultJsonRpcUri = TronUSDtPlugin.GetDefaultJsonRpcUri(btcPayNetworkProvider.NetworkType, configuration, network);
59+
viewModel.DefaultSmartContractAddress = USDtPlugin.GetDefaultSmartContractAddress(btcPayNetworkProvider.NetworkType, configuration, network);
60+
viewModel.DefaultJsonRpcUri = USDtPlugin.GetDefaultJsonRpcUri(btcPayNetworkProvider.NetworkType, configuration, network);
6161
return View(viewModel);
6262
}
6363

@@ -67,10 +67,10 @@ public async Task<IActionResult> GetServerConfig(TronUSDtLikeServerConfigViewMod
6767
JsonRpcUri = viewModel.JsonRpcUri is null or "" ? null : new Uri(viewModel.JsonRpcUri)
6868
};
6969

70-
await settingsRepository.UpdateSetting(serverSettings, TronUSDtPlugin.ServerSettingsKey(network.CryptoCode));
70+
await settingsRepository.UpdateSetting(serverSettings, USDtPlugin.ServerSettingsKey(network.CryptoCode));
7171

7272
tronUSDtLikeConfiguration.TronUSDtLikeConfigurationItems[network.CryptoCode] =
73-
TronUSDtPlugin.GetConfigurationItem(btcPayNetworkProvider.NetworkType, serverSettings, configuration, network);
73+
USDtPlugin.GetConfigurationItem(btcPayNetworkProvider.NetworkType, serverSettings, configuration, network);
7474

7575

7676
eventAggregator.Publish(new TronUSDtSettingsChanged());

BTCPayServer.Plugins.USDt/Controllers/UITronUSDtLikeStoreController.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
using BTCPayServer.Client;
88
using BTCPayServer.Data;
99
using BTCPayServer.Filters;
10-
using BTCPayServer.Plugins.TronUSDt.Controllers.ViewModels;
11-
using BTCPayServer.Plugins.TronUSDt.Services;
12-
using BTCPayServer.Plugins.TronUSDt.Services.Payments;
10+
using BTCPayServer.Payments;
11+
using BTCPayServer.Plugins.USDt.Controllers.ViewModels;
12+
using BTCPayServer.Plugins.USDt.Services;
13+
using BTCPayServer.Plugins.USDt.Services.Payments;
1314
using BTCPayServer.Services;
1415
using BTCPayServer.Services.Invoices;
1516
using BTCPayServer.Services.Stores;
1617
using Microsoft.AspNetCore.Authorization;
1718
using Microsoft.AspNetCore.Mvc;
1819

19-
namespace BTCPayServer.Plugins.TronUSDt.Controllers;
20+
namespace BTCPayServer.Plugins.USDt.Controllers;
2021

2122
[Route("stores/{storeId}/tronUSDtlike")]
2223
[OnlyIfSupport("TronUSDt")]
@@ -172,7 +173,7 @@ public async Task<IActionResult> GetStoreTronUSDtLikePaymentMethod(EditTronUSDtP
172173
Severity = StatusMessageModel.StatusSeverity.Error
173174
});
174175

175-
return RedirectToAction("GetStoreTronUSDtLikePaymentMethod", new { storeId = store.Id, cryptoCode });
176+
return RedirectToAction("GetStoreTronUSDtLikePaymentMethod", new { storeId = store.Id, cryptoCode = cryptoCode });
176177
}
177178

178179
currentPaymentMethodConfig.Addresses =

BTCPayServer.Plugins.USDt/Controllers/ViewModels/EditTronUSDtPaymentMethodViewModel.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using BTCPayServer.Plugins.TronUSDt.Configuration;
1+
using BTCPayServer.Plugins.USDt.Configuration;
22

3-
namespace BTCPayServer.Plugins.TronUSDt.Controllers.ViewModels;
3+
namespace BTCPayServer.Plugins.USDt.Controllers.ViewModels;
44

55
public class EditTronUSDtPaymentMethodViewModel
66
{

BTCPayServer.Plugins.USDt/Controllers/ViewModels/TronUSDtLikeServerConfigViewModel.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
2-
using BTCPayServer.Plugins.TronUSDt.Configuration;
2+
using BTCPayServer.Plugins.USDt.Configuration;
33
using BTCPayServer.Validation;
44

5-
namespace BTCPayServer.Plugins.TronUSDt.Controllers.ViewModels;
5+
namespace BTCPayServer.Plugins.USDt.Controllers.ViewModels;
66

77
public class TronUSDtLikeServerConfigViewModel
88
{

BTCPayServer.Plugins.USDt/Controllers/ViewModels/TronUSDtPaymentViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22

3-
namespace BTCPayServer.Plugins.TronUSDt.Controllers.ViewModels;
3+
namespace BTCPayServer.Plugins.USDt.Controllers.ViewModels;
44

55
public class TronUSDtPaymentViewModel
66
{

BTCPayServer.Plugins.USDt/Controllers/ViewModels/ViewTronUSDtStoreOptionItemViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace BTCPayServer.Plugins.TronUSDt.Controllers.ViewModels;
1+
namespace BTCPayServer.Plugins.USDt.Controllers.ViewModels;
22

33
public class ViewTronUSDtStoreOptionItemViewModel
44
{

BTCPayServer.Plugins.USDt/Controllers/ViewModels/ViewTronUSDtStoreOptionsViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Collections.Generic;
22

3-
namespace BTCPayServer.Plugins.TronUSDt.Controllers.ViewModels;
3+
namespace BTCPayServer.Plugins.USDt.Controllers.ViewModels;
44

55
public class ViewTronUSDtStoreOptionsViewModel
66
{

BTCPayServer.Plugins.USDt/Services/Events/TronUSDtDaemonStateChanged.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace BTCPayServer.Plugins.TronUSDt.Services.Events;
1+
using BTCPayServer.Payments;
2+
3+
namespace BTCPayServer.Plugins.USDt.Services.Events;
24

35
public class TronUSDtDaemonStateChanged
46
{

BTCPayServer.Plugins.USDt/Services/Events/TronUSDtSettingsChanged.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace BTCPayServer.Plugins.TronUSDt.Services.Events;
1+
namespace BTCPayServer.Plugins.USDt.Services.Events;
22

33
public class TronUSDtSettingsChanged
44
{

BTCPayServer.Plugins.USDt/Services/Payments/TronUSDtLikeOnChainPaymentMethodDetails.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace BTCPayServer.Plugins.TronUSDt.Services.Payments;
1+
namespace BTCPayServer.Plugins.USDt.Services.Payments;
22

33
public class TronUSDtLikeOnChainPaymentMethodDetails
44
{

BTCPayServer.Plugins.USDt/Services/Payments/TronUSDtLikePaymentData.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
using System.Globalization;
22
using System.Numerics;
33
using BTCPayServer.Client.Models;
4+
using BTCPayServer.Payments;
45
using BTCPayServer.Services.Invoices;
56
using Nethereum.Web3;
67

7-
namespace BTCPayServer.Plugins.TronUSDt.Services.Payments;
8+
namespace BTCPayServer.Plugins.USDt.Services.Payments;
89

910
public class TronUSDtLikePaymentData : CryptoPaymentData
1011
{

BTCPayServer.Plugins.USDt/Services/Payments/TronUSDtLikePaymentMethodHandler.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using Newtonsoft.Json;
88
using Newtonsoft.Json.Linq;
99

10-
namespace BTCPayServer.Plugins.TronUSDt.Services.Payments;
10+
namespace BTCPayServer.Plugins.USDt.Services.Payments;
1111

1212
public class TronUSDtLikePaymentMethodHandler(
1313
TronUSDtLikeSpecificBtcPayNetwork network,

BTCPayServer.Plugins.USDt/Services/Payments/TronUSDtPaymentLinkExtension.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
using System;
21
using System.Globalization;
32
using BTCPayServer.Payments;
43
using BTCPayServer.Services.Invoices;
54
using Microsoft.AspNetCore.Mvc;
65

7-
namespace BTCPayServer.Plugins.TronUSDt.Services.Payments;
6+
namespace BTCPayServer.Plugins.USDt.Services.Payments;
87

98
public class TronUSDtPaymentLinkExtension(PaymentMethodId paymentMethodId) : IPaymentLinkExtension
109
{

BTCPayServer.Plugins.USDt/Services/Payments/TronUSDtPaymentMethodConfig.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using BTCPayServer.Payments;
44
using BTCPayServer.Services.Invoices;
55

6-
namespace BTCPayServer.Plugins.TronUSDt.Services.Payments;
6+
namespace BTCPayServer.Plugins.USDt.Services.Payments;
77

88
public class TronUSDtPaymentMethodConfig
99
{

BTCPayServer.Plugins.USDt/Services/Payments/TronUSDtPaymentModelExtension.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Linq;
33
using BTCPayServer.Payments;
44

5-
namespace BTCPayServer.Plugins.TronUSDt.Services.Payments;
5+
namespace BTCPayServer.Plugins.USDt.Services.Payments;
66

77
public class TronUSDtPaymentModelExtension(
88
PaymentMethodId paymentMethodId,

BTCPayServer.Plugins.USDt/Services/Payments/TronUSDtPaymentType.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using BTCPayServer.Payments;
22

3-
namespace BTCPayServer.Plugins.TronUSDt.Services.Payments;
3+
namespace BTCPayServer.Plugins.USDt.Services.Payments;
44

55
internal class TronUSDtPaymentType
66
{

BTCPayServer.Plugins.USDt/Services/TronUSDtAddressHelper.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Text;
44
using NBitcoin.DataEncoders;
55

6-
namespace BTCPayServer.Plugins.TronUSDt.Services;
6+
namespace BTCPayServer.Plugins.USDt.Services;
77

88
public static class TronUSDtAddressHelper
99
{
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
namespace BTCPayServer.Plugins.TronUSDt.Services;
1+
namespace BTCPayServer.Plugins.USDt.Services;
22

33
public class TronUSDtLikeSpecificBtcPayNetwork : BTCPayNetworkBase;

BTCPayServer.Plugins.USDt/Services/TronUSDtLikeSummaryUpdaterHostedService.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
using System.Threading;
33
using System.Threading.Tasks;
44
using BTCPayServer.Logging;
5-
using BTCPayServer.Plugins.TronUSDt.Configuration;
5+
using BTCPayServer.Payments;
6+
using BTCPayServer.Plugins.USDt.Configuration;
67
using Microsoft.Extensions.Hosting;
78
using Microsoft.Extensions.Logging;
89

9-
namespace BTCPayServer.Plugins.TronUSDt.Services;
10+
namespace BTCPayServer.Plugins.USDt.Services;
1011

1112
public class TronUSDtLikeSummaryUpdaterHostedService(
1213
TronUSDtRPCProvider tronUSDtRpcProvider,

BTCPayServer.Plugins.USDt/Services/TronUSDtListener.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Concurrent;
33
using System.Collections.Generic;
4+
using System.Configuration;
45
using System.Linq;
56
using System.Numerics;
67
using System.Threading;
@@ -9,8 +10,9 @@
910
using BTCPayServer.Client.Models;
1011
using BTCPayServer.Data;
1112
using BTCPayServer.Events;
12-
using BTCPayServer.Plugins.TronUSDt.Configuration;
13-
using BTCPayServer.Plugins.TronUSDt.Services.Payments;
13+
using BTCPayServer.Payments;
14+
using BTCPayServer.Plugins.USDt.Configuration;
15+
using BTCPayServer.Plugins.USDt.Services.Payments;
1416
using BTCPayServer.Services.Invoices;
1517
using Microsoft.Extensions.Hosting;
1618
using Microsoft.Extensions.Logging;
@@ -21,7 +23,7 @@
2123
using Nethereum.Hex.HexTypes;
2224
using Nethereum.RPC.Eth.DTOs;
2325

24-
namespace BTCPayServer.Plugins.TronUSDt.Services;
26+
namespace BTCPayServer.Plugins.USDt.Services;
2527

2628
public class TronUSDtListener(
2729
InvoiceRepository invoiceRepository,

BTCPayServer.Plugins.USDt/Services/TronUSDtListenerState.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Numerics;
22

3-
namespace BTCPayServer.Plugins.TronUSDt.Services;
3+
namespace BTCPayServer.Plugins.USDt.Services;
44

55
public class TronUSDtListenerState
66
{

BTCPayServer.Plugins.USDt/Services/TronUSDtRPCProvider.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
using System.Net.Http;
77
using System.Numerics;
88
using System.Threading.Tasks;
9-
using BTCPayServer.Plugins.TronUSDt.Configuration;
10-
using BTCPayServer.Plugins.TronUSDt.Services.Events;
9+
using BTCPayServer.Payments;
10+
using BTCPayServer.Plugins.USDt.Configuration;
11+
using BTCPayServer.Plugins.USDt.Services.Events;
1112
using BTCPayServer.Services;
1213
using NBitcoin;
1314
using Nethereum.JsonRpc.Client;
1415
using Nethereum.StandardTokenEIP20;
1516
using Nethereum.Web3;
1617

17-
namespace BTCPayServer.Plugins.TronUSDt.Services;
18+
namespace BTCPayServer.Plugins.USDt.Services;
1819

1920
public class TronUSDtRPCProvider
2021
{
@@ -160,7 +161,7 @@ public async Task UpdateSummary(string cryptoCode)
160161

161162
public static string ListenerStateSettingKey(string cryptoCode)
162163
{
163-
return "TRONUSDT_LISTENER_" + cryptoCode;
164+
return "USDT_LISTENER_" + cryptoCode;
164165
}
165166

166167
public class TronUSDtLikeSummary

0 commit comments

Comments
 (0)