fixes for compile result mapping

pull/4182/head
Joseph Izang 1 year ago
parent 5434ebee72
commit e748a32e18
  1. 2
      apps/vyper/src/app/components/CompilerButton.tsx
  2. 3
      apps/vyper/src/app/components/VyperResult.tsx
  3. 15
      apps/vyper/src/app/utils/compiler.tsx

@ -36,7 +36,9 @@ function CompilerButton({contract, setOutput, compilerUrl, setCompilerResponse}:
}) })
let output let output
try { try {
console.log('calling comile endpoint now')
output = await compile(compilerUrl, _contract) output = await compile(compilerUrl, _contract)
console.log('output from compile endpoint', {output})
} catch (e: any) { } catch (e: any) {
setOutput(_contract.name, {status: 'failed', message: e.message}) setOutput(_contract.name, {status: 'failed', message: e.message})
return return

@ -1,11 +1,12 @@
import React, {useState} from 'react' import React, {useState} from 'react'
import {VyperCompilationResult, VyperCompilationOutput, isCompilationError} from '../utils' import {VyperCompilationOutput, isCompilationError} from '../utils'
import Tabs from 'react-bootstrap/Tabs' import Tabs from 'react-bootstrap/Tabs'
import Tab from 'react-bootstrap/Tab' import Tab from 'react-bootstrap/Tab'
import Button from 'react-bootstrap/Button' import Button from 'react-bootstrap/Button'
import JSONTree from 'react-json-view' import JSONTree from 'react-json-view'
import { JsonView } from 'react-json-view-lite' import { JsonView } from 'react-json-view-lite'
import {CopyToClipboard} from '@remix-ui/clipboard' import {CopyToClipboard} from '@remix-ui/clipboard'
import { VyperCompilationResult } from '../utils/types'
interface VyperResultProps { interface VyperResultProps {
output?: VyperCompilationOutput output?: VyperCompilationOutput

@ -1,5 +1,6 @@
import {CompilationResult, ABIDescription} from '@remixproject/plugin-api' import {CompilationResult, ABIDescription} from '@remixproject/plugin-api'
import axios from 'axios' import axios from 'axios'
import { VyperCompilationResultType } from './types'
export interface Contract { export interface Contract {
name: string name: string
@ -50,7 +51,7 @@ export function normalizeContractPath(contractPath: string): string[] {
* @param contract The name and content of the contract * @param contract The name and content of the contract
*/ */
export async function compile(url: string, contract: Contract): Promise<VyperCompilationOutput> { export async function compile(url: string, contract: Contract): Promise<VyperCompilationOutput> {
console.log('responding to call to comile')
if (!contract.name) { if (!contract.name) {
throw new Error('Set your Vyper contract file.') throw new Error('Set your Vyper contract file.')
} }
@ -87,11 +88,13 @@ export async function compile(url: string, contract: Contract): Promise<VyperCom
method: 'Get' method: 'Get'
})).data })).data
console.log({ result }) console.log({ result })
return result.data return result
} else if (status === 'FAILED') { } else if (status === 'PENDING' || status === 'FAILED') {
console.log('pending or failed state encountered')
result = await(await axios.get(url + '/exceptions/' + compileCode , { result = await(await axios.get(url + '/exceptions/' + compileCode , {
method: 'Get' method: 'Get'
})).data })).data
console.log({ result }, 'this is an exception')
return result.data return result.data
} }
console.log({ result }) console.log({ result })
@ -104,9 +107,9 @@ export async function compile(url: string, contract: Contract): Promise<VyperCom
* @param name Name of the contract file * @param name Name of the contract file
* @param compilationResult Result returned by the compiler * @param compilationResult Result returned by the compiler
*/ */
export function toStandardOutput(fileName: string, compilationResult: VyperCompilationResult): CompilationResult { export function toStandardOutput(fileName: string, compilationResult: VyperCompilationResultType): CompilationResult {
const contractName = fileName.split('/').slice(-1)[0].split('.')[0] const contractName = fileName.split('/').slice(-1)[0].split('.')[0]
const methodIdentifiers = JSON.parse(JSON.stringify(compilationResult['method_identifiers']).replace(/0x/g, '')) //const methodIdentifiers = JSON.parse(JSON.stringify(compilationResult['method_identifiers']).replace(/0x/g, ''))
return { return {
sources: { sources: {
[fileName]: { [fileName]: {
@ -133,7 +136,7 @@ export function toStandardOutput(fileName: string, compilationResult: VyperCompi
object: compilationResult['bytecode_runtime'].replace('0x', ''), object: compilationResult['bytecode_runtime'].replace('0x', ''),
opcodes: '' opcodes: ''
}, },
methodIdentifiers: methodIdentifiers // methodIdentifiers: methodIdentifiers
} }
} }
} as any } as any

Loading…
Cancel
Save