SubstrateGaming / Substrate.NET.API

Substrate .NET API Core for substrate-based nodes
https://github.com/SubstrateGaming
GNU General Public License v3.0
24 stars 19 forks source link

`tokenDecimals` is causing errors when connecting to certain parachains #76

Open RostislavLitovkin opened 7 months ago

RostislavLitovkin commented 7 months ago
Newtonsoft.Json.JsonSerializationException: Deserializing JSON-RPC result to type Properties failed with JsonReaderException: Error reading integer. Unexpected token: StartArray. Path 'result.tokenDecimals'.
 ---> Newtonsoft.Json.JsonReaderException: Error reading integer. Unexpected token: StartArray. Path 'result.tokenDecimals'.
   at Newtonsoft.Json.JsonReader.ReadAsInt32()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.Linq.JToken.ToObject[T](JsonSerializer jsonSerializer)
   at StreamJsonRpc.JsonMessageFormatter.JsonRpcResult.GetResult[T]()
   --- End of inner exception stack trace ---
   at StreamJsonRpc.JsonMessageFormatter.JsonRpcResult.GetResult[T]()
   at StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](RequestId id, String targetName, IReadOnlyList`1 arguments, IReadOnlyList`1 positionalArgumentDeclaredTypes, IReadOnlyDictionary`2 namedArgumentDeclaredTypes, CancellationToken cancellationToken, Boolean isParameterObject)
   at Substrate.NetApi.SubstrateClient.InvokeAsync[T](String method, Object parameters, CancellationToken token)
   at Substrate.NetApi.Modules.System.PropertiesAsync(CancellationToken token)
   at Substrate.NetApi.SubstrateClient.ConnectAsync(Boolean useMetaData, Boolean standardSubstrate, CancellationToken token)
   at Substrate.NetApi.SubstrateClient.ConnectAsync(Boolean useMetaData, CancellationToken token)
   at Substrate.NetApi.SubstrateClient.ConnectAsync()
   at PlutoWallet.Model.AjunaExt.SubstrateClientExt.ConnectAsync() in /Users/rostislavlitovkin/Programming/PlutoWallet/PlutoWallet.Model/AjunaExt/SubstrateClientExt.cs:line 83
   at PlutoWalletTests.AssetsTests.Setup() in /Users/rostislavlitovkin/Programming/PlutoWallet/PlutoWalletTests/AssetsTests.cs:line 27

I am getting the following error when Connecting to Bifrost wss://bifrost-polkadot.api.onfinality.io/public-ws rpc:

try
{
    var endpoint = PlutoWallet.Constants.Endpoints.GetEndpointDictionary["bifrost"];

    //string bestWebSecket = await WebSocketModel.GetFastestWebSocketAsync(endpoint.URLs);

    client = new SubstrateClientExt(
        endpoint, // This is my modification, can be ignored
        new Uri("wss://bifrost-polkadot.api.onfinality.io/public-ws"),
        Substrate.NetApi.Model.Extrinsics.ChargeTransactionPayment.Default());

    await client.ConnectAsync();
}
catch (Exception ex)
{
    // Prints the error written at the top
    Console.WriteLine(ex);
}
darkfriend77 commented 7 months ago

{"jsonrpc":"2.0","result":{"ss58Format":6,"tokenDecimals":[12],"tokenSymbol":["BNC"]},"id":1}

{"jsonrpc": "2.0", "result": {"ss58Format": 1337,"tokenDecimals": 12,"tokenSymbol": "BAJU"},"id": 1}

Might need to move it to a object, instead of a typed return value.