Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[net]chore(deps): switch to Substrate.DotNet producing code compatible with Substrate.NET.API 0.9.23 #649

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion net/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.11.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
<PackageVersion Include="PolySharp" Version="1.14.1" />
<PackageVersion Include="Substrate.NET.API" Version="0.9.24-rc8" />
<PackageVersion Include="Substrate.NET.API" Version="0.9.23" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.Threading.Channels" Version="8.0.0" />
<!-- For Tests -->
Expand Down
1 change: 0 additions & 1 deletion net/rs/client-gen/src/type_generators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ impl<'a> StructDefGenerator<'a> {
let generic_list = &csharp::import("global::System.Collections.Generic", "List");

quote! {
[global::Substrate.NetApi.Attributes.SubstrateNodeType(global::Substrate.NetApi.Model.Types.Metadata.Base.TypeDefEnum.Composite)]
public sealed partial class $(self.type_name) : global::Substrate.NetApi.Model.Types.Base.BaseType
{
$(self.props_tokens)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ICall<global::Substrate.NetApi.Model.Types.Primitive.U8> DoThat(global::Substrat
/// <inheritdoc/>
public ICall<global::Substrate.NetApi.Model.Types.Primitive.U8> DoThat(global::Substrate.NetApi.Model.Types.Base.BaseTuple<global::Substrate.NetApi.Model.Types.Primitive.U8, global::Substrate.NetApi.Model.Types.Primitive.U32> p1) { return new RemotingAction<global::Substrate.NetApi.Model.Types.Primitive.U8>( this.remoting, [20, 66, 97, 115, 105, 99, 24, 68, 111, 84, 104, 97, 116], new global::Substrate.NetApi.Model.Types.Base.BaseTupleRust(p1) ); } }

[global::Substrate.NetApi.Attributes.SubstrateNodeType(global::Substrate.NetApi.Model.Types.Metadata.Base.TypeDefEnum.Composite)] public sealed partial class MyParam : global::Substrate.NetApi.Model.Types.Base.BaseType {
public sealed partial class MyParam : global::Substrate.NetApi.Model.Types.Base.BaseType {
[System.Diagnostics.CodeAnalysis.AllowNull]
public global::Substrate.NetApi.Model.Types.Primitive.U32 F1 { get; set; }
[System.Diagnostics.CodeAnalysis.AllowNull]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ this.AddTypeDecoder<global::Substrate.NetApi.Model.Types.Base.BaseVoid>(ServiceW

public async global::System.Collections.Generic.IAsyncEnumerable<EnumServiceWithEventsEvents> ListenAsync([global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) { await foreach (var bytes in this.remoting.ListenAsync(cancellationToken)) { byte idx = 0; foreach (var route in EventRoutes) { if (route.Length > bytes.Length) { continue; } if (route.AsSpan().SequenceEqual(bytes.AsSpan()[..route.Length])) { var bytesLength = bytes.Length - route.Length + 1; var data = new byte[bytesLength]; data[0] = idx; Buffer.BlockCopy(bytes, route.Length, data, 1, bytes.Length - route.Length); var p = 0; EnumServiceWithEventsEvents ev = new(); ev.Decode(bytes, ref p); yield return ev; } idx++; } } } }

[global::Substrate.NetApi.Attributes.SubstrateNodeType(global::Substrate.NetApi.Model.Types.Metadata.Base.TypeDefEnum.Composite)] public sealed partial class MyParam : global::Substrate.NetApi.Model.Types.Base.BaseType {
public sealed partial class MyParam : global::Substrate.NetApi.Model.Types.Base.BaseType {
[System.Diagnostics.CodeAnalysis.AllowNull]
public global::Substrate.Gear.Client.Model.Types.Primitive.NonZeroU256 F1 { get; set; }
[System.Diagnostics.CodeAnalysis.AllowNull]
Expand Down
4 changes: 2 additions & 2 deletions net/rs/client-gen/tests/snapshots/generator__full.snap
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ this.AddTypeDecoder<global::Substrate.NetApi.Model.Types.Primitive.Str>(ServiceE
/// <summary>
/// ThisThatSvcAppTupleStruct docs
/// </summary>
[global::Substrate.NetApi.Attributes.SubstrateNodeType(global::Substrate.NetApi.Model.Types.Metadata.Base.TypeDefEnum.Composite)] public sealed partial class ThisThatSvcAppTupleStruct : global::Substrate.NetApi.Model.Types.Base.BaseType { [System.Diagnostics.CodeAnalysis.AllowNull]
public sealed partial class ThisThatSvcAppTupleStruct : global::Substrate.NetApi.Model.Types.Base.BaseType { [System.Diagnostics.CodeAnalysis.AllowNull]
public global::Substrate.NetApi.Model.Types.Primitive.Bool Value { get; set; }
/// <inheritdoc/>
public override string TypeName() => "ThisThatSvcAppTupleStruct";
Expand All @@ -95,7 +95,7 @@ this.AddTypeDecoder<global::Substrate.NetApi.Model.Types.Primitive.Str>(ServiceE
/// <summary>
/// ThisThatSvcAppDoThatParam docs
/// </summary>
[global::Substrate.NetApi.Attributes.SubstrateNodeType(global::Substrate.NetApi.Model.Types.Metadata.Base.TypeDefEnum.Composite)] public sealed partial class ThisThatSvcAppDoThatParam : global::Substrate.NetApi.Model.Types.Base.BaseType {
public sealed partial class ThisThatSvcAppDoThatParam : global::Substrate.NetApi.Model.Types.Base.BaseType {
/// <summary>
/// field `query`
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface INonZeroParams
/// <inheritdoc/>
public ICall<global::Substrate.Gear.Client.Model.Types.Primitive.NonZeroU64> DoThis(global::Substrate.Gear.Client.Model.Types.Primitive.NonZeroU256 p1, MyParam p2) { return new RemotingAction<global::Substrate.Gear.Client.Model.Types.Primitive.NonZeroU64>( this.remoting, [52, 78, 111, 110, 90, 101, 114, 111, 80, 97, 114, 97, 109, 115, 24, 68, 111, 84, 104, 105, 115], new global::Substrate.NetApi.Model.Types.Base.BaseTupleRust(p1, p2) ); } }

[global::Substrate.NetApi.Attributes.SubstrateNodeType(global::Substrate.NetApi.Model.Types.Metadata.Base.TypeDefEnum.Composite)] public sealed partial class MyParam : global::Substrate.NetApi.Model.Types.Base.BaseType {
public sealed partial class MyParam : global::Substrate.NetApi.Model.Types.Base.BaseType {
[System.Diagnostics.CodeAnalysis.AllowNull]
public global::Substrate.Gear.Client.Model.Types.Primitive.NonZeroU256 F1 { get; set; }
[System.Diagnostics.CodeAnalysis.AllowNull]
Expand Down
4 changes: 2 additions & 2 deletions net/rs/client-gen/tests/snapshots/generator__rmrk_works.snap
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public enum Part { Fixed,
this.AddTypeDecoder<SlotPart>(Part.Slot);
} }

[global::Substrate.NetApi.Attributes.SubstrateNodeType(global::Substrate.NetApi.Model.Types.Metadata.Base.TypeDefEnum.Composite)] public sealed partial class FixedPart : global::Substrate.NetApi.Model.Types.Base.BaseType {
public sealed partial class FixedPart : global::Substrate.NetApi.Model.Types.Base.BaseType {
/// <summary>
/// An optional zIndex of base part layer.
/// specifies the stack order of an element.
Expand All @@ -111,7 +111,7 @@ this.MetadataUri = new global::Substrate.NetApi.Model.Types.Primitive.Str();
this.MetadataUri.Decode(byteArray, ref p);
var bytesLength = p - start; this.TypeSize = bytesLength; this.Bytes = new byte[bytesLength]; Array.Copy(byteArray, start, this.Bytes, 0, bytesLength); } }

[global::Substrate.NetApi.Attributes.SubstrateNodeType(global::Substrate.NetApi.Model.Types.Metadata.Base.TypeDefEnum.Composite)] public sealed partial class SlotPart : global::Substrate.NetApi.Model.Types.Base.BaseType {
public sealed partial class SlotPart : global::Substrate.NetApi.Model.Types.Base.BaseType {
/// <summary>
/// Array of whitelisted collections that can be equipped in the given slot. Used with slot parts only.
/// </summary>
Expand Down
10 changes: 5 additions & 5 deletions net/src/Sails.Remoting/Core/RemotingReplyViaNodeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ public static async Task<RemotingReplyViaNodeClient<T>> FromExecutionAsync(
var queuedMessageData = extrinsicBlockEvents
.Where(
eventRecord =>
eventRecord.Phase.Matches(
eventRecord.Phase.ToBaseEnumRust().Matches(
Phase.ApplyExtrinsic,
(U32 extrinsicIdxInBlock) => extrinsicIdxInBlock.Value == extrinsicInfo.IndexInBlock))
.Select(
eventRecord => eventRecord.Event)
eventRecord => eventRecord.Event.ToBaseEnumRust())
.SelectIfMatches(
RuntimeEvent.Gear,
(EnumGearEvent gearEvent) => gearEvent)
(EnumGearEvent gearEvent) => gearEvent.ToBaseEnumRust())
.SelectIfMatches(
GearEvent.MessageQueued,
(MessageQueuedEventData data) => data)
Expand Down Expand Up @@ -133,10 +133,10 @@ await this.nodeClient.ListBlockEventsAsync(blockHeader.GetBlockHash(), cancellat
.SelectMany(
eventRecords => eventRecords.AsAsyncEnumerable())
.Select(
eventRecord => eventRecord.Event)
eventRecord => eventRecord.Event.ToBaseEnumRust())
.SelectIfMatches(
RuntimeEvent.Gear,
(EnumGearEvent gearEvent) => gearEvent)
(EnumGearEvent gearEvent) => gearEvent.ToBaseEnumRust())
.SelectIfMatches(
GearEvent.UserMessageSent,
(UserMessageSentEventData data) => (UserMessage)data.Value[0])
Expand Down
Loading