Skip to content

Commit

Permalink
added ignored files
Browse files Browse the repository at this point in the history
  • Loading branch information
wireless90 committed Jan 8, 2024
1 parent e9dd742 commit 72a38ab
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using IotaSDK.NET.Common.Interfaces;
using IotaSDK.NET.Common.Models;
using System;

namespace IotaSDK.NET.Contexts.WalletContext.Commands.BackupStronghold
{
internal class BackupStrongholdCommand : WalletRequest<IotaSDKResponse<bool>>
{
public BackupStrongholdCommand(IntPtr walletHandle, string destinationPath, string password) : base(walletHandle)
{
DestinationPath = destinationPath;
Password = password;
}

public string DestinationPath { get; }
public string Password { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using IotaSDK.NET.Common.Exceptions;
using IotaSDK.NET.Common.Models;
using IotaSDK.NET.Common.Rust;
using MediatR;
using System.Threading;
using System.Threading.Tasks;

namespace IotaSDK.NET.Contexts.WalletContext.Commands.BackupStronghold
{
internal class BackupStrongholdCommandHandler : IRequestHandler<BackupStrongholdCommand, IotaSDKResponse<bool>>
{
private readonly RustBridgeWallet _rustBridgeWallet;

public BackupStrongholdCommandHandler(RustBridgeWallet rustBridgeWallet)
{
_rustBridgeWallet = rustBridgeWallet;
}

public async Task<IotaSDKResponse<bool>> Handle(BackupStrongholdCommand request, CancellationToken cancellationToken)
{
BackupStrongholdCommandModelData modelData = new BackupStrongholdCommandModelData(request.DestinationPath, request.Password);
IotaSDKModel<BackupStrongholdCommandModelData> model = new IotaSDKModel<BackupStrongholdCommandModelData>("backup", modelData);
string json = model.AsJson();

string? walletResponse = await _rustBridgeWallet.CallWalletMethodAsync(request.WalletHandle, json);

IotaSDKException.CheckForException(walletResponse!);

var response = IotaSDKResponse<bool>.CreateInstance(walletResponse, "backup");
response.Payload = true;

return response;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace IotaSDK.NET.Contexts.WalletContext.Commands.BackupStronghold
{
internal class BackupStrongholdCommandModelData
{
public BackupStrongholdCommandModelData(string destination, string password)
{
Destination = destination;
Password = password;
}

public string Destination { get; }
public string Password { get; }
}
}

0 comments on commit 72a38ab

Please sign in to comment.