Open
Description
Here is the following metadata for SponsorshipState.Confirmed
and SponsorshipState.Unconfirmed
:
The underlying tuple has got 1 element of type AccountId. The Substrate.Net.Toolchain generated me the following code, which is different than what is in the real metadata.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Substrate.NetApi.Model.Types.Base;
using System.Collections.Generic;
namespace Unique.NetApi.Generated.Model.up_data_structs
{
/// <summary>
/// >> SponsorshipState
/// </summary>
public enum SponsorshipState
{
/// <summary>
/// >> Disabled
/// </summary>
Disabled = 0,
/// <summary>
/// >> Unconfirmed
/// </summary>
Unconfirmed = 1,
/// <summary>
/// >> Confirmed
/// </summary>
Confirmed = 2,
}
/// <summary>
/// >> 646 - Variant[up_data_structs.SponsorshipState]
/// </summary>
public sealed class EnumSponsorshipState : BaseEnumRust<SponsorshipState>
{
/// <summary>
/// Initializes a new instance of the class.
/// </summary>
public EnumSponsorshipState()
{
AddTypeDecoder<BaseVoid>(SponsorshipState.Disabled);
AddTypeDecoder<Unique.NetApi.Generated.Model.pallet_evm.account.EnumBasicCrossAccountIdRepr>(SponsorshipState.Unconfirmed);
AddTypeDecoder<Unique.NetApi.Generated.Model.pallet_evm.account.EnumBasicCrossAccountIdRepr>(SponsorshipState.Confirmed);
}
}
}
The last 2 lines are wrong:
AddTypeDecoder<Unique.NetApi.Generated.Model.pallet_evm.account.EnumBasicCrossAccountIdRepr>(SponsorshipState.Unconfirmed);
AddTypeDecoder<Unique.NetApi.Generated.Model.pallet_evm.account.EnumBasicCrossAccountIdRepr>(SponsorshipState.Confirmed);
and should be:
AddTypeDecoder<AccountId>(SponsorshipState.Unconfirmed);
AddTypeDecoder<AccountId>(SponsorshipState.Confirmed);
When I try to decode the Collection
type (which uses this enum), it fails and throws an exception.
I think this bug can occur on other chains as well.