mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-13 06:01:06 +00:00
initial SELFDESTRUCT support (#400)
Note: - The unstable interface in `v2509.0.0` of `polkadot-sdk` is required. - The differential test fails against EVM in `v2509.0.0` of `polkadot-sdk`. --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8;
|
||||
|
||||
// TODO: This currently fails the differential test.
|
||||
// The pallet doesn't send the correct balance back.
|
||||
|
||||
/* runner.json
|
||||
{
|
||||
"differential": false,
|
||||
"actions": [
|
||||
{
|
||||
"Upload": {
|
||||
"code": {
|
||||
"Solidity": {
|
||||
"contract": "SelfdestructTester"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Instantiate": {
|
||||
"code": {
|
||||
"Solidity": {
|
||||
"contract": "Selfdestruct"
|
||||
}
|
||||
},
|
||||
"value": 123456789
|
||||
}
|
||||
},
|
||||
{
|
||||
"Call": {
|
||||
"dest": {
|
||||
"Instantiated": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
|
||||
contract Selfdestruct {
|
||||
address tester;
|
||||
uint value;
|
||||
|
||||
constructor() payable {
|
||||
require(msg.value > 0, "the test should have value");
|
||||
value = msg.value;
|
||||
|
||||
SelfdestructTester s = new SelfdestructTester{value: msg.value}();
|
||||
tester = address(s);
|
||||
}
|
||||
|
||||
fallback() external {
|
||||
(bool success, ) = tester.call(hex"");
|
||||
require(success, "the call to the self destructing contract should succeed");
|
||||
}
|
||||
}
|
||||
|
||||
contract SelfdestructTester {
|
||||
constructor() payable {}
|
||||
|
||||
fallback() external {
|
||||
selfdestruct(payable(msg.sender));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user