From fe38b263a81a1a213a394b3ce5f7b1673141639f Mon Sep 17 00:00:00 2001 From: Erik Zhang Date: Thu, 17 Dec 2020 09:34:53 +0800 Subject: [PATCH] Fix CallFromNativeContract --- src/neo/SmartContract/ApplicationEngine.Contract.cs | 3 +-- src/neo/SmartContract/Native/OracleContract.cs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/neo/SmartContract/ApplicationEngine.Contract.cs b/src/neo/SmartContract/ApplicationEngine.Contract.cs index 7877de258a..195f84f50a 100644 --- a/src/neo/SmartContract/ApplicationEngine.Contract.cs +++ b/src/neo/SmartContract/ApplicationEngine.Contract.cs @@ -30,6 +30,7 @@ protected internal void CallContract(UInt160 contractHash, string method, Array protected internal void CallContractEx(UInt160 contractHash, string method, Array args, CallFlags callFlags) { + if (method.StartsWith('_')) throw new ArgumentException($"Invalid Method Name: {method}"); if ((callFlags & ~CallFlags.All) != 0) throw new ArgumentOutOfRangeException(nameof(callFlags)); CallContractInternal(contractHash, method, args, callFlags, ReturnTypeConvention.EnsureNotEmpty); @@ -37,8 +38,6 @@ protected internal void CallContractEx(UInt160 contractHash, string method, Arra private void CallContractInternal(UInt160 contractHash, string method, Array args, CallFlags flags, ReturnTypeConvention convention) { - if (method.StartsWith('_')) throw new ArgumentException($"Invalid Method Name: {method}"); - ContractState contract = NativeContract.Management.GetContract(Snapshot, contractHash); if (contract is null) throw new InvalidOperationException($"Called Contract Does Not Exist: {contractHash}"); ContractMethodDescriptor md = contract.Manifest.Abi.GetMethod(method); diff --git a/src/neo/SmartContract/Native/OracleContract.cs b/src/neo/SmartContract/Native/OracleContract.cs index 35587a70f6..ff6b2ac77d 100644 --- a/src/neo/SmartContract/Native/OracleContract.cs +++ b/src/neo/SmartContract/Native/OracleContract.cs @@ -177,7 +177,7 @@ private void Request(ApplicationEngine engine, string url, string filter, string //Check the arguments if (Utility.StrictUTF8.GetByteCount(url) > MaxUrlLength || (filter != null && Utility.StrictUTF8.GetByteCount(filter) > MaxFilterLength) - || Utility.StrictUTF8.GetByteCount(callback) > MaxCallbackLength + || Utility.StrictUTF8.GetByteCount(callback) > MaxCallbackLength || callback.StartsWith('_') || gasForResponse < 0_10000000) throw new ArgumentException();