From 009890b0bda2741b7d582b896e0adb105a42e9ae Mon Sep 17 00:00:00 2001 From: Hecate2 <2474101468@qq.com> Date: Fri, 8 Sep 2023 11:03:08 +0800 Subject: [PATCH 1/2] ContractPermissionDescriptor.Create(StackItem item) --- src/Neo/SmartContract/Manifest/ContractManifest.cs | 2 +- .../Manifest/ContractPermissionDescriptor.cs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Neo/SmartContract/Manifest/ContractManifest.cs b/src/Neo/SmartContract/Manifest/ContractManifest.cs index e68c764800..341b369ab4 100644 --- a/src/Neo/SmartContract/Manifest/ContractManifest.cs +++ b/src/Neo/SmartContract/Manifest/ContractManifest.cs @@ -81,7 +81,7 @@ void IInteroperable.FromStackItem(StackItem stackItem) { Null _ => WildcardContainer.CreateWildcard(), // Array array when array.Any(p => ((ByteString)p).Size == 0) => WildcardContainer.CreateWildcard(), - Array array => WildcardContainer.Create(array.Select(p => new ContractPermissionDescriptor(p.GetSpan())).ToArray()), + Array array => WildcardContainer.Create(array.Select(ContractPermissionDescriptor.Create).ToArray()), _ => throw new ArgumentException(null, nameof(stackItem)) }; Extra = (JObject)JToken.Parse(@struct[7].GetSpan()); diff --git a/src/Neo/SmartContract/Manifest/ContractPermissionDescriptor.cs b/src/Neo/SmartContract/Manifest/ContractPermissionDescriptor.cs index 133c338c6c..a6f0cc1807 100644 --- a/src/Neo/SmartContract/Manifest/ContractPermissionDescriptor.cs +++ b/src/Neo/SmartContract/Manifest/ContractPermissionDescriptor.cs @@ -11,6 +11,7 @@ using Neo.Cryptography.ECC; using Neo.IO; using Neo.Json; +using Neo.VM.Types; using System; namespace Neo.SmartContract.Manifest @@ -66,6 +67,13 @@ internal ContractPermissionDescriptor(ReadOnlySpan span) } } + public static ContractPermissionDescriptor Create(StackItem item) + { + if (item == StackItem.Null) + return CreateWildcard(); + return new ContractPermissionDescriptor(item.GetSpan()); + } + /// /// Creates a new instance of the class with the specified contract hash. /// From 2ffeceec9102ddf17b182cc0dd63f4be17b56fb8 Mon Sep 17 00:00:00 2001 From: Hecate2 Date: Fri, 8 Sep 2023 14:44:01 +0800 Subject: [PATCH 2/2] Update src/Neo/SmartContract/Manifest/ContractPermissionDescriptor.cs Co-authored-by: Jimmy --- .../SmartContract/Manifest/ContractPermissionDescriptor.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Neo/SmartContract/Manifest/ContractPermissionDescriptor.cs b/src/Neo/SmartContract/Manifest/ContractPermissionDescriptor.cs index a6f0cc1807..41dc7ca816 100644 --- a/src/Neo/SmartContract/Manifest/ContractPermissionDescriptor.cs +++ b/src/Neo/SmartContract/Manifest/ContractPermissionDescriptor.cs @@ -69,9 +69,7 @@ internal ContractPermissionDescriptor(ReadOnlySpan span) public static ContractPermissionDescriptor Create(StackItem item) { - if (item == StackItem.Null) - return CreateWildcard(); - return new ContractPermissionDescriptor(item.GetSpan()); + return item.Equals(StackItem.Null) ? CreateWildcard() : new ContractPermissionDescriptor(item.GetSpan()); } ///