Skip to content

Commit

Permalink
support data in VirtualDeploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Hecate2 committed Aug 28, 2024
1 parent 2fb2ee6 commit b42620e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Fairy.Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,25 @@ protected virtual JObject VirtualDeploy(JArray _params)
string session = _params[0]!.AsString();
NefFile nef = Convert.FromBase64String(_params[1]!.AsString()).AsSerializable<NefFile>();
ContractManifest manifest = ContractManifest.Parse(_params[2]!.AsString());
Signer[] signers = SignersFromJson((JArray)_params[3]!, system.Settings);
ContractParameter? data = null;
Signer[] signers;
var param3 = _params[3]! as JObject;
if (param3 != null) // A contract parameter
{
data = ContractParameter.FromJson(param3);
signers = SignersFromJson((JArray)_params[4]!, system.Settings);
}
else
signers = SignersFromJson((JArray)_params[3]!, system.Settings);
FairySession testSession = GetOrCreateFairySession(session);
DataCache snapshot = testSession.engine.Snapshot;
byte[] script;
using (ScriptBuilder sb = new ScriptBuilder())
{
sb.EmitDynamicCall(NativeContract.ContractManagement.Hash, "deploy", nef.ToArray(), manifest.ToJson().ToString());
if (data != null)
sb.EmitDynamicCall(NativeContract.ContractManagement.Hash, "deploy", nef.ToArray(), manifest.ToJson().ToString(), data);
else
sb.EmitDynamicCall(NativeContract.ContractManagement.Hash, "deploy", nef.ToArray(), manifest.ToJson().ToString());
script = sb.ToArray();
}
JObject json = new();
Expand Down

0 comments on commit b42620e

Please sign in to comment.