From 1261f25f592ba39619f867073522ad5758998a7f Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 8 Nov 2023 17:25:17 +0100 Subject: [PATCH] more changes to json react component --- apps/vyper/src/app/app.tsx | 10 ++++++++-- apps/vyper/src/app/components/CompilerButton.tsx | 5 ++++- apps/vyper/src/app/components/VyperResult.tsx | 9 +++++++-- apps/vyper/src/app/utils/compiler.tsx | 9 ++++++--- package.json | 1 + yarn.lock | 5 +++++ 6 files changed, 31 insertions(+), 8 deletions(-) diff --git a/apps/vyper/src/app/app.tsx b/apps/vyper/src/app/app.tsx index ebe9812988..73850794cf 100644 --- a/apps/vyper/src/app/app.tsx +++ b/apps/vyper/src/app/app.tsx @@ -33,6 +33,7 @@ const App: React.FC = () => { environment: 'local', localUrl: 'http://localhost:8000' }) + const [compilerResponse, setCompilerResponse] = useState({}) useEffect(() => { async function start() { @@ -92,10 +93,15 @@ const App: React.FC = () => {
- setOutput({...output, [name]: update})} /> + setOutput({...output, [name]: update})} + setCompilerResponse={setCompilerResponse} + />
- +
diff --git a/apps/vyper/src/app/components/CompilerButton.tsx b/apps/vyper/src/app/components/CompilerButton.tsx index 9cb3ac630a..b85a356337 100644 --- a/apps/vyper/src/app/components/CompilerButton.tsx +++ b/apps/vyper/src/app/components/CompilerButton.tsx @@ -6,9 +6,10 @@ interface Props { compilerUrl: string contract?: string setOutput: (name: string, output: VyperCompilationOutput) => void + setCompilerResponse: (response: any) => void } -function CompilerButton({contract, setOutput, compilerUrl}: Props) { +function CompilerButton({contract, setOutput, compilerUrl, setCompilerResponse}: Props) { if (!contract || !contract) { return } @@ -41,6 +42,8 @@ function CompilerButton({contract, setOutput, compilerUrl}: Props) { return } setOutput(_contract.name, output) + setCompilerResponse(output) + // ERROR if (isCompilationError(output)) { const line = output.line diff --git a/apps/vyper/src/app/components/VyperResult.tsx b/apps/vyper/src/app/components/VyperResult.tsx index 016271805b..d209246483 100644 --- a/apps/vyper/src/app/components/VyperResult.tsx +++ b/apps/vyper/src/app/components/VyperResult.tsx @@ -4,10 +4,12 @@ import Tabs from 'react-bootstrap/Tabs' import Tab from 'react-bootstrap/Tab' import Button from 'react-bootstrap/Button' import JSONTree from 'react-json-view' +import { JsonView } from 'react-json-view-lite' import {CopyToClipboard} from '@remix-ui/clipboard' interface VyperResultProps { output?: VyperCompilationOutput + compilerResponse?: any } export type ExampleContract = { @@ -15,7 +17,7 @@ export type ExampleContract = { address: string } -function VyperResult({output}: VyperResultProps) { +function VyperResult(props, {output, compilerResponse}: VyperResultProps) { const [active, setActive] = useState('abi') if (!output) @@ -52,7 +54,10 @@ function VyperResult({output}: VyperResultProps) { Copy ABI - + {/* */} + output.bytecode}> diff --git a/apps/vyper/src/app/utils/compiler.tsx b/apps/vyper/src/app/utils/compiler.tsx index 51f83f1097..2bb0aaffaa 100644 --- a/apps/vyper/src/app/utils/compiler.tsx +++ b/apps/vyper/src/app/utils/compiler.tsx @@ -63,10 +63,8 @@ export async function compile(url: string, contract: Contract): Promise