-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* release candidate 1 * added CheckMetadataHash added metadata v15 added runtime calls metadata * added interface and simple metadata call * added test * fixed tests, and directed to polkadot
- Loading branch information
1 parent
3448b93
commit 1974420
Showing
39 changed files
with
1,365 additions
and
556 deletions.
There are no files selected for viewing
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
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,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection.Metadata; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Newtonsoft.Json.Linq; | ||
using NUnit.Framework; | ||
using StreamJsonRpc; | ||
using Substrate.NetApi.Model.Rpc; | ||
using Substrate.NetApi.Model.Types.Base; | ||
using Substrate.NetApi.Model.Types.Primitive; | ||
|
||
namespace Substrate.NetApi.TestNode | ||
{ | ||
public class ModuleChainTest : NodeTest | ||
{ | ||
[Test] | ||
public async Task GetBlockAsyncTestAsync() | ||
{ | ||
var result = await _substrateClient.Chain.GetBlockAsync(CancellationToken.None); | ||
|
||
Assert.IsNotNull(result); | ||
} | ||
|
||
|
||
} | ||
} |
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
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,47 @@ | ||
using NUnit.Framework; | ||
using Substrate.NetApi.Model.Types.Metadata; | ||
using Substrate.NetApi.Model.Types.Metadata.V14; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using System.Linq; | ||
using Substrate.NetApi.Model.Types.Base; | ||
using Substrate.NetApi.Model.Types.Primitive; | ||
|
||
namespace Substrate.NetApi.TestNode | ||
{ | ||
public class ModuleRuntimeCallTest : NodeTest | ||
{ | ||
[Test] | ||
public async Task GetMetadataTestAsync() | ||
{ | ||
var result14 = await _substrateClient.RuntimeCall.MetadataAsync(CancellationToken.None); | ||
var mdv14 = new RuntimeMetadata<RuntimeMetadataV14>(); | ||
mdv14.Create(result14.Value.Select(p => p.Value).ToArray()); | ||
Assert.IsNotNull(mdv14); | ||
} | ||
|
||
[Test] | ||
public async Task GetMetadataAtVersionTestAsync() | ||
{ | ||
var result14 = await _substrateClient.RuntimeCall.MetadataAtVersionAsync(14, CancellationToken.None); | ||
var mdv14 = new RuntimeMetadata<RuntimeMetadataV14>(); | ||
mdv14.Create(result14.Value.Value.Select(p => p.Value).ToArray()); | ||
Assert.IsNotNull(mdv14); | ||
|
||
var result15 = await _substrateClient.RuntimeCall.MetadataAtVersionAsync(15, CancellationToken.None); | ||
var mdv15 = new RuntimeMetadata<RuntimeMetadataV15>(); | ||
mdv15.Create(result15.Value.Value.Select(p => p.Value).ToArray()); | ||
Assert.IsNotNull(mdv15); | ||
} | ||
|
||
[Test] | ||
public async Task GetMetadataVersionsTestAsync() | ||
{ | ||
var result = await _substrateClient.RuntimeCall.MetadataVersionsAsync(CancellationToken.None); | ||
|
||
Assert.IsNotNull(result); | ||
Assert.AreEqual(14, result.Value[0].Value); | ||
Assert.AreEqual(15, result.Value[1].Value); | ||
} | ||
} | ||
} |
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
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
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
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
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
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,12 @@ | ||
using Substrate.NetApi.Model.Types.Base; | ||
using Substrate.NetApi.Model.Types.Primitive; | ||
|
||
namespace Substrate.NetApi.Model.Types.Metadata.Base | ||
{ | ||
/// <summary> | ||
/// Byte Getter | ||
/// </summary> | ||
public class ByteGetter : BaseVec<U8> | ||
{ | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Substrate.NetApi/Model/Types/Metadata/Base/ErrorMetadata.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,34 @@ | ||
using Substrate.NetApi.Model.Types.Base; | ||
using Substrate.NetApi.Model.Types.Metadata.Base; | ||
using System; | ||
|
||
namespace Substrate.NetApi.Model.Types.Metadata.V14 | ||
{ | ||
/// <summary> | ||
/// Error Metadata | ||
/// </summary> | ||
public class ErrorMetadata : BaseType | ||
{ | ||
/// <inheritdoc/> | ||
public override byte[] Encode() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override void Decode(byte[] byteArray, ref int p) | ||
{ | ||
var start = p; | ||
|
||
ErrorType = new TType(); | ||
ErrorType.Decode(byteArray, ref p); | ||
|
||
TypeSize = p - start; | ||
} | ||
|
||
/// <summary> | ||
/// Error Type | ||
/// </summary> | ||
public TType ErrorType { get; private set; } | ||
} | ||
} |
5 changes: 3 additions & 2 deletions
5
....NetApi/Model/Types/Metadata/V14/Field.cs → ...NetApi/Model/Types/Metadata/Base/Field.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
46 changes: 46 additions & 0 deletions
46
Substrate.NetApi/Model/Types/Metadata/Base/MetaDataInfo.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,46 @@ | ||
using Substrate.NetApi.Model.Types.Base; | ||
using Substrate.NetApi.Model.Types.Primitive; | ||
using System; | ||
|
||
namespace Substrate.NetApi.Model.Types.Metadata.Base | ||
{ | ||
/// <summary> | ||
/// Meta Data Info Type | ||
/// </summary> | ||
public class MetaDataInfo : BaseType | ||
{ | ||
/// <inheritdoc/> | ||
public override byte[] Encode() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
/// <summary> | ||
/// Decode from byte array | ||
/// </summary> | ||
/// <param name="byteArray"></param> | ||
/// <param name="p"></param> | ||
public override void Decode(byte[] byteArray, ref int p) | ||
{ | ||
var start = p; | ||
|
||
Magic = new U32(); | ||
Magic.Decode(byteArray, ref p); | ||
|
||
Version = new U8(); | ||
Version.Decode(byteArray, ref p); | ||
|
||
TypeSize = p - start; | ||
} | ||
|
||
/// <summary> | ||
/// Magic | ||
/// </summary> | ||
public U32 Magic { get; private set; } | ||
|
||
/// <summary> | ||
/// Version | ||
/// </summary> | ||
public U8 Version { get; private set; } | ||
} | ||
} |
Oops, something went wrong.