Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
change compile to async format
Browse files Browse the repository at this point in the history
  • Loading branch information
varex83 committed Nov 8, 2023
1 parent a01e429 commit 971c805
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
1 change: 1 addition & 0 deletions api/src/handlers/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use rocket::State;
use solang_parser::pt::SourceUnitPart;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use tracing::info;
use tracing::instrument;

#[instrument]
Expand Down
14 changes: 3 additions & 11 deletions plugin/src/features/Compilation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { CompiledContractsContext } from '../../contexts/CompiledContractsContex
import { RemixClientContext } from '../../contexts/RemixClientContext'
import { apiUrl } from '../../utils/network'
import {
artifactFilename,
artifactFolder,
getFileExtension,
getFileNameFromPath
Expand All @@ -17,6 +16,7 @@ import { ethers } from 'ethers'
import CompilationContext from '../../contexts/CompilationContext'
import { type AccordianTabs } from '../Plugin'
import { type Contract } from '../../types/contracts'
import { asyncFetch } from '../../utils/async_fetch'

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface CompilationProps {
Expand Down Expand Up @@ -355,16 +355,8 @@ const Compilation: React.FC<CompilationProps> = ({ setAccordian }) => {
}

setStatus('Compiling...')
response = await fetch(
`${apiUrl}/compile/${hashDir}/${currentFilePath}`,
{
method: 'GET',
redirect: 'follow',
headers: {
'Content-Type': 'text/plain'
}
}
)

response = await asyncFetch(`compile-async/${hashDir}/${currentFilePath}`, 'compile-result')

if (!response.ok) {
await remixClient.call(
Expand Down
1 change: 0 additions & 1 deletion plugin/src/features/Deployment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Container from '../../ui_components/Container'
import { RemixClientContext } from '../../contexts/RemixClientContext'
import { type AccordianTabs } from '../Plugin'
import TransactionContext from '../../contexts/TransactionContext'
import { Wallet, Provider } from 'zksync-web3'
import * as zksync from 'zksync-web3'
import ConstructorInput from '../../components/ConstructorInput'
import { DeployedContractsContext } from '../../contexts/DeployedContractsContext'
Expand Down
4 changes: 1 addition & 3 deletions plugin/src/utils/async_fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ export async function asyncFetch (method: string, getterMethod: string) {
try {
await waitProcess(pid)

const response = await fetch(`${apiUrl}/${getterMethod}/${pid}`, {
return await fetch(`${apiUrl}/${getterMethod}/${pid}`, {
method: 'GET',
redirect: 'follow',
headers: {
'Content-Type': 'application/octet-stream'
}
})

return await response.text()
} catch (e) {
throw new Error(`Error while running process with id ${pid}, error: ${e}`)
}
Expand Down

0 comments on commit 971c805

Please sign in to comment.