From bd5d6e6e248b5b54faf4bd38521060b1b995c16d Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 4 Jun 2024 14:01:47 +0100 Subject: [PATCH 01/11] fix obtain solidity ver function --- .../run-tab/src/lib/components/universalDappUI.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx index 3a22192ad3..836e012ccd 100644 --- a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx @@ -28,8 +28,16 @@ export function UniversalDappUI(props: UdappProps) { const [evmBC, setEvmBC] = useState(null) const [instanceBalance, setInstanceBalance] = useState(0) - const getVersion = () => window.location.href.split('=')[5].split('+')[0].split('-')[1] - + const getVersion = () => { + let version = '' + try { + version = window.location.href.split('=')[5].split('+')[0].split('-')[1] + console.log('try part to see what version is', version) + } catch { + version = window.location.href.split('=')[5].split('+')[0].split('-')[1] + console.log('there was an error so retrying. lets see what version is now', version) + } + } useEffect(() => { if (!props.instance.abi) { const abi = txHelper.sortAbiFunction(props.instance.contractData.abi) From 641267d69d4863861e796503d2b504b97634fee7 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 4 Jun 2024 15:16:10 +0100 Subject: [PATCH 02/11] cleanup console logs --- libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx index 836e012ccd..88288665e7 100644 --- a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx @@ -32,11 +32,10 @@ export function UniversalDappUI(props: UdappProps) { let version = '' try { version = window.location.href.split('=')[5].split('+')[0].split('-')[1] - console.log('try part to see what version is', version) } catch { version = window.location.href.split('=')[5].split('+')[0].split('-')[1] - console.log('there was an error so retrying. lets see what version is now', version) } + return version } useEffect(() => { if (!props.instance.abi) { From ce70beb1ab46720d6d59afc5724dc64a07c164ff Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Thu, 6 Jun 2024 14:05:52 +0100 Subject: [PATCH 03/11] cater to compiler version for old ones --- .../src/lib/components/universalDappUI.tsx | 52 +++++++++++++------ 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx index 88288665e7..3051a92b21 100644 --- a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx @@ -28,14 +28,41 @@ export function UniversalDappUI(props: UdappProps) { const [evmBC, setEvmBC] = useState(null) const [instanceBalance, setInstanceBalance] = useState(0) - const getVersion = () => { - let version = '' - try { - version = window.location.href.split('=')[5].split('+')[0].split('-')[1] - } catch { - version = window.location.href.split('=')[5].split('+')[0].split('-')[1] + const UrlLink = () => { + + const getVersion = () => { + let version = '' + try { + version = window.location.href.split('=')[5].split('+')[0].split('-')[1] + } catch { + version = window.location.href.split('=')[5].split('+')[0].split('-')[1] + } + return version } - return version + + return ( +
+
+ +
+ } + > + { + parseFloat(getVersion()) < 0.6 ? ( + + + + ) : + + + } + +
+ ) } useEffect(() => { if (!props.instance.abi) { @@ -472,16 +499,7 @@ export function UniversalDappUI(props: UdappProps) { })}
-
-
- -
- }> - - - - -
+
From 840af9562b488b50521fc6a8439b6ffa5f93471b Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Fri, 7 Jun 2024 09:43:51 +0100 Subject: [PATCH 04/11] refine fix --- .../run-tab/src/lib/components/universalDappUI.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx index 3051a92b21..8105e53b48 100644 --- a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx @@ -37,9 +37,9 @@ export function UniversalDappUI(props: UdappProps) { } catch { version = window.location.href.split('=')[5].split('+')[0].split('-')[1] } - return version + return [version, parseFloat(version.slice(1))] } - + console.log('getVersion', getVersion()[1]) return (
@@ -51,12 +51,12 @@ export function UniversalDappUI(props: UdappProps) { tooltipId="receiveEthDocstoolTip" tooltipText={} > - { - parseFloat(getVersion()) < 0.6 ? ( - + { // receive method added to solidity v0.6.x. use this as diff. + (getVersion()[1] as number) < 0.6 ? ( + - ) : + ) : } From aaa06a0497a9f879be2a08d4cc0787f03a1761b5 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Fri, 7 Jun 2024 09:45:47 +0100 Subject: [PATCH 05/11] cleanup console.log --- libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx index 8105e53b48..8381266053 100644 --- a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx @@ -39,7 +39,7 @@ export function UniversalDappUI(props: UdappProps) { } return [version, parseFloat(version.slice(1))] } - console.log('getVersion', getVersion()[1]) + return (
From ecdfbbd7d5a9b5af14d96bd2ace9afde7dc00d54 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Fri, 7 Jun 2024 12:43:21 +0100 Subject: [PATCH 06/11] make compiler version part of state. update props --- .../src/lib/components/contractDropdownUI.tsx | 3 + .../src/lib/components/contractGUI.tsx | 17 +++++ .../lib/components/instanceContainerUI.tsx | 4 + .../src/lib/components/universalDappUI.tsx | 76 +++++++++---------- libs/remix-ui/run-tab/src/lib/run-tab.tsx | 21 +++++ libs/remix-ui/run-tab/src/lib/types/index.ts | 14 ++++ 6 files changed, 97 insertions(+), 38 deletions(-) diff --git a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx index cc58d83f1f..e8c30598de 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx @@ -483,6 +483,9 @@ export function ContractDropdownUI(props: ContractDropdownProps) { isValidProxyUpgrade={isValidProxyUpgrade} modal={props.modal} disabled={props.selectedAccount === ''} + solcVersion={props.solCompilerVersion} + setSolcVersion={props.setCompilerVersion} + getVersion={props.getCompilerVersion} />
>([]) const basicInputRef = useRef() const intl = useIntl() + // const [solcVersion, setSolcVersion] = useState({ version: '', canReceive: true }) + + // const getVersion = () => { + // let version = '' + // try { + // version = window.location.href.split('=')[5].split('+')[0].split('-')[1].slice(1) + // if (parseFloat(version) < 0.6) { + // setSolcVersion({ version: version, canReceive: false }) + // } + // setSolcVersion({ version: version, canReceive: false }) + // } catch (e) { + // version = window.location.href.split('=')[5].split('+')[0].split('-')[1].slice(1) + // console.log(e) + // } + // return version + // } useEffect(() => { if (props.deployOption && Array.isArray(props.deployOption)) { @@ -173,6 +189,7 @@ export function ContractGUI(props: ContractGUIProps) { } const handleActionClick = async () => { + props.getVersion() if (deployState.deploy) { const proxyInitializeString = getMultiValsString(initializeFields.current) props.clickCallBack(props.initializerOptions.inputs.inputs, proxyInitializeString, ['Deploy with Proxy']) diff --git a/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx b/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx index 7ebf00fc68..2d247e0d4c 100644 --- a/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx @@ -44,6 +44,8 @@ export function InstanceContainerUI(props: InstanceContainerProps) { plugin={props.plugin} exEnvironment={props.exEnvironment} editInstance={props.editInstance} + solcVersion={props.solcVersion} + getVersion={props.getVersion} /> ) })} @@ -92,6 +94,8 @@ export function InstanceContainerUI(props: InstanceContainerProps) { plugin={props.plugin} exEnvironment={props.exEnvironment} editInstance={props.editInstance} + solcVersion={props.solcVersion} + getVersion={props.getVersion} /> ) })} diff --git a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx index 8381266053..40b36f8e0c 100644 --- a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx @@ -27,43 +27,22 @@ export function UniversalDappUI(props: UdappProps) { const [calldataValue, setCalldataValue] = useState('') const [evmBC, setEvmBC] = useState(null) const [instanceBalance, setInstanceBalance] = useState(0) - - const UrlLink = () => { - - const getVersion = () => { - let version = '' - try { - version = window.location.href.split('=')[5].split('+')[0].split('-')[1] - } catch { - version = window.location.href.split('=')[5].split('+')[0].split('-')[1] - } - return [version, parseFloat(version.slice(1))] - } - - return ( -
-
- -
- } - > - { // receive method added to solidity v0.6.x. use this as diff. - (getVersion()[1] as number) < 0.6 ? ( - - - - ) : - - - } - -
- ) - } + // const [solcVersion, setSolcVersion] = useState({ version: '', canReceive: true }) + + // const getVersion = () => { + // let version = '' + // try { + // version = window.location.href.split('=')[5].split('+')[0].split('-')[1].slice(1) + // if (parseFloat(version) < 0.6) { + // setSolcVersion({ version: version, canReceive: false }) + // } + // setSolcVersion({ version: version, canReceive: false }) + // } catch (e) { + // version = window.location.href.split('=')[5].split('+')[0].split('-')[1].slice(1) + // console.log(e) + // } + // return version + // } useEffect(() => { if (!props.instance.abi) { const abi = txHelper.sortAbiFunction(props.instance.contractData.abi) @@ -469,6 +448,7 @@ export function UniversalDappUI(props: UdappProps) { return (
{ runTransaction(lookupOnly, funcABI, valArray, inputsValues, index) @@ -499,7 +479,27 @@ export function UniversalDappUI(props: UdappProps) { })}
- +
+
+ +
+ } + > + { // receive method added to solidity v0.6.x. use this as diff. + props.solcVersion.canReceive === false ? ( + + + + ) : + + + } + +
diff --git a/libs/remix-ui/run-tab/src/lib/run-tab.tsx b/libs/remix-ui/run-tab/src/lib/run-tab.tsx index 26d87b7fc0..56f50b1b70 100644 --- a/libs/remix-ui/run-tab/src/lib/run-tab.tsx +++ b/libs/remix-ui/run-tab/src/lib/run-tab.tsx @@ -80,6 +80,22 @@ export function RunTabUI(props: RunTabProps) { const [runTab, dispatch] = useReducer(runTabReducer, initialState) const REACT_API = { runTab } const currentfile = plugin.config.get('currentFile') + const [solcVersion, setSolcVersion] = useState<{version: string, canReceive: boolean}>({ version: '', canReceive: true }) + + const getVersion = () => { + let version = '' + try { + version = window.location.href.split('=')[5].split('+')[0].split('-')[1].slice(1) + if (parseFloat(version) < 0.6) { + setSolcVersion({ version: version, canReceive: false }) + } + setSolcVersion({ version: version, canReceive: true }) + } catch (e) { + version = window.location.href.split('=')[5].split('+')[0].split('-')[1].slice(1) + console.log(e) + } + return version + } useEffect(() => { if (!props.initialState) { @@ -306,6 +322,9 @@ export function RunTabUI(props: RunTabProps) { isValidProxyAddress={isValidProxyAddress} isValidProxyUpgrade={isValidProxyUpgrade} proxy={runTab.proxy} + solCompilerVersion={solcVersion} + setCompilerVersion={setSolcVersion} + getCompilerVersion={getVersion} /> { diff --git a/libs/remix-ui/run-tab/src/lib/types/index.ts b/libs/remix-ui/run-tab/src/lib/types/index.ts index 7e4ae84533..39c8fd5781 100644 --- a/libs/remix-ui/run-tab/src/lib/types/index.ts +++ b/libs/remix-ui/run-tab/src/lib/types/index.ts @@ -279,6 +279,11 @@ export interface ContractDropdownProps { isValidProxyAddress?: (address: string) => Promise, isValidProxyUpgrade?: (proxyAddress: string, contractName: string, solcInput: SolcInput, solcOuput: SolcOutput, solcVersion: string) => Promise, proxy: { deployments: { address: string, date: string, contractName: string }[] } + solCompilerVersion: { version: string, canReceive: boolean } + setCompilerVersion: React.Dispatch> + getCompilerVersion: () => string } export interface RecorderProps { @@ -343,6 +348,8 @@ export interface InstanceContainerProps { exEnvironment: string editInstance: (instance) => void plugin: RunTab + solcVersion: { version: string, canReceive: boolean } + getVersion: () => string } export interface Modal { @@ -397,6 +404,11 @@ export interface ContractGUIProps { isValidProxyAddress?: (address: string) => Promise, isValidProxyUpgrade?: (proxyAddress: string) => Promise, modal?: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void, okBtnClass?: string, cancelBtnClass?: string) => void + solcVersion?: { version: string, canReceive: boolean } + setSolcVersion?: React.Dispatch> + getVersion: () => string } export interface MainnetProps { network: Network, @@ -452,6 +464,8 @@ export interface UdappProps { exEnvironment: string editInstance: (instance) => void plugin: RunTab + solcVersion: { version: string, canReceive: boolean } + getVersion: () => string } export interface DeployButtonProps { From c26f1d86cadaa65d3a752b2a87abbbf98289ab0e Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Mon, 10 Jun 2024 10:22:57 +0100 Subject: [PATCH 07/11] cleanup e2e. clean up comments. add default compiler version --- apps/remix-ide-e2e/src/tests/terminal.test.ts | 159 +++++++++--------- .../src/lib/components/contractGUI.tsx | 21 +-- .../src/lib/components/universalDappUI.tsx | 17 +- libs/remix-ui/run-tab/src/lib/run-tab.tsx | 4 +- 4 files changed, 83 insertions(+), 118 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/terminal.test.ts b/apps/remix-ide-e2e/src/tests/terminal.test.ts index eb5074e3ca..fdbc8fb8b1 100644 --- a/apps/remix-ide-e2e/src/tests/terminal.test.ts +++ b/apps/remix-ide-e2e/src/tests/terminal.test.ts @@ -167,7 +167,7 @@ module.exports = { }, 'Should print hardhat logs #group4': function (browser: NightwatchBrowser) { browser - .addFile('printHardhatlog.sol', { content: hardhatLog }) + .addFile('printHardhatlog.sol', { content: hardhatLog }) .clickLaunchIcon('solidity') .click('*[data-id="terminalClearConsole"]') // clear the terminal .waitForElementVisible('[for="autoCompile"]') @@ -266,22 +266,22 @@ module.exports = { if (Array.isArray(result.value) && result.value.length > 0) { console.log('Found ' + result.value.length + ' transactions') browser - .click({ - selector: '[data-id="listenNetworkCheckInput"]', - }) - .click({ - selector: '*[data-id="terminalClearConsole"]', - }) - .click({ - selector: '*[data-id="compilerContainerCompileAndRunBtn"]', - }) - .pause(10000) - .waitForElementNotPresent({ - locateStrategy: 'xpath', - selector: "//*[@class='remix_ui_terminal_log' and contains(.,'to:') and contains(.,'from:')]", - timeout: 120000 - }) - .end() + .click({ + selector: '[data-id="listenNetworkCheckInput"]', + }) + .click({ + selector: '*[data-id="terminalClearConsole"]', + }) + .click({ + selector: '*[data-id="compilerContainerCompileAndRunBtn"]', + }) + .pause(10000) + .waitForElementNotPresent({ + locateStrategy: 'xpath', + selector: "//*[@class='remix_ui_terminal_log' and contains(.,'to:') and contains(.,'from:')]", + timeout: 120000 + }) + .end() } else { browser .assert.fail('No transaction found') @@ -309,7 +309,7 @@ module.exports = { .switchEnvironment('vm-custom-fork') .waitForElementVisible('[data-id="vm-custom-fork-modal-footer-ok-react"]') .execute(() => { - (document.querySelector('*[data-id="vm-custom-forkModalDialogContainer-react"] input[data-id="CustomForkNodeUrl"]') as any).focus() + (document.querySelector('*[data-id="vm-custom-forkModalDialogContainer-react"] input[data-id="CustomForkNodeUrl"]') as any).focus() }, [], () => { }) .clearValue('*[data-id="CustomForkNodeUrl"]').pause(1000).setValue('*[data-id="CustomForkNodeUrl"]', 'https://go.getblock.io/ee42d0a88f314707be11dd799b122cb9') .execute(() => { @@ -331,7 +331,7 @@ module.exports = { .executeScriptInTerminal(`web3.eth.getCode('0x75F509A4eDA030470272DfBAf99A47D587E76709')`) // sepolia contract .waitForElementContainsText('*[data-id="terminalJournal"]', byteCodeInSepolia, 120000) .click('*[data-id="terminalClearConsole"]') - }, + }, 'Should run a free function while being connected to mainnet #group9': function (browser: NightwatchBrowser) { const script = ` @@ -359,10 +359,10 @@ module.exports = { .switchEnvironment('vm-mainnet-fork') .clickLaunchIcon('filePanel') .addFile('test_mainnet.sol', { content: script }) - - const path = "//*[@class='view-line' and contains(.,'resolveENS') and contains(.,'view')]//span//span[contains(.,'(')]" + + const path = "//*[@class='view-line' and contains(.,'resolveENS') and contains(.,'view')]//span//span[contains(.,'(')]" const pathRunFunction = `//li//*[@aria-label='Run the free function "resolveENS"']` - browser.waitForElementVisible('#editorView') + browser.waitForElementVisible('#editorView') //.waitForElementPresent(pathRunFunction) .pause(10000) // the parser need to parse the code .useXpath() @@ -371,25 +371,25 @@ module.exports = { .perform(function () { const actions = this.actions({ async: true }); return actions - .keyDown(this.Keys.SHIFT) - .keyDown(this.Keys.ALT) - .sendKeys('r') + .keyDown(this.Keys.SHIFT) + .keyDown(this.Keys.ALT) + .sendKeys('r') }) .useCss() .waitForElementContainsText('*[data-id="terminalJournal"]', '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', 120000) }, - + 'Should run free function which logs in the terminal #group10': function (browser: NightwatchBrowser) { const script = `import "hardhat/console.sol"; function runSomething () view { console.log("test running free function"); - } + } ` browser .addFile('test.sol', { content: script }) .scrollToLine(3) - const path = "//*[@class='view-line' and contains(.,'runSomething') and contains(.,'view')]//span//span[contains(.,'(')]" + const path = "//*[@class='view-line' and contains(.,'runSomething') and contains(.,'view')]//span//span[contains(.,'(')]" const pathRunFunction = `//li//*[@aria-label='Run the free function "runSomething"']` browser.waitForElementVisible('#editorView') .useXpath() @@ -398,18 +398,15 @@ module.exports = { .perform(function () { const actions = this.actions({ async: true }); return actions - .keyDown(this.Keys.SHIFT) - .keyDown(this.Keys.ALT) - .sendKeys('r') + .keyDown(this.Keys.SHIFT) + .keyDown(this.Keys.ALT) + .sendKeys('r') }) .useCss() .waitForElementContainsText('*[data-id="terminalJournal"]', 'test running free function', 120000) } } - - - const asyncAwait = ` var p = function () { return new Promise(function (resolve, reject) { @@ -417,7 +414,7 @@ const asyncAwait = ` resolve("Promise Resolved") }, 5000) }) - } + } var run = async () => { console.log('Waiting Promise') @@ -455,7 +452,7 @@ const resolveExternalUrlAndSave = ` } catch (e) { console.log(e.message) } -})() +})() ` const resolveExternalUrlAndSaveToaPath = ` @@ -466,7 +463,7 @@ const resolveExternalUrlAndSaveToaPath = ` } catch (e) { console.log(e.message) } -})() +})() ` const resolveUrl = ` @@ -477,7 +474,7 @@ const resolveUrl = ` } catch (e) { console.log(e.message) } -})() +})() ` const deployWithEthersJs = ` @@ -485,32 +482,32 @@ const deployWithEthersJs = ` (async () => { try { console.log('Running deployWithEthers script...') - + const constructorArgs = [] // Put constructor args (if any) here for your contract // Note that the script needs the ABI which is generated from the compilation artifact. // Make sure contract is compiled and artifacts are generated const artifactsPath = 'contracts/artifacts/Owner.json' // Change this for different path - + const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner() - + let factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) - + let contract = await factory.deploy(...constructorArgs); - + console.log('Contract Address: ', contract.address); - + // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() console.log('Deployment successful.') - + contract.on('OwnerSet', (previousOwner, newOwner) => { console.log('previousOwner' , previousOwner) console.log('newOwner' , newOwner) }) - + console.log('ok') } catch (e) { console.log(e.message) @@ -577,12 +574,12 @@ contract StorageWithLib { * @dev Store valrue in variable * @param num value to store */ - function store(uint256 num) public { - number = num; + function store(uint256 num) public { + number = num; } /** - * @dev Return value + * @dev Return value * @return value of 'number' */ function retrieve() public view returns (uint256){ @@ -629,11 +626,11 @@ describe("Storage", function () { deployedLinkReferences: metadata.data.deployedBytecode.linkReferences, } const options = { - libraries: { + libraries: { 'Lib': lib.address } } - + const factory = await ethers.getContractFactoryFromArtifact(artifact, options) const storage = await factory.deploy(); await storage.deployed() @@ -657,10 +654,10 @@ import "hardhat/console.sol"; contract OwnerTest { address private owner; - + // event for EVM logging event OwnerSet(address indexed oldOwner, address indexed newOwner); - + // modifier to check if caller is owner modifier isOwner() { // If the first argument of 'require' evaluates to 'false', execution terminates and all @@ -671,7 +668,7 @@ contract OwnerTest { require(msg.sender == owner, "Caller is not owner"); _; } - + /** * @dev Set contract deployer as owner */ @@ -692,7 +689,7 @@ contract OwnerTest { } /** - * @dev Return owner address + * @dev Return owner address * @return address of owner */ function getOwner() external view returns (address) { @@ -705,39 +702,39 @@ const scriptAutoExec = { contract: `// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.8.2 <0.9.0; - + library lib { function test () public view returns (uint) { - + return 147; } } - + /** * @title Storage * @dev Store & retrieve value inr a variable * @custom:dev-run-script ./scripts/deploy_storage.js */ contract Storage { - + uint256 number; - + /** * @dev Store valrue in variable * @param num value to store */ function store(uint256 num) public { - number = num; + number = num; } - + /** - * @dev Return value + * @dev Return value * @return value of 'number' */ function retrieve() public view returns (uint256){ return number; } - + function getFromLib() public view returns (uint) { return lib.test(); } @@ -747,16 +744,16 @@ const scriptAutoExec = { // Right click on the script name and hit "Run" to execute const { expect } = require("chai"); const { ethers } = require("hardhat"); - + (async () => { try { // function getContractFactoryFromArtifact(artifact: Artifact, signer?: ethers.Signer): Promise; - + // function getContractFactoryFromArtifact(artifact: Artifact, factoryOptions: FactoryOptions): Promise; - + const metadataLib = JSON.parse(await remix.call('fileManager', 'readFile', 'contracts/artifacts/lib.json')) console.log('deploying lib:') - + const artifactLib = { contractName: 'Lib', sourceName: 'contracts/1_Storage.sol', @@ -767,15 +764,15 @@ const scriptAutoExec = { deployedLinkReferences: metadataLib.data.deployedBytecode.linkReferences, } const optionsLib = {} - + const factoryLib = await ethers.getContractFactoryFromArtifact(artifactLib, optionsLib) - + const lib = await factoryLib.deploy(); - + await lib.deployed() - + console.log('lib deployed', lib.address) - + const metadata = JSON.parse(await remix.call('fileManager', 'readFile', 'contracts/artifacts/Storage.json')) const artifact = { contractName: 'Storage', @@ -787,25 +784,25 @@ const scriptAutoExec = { deployedLinkReferences: metadata.data.deployedBytecode.linkReferences, } const options = { - libraries: { + libraries: { 'lib': lib.address } } - + const factory = await ethers.getContractFactoryFromArtifact(artifact, options) - + const storage = await factory.deploy(); - + await storage.deployed() - + const storeValue = await storage.store(333); - + // wait until the transaction is mined await storeValue.wait(); - + console.log((await storage.getFromLib()).toString()) // expect((await storage.getFromLib()).toString()).to.equal('34'); - + } catch (e) { console.error(e.message) } diff --git a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx index 89a6ac9dc5..2cc87d03ff 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx @@ -32,23 +32,6 @@ export function ContractGUI(props: ContractGUIProps) { const initializeFields = useRef>([]) const basicInputRef = useRef() const intl = useIntl() - // const [solcVersion, setSolcVersion] = useState({ version: '', canReceive: true }) - - // const getVersion = () => { - // let version = '' - // try { - // version = window.location.href.split('=')[5].split('+')[0].split('-')[1].slice(1) - // if (parseFloat(version) < 0.6) { - // setSolcVersion({ version: version, canReceive: false }) - // } - // setSolcVersion({ version: version, canReceive: false }) - // } catch (e) { - // version = window.location.href.split('=')[5].split('+')[0].split('-')[1].slice(1) - // console.log(e) - // } - // return version - // } - useEffect(() => { if (props.deployOption && Array.isArray(props.deployOption)) { if (props.deployOption[0] && props.deployOption[0].title === 'Deploy with Proxy' && props.deployOption[0].active) handleDeployProxySelect(true) @@ -316,8 +299,8 @@ export function ContractGUI(props: ContractGUIProps) {