Skip to content
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 Noficiations.from() builtin and API #2494

Open
spencercorwin opened this issue Jun 26, 2021 · 1 comment
Open

Add Noficiations.from() builtin and API #2494

spencercorwin opened this issue Jun 26, 2021 · 1 comment
Labels
area/compiler Categorize issue or PR as compiler (@neo-one/smart-contract-compiler) related kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/feature Categorizes issue or PR as related to a new feature. priority/important-longterm Important over the long term, but may not be staffed.

Comments

@spencercorwin
Copy link
Collaborator

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 spencercorwin added kind/feature Categorizes issue or PR as related to a new feature. area/compiler Categorize issue or PR as compiler (@neo-one/smart-contract-compiler) related kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. priority/important-longterm Important over the long term, but may not be staffed. labels Jun 26, 2021
@spencercorwin
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/compiler Categorize issue or PR as compiler (@neo-one/smart-contract-compiler) related kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/feature Categorizes issue or PR as related to a new feature. priority/important-longterm Important over the long term, but may not be staffed.
Projects
None yet
Development

No branches or pull requests

1 participant