From 8a7a53762e13c66e648f2737b610af59436c06c0 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 28 Jul 2022 19:34:34 +0530 Subject: [PATCH 1/3] handle various compiler version from URL --- .../solidity-compiler/src/lib/compiler-container.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 34613067a2..527a83b54b 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -309,7 +309,14 @@ export const CompilerContainer = (props: CompilerContainerProps) => { allVersions = [...allVersions, ...versions] selectedVersion = state.defaultVersion - if (api.getCompilerParameters().version) selectedVersion = api.getCompilerParameters().version + if (api.getCompilerParameters().version) { + const versionFromURL = api.getCompilerParameters().version + // URL version can be like 0.8.7+commit.e28d00a7, 0.8.7 or soljson-v0.8.7+commit.e28d00a7.js + const selectedVersionArr = versions.filter(obj => obj.path === versionFromURL || obj.longVersion === versionFromURL || obj.version === versionFromURL) + // for version like 0.8.15, there will be more than one elements in the array + // In that case too, index 0 will have non-nightly version object + if (selectedVersionArr.length) selectedVersion = selectedVersionArr[0].path + } // Check if version is a URL and corresponding filename starts with 'soljson' if (selectedVersion.startsWith('https://')) { const urlArr = selectedVersion.split('/') From 475abb0697f4cf6cb773f09bf0add3a3b39c84cc Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 29 Jul 2022 10:33:29 +0530 Subject: [PATCH 2/3] handle compiler link --- .../src/lib/compiler-container.tsx | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) 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 527a83b54b..d0c5e90025 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -311,17 +311,20 @@ export const CompilerContainer = (props: CompilerContainerProps) => { selectedVersion = state.defaultVersion if (api.getCompilerParameters().version) { const versionFromURL = api.getCompilerParameters().version - // URL version can be like 0.8.7+commit.e28d00a7, 0.8.7 or soljson-v0.8.7+commit.e28d00a7.js - const selectedVersionArr = versions.filter(obj => obj.path === versionFromURL || obj.longVersion === versionFromURL || obj.version === versionFromURL) - // for version like 0.8.15, there will be more than one elements in the array - // In that case too, index 0 will have non-nightly version object - if (selectedVersionArr.length) selectedVersion = selectedVersionArr[0].path - } - // Check if version is a URL and corresponding filename starts with 'soljson' - if (selectedVersion.startsWith('https://')) { - const urlArr = selectedVersion.split('/') - - if (urlArr[urlArr.length - 1].startsWith('soljson')) isURL = true + // Check if version is a URL and corresponding filename starts with 'soljson' + if (versionFromURL.startsWith('https://')) { + const urlArr = versionFromURL.split('/') + if (urlArr[urlArr.length - 1].startsWith('soljson')) { + isURL = true + selectedVersion = versionFromURL + } + } else { + // URL version can be like 0.8.7+commit.e28d00a7, 0.8.7 or soljson-v0.8.7+commit.e28d00a7.js + const selectedVersionArr = versions.filter(obj => obj.path === versionFromURL || obj.longVersion === versionFromURL || obj.version === versionFromURL) + // for version like 0.8.15, there will be more than one elements in the array + // In that case too, index 0 will have non-nightly version object + if (selectedVersionArr.length) selectedVersion = selectedVersionArr[0].path + } } if (wasmRes.event.type !== 'error') { allVersionsWasm = JSON.parse(wasmRes.json).builds.slice().reverse() From 15771cebbc477c8c6be326f8d359b2802f812ca0 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 29 Jul 2022 10:43:04 +0530 Subject: [PATCH 3/3] added e2e --- apps/remix-ide-e2e/src/tests/url.test.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/url.test.ts b/apps/remix-ide-e2e/src/tests/url.test.ts index 91139619e8..b85b2caa1e 100644 --- a/apps/remix-ide-e2e/src/tests/url.test.ts +++ b/apps/remix-ide-e2e/src/tests/url.test.ts @@ -159,7 +159,7 @@ module.exports = { .expect.element('[data-id="contractGUIUpgradeImplementation"]').to.be.selected }, - 'Should load using URL compiler params': function (browser: NightwatchBrowser) { + 'Should load using various URL compiler params': function (browser: NightwatchBrowser) { browser .pause(5000) .url('http://127.0.0.1:8080/#optimize=true&runs=300&autoCompile=true&evmVersion=istanbul&version=soljson-v0.7.4+commit.3f05b770.js&language=Yul') @@ -173,6 +173,16 @@ module.exports = { .verify.elementPresent('#optimize:checked') .verify.elementPresent('#autoCompile:checked') .verify.attributeEquals('#runs', 'value', '300') + .url('http://127.0.0.1:8080/#version=0.8.7') + .refresh() + .pause(5000) + .clickLaunchIcon('solidity') + .assert.containsText('#versionSelector option[data-id="selected"]', '0.8.7+commit.e28d00a7') + .url('http://127.0.0.1:8080/#version=0.8.15+commit.e14f2714') + .refresh() + .pause(5000) + .clickLaunchIcon('solidity') + .assert.containsText('#versionSelector option[data-id="selected"]', '0.8.15+commit.e14f2714') }, 'Should load using compiler from link passed in remix URL': function (browser: NightwatchBrowser) {