Skip to content

Commit

Permalink
Merge pull request #61 from RemarkableTools/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
axenteoctavian authored Jan 26, 2024
2 parents 09021bd + 3c4b26d commit 262aa13
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 25 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2023 Remarkable Tools
Copyright 2024 Remarkable Tools

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
25 changes: 12 additions & 13 deletions src/Mx.NET.SDK.Core/Domain/Abi/AbiDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,24 @@ private TypeValue GetTypeValue(string type)
if (Types.Keys.Contains(type))
{
var typeFromStruct = Types[type];
if (typeFromStruct.Type == "enum")
if (typeFromStruct.Type == "enum" || typeFromStruct.Type == "explicit-enum")
{
return TypeValue.EnumValue(typeFromStruct.Type,
typeFromStruct.Variants?
.ToList()
.Select(v => new VariantDefinition(v.Name, "", v.Discriminant, v.Fields?
.ToList()
.Select(f=> new FieldDefinition(f.Name, "", GetTypeValue(f.Type)))
.ToArray()))
.ToArray());
typeFromStruct.Variants?.ToList()
.Select(v => new VariantDefinition(v.Name,
"",
v.Discriminant,
v.Fields?.ToList()
.Select(f => new FieldDefinition(f.Name, "", GetTypeValue(f.Type)))
.ToArray()))
.ToArray());
}
else if (typeFromStruct.Type == "struct")
{
return TypeValue.StructValue(typeFromStruct.Type,
typeFromStruct.Fields?
.ToList()
.Select(f => new FieldDefinition(f.Name, "", GetTypeValue(f.Type)))
.ToArray());

typeFromStruct.Fields?.ToList()
.Select(f => new FieldDefinition(f.Name, "", GetTypeValue(f.Type)))
.ToArray());
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/Mx.NET.SDK.Core/Domain/Values/EnumValue.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Mx.NET.SDK.Core.Domain.Helper;
using System;
using System.Linq;

namespace Mx.NET.SDK.Core.Domain.Values
Expand All @@ -22,6 +21,11 @@ public override string ToString()
return Discriminant.ToString();
}

public T ToEnum<T>()
{
return JsonWrapper.Deserialize<T>(ToString());
}

public override T ToObject<T>()
{
return JsonWrapper.Deserialize<T>(ToJson());
Expand Down
6 changes: 5 additions & 1 deletion src/Mx.NET.SDK.Core/Domain/Values/TypeValue.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using System.Linq;

namespace Mx.NET.SDK.Core.Domain.Values
{
Expand Down Expand Up @@ -37,7 +38,10 @@ public TypeValue(string binaryType, string rustType, VariantDefinition[] variant
{
BinaryType = binaryType;
RustType = rustType;
_variantDefinitions = variantDefinitions;
if (variantDefinitions.All(v => v.Discriminant == default))
_variantDefinitions = variantDefinitions.Select((v, index) => new VariantDefinition(v.Name, v.Description, index, v.Fields)).ToArray();
else
_variantDefinitions = variantDefinitions;
}

public TypeValue(string binaryType, TypeValue innerType = null, int? length = null)
Expand Down
6 changes: 3 additions & 3 deletions src/Mx.NET.SDK.Core/Mx.NET.SDK.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
<RepositoryUrl>https://github.com/RemarkableTools/Mx.NET.SDK/tree/main/src/Mx.NET.SDK.Core</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<Company>Remarkable Tools</Company>
<Version>2.0.5</Version>
<Version>2.0.6</Version>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Title>RemarkableTools.Mx.Core</Title>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackAsTool>False</PackAsTool>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
<Copyright>Copyright © Remarkable Tools 2023</Copyright>
<Copyright>Copyright © Remarkable Tools 2024</Copyright>
<PackageIcon>RemarkableToolsPackage.jpg</PackageIcon>
<PackageReleaseNotes>SDK updates and improvements</PackageReleaseNotes>
</PropertyGroup>
Expand All @@ -44,7 +44,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Mx.NET.SDK.Wallet/Mx.NET.SDK.Wallet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<Title>RemarkableTools.Mx.Wallet</Title>
<Copyright>Copyright © Remarkable Tools 2023</Copyright>
<Copyright>Copyright © Remarkable Tools 2024</Copyright>
<PackageIcon>RemarkableToolsPackage.jpg</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReleaseNotes>SDK updates and improvements</PackageReleaseNotes>
Expand Down
4 changes: 2 additions & 2 deletions src/Mx.NET.SDK/Mx.NET.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PackAsTool>False</PackAsTool>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
<Copyright>Copyright © Remarkable Tools 2023</Copyright>
<Copyright>Copyright © Remarkable Tools 2024</Copyright>
<PackageIcon>RemarkableToolsPackage.jpg</PackageIcon>
<PackageReleaseNotes>SDK updates and improvements</PackageReleaseNotes>
</PropertyGroup>
Expand All @@ -45,7 +45,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions tests/MS Testing/MS Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.2.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 262aa13

Please sign in to comment.