commit
e4339ad539
@ -1,63 +1,77 @@ |
|||||||
const testFolder = './apps/remix-ide-e2e/src/tests/'; |
|
||||||
const fs = require('fs'); |
const fs = require('fs'); |
||||||
|
var child_process = require('child_process'); |
||||||
|
const { exit } = require('process'); |
||||||
|
|
||||||
let url = 'https://binaries.soliditylang.org/wasm/list.json' |
const child = child_process.spawnSync('grep -r --include="*.json" --include="*.ts" --include="*.tsx" "+commit" apps/**/* libs/**/*', [], { encoding: 'utf8', cwd: process.cwd(), shell: true }); |
||||||
|
|
||||||
const axios = require('axios') |
if (child.error) { |
||||||
|
console.log("ERROR: ", child); |
||||||
|
exit(1); |
||||||
|
} |
||||||
|
|
||||||
// use axios to download the file
|
|
||||||
axios({ |
|
||||||
url: url, |
|
||||||
method: 'GET', |
|
||||||
}).then((response) => { |
|
||||||
|
|
||||||
let info = response.data; |
let soljson =[]; |
||||||
info.builds = info.builds.filter(build => build.path.indexOf('nightly') === -1) |
|
||||||
for (let build of info.builds) { |
|
||||||
|
|
||||||
const buildurl = `https://solc-bin.ethereum.org/wasm/${build.path}`; |
const quotedVersionsRegex = /['"v]\d*\.\d*\.\d*\+commit\.[\d\w]*/g; |
||||||
console.log(buildurl) |
let quotedVersionsRegexMatch = child.stdout.match(quotedVersionsRegex) |
||||||
|
if(quotedVersionsRegexMatch){ |
||||||
|
let soljson2 = quotedVersionsRegexMatch.map((item) => item.replace('\'', 'v').replace('"', 'v')) |
||||||
|
console.log('non nightly soljson versions found: ', soljson2); |
||||||
|
if(soljson2) soljson = soljson.concat(soljson2); |
||||||
|
} |
||||||
|
|
||||||
const path = `./dist/apps/remix-ide/assets/js/${build.path}`; |
|
||||||
// use axios to get the file
|
|
||||||
axios({ |
|
||||||
method: 'get', |
|
||||||
url: buildurl, |
|
||||||
responseType: 'stream' |
|
||||||
}).then(function (response) { |
|
||||||
// pipe the result stream into a file on disc
|
|
||||||
response.data.pipe(fs.createWriteStream(path)); |
|
||||||
}) |
|
||||||
|
|
||||||
} |
const nightlyVersionsRegex = /\d*\.\d*\.\d-nightly.*\+commit\.[\d\w]*/g |
||||||
|
const nightlyVersionsRegexMatch = child.stdout.match(nightlyVersionsRegex) |
||||||
|
if(nightlyVersionsRegexMatch){ |
||||||
|
let soljson3 = nightlyVersionsRegexMatch.map((item) => 'v' + item); |
||||||
|
console.log('nightly soljson versions found: ', soljson3); |
||||||
|
if(soljson3) soljson = soljson.concat(soljson3); |
||||||
} |
} |
||||||
) |
|
||||||
|
if (soljson) { |
||||||
fs.readdirSync(testFolder).forEach(file => { |
// filter out duplicates
|
||||||
let c = fs.readFileSync(testFolder + file, 'utf8'); |
soljson = soljson.filter((item, index) => soljson.indexOf(item) === index); |
||||||
const re = /(?<=soljson).*(?=(.js))/g; |
|
||||||
const soljson = c.match(re); |
// manually add some versions
|
||||||
if (soljson) { |
soljson.push('v0.7.6+commit.7338295f'); |
||||||
for (let i = 0; i < soljson.length; i++) { |
|
||||||
|
console.log('soljson versions found: ', soljson, soljson.length); |
||||||
const version = soljson[i]; |
|
||||||
if (version && version.indexOf('nightly') > -1) { |
for (let i = 0; i < soljson.length; i++) { |
||||||
const url = `https://solc-bin.ethereum.org/bin/soljson${version}.js`; |
const version = soljson[i]; |
||||||
console.log(url) |
if (version) { |
||||||
|
let url = '' |
||||||
const path = `./dist/apps/remix-ide/assets/js/soljson${version}.js`; |
|
||||||
// use axios to get the file
|
// if nightly
|
||||||
axios({ |
if (version.includes('nightly')) { |
||||||
method: 'get', |
url = `https://binaries.soliditylang.org/bin/soljson-${version}.js`; |
||||||
url: url, |
}else{ |
||||||
responseType: 'stream' |
url = `https://binaries.soliditylang.org/wasm/soljson-${version}.js`; |
||||||
}).then(function (response) { |
|
||||||
// pipe the result stream into a file on disc
|
|
||||||
response.data.pipe(fs.createWriteStream(path)); |
|
||||||
}) |
|
||||||
} |
} |
||||||
|
|
||||||
|
const dir = './dist/apps/remix-ide/assets/js/soljson'; |
||||||
|
if (!fs.existsSync(dir)) { |
||||||
|
fs.mkdirSync(dir); |
||||||
|
} |
||||||
|
|
||||||
|
const path = `./dist/apps/remix-ide/assets/js/soljson/soljson-${version}.js`; |
||||||
|
// check if the file exists
|
||||||
|
const exists = fs.existsSync(path); |
||||||
|
if (!exists) { |
||||||
|
console.log('URL:', url) |
||||||
|
try { |
||||||
|
// use curl to download the file
|
||||||
|
child_process.exec(`curl -o ${path} ${url}`, { encoding: 'utf8', cwd: process.cwd(), shell: true }) |
||||||
|
} catch (e) { |
||||||
|
console.log('Failed to download soljson' + version + ' from ' + url) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}); |
} |
||||||
|
|
||||||
|
@ -0,0 +1,33 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
echo "Downloading latest soljson.js from https://binaries.soliditylang.org/wasm/list.json" |
||||||
|
set -e |
||||||
|
# check if curl is installed |
||||||
|
if ! command -v curl &> /dev/null |
||||||
|
then |
||||||
|
echo "curl could not be found" |
||||||
|
exit |
||||||
|
fi |
||||||
|
|
||||||
|
|
||||||
|
# download https://binaries.soliditylang.org/wasm/list.json as json |
||||||
|
curl -s https://binaries.soliditylang.org/wasm/list.json > list.json |
||||||
|
# get the latest version without jq |
||||||
|
latest=$(grep 'latestRelease' list.json | cut -d '"' -f 4) |
||||||
|
echo "latest version: $latest" |
||||||
|
# get url |
||||||
|
url=$(grep "\"$latest\":" list.json | cut -d '"' -f 4) |
||||||
|
echo "url: $url" |
||||||
|
path="https://binaries.soliditylang.org/bin/$url" |
||||||
|
echo "path: $path" |
||||||
|
# download the file to ./apps/remix-ide/src/assets/js/soljson.js |
||||||
|
curl -s $path > ./apps/remix-ide/src/assets/js/soljson.js |
||||||
|
# if directory ./apps/remix-ide/src/assets/js/soljson does not exist, create it |
||||||
|
if [ ! -d "./apps/remix-ide/src/assets/js/soljson" ]; then |
||||||
|
mkdir ./apps/remix-ide/src/assets/js/soljson |
||||||
|
fi |
||||||
|
cp ./apps/remix-ide/src/assets/js/soljson.js ./apps/remix-ide/src/assets/js/soljson/$url |
||||||
|
|
||||||
|
# remove list.json |
||||||
|
rm list.json |
||||||
|
|
@ -0,0 +1,31 @@ |
|||||||
|
import React, { useEffect, useRef } from "react"; |
||||||
|
|
||||||
|
type UploadFileProps = { |
||||||
|
onUpload: (target: EventTarget & HTMLInputElement, files?: FileList) => void; |
||||||
|
accept?: string; |
||||||
|
multiple?: boolean; |
||||||
|
}; |
||||||
|
|
||||||
|
const UploadFile = (props: UploadFileProps) => { |
||||||
|
const ref = useRef<HTMLInputElement>(); |
||||||
|
|
||||||
|
useEffect(() => { |
||||||
|
ref.current.click(); |
||||||
|
ref.current.onchange= (event)=>{ |
||||||
|
//@ts-ignore
|
||||||
|
props.onUpload(event.target, event.target.files); |
||||||
|
} |
||||||
|
}, []); |
||||||
|
|
||||||
|
return ( |
||||||
|
<input |
||||||
|
ref={ref} |
||||||
|
style={{ display: "none" }} |
||||||
|
accept={props.accept} |
||||||
|
multiple={props.multiple} |
||||||
|
type="file" |
||||||
|
/> |
||||||
|
); |
||||||
|
}; |
||||||
|
|
||||||
|
export default UploadFile; |
Loading…
Reference in new issue