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

Commit

Permalink
polish code
Browse files Browse the repository at this point in the history
  • Loading branch information
varex83 committed Nov 13, 2023
1 parent 1c9fb9c commit 449f9ae
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions api/src/handlers/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::handlers::process::{do_process_command, fetch_process_result};
use crate::handlers::types::{ApiCommand, ApiCommandResult, CompileResponse, SolFile};
use crate::rate_limiter::RateLimited;
use crate::types::{ApiError, Result};
use crate::utils::hardhat_config::{HardhatConfig, HardhatConfigBuilder};
use crate::utils::hardhat_config::HardhatConfigBuilder;
use crate::utils::lib::{
check_file_ext, get_file_path, path_buf_to_string, status_code_to_message,
to_human_error_batch, ALLOWED_VERSIONS, ARTIFACTS_ROOT, SOL_ROOT,
Expand Down Expand Up @@ -71,7 +71,7 @@ pub async fn do_compile(
version: String,
remix_file_path: PathBuf,
) -> Result<Json<CompileResponse>> {
if ALLOWED_VERSIONS.contains(&version.as_str()) == false {
if !ALLOWED_VERSIONS.contains(&version.as_str()) {
return Err(ApiError::VersionNotSupported(version));
}

Expand Down
2 changes: 1 addition & 1 deletion api/src/handlers/save_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub async fn do_save_code(
version: String,
remix_file_path: PathBuf,
) -> Result<String> {
if (ALLOWED_VERSIONS.contains(&version.as_str())) == false {
if !ALLOWED_VERSIONS.contains(&version.as_str()) {
return Err(ApiError::VersionNotSupported(version));
}

Expand Down
6 changes: 3 additions & 3 deletions api/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ use tracing::info;

#[launch]
async fn rocket() -> _ {
// if let Err(err) = init_logger() {
// eprintln!("Error initializing logger: {}", err);
// }
if let Err(err) = init_logger() {
eprintln!("Error initializing logger: {}", err);
}

let number_of_workers = match std::env::var("WORKER_THREADS") {
Ok(v) => v.parse::<u32>().unwrap_or(2u32),
Expand Down
21 changes: 13 additions & 8 deletions api/src/utils/hardhat_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,30 @@ pub struct HardhatConfig {
pub paths: PathsConfig,
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Default)]
pub struct ZksolcConfig {
pub version: String,
pub settings: serde_json::Value,
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Default)]
pub struct SolidityConfig {
pub version: String,
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Default)]
pub struct PathsConfig {
pub sources: String,
pub artifacts: String,
}

#[derive(Default)]
pub struct HardhatConfigBuilder {
config: HardhatConfig,
}

impl HardhatConfig {
pub fn new() -> Self {
impl Default for HardhatConfig {
fn default() -> Self {
Self {
name: Self::generate_random_name(),
zksolc: ZksolcConfig {
Expand All @@ -49,6 +50,12 @@ impl HardhatConfig {
},
}
}
}

impl HardhatConfig {
pub fn new() -> Self {
Self::default()
}

pub fn to_string_config(&self) -> String {
let config_prefix_js = r#"
Expand Down Expand Up @@ -122,9 +129,7 @@ export default config;

impl HardhatConfigBuilder {
pub fn new() -> Self {
Self {
config: HardhatConfig::new(),
}
Self::default()
}

pub fn zksolc_version(&mut self, version: &str) -> &mut Self {
Expand Down
2 changes: 1 addition & 1 deletion api/src/utils/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub fn to_human_error(
pub fn to_human_error_batch(diagnostics: Vec<Diagnostic>) -> String {
diagnostics
.into_iter()
.map(|diagnostic| to_human_error(diagnostic))
.map(to_human_error)
.collect::<Vec<String>>()
.join("\n")
}
2 changes: 1 addition & 1 deletion plugin/src/components/BackgroundNotices/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'

const Notices = [
'The zksync Remix Plugin is in Alpha',
'The zkSync Remix Plugin is in Alpha',
'Solidity contracts are compiled on a server hosted by Nethermind'
]

Expand Down
4 changes: 2 additions & 2 deletions plugin/src/features/CompilerVersion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ const SolidityVersion: React.FC = () => {

setVersions(allowedVersions)

if (versions.length > 0 && solidityVersion === '') {
setSolidityVersion(versions[0])
if (allowedVersions.length > 0) {
setSolidityVersion(allowedVersions[0])
}
}
} catch (e) {
Expand Down
5 changes: 0 additions & 5 deletions plugin/src/features/Deployment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ const Deployment: React.FC<DeploymentProps> = ({ setActiveTab }) => {
type: 'info'
})

remixClient.terminal.log({
value: `Abi: ${JSON.stringify(selectedContract.abi, null, 2)}`,
type: 'info'
})

const factory = new zksync.ContractFactory(
selectedContract.abi,
selectedContract.bytecode,
Expand Down

0 comments on commit 449f9ae

Please sign in to comment.