public static string forge_entrypoint(string value) { string res = ""; if (entrypoint_tags.ContainsKey(value)) { res += entrypoint_tags[value].ToString("X2"); } else { res += "ff"; res += Forge.forge_array(Encoding.Default.GetBytes(value).ToHexString()); } return(res); }
public static string forge_micheline(JToken data) { string res = ""; if (data is JArray) { res += "02"; res += Forge.forge_array(string.Concat(data.Select(item => forge_micheline(item)))); } else if (data is JObject) { if (data["prim"] != null) { var args_len = data["args"]?.Count() ?? 0; var annots_len = data["annots"]?.Count() ?? 0; res += len_tags[args_len][annots_len > 0]; res += prim_tags[data["prim"].ToString()]; if (args_len > 0) { string args = string.Concat(data["args"].Select(item => forge_micheline(item))); if (args_len < 3) { res += args; } else { res += Forge.forge_array(args); } } if (annots_len > 0) { res += Forge.forge_array(string.Join(" ", data["annots"])); } else if (args_len == 3) { res += new string('0', 8); } } else if (data["bytes"] != null) { res += "0A"; res += Forge.forge_array(data["bytes"].ToString()); } else if (data["int"] != null) { res += "00"; res += forge_int(data["int"].Value <int>()); } else if (data["string"] != null) { res += "01"; res += Forge.forge_array(Encoding.Default.GetBytes(data["string"].Value <string>()).ToHexString()); } else { throw new Exception($"Michelson forge error"); } } else { throw new Exception($"Michelson forge error"); } return(res); }