Skip to content

Commit 1c88c6d

Browse files
authored
Merge pull request #1977 from ethereum/fix_udapp_input_parameters
reset input parameters
2 parents adbb7a5 + fd24241 commit 1c88c6d

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

apps/remix-ide-e2e/src/tests/transactionExecution.test.ts

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,26 @@ module.exports = {
195195
.journalLastChildIncludes('"documentation": "param2 from library"')
196196
.journalLastChildIncludes('"documentation": "param3 from library"')
197197
.journalLastChildIncludes('Debug the transaction to get more information.')
198+
},
199+
200+
'Should compile and deploy 2 simple contracts, the contract creation component state should be correctly reset for the deployment of the second contract #group4': function (browser: NightwatchBrowser) {
201+
browser
202+
.addFile('Storage.sol', sources[6]['Storage.sol'])
203+
.addFile('Owner.sol', sources[6]['Owner.sol'])
204+
.clickLaunchIcon('udapp')
205+
.createContract('42')
206+
.openFile('Storage.sol')
207+
.clickLaunchIcon('udapp')
208+
.createContract('') // this creation will fail if the component hasn't been properly reset.
209+
.clickInstance(1)
210+
.clickFunction('store - transact (not payable)', { types: 'uint256 num', values: '24' })
211+
.testFunction('last', // we check if the contract is actually reachable.
212+
{
213+
status: 'true Transaction mined and execution succeed',
214+
'decoded input': {
215+
'uint256 num': '24'
216+
}
217+
})
198218
.end()
199219
}
200220
}
@@ -322,5 +342,92 @@ contract C {
322342
}
323343
}`
324344
}
345+
},
346+
{
347+
'Owner.sol': {
348+
content: `
349+
// SPDX-License-Identifier: GPL-3.0
350+
351+
pragma solidity >=0.7.0 <0.9.0;
352+
353+
/**
354+
* @title Owner
355+
* @dev Set & change owner
356+
*/
357+
contract Owner {
358+
359+
address private owner;
360+
361+
// event for EVM logging
362+
event OwnerSet(address indexed oldOwner, address indexed newOwner);
363+
364+
// modifier to check if caller is owner
365+
modifier isOwner() {
366+
// If the first argument of 'require' evaluates to 'false', execution terminates and all
367+
// changes to the state and to Ether balances are reverted.
368+
// This used to consume all gas in old EVM versions, but not anymore.
369+
// It is often a good idea to use 'require' to check if functions are called correctly.
370+
// As a second argument, you can also provide an explanation about what went wrong.
371+
require(msg.sender == owner, "Caller is not owner");
372+
_;
373+
}
374+
375+
/**
376+
* @dev Set contract deployer as owner
377+
*/
378+
constructor(uint p) {
379+
owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor
380+
emit OwnerSet(address(0), owner);
381+
}
382+
383+
/**
384+
* @dev Change owner
385+
* @param newOwner address of new owner
386+
*/
387+
function changeOwner(address newOwner) public isOwner {
388+
emit OwnerSet(owner, newOwner);
389+
owner = newOwner;
390+
}
391+
392+
/**
393+
* @dev Return owner address
394+
* @return address of owner
395+
*/
396+
function getOwner() external view returns (address) {
397+
return owner;
398+
}
399+
}`
400+
},
401+
'Storage.sol': {
402+
content: `
403+
// SPDX-License-Identifier: GPL-3.0
404+
405+
pragma solidity >=0.7.0 <0.9.0;
406+
407+
/**
408+
* @title Storage
409+
* @dev Store & retrieve value in a variable
410+
*/
411+
contract Storage {
412+
413+
uint256 number;
414+
415+
/**
416+
* @dev Store value in variable
417+
* @param num value to store
418+
*/
419+
function store(uint256 num) public {
420+
number = num;
421+
}
422+
423+
/**
424+
* @dev Return value
425+
* @return value of 'number'
426+
*/
427+
function retrieve() public view returns (uint256){
428+
return number;
429+
}
430+
}`
431+
}
325432
}
326433
]

libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export function ContractGUI (props: ContractGUIProps) {
2525
} else {
2626
setTitle(props.funcABI.type === 'receive' ? '(receive)' : '(fallback)')
2727
}
28+
setBasicInput('')
2829
}, [props.title, props.funcABI])
2930

3031
useEffect(() => {

0 commit comments

Comments
 (0)