fix issues with displaying vyper results

pull/4182/head
Joseph Izang 1 year ago
parent 69f0b2a3a2
commit b87cd2f8b0
  1. 12
      apps/remix-ide/src/app/plugins/vyper-compilation-details.tsx
  2. 8
      apps/vyper/src/app/app.css
  3. 64
      apps/vyper/src/app/components/CompilerButton.tsx
  4. 2
      apps/vyper/src/app/components/VyperResult.tsx
  5. 1
      libs/remix-ui/solidity-compile-details/src/lib/solidity-compile-details.tsx
  6. 20
      libs/remix-ui/vyper-compile-details/src/lib/vyper-compile-details.tsx
  7. 36
      libs/remix-ui/vyper-compile-details/src/lib/vyperCompile.tsx

@ -45,10 +45,11 @@ export class VyperCompilationDetailsPlugin extends ViewPlugin {
} }
async showDetails(sentPayload: any) { async showDetails(sentPayload: any) {
console.log({ sentPayload }) console.log(sentPayload )
const contractName = Object.entries(sentPayload).find(([key, value]) => key ) const contractName = Object.entries(sentPayload).find(([key, value]) => key )
this.profile.displayName = `${contractName}`
await this.call('tabs', 'focus', 'vyperCompilationDetails') await this.call('tabs', 'focus', 'vyperCompilationDetails')
this.profile.displayName = `${contractName}`
this.renderComponent()
this.payload = sentPayload this.payload = sentPayload
this.renderComponent() this.renderComponent()
} }
@ -74,12 +75,7 @@ export class VyperCompilationDetailsPlugin extends ViewPlugin {
updateComponent(state: any) { updateComponent(state: any) {
return ( return (
<RemixUiVyperCompileDetails <RemixUiVyperCompileDetails
// plugin={this} payload={this.payload}
// contractProperties={state.contractProperties}
// selectedContract={state.selectedContract}
// saveAs={state.saveAs}
// help={state.help}
// insertValue={state.insertValue}
/> />
) )
} }

@ -48,14 +48,6 @@ html, body, #root, main {
} }
#compile-btn {
}
#compile-btn * {
width: 100%;
}
#result { #result {
flex: 1; flex: 1;
display: flex; display: flex;

@ -1,4 +1,4 @@
import React, { useState } from 'react' import React, { Fragment, useState } from 'react'
import {isVyper, compile, toStandardOutput, VyperCompilationOutput, isCompilationError, remixClient, normalizeContractPath} from '../utils' import {isVyper, compile, toStandardOutput, VyperCompilationOutput, isCompilationError, remixClient, normalizeContractPath} from '../utils'
import Button from 'react-bootstrap/Button' import Button from 'react-bootstrap/Button'
import _ from 'lodash' import _ from 'lodash'
@ -46,25 +46,29 @@ function CompilerButton({contract, setOutput, compilerUrl, resetCompilerState}:
setOutput(_contract.name, {status: 'failed', message: e.message}) setOutput(_contract.name, {status: 'failed', message: e.message})
return return
} }
// console.log({ output }) console.log({ output })
// const compileReturnType = () => { const compileReturnType = () => {
// const t: any = toStandardOutput(contract, output) const t: any = toStandardOutput(contract, output)
// const temp = _.merge(t['contracts'][contract]) console.log(t)
// const normal = normalizeContractPath(contract)[2] const temp = _.merge(t['contracts'][contract])
// const abi = temp[normal]['abi'] const normal = normalizeContractPath(contract)[2]
// const evm = _.merge(temp[normal]['evm']) const abi = temp[normal]['abi']
// const dpb = evm.deployedBytecode const evm = _.merge(temp[normal]['evm'])
// const runtimeBytecode = evm.bytecode const dpb = evm.deployedBytecode
const runtimeBytecode = evm.bytecode
const methodIdentifiers = evm.methodIdentifiers
// const result = { const result = {
// contractName: normal, contractName: normal,
// abi: abi, abi: abi,
// bytecode: dpb, bytecode: dpb,
// runtimeBytecode: runtimeBytecode, runtimeBytecode: runtimeBytecode,
// ir: '' ir: '',
// } methodIdentifiers: methodIdentifiers
// return result }
// } console.log(result)
return result
}
// setOutput(_contract.name, compileReturnType()) // setOutput(_contract.name, compileReturnType())
// ERROR // ERROR
@ -111,9 +115,9 @@ function CompilerButton({contract, setOutput, compilerUrl, resetCompilerState}:
}) })
const data = toStandardOutput(_contract.name, output) const data = toStandardOutput(_contract.name, output)
remixClient.compilationFinish(_contract.name, _contract.content, data) remixClient.compilationFinish(_contract.name, _contract.content, data)
console.log(data) // console.log(data)
setOutput(_contract.name, data) setOutput(_contract.name, compileReturnType())
setLoadingSpinnerState(false) // setLoadingSpinnerState(false)
// remixClient.call('compilationDetails' as any, 'showDetails', data) // remixClient.call('compilationDetails' as any, 'showDetails', data)
} catch (err: any) { } catch (err: any) {
remixClient.changeStatus({ remixClient.changeStatus({
@ -125,13 +129,15 @@ function CompilerButton({contract, setOutput, compilerUrl, resetCompilerState}:
} }
return ( return (
<button data-id="compile" onClick={compileContract} title={contract} className="d-flex flex-column btn btn-primary w-100"> <Fragment>
<div className="d-flex justify-content-center align-item-center"> <button data-id="compile" onClick={compileContract} title={contract} className="btn btn-primary btn-block d-block w-100 text-break remixui_disabled mb-1 mt-3">
{loadingSpinner ? <span className="fas fa-sync fa-pulse" role="status" aria-hidden="true" /> : null} <div className="fa-1x">
<span>Compile</span> {/* {loadingSpinner ? <span className="fas fa-sync fa-pulse" role="status" aria-hidden="true" /> : null} */}
<span className="overflow-hidden text-truncate text-nowrap">{contract}</span> <span>Compile</span>
</div> <span className="overflow-hidden text-truncate text-nowrap">{contract}</span>
</button> </div>
</button>
</Fragment>
) )
} }

@ -53,7 +53,7 @@ function VyperResult({ output, plugin }: VyperResultProps) {
</div> </div>
) )
} }
console.log(output)
return ( return (
<> <>
<div className="border border-top"></div> <div className="border border-top"></div>

@ -5,7 +5,6 @@ import { ContractPropertyName } from '@remix-ui/solidity-compiler'
import React from 'react' import React from 'react'
import SolidityCompile from './components/solidityCompile' import SolidityCompile from './components/solidityCompile'
import VyperCompile from './components/vyperCompile'
export interface RemixUiCompileDetailsProps { export interface RemixUiCompileDetailsProps {
plugin?: any plugin?: any

@ -1,12 +1,24 @@
import React from 'react' import React from 'react'
import VyperCompile from './vyperCompile'
//@ts-nocheck
export function RemixUiVyperCompileDetails() {
interface RemixUiVyperCompileDetailsProps {
payload: any
}
export function RemixUiVyperCompileDetails({ payload }: RemixUiVyperCompileDetailsProps) {
const dpayload = Object.values(payload) as any
return ( return (
<> <>
<div> <VyperCompile
<h1>Welcome to Vyper Compile Details Plugin!!</h1> ir={dpayload[0].ir}
</div> methodIdentifiers={dpayload[0].methodIdentifiers}
abi={dpayload[0].abi}
bytecode={dpayload[0].bytecode}
bytecodeRuntime={dpayload[0].bytecodeRuntime}
/>
</> </>
) )
} }

@ -12,43 +12,43 @@ import { ABIDescription } from '@remixproject/plugin-api'
const _paq = (window._paq = window._paq || []) const _paq = (window._paq = window._paq || [])
export interface VyperCompilationResult { export interface VyperCompilationResult {
status: 'success' status?: 'success'
bytecode: string bytecode: string
bytecode_runtime: string bytecodeRuntime: string
abi: ABIDescription[] abi: ABIDescription[]
ir: string ir: string
method_identifiers: { methodIdentifiers: {
[method: string]: string [method: string]: string
} }
} }
export default function VyperCompile({ saveAs, contractProperties, selectedContract }: any) { export default function VyperCompile(props: VyperCompilationResult) {
const intl = useIntl() const intl = useIntl()
const downloadFn = () => { // const downloadFn = () => {
_paq.push(['trackEvent', 'compiler', 'compilerDetails', 'download']) // _paq.push(['trackEvent', 'compiler', 'compilerDetails', 'download'])
saveAs(new Blob([JSON.stringify(contractProperties, null, '\t')]), `${selectedContract}_compData.json`) // saveAs(new Blob([JSON.stringify(contractProperties, null, '\t')]), `${selectedContract}_compData.json`)
} // }
const [active, setActive] = useState<keyof VyperCompilationResult>('abi') const [active, setActive] = useState<keyof VyperCompilationResult>('abi')
const tabContent = [ const tabContent = [
{ {
tabHeadingText: 'ABI', tabHeadingText: 'ABI',
tabPayload: Object.values(contractProperties)[0]['abi'], tabPayload: props.abi, //Object.values(props)[0]['abi'],
tabMemberType: 'abi', tabMemberType: 'abi',
tabButtonText: () => 'Copy ABI', tabButtonText: () => 'Copy ABI',
eventKey: 'abi' eventKey: 'abi'
}, },
{ {
tabHeadingText: 'Bytecode', tabHeadingText: 'Bytecode',
tabPayload: Object.values(contractProperties)[0]['bytecode'].object.toString(), tabPayload: props.bytecode, //Object.values(props)[0]['bytecode'].object.toString(),
tabMemberType: 'bytecode', tabMemberType: 'bytecode',
tabButtonText: () => 'Copy Bytecode', tabButtonText: () => 'Copy Bytecode',
eventKey: 'bytecode' eventKey: 'bytecode'
}, },
{ {
tabHeadingText: 'Runtime Bytecode', tabHeadingText: 'Runtime Bytecode',
tabPayload: Object.values(contractProperties)[0]['runtimeBytecode'].object.toString(), tabPayload: props.bytecodeRuntime,// Object.values(props)[0]['runtimeBytecode'].object.toString(),
tabMemberType: 'bytecode_runtime', tabMemberType: 'bytecode_runtime',
tabButtonText: () => 'Copy Runtime Bytecode', tabButtonText: () => 'Copy Runtime Bytecode',
eventKey: 'bytecode_runtime' eventKey: 'bytecode_runtime'
@ -63,28 +63,28 @@ export default function VyperCompile({ saveAs, contractProperties, selectedContr
] ]
return ( return (
<> <>
<div className="d-flex justify-content-between align-items-center mr-1"> {/* <div className="d-flex justify-content-between align-items-center mr-1">
<span className="lead">{selectedContract}</span> <span className="lead">{selectedContract}</span>
<CustomTooltip tooltipText={intl.formatMessage({id: 'solidity.compileDetails'})}> <CustomTooltip tooltipText={intl.formatMessage({id: 'solidity.compileDetails'})}>
<span className="btn btn-outline-success border-success mr-1" onClick={downloadFn}>Download</span> <span className="btn btn-outline-success border-success mr-1" onClick={downloadFn}>Download</span>
</CustomTooltip> </CustomTooltip>
</div> </div> */}
<Tabs id="result" activeKey={active} onSelect={(key: any) => setActive(key)} justify> <Tabs id="result" activeKey={active} onSelect={(key: any) => setActive(key)} justify>
{tabContent.map((content, index) => ( {tabContent.map((content, index) => (
<Tab eventKey={content.eventKey} title={content.tabHeadingText} as={'span'} key={`${index}-${content.eventKey}`}> <Tab eventKey={content.eventKey} title={content.tabHeadingText} as={'span'} key={`${index}-${content.eventKey}`}>
<CopyToClipboard getContent={() => content.eventKey !== 'abi' ? content.tabPayload : JSON.stringify(Object.values(contractProperties)[0]['abi'])}> <CopyToClipboard getContent={() => content.eventKey !== 'abi' ? content.tabPayload : JSON.stringify(Object.values(props)[0]['abi'])}>
<Button variant="info" className="copy" data-id={content.eventKey === 'abi' ? "copy-abi" : ''}> <Button variant="info" className="copy" data-id={content.eventKey === 'abi' ? "copy-abi" : ''}>
{content.tabButtonText()} {content.tabButtonText()}
</Button> </Button>
</CopyToClipboard> </CopyToClipboard>
{ {
content.eventKey === 'abi' ? <JSONTree src={content.tabPayload} theme={{} as any}/> : ( content.eventKey === 'abi' ? <JSONTree src={content.tabPayload as ABIDescription[]} theme={{} as any}/> : (
<textarea defaultValue={content.tabPayload}></textarea> <textarea defaultValue={content.tabPayload as string}></textarea>
) )
} }
<Button> {/* <Button>
{content.tabButtonText()} {content.tabButtonText()}
</Button> </Button> */}
</Tab>))} </Tab>))}
</Tabs> </Tabs>
</> </>
Loading…
Cancel
Save