-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(evm): prevent funtoken from erc20 contract to be created with non-complete contracts #2150
base: main
Are you sure you want to change the base?
Changes from all commits
76ed81c
20ef16b
d81a9e8
597cbdb
7857969
a99cd91
6c9ca53
f20bc28
447de16
baf5ee9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,18 @@ | |
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
import {ERC20} from '@openzeppelin/contracts/token/ERC20/ERC20.sol'; | ||
|
||
contract TestERC20 is ERC20 { | ||
// Define the supply of TestERC20: 1,000,000 | ||
uint256 constant initialSupply = 1000000 * (10 ** 18); | ||
|
||
// Define the supply of TestERC20: 1,000,000 | ||
uint256 constant initialSupply = 1000000 * (10**18); | ||
// Constructor will be called on contract creation | ||
constructor() ERC20('TestERC20', 'FOO') { | ||
_mint(msg.sender, initialSupply); | ||
} | ||
|
||
// Constructor will be called on contract creation | ||
constructor() ERC20("TestERC20", "FOO") { | ||
_mint(msg.sender, initialSupply); | ||
} | ||
function mint(address to, uint256 amount) public { | ||
_mint(to, amount); | ||
} | ||
Comment on lines
+16
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add access control to mint function The +import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';
-contract TestERC20 is ERC20 {
+contract TestERC20 is ERC20, Ownable {
// ... other code ...
- function mint(address to, uint256 amount) public {
+ function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
[ | ||
{ | ||
"constant": false, | ||
"inputs": [ | ||
{ | ||
"name": "owner_", | ||
"type": "address" | ||
} | ||
], | ||
"name": "setOwner", | ||
"outputs": [], | ||
"payable": false, | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"constant": false, | ||
"inputs": [ | ||
{ | ||
"name": "authority_", | ||
"type": "address" | ||
} | ||
], | ||
"name": "setAuthority", | ||
"outputs": [], | ||
"payable": false, | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"constant": true, | ||
"inputs": [], | ||
"name": "owner", | ||
"outputs": [ | ||
{ | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"payable": false, | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"constant": true, | ||
"inputs": [], | ||
"name": "authority", | ||
"outputs": [ | ||
{ | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"payable": false, | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"payable": false, | ||
"stateMutability": "nonpayable", | ||
"type": "constructor" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"name": "authority", | ||
"type": "address" | ||
} | ||
], | ||
"name": "LogSetAuthority", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"name": "owner", | ||
"type": "address" | ||
} | ||
], | ||
"name": "LogSetOwner", | ||
"type": "event" | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[ | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"name": "authority", | ||
"type": "address" | ||
} | ||
], | ||
"name": "LogSetAuthority", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"name": "owner", | ||
"type": "address" | ||
} | ||
], | ||
"name": "LogSetOwner", | ||
"type": "event" | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[ | ||
{ | ||
"constant": true, | ||
"inputs": [ | ||
{ | ||
"name": "src", | ||
"type": "address" | ||
}, | ||
{ | ||
"name": "dst", | ||
"type": "address" | ||
}, | ||
{ | ||
"name": "sig", | ||
"type": "bytes4" | ||
} | ||
], | ||
"name": "canCall", | ||
"outputs": [ | ||
{ | ||
"name": "", | ||
"type": "bool" | ||
} | ||
], | ||
"payable": false, | ||
"stateMutability": "view", | ||
"type": "function" | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[ | ||
{ | ||
"anonymous": true, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"name": "sig", | ||
"type": "bytes4" | ||
}, | ||
{ | ||
"indexed": true, | ||
"name": "guy", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": true, | ||
"name": "foo", | ||
"type": "bytes32" | ||
}, | ||
{ | ||
"indexed": true, | ||
"name": "bar", | ||
"type": "bytes32" | ||
}, | ||
{ | ||
"indexed": false, | ||
"name": "wad", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"indexed": false, | ||
"name": "fax", | ||
"type": "bytes" | ||
} | ||
], | ||
"name": "LogNote", | ||
"type": "event" | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Standardize gas limit to 1,500,000 for consistency
The gas limit of 2,500,000 is inconsistent with similar operations in the codebase. Other token operations in the test files consistently use 1,500,000 gas, including:
eth/rpc/backend/gas_used_test.go
eth/rpc/backend/backend_suite_test.go
Consider reducing the gas limit to 1,500,000 to maintain consistency across the test suite.
🔗 Analysis chain
Maintain consistent gas limits across similar operations.
The gas limit of 2,500,000 for sending ERC20 tokens to coin seems inconsistent with similar operations in other tests. Consider standardizing gas limits across similar operations to ensure consistent testing and better detection of gas usage regressions.
Let's verify gas usage patterns for similar operations:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 43
Script:
Length of output: 10817