For those who prefer the video format here we have a video with a recopilation of this updates you can follow along:
KOVAN
has been replaced withSEPOLIA
here is the link to ChainLink
We are not going to spoil you the solution of most the challenges but when is our fault we have to aknowledge it. In this challenge we made a little mistake on the smart contract, in line 40 there is a typo stating 10e10
instead of 1e10
which is the correct value. This is the reason why the challenge is not working as expected.
function solveChallenge(uint256 priceGuess, string memory yourTwitterHandle) external {
uint256 actualPrice = getPrice();
if (getDecimals() == 8) {
actualPrice = actualPrice * 10e10; // <======== HERE!
}
if (actualPrice + 3e18 > priceGuess && actualPrice - 3e18 < priceGuess) {
_updateAndRewardSolver(yourTwitterHandle);
} else {
revert LessonFour__WrongPrice();
}
}
So if you use the price feed as normal with 18 decimals and your price feed returns a value like:
1572890000000000000000
You will need to add one zero to the end of the number to make it work:
15728900000000000000000
forge test -m
has been replaced byforge test --mt
- If you have trouble installing anvil, you can install it with this command:
# install Anvil
cargo install --path ./anvil --profile local --force
Per the foundry docs
- The extension used on the video is Better TOML which has being deprecated, so please use Even Better TOML instead.
forge test -m
has been replaced byforge test --mt
- To run the foundry-devops tool, you might need to install jq
The modulo examples shown on remix in the demo are the wrong way around.
It shows on screen (line 11):
// 2 % 2 = 0. 2 % 3 = 1. 2 % 6 = 0. 2 % 7 = 1
What it should be:
// 2 % 2 = 0. 3 % 2 = 1. 6 % 2 = 0. 7 % 2 = 1
On the latest version of Openzeppelin the _isApprovedOrOwner
and _exists
are no longer included on OpenZeppelin ERC721 so we have two options:
-
Use the exact same version of OpenZeppelin as the one used on the video:
forge install openzeppelin/[email protected] --no-commit
. -
Replace the functions for their equivalent on the latest version of OpenZeppelin:
- for
_isApprovedOrOwner
replace it for:_isAuthorized
. _isAuthorized(_ownerOf(tokenId), msg.sender, tokenId)
is equivalent to_isApprovedOrOwner(msg.sender, tokenId)
.
- for
In the latest version of openzeppelin/openzeppelin-contracts ERC20Mock.sol
file has been updated with 0 constructor parameters.
You should use forge install openzeppelin/[email protected] --no-commit
command to download the appropriate version synced with the video.
The UUPSUpgradeable function upgradeTo
has been removed in Openzeppelin version 5. You should use forge install openzeppelin/[email protected] --no-commit
command to download the appropriate version synced with the video, or use upgradeToAndCall(address, new bytes(0))
instead.
Openzeppelin v5 made some changes:
- Ownable constructor has been updated with 1 parameter instead of 0. Since
Box.sol
it's inheriting it, we need to pass the address of the owner of the Box contract into its constructor:
constructor(address owner) Ownable(owner) {}
This will also change the behaviour inside the GovernorTest.sol
, where we dont need to transfer the contract ownership, but we just set it inside the constructor.
contract GovernorTest is Test {
function setUp() public {
// controlled.transferOwnership(address(timelock)); deprecated
controlled = new Controlled(address(timelock));
}
}
- The role TIMELOCK_ADMIN_ROLE has been removed inside
TimelockController.sol
. The admin can be set inside the MyTimelock constructor (1) and then (2) can be revoked after the assignement of the needed roles to MyGoverner.
contract MyTimelock is TimelockController {
constructor(uint256 minDelay, address[] memory proposers, address[] memory executors, address admin)
TimelockController(minDelay, proposers, executors, admin){}
}
contract GovernorTest is Test {
function setUp() public {
//(1)
timelock = new Timelock(MIN_DELAY, proposers, executors, address(this));
//(2)
bytes32 adminRole = timelock.DEFAULT_ADMIN_ROLE();
timelock.revokeRole(adminRole, address(this));
}
}
- Openzeppelin Wizard
- The Openzeppelin Wizard has a total different content and it misses this import inside
GovToken.sol
:import {Nonces} from "@openzeppelin/contracts/utils/Nonces.sol";
- The voting delay has now changed from 1 block to 7400: this value has to be updated also for the
VOTING_DELAY
state variable insideGovernorTest.sol
.