diff --git a/apps/remix-ide/ci/downloadsoljson2.sh b/apps/remix-ide/ci/downloadsoljson2.sh new file mode 100644 index 0000000000..c517f02fb1 --- /dev/null +++ b/apps/remix-ide/ci/downloadsoljson2.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +echo "Downloading specified soljson.js version based on defaultVersion in package.json" + +set -e + +# Check if curl and jq are installed +if ! command -v curl &> /dev/null; then + echo "curl could not be found" + exit 1 +fi + +if ! command -v jq &> /dev/null; then + echo "jq could not be found" + exit 1 +fi + +# Read the defaultVersion from package.json +defaultVersion=$(jq -r '.defaultVersion' package.json) +echo "Specified version from package.json: $defaultVersion" + +# Download the list.json file containing available versions +curl -s https://binaries.soliditylang.org/wasm/list.json > list.json + +# Use jq to extract the path for the specified version from the builds array +path=$(jq -r --arg version "$defaultVersion" '.builds[] | select(.path==$version) | .path' list.json) +if [ -z "$path" ]; then + echo "The specified version $defaultVersion could not be found in the list" + exit 1 +fi + +echo "Path for the specified version: $path" +fullPath="https://binaries.soliditylang.org/bin/$path" +echo "Download fullPath: $fullPath" + +# Ensure the target directory exists +if [ ! -d "./apps/remix-ide/src/assets/js/soljson" ]; then + mkdir -p ./apps/remix-ide/src/assets/js/soljson +fi + +# Download the file to ./apps/remix-ide/src/assets/js/soljson.js +curl -s "$fullPath" > ./apps/remix-ide/src/assets/js/soljson.js + +# Copy the downloaded soljson.js to the specific version directory +cp ./apps/remix-ide/src/assets/js/soljson.js "./apps/remix-ide/src/assets/js/soljson/$path" +cp list.json ./apps/remix-ide/src/assets/list.json + +# Clean up by removing the list.json +rm list.json diff --git a/apps/remix-ide/webpack.config.js b/apps/remix-ide/webpack.config.js index f9cd3155e5..301883ceec 100644 --- a/apps/remix-ide/webpack.config.js +++ b/apps/remix-ide/webpack.config.js @@ -16,7 +16,7 @@ const versionData = { const loadLocalSolJson = async () => { //execute apps/remix-ide/ci/downloadsoljson.sh - const child = require('child_process').execSync('bash ' + __dirname + '/ci/downloadsoljson.sh', { encoding: 'utf8', cwd: process.cwd(), shell: true }) + const child = require('child_process').execSync('bash ' + __dirname + '/ci/downloadsoljson2.sh', { encoding: 'utf8', cwd: process.cwd(), shell: true }) // show output //console.log(child) } diff --git a/libs/remix-solidity/src/compiler/compiler.ts b/libs/remix-solidity/src/compiler/compiler.ts index fd5f5be51e..85c475899b 100644 --- a/libs/remix-solidity/src/compiler/compiler.ts +++ b/libs/remix-solidity/src/compiler/compiler.ts @@ -112,6 +112,7 @@ export class Compiler { */ onCompilerLoaded(version: string, license: string): void { + console.log('compiler loaded:', version) this.state.currentVersion = version this.state.compilerLicense = license this.event.trigger('compilerLoaded', [version, license]) diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx index 0898fc76b3..0a6e2821e0 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -11,6 +11,7 @@ import {getValidLanguage} from '@remix-project/remix-solidity' import {CopyToClipboard} from '@remix-ui/clipboard' import {configFileContent} from './compilerConfiguration' import { appPlatformTypes, platformContext, onLineContext } from '@remix-ui/app' +import * as packageJson from '../../../../../package.json' import './css/style.css' @@ -18,6 +19,7 @@ import { CompilerDropdown } from './components/compiler-dropdown' const defaultPath = 'compiler_config.json' +console.log('local version', packageJson.defaultVersion) declare global { interface Window { @@ -61,7 +63,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { downloaded: [], compilerLicense: null, selectedVersion: null, - defaultVersion: 'soljson-v0.8.24+commit.e11b9ed9.js', // this default version is defined: in makeMockCompiler (for browser test) + defaultVersion: packageJson.defaultVersion, // this default version is defined: in makeMockCompiler (for browser test) runs: '', compiledFileName: '', includeNightlies: false, diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index 6481f5ddf4..4f5c768ae0 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -6,10 +6,13 @@ import { Toaster } from '@remix-ui/toaster' // eslint-disable-line import { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line import { Renderer } from '@remix-ui/renderer' // eslint-disable-line import { baseURLBin, baseURLWasm, pathToURL } from '@remix-project/remix-solidity' - +import * as packageJson from '../../../../../package.json' import './css/style.css' import { iSolJsonBinData, iSolJsonBinDataBuild } from '@remix-project/remix-lib' +const defaultPath = 'compiler_config.json' +console.log('local version', packageJson.defaultVersion) + export const SolidityCompiler = (props: SolidityCompilerProps) => { const { api, @@ -39,8 +42,9 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { handleHide: null }, solJsonBinData: null, - defaultVersion: 'soljson-v0.8.25+commit.b61c2a91.js', // this default version is defined: in makeMockCompiler (for browser test) + defaultVersion: packageJson.defaultVersion, // this default version is defined: in makeMockCompiler (for browser test) }) + const [currentVersion, setCurrentVersion] = useState('') const [hideWarnings, setHideWarnings] = useState(false) const [compileErrors, setCompileErrors] = useState>({ [currentFile]: api.compileErrors }) diff --git a/package.json b/package.json index d32748ffce..7a859ee86a 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "license": "MIT", "description": "Ethereum Remix Monorepo", "main": "index.js", + "defaultVersion": "soljson-v0.8.24+commit.e11b9ed9.js", "keywords": [ "ethereum", "solidity",