Skip to content

Commit cdc1aad

Browse files
committedSep 10, 2021
fix, add handling for structs to API
1 parent d5ae39b commit cdc1aad

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed
 

‎Phantasma.API/NexusAPI.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -615,9 +615,7 @@ private TokenDataResult FillNFT(string symbol, BigInteger ID, bool extended)
615615
}
616616
}
617617
}
618-
619618
}
620-
621619
}
622620

623621
var infusion = info.Infusion.Select(x => new TokenPropertyResult() { Key = x.Symbol, Value = x.Value.ToString() }).ToArray();
@@ -1730,7 +1728,7 @@ public IAPIResult GetNFT([APIParameter("Symbol of token", "NACHO")] string symbo
17301728
TokenDataResult result;
17311729
try
17321730
{
1733-
result = FillNFT(symbol, ID, extended); ;
1731+
result = FillNFT(symbol, ID, extended);
17341732
}
17351733
catch (Exception e)
17361734
{

‎Phantasma.Storage/Serialization.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public static void Serialize(BinaryWriter writer, object obj, Type type)
182182
writer.WriteVarInt(val);
183183
}
184184
else
185-
if (type.IsStructOrClass()) // check if struct or class
185+
if (type.IsStructOrClass())
186186
{
187187
var fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance);
188188

‎Phantasma.VM/VMObject.cs

+9
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ public string AsString()
189189

190190
return "Interop:" + Data.GetType().Name;
191191
}
192+
case VMType.Struct:
193+
using (var stream = new MemoryStream())
194+
{
195+
using (var writer = new BinaryWriter(stream))
196+
{
197+
SerializeData(writer);
198+
}
199+
return BitConverter.ToString(stream.ToArray()).Replace("-", "");
200+
}
192201

193202
case VMType.Bool:
194203
return ((bool)Data) ? "true" : "false";

0 commit comments

Comments
 (0)