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

APIV3 GetBlockTransactions throws JSON deserialization error. #110

Open
jamescarter-le opened this issue Jun 28, 2024 · 0 comments
Open

Comments

@jamescarter-le
Copy link

When using HTTP_TONCENTERAPIV3 and calling client.GetBlockTransactions the application can fail to deserialize the response:

Newtonsoft.Json.JsonSerializationException: Error converting value {null} to type 'System.Int64'. Path 'transactions[1].in_msg.created_lt', line 1, position 3792.
 ---> System.InvalidCastException: Null object cannot be converted to a value type.
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
   --- End of inner exception stack trace ---
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
   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.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.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
   at TonSdk.Client.HttpApiV3.GetTransactions(Address address, UInt32 limit, Nullable`1 lt, String hash, Nullable`1 to_lt, Nullable`1 archival)
   at TonSdk.Client.TonClient.GetTransactions(Address address, UInt32 limit, Nullable`1 lt, String hash, Nullable`1 to_lt, Nullable`1 archival)
   at Program.<Main>$(String[] args) in C:\Scratch\TonTestSdk\Program.cs:line 44

Here is the response from TonCenter:
toncenter.com/api/v3/transactions?account=EQDNDaIHcH22lEqZgVritZNp860-KCzGf-s1hWMADf8ky1YS&offset=0&limit=10&sort=desc&start_lt=47392202000001

