Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ public class StoreMnemonicCommandHandler : IRequestHandler<StoreMnemonicCommand,
{
public async Task<StoreMnemonicResponse> Handle(StoreMnemonicCommand request, CancellationToken cancellationToken)
{
StoreMnemonicCommandMessage message = new StoreMnemonicCommandMessage(request.Mnemonic);
StoreMnemonicCommandMessageData messageData = new StoreMnemonicCommandMessageData(request.Mnemonic);
StoreMnemonicCommandMessage message = new StoreMnemonicCommandMessage(messageData);

string messageJson = JsonConvert.SerializeObject(message);
RustBridgeGenericResponse genericResponse = await request.Wallet.SendMessageAsync(messageJson);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace IotaWalletNet.Application.WalletContext.Commands.StoreMnemonic
{
internal class StoreMnemonicCommandMessage : Message<string>
internal class StoreMnemonicCommandMessage : Message<StoreMnemonicCommandMessageData>
{
private const string COMMAND = "storeMnemonic";

public StoreMnemonicCommandMessage(string mnemonic)
public StoreMnemonicCommandMessage(StoreMnemonicCommandMessageData storeMnemonicCommandMessageData)
{
Cmd = COMMAND;
Payload = mnemonic;
Payload = storeMnemonicCommandMessageData;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace IotaWalletNet.Application.WalletContext.Commands.StoreMnemonic
{
internal class StoreMnemonicCommandMessageData
{
public StoreMnemonicCommandMessageData(string mnemonic)
{
Mnemonic= mnemonic;
}

public string Mnemonic { get; private set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public class VerifyMnemonicCommandHandler : IRequestHandler<VerifyMnemonicComman
{
public async Task<VerifyMnemonicResponse> Handle(VerifyMnemonicCommand request, CancellationToken cancellationToken)
{
VerifyMnemonicCommandMessage message = new VerifyMnemonicCommandMessage(request.Mnemonic);
VerifyMnemonicCommandMessageData messageData = new VerifyMnemonicCommandMessageData(request.Mnemonic);
VerifyMnemonicCommandMessage message = new VerifyMnemonicCommandMessage(messageData);
string json = JsonConvert.SerializeObject(message);
RustBridgeGenericResponse genericResponse = await request.Wallet.SendMessageAsync(json);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace IotaWalletNet.Application.WalletContext.Commands.VerifyMnemonic
{
public class VerifyMnemonicCommandMessage : Message<string>
internal class VerifyMnemonicCommandMessage : Message<VerifyMnemonicCommandMessageData>
{
private const string COMMAND = "verifyMnemonic";

public VerifyMnemonicCommandMessage(string mnemonic)
public VerifyMnemonicCommandMessage(VerifyMnemonicCommandMessageData verifyMnemonicCommandMessageData)
{
Cmd = COMMAND;
Payload = mnemonic;
Payload = verifyMnemonicCommandMessageData;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace IotaWalletNet.Application.WalletContext.Commands.VerifyMnemonic
{
internal class VerifyMnemonicCommandMessageData
{
public VerifyMnemonicCommandMessageData(string mnemonic)
{
Mnemonic = mnemonic;
}

public string Mnemonic { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public partial class GetAccountQueryHandler : IRequestHandler<GetAccountQuery, G
{
public async Task<GetAccountResponse> Handle(GetAccountQuery request, CancellationToken cancellationToken)
{
GetAccountQueryMessage message = new GetAccountQueryMessage(request.Username);
GetAccountQueryMessageData messageData = new GetAccountQueryMessageData(request.Username);
GetAccountQueryMessage message = new GetAccountQueryMessage(messageData);
string json = JsonConvert.SerializeObject(message);
RustBridgeGenericResponse genericResponse = await request.Wallet.SendMessageAsync(json);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace IotaWalletNet.Application.WalletContext.Queries.GetAccount
{
public class GetAccountQueryMessage : Message<string>
internal class GetAccountQueryMessage : Message<GetAccountQueryMessageData>
{
private const string COMMAND = "getAccount";

public GetAccountQueryMessage(string username)
public GetAccountQueryMessage(GetAccountQueryMessageData getAccountQueryMessageData)
{
Cmd = COMMAND;
Payload = username;
Payload = getAccountQueryMessageData;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace IotaWalletNet.Application.WalletContext.Queries.GetAccount
{
internal class GetAccountQueryMessageData
{
public GetAccountQueryMessageData(string username)
{
AccountId= username;
}

public string AccountId { get; private set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static async Task Run()
SyncAccountResponse syncAccountResponse = await account.SyncAccountAsync();
Console.WriteLine($"SyncAccountAsync: {syncAccountResponse}");

await account.ConsolidateOutputsAsync(true);
//await account.ConsolidateOutputsAsync(true);

GetBalanceResponse getBalanceResponse = await account.GetBalanceAsync();
Console.WriteLine($"GetBalanceAsync: {getBalanceResponse}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ public static async Task Run()
//Sync account
await account.SyncAccountAsync();

Console.WriteLine(await account.GetBalanceAsync());

//TODO: Replace with an nft output id from your accounts.
string outputId = "0x9c5fc8b575e29377e0401d2cd6138c0f4859fbb95b5acf0ea81b3354de6eb2e70100";
string outputId = "0xbb237bab9e5277867c99cb05ce89176838a57bce230a9cd593aee586bffa11b50000";

var nftId = outputId.ComputeBlake2bHash();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ public static async Task Run()

await account.SyncAccountAsync();

Console.WriteLine(await account.GetBalanceAsync());

//TODO: Replace with the address of your choice!
string receiverAddress = "rms1qz8wf6jrchvsfmcnsfhlf6s53x3u85y0j4hvwth9a5ff3xhrxtmvvyc9ae7";

//TODO: Replace with an nft output id from your accounts.
string outputId = "0x9c5fc8b575e29377e0401d2cd6138c0f4859fbb95b5acf0ea81b3354de6eb2e70000";
string outputId = "0xbb237bab9e5277867c99cb05ce89176838a57bce230a9cd593aee586bffa11b50100";

var nftId = outputId.ComputeBlake2bHash();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="SiaSkynet" Version="3.5.0" />
<PackageReference Include="SiaSkynet" Version="3.6.0" />
</ItemGroup>

<ItemGroup>
Expand Down
17 changes: 15 additions & 2 deletions csharp/IotaWalletNet/IotaWalletNet.Main/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
using IotaWalletNet.Main.Examples.Events.WaitForTransactionConfirmation;
using IotaWalletNet.Main.Examples.Accounts_and_Addresses;
using IotaWalletNet.Main.Examples.Accounts_and_Addresses.Check_Balance;
using IotaWalletNet.Main.Examples.Accounts_and_Addresses.Generate_an_Address;
using IotaWalletNet.Main.Examples.Events.Subscribe;
using IotaWalletNet.Main.Examples.Events.WaitForTransactionConfirmation;
using IotaWalletNet.Main.Examples.Native_Tokens.Melt;
using IotaWalletNet.Main.Examples.Native_Tokens.Mint;
using IotaWalletNet.Main.Examples.Native_Tokens.Send;
using IotaWalletNet.Main.Examples.NFTs.Burn;
using IotaWalletNet.Main.Examples.NFTs.Mint;
using IotaWalletNet.Main.Examples.NFTs.Send;
using IotaWalletNet.Main.Examples.Outputs_and_Transactions.Periodic_Syncing;
using IotaWalletNet.Main.Examples.Outputs_and_Transactions.Request_Tokens_from_Faucet;
using IotaWalletNet.Main.Examples.Outputs_and_Transactions.Send_a_Transaction;

namespace IotaWalletNet.Main
{
internal class Program
{
private static async Task Main(string[] args)
{

//await CreateAWalletAndAccountExample.Run();

//await RequestTokensFromFaucetExample.Run();
Expand Down Expand Up @@ -37,7 +50,7 @@ private static async Task Main(string[] args)
//await ClaimOutputsExample.Run();

//await PeriodicSyncingExample.Run();
await WaitForTransactionConfirmationExample.Run();
//await WaitForTransactionConfirmationExample.Run();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ public async Task WalletShouldValidateFalseForWrongMnemonic()
IWallet wallet = _serviceScope.ServiceProvider.GetRequiredService<IWallet>();
wallet = await CreateOfflineFullWalletAsync(wallet, shouldCreateAndStoreMnemonic: false);
string mnemonic = "hood medal among prevent during embrace inmate swarm ancient damp token rail wolf risk tortoise record dose language rival cloud sting grace palm style";
try
{
await wallet.VerifyMnemonicAsync("asdasd");

}
catch(RustBridgeException e)
{

}

await wallet.Awaiting(x => x.VerifyMnemonicAsync("wrong mnemonic")).Should().ThrowAsync<RustBridgeException>();
await wallet.Awaiting(x => x.VerifyMnemonicAsync(mnemonic + "random")).Should().ThrowAsync<RustBridgeException>();
Expand Down