Skip to content

Commit

Permalink
chore: cleaned up Solidity warnings (#701)
Browse files Browse the repository at this point in the history
* chore: cleaned up Solidity warnings

Signed-off-by: Logan Nguyen <[email protected]>

* fix: reverted transfer back to send

Signed-off-by: Logan Nguyen <[email protected]>

* fix: reverted prevrando back to difficulty

Signed-off-by: Logan Nguyen <[email protected]>

* fix: removed unused var

Signed-off-by: Logan Nguyen <[email protected]>

* fix: restored uint x declaration

Signed-off-by: Logan Nguyen <[email protected]>

* fix: added comments for InternalCalle contract

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed contract-abi artifacts

Signed-off-by: Logan Nguyen <[email protected]>

---------

Signed-off-by: Logan Nguyen <[email protected]>
  • Loading branch information
quiet-node authored Mar 25, 2024
1 parent 2eecfc6 commit 21aaeb3
Show file tree
Hide file tree
Showing 18 changed files with 68 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"type": "bool"
}
],
"stateMutability": "nonpayable",
"stateMutability": "pure",
"type": "function"
},
{
Expand All @@ -59,7 +59,7 @@
"type": "address"
}
],
"name": "selfdestruct",
"name": "selfDestruct",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"type": "address"
}
],
"name": "selfdestruct",
"name": "selfDestruct",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
Expand Down Expand Up @@ -140,7 +140,7 @@
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"stateMutability": "view",
"type": "function"
},
{
Expand All @@ -153,7 +153,7 @@
],
"name": "staticCallNonExisting",
"outputs": [],
"stateMutability": "nonpayable",
"stateMutability": "view",
"type": "function"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@
"name": "decimals",
"type": "int32"
},
{
"internalType": "int64",
"name": "feeAmount",
"type": "int64"
},
{
"components": [
{
Expand Down Expand Up @@ -429,6 +434,11 @@
"name": "maxSupply",
"type": "int64"
},
{
"internalType": "int64",
"name": "feeAmount",
"type": "int64"
},
{
"components": [
{
Expand Down
60 changes: 2 additions & 58 deletions contracts-abi/contracts/multicaller/Receiver.sol/Receiver.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,7 @@
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "c",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "d",
"type": "uint256"
}
],
"internalType": "struct Receiver.SomeData",
"name": "longInput",
"type": "tuple"
}
],
"inputs": [],
"name": "processLongInput",
"outputs": [
{
Expand All @@ -71,35 +43,7 @@
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "c",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "d",
"type": "uint256"
}
],
"internalType": "struct Receiver.SomeData",
"name": "longInput",
"type": "tuple"
}
],
"inputs": [],
"name": "processLongInputTx",
"outputs": [
{
Expand Down
76 changes: 4 additions & 72 deletions contracts-abi/contracts/multicaller/Reverter.sol/Reverter.json
Original file line number Diff line number Diff line change
@@ -1,83 +1,15 @@
[
{
"inputs": [
{
"components": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "c",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "d",
"type": "uint256"
}
],
"internalType": "struct Reverter.SomeData",
"name": "longInput",
"type": "tuple"
}
],
"inputs": [],
"name": "processLongInput",
"outputs": [
{
"internalType": "uint256",
"name": "sum",
"type": "uint256"
}
],
"outputs": [],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint24",
"name": "count",
"type": "uint24"
}
],
"inputs": [],
"name": "processLongOutput",
"outputs": [
{
"components": [
{
"internalType": "uint256",
"name": "a",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "b",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "c",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "d",
"type": "uint256"
}
],
"internalType": "struct Reverter.SomeData[]",
"name": "",
"type": "tuple[]"
}
],
"outputs": [],
"stateMutability": "pure",
"type": "function"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,9 @@
],
"stateMutability": "view",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"type": "bytes32[2]"
}
],
"stateMutability": "nonpayable",
"stateMutability": "view",
"type": "function"
},
{
Expand Down
7 changes: 5 additions & 2 deletions contracts/discrepancies/nonce/InternalCallee.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ contract InternalCallee {
}

function externalFunction() external returns (uint) {
// mutate state to maintain non-view function status
return ++calledTimes;
}

function revertWithRevertReason() public returns (bool) {
// mutate state to maintain non-view function status
++calledTimes;
revert("RevertReason");
}

function revertWithoutRevertReason() public returns (bool) {
function revertWithoutRevertReason() public pure returns (bool) {
revert();
}

function selfdestruct(address payable _addr) external {
function selfDestruct(address payable _addr) external {
selfdestruct(_addr);
}
}
24 changes: 15 additions & 9 deletions contracts/discrepancies/nonce/InternalCaller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ contract InternalCaller {
constructor() payable {}

function callNonExisting(address _addr) external {
_addr.call(abi.encodeWithSignature("nonExisting()"));
(bool success,) = _addr.call(abi.encodeWithSignature("nonExisting()"));
require(success);
}

function staticCallNonExisting(address _addr) external {
_addr.staticcall(abi.encodeWithSignature("nonExisting()"));
function staticCallNonExisting(address _addr) view external {
(bool success,) = _addr.staticcall(abi.encodeWithSignature("nonExisting()"));
require(success);
}

function staticCallExternalFunction(address _addr) external returns (uint) {
function staticCallExternalFunction(address _addr) view external returns (uint) {
(bool success, bytes memory result) = _addr.staticcall(abi.encodeWithSignature("externalFunction()"));
return success && result.length > 0 ? abi.decode(result, (uint)) : 0;
}
Expand All @@ -28,26 +30,30 @@ contract InternalCaller {
}

function callRevertWithRevertReason(address _addr) external {
_addr.call(abi.encodeWithSignature("revertWithRevertReason()"));
(bool success,) = _addr.call(abi.encodeWithSignature("revertWithRevertReason()"));
require(success);
}

function callRevertWithoutRevertReason(address _addr) external {
_addr.call(abi.encodeWithSignature("revertWithoutRevertReason()"));
(bool success,) = _addr.call(abi.encodeWithSignature("revertWithoutRevertReason()"));
require(success);
}

function sendTo(address payable _addr) external {
_addr.send(1);
bool sent = _addr.send(1);
require(sent);
}

function transferTo(address payable _addr) external {
_addr.transfer(1);
}

function callWithValueTo(address _addr) external {
_addr.call{value : 1}("");
(bool success,) = _addr.call{value : 1}("");
require(success);
}

function selfdestruct(address payable _addr) external {
function selfDestruct(address payable _addr) external {
selfdestruct(_addr);
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/multicaller/Receiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ contract Receiver {
uint d;
}

function processLongInput(SomeData memory longInput) pure external returns (uint result) {
function processLongInput() pure external returns (uint result) {
result = 5;
}

Expand All @@ -24,7 +24,7 @@ contract Receiver {
return data;
}

function processLongInputTx(SomeData memory longInput) payable external returns (uint) {
function processLongInputTx() payable external returns (uint) {
counter += 1;
return counter;
}
Expand Down
6 changes: 2 additions & 4 deletions contracts/multicaller/Reverter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ contract Reverter {
uint d;
}

function processLongInput(SomeData memory longInput) pure external returns (uint sum) {
function processLongInput() pure external {
revert("SomeRevertReason");
}

function processLongOutput(
uint24 count
) external pure returns (SomeData[] memory) {
function processLongOutput() pure external {
revert("SomeRevertReason");
}
}
3 changes: 3 additions & 0 deletions contracts/openzeppelin/beacon-proxy/MyProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ contract MyProxy is BeaconProxy {
function implementation() public view returns (address) {
return _implementation();
}

/// @notice required by Solidity
receive() external payable {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ contract ReentrancyGuardTestSender is ReentrancyGuard {
function reentrancyTest() external {
counter = counter + 1;
(bool sent,) = msg.sender.call{value: 100000000}("");
require(sent);
}

function reentrancyTestNonReentrant() external nonReentrant {
counter = counter + 1;
(bool sent,) = msg.sender.call{value: 100000000}("");
require(!sent);
}

receive() external payable {}
Expand Down
1 change: 1 addition & 0 deletions contracts/solidity/block/BlockInfo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ contract BlockInfo {
}

// should behave like prevrandao
/// @notice since VM version Paris, "difficulty" was replaced by "prevrandao", which now returns a random number based on the beacon chain
function getBlockDifficulty() external view returns (uint256) {
return block.difficulty;
}
Expand Down
Loading

0 comments on commit 21aaeb3

Please sign in to comment.