♻️ Splitted wallet service
This commit is contained in:
37
DysonNetwork.Shared/Registry/RemoteWalletService.cs
Normal file
37
DysonNetwork.Shared/Registry/RemoteWalletService.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using DysonNetwork.Shared.Proto;
|
||||
|
||||
namespace DysonNetwork.Shared.Registry;
|
||||
|
||||
public class RemoteWalletService(WalletService.WalletServiceClient wallet)
|
||||
{
|
||||
public async Task<Wallet> GetWallet(Guid accountId)
|
||||
{
|
||||
var request = new GetWalletRequest { AccountId = accountId.ToString() };
|
||||
var response = await wallet.GetWalletAsync(request);
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<Wallet> CreateWallet(Guid accountId)
|
||||
{
|
||||
var request = new CreateWalletRequest { AccountId = accountId.ToString() };
|
||||
var response = await wallet.CreateWalletAsync(request);
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<WalletPocket> GetOrCreateWalletPocket(Guid walletId, string currency, decimal? initialAmount = null)
|
||||
{
|
||||
var request = new GetOrCreateWalletPocketRequest
|
||||
{
|
||||
WalletId = walletId.ToString(),
|
||||
Currency = currency
|
||||
};
|
||||
|
||||
if (initialAmount.HasValue)
|
||||
{
|
||||
request.InitialAmount = initialAmount.Value.ToString();
|
||||
}
|
||||
|
||||
var response = await wallet.GetOrCreateWalletPocketAsync(request);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user