Skip to content

Commit

Permalink
return nefFile that can be saved as .nef file
Browse files Browse the repository at this point in the history
  • Loading branch information
Hecate2 committed Aug 12, 2024
1 parent 3ee57af commit 04eea0f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Fairy.Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 04eea0f

Please sign in to comment.