[WIP RFC] Allow complex arguments in the UI #141 #142
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #141
Context
Currently the Playground can handle arguments to functions, unless they are complex Cadence types (Struct, Resource, Enum ...etc).
The following code is where we're determining the Cadence type before sending a properly structured Cadence trasnaction to the API via a GraphQL query: https://github.com/onflow/flow-playground/blob/mackenzie/params-bugfix-%23141/src/components/Arguments/index.tsx#L26
Description
This PR aims to add support for the missing Cadence types using the built-in Cadence language server to parse parameters for their type, and return the properly formatted Cadence JSON to be sent to the API.
This code is how to call the language server from JS to create the valid JSON required by the Playground API / Flow VM.
It will produce valid cadence JSON for the given Cadence code and contract/script parameters by matching on the name.
Suggested Solution
Replace the existing code for handling arguments input from the UI with this call to the awesome WASM embedded language server, without which this would be impossible!