-
Notifications
You must be signed in to change notification settings - Fork 359
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
Add FeeCurrencyDirectory to Anvil migrations #10992
Add FeeCurrencyDirectory to Anvil migrations #10992
Conversation
Not checked that the current changes are sufficient and working.
Notes-to-self
/**
* @notice Sets the currency configuration for a token.
* @dev This action can only be performed by the contract owner.
* @param token The token address.
* @param oracle The oracle address for price fetching.
* @param intrinsicGas The intrinsic gas value for transactions.
*/
function setCurrencyConfig(
address token,
address oracle,
uint256 intrinsicGas
)
|
Test migration locallyRequirement:
Steps to reproduce:
Test
|
…y-to-Anvil-migrations
1. adds test oracle address 2. adds test intrinsic gas value
…y-to-Anvil-migrations
(note-to-self) |
…interface I was calling `initialize()`, but that function is defined in `FeeCurrencyDirectory` not `IFeeCurrencyDirectory`. Also updates string length, which was previously forgotten. At this point the compilation succeeds as expected, and the migration transactions are successful.
At this point the compilation succeeds as expected, and the migration transactions are successful. Next, I'll run a local Anvil instance (with all the migrations), and I'll interact with the deployed
|
(note-to-self)
|
At this point (a36eae5), the local tests pass. Local testWe can:
|
This means, all currencies registered in the `FeeCurrencyDirectory` now support the `getExchangeRate` function, which uses the MockOracle contract under the hood.
As of 8b910b7, the migration script sets the oracle in This works as expected ✅ Calling the $ cast call \
0x42Fe5a2A61ed9705eb2F08a04A58CEB606D22f6a \
"getExchangeRate(address)(uint256, uint256)" \
0xb7a33b4ad2B1f6b0a944232F5c71798d27Ad9272 \
--rpc-url=http://127.0.0.1:8546/
10
5 |
…y-to-Anvil-migrations
…grations' of github.com:celo-org/celo-monorepo into arthurgousset/feat/add-FeeCurrencyDirectory-to-Anvil-migrations
The `SortedOracles.sol` contract already implements the `IOracle.sol` interface. This commit only adds it to the contract definition for ease of reference.
…cles` The latest `SortedOracles.sol` implementation implements the `IOracle.sol` interface. That means it implements the required `getExchangeRate()` function. That means the `MockOracle.sol` contract is not required in the migrations.
As of 1c04e8b, the migration script sets the oracle in This works as expected ✅ Calling the $ cast call \
0x42Fe5a2A61ed9705eb2F08a04A58CEB606D22f6a \
"getExchangeRate(address)(uint256, uint256)" \
0xb7a33b4ad2B1f6b0a944232F5c71798d27Ad9272 \
--rpc-url=http://127.0.0.1:8546
1000000000000000000000000 [1e24]
1000000000000000000000000 [1e24] |
Now matches error message defined in `isL2Check.sol` Source: https://github.com/celo-org/celo-monorepo/blob/668a4050f7ee067948498c333da3feec85fa03fe/packages/protocol/contracts-0.8/common/IsL2Check.sol#L32-L33
Description
Adds the new
FeeCurrencyDirectory
contract to the Anvil migration script.Changes
FeeCurrencyDirectory
contractFeeCurrencyDirectory
in theRegistry
FeeCurrencyDirectory
Other changes
is IOracle
to the class definition inSortedOracles
Migrations.s.sol
Tested
Yes, tested locally:
FeeCurrencyDirectory
address from theRegistry
FeeCurrencyDirectory
contractFeeCurrencyDirectory
contractSteps to reproduce tests locally
Requirement:
packages/protocol
directoryTests:
Run migration script (in a different Terminal)
Check that Anvil is running
Source: start_anvil.sh
Anvil is running ✅
get the
FeeCurrencyDirectory
address from theRegistry
:FeeCurrencyDirectory
is registered in theRegistry
✅get registered currencies from the
FeeCurrencyDirectory
contract3 currencies are registered in the
FeeCurrencyDirectory
✅ As expected, the registered currencies are:cUSD ✅
cast call \ 0xe6774BE4E5f97dB10cAFB4c00C74cFbdCDc434D9 \ "name()" \ --rpc-url=http://127.0.0.1:8546 0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b43656c6f20446f6c6c6172000000000000000000000000000000000000000000
cEUR ✅
cast call \ 0xb7a33b4ad2B1f6b0a944232F5c71798d27Ad9272 \ "name()" \ --rpc-url=http://127.0.0.1:8546 0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000943656c6f204575726f0000000000000000000000000000000000000000000000
cREAL ✅
cast call \ 0x2A3733dBc31980f02b12135C809b5da33BF3a1e9 \ "name()" \ --rpc-url=http://127.0.0.1:8546 0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001343656c6f204272617a696c69616e205265616c00000000000000000000000000
Get exchange rate for a currency:
$ cast call \ 0x42Fe5a2A61ed9705eb2F08a04A58CEB606D22f6a \ "getExchangeRate(address)(uint256, uint256)" \ 0xb7a33b4ad2B1f6b0a944232F5c71798d27Ad9272 \ --rpc-url=http://127.0.0.1:8546 1000000000000000000000000 [1e24] 1000000000000000000000000 [1e24]
Calling the
getExchangeRate
function on a registered currency returns an exchange rate ✅Terminate Anvil:
Source: start_anvil.sh
Related issues
Backwards compatibility
Yes, only adds to the migration script, doesn't alter existing expectations and behaviour.
Documentation
No docs changes