diff --git a/crates/sandbox/src/build_command.rs b/crates/sandbox/src/build_command.rs index b9c0c5138..289a1b648 100644 --- a/crates/sandbox/src/build_command.rs +++ b/crates/sandbox/src/build_command.rs @@ -131,7 +131,7 @@ fn build_execution_command() -> Vec { "rm -rf {}/contract.* {}/metadata.json", target_dir, target_dir ); - let build_cmd = "cargo contract build --offline --skip-linting 2>&1".to_string(); + let build_cmd = "cargo contract build --offline 2>&1".to_string(); let move_cmd = format!("mv {}/contract.contract {}", target_dir, DOCKER_OUTPUT); let command = format!("{} && {} && {}", clean_cmd, build_cmd, move_cmd); diff --git a/crates/sandbox/src/lib.rs b/crates/sandbox/src/lib.rs index a6b89ec8c..c06ff361d 100644 --- a/crates/sandbox/src/lib.rs +++ b/crates/sandbox/src/lib.rs @@ -165,7 +165,7 @@ pub enum FormattingResult { // CONSTANTS // ------------------------------------------------------------------------------------------------- -const DOCKER_PROCESS_TIMEOUT_HARD: Duration = Duration::from_secs(30); +const DOCKER_PROCESS_TIMEOUT_HARD: Duration = Duration::from_secs(60); // ------------------------------------------------------------------------------------------------- // TRAIT IMPLEMENTATION diff --git a/packages/ink-editor/src/example-code.ts b/packages/ink-editor/src/example-code.ts deleted file mode 100644 index a48ab7de6..000000000 --- a/packages/ink-editor/src/example-code.ts +++ /dev/null @@ -1,55 +0,0 @@ -export default `#![cfg_attr(not(feature = "std"), no_std)] - -#[ink::contract] -pub mod flipper { - #[ink(storage)] - pub struct Flipper { - value: bool, - } - - impl Flipper { - /// Creates a new flipper smart contract initialized with the given value. - #[ink(constructor)] - pub fn new(init_value: bool) -> Self { - Self { value: init_value } - } - - /// Creates a new flipper smart contract initialized to \`false\`. - #[ink(constructor)] - pub fn default() -> Self { - Self::new(Default::default()) - } - - /// Flips the current value of the Flipper's boolean. - #[ink(message)] - pub fn flip(&mut self) { - self.value = !self.value; - } - - /// Returns the current value of the Flipper's boolean. - #[ink(message)] - pub fn get(&self) -> bool { - self.value - } - } - - #[cfg(test)] - mod tests { - use super::*; - - #[ink::test] - fn default_works() { - let flipper = Flipper::default(); - assert!(!flipper.get()); - } - - #[ink::test] - fn it_works() { - let mut flipper = Flipper::new(false); - assert!(!flipper.get()); - flipper.flip(); - assert!(flipper.get()); - } - } -} -`; diff --git a/packages/ink-editor/src/index.tsx b/packages/ink-editor/src/index.tsx index 02eff23cc..eb8aa11bc 100644 --- a/packages/ink-editor/src/index.tsx +++ b/packages/ink-editor/src/index.tsx @@ -1,4 +1,5 @@ -import exampleCode from './example-code'; +// See: https://github.com/webpack/webpack/issues/12900 +import exampleCode from '../../../crates/contract/lib.txt!=!../../../crates/contract/lib.rs'; import { InkEditor, InkEditorProps } from './ink-editor'; export { exampleCode, InkEditor }; export type { InkEditorProps }; diff --git a/packages/ink-editor/src/module.d.ts b/packages/ink-editor/src/module.d.ts index f722fd334..9f3fd67ce 100644 --- a/packages/ink-editor/src/module.d.ts +++ b/packages/ink-editor/src/module.d.ts @@ -1 +1,2 @@ declare module 'monaco-editor/esm/vs/basic-languages/rust/rust'; +declare module '*.rs'; diff --git a/packages/ink-editor/webpack.config.js b/packages/ink-editor/webpack.config.js index 8df7ca5c6..29e939982 100644 --- a/packages/ink-editor/webpack.config.js +++ b/packages/ink-editor/webpack.config.js @@ -41,6 +41,10 @@ const webpackConfig = { }, ], }, + { + test: /\.txt$/, + type: 'asset/source', + }, ], }, plugins: [ diff --git a/packages/playground/src/context/side-effects/load-code.ts b/packages/playground/src/context/side-effects/load-code.ts index a288ae1e8..dae05354c 100644 --- a/packages/playground/src/context/side-effects/load-code.ts +++ b/packages/playground/src/context/side-effects/load-code.ts @@ -3,7 +3,8 @@ import { MessageDispatch } from '../messages/reducer'; import { gistLoadRequest } from '@paritytech/ink-editor/api/gists'; import { GistCreateResponse } from '@paritytech/commontypes'; import qs from 'qs'; -import exampleCode from '@paritytech/ink-editor/example-code'; +// See: https://github.com/webpack/webpack/issues/12900 +import exampleCode from '../../../../../crates/contract/lib.txt!=!../../../../../crates/contract/lib.rs'; import { GIST_LOAD_URL } from '~/env'; type Params = { id?: string }; @@ -67,6 +68,7 @@ export async function loadCode(state: State, dispatch: Dispatch): Promise