From 04eea0f0913149bcfcb34512d7f54d34283eb42d Mon Sep 17 00:00:00 2001 From: Hecate2 <2474101468@qq.com> Date: Mon, 12 Aug 2024 15:43:07 +0800 Subject: [PATCH] return nefFile that can be saved as .nef file --- Fairy.Utils.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Fairy.Utils.cs b/Fairy.Utils.cs index 87e2c2c..bbee681 100644 --- a/Fairy.Utils.cs +++ b/Fairy.Utils.cs @@ -96,7 +96,16 @@ protected virtual JToken GetContract(JArray _params) ContractState contractState = NativeContract.ContractManagement.GetContract( session == null ? system.StoreView : sessionStringToFairySession[session].engine.Snapshot, hash); - return contractState.ToJson(); + JObject result = contractState.ToJson(); + using (MemoryStream ms = new MemoryStream()) + using (BinaryWriter writer = new BinaryWriter(ms)) + { + contractState.Nef.Serialize(writer); + byte[] nef = ms.ToArray(); + // base64 encoded bytes that can be directly saved as .nef file + result["nefFile"] = Convert.ToBase64String(nef)!; + } + return result; } [RpcMethod]