Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Sync to CI01133 #707

Merged
merged 10 commits into from
Jan 5, 2021
Merged
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
6 changes: 3 additions & 3 deletions neo-cli/CLI/MainService.Vote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private void OnRegisterCandidateCommand(UInt160 account)
byte[] script;
using (ScriptBuilder scriptBuilder = new ScriptBuilder())
{
scriptBuilder.EmitAppCall(NativeContract.NEO.Hash, "registerCandidate", publicKey);
scriptBuilder.EmitDynamicCall(NativeContract.NEO.Hash, "registerCandidate", true, publicKey);
script = scriptBuilder.ToArray();
}

Expand Down Expand Up @@ -83,7 +83,7 @@ private void OnUnregisterCandidateCommand(UInt160 account)
byte[] script;
using (ScriptBuilder scriptBuilder = new ScriptBuilder())
{
scriptBuilder.EmitAppCall(NativeContract.NEO.Hash, "unregisterCandidate", publicKey);
scriptBuilder.EmitDynamicCall(NativeContract.NEO.Hash, "unregisterCandidate", true, publicKey);
script = scriptBuilder.ToArray();
}

Expand All @@ -107,7 +107,7 @@ private void OnVoteCommand(UInt160 senderAccount, ECPoint publicKey)
byte[] script;
using (ScriptBuilder scriptBuilder = new ScriptBuilder())
{
scriptBuilder.EmitAppCall(NativeContract.NEO.Hash, "vote", senderAccount, publicKey);
scriptBuilder.EmitDynamicCall(NativeContract.NEO.Hash, "vote", true, senderAccount, publicKey);
script = scriptBuilder.ToArray();
}

Expand Down
27 changes: 25 additions & 2 deletions neo-cli/CLI/MainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private byte[] LoadDeploymentScript(string nefFilePath, string manifestFilePath,

using (ScriptBuilder sb = new ScriptBuilder())
{
sb.EmitAppCall(NativeContract.ContractManagement.Hash, "deploy", nef.ToArray(), manifest.ToJson().ToString());
sb.EmitDynamicCall(NativeContract.ContractManagement.Hash, "deploy", true, nef.ToArray(), manifest.ToJson().ToString());
return sb.ToArray();
}
}
Expand Down Expand Up @@ -525,11 +525,34 @@ private bool OnInvokeWithResult(UInt160 scriptHash, string operation, out StackI
}
}

bool hasReturnValue;
var snapshot = Blockchain.Singleton.GetSnapshot();
ContractState contract = NativeContract.ContractManagement.GetContract(snapshot, scriptHash);
if (contract == null)
{
Console.WriteLine("Contract does not exist.");
result = StackItem.Null;
return false;
}
else
{
if (contract.Manifest.Abi.GetMethod(operation) == null)
{
Console.WriteLine("This method does not not exist in this contract.");
result = StackItem.Null;
return false;
}
else
{
hasReturnValue = contract.Manifest.Abi.GetMethod(operation).ReturnType != ContractParameterType.Void;
}
}

byte[] script;

using (ScriptBuilder scriptBuilder = new ScriptBuilder())
{
scriptBuilder.EmitAppCall(scriptHash, operation, parameters.ToArray());
scriptBuilder.EmitDynamicCall(scriptHash, operation, hasReturnValue, parameters.ToArray());
script = scriptBuilder.ToArray();
Console.WriteLine($"Invoking script with: '{script.ToBase64String()}'");
}
Expand Down
2 changes: 1 addition & 1 deletion neo-cli/neo-cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI01125" />
<PackageReference Include="Neo" Version="3.0.0-CI01133" />
</ItemGroup>

<ItemGroup>
Expand Down