Skip to content

Commit

Permalink
#74 providing base to allow proper view on parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfriend77 committed Jan 31, 2024
1 parent b4951b4 commit 07e2deb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
28 changes: 23 additions & 5 deletions Substrate.NetApi/Model/Extrinsics/Method.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Substrate.NetApi.Model.Types;

namespace Substrate.NetApi.Model.Extrinsics
{
Expand Down Expand Up @@ -28,10 +29,15 @@ public class Method
/// </summary>
public byte CallIndex { get; set; }

/// <summary>
/// Parameters unencoded
/// </summary>
public IEncodable Parameters { get; set; }

/// <summary>
/// Parameters
/// </summary>
public byte[] Parameters { get; set; }
public byte[] ParametersBytes { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="Method"/> class.
Expand All @@ -43,7 +49,7 @@ public Method(byte moduleIndex, byte callIndex, byte[] parameters)
{
ModuleIndex = moduleIndex;
CallIndex = callIndex;
Parameters = parameters ?? new byte[0];
ParametersBytes = parameters ?? new byte[0];
}

/// <summary>
Expand All @@ -55,7 +61,7 @@ public Method(byte moduleIndex, byte callIndex)
{
ModuleIndex = moduleIndex;
CallIndex = callIndex;
Parameters = new byte[0];
ParametersBytes = new byte[0];
}

/// <summary>
Expand All @@ -72,9 +78,21 @@ public Method(byte moduleIndex, string moduleName, byte callIndex, string callNa
ModuleIndex = moduleIndex;
CallName = callName;
CallIndex = callIndex;
Parameters = parameters;
ParametersBytes = parameters;
}

/// <summary>
/// Initializes a new instance of the <see cref="Method"/> class.
/// </summary>
/// <param name="moduleIndex"></param>
/// <param name="moduleName"></param>
/// <param name="callIndex"></param>
/// <param name="callName"></param>
/// <param name="parameters"></param>
public Method(byte moduleIndex, string moduleName, byte callIndex, string callName, IEncodable parameters)
: this(moduleIndex, moduleName, callIndex, callName, parameters.Encode())
{ }

/// <summary>
/// Encodes this instance.
/// </summary>
Expand All @@ -84,7 +102,7 @@ public byte[] Encode()
var result = new List<byte>();
result.Add(ModuleIndex);
result.Add(CallIndex);
result.AddRange(Parameters);
result.AddRange(ParametersBytes);
return result.ToArray();
}

Expand Down
2 changes: 1 addition & 1 deletion Substrate.NetApi/Substrate.NetApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<PackageId>Substrate.NET.API</PackageId>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0</TargetFrameworks>
<Version>0.9.16</Version>
<Version>0.9.17</Version>
<Company>Substrate Gaming</Company>
<Authors>Substrate Gaming</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down

0 comments on commit 07e2deb

Please sign in to comment.