Add initAddress api
This commit is contained in:
@@ -3,6 +3,7 @@ using Managing.Application.Abstractions.Services;
|
||||
using Managing.Application.Trading.Commands;
|
||||
using Managing.Domain.MoneyManagements;
|
||||
using Managing.Domain.Trades;
|
||||
using Managing.Infrastructure.Evm.Models.Privy;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -156,4 +157,33 @@ public class TradingController : BaseController
|
||||
var result = await _openTradeCommandHandler.Handle(command);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a Privy wallet address for the user.
|
||||
/// </summary>
|
||||
/// <param name="publicAddress">The public address of the Privy wallet to initialize.</param>
|
||||
/// <returns>The initialization response containing success status and transaction hashes.</returns>
|
||||
[HttpPost("InitPrivyWallet")]
|
||||
public async Task<ActionResult<PrivyInitAddressResponse>> InitPrivyWallet([FromBody] string publicAddress)
|
||||
{
|
||||
if (string.IsNullOrEmpty(publicAddress))
|
||||
{
|
||||
return BadRequest("Public address cannot be null or empty.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _tradingService.InitPrivyWallet(publicAddress);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error initializing Privy wallet address: {Address}", publicAddress);
|
||||
return StatusCode(500, new PrivyInitAddressResponse
|
||||
{
|
||||
Success = false,
|
||||
Error = "An error occurred while initializing the Privy wallet address."
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user