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 decode specification (v1) #165

Closed
10 tasks done
brunomenezes opened this issue Apr 25, 2024 · 3 comments · Fixed by #213
Closed
10 tasks done

Add decode specification (v1) #165

brunomenezes opened this issue Apr 25, 2024 · 3 comments · Fixed by #213
Assignees
Labels
Type: Feature Add a new feature to the system

Comments

@brunomenezes
Copy link
Collaborator

brunomenezes commented Apr 25, 2024

📄 Context

Currently, for the input's payload, we are displaying the content in three ways: as is (i.e. Raw), as Text (trying to convert the Hex value) and JSON that leverages the result of the latter. It would be an excellent addition to provide a way for the user (i.e. developer) to describe how it should be parsed and save that specification for reuse.

PS: I am calling the feature decode specification because the payload may be encoded with a non-standard-packed-mode and just dropping an ABI will not work; pre-steps are necessary (e.g. Slice bytes) before you define a piece of ABI to use.

✔️ Solution

Implement a UI that allows users to specify how to decode a given input payload into a human-readable form. The spec is a single or series of transformation steps, depending on the original encoding used.

  • Support JSON-ABIs format.
  • Support Human-Readable-ABI format.
  • Support byte slices. e.g. Portals use a non-standard packed mode encodePacked so pre-steps are necessary.
  • Support live feedback. i.e., set a payload while defining the specification so the user can see the result.
  • Support conditional for auto-applying the spec to a given input. e.g. when app address x and msgSender y
    • Limit to a couple of properties: i.e. application-address, msgSender.
    • In case of multiple specs would match. The first match is the one selected.
  • Should be able to choose a named specification against a payload manually. It should transform the content inside the Raw panel.
  • Should be able to save the specification. (local-storage)

📈 Subtasks

  • Implement the custom specification UI.
  • Add support to byte slicing.
  • Add support to JSON-ABIs.
  • Add support to human-readable ABI.
  • Add live testing feedback.
  • Add support to conditionals.
  • Update the input details component to support specification selection.

🎯 Definition of Done

  • I can see a correct payload in human-readable form inside the raw panel. Also, show the specification selected.
  • specification can be saved. Persist through page refreshes.
  • Auto-select a Specification when conditional match.
@brunomenezes brunomenezes added the Type: Feature Add a new feature to the system label Apr 25, 2024
@brunomenezes brunomenezes self-assigned this Apr 25, 2024
@brunomenezes
Copy link
Collaborator Author

cc: @tuler

@brunomenezes
Copy link
Collaborator Author

Hi @tuler, I am adding here the compare so you can see the current commits.
At the current point, I would point you to the tests inside decoder.test.ts and conditionals.test.ts to have a feel for its inner workings and what each piece accomplishes.

main...feature/165-add-decode-specification-v1

I will be working next in the form-ui + preview to define and play around while defining a specification, persistence and later the integration with the current input-data component we have (textarea displaying the payload in the input's table).

@brunomenezes brunomenezes added the Status: On-Hold On-hold for further development, because upcoming changes will affect the Issue or PR targeted label May 29, 2024
@brunomenezes brunomenezes removed the Status: On-Hold On-hold for further development, because upcoming changes will affect the Issue or PR targeted label Jul 2, 2024
@brunomenezes brunomenezes linked a pull request Jul 16, 2024 that will close this issue
@brunomenezes
Copy link
Collaborator Author

There is a problem with a case: if the user is prototyping in the JSON ABI mode, changes to the struct will not be reflected in the generated JSON Abi unless the parameter name of this struct is also modified. e.g. from function myFunc(Baz baz) to function myFunc(Baz baz2).

More details are available in the issue created in the wevm/abitype repo: wevm/abitype#247

cc: @tuler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Add a new feature to the system
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant