Skip to content

Commit

Permalink
Fix types in native contracts (#2356)
Browse files Browse the repository at this point in the history
* Fix types in native contracts

* format

Co-authored-by: Shargon <shargon@gmail.com>
  • Loading branch information
erikzhang and shargon authored Feb 21, 2021
1 parent 0c83d45 commit ee898bf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/neo/SmartContract/Native/ContractMethodMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Neo.Cryptography.ECC;
using Neo.IO;
using Neo.Persistence;
using Neo.SmartContract.Manifest;
Expand Down Expand Up @@ -70,18 +71,22 @@ 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;
if (type == typeof(VM.Types.Buffer)) return ContractParameterType.ByteArray;
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;
}
}
}

0 comments on commit ee898bf

Please sign in to comment.