Skip to content

Commit

Permalink
ContractPermissionDescriptor.Create(StackItem item)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hecate2 committed Sep 8, 2023
1 parent 4e9314d commit 009890b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Neo/SmartContract/Manifest/ContractManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void IInteroperable.FromStackItem(StackItem stackItem)
{
Null _ => WildcardContainer<ContractPermissionDescriptor>.CreateWildcard(),
// Array array when array.Any(p => ((ByteString)p).Size == 0) => WildcardContainer<ContractPermissionDescriptor>.CreateWildcard(),
Array array => WildcardContainer<ContractPermissionDescriptor>.Create(array.Select(p => new ContractPermissionDescriptor(p.GetSpan())).ToArray()),
Array array => WildcardContainer<ContractPermissionDescriptor>.Create(array.Select(ContractPermissionDescriptor.Create).ToArray()),
_ => throw new ArgumentException(null, nameof(stackItem))
};
Extra = (JObject)JToken.Parse(@struct[7].GetSpan());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Neo.Cryptography.ECC;
using Neo.IO;
using Neo.Json;
using Neo.VM.Types;
using System;

namespace Neo.SmartContract.Manifest
Expand Down Expand Up @@ -66,6 +67,13 @@ internal ContractPermissionDescriptor(ReadOnlySpan<byte> span)
}
}

public static ContractPermissionDescriptor Create(StackItem item)
{
if (item == StackItem.Null)
return CreateWildcard();
return new ContractPermissionDescriptor(item.GetSpan());
}

/// <summary>
/// Creates a new instance of the <see cref="ContractPermissionDescriptor"/> class with the specified contract hash.
/// </summary>
Expand Down

0 comments on commit 009890b

Please sign in to comment.