streamline stack item types in Neo3EventListener#48
Conversation
luc10921
left a comment
There was a problem hiding this comment.
Also, there is a pre-commit hook that warns about formatting problems and cancels the commit if there is something wrong.
It should be triggering in the commits here.
If it's not sending the error when committing, try following these steps:
// Use a node version that is expected from this project
// ">=14.15.0 <15.0.0 || >=16.13.0 <17.0.0 || >=18.15.0 <=20.14.0",
nvm use 2.14.0
// I'm using nvm to be able to easily change node versions when needed
// https://github.com/nvm-sh/nvm
// Install rush.js https://rushjs.io/pages/intro/get_started/
npm install -g @microsoft/rush
With those steps, you should get an error message when trying to commit.
Checking formatting...
[warn] packages/neon-dappkit-types/src/Neo3EventListener.ts
[warn] packages/neon-dappkit-types/src/Neo3Invoker.ts
[warn] packages/neon-dappkit/src/NeonEventListener.ts
[warn] packages/neon-dappkit/test/NeonEventListener.spec.ts
[warn] Code style issues found in 4 files. Run Prettier to fix.
The script failed with exit code 1
You can also run the command rush lint to get the same error message without committing.
To fix the problems, run rush format.
|
|
||
| export interface InvokeBase <T extends RpcResponseStackItem = RpcResponseStackItem> { | ||
| /** State of VM on exit. HALT means a successful exit while FAULT means exit with error. */ | ||
| state: 'HALT' | 'FAULT' |
There was a problem hiding this comment.
Why state instead of vmstate? The rpc method returns vmstate, it might be confusing for the user that checked the rpc documentation and is expecting it
https://docs.neo.org/docs/n3/reference/rpc/getapplicationlog.html
There was a problem hiding this comment.
I didn't change the name. The original name on InvokeResult was state I just moved it to a common shared class. This way there are fewer changes needed. I personally think vmstate is nicer but if we go that route we should probably rename a lot more (particularly classes)
| "changes": [ | ||
| { | ||
| "packageName": "@cityofzion/neon-dappkit", | ||
| "comment": "upate to use latest type changes", |
|
I didn't use Sounds like a good check to add to CI |
It started by realizing I could not do
but I had to use
Which made no sense to me as there is only one stack item in the VM.
Upon closer inspection I realized that
Neo3EventListenerhad it's own stack item interface (Neo3StackItem) whereNeo3Parser,Neo3InvokerandTypeCheckerall useRpcResponseStackItem. I visualized that state belowNote that
InvokeResultis also missingnotifications[]and theNeo3ApplicationLogis missing theexceptionfield.This PR addresses the issue by ensuring that
Neo3EventListeneruses the same stack item and notification types as elsewhere. Specifically as shown in the image belowArguably we could move
notificationsfromInvokeBaseto justApplicationExecutionbecause atmneon-js(which is used internally when doing an invoke) doesn't return the notifications fortestinvokeandtestscriptcalls. However, I'd rather updateneon-jsand have this already in the right place instead.