Remove useless constant

This commit is contained in:
nicolas.dorier 2020-12-23 14:07:24 +09:00
parent 69eaaef963
commit f0fc0441bd
No known key found for this signature in database
GPG key ID: 6618763EF09186FE
2 changed files with 14 additions and 12 deletions

View file

@ -35,7 +35,7 @@ namespace BTCPayServer.Controllers.GreenField
} }
[Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)] [Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/" + BitcoinPaymentType.GreenFieldApiId)] [HttpGet("~/api/v1/stores/{storeId}/payment-methods/onchain")]
public ActionResult<IEnumerable<OnChainPaymentMethodData>> GetOnChainPaymentMethods( public ActionResult<IEnumerable<OnChainPaymentMethodData>> GetOnChainPaymentMethods(
[FromQuery] bool enabledOnly = false) [FromQuery] bool enabledOnly = false)
{ {
@ -55,7 +55,7 @@ namespace BTCPayServer.Controllers.GreenField
} }
[Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)] [Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/" + BitcoinPaymentType.GreenFieldApiId + "/{cryptoCode}")] [HttpGet("~/api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}")]
public ActionResult<OnChainPaymentMethodData> GetOnChainPaymentMethod(string cryptoCode) public ActionResult<OnChainPaymentMethodData> GetOnChainPaymentMethod(string cryptoCode)
{ {
if (!GetCryptoCodeWallet(cryptoCode, out BTCPayNetwork _, out BTCPayWallet _)) if (!GetCryptoCodeWallet(cryptoCode, out BTCPayNetwork _, out BTCPayWallet _))
@ -72,8 +72,7 @@ namespace BTCPayServer.Controllers.GreenField
} }
[Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)] [Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/" + BitcoinPaymentType.GreenFieldApiId + [HttpGet("~/api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/preview")]
"/{cryptoCode}/preview")]
public ActionResult<OnChainPaymentMethodPreviewResultData> GetOnChainPaymentMethodPreview( public ActionResult<OnChainPaymentMethodPreviewResultData> GetOnChainPaymentMethodPreview(
string cryptoCode, string cryptoCode,
int offset = 0, int amount = 10) int offset = 0, int amount = 10)
@ -111,8 +110,7 @@ namespace BTCPayServer.Controllers.GreenField
[Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)] [Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
[HttpPost("~/api/v1/stores/{storeId}/payment-methods/" + BitcoinPaymentType.GreenFieldApiId + [HttpPost("~/api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/preview")]
"/{cryptoCode}/preview")]
public IActionResult GetProposedOnChainPaymentMethodPreview(string cryptoCode, public IActionResult GetProposedOnChainPaymentMethodPreview(string cryptoCode,
[FromBody] OnChainPaymentMethodData paymentMethodData, [FromBody] OnChainPaymentMethodData paymentMethodData,
int offset = 0, int amount = 10) int offset = 0, int amount = 10)
@ -121,7 +119,13 @@ namespace BTCPayServer.Controllers.GreenField
{ {
return NotFound(); return NotFound();
} }
if (string.IsNullOrEmpty(paymentMethodData.DerivationScheme))
{
ModelState.AddModelError(nameof(OnChainPaymentMethodData.DerivationScheme),
"Missing derivationScheme");
}
if (!ModelState.IsValid)
return this.CreateValidationError(ModelState);
try try
{ {
var strategy = DerivationSchemeSettings.Parse(paymentMethodData.DerivationScheme, network); var strategy = DerivationSchemeSettings.Parse(paymentMethodData.DerivationScheme, network);
@ -155,8 +159,7 @@ namespace BTCPayServer.Controllers.GreenField
} }
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)] [Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
[HttpDelete("~/api/v1/stores/{storeId}/payment-methods/" + BitcoinPaymentType.GreenFieldApiId + [HttpDelete("~/api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}")]
"/{cryptoCode}")]
public async Task<ActionResult<OnChainPaymentMethodPreviewResultData>> RemoveOnChainPaymentMethod( public async Task<ActionResult<OnChainPaymentMethodPreviewResultData>> RemoveOnChainPaymentMethod(
string cryptoCode, string cryptoCode,
int offset = 0, int amount = 10) int offset = 0, int amount = 10)
@ -174,7 +177,7 @@ namespace BTCPayServer.Controllers.GreenField
} }
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)] [Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
[HttpPut("~/api/v1/stores/{storeId}/payment-methods/" + BitcoinPaymentType.GreenFieldApiId + "/{cryptoCode}")] [HttpPut("~/api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}")]
public async Task<IActionResult> UpdateOnChainPaymentMethod(string cryptoCode, public async Task<IActionResult> UpdateOnChainPaymentMethod(string cryptoCode,
[FromBody] OnChainPaymentMethodData paymentMethodData) [FromBody] OnChainPaymentMethodData paymentMethodData)
{ {

View file

@ -18,8 +18,7 @@ namespace BTCPayServer.Payments
public override string ToPrettyString() => "On-Chain"; public override string ToPrettyString() => "On-Chain";
public override string GetId() => "BTCLike"; public override string GetId() => "BTCLike";
public override string GetBadge() => "🔗"; public override string GetBadge() => "🔗";
public override string ToStringNormalized() => GreenFieldApiId; public override string ToStringNormalized() => "OnChain";
public const string GreenFieldApiId = "OnChain";
public override CryptoPaymentData DeserializePaymentData(BTCPayNetworkBase network, string str) public override CryptoPaymentData DeserializePaymentData(BTCPayNetworkBase network, string str)
{ {
return ((BTCPayNetwork)network)?.ToObject<BitcoinLikePaymentData>(str); return ((BTCPayNetwork)network)?.ToObject<BitcoinLikePaymentData>(str);