Modify create contract command to accept array of inputs for multi fields

pull/5370/head
David Disu 3 years ago
parent 41451aabf6
commit 5318ea813a
  1. 16
      apps/remix-ide-e2e/src/commands/createContract.ts
  2. 10
      apps/remix-ide-e2e/src/tests/debugger.test.ts
  3. 8
      apps/remix-ide-e2e/src/tests/libraryDeployment.test.ts
  4. 6
      apps/remix-ide-e2e/src/tests/recorder.test.ts
  5. 2
      apps/remix-ide-e2e/src/tests/signingMessage.test.ts
  6. 12
      apps/remix-ide-e2e/src/tests/specialFunctions.test.ts
  7. 2
      apps/remix-ide-e2e/src/tests/terminal.test.ts
  8. 4
      apps/remix-ide-e2e/src/tests/transactionExecution.test.ts
  9. 2
      apps/remix-ide-e2e/src/types/index.d.ts
  10. 2
      libs/remix-ui/run-tab/src/lib/actions/events.ts
  11. 2
      libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx

@ -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')

@ -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)')

@ -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
})

@ -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 () {

@ -33,7 +33,7 @@ module.exports = {
.clickLaunchIcon('udapp')
.pause(5000)
.selectContract('ECVerify')
.createContract('')
.createContract([''])
.clickInstance(0)
.perform((done) => {
browser.getAddressAtPosition(0, (address) => {

@ -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) => {

@ -172,7 +172,7 @@ module.exports = {
.clickLaunchIcon('udapp')
.click('*[data-id="deployAndRunClearInstances"]')
.selectContract('OwnerTest')
.createContract('')
.createContract([''])
.pause(1000)
.journalChildIncludes('constructor', { shouldHaveOnlyOneOccurence: true })
.pause(5000)

@ -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.

@ -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,

@ -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) {

@ -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)
}

Loading…
Cancel
Save