neo-one icon indicating copy to clipboard operation
neo-one copied to clipboard

Add `Noficiations.from()` builtin and API

Open spencercorwin opened this issue 3 years ago • 1 comments

We should probably add a way to get arbitrary notifications from any contract with something like Notifications.from(Address.from(<address-string>)) which will return an array of builtin Notifications for the smart contract to parse for whatever logic. This is somewhat difficult and complex.

  • Add documentation and test coverage
  • Document notifications, stack items, stackitemtype, etc. in Index.d.ts
  • Implement StackItems and Notifications in compiler
  • Use ISTYPE opcode? Or create helper for IsBuiltinTypeHelper
  • Need to add a types folder for notifications
  • Need to add to all the builtin type stuff for notification
  • Need to be able to parse the stack items
  • Each stack item should be some sort of object with a type and then other key-value pairs depending on the type
  • May need to add builtin type for StackItem and for each stackitem
  • Then need to integrate APIs for those stack items into index.d.ts and the compiler
  • Iterative over the state array and for each item determine its type and wrap that in an object with a type property which will be a number enum or a string (see how it was done with transactions)
  • Test with Blockchain.test.ts in compiler

spencercorwin avatar Jun 26 '21 06:06 spencercorwin

Look at how we use interfaces as generics in SmartContract.for<T>() in the compiler to do something similar with notifications. If the user knows what a notification's structure will be when we can have them define that with an interface that is passed into something like Notification.for<T>(address). That way we don't have to define every possible stack item in the compiler, which seems non-sensical

spencercorwin avatar Aug 11 '21 22:08 spencercorwin