From f88cacfa4788a71bddb6187351d930d25e563c32 Mon Sep 17 00:00:00 2001 From: Max Daunarovich Date: Mon, 24 Jan 2022 19:33:02 +0300 Subject: [PATCH 1/3] Update argument formatting --- src/components/Arguments/index.tsx | 48 +++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/components/Arguments/index.tsx b/src/components/Arguments/index.tsx index a54a5115..f4827814 100644 --- a/src/components/Arguments/index.tsx +++ b/src/components/Arguments/index.tsx @@ -265,41 +265,41 @@ const Arguments: React.FC = (props) => { const { name, type } = arg; let value = values[name]; + if (type === `String`) { + value = `${value}`; + } + // We probably better fix this on server side... if (type === 'UFix64') { if (value.indexOf('.') < 0) { value = `${value}.0`; } } + + // Language server throws "input is not literal" without quotes + if (type === `String`) { + console.log({ value }); + value = `\"${value.replace(/"/g, '\\"')}\"`; + } + return value; }); - const formatted = await props.languageClient.sendRequest( - ExecuteCommandRequest.type, - { - command: 'cadence.server.parseEntryPointArguments', - arguments: [ - props.editor.getModel().uri.toString(), - fixed - ], - }, - ); + let formatted: any; + try { + formatted = await props.languageClient.sendRequest( + ExecuteCommandRequest.type, + { + command: 'cadence.server.parseEntryPointArguments', + arguments: [props.editor.getModel().uri.toString(), fixed], + }, + ); + } catch (e) { + console.log(e); + } // Map values to strings that will be passed to backend - const args:any = list.map((arg, index) => { - const { type } = arg; - const fixedValue = fixed[index] - - // We need to keep Bool values as boolean and not string - const value = type === "Bool" ? fixedValue === "true" : fixed[index] - - // If we have a complex type - return value formatted by language server - if ( isComplexType(type)){ - return JSON.stringify(formatted[index]) - } - - return JSON.stringify({ value, type }); - }); + const args: any = list.map((_, index) => JSON.stringify(formatted[index])) let rawResult, resultType; try { From 35523c17d3eddcf7429c74deb6391c529fc81a0d Mon Sep 17 00:00:00 2001 From: Max Daunarovich Date: Fri, 28 Jan 2022 22:56:49 +0300 Subject: [PATCH 2/3] Add comment to trigger snyk --- src/index.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.tsx b/src/index.tsx index bbf33da1..389a5652 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -2,5 +2,7 @@ import * as React from "react" import * as ReactDOM from "react-dom" import App from "./App" +// simple comment to re-trigger snyk + const root = document.getElementById("root") ReactDOM.render(, root) From c6745d079fc2d1d910ea2b79367ee9df04e828f5 Mon Sep 17 00:00:00 2001 From: Max Daunarovich Date: Fri, 28 Jan 2022 22:57:29 +0300 Subject: [PATCH 3/3] Remove comment --- src/index.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 389a5652..bbf33da1 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -2,7 +2,5 @@ import * as React from "react" import * as ReactDOM from "react-dom" import App from "./App" -// simple comment to re-trigger snyk - const root = document.getElementById("root") ReactDOM.render(, root)