-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9dd742
commit 72a38ab
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
IotaSDK.NET/Contexts/WalletContext/Commands/BackupStronghold/BackupStrongholdCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...DK.NET/Contexts/WalletContext/Commands/BackupStronghold/BackupStrongholdCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
....NET/Contexts/WalletContext/Commands/BackupStronghold/BackupStrongholdCommandModelData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |