Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated code to all args be passed to deploy method #200

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/adapter3/LaunchConfigParser.Invocations.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Neo.Network.P2P.Payloads;
using Newtonsoft.Json.Linq;
using System;

namespace NeoDebug.Neo3
{
Expand Down Expand Up @@ -30,13 +30,30 @@ public static bool TryFromJson(JToken token, out InvokeFileInvocation invocation

public struct ContractDeployInvocation
{
public readonly JArray Args;

public ContractDeployInvocation(JArray args)
{
Args = args;
}

public static bool TryFromJson(JToken token, out ContractDeployInvocation invocation)
{
if (token.Type == JTokenType.String && token.Value<string>() == "deploy")
{
invocation = new ContractDeployInvocation();
return true;
}
else if (token.Type == JTokenType.Object && token.Value<bool>("deploy"))
{
var argsJson = token["args"];
var args = argsJson == null
? new JArray()
: argsJson is JArray ? (JArray)argsJson : new JArray(argsJson);

invocation = new ContractDeployInvocation(args);
return true;
}

invocation = default;
return false;
Expand Down
5 changes: 3 additions & 2 deletions src/adapter3/LaunchConfigParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ static async Task<IApplicationEngine> CreateDebugEngineAsync(ConfigProps config,
{
signers = new[] { deploySigner };
}

var tokenArgs = invocation.AsT3.Args;
var args = tokenArgs != null ? paramParser.ParseParameters(tokenArgs).ToArray() : null;
using var builder = new ScriptBuilder();
builder.EmitDynamicCall(NativeContract.ContractManagement.Hash, "deploy", launchNefFile.ToArray(), launchManifest.ToJson().ToString());
builder.EmitDynamicCall(NativeContract.ContractManagement.Hash, "deploy", launchNefFile.ToArray(), launchManifest.ToJson().ToString(), args);
invokeScript = builder.ToArray();
}
else
Expand Down