Skip to content

Commit

Permalink
Fix MethodCallback (#1723)
Browse files Browse the repository at this point in the history
  • Loading branch information
shargon authored Jun 22, 2020
1 parent d275916 commit 8f509db
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/neo/SmartContract/Callbacks/MethodCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ internal class MethodCallback : SyscallCallback
public override int ParametersCount => method.Parameters.Length;

public MethodCallback(ApplicationEngine engine, UInt160 hash, string method)
: base(ApplicationEngine.System_Contract_Call)
: base(ApplicationEngine.System_Contract_Call, false)
{
if (method.StartsWith('_')) throw new ArgumentException();
this.contract = engine.Snapshot.Contracts[hash];
ContractManifest currentManifest = engine.Snapshot.Contracts.TryGet(engine.CurrentScriptHash)?.Manifest;
if (currentManifest != null && !currentManifest.CanCall(contract.Manifest, method))
if (currentManifest != null && !currentManifest.CanCall(this.contract.Manifest, method))
throw new InvalidOperationException();
this.contract = engine.Snapshot.Contracts[hash];
this.method = contract.Manifest.Abi.Methods.First(p => p.Name == method);
this.method = this.contract.Manifest.Abi.Methods.First(p => p.Name == method);
}

public override void LoadContext(ApplicationEngine engine, Array args)
Expand Down
4 changes: 2 additions & 2 deletions src/neo/SmartContract/Callbacks/SyscallCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ internal class SyscallCallback : CallbackBase
public InteropDescriptor Method { get; }
public override int ParametersCount => Method.Parameters.Length;

public SyscallCallback(uint method)
public SyscallCallback(uint method, bool check = true)
{
this.Method = ApplicationEngine.Services[method];
if (!Method.AllowCallback)
if (check && !Method.AllowCallback)
throw new InvalidOperationException("This SYSCALL is not allowed for creating callback.");
}

Expand Down
2 changes: 1 addition & 1 deletion src/neo/SmartContract/Manifest/ContractManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static ContractManifest FromJson(JObject json)
/// <returns>Return ContractManifest</returns>
public static ContractManifest Parse(ReadOnlySpan<byte> json) => FromJson(JObject.Parse(json));

internal static ContractManifest Parse(string json) => FromJson(JObject.Parse(json));
public static ContractManifest Parse(string json) => FromJson(JObject.Parse(json));

/// <summary
/// To json
Expand Down

0 comments on commit 8f509db

Please sign in to comment.