From 8a7a53762e13c66e648f2737b610af59436c06c0 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 28 Jul 2022 19:34:34 +0530 Subject: [PATCH] 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('/')