Improve the developer experience by having compatible source definition of common domain
model types such as Block and Transaction across RpcClient, Neo node plugins and the Smart
Contract Framework.
Problem
Core domain types like Block and Transaction have a different definition in the Smart
Contract framework and Neo core. This makes it harder for developers to learn and use
the Neo platform. It also makes it harder to move code between dApp clients and smart
contracts.
Examples:
Block.PrevHash field is a byte[] in the Smart Contract Framework and a UInt256 in Neo
To retrieve a Transaction from a block in Neo, you use the Block.Transaction array. To retrieve a
Transaction from a block in Smart Contract Framework, you call Blockchain.GetTransactionFromBlock
Neo supports a variety of contract parameter types that have no represenation in smart contracts
such as Hash160/256, Public Key and Signature
Proposals
Create a new namespace Neo.Models.
Move domain models from their current namespaces to Neo.Models
For Neo core, this means moving Block, BlockBase, Header and Transaction from Neo.Network.P2P.Payloads to Neo.Models.
For Contract Framework, this means moving Block and Transaction from Neo.SmartContract.Framework.Services.Neo
Add UInt160, UInt256 and ECPoint types to Contract Framework in namespaces that match locations form Neo core
These fundamental types will continue to be represented in the VM as byte arrays. The goal of this change is to provide familiarity and basic type safety
Functional parity between neo core and contract framework for these types is NOT A REQUIREMENT.
These types need explicit byte array cast operator for use as storage keys and values. Since these types are stored as byte arrays in the VM, the cast operator is a no-op, but there to reinforce to the developer the correct usage of these types
Update contract framework Block and Transaction to use UInt160/256 for properties where appropriate to match neo core
Example: Hash field of block and transaction should be UInt256 not byte[]
Update contract framework Block to expose Transactions read only indexable collection instead of using TransactionCount field + Blockchain.GetTransactionForBlock method
Update contract framework services to use new fundamental types where appropriate instead of byte arrays. Introduce overloads where needed
Example: Runtime.CheckWitness should have two overloads, taking UInt160 and ECPoint
Simplify the namespace of service types in the contract framework.
Move Smart Contract types used to control the compilation process such as SyscallAttribute and IApiInterface out of the root contract framework namespace and into a new Neo.Contract.Metadata namespace
Update NEON compiler + neo core to support contract framework changes as appropriate
Objective
Improve the developer experience by having compatible source definition of common domain model types such as Block and Transaction across RpcClient, Neo node plugins and the Smart Contract Framework.
Problem
Core domain types like Block and Transaction have a different definition in the Smart Contract framework and Neo core. This makes it harder for developers to learn and use the Neo platform. It also makes it harder to move code between dApp clients and smart contracts.
Examples:
Proposals