mirror of
https://github.com/logos-messaging/logos-messaging-rlnv2-contract.git
synced 2026-08-10 16:53:18 +00:00
chore: update readme and script to allow running on anvil
This commit is contained in:
parent
a658315e03
commit
3fbcbfe624
@ -59,7 +59,14 @@ $ forge coverage
|
||||
#### Deploy to Anvil:
|
||||
|
||||
```sh
|
||||
$ forge script script/Deploy.s.sol --broadcast --fork-url http://localhost:8545
|
||||
$ TOKEN_ADDRESS=0x1122334455667788990011223344556677889900 forge script script/Deploy.s.sol --broadcast --rpc-url localhost --tc Deploy
|
||||
```
|
||||
|
||||
Replace the `TOKEN_ADDRESS` value by a token address you have deployed on anvil. A `TestToken` is available in
|
||||
`test/TestToken.sol` and can be deployed with
|
||||
|
||||
```sh
|
||||
forge script test/TestToken.sol --broadcast --rpc-url localhost --tc TestTokenFactory
|
||||
```
|
||||
|
||||
For this script to work, you need to have a `MNEMONIC` environment variable set to a valid
|
||||
|
||||
@ -11,15 +11,30 @@ import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils
|
||||
import { BaseScript } from "./Base.s.sol";
|
||||
|
||||
contract Deploy is BaseScript {
|
||||
function run(address _token) public broadcast returns (WakuRlnV2 w, address impl) {
|
||||
// TODO: Use the correct values when deploying to mainnet
|
||||
function run() public broadcast returns (WakuRlnV2 w, address impl) {
|
||||
address _token = _getTokenAddress();
|
||||
return deploy(_token);
|
||||
}
|
||||
|
||||
function deploy(address _token) public returns (WakuRlnV2 w, address impl) {
|
||||
address priceCalcAddr = address(new LinearPriceCalculator(_token, 0.05 ether));
|
||||
// TODO: set DAI address 0x6B175474E89094C44Da98b954EedeAC495271d0F
|
||||
impl = address(new WakuRlnV2());
|
||||
bytes memory data = abi.encodeCall(WakuRlnV2.initialize, (priceCalcAddr, 160_000, 20, 600, 180 days, 30 days));
|
||||
address proxy = address(new ERC1967Proxy(impl, data));
|
||||
w = WakuRlnV2(proxy);
|
||||
}
|
||||
|
||||
function _getTokenAddress() internal view returns (address) {
|
||||
try vm.envAddress("TOKEN_ADDRESS") returns (address passedAddress) {
|
||||
return passedAddress;
|
||||
} catch {
|
||||
if (block.chainid == 1) {
|
||||
return 0x6B175474E89094C44Da98b954EedeAC495271d0F; // DAI address on mainnet
|
||||
} else {
|
||||
revert("no TOKEN_ADDRESS was specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
contract DeployLibs is BaseScript {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity >=0.8.19 <0.9.0;
|
||||
|
||||
import { BaseScript } from "../script/Base.s.sol";
|
||||
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||
|
||||
contract TestToken is ERC20 {
|
||||
@ -10,3 +11,9 @@ contract TestToken is ERC20 {
|
||||
_mint(to, amount);
|
||||
}
|
||||
}
|
||||
|
||||
contract TestTokenFactory is BaseScript {
|
||||
function run() public broadcast returns (address) {
|
||||
return address(new TestToken());
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ contract WakuRlnV2Test is Test {
|
||||
token = new TestToken();
|
||||
|
||||
Deploy deployment = new Deploy();
|
||||
(w, impl) = deployment.run(address(token));
|
||||
(w, impl) = deployment.deploy(address(token));
|
||||
|
||||
// Minting a large number of tokens to not have to worry about
|
||||
// Not having enough balance
|
||||
@ -898,7 +898,7 @@ contract WakuRlnV2Test is Test {
|
||||
|
||||
/*| Name | Type | Slot | Offset | Bytes |
|
||||
|---------------------|-----------------------------------------------------|------|--------|-------|
|
||||
| nextCommitmentIndex | uint32 | 206 | 0 | 4 | */
|
||||
| nextCommitmentIndex | uint32 | 206 | 0 | 4 | */
|
||||
|
||||
/*
|
||||
Pro tip: to easily find the storage slot of a variable, without having to calculate the storage layout
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user