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

Commit

Permalink
fix rust and js formating issues
Browse files Browse the repository at this point in the history
Signed-off-by: Jasti Sri Radhe Shyam <[email protected]>
  • Loading branch information
radhe-zeeve committed Dec 13, 2023
1 parent 7b81d50 commit f396c71
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 17 deletions.
6 changes: 5 additions & 1 deletion crates/backend/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ pub struct Opts {
#[arg(short = 'f', long = "frontend_folder")]
pub frontend_folder: Option<String>,

#[arg(long = "versions_file_path", default_value = "./config/versions.json", env = "VERSIONS_FILE_PATH")]
#[arg(
long = "versions_file_path",
default_value = "./config/versions.json",
env = "VERSIONS_FILE_PATH"
)]
pub versions_file_path: String,

#[arg(short = 'g', long = "github_token", env = "GITHUB_GIST_TOKEN")]
Expand Down
2 changes: 1 addition & 1 deletion crates/backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async fn main() -> std::io::Result<()> {
get().to(route_status),
)
.app_data(web::Data::new(AppVersionState {
versions_file_path: versions_file_path,
versions_file_path,
}))
.service(
web::resource("/version_list").to(route_version_list)
Expand Down
1 change: 0 additions & 1 deletion crates/backend/src/services/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ pub async fn route_status() -> HttpResponse<BoxBody> {
HttpResponse::Ok().body("ink-compiler is live")
}


// -------------------------------------------------------------------------------------------------
// TESTS
// -------------------------------------------------------------------------------------------------
Expand Down
11 changes: 8 additions & 3 deletions crates/backend/src/services/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@

//! This module contains the service which serves the backend as static files.

use std::path::{PathBuf, Path};
use actix_web::{Result, web};
use actix_files as fs;
use actix_web::{
web,
Result,
};
use std::path::Path;

pub struct FrontendState {
pub frontend_folder: String,
Expand All @@ -29,7 +32,9 @@ pub fn route_frontend(at: &str, dir: &str) -> actix_files::Files {
pub async fn route_frontend_version(
data: web::Data<FrontendState>,
) -> Result<actix_files::NamedFile> {
Ok(fs::NamedFile::open(PathBuf::from(Path::new(&data.frontend_folder).join("index.html")))?)
Ok(fs::NamedFile::open(
Path::new(&data.frontend_folder).join("index.html"),
)?)
}

#[cfg(test)]
Expand Down
13 changes: 10 additions & 3 deletions crates/backend/src/services/version.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
use std::fs;

use actix_web::{body::BoxBody, web, HttpResponse};
use actix_web::{
body::BoxBody,
web,
HttpResponse,
};

pub use sandbox::VersionListResult;
use serde_json::{json, Value};
use serde_json::{
json,
Value,
};

pub struct AppVersionState {
pub versions_file_path: String,
Expand All @@ -17,7 +24,7 @@ pub async fn route_version_list(
data: web::Data<AppVersionState>,
) -> HttpResponse<BoxBody> {
let versions_file_path = &data.versions_file_path;
let versions_arr_string = read_json_file(&versions_file_path).unwrap();
let versions_arr_string = read_json_file(versions_file_path).unwrap();
let versions_arr_json: Value =
serde_json::from_str(versions_arr_string.as_str()).expect("Failed to parse JSON");
let versions_json = json!({
Expand Down
4 changes: 2 additions & 2 deletions crates/generate-bindings/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ mod cli;

use crate::cli::Cli;
use backend::services::{
version::VersionListResult,
contract::{
CompilationRequest,
CompilationResult,
Expand All @@ -38,6 +37,7 @@ use backend::services::{
GistLoadResponse,
},
},
version::VersionListResult,
};
use clap::Parser;
use std::{
Expand Down Expand Up @@ -65,7 +65,7 @@ fn main() -> std::io::Result<()> {
GistLoadResponse,
GistCreateRequest,
GistCreateResponse,
VersionListResult
VersionListResult,
);

let path = Path::new(&target);
Expand Down
5 changes: 4 additions & 1 deletion crates/sandbox/src/build_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
//! strategy. This allows easy mocking.

use crate::docker_command;
use std::{path::Path, time::Duration};
use std::{
path::Path,
time::Duration,
};
use tokio::process::Command;

const DOCKER_PROCESS_TIMEOUT_SOFT: Duration = Duration::from_secs(20);
Expand Down
6 changes: 3 additions & 3 deletions crates/sandbox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub enum FormattingResult {
#[serde(rename_all = "snake_case")]
// #[serde(tag = "type", content = "payload", rename_all = "SCREAMING_SNAKE_CASE")]
pub struct VersionListResult {
versions: Vec<String>
versions: Vec<String>,
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -201,8 +201,8 @@ impl Sandbox {
pub fn compile(&self, req: &CompilationRequest) -> Result<CompilationResult> {
self.write_source_code(&req.source)?;

let command = build_compile_command(&self.input_file, &self.output_dir, &req.version);

let command =
build_compile_command(&self.input_file, &self.output_dir, &req.version);
println!("Executing command: \n{:?}", command);

let output = run_command_with_timeout(command)?;
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/src/app/Header/VersionsSubmenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MenuSelectElementWrapper, MenuElementWrapper } from '@paritytech/components/';
import { MenuSelectElementWrapper } from '@paritytech/components/';
import { ReactElement, useContext } from 'react';
import { AppContext } from '~/context/app/';
import { Dispatch, State } from '~/context/app/reducer';
Expand Down
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct_field_align_threshold = 0
enum_discrim_align_threshold = 0
match_arm_blocks = true
force_multiline_blocks = true # changed
fn_args_layout = "Tall"
fn_params_layout = "Tall"
brace_style = "SameLineWhere"
control_brace_style = "AlwaysSameLine"
trailing_semicolon = false # changed
Expand Down

0 comments on commit f396c71

Please sign in to comment.