✨ Payment grpc services and perks in proto
This commit is contained in:
29
DysonNetwork.Pass/Wallet/WalletServiceGrpc.cs
Normal file
29
DysonNetwork.Pass/Wallet/WalletServiceGrpc.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using DysonNetwork.Shared.Proto;
|
||||
using Grpc.Core;
|
||||
|
||||
namespace DysonNetwork.Pass.Wallet;
|
||||
|
||||
public class WalletServiceGrpc(WalletService walletService) : Shared.Proto.WalletService.WalletServiceBase
|
||||
{
|
||||
public override async Task<Shared.Proto.Wallet> GetWallet(GetWalletRequest request, ServerCallContext context)
|
||||
{
|
||||
var wallet = await walletService.GetWalletAsync(Guid.Parse(request.AccountId));
|
||||
if (wallet == null)
|
||||
{
|
||||
throw new RpcException(new Status(StatusCode.NotFound, "Wallet not found."));
|
||||
}
|
||||
return wallet.ToProtoValue();
|
||||
}
|
||||
|
||||
public override async Task<Shared.Proto.Wallet> CreateWallet(CreateWalletRequest request, ServerCallContext context)
|
||||
{
|
||||
var wallet = await walletService.CreateWalletAsync(Guid.Parse(request.AccountId));
|
||||
return wallet.ToProtoValue();
|
||||
}
|
||||
|
||||
public override async Task<Shared.Proto.WalletPocket> GetOrCreateWalletPocket(GetOrCreateWalletPocketRequest request, ServerCallContext context)
|
||||
{
|
||||
var (pocket, _) = await walletService.GetOrCreateWalletPocketAsync(Guid.Parse(request.WalletId), request.Currency, request.HasInitialAmount ? decimal.Parse(request.InitialAmount) : null);
|
||||
return pocket.ToProtoValue();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user