You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently there is an issue with deserializing u128 and structs
U128
There are currently two way to temporeraly get around this issue
change the line 130 in the model.cs to "u128" => new FieldElement(value.value.ToObject()), and make all the u128 in the models into fieldelements and it will save all the u128 into hex (this is what i have done)
create a fucntion such as
` public static BigInteger HexToBigInteger(string hexString)
{
if (hexString.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
{
hexString = hexString.Substring(2);
}
hexString = hexString.TrimStart('0');
byte[] bytes = new byte[hexString.Length / 2 + hexString.Length % 2];
for (int index = 0; index < bytes.Length; index++)
{
string byteValue = hexString.Length % 2 != 0 && index == 0
? hexString.Substring(0, 1)
: hexString.Substring(index * 2 - (hexString.Length % 2 == 0 ? 0 : 1), 2);
bytes[bytes.Length - index - 1] = Convert.ToByte(byteValue, 16);
}
return new BigInteger(bytes.Concat(new byte[] { 0 }).ToArray());
}`
to turn the hex given to a bigint (havent tried this yet)
STRUCTS
Structs in the function HandleField get passed empty, for example for this code here
` else if (ty is Model.Struct struct_)
{
var instance = Activator.CreateInstance(type);
var fields = type.GetFields();
foreach (var field in fields)
{
Debug.Log($"Field: {field.Name}"); //attack
Debug.Log($"Field type: {field.FieldType}"); //System.Byte
}
Debug.Log("printing the members:");
foreach (var member in struct_.members)
{
Debug.Log($"Member: {member.Key}"); //id
Debug.Log($"Member type: {member.Value}"); //System.Byte
}
foreach (var field in fields)
{
field.SetValue(instance, HandleField(field.FieldType, struct_.members[field.Name]));
}
return instance;
}`
the first loop would print the correct names but the second one is empty therefore giving a dict not found error,
Currently i have no fix for this so i have just added a simple check before starting the function
if (member is Model.Struct) { continue; }
The text was updated successfully, but these errors were encountered:
Currently there is an issue with deserializing u128 and structs
U128
There are currently two way to temporeraly get around this issue
change the line 130 in the model.cs to "u128" => new FieldElement(value.value.ToObject()), and make all the u128 in the models into fieldelements and it will save all the u128 into hex (this is what i have done)
create a fucntion such as
` public static BigInteger HexToBigInteger(string hexString)
{
if (hexString.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
{
hexString = hexString.Substring(2);
}
}`
to turn the hex given to a bigint (havent tried this yet)
STRUCTS
Structs in the function HandleField get passed empty, for example for this code here
` else if (ty is Model.Struct struct_)
{
var instance = Activator.CreateInstance(type);
var fields = type.GetFields();
the first loop would print the correct names but the second one is empty therefore giving a dict not found error,
Currently i have no fix for this so i have just added a simple check before starting the function
if (member is Model.Struct) { continue; }
The text was updated successfully, but these errors were encountered: