fix bug where compiled artifacts are not cleared before another compile completes

pull/4182/head
Joseph Izang 12 months ago
parent 218b69709d
commit 67be320f98
  1. 5
      apps/vyper/src/app/app.tsx
  2. 5
      apps/vyper/src/app/components/CompilerButton.tsx

@ -65,6 +65,10 @@ const App: React.FC = () => {
return state.environment === 'remote' ? 'https://vyper2.remixproject.org/' : state.localUrl return state.environment === 'remote' ? 'https://vyper2.remixproject.org/' : state.localUrl
} }
function resetCompilerResultState() {
setOutput({})
}
return ( return (
<main id="vyper-plugin"> <main id="vyper-plugin">
<header> <header>
@ -97,6 +101,7 @@ const App: React.FC = () => {
compilerUrl={compilerUrl()} compilerUrl={compilerUrl()}
contract={contract} contract={contract}
setOutput={(name, update) => setOutput({...output, [name]: update})} setOutput={(name, update) => setOutput({...output, [name]: update})}
resetCompilerState={resetCompilerResultState}
/> />
</div> </div>

@ -8,9 +8,10 @@ interface Props {
compilerUrl: string compilerUrl: string
contract?: string contract?: string
setOutput: (name: string, output: any) => void setOutput: (name: string, output: any) => void
resetCompilerState: () => void
} }
function CompilerButton({contract, setOutput, compilerUrl}: Props) { function CompilerButton({contract, setOutput, compilerUrl, resetCompilerState}: Props) {
if (!contract || !contract) { if (!contract || !contract) {
return <Button disabled>No contract selected</Button> return <Button disabled>No contract selected</Button>
} }
@ -21,6 +22,7 @@ function CompilerButton({contract, setOutput, compilerUrl}: Props) {
/** Compile a Contract */ /** Compile a Contract */
async function compileContract() { async function compileContract() {
resetCompilerState()
try { try {
await remixClient.discardHighlight() await remixClient.discardHighlight()
let _contract: any let _contract: any
@ -46,7 +48,6 @@ function CompilerButton({contract, setOutput, compilerUrl}: Props) {
const t: any = toStandardOutput(contract, output) const t: any = toStandardOutput(contract, output)
const temp = _.merge(t['contracts'][contract]) const temp = _.merge(t['contracts'][contract])
const normal = normalizeContractPath(contract)[2] const normal = normalizeContractPath(contract)[2]
console.log(normal)
const abi = temp[normal]['abi'] const abi = temp[normal]['abi']
const evm = _.merge(temp[normal]['evm']) const evm = _.merge(temp[normal]['evm'])
const dpb = evm.deployedBytecode const dpb = evm.deployedBytecode

Loading…
Cancel
Save