diff --git a/src/Neo.Compiler.MSIL/FuncExport.cs b/src/Neo.Compiler.MSIL/FuncExport.cs index e91bf3e3b..9a2ad7510 100644 --- a/src/Neo.Compiler.MSIL/FuncExport.cs +++ b/src/Neo.Compiler.MSIL/FuncExport.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Text; using IApiInterface = scfx.Neo.SmartContract.Framework.IApiInterface; -using ContractFeatures = scfx.Neo.SmartContract.Framework.ContractFeatures; namespace Neo.Compiler { @@ -212,21 +211,14 @@ public static string GenerateManifest(JObject abi, NeoModule module) { var sbABI = abi.ToString(false); - var features = module == null ? ContractFeatures.NoProperty : module.attributes - .Where(u => u.AttributeType.FullName == "Neo.SmartContract.Framework.FeaturesAttribute") - .Select(u => (ContractFeatures)u.ConstructorArguments.FirstOrDefault().Value) - .FirstOrDefault(); - var extraAttributes = module == null ? Array.Empty>() : module.attributes.Where(u => u.AttributeType.FullName == "Neo.SmartContract.Framework.ManifestExtraAttribute").Select(attribute => attribute.ConstructorArguments).ToArray(); var supportedStandardsAttribute = module?.attributes.Where(u => u.AttributeType.FullName == "Neo.SmartContract.Framework.SupportedStandardsAttribute").Select(attribute => attribute.ConstructorArguments).FirstOrDefault(); var extra = BuildExtraAttributes(extraAttributes); var supportedStandards = BuildSupportedStandards(supportedStandardsAttribute); - var storage = features.HasFlag(ContractFeatures.HasStorage).ToString().ToLowerInvariant(); - var payable = features.HasFlag(ContractFeatures.Payable).ToString().ToLowerInvariant(); return - @"{""groups"":[],""features"":{""storage"":" + storage + @",""payable"":" + payable + @"},""abi"":" + + @"{""groups"":[],""abi"":" + sbABI + @",""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safemethods"":[],""supportedstandards"":" + supportedStandards + @",""extra"":" + extra + "}"; } diff --git a/src/Neo.Compiler.MSIL/Neo.Compiler.MSIL.csproj b/src/Neo.Compiler.MSIL/Neo.Compiler.MSIL.csproj index c97a30e80..c4971c335 100644 --- a/src/Neo.Compiler.MSIL/Neo.Compiler.MSIL.csproj +++ b/src/Neo.Compiler.MSIL/Neo.Compiler.MSIL.csproj @@ -42,7 +42,7 @@ - + diff --git a/src/Neo.SmartContract.Framework/ContractFeatures.cs b/src/Neo.SmartContract.Framework/ContractFeatures.cs deleted file mode 100644 index 27260948c..000000000 --- a/src/Neo.SmartContract.Framework/ContractFeatures.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; - -namespace Neo.SmartContract.Framework -{ - [Flags] - public enum ContractFeatures : byte - { - NoProperty = 0, - - HasStorage = 1 << 0, - Payable = 1 << 2, - } -} diff --git a/src/Neo.SmartContract.Framework/FeaturesAttribute.cs b/src/Neo.SmartContract.Framework/FeaturesAttribute.cs deleted file mode 100644 index 21a482f53..000000000 --- a/src/Neo.SmartContract.Framework/FeaturesAttribute.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -namespace Neo.SmartContract.Framework -{ - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] - public class FeaturesAttribute : Attribute - { - /// - /// Smart contract features - /// - public ContractFeatures Features { get; } - - /// - /// Constructor - /// - /// Specify the smart contract features - public FeaturesAttribute(ContractFeatures features) - { - Features = features; - } - } -} diff --git a/templates/Template.CSharp/Contract1.cs b/templates/Template.CSharp/Contract1.cs index 75c8d5a73..e1da5e501 100644 --- a/templates/Template.CSharp/Contract1.cs +++ b/templates/Template.CSharp/Contract1.cs @@ -8,7 +8,6 @@ namespace $safeprojectname$ [ManifestExtra("Author", "Neo")] [ManifestExtra("Email", "dev@neo.org")] [ManifestExtra("Description", "This is a contract example")] - [Features(ContractFeatures.HasStorage)] public class Contract1 : SmartContract { //TODO: Replace it with your own address. diff --git a/templates/Template.NEP5.CSharp/NEP5.cs b/templates/Template.NEP5.CSharp/NEP5.cs index 9c2eb53dd..d23dda2ed 100644 --- a/templates/Template.NEP5.CSharp/NEP5.cs +++ b/templates/Template.NEP5.CSharp/NEP5.cs @@ -10,7 +10,6 @@ namespace Template.NEP5.CSharp [ManifestExtra("Email", "dev@neo.org")] [ManifestExtra("Description", "This is a NEP5 example")] [SupportedStandards("NEP5", "NEP10")] - [Features(ContractFeatures.HasStorage | ContractFeatures.Payable)] public partial class NEP5 : SmartContract { #region Token Settings diff --git a/tests/Neo.Compiler.MSIL.UnitTests/UnitTest_NULL.cs b/tests/Neo.Compiler.MSIL.UnitTests/UnitTest_NULL.cs index 3100902d8..275088389 100644 --- a/tests/Neo.Compiler.MSIL.UnitTests/UnitTest_NULL.cs +++ b/tests/Neo.Compiler.MSIL.UnitTests/UnitTest_NULL.cs @@ -112,9 +112,6 @@ public void NullCollationAndCollation() { Script = testengine.EntryContext.Script, Manifest = new ContractManifest() - { - Features = ContractFeatures.HasStorage - } }); var result = _testengine.ExecuteTestCaseStandard("nullCollationAndCollation", "nes"); @@ -131,9 +128,6 @@ public void NullCollationAndCollation2() { Script = testengine.EntryContext.Script, Manifest = new ContractManifest() - { - Features = ContractFeatures.HasStorage - } }); var result = _testengine.ExecuteTestCaseStandard("nullCollationAndCollation2", "nes"); diff --git a/tests/Neo.SmartContract.Framework.UnitTests/FeatureTest.cs b/tests/Neo.SmartContract.Framework.UnitTests/FeatureTest.cs deleted file mode 100644 index bbb6b4017..000000000 --- a/tests/Neo.SmartContract.Framework.UnitTests/FeatureTest.cs +++ /dev/null @@ -1,31 +0,0 @@ -extern alias scfx; - -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Neo.Compiler.MSIL.UnitTests.Utils; -using System.Linq; -using ContractFeatures = scfx.Neo.SmartContract.Framework.ContractFeatures; - -namespace Neo.SmartContract.Framework.UnitTests -{ - [TestClass] - public class FeatureTest - { - [TestMethod] - public void TestFeature() - { - var testengine = new TestEngine(); - testengine.AddEntryScript("./TestClasses/Contract_Feature.cs"); - - // Check that we have only one Feature - - Assert.AreEqual(1, testengine.ScriptEntry.converterIL.outModule.attributes.Count); - - // Check that was the SmartContract Feature - - Assert.AreEqual(ContractFeatures.Payable, testengine.ScriptEntry.converterIL.outModule.attributes - .Where(u => u.AttributeType.FullName == "Neo.SmartContract.Framework.FeaturesAttribute") - .Select(u => (ContractFeatures)u.ConstructorArguments.FirstOrDefault().Value) - .FirstOrDefault()); - } - } -} diff --git a/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/BlockchainTest.cs b/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/BlockchainTest.cs index 7a3b4dbe2..0185cf95e 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/BlockchainTest.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/BlockchainTest.cs @@ -334,7 +334,6 @@ public void GetContract() Script = new byte[] { 0x01, 0x02, 0x03 }, Manifest = new Manifest.ContractManifest() { - Features = Manifest.ContractFeatures.HasStorage, SupportedStandards = new string[0], Groups = new Manifest.ContractGroup[0], Trusts = Manifest.WildcardContainer.Create(), @@ -371,39 +370,6 @@ public void GetContract() Assert.IsInstanceOfType(item, typeof(VM.Types.ByteString)); Assert.AreEqual(contract.Manifest.ToString(), item.GetString()); - // Found + HasStorage - - _engine.Reset(); - result = _engine.ExecuteTestCaseStandard("getContract", new VM.Types.ByteString(contract.ScriptHash.ToArray()), new VM.Types.ByteString(Utility.StrictUTF8.GetBytes("HasStorage"))); - Assert.AreEqual(VMState.HALT, _engine.State); - Assert.AreEqual(1, result.Count); - - item = result.Pop(); - Assert.IsInstanceOfType(item, typeof(Boolean)); - Assert.AreEqual(contract.HasStorage, item.GetBoolean()); - - // Found + IsPayable - - _engine.Reset(); - result = _engine.ExecuteTestCaseStandard("getContract", new VM.Types.ByteString(contract.ScriptHash.ToArray()), new VM.Types.ByteString(Utility.StrictUTF8.GetBytes("IsPayable"))); - Assert.AreEqual(VMState.HALT, _engine.State); - Assert.AreEqual(1, result.Count); - - item = result.Pop(); - Assert.IsInstanceOfType(item, typeof(Boolean)); - Assert.AreEqual(contract.Payable, item.GetBoolean()); - - // Found + IsPayable - - _engine.Reset(); - result = _engine.ExecuteTestCaseStandard("getContract", new VM.Types.ByteString(contract.ScriptHash.ToArray()), new VM.Types.ByteString(Utility.StrictUTF8.GetBytes("Script"))); - Assert.AreEqual(VMState.HALT, _engine.State); - Assert.AreEqual(1, result.Count); - - item = result.Pop(); - Assert.IsInstanceOfType(item, typeof(VM.Types.ByteString)); - CollectionAssert.AreEqual(contract.Script, item.GetSpan().ToArray()); - // Found + Uknown property _engine.Reset(); diff --git a/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/ContractTest.cs b/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/ContractTest.cs index 398b15eb9..61d589592 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/ContractTest.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/ContractTest.cs @@ -29,17 +29,10 @@ public void Test_CreateCallDestroy() var script = _engine.Build("./TestClasses/Contract_Create.cs"); var manifest = ContractManifest.FromJson(JObject.Parse(script.finalManifest)); - // Check first - - _engine.Reset(); - var result = _engine.ExecuteTestCaseStandard("call", manifest.Hash.ToArray(), "oldContract", new Array()); - Assert.AreEqual(VMState.FAULT, _engine.State); - Assert.AreEqual(0, result.Count); - // Create _engine.Reset(); - result = _engine.ExecuteTestCaseStandard("create", script.finalNEF, manifest.ToJson().ToString()); + var result = _engine.ExecuteTestCaseStandard("create", script.finalNEF, manifest.ToJson().ToString()); Assert.AreEqual(VMState.HALT, _engine.State); Assert.AreEqual(1, result.Count); @@ -48,8 +41,6 @@ public void Test_CreateCallDestroy() var itemArray = item as Array; Assert.AreEqual(script.finalNEF, itemArray[0]); // Script Assert.AreEqual(manifest.ToString(), itemArray[1].GetString()); // Manifest - Assert.AreEqual(false, itemArray[2]); // HasStorage - Assert.AreEqual(false, itemArray[3]); // Payable // Call @@ -88,21 +79,10 @@ public void Test_Update() var scriptUpdate = _engine.Build("./TestClasses/Contract_Update.cs"); var manifestUpdate = ContractManifest.FromJson(JObject.Parse(scriptUpdate.finalManifest)); - // Check first - - _engine.Reset(); - var result = _engine.ExecuteTestCaseStandard("call", manifest.Hash.ToArray(), "oldContract", new Array()); - Assert.AreEqual(VMState.FAULT, _engine.State); - Assert.AreEqual(0, result.Count); - - _engine.Reset(); - _ = _engine.ExecuteTestCaseStandard("call", manifestUpdate.Hash.ToArray(), "newContract", new Array()); - Assert.AreEqual(VMState.FAULT, _engine.State); - // Create _engine.Reset(); - result = _engine.ExecuteTestCaseStandard("create", script.finalNEF, manifest.ToJson().ToString()); + var result = _engine.ExecuteTestCaseStandard("create", script.finalNEF, manifest.ToJson().ToString()); Assert.AreEqual(VMState.HALT, _engine.State); Assert.AreEqual(1, result.Count); @@ -111,8 +91,6 @@ public void Test_Update() var itemArray = item as Array; Assert.AreEqual(script.finalNEF, itemArray[0]); // Script Assert.AreEqual(manifest.ToString(), itemArray[1].GetString()); // Manifest - Assert.AreEqual(false, itemArray[2]); // HasStorage - Assert.AreEqual(false, itemArray[3]); // Payable // Call & Update diff --git a/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/RuntimeTest.cs b/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/RuntimeTest.cs index 3ece9e0bb..a751dcbbe 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/RuntimeTest.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/RuntimeTest.cs @@ -141,7 +141,7 @@ public void Test_GasLeft() var item = result.Pop(); Assert.IsInstanceOfType(item, typeof(Integer)); - Assert.AreEqual(TestEngine.TestGas - 1200, item.GetInteger()); + Assert.AreEqual(TestEngine.TestGas - 2000, item.GetInteger()); } [TestMethod] diff --git a/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/StaticStorageMapTest.cs b/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/StaticStorageMapTest.cs index cdd560990..6f397f58f 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/StaticStorageMapTest.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/StaticStorageMapTest.cs @@ -5,7 +5,6 @@ using Neo.Ledger; using Neo.VM; using System.Linq; -using ContractFeatures = scfx.Neo.SmartContract.Framework.ContractFeatures; namespace Neo.SmartContract.Framework.UnitTests.Services.Neo { @@ -22,18 +21,10 @@ public void Init() _engine = new TestEngine(snapshot: snapshot.Clone()); _engine.AddEntryScript("./TestClasses/Contract_StaticStorageMap.cs"); - Assert.AreEqual(ContractFeatures.HasStorage, _engine.ScriptEntry.converterIL.outModule.attributes - .Where(u => u.AttributeType.Name == "FeaturesAttribute") - .Select(u => (ContractFeatures)u.ConstructorArguments.FirstOrDefault().Value) - .FirstOrDefault()); - _engine.Snapshot.Contracts.Add(_engine.EntryScriptHash, new ContractState() { Script = _engine.EntryContext.Script, Manifest = new Manifest.ContractManifest() - { - Features = Manifest.ContractFeatures.HasStorage - } }); } diff --git a/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/StorageTest.cs b/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/StorageTest.cs index 400cf938d..b0bb73f28 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/StorageTest.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/Services/Neo/StorageTest.cs @@ -6,7 +6,6 @@ using Neo.VM.Types; using System; using System.Linq; -using ContractFeatures = scfx.Neo.SmartContract.Framework.ContractFeatures; namespace Neo.SmartContract.Framework.UnitTests.Services.Neo { @@ -66,18 +65,10 @@ public void Init() testengine = new TestEngine(snapshot: snapshot.Clone()); testengine.AddEntryScript("./TestClasses/Contract_Storage.cs"); - Assert.AreEqual(ContractFeatures.HasStorage, testengine.ScriptEntry.converterIL.outModule.attributes - .Where(u => u.AttributeType.FullName == "Neo.SmartContract.Framework.FeaturesAttribute") - .Select(u => (ContractFeatures)u.ConstructorArguments.FirstOrDefault().Value) - .FirstOrDefault()); - testengine.Snapshot.Contracts.Add(testengine.EntryScriptHash, new Ledger.ContractState() { Script = testengine.EntryContext.Script, Manifest = new Manifest.ContractManifest() - { - Features = Manifest.ContractFeatures.HasStorage - } }); } diff --git a/tests/Neo.SmartContract.Framework.UnitTests/TestClasses/Contract_Feature.cs b/tests/Neo.SmartContract.Framework.UnitTests/TestClasses/Contract_Feature.cs deleted file mode 100644 index 0fac8a03a..000000000 --- a/tests/Neo.SmartContract.Framework.UnitTests/TestClasses/Contract_Feature.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Neo.SmartContract.Framework; - -namespace Neo.Compiler.MSIL.TestClasses -{ - [Features(ContractFeatures.HasStorage)] - class Sample - { - public int Value; - } - - [Features(ContractFeatures.Payable)] - class Contract_Feature : SmartContract.Framework.SmartContract - { - public static object Main(string method, object[] args) - { - var a = new Sample(); - return a.Value; - } - } -} diff --git a/tests/Neo.SmartContract.Framework.UnitTests/TestClasses/Contract_StaticStorageMap.cs b/tests/Neo.SmartContract.Framework.UnitTests/TestClasses/Contract_StaticStorageMap.cs index ed3bc5509..6e0421e5f 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/TestClasses/Contract_StaticStorageMap.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/TestClasses/Contract_StaticStorageMap.cs @@ -4,7 +4,6 @@ namespace Neo.Compiler.MSIL.TestClasses { - [Features(ContractFeatures.HasStorage)] class Contract_StaticStorageMap : SmartContract.Framework.SmartContract { private static StorageMap Data = Storage.CurrentContext.CreateMap("data"); diff --git a/tests/Neo.SmartContract.Framework.UnitTests/TestClasses/Contract_Storage.cs b/tests/Neo.SmartContract.Framework.UnitTests/TestClasses/Contract_Storage.cs index bac382f7a..631bc1638 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/TestClasses/Contract_Storage.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/TestClasses/Contract_Storage.cs @@ -3,7 +3,6 @@ namespace Neo.Compiler.MSIL.TestClasses { - [Features(ContractFeatures.HasStorage)] class Contract_Storage : SmartContract.Framework.SmartContract { // There is no main here, it can be auto generation. diff --git a/tests/Template.NEP5.UnitTests/UnitTest_NEP5.cs b/tests/Template.NEP5.UnitTests/UnitTest_NEP5.cs index 8eb6e9b89..e9adeaf14 100644 --- a/tests/Template.NEP5.UnitTests/UnitTest_NEP5.cs +++ b/tests/Template.NEP5.UnitTests/UnitTest_NEP5.cs @@ -81,9 +81,6 @@ public void Test_totalSupply() snapshot.Contracts.Add(hash, new Neo.Ledger.ContractState() { Manifest = new Neo.SmartContract.Manifest.ContractManifest() - { - Features = Neo.SmartContract.Manifest.ContractFeatures.HasStorage - } }); snapshot.Storages.Add(new Neo.Ledger.StorageKey() @@ -115,9 +112,6 @@ public void Test_totalSupply_empty() snapshot.Contracts.Add(hash, new Neo.Ledger.ContractState() { Manifest = new Neo.SmartContract.Manifest.ContractManifest() - { - Features = Neo.SmartContract.Manifest.ContractFeatures.HasStorage - } }); var result = engine.ExecuteTestCaseStandard("totalSupply"); @@ -139,9 +133,6 @@ public void Test_balanceOf() snapshot.Contracts.Add(hash, new Neo.Ledger.ContractState() { Manifest = new Neo.SmartContract.Manifest.ContractManifest() - { - Features = Neo.SmartContract.Manifest.ContractFeatures.HasStorage - } }); snapshot.Storages.Add(new Neo.Ledger.StorageKey() @@ -174,9 +165,6 @@ public void Test_balanceOf_empty() snapshot.Contracts.Add(hash, new Neo.Ledger.ContractState() { Manifest = new Neo.SmartContract.Manifest.ContractManifest() - { - Features = Neo.SmartContract.Manifest.ContractFeatures.HasStorage - } }); var result = engine.ExecuteTestCaseStandard("balanceOf", address);