-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add UInt160, UInt256 and ECPoint to SmartContract Framework #362
Conversation
@ShawnYun GitHub wouldn't let me request you as an official reviewer. Please review this PR if you have a chance. |
We should add |
@shargon Shouldn't |
Co-authored-by: Erik Zhang <erik@neo.org>
Am I supposed to squash and merge this PR now that it's approved? |
I have tested it again, calling all methods using the contract, everything is normal, except for one place it should be |
fixes #208, part of neo-project/neo#1866
Obsoletes #347
This PR introduces
Neo.UInt160
,Neo.UInt256
andNeo.Cryptography.ECC.ECPoint
to the Neo.SmartContract.Framework assembly. Note, these type namespaces were explicitly chosen to match their corresponding types in Neo.dll. Over the next few weeks, I'll be introducing additional PRs to further unify types in Neo and Neo.SmartContract.Framework as part of neo-project/neo#1866.Because these types in the two assemblies have the same fully qualified namespace, an assembly that needs to reference Neo and Neo.SmartContract.Framework needs to use a reference alias to disambiguate. I've added appropriate reference aliases in Neo.Compiler.MSIL and the relevant unit tests projects.
Under the hood, these types are simple byte arrays, like how strings are handled in Neo smart contracts. These types are merely there to provide a small amount of compile time type safety + familiarity to the developer. Relevant service methods (such as
Runtime.CheckWitness
) and domain properties (such asBlock.Hash
) have been updated where appropriate to be strongly typed asUInt160
,UInt256
orECPoint
.Assorted Notes:
NEO
andOracle
) have been updated to expose their script hash as a staticHash
property. To avoid declaring the script hash twice, NEON has been updated to look for a newNativeContractHashAttribute
as a marker for the appropriate method to return the contract script hash.ConvertNewObj
in NEON has been updated to support the default and byte array constructors ofUInt160
andUInt256
. Default constructor pushes a byte array of appropriate size onto to stack. Byte array constructors inject VM code to validate the byte array on the evaluation stack is of the expected sizeECPoint
in SmartContract.Framework has neither default or byte array constructors. I wasn't sure if these types were ever constructed from byte arrays in contracts. It would be straightforward to include these constructors similar toUInt160
/UInt256
's constructors.UInt160
/UInt256
each have a static Zero property that pushes a zero array of appropriate length onto the stack viaOpCodeAttribute
FuncExport.ConvType
recognizes the new types and returns the appropriateContractParameterType
value as a stringModuleConverter.IsContractCall
was updated to return contract hash out parameter as UInt160 instead of a byte array