Skip to content

Commit 6110d56

Browse files
authored
Merge branch 'main' into 67-feat-sendmicrotransaction
2 parents 729f76a + 7f6f44b commit 6110d56

File tree

23 files changed

+592
-46
lines changed

23 files changed

+592
-46
lines changed

.github/workflows/Compile.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ on:
88
branches: [ "main" ]
99
env:
1010
MAIN_SOLUTION_PATH: "./csharp/IotaWalletNet/IotaWalletNet.sln"
11+
1112

1213
jobs:
1314
build:
1415

15-
runs-on: windows-latest
16+
runs-on: ubuntu-latest
1617
environment: myenv
1718

1819
steps:
@@ -32,5 +33,7 @@ jobs:
3233
working-directory: ./csharp/IotaWalletNet
3334

3435
- name: Test
35-
run: dotnet test --configuration Release --no-build --verbosity normal --logger:"console;verbosity=detailed"
36+
run: |
37+
export LD_LIBRARY_PATH="/home/runner/work/IotaWallet.NET/IotaWallet.NET/csharp/IotaWalletNet/IotaWalletNet.Main/bin/Release/net6.0/"
38+
dotnet test --configuration Release --no-build --verbosity normal --logger:"console;verbosity=detailed"
3639
working-directory: ./csharp/IotaWalletNet

.github/workflows/GithubNuget.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
env:
1313
APP_SOLUTION_PATH: ./csharp/IotaWalletNet/IotaWalletNet.Application/IotaWalletNet.Application.csproj
1414
DOMAIN_SOLUTION_PATH: ./csharp/IotaWalletNet/IotaWalletNet.Domain/IotaWalletNet.Domain.csproj
15-
NUGET_PATH: ${{ github.workspace }}\nugets
15+
NUGET_PATH: ${{ github.workspace }}/nugets
1616
NUGET_SRC_URL: 'https://api.nuget.org/v3/index.json'
1717

1818
# Allows you to run this workflow manually from the Actions tab
@@ -23,7 +23,7 @@ jobs:
2323
# This workflow contains a single job called "build"
2424
build:
2525
# The type of runner that the job will run on
26-
runs-on: windows-latest
26+
runs-on: ubuntu-latest
2727
environment: myenv
2828

2929
# Steps represent a sequence of tasks that will be executed as part of the job
@@ -46,7 +46,9 @@ jobs:
4646
working-directory: ./csharp/IotaWalletNet
4747

4848
- name: Test
49-
run: dotnet test --configuration Release --no-build --verbosity normal --logger:"console;verbosity=detailed"
49+
run: |
50+
export LD_LIBRARY_PATH="/home/runner/work/IotaWallet.NET/IotaWallet.NET/csharp/IotaWalletNet/IotaWalletNet.Main/bin/Release/net6.0/"
51+
dotnet test --configuration Release --no-build --verbosity normal --logger:"console;verbosity=detailed"
5052
working-directory: ./csharp/IotaWalletNet
5153

5254
- name: Get Version
@@ -63,18 +65,18 @@ jobs:
6365
uses: actions/upload-artifact@v1
6466
with:
6567
name: IotaWallet.Net.Domain
66-
path: ${{ env.NUGET_PATH }}\IotaWallet.Net.Domain.${{ steps.version.outputs.version-without-v }}.nupkg
68+
path: ${{ env.NUGET_PATH }}/IotaWallet.Net.Domain.${{ steps.version.outputs.version-without-v }}.nupkg
6769

6870
- name: Create Application NuGet Package Artifact
6971
uses: actions/upload-artifact@v1
7072
with:
7173
name: IotaWallet.Net
72-
path: ${{ env.NUGET_PATH }}\IotaWallet.Net.${{ steps.version.outputs.version-without-v }}.nupkg
74+
path: ${{ env.NUGET_PATH }}/IotaWallet.Net.${{ steps.version.outputs.version-without-v }}.nupkg
7375

7476
- name: Add Nuget Source
7577
#run: dotnet nuget push ${{ env.NUGET_PATH }}\*.nupkg -s "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NUGET_AUTH_TOKEN }} --skip-duplicate --no-symbols
7678
run: dotnet nuget add source --username wireless90 --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/IOTA-NET/index.json"
7779

