-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from SubstrateGaming/feature/v15_metadata
Update Metadata V15
- Loading branch information
Showing
9 changed files
with
213 additions
and
20 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
1 change: 1 addition & 0 deletions
1
Substrate.NET.Metadata.Tests/Mocks/V15/MetadataV15_FromPolkadotJs.txt
Large diffs are not rendered by default.
Oops, something went wrong.
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,61 @@ | ||
using Microsoft.VisualBasic; | ||
using Newtonsoft.Json.Linq; | ||
using Substrate.NET.Metadata.Base; | ||
using Substrate.NetApi.Model.Types.Base; | ||
using Substrate.NetApi.Model.Types.Primitive; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Substrate.NET.Metadata.V15 | ||
{ | ||
public class CustomMetadata15 : BaseType | ||
{ | ||
public BaseVec<BaseTuple<Str, CustomValueMetadata15>> Map { get; private set; } = default!; | ||
|
||
public override void Decode(byte[] byteArray, ref int p) | ||
{ | ||
var start = p; | ||
Map = new BaseVec<BaseTuple<Str, CustomValueMetadata15>>(); | ||
|
||
Map.Decode(byteArray, ref p); | ||
var bytesLength = p - start; | ||
TypeSize = bytesLength; | ||
Bytes = new byte[bytesLength]; | ||
Array.Copy(byteArray, start, Bytes, 0, bytesLength); | ||
} | ||
|
||
public override byte[] Encode() | ||
{ | ||
var result = new List<byte>(); | ||
result.AddRange(Map.Encode()); | ||
return result.ToArray(); | ||
} | ||
} | ||
|
||
public class CustomValueMetadata15 : BaseType | ||
{ | ||
public TType CustomType { get; private set; } = default!; | ||
public BaseVec<U8> Value { get; private set; } = default!; | ||
|
||
public override byte[] Encode() | ||
{ | ||
var result = new List<byte>(); | ||
result.AddRange(CustomType.Encode()); | ||
result.AddRange(Value.Encode()); | ||
return result.ToArray(); | ||
} | ||
|
||
public override void Decode(byte[] byteArray, ref int p) | ||
{ | ||
CustomType = new TType(); | ||
CustomType.Decode(byteArray, ref p); | ||
|
||
Value = new BaseVec<U8>(); | ||
Value.Decode(byteArray, ref p); | ||
} | ||
} | ||
} |
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,59 @@ | ||
using Substrate.NET.Metadata.Base; | ||
using Substrate.NET.Metadata.V14; | ||
using Substrate.NetApi.Model.Types.Base; | ||
using Substrate.NetApi.Model.Types.Primitive; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Substrate.NET.Metadata.V15 | ||
{ | ||
public class ExtrinsicMetadataV15 : BaseType | ||
{ | ||
public override byte[] Encode() | ||
{ | ||
var result = new List<byte>(); | ||
result.AddRange(Version.Encode()); | ||
result.AddRange(AddressType.Encode()); | ||
result.AddRange(CallType.Encode()); | ||
result.AddRange(SignatureType.Encode()); | ||
result.AddRange(ExtraType.Encode()); | ||
result.AddRange(SignedExtensions.Encode()); | ||
return result.ToArray(); | ||
} | ||
|
||
public override void Decode(byte[] byteArray, ref int p) | ||
{ | ||
var start = p; | ||
|
||
Version = new U8(); | ||
Version.Decode(byteArray, ref p); | ||
|
||
AddressType = new TType(); | ||
AddressType.Decode(byteArray, ref p); | ||
|
||
CallType = new TType(); | ||
CallType.Decode(byteArray, ref p); | ||
|
||
SignatureType = new TType(); | ||
SignatureType.Decode(byteArray, ref p); | ||
|
||
ExtraType = new TType(); | ||
ExtraType.Decode(byteArray, ref p); | ||
|
||
SignedExtensions = new BaseVec<SignedExtensionMetadataV14>(); | ||
SignedExtensions.Decode(byteArray, ref p); | ||
|
||
TypeSize = p - start; | ||
} | ||
|
||
public U8 Version { get; private set; } = default!; | ||
public TType AddressType { get; private set; } = default!; | ||
public TType CallType { get; private set; } = default!; | ||
public TType SignatureType { get; private set; } = default!; | ||
public TType ExtraType { get; private set; } = default!; | ||
public BaseVec<SignedExtensionMetadataV14> SignedExtensions { get; private set; } = default!; | ||
} | ||
} |
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,44 @@ | ||
using Newtonsoft.Json.Linq; | ||
using Substrate.NET.Metadata.Base; | ||
using Substrate.NetApi.Model.Types.Base; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Substrate.NET.Metadata.V15 | ||
{ | ||
public class OuterEnums15 : BaseType | ||
{ | ||
public override byte[] Encode() | ||
{ | ||
var result = new List<byte>(); | ||
result.AddRange(CallType.Encode()); | ||
result.AddRange(EventType.Encode()); | ||
result.AddRange(ErrorType.Encode()); | ||
return result.ToArray(); | ||
} | ||
|
||
public override void Decode(byte[] byteArray, ref int p) | ||
{ | ||
CallType = new TType(); | ||
CallType.Decode(byteArray, ref p); | ||
|
||
EventType = new TType(); | ||
EventType.Decode(byteArray, ref p); | ||
|
||
ErrorType = new TType(); | ||
ErrorType.Decode(byteArray, ref p); | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return $"CallType: {CallType}, EventType: {EventType}, ErrorType: {ErrorType}"; | ||
} | ||
|
||
public TType CallType { get; private set; } = default!; | ||
public TType EventType { get; private set; } = default!; | ||
public TType ErrorType { get; private set; } = default!; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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