From 02aa97699b437e0dd736ad0a0750ba86ccd9778d Mon Sep 17 00:00:00 2001 From: Erik Zhang Date: Fri, 19 Feb 2021 20:51:46 +0800 Subject: [PATCH 1/2] Fix types in native contracts --- src/neo/SmartContract/Native/ContractMethodMetadata.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/neo/SmartContract/Native/ContractMethodMetadata.cs b/src/neo/SmartContract/Native/ContractMethodMetadata.cs index d4e26594bc..b627c3a60f 100644 --- a/src/neo/SmartContract/Native/ContractMethodMetadata.cs +++ b/src/neo/SmartContract/Native/ContractMethodMetadata.cs @@ -1,3 +1,4 @@ +using Neo.Cryptography.ECC; using Neo.IO; using Neo.Persistence; using Neo.SmartContract.Manifest; @@ -70,6 +71,7 @@ private static ContractParameterType ToParameterType(Type type) if (type == typeof(string)) return ContractParameterType.String; if (type == typeof(UInt160)) return ContractParameterType.Hash160; if (type == typeof(UInt256)) return ContractParameterType.Hash256; + if (type == typeof(ECPoint)) return ContractParameterType.PublicKey; if (type == typeof(VM.Types.Boolean)) return ContractParameterType.Boolean; if (type == typeof(Integer)) return ContractParameterType.Integer; if (type == typeof(ByteString)) return ContractParameterType.ByteArray; @@ -77,11 +79,14 @@ private static ContractParameterType ToParameterType(Type type) if (type == typeof(Array)) return ContractParameterType.Array; if (type == typeof(Struct)) return ContractParameterType.Array; if (type == typeof(Map)) return ContractParameterType.Map; + if (type == typeof(StackItem)) return ContractParameterType.Any; + if (type == typeof(object)) return ContractParameterType.Any; if (typeof(IInteroperable).IsAssignableFrom(type)) return ContractParameterType.Array; if (typeof(ISerializable).IsAssignableFrom(type)) return ContractParameterType.ByteArray; if (type.IsArray) return ContractParameterType.Array; if (type.IsEnum) return ContractParameterType.Integer; - return ContractParameterType.Any; + if (type.IsValueType) return ContractParameterType.Array; + return ContractParameterType.InteropInterface; } } } From f0769d144ebd10407bf70d1a153a029f28a060e6 Mon Sep 17 00:00:00 2001 From: Erik Zhang Date: Fri, 19 Feb 2021 20:54:55 +0800 Subject: [PATCH 2/2] format --- src/neo/SmartContract/Native/ContractMethodMetadata.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/neo/SmartContract/Native/ContractMethodMetadata.cs b/src/neo/SmartContract/Native/ContractMethodMetadata.cs index b627c3a60f..d22e5332f5 100644 --- a/src/neo/SmartContract/Native/ContractMethodMetadata.cs +++ b/src/neo/SmartContract/Native/ContractMethodMetadata.cs @@ -1,4 +1,4 @@ -using Neo.Cryptography.ECC; +using Neo.Cryptography.ECC; using Neo.IO; using Neo.Persistence; using Neo.SmartContract.Manifest;