Skip to content

Commit

Permalink
patch: using RP storage
Browse files Browse the repository at this point in the history
  • Loading branch information
cosminobol committed Aug 10, 2024
1 parent b414abc commit 467b37e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/rocket-pool/ObolRocketPoolRecipient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {ObolRocketPoolStorage} from "./ObolRocketPoolStorage.sol";
import {IRocketPoolMinipoolManager} from "../interfaces/external/rocketPool/IRocketPoolMinipoolManager.sol";
import {IRocketMinipoolDelegate} from "../interfaces/external/rocketPool/IRocketMinipoolDelegate.sol";
import {IRocketMinipoolBase} from "../interfaces/external/rocketPool/IRocketMinipoolBase.sol";
import {IRocketPoolStorage} from "../interfaces/external/rocketPool/IRocketPoolStorage.sol";

contract ObolRocketPoolRecipient is Clone {
/// -----------------------------------------------------------------------
Expand Down Expand Up @@ -77,6 +78,9 @@ contract ObolRocketPoolRecipient is Clone {
uint256 internal constant PRINCIPAL_RECIPIENT_INDEX = 0;
uint256 internal constant REWARD_RECIPIENT_INDEX = 1;

/// @dev RocketPool storage names
string constant STORAGE_MINIPOOL_MANAGER = "rocketMinipoolManager";

/// -----------------------------------------------------------------------
/// storage - cwia offsets
/// -----------------------------------------------------------------------
Expand Down Expand Up @@ -159,8 +163,8 @@ contract ObolRocketPoolRecipient is Clone {
}

function viewRewards(address _miniPool) public view returns (uint256) {
ObolRocketPoolStorage _rpStorage = ObolRocketPoolStorage(rpStorage());
address miniPoolManager = _rpStorage.rocketPoolMinipoolManager();
IRocketPoolStorage _rpStorage = IRocketPoolStorage(rpStorage());
address miniPoolManager = _rpStorage.getAddress(keccak256(abi.encodePacked("contract.address", STORAGE_MINIPOOL_MANAGER)));
if (!IRocketPoolMinipoolManager(miniPoolManager).getMinipoolExists(_miniPool)) revert InvalidMinipool_Address();

uint256 nodeRefundBalance = IRocketMinipoolDelegate(_miniPool).getNodeRefundBalance();
Expand Down Expand Up @@ -254,9 +258,9 @@ contract ObolRocketPoolRecipient is Clone {
}

function _distributeFunds(address _miniPool, bool _rewards, uint256 pullFlowFlag) internal {
ObolRocketPoolStorage _rpStorage = ObolRocketPoolStorage(rpStorage());
{
address miniPoolManager = _rpStorage.rocketPoolMinipoolManager();
IRocketPoolStorage _rpStorage = IRocketPoolStorage(rpStorage());
address miniPoolManager = _rpStorage.getAddress(keccak256(abi.encodePacked("contract.address", STORAGE_MINIPOOL_MANAGER)));
if (!IRocketPoolMinipoolManager(miniPoolManager).getMinipoolExists(_miniPool)) revert InvalidMinipool_Address();
}

Expand Down
1 change: 1 addition & 0 deletions src/rocket-pool/ObolRocketPoolStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity 0.8.19;

import {Ownable} from "solady/auth/Ownable.sol";

/// @dev deprecated
//https://docs.rocketpool.net/overview/contracts-integrations
contract ObolRocketPoolStorage is Ownable {
// address internal constant RP_DEPOSIT = 0xDD3f50F8A6CafbE9b31a427582963f465E745AF8;
Expand Down
5 changes: 3 additions & 2 deletions src/test/rocket-pool/ObolRocketPoolRecipient.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {IENSReverseRegistrar} from "../../interfaces/IENSReverseRegistrar.sol";

import {RPMinipoolManagerMock} from "./mocks/RPMinipoolManagerMock.sol";
import {RPMinipoolMock} from "./mocks/RPMinipoolMock.sol";
import {RPStorageMock} from "./mocks/RPStorageMock.sol";

contract ObolRocketPoolRecipientTest is RocketPoolTestHelper, Test {
using SafeTransferLib for address;
Expand All @@ -24,7 +25,7 @@ contract ObolRocketPoolRecipientTest is RocketPoolTestHelper, Test {

ObolRocketPoolRecipient public rpModule;
ObolRocketPoolRecipientFactory public rpFactory;
ObolRocketPoolStorage rpStorage;
RPStorageMock rpStorage;
address internal recoveryAddress;

ObolRocketPoolRecipient public rpRecipient;
Expand All @@ -51,7 +52,7 @@ contract ObolRocketPoolRecipientTest is RocketPoolTestHelper, Test {
bytes.concat(bytes32(0))
);

rpStorage = new ObolRocketPoolStorage();
rpStorage = new RPStorageMock();
rpFactory = new ObolRocketPoolRecipientFactory(
address(rpStorage), "demo.obol.eth", ENS_REVERSE_REGISTRAR_GOERLI, address(this)
);
Expand Down
14 changes: 14 additions & 0 deletions src/test/rocket-pool/mocks/RPStorageMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.19;

contract RPStorageMock {
address public minipoolManager;

function setMinipoolManager(address _minipoolManager) external {
minipoolManager = _minipoolManager;
}

function getAddress(bytes32) external view returns (address) {
return minipoolManager;
}
}

0 comments on commit 467b37e

Please sign in to comment.