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

Fix sub-account universal transfer history serialization error #1273

Merged

Conversation

wurdum
Copy link
Contributor

@wurdum wurdum commented Jul 10, 2023

We were testing universal transfer from SPOT Master Account to MARGIN Sub Account and querying results through the following APIs:

After successfully executing transfer using .GeneralApi.SubAccount.TranferSubAccountAsync, calling .GeneralApi.SubAccount.GetUniversalTransferHistoryAsync throws the following exception:

Deserialize Unknown Exception: InvalidOperationException - Sequence contains no matching element 
    at System.Linq.ThrowHelper.ThrowNoMatchException() 
    at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate) 
    at Binance.Net.Converters.BrokerageAccountTypeConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) 
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) 
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) 
    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.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id) 
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) 
    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.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) 
    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.JsonSerializer.Deserialize[T](JsonReader reader) 
    at CryptoExchange.Net.BaseApiClient.DeserializeAsync[T](Stream stream, JsonSerializer serializer, Nullable`1 requestId, Nullable`1 elapsedMilliseconds) 

It looks like tests for GetUniversalTransferHistoryAsync were broken. After fixing them, I was able to identify and fix the error: TranferSubAccountAsync uses TransferAccountType for FromAccountType/ToAccountType, but GetUniversalTransferHistoryAsync returns BrokerageAccountType, which later blows the converter.

@JKorf
Copy link
Owner

JKorf commented Jul 11, 2023

Thanks for the PR!

@JKorf JKorf merged commit 70426d7 into JKorf:master Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants