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
try {
console.log('calling comile endpoint now')
output = await compile(compilerUrl, _contract)
console.log('output from compile endpoint', {output})
} catch (e: any) {
setOutput(_contract.name, {status: 'failed', message: e.message})
return

@ -1,11 +1,12 @@
import React, {useState} from 'react'
import {VyperCompilationResult, VyperCompilationOutput, isCompilationError} from '../utils'
import {VyperCompilationOutput, isCompilationError} from '../utils'
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'
import { VyperCompilationResult } from '../utils/types'
interface VyperResultProps {
output?: VyperCompilationOutput

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

Loading…
Cancel
Save