From cb0e876438d30507da94b962902be0f5841fdac0 Mon Sep 17 00:00:00 2001 From: Jim8y Date: Mon, 11 Mar 2024 20:19:15 +0800 Subject: [PATCH 1/7] implement payable --- .../ContractManifestExtension.cs | 48 +++++++++++++++++++ .../NEPStandard.cs | 20 +++++++- .../Contract_SupportedStandard11Payable.cs | 20 ++++++++ .../Contract_SupportedStandard17Payable.cs | 20 ++++++++ .../SupportedStandardsTest.cs | 12 +++++ .../Contract_SupportedStandard11Payable.cs | 34 +++++++++++++ .../Contract_SupportedStandard17Payable.cs | 34 +++++++++++++ 7 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Payable.cs create mode 100644 tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard17Payable.cs create mode 100644 tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs create mode 100644 tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard17Payable.cs diff --git a/src/Neo.Compiler.CSharp/ContractManifestExtension.cs b/src/Neo.Compiler.CSharp/ContractManifestExtension.cs index 4c041f420..1babbd3d8 100644 --- a/src/Neo.Compiler.CSharp/ContractManifestExtension.cs +++ b/src/Neo.Compiler.CSharp/ContractManifestExtension.cs @@ -163,6 +163,44 @@ private static void CheckNep17Compliant(this ContractManifest manifest) } } + private static void CheckNep11PayableCompliant(this ContractManifest manifest) + { + try + { + var onNEP11PaymentMethod = manifest.Abi.GetMethod("onNEP11Payment", 3); + var onNEP11PaymentValid = onNEP11PaymentMethod is { Safe: false, ReturnType: ContractParameterType.Void } && + onNEP11PaymentMethod.Parameters[0].Type == ContractParameterType.Hash160 && + onNEP11PaymentMethod.Parameters[1].Type == ContractParameterType.Integer && + onNEP11PaymentMethod.Parameters[2].Type == ContractParameterType.Any; + + if (!onNEP11PaymentValid) throw new CompilationException(DiagnosticId.IncorrectNEPStandard, + $"Incomplete NEP standard {NepStandard.Nep11Payable.ToStandard()} implementation: onNEP11Payment"); + } + catch (Exception ex) when (ex is not CompilationException) + { + throw new CompilationException(DiagnosticId.IncorrectNEPStandard, $"Incomplete NEP standard {NepStandard.Nep11Payable.ToStandard()} implementation: Unidentified issue."); + } + } + + private static void CheckNep17PayableCompliant(this ContractManifest manifest) + { + try + { + var onNEP17PaymentMethod = manifest.Abi.GetMethod("onNEP17Payment", 3); + var onNEP17PaymentValid = onNEP17PaymentMethod is { Safe: false, ReturnType: ContractParameterType.Void } && + onNEP17PaymentMethod.Parameters[0].Type == ContractParameterType.Hash160 && + onNEP17PaymentMethod.Parameters[1].Type == ContractParameterType.Integer && + onNEP17PaymentMethod.Parameters[2].Type == ContractParameterType.Any; + + if (!onNEP17PaymentValid) throw new CompilationException(DiagnosticId.IncorrectNEPStandard, + $"Incomplete NEP standard {NepStandard.Nep17Payable.ToStandard()} implementation: onNEP17Payment"); + } + catch (Exception ex) when (ex is not CompilationException) + { + throw new CompilationException(DiagnosticId.IncorrectNEPStandard, $"Incomplete NEP standard {NepStandard.Nep17Payable.ToStandard()} implementation: Unidentified issue."); + } + } + internal static ContractManifest CheckStandards(this ContractManifest manifest) { if (manifest.SupportedStandards.Contains(NepStandard.Nep11.ToStandard())) @@ -175,6 +213,16 @@ internal static ContractManifest CheckStandards(this ContractManifest manifest) manifest.CheckNep17Compliant(); } + if (manifest.SupportedStandards.Contains(NepStandard.Nep11Payable.ToStandard())) + { + manifest.CheckNep11PayableCompliant(); + } + + if (manifest.SupportedStandards.Contains(NepStandard.Nep17Payable.ToStandard())) + { + manifest.CheckNep17PayableCompliant(); + } + return manifest; } } diff --git a/src/Neo.SmartContract.Framework/NEPStandard.cs b/src/Neo.SmartContract.Framework/NEPStandard.cs index b22771ca3..0f271da14 100644 --- a/src/Neo.SmartContract.Framework/NEPStandard.cs +++ b/src/Neo.SmartContract.Framework/NEPStandard.cs @@ -7,7 +7,19 @@ public enum NepStandard Nep11, // The NEP-17 standard is used for fungible tokens. // Defined at https://github.com/neo-project/proposals/blob/master/nep-17.mediawiki - Nep17 + Nep17, + // Smart contract transfer callback for non-fungible tokens (NFTs). + // This is an extension standard of NEP-11. + // Defined at https://github.com/neo-project/proposals/pull/169/files#diff-2b5f7c12a23f7dbe4cb46bbf4be6936882f8e0f0b3a4db9d8c58eb294b02e6ed + Nep11_Y, + // This is the nick name of NEP-11-Y. + Nep11Payable, + // Smart contract transfer callback for fungible tokens. + // This is an extension standard of NEP-17. + // Defined at https://github.com/neo-project/proposals/pull/169/files#diff-70768f307c9aa84f8c94e790495a76d47fffeca2331444592ebba6f13b1e6460 + Nep17_Z, + // This is the nick name of NEP-17-Z. + Nep17Payable, } public static class NepStandardExtensions @@ -20,6 +32,12 @@ public static string ToStandard(this NepStandard standard) return "NEP-11"; case NepStandard.Nep17: return "NEP-17"; + case NepStandard.Nep11Payable: + case NepStandard.Nep11_Y: + return "NEP-11-Y"; + case NepStandard.Nep17Payable: + case NepStandard.Nep17_Z: + return "NEP-17-Z"; default: return standard.ToString(); } diff --git a/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Payable.cs b/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Payable.cs new file mode 100644 index 000000000..fa125bee1 --- /dev/null +++ b/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Payable.cs @@ -0,0 +1,20 @@ +using Neo.SmartContract.Framework.Attributes; +using System.ComponentModel; +using System.Numerics; +using Neo.SmartContract.Framework.Interfaces; + +namespace Neo.SmartContract.Framework.TestContracts +{ + [DisplayName(nameof(Contract_SupportedStandard11Payable))] + [ContractDescription("")] + [ContractAuthor("", "")] + [ContractVersion("")] + [ContractPermission(Permission.WildCard, Method.WildCard)] + [SupportedStandards(NepStandard.Nep11Payable)] + public class Contract_SupportedStandard11Payable : SmartContract, INep11Payable + { + public void OnNEP11Payment(UInt160 from, BigInteger amount, object? data = null) + { + } + } +} diff --git a/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard17Payable.cs b/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard17Payable.cs new file mode 100644 index 000000000..460f487ab --- /dev/null +++ b/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard17Payable.cs @@ -0,0 +1,20 @@ +using Neo.SmartContract.Framework.Attributes; +using System.ComponentModel; +using System.Numerics; +using Neo.SmartContract.Framework.Interfaces; + +namespace Neo.SmartContract.Framework.TestContracts +{ + [DisplayName(nameof(Contract_SupportedStandard17Payable))] + [ContractDescription("")] + [ContractAuthor("", "")] + [ContractVersion("")] + [ContractPermission(Permission.WildCard, Method.WildCard)] + [SupportedStandards(NepStandard.Nep17Payable)] + public class Contract_SupportedStandard17Payable : SmartContract, INep17Payable + { + public void OnNEP17Payment(UInt160 from, BigInteger amount, object? data = null) + { + } + } +} diff --git a/tests/Neo.SmartContract.Framework.UnitTests/SupportedStandardsTest.cs b/tests/Neo.SmartContract.Framework.UnitTests/SupportedStandardsTest.cs index fc38dc99a..707f94119 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/SupportedStandardsTest.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/SupportedStandardsTest.cs @@ -23,5 +23,17 @@ public void TestStandardNEP17AttributeEnum() { CollectionAssert.AreEqual(Contract_SupportedStandard17Enum.Manifest.SupportedStandards, new string[] { "NEP-17" }); } + + [TestMethod] + public void TestStandardNEP11PayableAttribute() + { + CollectionAssert.AreEqual(Contract_SupportedStandard11Payable.Manifest.SupportedStandards, new string[] { "NEP-11-Y" }); + } + + [TestMethod] + public void TestStandardNEP17PayableAttribute() + { + CollectionAssert.AreEqual(Contract_SupportedStandard17Payable.Manifest.SupportedStandards, new string[] { "NEP-17-Z" }); + } } } diff --git a/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs new file mode 100644 index 000000000..e04cb0d7f --- /dev/null +++ b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs @@ -0,0 +1,34 @@ +using Neo.Cryptography.ECC; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Numerics; + +namespace Neo.SmartContract.Testing; + +public abstract class Contract_SupportedStandard11Payable : Neo.SmartContract.Testing.SmartContract +{ + #region Compiled data + + public static readonly Neo.SmartContract.Manifest.ContractManifest Manifest = Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_SupportedStandard11Payable"",""groups"":[],""features"":{},""supportedstandards"":[""NEP-11-Y""],""abi"":{""methods"":[{""name"":""onNEP11Payment"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""data"",""type"":""Any""}],""returntype"":""Void"",""offset"":15,""safe"":false}],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""extra"":{""Description"":""\u003CDescription Here\u003E"",""Author"":""\u003CYour Name Or Company Here\u003E"",""Version"":""\u003CVersion String Here\u003E""}}"); + + public static readonly Neo.SmartContract.NefFile Nef = Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVXAARAVwABeDQDQFcAAUDCSjTzIu3rbva0")); + + #endregion + + #region Unsafe methods + + /// + /// Unsafe method + /// + [DisplayName("onNEP11Payment")] + public abstract void OnNEP11Payment(UInt160? from, BigInteger? amount, object? data = null); + + #endregion + + #region Constructor for internal use only + + protected Contract_SupportedStandard11Payable(Neo.SmartContract.Testing.SmartContractInitialize initialize) : base(initialize) { } + + #endregion +} diff --git a/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard17Payable.cs b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard17Payable.cs new file mode 100644 index 000000000..17d5a54d5 --- /dev/null +++ b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard17Payable.cs @@ -0,0 +1,34 @@ +using Neo.Cryptography.ECC; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Numerics; + +namespace Neo.SmartContract.Testing; + +public abstract class Contract_SupportedStandard17Payable : Neo.SmartContract.Testing.SmartContract +{ + #region Compiled data + + public static readonly Neo.SmartContract.Manifest.ContractManifest Manifest = Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_SupportedStandard17Payable"",""groups"":[],""features"":{},""supportedstandards"":[""NEP-17-Z""],""abi"":{""methods"":[{""name"":""onNEP17Payment"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""data"",""type"":""Any""}],""returntype"":""Void"",""offset"":15,""safe"":false}],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""extra"":{""Description"":""\u003CDescription Here\u003E"",""Author"":""\u003CYour Name Or Company Here\u003E"",""Version"":""\u003CVersion String Here\u003E""}}"); + + public static readonly Neo.SmartContract.NefFile Nef = Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVXAARAVwABeDQDQFcAAUDCSjTzIu3rbva0")); + + #endregion + + #region Unsafe methods + + /// + /// Unsafe method + /// + [DisplayName("onNEP17Payment")] + public abstract void OnNEP17Payment(UInt160? from, BigInteger? amount, object? data = null); + + #endregion + + #region Constructor for internal use only + + protected Contract_SupportedStandard17Payable(Neo.SmartContract.Testing.SmartContractInitialize initialize) : base(initialize) { } + + #endregion +} From a1a950a3bef5034767c0565bef430d8d0d878f90 Mon Sep 17 00:00:00 2001 From: Jim8y Date: Wed, 22 May 2024 06:52:32 +0800 Subject: [PATCH 2/7] adopt NEP25 and NEP26 --- src/Neo.SmartContract.Framework/NEPStandard.cs | 12 ++++++------ .../SupportedStandardsTest.cs | 4 ++-- .../Contract_SupportedStandard11Payable.cs | 2 +- .../Contract_SupportedStandard17Payable.cs | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Neo.SmartContract.Framework/NEPStandard.cs b/src/Neo.SmartContract.Framework/NEPStandard.cs index f1da67d14..a72b0230a 100644 --- a/src/Neo.SmartContract.Framework/NEPStandard.cs +++ b/src/Neo.SmartContract.Framework/NEPStandard.cs @@ -22,14 +22,14 @@ public enum NepStandard // Smart contract transfer callback for non-fungible tokens (NFTs). // This is an extension standard of NEP-11. // Defined at https://github.com/neo-project/proposals/pull/169/files#diff-2b5f7c12a23f7dbe4cb46bbf4be6936882f8e0f0b3a4db9d8c58eb294b02e6ed - Nep11_Y, - // This is the nick name of NEP-11-Y. + Nep25, + // This is the nick name of NEP-25. Nep11Payable, // Smart contract transfer callback for fungible tokens. // This is an extension standard of NEP-17. // Defined at https://github.com/neo-project/proposals/pull/169/files#diff-70768f307c9aa84f8c94e790495a76d47fffeca2331444592ebba6f13b1e6460 - Nep17_Z, - // This is the nick name of NEP-17-Z. + Nep26, + // This is the nick name of NEP-26. Nep17Payable, // This NEP defines a global standard to get royalty payment information for Non-Fungible Tokens (NFTs) // in order to enable support for royalty payments across all NFT marketplaces in the NEO Smart Economy. @@ -46,8 +46,8 @@ public static string ToStandard(this NepStandard standard) { NepStandard.Nep11 => "NEP-11", NepStandard.Nep17 => "NEP-17", - NepStandard.Nep11Payable or NepStandard.Nep11_Y => "NEP-11-Y", - NepStandard.Nep17Payable or NepStandard.Nep17_Z => "NEP-17-Z", + NepStandard.Nep11Payable or NepStandard.Nep25 => "NEP-25", + NepStandard.Nep17Payable or NepStandard.Nep26 => "NEP-26", NepStandard.Nep24 => "NEP-24", _ => standard.ToString() }; diff --git a/tests/Neo.SmartContract.Framework.UnitTests/SupportedStandardsTest.cs b/tests/Neo.SmartContract.Framework.UnitTests/SupportedStandardsTest.cs index 707f94119..bd1dc8427 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/SupportedStandardsTest.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/SupportedStandardsTest.cs @@ -27,13 +27,13 @@ public void TestStandardNEP17AttributeEnum() [TestMethod] public void TestStandardNEP11PayableAttribute() { - CollectionAssert.AreEqual(Contract_SupportedStandard11Payable.Manifest.SupportedStandards, new string[] { "NEP-11-Y" }); + CollectionAssert.AreEqual(Contract_SupportedStandard11Payable.Manifest.SupportedStandards, new string[] { "NEP-25" }); } [TestMethod] public void TestStandardNEP17PayableAttribute() { - CollectionAssert.AreEqual(Contract_SupportedStandard17Payable.Manifest.SupportedStandards, new string[] { "NEP-17-Z" }); + CollectionAssert.AreEqual(Contract_SupportedStandard17Payable.Manifest.SupportedStandards, new string[] { "NEP-26" }); } } } diff --git a/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs index e04cb0d7f..e57ecfd06 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs @@ -10,7 +10,7 @@ public abstract class Contract_SupportedStandard11Payable : Neo.SmartContract.Te { #region Compiled data - public static readonly Neo.SmartContract.Manifest.ContractManifest Manifest = Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_SupportedStandard11Payable"",""groups"":[],""features"":{},""supportedstandards"":[""NEP-11-Y""],""abi"":{""methods"":[{""name"":""onNEP11Payment"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""data"",""type"":""Any""}],""returntype"":""Void"",""offset"":15,""safe"":false}],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""extra"":{""Description"":""\u003CDescription Here\u003E"",""Author"":""\u003CYour Name Or Company Here\u003E"",""Version"":""\u003CVersion String Here\u003E""}}"); + public static readonly Neo.SmartContract.Manifest.ContractManifest Manifest = Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_SupportedStandard11Payable"",""groups"":[],""features"":{},""supportedstandards"":[""NEP-25""],""abi"":{""methods"":[{""name"":""onNEP11Payment"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""data"",""type"":""Any""}],""returntype"":""Void"",""offset"":15,""safe"":false}],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""extra"":{""Description"":""\u003CDescription Here\u003E"",""Author"":""\u003CYour Name Or Company Here\u003E"",""Version"":""\u003CVersion String Here\u003E""}}"); public static readonly Neo.SmartContract.NefFile Nef = Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVXAARAVwABeDQDQFcAAUDCSjTzIu3rbva0")); diff --git a/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard17Payable.cs b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard17Payable.cs index 17d5a54d5..170d12f99 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard17Payable.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard17Payable.cs @@ -10,7 +10,7 @@ public abstract class Contract_SupportedStandard17Payable : Neo.SmartContract.Te { #region Compiled data - public static readonly Neo.SmartContract.Manifest.ContractManifest Manifest = Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_SupportedStandard17Payable"",""groups"":[],""features"":{},""supportedstandards"":[""NEP-17-Z""],""abi"":{""methods"":[{""name"":""onNEP17Payment"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""data"",""type"":""Any""}],""returntype"":""Void"",""offset"":15,""safe"":false}],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""extra"":{""Description"":""\u003CDescription Here\u003E"",""Author"":""\u003CYour Name Or Company Here\u003E"",""Version"":""\u003CVersion String Here\u003E""}}"); + public static readonly Neo.SmartContract.Manifest.ContractManifest Manifest = Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_SupportedStandard17Payable"",""groups"":[],""features"":{},""supportedstandards"":[""NEP-26""],""abi"":{""methods"":[{""name"":""onNEP17Payment"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""data"",""type"":""Any""}],""returntype"":""Void"",""offset"":15,""safe"":false}],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""extra"":{""Description"":""\u003CDescription Here\u003E"",""Author"":""\u003CYour Name Or Company Here\u003E"",""Version"":""\u003CVersion String Here\u003E""}}"); public static readonly Neo.SmartContract.NefFile Nef = Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVXAARAVwABeDQDQFcAAUDCSjTzIu3rbva0")); From 8795eeb74275c0a8c6778b4a1e154be4ff8df99e Mon Sep 17 00:00:00 2001 From: Shargon Date: Wed, 22 May 2024 09:49:58 +0200 Subject: [PATCH 3/7] Apply suggestions from code review --- .../Contract_SupportedStandard11Payable.cs | 2 +- .../Contract_SupportedStandard17Payable.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Payable.cs b/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Payable.cs index fa125bee1..0fb7be043 100644 --- a/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Payable.cs +++ b/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Payable.cs @@ -9,7 +9,7 @@ namespace Neo.SmartContract.Framework.TestContracts [ContractDescription("")] [ContractAuthor("", "")] [ContractVersion("")] - [ContractPermission(Permission.WildCard, Method.WildCard)] + [ContractPermission(Permission.Any, Method.Any)] [SupportedStandards(NepStandard.Nep11Payable)] public class Contract_SupportedStandard11Payable : SmartContract, INep11Payable { diff --git a/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard17Payable.cs b/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard17Payable.cs index 460f487ab..0b9977dea 100644 --- a/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard17Payable.cs +++ b/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard17Payable.cs @@ -9,7 +9,7 @@ namespace Neo.SmartContract.Framework.TestContracts [ContractDescription("")] [ContractAuthor("", "")] [ContractVersion("")] - [ContractPermission(Permission.WildCard, Method.WildCard)] + [ContractPermission(Permission.Any, Method.Any)] [SupportedStandards(NepStandard.Nep17Payable)] public class Contract_SupportedStandard17Payable : SmartContract, INep17Payable { From f37b86d493226b83c2f681fb6eb4e7079a9f8e4c Mon Sep 17 00:00:00 2001 From: Fernando Diaz Toledano Date: Wed, 22 May 2024 10:33:27 +0200 Subject: [PATCH 4/7] Fix nep11 --- src/Neo.Compiler.CSharp/ContractManifestExtension.cs | 5 +++-- src/Neo.SmartContract.Framework/Interfaces/INEP11Payable.cs | 3 ++- .../Contract_SupportedStandard11Payable.cs | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Neo.Compiler.CSharp/ContractManifestExtension.cs b/src/Neo.Compiler.CSharp/ContractManifestExtension.cs index bb2904d87..a4f977e15 100644 --- a/src/Neo.Compiler.CSharp/ContractManifestExtension.cs +++ b/src/Neo.Compiler.CSharp/ContractManifestExtension.cs @@ -167,11 +167,12 @@ private static void CheckNep11PayableCompliant(this ContractManifest manifest) { try { - var onNEP11PaymentMethod = manifest.Abi.GetMethod("onNEP11Payment", 3); + var onNEP11PaymentMethod = manifest.Abi.GetMethod("onNEP11Payment", 4); var onNEP11PaymentValid = onNEP11PaymentMethod is { Safe: false, ReturnType: ContractParameterType.Void } && onNEP11PaymentMethod.Parameters[0].Type == ContractParameterType.Hash160 && onNEP11PaymentMethod.Parameters[1].Type == ContractParameterType.Integer && - onNEP11PaymentMethod.Parameters[2].Type == ContractParameterType.Any; + onNEP11PaymentMethod.Parameters[2].Type == ContractParameterType.String && + onNEP11PaymentMethod.Parameters[3].Type == ContractParameterType.Any; if (!onNEP11PaymentValid) throw new CompilationException(DiagnosticId.IncorrectNEPStandard, $"Incomplete NEP standard {NepStandard.Nep11Payable.ToStandard()} implementation: onNEP11Payment"); diff --git a/src/Neo.SmartContract.Framework/Interfaces/INEP11Payable.cs b/src/Neo.SmartContract.Framework/Interfaces/INEP11Payable.cs index 8cbde24c2..8a87e121b 100644 --- a/src/Neo.SmartContract.Framework/Interfaces/INEP11Payable.cs +++ b/src/Neo.SmartContract.Framework/Interfaces/INEP11Payable.cs @@ -26,6 +26,7 @@ public interface INep11Payable /// /// The address of the payer /// The amount of token to be transferred + /// The token id to be transferred /// Additional payment description data /// /// This interface method is defined as non-static, @@ -34,5 +35,5 @@ public interface INep11Payable /// Both static and non-static methods of smart contract interface works, /// they differs on how you process static field. /// - public void OnNEP11Payment(UInt160 from, BigInteger amount, object? data = null); + public void OnNEP11Payment(UInt160 from, BigInteger amount, string tokenId, object? data = null); } diff --git a/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Payable.cs b/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Payable.cs index 0fb7be043..800669059 100644 --- a/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Payable.cs +++ b/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Payable.cs @@ -13,7 +13,7 @@ namespace Neo.SmartContract.Framework.TestContracts [SupportedStandards(NepStandard.Nep11Payable)] public class Contract_SupportedStandard11Payable : SmartContract, INep11Payable { - public void OnNEP11Payment(UInt160 from, BigInteger amount, object? data = null) + public void OnNEP11Payment(UInt160 from, BigInteger amount, string tokenId, object? data = null) { } } From 8670f7118a482357a585671c29df1eb958572ea7 Mon Sep 17 00:00:00 2001 From: Fernando Diaz Toledano Date: Wed, 22 May 2024 10:34:16 +0200 Subject: [PATCH 5/7] Remove safe check --- src/Neo.Compiler.CSharp/ContractManifestExtension.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Neo.Compiler.CSharp/ContractManifestExtension.cs b/src/Neo.Compiler.CSharp/ContractManifestExtension.cs index a4f977e15..bf696f550 100644 --- a/src/Neo.Compiler.CSharp/ContractManifestExtension.cs +++ b/src/Neo.Compiler.CSharp/ContractManifestExtension.cs @@ -168,7 +168,7 @@ private static void CheckNep11PayableCompliant(this ContractManifest manifest) try { var onNEP11PaymentMethod = manifest.Abi.GetMethod("onNEP11Payment", 4); - var onNEP11PaymentValid = onNEP11PaymentMethod is { Safe: false, ReturnType: ContractParameterType.Void } && + var onNEP11PaymentValid = onNEP11PaymentMethod is { ReturnType: ContractParameterType.Void } && onNEP11PaymentMethod.Parameters[0].Type == ContractParameterType.Hash160 && onNEP11PaymentMethod.Parameters[1].Type == ContractParameterType.Integer && onNEP11PaymentMethod.Parameters[2].Type == ContractParameterType.String && @@ -188,7 +188,7 @@ private static void CheckNep17PayableCompliant(this ContractManifest manifest) try { var onNEP17PaymentMethod = manifest.Abi.GetMethod("onNEP17Payment", 3); - var onNEP17PaymentValid = onNEP17PaymentMethod is { Safe: false, ReturnType: ContractParameterType.Void } && + var onNEP17PaymentValid = onNEP17PaymentMethod is { ReturnType: ContractParameterType.Void } && onNEP17PaymentMethod.Parameters[0].Type == ContractParameterType.Hash160 && onNEP17PaymentMethod.Parameters[1].Type == ContractParameterType.Integer && onNEP17PaymentMethod.Parameters[2].Type == ContractParameterType.Any; From 9148455209a094a7b1598ed9e1236212785a1355 Mon Sep 17 00:00:00 2001 From: Jim8y Date: Wed, 22 May 2024 17:47:36 +0800 Subject: [PATCH 6/7] fix onnep11payable --- .../Contract_SupportedStandard11Enum.cs | 2 +- .../TestingArtifacts/Contract_SupportedStandard11Enum.cs | 6 +++--- .../TestingArtifacts/Contract_SupportedStandard11Payable.cs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Enum.cs b/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Enum.cs index 980a1beb1..0ad716ab1 100644 --- a/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Enum.cs +++ b/tests/Neo.SmartContract.Framework.TestContracts/Contract_SupportedStandard11Enum.cs @@ -14,7 +14,7 @@ public static bool TestStandard() public override string Symbol { [Safe] get; } = "EXAMPLE"; - public void OnNEP11Payment(UInt160 from, BigInteger amount, object? data = null) + public void OnNEP11Payment(UInt160 from, BigInteger amount, string tokenId, object? data = null) { } } diff --git a/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Enum.cs b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Enum.cs index 7d60c9fb4..c2d5316b9 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Enum.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Enum.cs @@ -10,9 +10,9 @@ public abstract class Contract_SupportedStandard11Enum : Neo.SmartContract.Testi { #region Compiled data - public static readonly Neo.SmartContract.Manifest.ContractManifest Manifest = Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_SupportedStandard11Enum"",""groups"":[],""features"":{},""supportedstandards"":[""NEP-11""],""abi"":{""methods"":[{""name"":""symbol"",""parameters"":[],""returntype"":""String"",""offset"":953,""safe"":true},{""name"":""decimals"",""parameters"":[],""returntype"":""Integer"",""offset"":970,""safe"":true},{""name"":""totalSupply"",""parameters"":[],""returntype"":""Integer"",""offset"":45,""safe"":true},{""name"":""balanceOf"",""parameters"":[{""name"":""owner"",""type"":""Hash160""}],""returntype"":""Integer"",""offset"":71,""safe"":true},{""name"":""ownerOf"",""parameters"":[{""name"":""tokenId"",""type"":""ByteArray""}],""returntype"":""Hash160"",""offset"":267,""safe"":true},{""name"":""properties"",""parameters"":[{""name"":""tokenId"",""type"":""ByteArray""}],""returntype"":""Map"",""offset"":985,""safe"":true},{""name"":""tokens"",""parameters"":[],""returntype"":""InteropInterface"",""offset"":472,""safe"":true},{""name"":""tokensOf"",""parameters"":[{""name"":""owner"",""type"":""Hash160""}],""returntype"":""InteropInterface"",""offset"":502,""safe"":true},{""name"":""transfer"",""parameters"":[{""name"":""to"",""type"":""Hash160""},{""name"":""tokenId"",""type"":""ByteArray""},{""name"":""data"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":595,""safe"":false},{""name"":""testStandard"",""parameters"":[],""returntype"":""Boolean"",""offset"":908,""safe"":false},{""name"":""onNEP11Payment"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""data"",""type"":""Any""}],""returntype"":""Void"",""offset"":1000,""safe"":false},{""name"":""_initialize"",""parameters"":[],""returntype"":""Void"",""offset"":918,""safe"":false}],""events"":[{""name"":""Transfer"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""to"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""tokenId"",""type"":""ByteArray""}]}]},""permissions"":[{""contract"":""0x726cb6e0cd8628a1350a611384688911ab75f51b"",""methods"":[""sha256""]},{""contract"":""0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0"",""methods"":[""deserialize"",""serialize""]},{""contract"":""0xfffdc93764dbaddd97c48f252a53ea4643faa3fd"",""methods"":[""getContract""]},{""contract"":""*"",""methods"":[""onNEP11Payment""]}],""trusts"":[],""extra"":{}}"); + public static readonly Neo.SmartContract.Manifest.ContractManifest Manifest = Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_SupportedStandard11Enum"",""groups"":[],""features"":{},""supportedstandards"":[""NEP-11""],""abi"":{""methods"":[{""name"":""symbol"",""parameters"":[],""returntype"":""String"",""offset"":953,""safe"":true},{""name"":""decimals"",""parameters"":[],""returntype"":""Integer"",""offset"":970,""safe"":true},{""name"":""totalSupply"",""parameters"":[],""returntype"":""Integer"",""offset"":45,""safe"":true},{""name"":""balanceOf"",""parameters"":[{""name"":""owner"",""type"":""Hash160""}],""returntype"":""Integer"",""offset"":71,""safe"":true},{""name"":""ownerOf"",""parameters"":[{""name"":""tokenId"",""type"":""ByteArray""}],""returntype"":""Hash160"",""offset"":267,""safe"":true},{""name"":""properties"",""parameters"":[{""name"":""tokenId"",""type"":""ByteArray""}],""returntype"":""Map"",""offset"":985,""safe"":true},{""name"":""tokens"",""parameters"":[],""returntype"":""InteropInterface"",""offset"":472,""safe"":true},{""name"":""tokensOf"",""parameters"":[{""name"":""owner"",""type"":""Hash160""}],""returntype"":""InteropInterface"",""offset"":502,""safe"":true},{""name"":""transfer"",""parameters"":[{""name"":""to"",""type"":""Hash160""},{""name"":""tokenId"",""type"":""ByteArray""},{""name"":""data"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":595,""safe"":false},{""name"":""testStandard"",""parameters"":[],""returntype"":""Boolean"",""offset"":908,""safe"":false},{""name"":""onNEP11Payment"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""tokenId"",""type"":""String""},{""name"":""data"",""type"":""Any""}],""returntype"":""Void"",""offset"":1000,""safe"":false},{""name"":""_initialize"",""parameters"":[],""returntype"":""Void"",""offset"":918,""safe"":false}],""events"":[{""name"":""Transfer"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""to"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""tokenId"",""type"":""ByteArray""}]}]},""permissions"":[{""contract"":""0x726cb6e0cd8628a1350a611384688911ab75f51b"",""methods"":[""sha256""]},{""contract"":""0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0"",""methods"":[""deserialize"",""serialize""]},{""contract"":""0xfffdc93764dbaddd97c48f252a53ea4643faa3fd"",""methods"":[""getContract""]},{""contract"":""*"",""methods"":[""onNEP11Payment""]}],""trusts"":[],""extra"":{}}"); - public static readonly Neo.SmartContract.NefFile Nef = Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATA7znO4OTpJcbCoGp54UQN2G/OrAtkZXNlcmlhbGl6ZQEAAQ/A7znO4OTpJcbCoGp54UQN2G/OrAlzZXJpYWxpemUBAAEP/aP6Q0bqUyolj8SX3a3bZDfJ/f8LZ2V0Q29udHJhY3QBAAEPG/V1qxGJaIQTYQo1oSiGzeC2bHIGc2hhMjU2AQABDwAA/fYDEM5AVwABeBAMB0VYQU1QTEXQeDQDQFcAAXg0A0BXAAF4NANAVwABQFcAARBAWtgmFwwBAEH2tGviQZJd6DFK2CYERRBKYkBXAQF4cGgLlyYHEdsgIg14StkoUMoAFLOrqiYlDCBUaGUgYXJndW1lbnQgIm93bmVyIiBpcyBpbnZhbGlkLjpBm/ZnzhERiE4QUdBQEsBweGjBRVOLUEGSXegxStgmBEUQ2yEiAkBXAgJBm/ZnzhERiE4QUdBQEsBweGjBRVOLUEGSXegxStgmBEUQ2yFxaXmeSnFFaRC1JgcQ2yAiJ2kQsyYQeGjBRVOLUEEvWMXtIg9peGjBRVOLUEHmPxiEEdsgIgJAVwMBeMoAQLcmPAw3VGhlIGFyZ3VtZW50ICJ0b2tlbklkIiBzaG91bGQgYmUgNjQgb3IgbGVzcyBieXRlcyBsb25nLjoTEYhOEFHQQZv2Z84SwHB4aMFFU4tQQZJd6DFK2CY0RQwuVGhlIHRva2VuIHdpdGggZ2l2ZW4gInRva2VuSWQiIGRvZXMgbm90IGV4aXN0LjpxaTcAAHJqEM4iAkBXAgITEYhOEFHQQZv2Z84SwHB5aMFFU4tQQZJd6DE3AABxyGkRzktT0CICQFcBABMRiE4QUdBBm/ZnzhLAcBNowUVB3zC4miICQFcBAXhwaAuXJgcR2yAiDXhK2ShQygAUs6uqJiQMH1RoZSBhcmd1bWVudCAib3duZXIiIGlzIGludmFsaWQ6FBGIThBR0EGb9mfOEsBwE3howUVTi1BB3zC4miICQFcDA3hwaAuXJgcR2yAiDXhK2ShQygAUs6uqJiIMHVRoZSBhcmd1bWVudCAidG8iIGlzIGludmFsaWQuOhMRiE4QUdBBm/ZnzhLAcHlowUVTi1BBkl3oMTcAAHFpEM5yakH4J+yMqiYHENsgIjVqeJgmJXhKaRBR0EVpNwEASnlowUVTi1BB5j8YhEUPeWo0ExF5eDQOenl4ajRKEdsgIgJAVwIDeng1tP3//0VBm/ZnzhQRiE4QUdBQEsBweHmL2yhxehC3JhEQaWjBRVOLUEHmPxiEIg5paMFFU4tQQS9Yxe1AVwEEwkp4z0p5z0oRz0p6zwwIVHJhbnNmZXJBlQFvYXlwaAuXqiQHENsgIgt5NwIAcGgLl6omIHt6EXgUwB8MDm9uTkVQMTFQYXltZW50eUFifVtSRUAR2yAiAkBXAARAVgMKFP7//wqL/P//Cl78//8TwGAKAv7//wp5/P//CxPAYUALEcBKWM9KNUP8//8jO/z//8JKWc9KNUf8//8jVPz//8JKWc9KNTj8//8jyf3//wsRwEpYz0o1FPz//yKeK4TEhA==")); + public static readonly Neo.SmartContract.NefFile Nef = Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATA7znO4OTpJcbCoGp54UQN2G/OrAtkZXNlcmlhbGl6ZQEAAQ/A7znO4OTpJcbCoGp54UQN2G/OrAlzZXJpYWxpemUBAAEP/aP6Q0bqUyolj8SX3a3bZDfJ/f8LZ2V0Q29udHJhY3QBAAEPG/V1qxGJaIQTYQo1oSiGzeC2bHIGc2hhMjU2AQABDwAA/fYDEM5AVwABeBAMB0VYQU1QTEXQeDQDQFcAAXg0A0BXAAF4NANAVwABQFcAARBAWtgmFwwBAEH2tGviQZJd6DFK2CYERRBKYkBXAQF4cGgLlyYHEdsgIg14StkoUMoAFLOrqiYlDCBUaGUgYXJndW1lbnQgIm93bmVyIiBpcyBpbnZhbGlkLjpBm/ZnzhERiE4QUdBQEsBweGjBRVOLUEGSXegxStgmBEUQ2yEiAkBXAgJBm/ZnzhERiE4QUdBQEsBweGjBRVOLUEGSXegxStgmBEUQ2yFxaXmeSnFFaRC1JgcQ2yAiJ2kQsyYQeGjBRVOLUEEvWMXtIg9peGjBRVOLUEHmPxiEEdsgIgJAVwMBeMoAQLcmPAw3VGhlIGFyZ3VtZW50ICJ0b2tlbklkIiBzaG91bGQgYmUgNjQgb3IgbGVzcyBieXRlcyBsb25nLjoTEYhOEFHQQZv2Z84SwHB4aMFFU4tQQZJd6DFK2CY0RQwuVGhlIHRva2VuIHdpdGggZ2l2ZW4gInRva2VuSWQiIGRvZXMgbm90IGV4aXN0LjpxaTcAAHJqEM4iAkBXAgITEYhOEFHQQZv2Z84SwHB5aMFFU4tQQZJd6DE3AABxyGkRzktT0CICQFcBABMRiE4QUdBBm/ZnzhLAcBNowUVB3zC4miICQFcBAXhwaAuXJgcR2yAiDXhK2ShQygAUs6uqJiQMH1RoZSBhcmd1bWVudCAib3duZXIiIGlzIGludmFsaWQ6FBGIThBR0EGb9mfOEsBwE3howUVTi1BB3zC4miICQFcDA3hwaAuXJgcR2yAiDXhK2ShQygAUs6uqJiIMHVRoZSBhcmd1bWVudCAidG8iIGlzIGludmFsaWQuOhMRiE4QUdBBm/ZnzhLAcHlowUVTi1BBkl3oMTcAAHFpEM5yakH4J+yMqiYHENsgIjVqeJgmJXhKaRBR0EVpNwEASnlowUVTi1BB5j8YhEUPeWo0ExF5eDQOenl4ajRKEdsgIgJAVwIDeng1tP3//0VBm/ZnzhQRiE4QUdBQEsBweHmL2yhxehC3JhEQaWjBRVOLUEHmPxiEIg5paMFFU4tQQS9Yxe1AVwEEwkp4z0p5z0oRz0p6zwwIVHJhbnNmZXJBlQFvYXlwaAuXqiQHENsgIgt5NwIAcGgLl6omIHt6EXgUwB8MDm9uTkVQMTFQYXltZW50eUFifVtSRUAR2yAiAkBXAAVAVgMKFP7//wqL/P//Cl78//8TwGAKAv7//wp5/P//CxPAYUALEcBKWM9KNUP8//8jO/z//8JKWc9KNUf8//8jVPz//8JKWc9KNTj8//8jyf3//wsRwEpYz0o1FPz//yKevncGMg==")); #endregion @@ -83,7 +83,7 @@ public abstract class Contract_SupportedStandard11Enum : Neo.SmartContract.Testi /// Unsafe method /// [DisplayName("onNEP11Payment")] - public abstract void OnNEP11Payment(UInt160? from, BigInteger? amount, object? data = null); + public abstract void OnNEP11Payment(UInt160? from, BigInteger? amount, string? tokenId, object? data = null); /// /// Unsafe method diff --git a/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs index e57ecfd06..1d60a9a13 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs @@ -10,9 +10,9 @@ public abstract class Contract_SupportedStandard11Payable : Neo.SmartContract.Te { #region Compiled data - public static readonly Neo.SmartContract.Manifest.ContractManifest Manifest = Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_SupportedStandard11Payable"",""groups"":[],""features"":{},""supportedstandards"":[""NEP-25""],""abi"":{""methods"":[{""name"":""onNEP11Payment"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""data"",""type"":""Any""}],""returntype"":""Void"",""offset"":15,""safe"":false}],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""extra"":{""Description"":""\u003CDescription Here\u003E"",""Author"":""\u003CYour Name Or Company Here\u003E"",""Version"":""\u003CVersion String Here\u003E""}}"); + public static readonly Neo.SmartContract.Manifest.ContractManifest Manifest = Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_SupportedStandard11Payable"",""groups"":[],""features"":{},""supportedstandards"":[""NEP-25""],""abi"":{""methods"":[{""name"":""onNEP11Payment"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""tokenId"",""type"":""String""},{""name"":""data"",""type"":""Any""}],""returntype"":""Void"",""offset"":15,""safe"":false}],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""extra"":{""Description"":""\u003CDescription Here\u003E"",""Author"":""\u003CYour Name Or Company Here\u003E"",""Version"":""\u003CVersion String Here\u003E""}}"); - public static readonly Neo.SmartContract.NefFile Nef = Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVXAARAVwABeDQDQFcAAUDCSjTzIu3rbva0")); + public static readonly Neo.SmartContract.NefFile Nef = Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVXAAVAVwABeDQDQFcAAUDCSjTzIu1tevRy")); #endregion @@ -22,7 +22,7 @@ public abstract class Contract_SupportedStandard11Payable : Neo.SmartContract.Te /// Unsafe method /// [DisplayName("onNEP11Payment")] - public abstract void OnNEP11Payment(UInt160? from, BigInteger? amount, object? data = null); + public abstract void OnNEP11Payment(UInt160? from, BigInteger? amount, string? tokenId, object? data = null); #endregion From bcf35f00055fda4fb49861eadf3740592a3cd304 Mon Sep 17 00:00:00 2001 From: Jim8y Date: Fri, 24 May 2024 08:52:51 +0800 Subject: [PATCH 7/7] use NEP 26 and NEP 27 --- src/Neo.SmartContract.Framework/NEPStandard.cs | 8 ++++---- .../SupportedStandardsTest.cs | 4 ++-- .../Contract_SupportedStandard11Payable.cs | 2 +- .../Contract_SupportedStandard17Payable.cs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Neo.SmartContract.Framework/NEPStandard.cs b/src/Neo.SmartContract.Framework/NEPStandard.cs index a72b0230a..ca6817815 100644 --- a/src/Neo.SmartContract.Framework/NEPStandard.cs +++ b/src/Neo.SmartContract.Framework/NEPStandard.cs @@ -22,13 +22,13 @@ public enum NepStandard // Smart contract transfer callback for non-fungible tokens (NFTs). // This is an extension standard of NEP-11. // Defined at https://github.com/neo-project/proposals/pull/169/files#diff-2b5f7c12a23f7dbe4cb46bbf4be6936882f8e0f0b3a4db9d8c58eb294b02e6ed - Nep25, + Nep26, // This is the nick name of NEP-25. Nep11Payable, // Smart contract transfer callback for fungible tokens. // This is an extension standard of NEP-17. // Defined at https://github.com/neo-project/proposals/pull/169/files#diff-70768f307c9aa84f8c94e790495a76d47fffeca2331444592ebba6f13b1e6460 - Nep26, + Nep27, // This is the nick name of NEP-26. Nep17Payable, // This NEP defines a global standard to get royalty payment information for Non-Fungible Tokens (NFTs) @@ -46,9 +46,9 @@ public static string ToStandard(this NepStandard standard) { NepStandard.Nep11 => "NEP-11", NepStandard.Nep17 => "NEP-17", - NepStandard.Nep11Payable or NepStandard.Nep25 => "NEP-25", - NepStandard.Nep17Payable or NepStandard.Nep26 => "NEP-26", NepStandard.Nep24 => "NEP-24", + NepStandard.Nep11Payable or NepStandard.Nep26 => "NEP-26", + NepStandard.Nep17Payable or NepStandard.Nep27 => "NEP-27", _ => standard.ToString() }; } diff --git a/tests/Neo.SmartContract.Framework.UnitTests/SupportedStandardsTest.cs b/tests/Neo.SmartContract.Framework.UnitTests/SupportedStandardsTest.cs index bd1dc8427..e2d356741 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/SupportedStandardsTest.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/SupportedStandardsTest.cs @@ -27,13 +27,13 @@ public void TestStandardNEP17AttributeEnum() [TestMethod] public void TestStandardNEP11PayableAttribute() { - CollectionAssert.AreEqual(Contract_SupportedStandard11Payable.Manifest.SupportedStandards, new string[] { "NEP-25" }); + CollectionAssert.AreEqual(Contract_SupportedStandard11Payable.Manifest.SupportedStandards, new string[] { "NEP-26" }); } [TestMethod] public void TestStandardNEP17PayableAttribute() { - CollectionAssert.AreEqual(Contract_SupportedStandard17Payable.Manifest.SupportedStandards, new string[] { "NEP-26" }); + CollectionAssert.AreEqual(Contract_SupportedStandard17Payable.Manifest.SupportedStandards, new string[] { "NEP-27" }); } } } diff --git a/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs index 1d60a9a13..bef090158 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard11Payable.cs @@ -10,7 +10,7 @@ public abstract class Contract_SupportedStandard11Payable : Neo.SmartContract.Te { #region Compiled data - public static readonly Neo.SmartContract.Manifest.ContractManifest Manifest = Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_SupportedStandard11Payable"",""groups"":[],""features"":{},""supportedstandards"":[""NEP-25""],""abi"":{""methods"":[{""name"":""onNEP11Payment"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""tokenId"",""type"":""String""},{""name"":""data"",""type"":""Any""}],""returntype"":""Void"",""offset"":15,""safe"":false}],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""extra"":{""Description"":""\u003CDescription Here\u003E"",""Author"":""\u003CYour Name Or Company Here\u003E"",""Version"":""\u003CVersion String Here\u003E""}}"); + public static readonly Neo.SmartContract.Manifest.ContractManifest Manifest = Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_SupportedStandard11Payable"",""groups"":[],""features"":{},""supportedstandards"":[""NEP-26""],""abi"":{""methods"":[{""name"":""onNEP11Payment"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""tokenId"",""type"":""String""},{""name"":""data"",""type"":""Any""}],""returntype"":""Void"",""offset"":15,""safe"":false}],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""extra"":{""Description"":""\u003CDescription Here\u003E"",""Author"":""\u003CYour Name Or Company Here\u003E"",""Version"":""\u003CVersion String Here\u003E""}}"); public static readonly Neo.SmartContract.NefFile Nef = Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVXAAVAVwABeDQDQFcAAUDCSjTzIu1tevRy")); diff --git a/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard17Payable.cs b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard17Payable.cs index 170d12f99..35b371918 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard17Payable.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/TestingArtifacts/Contract_SupportedStandard17Payable.cs @@ -10,7 +10,7 @@ public abstract class Contract_SupportedStandard17Payable : Neo.SmartContract.Te { #region Compiled data - public static readonly Neo.SmartContract.Manifest.ContractManifest Manifest = Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_SupportedStandard17Payable"",""groups"":[],""features"":{},""supportedstandards"":[""NEP-26""],""abi"":{""methods"":[{""name"":""onNEP17Payment"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""data"",""type"":""Any""}],""returntype"":""Void"",""offset"":15,""safe"":false}],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""extra"":{""Description"":""\u003CDescription Here\u003E"",""Author"":""\u003CYour Name Or Company Here\u003E"",""Version"":""\u003CVersion String Here\u003E""}}"); + public static readonly Neo.SmartContract.Manifest.ContractManifest Manifest = Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_SupportedStandard17Payable"",""groups"":[],""features"":{},""supportedstandards"":[""NEP-27""],""abi"":{""methods"":[{""name"":""onNEP17Payment"",""parameters"":[{""name"":""from"",""type"":""Hash160""},{""name"":""amount"",""type"":""Integer""},{""name"":""data"",""type"":""Any""}],""returntype"":""Void"",""offset"":15,""safe"":false}],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""extra"":{""Description"":""\u003CDescription Here\u003E"",""Author"":""\u003CYour Name Or Company Here\u003E"",""Version"":""\u003CVersion String Here\u003E""}}"); public static readonly Neo.SmartContract.NefFile Nef = Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVXAARAVwABeDQDQFcAAUDCSjTzIu3rbva0"));