diff --git a/src/neo/SmartContract/ApplicationEngine.Contract.cs b/src/neo/SmartContract/ApplicationEngine.Contract.cs index c537469da6..5b84938289 100644 --- a/src/neo/SmartContract/ApplicationEngine.Contract.cs +++ b/src/neo/SmartContract/ApplicationEngine.Contract.cs @@ -1,6 +1,7 @@ using Neo.Cryptography.ECC; using Neo.IO; using Neo.Ledger; +using Neo.Network.P2P.Payloads; using Neo.SmartContract.Manifest; using Neo.SmartContract.Native; using Neo.VM; @@ -164,7 +165,27 @@ private void CallContractInternal(UInt160 contractHash, string method, Array arg internal bool IsStandardContract(UInt160 hash) { ContractState contract = Snapshot.Contracts.TryGet(hash); - return contract is null || contract.Script.IsStandardContract(); + + // It's a stored contract + + if (contract != null) return contract.Script.IsStandardContract(); + + // Try to find it in the transaction + + if (ScriptContainer is Transaction tx) + { + foreach (var witness in tx.Witnesses) + { + if (witness.ScriptHash == hash) + { + return witness.VerificationScript.IsStandardContract(); + } + } + } + + // It's not possible to determine if it's standard + + return false; } internal CallFlags GetCallFlags() diff --git a/tests/neo.UnitTests/SmartContract/UT_InteropService.NEO.cs b/tests/neo.UnitTests/SmartContract/UT_InteropService.NEO.cs index 283fdc1d3f..5d78c4ebd5 100644 --- a/tests/neo.UnitTests/SmartContract/UT_InteropService.NEO.cs +++ b/tests/neo.UnitTests/SmartContract/UT_InteropService.NEO.cs @@ -110,7 +110,7 @@ public void TestAccount_IsStandard() 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }; - engine.IsStandardContract(new UInt160(hash)).Should().BeTrue(); + engine.IsStandardContract(new UInt160(hash)).Should().BeFalse(); var snapshot = Blockchain.Singleton.GetSnapshot(); var state = TestUtils.GetContract(); @@ -118,6 +118,11 @@ public void TestAccount_IsStandard() engine = new ApplicationEngine(TriggerType.Application, null, snapshot, 0, true); engine.LoadScript(new byte[] { 0x01 }); engine.IsStandardContract(state.ScriptHash).Should().BeFalse(); + + state.Script = Contract.CreateSignatureRedeemScript(Blockchain.StandbyValidators[0]); + engine = new ApplicationEngine(TriggerType.Application, null, snapshot, 0, true); + engine.LoadScript(new byte[] { 0x01 }); + engine.IsStandardContract(state.ScriptHash).Should().BeTrue(); } [TestMethod]