using DysonNetwork.Shared.Proto; using Grpc.Core; namespace DysonNetwork.Pass.Wallet; public class WalletServiceGrpc(WalletService walletService) : Shared.Proto.WalletService.WalletServiceBase { public override async Task 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 CreateWallet(CreateWalletRequest request, ServerCallContext context) { var wallet = await walletService.CreateWalletAsync(Guid.Parse(request.AccountId)); return wallet.ToProtoValue(); } public override async Task 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(); } }