7880
- name: Push All Nugets
79-
run: dotnet nuget push ${{ env.NUGET_PATH }}\*.nupkg --api-key ${{ secrets.GHUB_NUGET_AUTH_TOKEN }} --source "github" --skip-duplicate --no-symbols
81+
run: dotnet nuget push ${{ env.NUGET_PATH }}/*.nupkg --api-key ${{ secrets.GHUB_NUGET_AUTH_TOKEN }} --source "github" --skip-duplicate --no-symbols
8082

.github/workflows/Nuget.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
env:
1313
APP_SOLUTION_PATH: ./csharp/IotaWalletNet/IotaWalletNet.Application/IotaWalletNet.Application.csproj
1414
DOMAIN_SOLUTION_PATH: ./csharp/IotaWalletNet/IotaWalletNet.Domain/IotaWalletNet.Domain.csproj
15-
NUGET_PATH: ${{ github.workspace }}\nugets
15+
NUGET_PATH: ${{ github.workspace }}/nugets
1616
NUGET_SRC_URL: 'https://api.nuget.org/v3/index.json'
1717

1818
# Allows you to run this workflow manually from the Actions tab
@@ -23,7 +23,7 @@ jobs:
2323
# This workflow contains a single job called "build"
2424
build:
2525
# The type of runner that the job will run on
26-
runs-on: windows-latest
26+
runs-on: ubuntu-latest
2727
environment: myenv
2828

2929
# Steps represent a sequence of tasks that will be executed as part of the job
@@ -46,7 +46,9 @@ jobs:
4646
working-directory: ./csharp/IotaWalletNet
4747

4848
- name: Test
49-
run: dotnet test --configuration Release --no-build --verbosity normal --logger:"console;verbosity=detailed"
49+
run: |
50+
export LD_LIBRARY_PATH="/home/runner/work/IotaWallet.NET/IotaWallet.NET/csharp/IotaWalletNet/IotaWalletNet.Main/bin/Release/net6.0/"
51+
dotnet test --configuration Release --no-build --verbosity normal --logger:"console;verbosity=detailed"
5052
working-directory: ./csharp/IotaWalletNet
5153

5254
- name: Get Version
@@ -64,14 +66,14 @@ jobs:
6466
uses: actions/upload-artifact@v1
6567
with:
6668
name: IotaWallet.Net.Domain
67-
path: ${{ env.NUGET_PATH }}\IotaWallet.Net.Domain.${{ steps.version.outputs.version-without-v }}.nupkg
69+
path: ${{ env.NUGET_PATH }}/IotaWallet.Net.Domain.${{ steps.version.outputs.version-without-v }}.nupkg
6870

6971
- name: Create Application NuGet Package Artifact
7072
uses: actions/upload-artifact@v1
7173
with:
7274
name: IotaWallet.Net
73-
path: ${{ env.NUGET_PATH }}\IotaWallet.Net.${{ steps.version.outputs.version-without-v }}.nupkg
75+
path: ${{ env.NUGET_PATH }}/IotaWallet.Net.${{ steps.version.outputs.version-without-v }}.nupkg
7476

7577
- name: Push All Nugets
76-
run: dotnet nuget push ${{ env.NUGET_PATH }}\*.nupkg -s "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NUGET_AUTH_TOKEN }} --skip-duplicate --no-symbols
78+
run: dotnet nuget push ${{ env.NUGET_PATH }}/*.nupkg -s "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NUGET_AUTH_TOKEN }} --skip-duplicate --no-symbols
7779

csharp/IotaWalletNet/IotaWalletNet.Application/Account.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ public async Task<MeltNativeTokensResponse> MeltNativeTokensAsync(string tokenId
8989
return await _mediator.Send(new MeltNativeTokensCommand(tokenId, meltAmountHexEncoded, Username, this));
9090
}
9191

92-
public async Task<BurnNativeTokensResponse> BurnNativeTokensAsync(string tokenId, string meltAmountHexEncoded)
92+
public async Task<BurnNativeTokensResponse> BurnNativeTokensAsync(string tokenId, string burnAmountHexEncoded)
9393
{
94-
return await _mediator.Send(new BurnNativeTokensCommand(tokenId, meltAmountHexEncoded, Username, this));
94+
return await _mediator.Send(new BurnNativeTokensCommand(tokenId, burnAmountHexEncoded, Username, this));
9595
}
9696
public async Task<SendNativeTokensResponse> SendNativeTokensAsync(List<AddressWithNativeTokens> addressWithNativeTokens)
9797
{

csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/BurnNativeTokens/BurnNativeTokensCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ namespace IotaWalletNet.Application.AccountContext.Commands.BurnNativeTokens
55
{
66
public class BurnNativeTokensCommand : IRequest<BurnNativeTokensResponse>
77
{
8-
public BurnNativeTokensCommand(string tokenId, string meltAmount, string username, IAccount account)
8+
public BurnNativeTokensCommand(string tokenId, string burnAmount, string username, IAccount account)
99
{
1010
TokenId = tokenId;
11-
MeltAmount = meltAmount;
11+
BurnAmount = burnAmount;
1212
Username = username;
1313
Account = account;
1414
}
@@ -21,7 +21,7 @@ public BurnNativeTokensCommand(string tokenId, string meltAmount, string usernam
2121
/// <summary>
2222
/// [HexEncodedAmount] To be melted amount.
2323
/// </summary>
24-
public string MeltAmount { get; set; }
24+
public string BurnAmount { get; set; }
2525

2626

2727
public string Username { get; set; }

csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/BurnNativeTokens/BurnNativeTokensCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class BurnNativeTokensCommandHandler : IRequestHandler<BurnNativeTokensCo
99
{
1010
public async Task<BurnNativeTokensResponse> Handle(BurnNativeTokensCommand request, CancellationToken cancellationToken)
1111
{
12-
BurnNativeTokensCommandMessageData messageData = new BurnNativeTokensCommandMessageData(request.TokenId, request.MeltAmount, new TransactionOptions());
12+
BurnNativeTokensCommandMessageData messageData = new BurnNativeTokensCommandMessageData(request.TokenId, request.BurnAmount, new TransactionOptions());
1313

1414
BurnNativeTokensCommandMessage message = new BurnNativeTokensCommandMessage(request.Username, messageData);
1515

csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/BurnNativeTokens/BurnNativeTokensCommandMessageData.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ namespace IotaWalletNet.Application.AccountContext.Commands.BurnNativeTokens
44
{
55
public class BurnNativeTokensCommandMessageData
66
{
7-
public BurnNativeTokensCommandMessageData(string tokenId, string meltAmount, TransactionOptions options)
7+
public BurnNativeTokensCommandMessageData(string tokenId, string burnAmount, TransactionOptions options)
88
{
99
TokenId = tokenId;
10-
MeltAmount = meltAmount;
10+
BurnAmount = burnAmount;
1111
Options = options;
1212
}
1313

@@ -17,9 +17,9 @@ public BurnNativeTokensCommandMessageData(string tokenId, string meltAmount, Tra
1717
public string TokenId { get; set; }
1818

1919
/// <summary>
20-
/// [HexEncodedAmount] To be melted amount.
20+
/// [HexEncodedAmount] To be burned amount.
2121
/// </summary>
22-
public string MeltAmount { get; set; }
22+
public string BurnAmount { get; set; }
2323

2424
/// <summary>
2525
/// The options to define a `RemainderValueStrategy` or custom inputs.

csharp/IotaWalletNet/IotaWalletNet.Application/Common/Interfaces/IAccount.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public interface IAccount : IRustBridgeCommunicator
6161
Task<SendNativeTokensResponse> SendNativeTokensAsync(List<AddressWithNativeTokens> addressWithNativeTokens);
6262
Task<CreateAliasOutputResponse> CreateAliasOutputAsync(AliasOutputOptions aliasOutputOptions);
6363
Task<MeltNativeTokensResponse> MeltNativeTokensAsync(string tokenId, string meltAmountHexEncoded);
64-
Task<BurnNativeTokensResponse> BurnNativeTokensAsync(string tokenId, string meltAmountHexEncoded);
64+
Task<BurnNativeTokensResponse> BurnNativeTokensAsync(string tokenId, string burnAmountHexEncoded);
6565
Task<SendAmountResponse> SendAmountAsync(List<AddressWithAmount> addressesWithAmounts, TaggedDataPayload? taggedDataPayload = null);
6666
Task<ConsolidateOutputsResponse> ConsolidateOutputsAsync(bool force, int? outputsConsolidationThreshold = null);
6767
Task<GetFoundryOutputResponse> GetFoundryOutputAsync(string tokenId);
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
namespace IotaWalletNet.Domain.Common.Extensions
2+
{
3+
public static class NumberExtensions
4+
{
5+
public static string ToHexEncodedAmount(this Int64 input)
6+
{
7+
return $"0x{Convert.ToHexString(BitConverter.GetBytes(input).Reverse().ToArray())}";
8+
}
9+
10+
public static string ToHexEncodedAmount(this UInt64 input)
11+
{
12+
return $"0x{Convert.ToHexString(BitConverter.GetBytes(input).Reverse().ToArray())}";
13+
}
14+
public static string ToHexEncodedAmount(this UInt32 input)
15+
{
16+
return $"0x{Convert.ToHexString(BitConverter.GetBytes(input).Reverse().ToArray())}";
17+
}
18+
19+
public static string ToHexEncodedAmount(this Int32 input)
20+
{
21+
return $"0x{Convert.ToHexString(BitConverter.GetBytes(input).Reverse().ToArray())}";
22+
}
23+
24+
private static string PreprocessHexEncodedAmountString(string hexEncodedAmount)
25+
{
26+
if (hexEncodedAmount.ToLower().StartsWith("0x"))
27+
hexEncodedAmount = hexEncodedAmount.Substring(2);
28+
29+
if(hexEncodedAmount.Length % 2 != 0)
30+
hexEncodedAmount = "0" + hexEncodedAmount;
31+
32+
return hexEncodedAmount;
33+
return new string(hexEncodedAmount.AsEnumerable().Reverse().ToArray());
34+
}
35+
36+
/// <summary>
37+
/// This is to be used after PreprocessHexEncodedAmountString
38+
/// </summary>
39+
private static string PadFor64Bits(string hexEncodedAmount)
40+
{
41+
const int REQUIRED_PADDINGS = 16;
42+
hexEncodedAmount = hexEncodedAmount.PadLeft(REQUIRED_PADDINGS, '0');
43+
return hexEncodedAmount;
44+
}
45+
private static string PadFor32Bits(string hexEncodedAmount)
46+
{
47+
const int REQUIRED_PADDINGS = 8;
48+
hexEncodedAmount = hexEncodedAmount.PadLeft(REQUIRED_PADDINGS, '0');
49+
return hexEncodedAmount;
50+
}
51+
52+
public static Int64 FromHexEncodedAmountToInt64(this string hexEncodedAmount)
53+
{
54+
hexEncodedAmount = PreprocessHexEncodedAmountString(hexEncodedAmount);
55+
56+
return Int64.Parse(hexEncodedAmount, System.Globalization.NumberStyles.HexNumber);
57+
}
58+
59+
public static UInt64 FromHexEncodedAmountToUInt64(this string hexEncodedAmount)
60+
{
61+
hexEncodedAmount = PreprocessHexEncodedAmountString(hexEncodedAmount);
62+
63+
return UInt64.Parse(hexEncodedAmount, System.Globalization.NumberStyles.HexNumber);
64+
}
65+
66+
public static Int32 FromHexEncodedAmountToInt32(this string hexEncodedAmount)
67+
{
68+
hexEncodedAmount = PreprocessHexEncodedAmountString(hexEncodedAmount);
69+
70+
71+
return Int32.Parse(hexEncodedAmount, System.Globalization.NumberStyles.HexNumber);
72+
}
73+
74+
public static UInt32 FromHexEncodedAmountToUInt32(this string hexEncodedAmount)
75+
{
76+
hexEncodedAmount = PreprocessHexEncodedAmountString(hexEncodedAmount);
77+
78+
79+
return UInt32.Parse(hexEncodedAmount, System.Globalization.NumberStyles.HexNumber);
80+
}
81+
}
82+
}

csharp/IotaWalletNet/IotaWalletNet.Domain/Common/Extensions/StringExtensions.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@ public static class StringExtensions
99

1010
public static bool IsNotNullAndEmpty(this string? input) => !input.IsNullOrEmpty();
1111

12-
public static string ToHexString(this string input) => "0x" + Convert.ToHexString(Encoding.UTF8.GetBytes(input));
12+
public static string ToHexString(this string input)
13+
=> "0x" + Convert.ToHexString(Encoding.UTF8.GetBytes(input));
14+
1315

1416
public static string FromHexString(this string hexString)
1517
{
16-
hexString = hexString.Substring(2); // remove the 0x of a hexstring eg 0x1337
18+
if(hexString.ToLower().StartsWith("0x"))
19+
hexString = hexString.Substring(2); // remove the 0x of a hexstring eg 0x1337
20+
21+
// eg 0x0 becomes 0 then becomes 00, to be able to use fromhexstring, we need length of hexstring to be % 2
22+
if (hexString.Length % 2 != 0)
23+
hexString = $"0{hexString}";
1724

1825
byte[] utf8StringBytes = Convert.FromHexString(hexString);
1926

0 commit comments

Comments
 (0)