diff --git a/apps/remix-ide-e2e/src/commands/createContract.ts b/apps/remix-ide-e2e/src/commands/createContract.ts index 015a4f2012..44ff4780c7 100644 --- a/apps/remix-ide-e2e/src/commands/createContract.ts +++ b/apps/remix-ide-e2e/src/commands/createContract.ts @@ -2,7 +2,7 @@ import { NightwatchBrowser } from 'nightwatch' import EventEmitter from 'events' class CreateContract extends EventEmitter { - command (this: NightwatchBrowser, inputParams: string): NightwatchBrowser { + command (this: NightwatchBrowser, inputParams: string[]): NightwatchBrowser { this.api.perform((done) => { createContract(this.api, inputParams, () => { done() @@ -13,11 +13,19 @@ class CreateContract extends EventEmitter { } } -function createContract (browser: NightwatchBrowser, inputParams: string, callback: VoidFunction) { - if (inputParams) { - browser.setValue('.udapp_contractActionsContainerSingle > input', inputParams, function () { +function createContract (browser: NightwatchBrowser, inputParams: string[], callback: VoidFunction) { + if (inputParams.length === 1) { + browser.setValue('.udapp_contractActionsContainerSingle > input', inputParams[0], function () { browser.click('.udapp_contractActionsContainerSingle > button').pause(500).perform(function () { callback() }) }) + } else if (inputParams.length > 1) { + browser.perform((done) => { + for (let i = 0; i < inputParams.length; i++) { + browser.setValue(`div.udapp_multiArg:nth-child(${i + 1}) > input`, inputParams[i]) + } + done() + }) + .click('div.udapp_multiArg > button').pause(500).perform(function () { callback() }) } else { browser .click('.udapp_contractActionsContainerSingle > button') diff --git a/apps/remix-ide-e2e/src/tests/debugger.test.ts b/apps/remix-ide-e2e/src/tests/debugger.test.ts index 9010b79b58..381d3b68bb 100644 --- a/apps/remix-ide-e2e/src/tests/debugger.test.ts +++ b/apps/remix-ide-e2e/src/tests/debugger.test.ts @@ -86,7 +86,7 @@ module.exports = { .clickLaunchIcon('udapp') .waitForElementPresent('*[title="Deploy - transact (not payable)"]', 35000) .selectContract('ERC20') - .createContract('"tokenName", "symbol"') + .createContract(["tokenName", "symbol"]) .debugTransaction(0) .pause(2000) .waitForElementVisible('#stepdetail') @@ -115,7 +115,7 @@ module.exports = { .testContracts('withABIEncoderV2.sol', sources[2]['withABIEncoderV2.sol'], ['test']) .clickLaunchIcon('udapp') .selectContract('test') - .createContract('') + .createContract(['']) .clearConsole() .clickInstance(0) .clickFunction('test1 - transact (not payable)', { types: 'bytes userData', values: '0x000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000015b38da6a701c568545dcfcb03fcb875f56beddc4' }) @@ -148,7 +148,7 @@ module.exports = { .testContracts('locals.sol', sources[3]['locals.sol'], ['testLocals']) .clickLaunchIcon('udapp') .waitForElementPresent('*[title="Deploy - transact (not payable)"]', 40000) - .createContract('') + .createContract(['']) .pause(2000) .clearConsole() .clickInstance(0) @@ -173,7 +173,7 @@ module.exports = { .pause(2000) .testContracts('withGeneratedSources.sol', sources[4]['withGeneratedSources.sol'], ['A']) .clickLaunchIcon('udapp') - .createContract('') + .createContract(['']) .clearConsole() .clickInstance(0) .clickFunction('f - transact (not payable)', { types: 'uint256[] ', values: '[]' }) @@ -235,7 +235,7 @@ module.exports = { .testContracts('reverted.sol', sources[6]['reverted.sol'], ['A', 'B', 'C']) .clickLaunchIcon('udapp') .selectContract('A') - .createContract('') + .createContract(['']) .pause(500) .clickInstance(0) .clickFunction('callA - transact (not payable)') diff --git a/apps/remix-ide-e2e/src/tests/libraryDeployment.test.ts b/apps/remix-ide-e2e/src/tests/libraryDeployment.test.ts index 4b3c4528c4..50a9e55408 100644 --- a/apps/remix-ide-e2e/src/tests/libraryDeployment.test.ts +++ b/apps/remix-ide-e2e/src/tests/libraryDeployment.test.ts @@ -22,7 +22,7 @@ module.exports = { browser.verifyContracts(['test']) .clickLaunchIcon('udapp') .selectContract('test') - .createContract('') + .createContract(['']) .getAddressAtPosition(0, (address) => { console.log('testAutoDeployLib ' + address) addressRef = address @@ -46,7 +46,7 @@ module.exports = { .verifyContracts(['test']) .clickLaunchIcon('udapp') .selectContract('lib') // deploy lib - .createContract('') + .createContract(['']) .perform((done) => { browser.getAddressAtPosition(0, (address) => { console.log(address) @@ -74,7 +74,7 @@ function checkDeployShouldFail (browser: NightwatchBrowser, callback: VoidFuncti .openFile('Untitled5.sol') .clickLaunchIcon('udapp') .selectContract('test') // deploy lib - .createContract('') + .createContract(['']) .pause(2000) .getText('div[class^="terminal"]', (value) => { console.log('value: ', value) @@ -98,7 +98,7 @@ function checkDeployShouldSucceed (browser: NightwatchBrowser, address: string, .openFile('Untitled5.sol') .clickLaunchIcon('udapp') .selectContract('test') // deploy lib - .createContract('') + .createContract(['']) .getAddressAtPosition(1, (address) => { addressRef = address }) diff --git a/apps/remix-ide-e2e/src/tests/recorder.test.ts b/apps/remix-ide-e2e/src/tests/recorder.test.ts index 7e1c0859a7..521e74786b 100644 --- a/apps/remix-ide-e2e/src/tests/recorder.test.ts +++ b/apps/remix-ide-e2e/src/tests/recorder.test.ts @@ -39,7 +39,7 @@ module.exports = { 'Save scenario': function (browser: NightwatchBrowser) { browser.testContracts('testRecorder.sol', sources[0]['testRecorder.sol'], ['testRecorder']) .clickLaunchIcon('udapp') - .createContract('12') + .createContract(['12']) .clickInstance(0) .clickFunction('set - transact (not payable)', { types: 'uint256 _p', values: '34' }) .click('i.savetransaction') @@ -72,11 +72,11 @@ module.exports = { .clickLaunchIcon('udapp') .selectContract('t1est') .pause(1000) - .createContract('') + .createContract(['']) .clickInstance(0) .selectContract('t2est') .pause(1000) - .createContract('') + .createContract(['']) .click('i.savetransaction') .waitForElementVisible('[data-id="udappNotify-modal-footer-ok-react"]') .execute(function () { diff --git a/apps/remix-ide-e2e/src/tests/signingMessage.test.ts b/apps/remix-ide-e2e/src/tests/signingMessage.test.ts index 913851fa38..e3ba544660 100644 --- a/apps/remix-ide-e2e/src/tests/signingMessage.test.ts +++ b/apps/remix-ide-e2e/src/tests/signingMessage.test.ts @@ -33,7 +33,7 @@ module.exports = { .clickLaunchIcon('udapp') .pause(5000) .selectContract('ECVerify') - .createContract('') + .createContract(['']) .clickInstance(0) .perform((done) => { browser.getAddressAtPosition(0, (address) => { diff --git a/apps/remix-ide-e2e/src/tests/specialFunctions.test.ts b/apps/remix-ide-e2e/src/tests/specialFunctions.test.ts index bcdc3c4977..b0c7adba47 100644 --- a/apps/remix-ide-e2e/src/tests/specialFunctions.test.ts +++ b/apps/remix-ide-e2e/src/tests/specialFunctions.test.ts @@ -24,7 +24,7 @@ module.exports = { .clickLaunchIcon('udapp') .selectAccount('0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c') // this account will be used for this test suite .selectContract('CheckSpecials') - .createContract('') // deploy + .createContract(['']) // deploy .clickInstance(0) .perform((done) => { browser.getAddressAtPosition(0, (address) => { @@ -92,7 +92,7 @@ module.exports = { .testContracts('receiveOnly.sol', sources[1]['receiveOnly.sol'], ['CheckSpecials']) .clickLaunchIcon('udapp') .selectContract('CheckSpecials') - .createContract('') + .createContract(['']) .clickInstance(0) .perform((done) => { browser.getAddressAtPosition(0, (address) => { @@ -122,7 +122,7 @@ module.exports = { .testContracts('fallbackOnlyPayable.sol', sources[2]['fallbackOnlyPayable.sol'], ['CheckSpecials']) .clickLaunchIcon('udapp') .selectContract('CheckSpecials') - .createContract('') + .createContract(['']) .clickInstance(0) .perform((done) => { browser.getAddressAtPosition(0, (address) => { @@ -153,7 +153,7 @@ module.exports = { .testContracts('fallbackOnlyNotPayable.sol', sources[3]['fallbackOnlyNotPayable.sol'], ['CheckSpecials']) .clickLaunchIcon('udapp') .selectContract('CheckSpecials') - .createContract('') + .createContract(['']) .clickInstance(0) .perform((done) => { browser.getAddressAtPosition(0, (address) => { @@ -174,7 +174,7 @@ module.exports = { .clearValue('#value') .setValue('#value', '0') .pause(2000) - .createContract('') + .createContract(['']) .pause(1000) .clickInstance(0).pause(1000) .perform((done) => { @@ -208,7 +208,7 @@ module.exports = { .waitForElementVisible('#value') .clearValue('#value') .setValue('#value', '0').pause(2000) - .createContract('') + .createContract(['']) .clickInstance(0) .pause(1000) .perform((done) => { diff --git a/apps/remix-ide-e2e/src/tests/terminal.test.ts b/apps/remix-ide-e2e/src/tests/terminal.test.ts index a824c7871f..101500c58c 100644 --- a/apps/remix-ide-e2e/src/tests/terminal.test.ts +++ b/apps/remix-ide-e2e/src/tests/terminal.test.ts @@ -172,7 +172,7 @@ module.exports = { .clickLaunchIcon('udapp') .click('*[data-id="deployAndRunClearInstances"]') .selectContract('OwnerTest') - .createContract('') + .createContract(['']) .pause(1000) .journalChildIncludes('constructor', { shouldHaveOnlyOneOccurence: true }) .pause(5000) diff --git a/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts b/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts index da26b27793..3eac406fcd 100644 --- a/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts +++ b/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts @@ -202,10 +202,10 @@ module.exports = { .addFile('Storage.sol', sources[6]['Storage.sol']) .addFile('Owner.sol', sources[6]['Owner.sol']) .clickLaunchIcon('udapp') - .createContract('42, 24') + .createContract(['42', '24']) .openFile('Storage.sol') .clickLaunchIcon('udapp') - .createContract('102') // this creation will fail if the component hasn't been properly reset. + .createContract(['102']) // this creation will fail if the component hasn't been properly reset. .clickInstance(1) .clickFunction('store - transact (not payable)', { types: 'uint256 num', values: '24' }) .testFunction('last', // we check if the contract is actually reachable. diff --git a/apps/remix-ide-e2e/src/types/index.d.ts b/apps/remix-ide-e2e/src/types/index.d.ts index 7fbcb174d5..f17e6b17de 100644 --- a/apps/remix-ide-e2e/src/types/index.d.ts +++ b/apps/remix-ide-e2e/src/types/index.d.ts @@ -34,7 +34,7 @@ declare module 'nightwatch' { getModalBody(callback: (value: string, cb: VoidFunction) => void): NightwatchBrowser, modalFooterCancelClick(id?: string): NightwatchBrowser, selectContract(contractName: string): NightwatchBrowser, - createContract(inputParams: string): NightwatchBrowser, + createContract(inputParams: string[]): NightwatchBrowser, getAddressAtPosition(index: number, cb: (pos: string) => void): NightwatchBrowser, testConstantFunction(address: string, fnFullName: string, expectedInput: NightwatchTestConstantFunctionExpectedInput | null, expectedOutput: string): NightwatchBrowser, getEditorValue(callback: (content: string) => void): NightwatchBrowser, diff --git a/libs/remix-ui/run-tab/src/lib/actions/events.ts b/libs/remix-ui/run-tab/src/lib/actions/events.ts index 9452c14204..f8d74dc359 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/events.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/events.ts @@ -102,7 +102,7 @@ const broadcastCompilationResult = async (plugin: RunTab, dispatch: React.Dispat }) const index = contracts.findIndex(contract => contract.alias === plugin.REACT_API.contracts.currentContract) - if (index < 0) dispatch(setCurrentContract(contracts[0].alias)) + if ((index < 0) && (contracts.length > 0)) dispatch(setCurrentContract(contracts[0].alias)) const isUpgradeable = await plugin.call('openzeppelin-proxy', 'isConcerned', data.sources[file] ? data.sources[file].ast : {}) if (isUpgradeable) { 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 3181b1f070..670025435f 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx @@ -144,8 +144,6 @@ export function ContractDropdownUI (props: ContractDropdownProps) { } const clickCallback = (inputs, value, deployMode?: DeployMode[]) => { - console.log('value: ', value) - console.log('deployMode: ', deployMode) createInstance(loadedContractData, value, deployMode) }