github.com/iotexproject/iotex-core@v1.14.1-rc1/action/protocol/execution/testdata-istanbul/write-protection-007.sol (about) 1 // SPDX-License-Identifier: MIT 2 pragma solidity ^0.6.6; 3 4 // NOTE: Deploy this contract first 5 contract B { 6 // NOTE: storage layout must be the same as contract A 7 uint public num; 8 address public sender; 9 uint public value; 10 mapping(uint => uint) private _a; 11 event Done(); 12 13 constructor() public { 14 _a[1] = 1; 15 _a[2] = 2; 16 _a[3] = 3; 17 } 18 19 function setVars(uint _num) public payable { 20 if (_num == 1) { 21 delete _a[1]; 22 delete _a[2]; 23 delete _a[3]; 24 } 25 num = _num; 26 sender = msg.sender; 27 value = msg.value; 28 emit Done(); 29 } 30 } 31 32 contract A { 33 uint public num; 34 address public sender; 35 uint public value; 36 address private c; 37 event Success(bool); 38 39 function make() public { 40 c = address(new B()); 41 } 42 43 function setVars(address _contract, uint _num) public returns (uint256) { 44 if (_contract == address(0)) { 45 _contract = c; 46 } 47 _contract.staticcall( 48 abi.encodeWithSignature("setVars(uint256)", 0) 49 ); 50 (bool success, bytes memory _) = _contract.staticcall( 51 abi.encodeWithSignature("setVars(uint256)", 1) 52 ); 53 54 emit Success(success); 55 56 return 1; 57 } 58 }