From 64fc0521877af3f2ebc1ec2cd2c7d4cfc2c6bee1 Mon Sep 17 00:00:00 2001 From: kilogold Date: Mon, 8 Apr 2024 23:36:59 -0700 Subject: [PATCH] Skipping accounts if none exist. --- Solana.Unity.Anchor.Tool/AnchorSourceGenerator.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Solana.Unity.Anchor.Tool/AnchorSourceGenerator.cs b/Solana.Unity.Anchor.Tool/AnchorSourceGenerator.cs index 1ee1521..9870dde 100644 --- a/Solana.Unity.Anchor.Tool/AnchorSourceGenerator.cs +++ b/Solana.Unity.Anchor.Tool/AnchorSourceGenerator.cs @@ -46,7 +46,12 @@ static int Main(string[] args) var jsonParsed = JObject.Parse(idlStr); // Set UnixTimestamp to Int64 in accounts - foreach (JToken account in (JArray)jsonParsed["accounts"]) + if (!jsonParsed.TryGetValue("accounts", out JToken val)) + { + val = new JArray(); + } + + foreach (JToken account in (JArray)val) { JToken accountType = account["type"]; foreach (JObject fields in (JArray)accountType["fields"])