{
 "transactions": [
     {
         "account": "0:CD0DA207707DB6944A99815AE2B59369F3AD3E282CC67FEB358563000DFF24CB",
         "hash": "jhhKK/c3DQr+zNz3iETF450uZfwgznxHyv2UcnlLnTc=",
         "lt": "47392202000021",
         "now": 1719582529,
         "orig_status": "active",
         "end_status": "active",
         "total_fees": "396400",
         "prev_trans_hash": "vV3YFlqAdL/1o1dpwawqFuLgXjfP34O1YtJaTmV1AN0=",
         "prev_trans_lt": "47392202000001",
         "description": {
             "type": "ord",
             "action": {
                 "valid": true,
                 "success": true,
                 "no_funds": false,
                 "result_code": 0,
                 "tot_actions": 0,
                 "msgs_created": 0,
                 "spec_actions": 0,
                 "tot_msg_size": {
                     "bits": "0",
                     "cells": "0"
                 },
                 "status_change": "unchanged",
                 "skipped_actions": 0,
                 "action_list_hash": "lqKW0iTyhcZ77pPDD4owkVfw2qNdxbh+QQt4YwoJz8c="
             },
             "aborted": false,
             "credit_ph": {
                 "credit": "4618000"
             },
             "destroyed": false,
             "compute_ph": {
                 "mode": 0,
                 "type": "vm",
                 "success": true,
                 "gas_fees": "396400",
                 "gas_used": "991",
                 "vm_steps": 29,
                 "exit_code": 0,
                 "gas_limit": "11545",
                 "msg_state_used": false,
                 "account_activated": false,
                 "vm_init_state_hash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
                 "vm_final_state_hash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
             },
             "storage_ph": {
                 "status_change": "unchanged",
                 "storage_fees_collected": "0"
             },
             "credit_first": false
         },
         "block_ref": {
             "workchain": 0,
             "shard": "C000000000000000",
             "seqno": 44272274
         },
         "in_msg": {
             "hash": "FH0fOhm9bbGuaapRGaIlwwttOu44frYSOCPi1j/7UME=",
             "source": "0:A107678CA051B84E1B84B19E9E86504F2895CE8CDC6547907BA8A64D188BF6E7",
             "destination": "0:CD0DA207707DB6944A99815AE2B59369F3AD3E282CC67FEB358563000DFF24CB",
             "value": "4618000",
             "fwd_fee": "301869",
             "ihr_fee": "0",
             "created_lt": "47392202000020",
             "created_at": "1719582529",
             "opcode": "0x00000000",
             "ihr_disabled": true,
             "bounce": true,
             "bounced": false,
             "import_fee": null,
             "message_content": {
                 "hash": "P+k4lxWGmOTUc7dEFNdJNxaw/DpwMQk0hz8AGdqsyrQ=",
                 "body": "te6cckEBAQEABgAACAAAAADjAK8P",
                 "decoded": {
                     "type": "text_comment",
                     "comment": ""
                 }
             },
             "init_state": null
         },
         "out_msgs": [],
         "account_state_before": {
             "hash": "tqHJ5o3QIwuBLQuDrngHVBXyQTjGd99LmuHzfgrYtag=",
             "balance": null,
             "account_status": null,
             "frozen_hash": null,
             "code_hash": null,
             "data_hash": null
         },
         "account_state_after": {
             "hash": "2FDwaPJtDGbQkdbK4+doQGSSzYnfLse+W+YUvB/7C+Y=",
             "balance": "919285349",
             "account_status": "active",
             "frozen_hash": null,
             "code_hash": "/rX/aCDi/w2Ug+fg1iyBfYRniftK5YDIeIZtlZ2r1cA=",
             "data_hash": "nnH9X9M76s+VInxPcKUXTIYvitguPyXvWySUOhaYyPc="
         },
         "mc_block_seqno": 38657593
     },
     {
         "account": "0:CD0DA207707DB6944A99815AE2B59369F3AD3E282CC67FEB358563000DFF24CB",
         "hash": "vV3YFlqAdL/1o1dpwawqFuLgXjfP34O1YtJaTmV1AN0=",
         "lt": "47392202000001",
         "now": 1719582529,
         "orig_status": "active",
         "end_status": "active",
         "total_fees": "2198551",
         "prev_trans_hash": "i+09/CUCPmtruJeFzWGWSWFnYoUv/wC/2Vz5lai5V0c=",
         "prev_trans_lt": "47392052000001",
         "description": {
             "type": "ord",
             "action": {
                 "valid": true,
                 "success": true,
                 "no_funds": false,
                 "result_code": 0,
                 "tot_actions": 1,
                 "msgs_created": 1,
                 "spec_actions": 0,
                 "tot_msg_size": {
                     "bits": "865",
                     "cells": "2"
                 },
                 "status_change": "unchanged",
                 "total_fwd_fees": "494400",
                 "skipped_actions": 0,
                 "action_list_hash": "gNAEUJwALEnY8AB1W+LYfaQfiVHQW2KmzefDvRd0ZeE=",
                 "total_action_fees": "164797"
             },
             "aborted": false,
             "credit_ph": {
                 "credit": "139775004705023"
             },
             "destroyed": false,
             "compute_ph": {
                 "mode": 0,
                 "type": "vm",
                 "success": true,
                 "gas_fees": "1323200",
                 "gas_used": "3308",
                 "vm_steps": 68,
                 "exit_code": 0,
                 "gas_limit": "0",
                 "gas_credit": "10000",
                 "msg_state_used": false,
                 "account_activated": false,
                 "vm_init_state_hash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
                 "vm_final_state_hash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
             },
             "storage_ph": {
                 "status_change": "unchanged",
                 "storage_fees_collected": "154"
             },
             "credit_first": true
         },
         "block_ref": {
             "workchain": 0,
             "shard": "C000000000000000",
             "seqno": 44272274
         },
         "in_msg": {
             "hash": "6V/uUnkjlJBBVWXaCnVqr9lYH0gT/Dyup8TdqHd4nR4=",
             "source": null,
             "destination": "0:CD0DA207707DB6944A99815AE2B59369F3AD3E282CC67FEB358563000DFF24CB",
             "value": null,
             "fwd_fee": null,
             "ihr_fee": null,
             "created_lt": null,
             "created_at": null,
             "opcode": "0xd59bc7a0",
             "ihr_disabled": null,
             "bounce": null,
             "bounced": null,
             "import_fee": "0",
             "message_content": {
                 "hash": "+4NRNR5y8z0ThSEDWuMlo6dwuLMZs1KEdtHby4orLW0=",
                 "body": "te6cckEBAwEAngABnNWbx6Bmcuoe0+mxwPUBgqkoynQcl9QSwlXLwHDWxL4pFQwo8mMFJFETOwEAaoP0NZSsSG1C3S6gfHze6IyzegopqaMXZn7AYgAAAJoAAwEBbmIAUIOzxlAo3CcNwljPT0MoJ5RK50ZuMqPIPdRTJoxF+3Ob0JAAAAAAAAAAAAAAAAAAAGEVNRQCACIzMzYzMTcxOTU4MjUwODg1NGtQ55c=",
                 "decoded": null
             },
             "init_state": null
         },
         "out_msgs": [
             {
                 "hash": "dO0JhK3kNAOOTlUQjIq8jkP0pkKS9NZYpDVl2Fz5U6w=",
                 "source": "0:CD0DA207707DB6944A99815AE2B59369F3AD3E282CC67FEB358563000DFF24CB",
                 "destination": "0:A107678CA051B84E1B84B19E9E86504F2895CE8CDC6547907BA8A64D188BF6E7",
                 "value": "8000000",
                 "fwd_fee": "329603",
                 "ihr_fee": "0",
                 "created_lt": "47392202000002",
                 "created_at": "1719582529",
                 "opcode": "0x61153514",
                 "ihr_disabled": true,
                 "bounce": true,
                 "bounced": false,
                 "import_fee": null,
                 "message_content": {
                     "hash": "XwFfeHYUwpqBQd5NjKJSJKV50pbRJUh+yIy2FujYtmM=",
                     "body": "te6cckEBAgEAGgABCGEVNRQBACIzMzYzMTcxOTU4MjUwODg1NP/X3aw=",
                     "decoded": null
                 },
                 "init_state": null
             }
         ],
         "account_state_before": {
             "hash": "BsC2e1KhSBeaeyyjK67HbmRO9yV+ZhI3HdwNCaB7OhA=",
             "balance": "925591903",
             "account_status": "active",
             "frozen_hash": null,
             "code_hash": "/rX/aCDi/w2Ug+fg1iyBfYRniftK5YDIeIZtlZ2r1cA=",
             "data_hash": "pOxOXfiMGmbUc84kVE0thv63blpgoFhfq4AdIvNdAAY="
         },
         "account_state_after": {
             "hash": "tqHJ5o3QIwuBLQuDrngHVBXyQTjGd99LmuHzfgrYtag=",
             "balance": null,
             "account_status": null,
             "frozen_hash": null,
             "code_hash": null,
             "data_hash": null
         },
         "mc_block_seqno": 38657593
     }
 ],
 "address_book": {
     "0:CD0DA207707DB6944A99815AE2B59369F3AD3E282CC67FEB358563000DFF24CB": {
         "user_friendly": "UQDNDaIHcH22lEqZgVritZNp860-KCzGf-s1hWMADf8kywvX"
     },
     "0:A107678CA051B84E1B84B19E9E86504F2895CE8CDC6547907BA8A64D188BF6E7": {
         "user_friendly": "EQChB2eMoFG4ThuEsZ6ehlBPKJXOjNxlR5B7qKZNGIv256Da"
     }
 }
}
@jamescarter-le jamescarter-le changed the title GetTransactions throws JSON deserialization error. APIV3 GetTransactions throws JSON deserialization error. Jun 28, 2024
@jamescarter-le jamescarter-le changed the title APIV3 GetTransactions throws JSON deserialization error. APIV3 GetBlockTransactions throws JSON deserialization error. Jun 28, 2024
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

No branches or pull requests

1 participant