Skip to content

Conversation

@10thfloor
Copy link
Contributor

@10thfloor 10thfloor commented Apr 20, 2021

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.

const result  = await this.languageClient.sendRequest(ExecuteCommandRequest.type, {
  command: "cadence.server.parseEntryPointArguments",
  arguments: [
        this.editor.getModel().uri.toString(),
        ['{"a": "b"}']
     ]
})

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!

@vercel
Copy link

vercel bot commented Apr 20, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/onflow/flow-playground/CJ1DWyLdFrW1jVhw3YufPn9cf5bB
✅ Preview: https://flow-playground-git-mackenzie-params-bugfix-141-onflow.vercel.app

@10thfloor 10thfloor changed the title make error message a pre, so signification whitespace is not removed … Allow complex arguments in the UI #141 Apr 20, 2021
@10thfloor 10thfloor changed the title Allow complex arguments in the UI #141 [WIP RFC] Allow complex arguments in the UI #141 Apr 20, 2021
@vercel vercel bot temporarily deployed to Preview May 6, 2021 22:38 Inactive
@10thfloor
Copy link
Contributor Author

Closing in favour of #148

@10thfloor 10thfloor closed this May 21, 2021
@bthaile bthaile deleted the mackenzie/params-bugfix-#141 branch May 16, 2023 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Complex arguments are not working

3 participants