Skip to content
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: ObolErc1155Recipient #138

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
43 changes: 43 additions & 0 deletions script/CreateERC1155RecipientTestData.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "forge-std/Script.sol";
import {IObolErc1155Recipient} from "src/interfaces/IObolErc1155Recipient.sol";

contract CreateERC1155RecipientTestData is Script {
function run(address _erc1155Recipient, address _owr) external {
IObolErc1155Recipient _recipient = IObolErc1155Recipient(_erc1155Recipient);

IObolErc1155Recipient.DepositInfo memory depositInfo = IObolErc1155Recipient.DepositInfo({
pubkey: "",
withdrawal_credentials: "",
sig: "",
root: bytes32(0)
});

// Create 3 partitions with the following configuration:
// - 1 with a max supply of 20 out of which 3 are active
// - 1 with a max supply of 50 out of which 2 are active
// - 1 with a max supply of 10, all of them active

//0
_recipient.createPartition(20, _owr);

//1
_recipient.createPartition(50, _owr);

//2
_recipient.createPartition(10, _owr);

// Recipient should use a mock version of the deposit contract
// Have 1 active validator in each partition
for(uint256 i; i < 3; i++) {
_recipient.mint{value: 0}(i, depositInfo);
}

// Activate the rest of the validators in the 3rd partition
for(uint256 i; i < 9; i++) {
_recipient.mint{value: 0}(2, depositInfo);
}
}
}
19 changes: 19 additions & 0 deletions script/DeployERC1155Recipient.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "forge-std/Script.sol";
import {ObolErc1155Recipient} from "src/owr/ObolErc1155Recipient.sol";

contract DeployERC1155Recipient is Script {

// @dev `_depositContract` is passed to allow
function run(string memory _baseUri, address _owner, address _depositContract) external {
uint256 privKey = vm.envUint("PRIVATE_KEY");

vm.startBroadcast(privKey);

new ObolErc1155Recipient{salt: keccak256("owr.erc1155recipient")}(_baseUri, _owner, _depositContract);

vm.stopBroadcast();
}
}
17 changes: 17 additions & 0 deletions script/DeployMockDepositContract.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "forge-std/Script.sol";
import {DepositContractMock} from "src/test/owr/mocks/DepositContractMock.sol";

contract DeployMockDepositContract is Script {
function run() external {
uint256 privKey = vm.envUint("PRIVATE_KEY");

vm.startBroadcast(privKey);

new DepositContractMock{salt: keccak256("depositContractMock")}();

vm.stopBroadcast();
}
}
2 changes: 1 addition & 1 deletion script/DeployOTWRAndSplit.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.19;

import "forge-std/Script.sol";
import {OptimisticTokenWithdrawalRecipientFactory} from "src/owr/token/OptimisticTokenWithdrawalRecipientFactory.sol";
import {ISplitMain, SplitConfiguration} from "src/interfaces/ISplitMain.sol";
import {ISplitMain, SplitConfiguration} from "src/interfaces/external/splits/ISplitMain.sol";
import {SplitterConfiguration} from "./SplitterConfiguration.sol";

contract DeployOTWRAndSplit is Script, SplitterConfiguration {
Expand Down
73 changes: 73 additions & 0 deletions script/DeployPullOWRAndSplit.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "forge-std/Script.sol";
import {OptimisticPullWithdrawalRecipientFactory} from "src/owr/OptimisticPullWithdrawalRecipientFactory.sol";
import {ISplitMain, SplitConfiguration} from "src/interfaces/external/splits/ISplitMain.sol";
import {SplitterConfiguration} from "./SplitterConfiguration.sol";

contract DeployPullOWRAndSplit is Script, SplitterConfiguration {
address private constant ETH_ADDRESS = address(0);

error Invalid_PrincipalRecipient();

struct ConfigurationData {
address principalRecipient;
address recoveryRecipient;
JsonSplitData split;
}

/// @param jsonFilePath the data format can be seen in ./data/deploy-pullOWR-sample.json
/// @param split address for 0xsplits PullSplit
/// @param pullOwrFactory address for factory
function run(string memory jsonFilePath, address split, address pullOwrFactory, uint256 stakeSize)
external
{
// string memory jsonFilePath = "script/data/deploy-pullOwr-sample.json";
// address pullOwrFactory = 0xcFf568fBD1386f0d7784C174411341C8588d4Ba4;
// address split = 0x2636b017110c4d8977C6a7351D1de09e95fd595a;
// uint256 stakeSize = 32;

uint256 privKey = vm.envUint("PRIVATE_KEY");
bytes memory parsedJson = vm.parseJson(vm.readFile(jsonFilePath));

ConfigurationData[] memory data = abi.decode(parsedJson, (ConfigurationData[]));
_validateInputJson(data);

// deploy the split and obol script
string memory jsonKey = "pullOwrDeploy";
string memory finalJSON;

for (uint256 i = 0; i < data.length; i++) {
{
vm.startBroadcast(privKey);

ConfigurationData memory currentConfiguration = data[i];
address pullOwrAddress = address(
OptimisticPullWithdrawalRecipientFactory(pullOwrFactory).createOWRecipient(
ETH_ADDRESS, currentConfiguration.recoveryRecipient, currentConfiguration.principalRecipient, split, stakeSize * 1 ether
)
);

vm.stopBroadcast();

string memory objKey = vm.toString(i);

vm.serializeAddress(objKey, "splitAddress", split);
string memory repsonse = vm.serializeAddress(objKey, "pullOWRAddress", pullOwrAddress);

finalJSON = vm.serializeString(jsonKey, objKey, repsonse);
}

}

vm.writeJson(finalJSON, "./pullOwr-split.json");
}

function _validateInputJson(ConfigurationData[] memory configuration) internal pure {
for (uint256 i = 0; i < configuration.length; i++) {
if (configuration[i].principalRecipient == address(0)) revert Invalid_PrincipalRecipient();
_validateSplitInputJson(configuration[i].split);
}
}
}
17 changes: 17 additions & 0 deletions script/DeployPullSplitMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "forge-std/Script.sol";
import {PullSplitMock} from "src/test/owr/mocks/PullSplitMock.sol";

contract DeployPullSplitMock is Script {
function run() external {
uint256 privKey = vm.envUint("PRIVATE_KEY");

vm.startBroadcast(privKey);

new PullSplitMock{salt: keccak256("pullSplitMock.1")}();

vm.stopBroadcast();
}
}
38 changes: 19 additions & 19 deletions script/OWRFactoryScript.s.sol
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import "forge-std/Script.sol";
import {OptimisticWithdrawalRecipientFactory} from "src/owr/OptimisticWithdrawalRecipientFactory.sol";

contract OWRFactoryScript is Script {
function run(string memory _name, address _ensReverseRegistrar, address _ensOwner) external {
uint256 privKey = vm.envUint("PRIVATE_KEY");

vm.startBroadcast(privKey);

new OptimisticWithdrawalRecipientFactory{salt: keccak256("obol.owrFactory.v1")}(
_name, _ensReverseRegistrar, _ensOwner
);

vm.stopBroadcast();
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "forge-std/Script.sol";
import {OptimisticWithdrawalRecipientFactory} from "src/owr/OptimisticWithdrawalRecipientFactory.sol";
contract OWRFactoryScript is Script {
function run(string memory _name, address _ensReverseRegistrar, address _ensOwner) external {
uint256 privKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(privKey);
new OptimisticWithdrawalRecipientFactory{salt: keccak256("obol.owrFactory.v1")}(
_name, _ensReverseRegistrar, _ensOwner
);
vm.stopBroadcast();
}
}
156 changes: 78 additions & 78 deletions script/ObolLidoSetupScript.sol
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "forge-std/Script.sol";
import {ISplitMain, SplitConfiguration} from "src/interfaces/ISplitMain.sol";
import {ObolLidoSplitFactory} from "src/lido/ObolLidoSplitFactory.sol";
import {SplitterConfiguration} from "./SplitterConfiguration.sol";

/// @title ObolLidoScript
/// @author Obol
/// @notice Creates Split and ObolLidoSplit Adddresses
///
/// @dev Takes a json file following the format defined at ./data/lido-data-sample.json
/// and deploys split and ObolLido split contracts.
///
/// It outputs the result of the script to "./result.json"
///
/// NOTE: It's COMPULSORY the json file supplied follows the arrangement format defined
/// in the sample file else the json parse will fail.
///
///
/// To Run
///
/// Step 1 fill in the appropriate details for env vars
/// > cp .env.deployment .env
///
/// Step 2 add to environment
/// > source .env
///
/// Step 3 Run forge script to simulate the execution of the transaction
///
/// > forge script script/ObolLidoSetupScript.sol:ObolLidoSetupScript --fork-url $RPC_URL -vvvv --sig
/// "run(string,address,address)" "<PATH_TO_JSON_FILE e.g. ./script/data/lido-data-sample.json>" $SPLITMAIN
/// $OBOL_LIDO_SPLIT_FACTORY
///
/// add --broadcast flag to broadcast to the public blockchain

contract ObolLidoSetupScript is Script, SplitterConfiguration {
function run(string memory jsonFilePath, address splitMain, address obolLidoSplitFactory) external {
uint256 privKey = vm.envUint("PRIVATE_KEY");

string memory file = vm.readFile(jsonFilePath);
bytes memory parsedJson = vm.parseJson(file);
JsonSplitData[] memory configuration = abi.decode(parsedJson, (JsonSplitData[]));
_validateSplitInputJson(configuration);

// deploy the split and obol script
string memory jsonKey = "lidoObolDeploy";
string memory finalJSON;

for (uint256 j = 0; j < configuration.length; j++) {
string memory objKey = vm.toString(j);
// deploy split
JsonSplitData memory currentConfiguration = configuration[j];

vm.startBroadcast(privKey);

address split = ISplitMain(splitMain).createSplit(
currentConfiguration.accounts,
currentConfiguration.percentAllocations,
currentConfiguration.distributorFee,
currentConfiguration.controller
);

// create obol split
address obolLidoSplitAdress = ObolLidoSplitFactory(obolLidoSplitFactory).createCollector(address(0), split);

vm.stopBroadcast();

vm.serializeAddress(objKey, "splitAddress", split);
string memory repsonse = vm.serializeAddress(objKey, "obolLidoSplitAddress", obolLidoSplitAdress);

finalJSON = vm.serializeString(jsonKey, objKey, repsonse);
}

vm.writeJson(finalJSON, "./result.json");
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "forge-std/Script.sol";
import {ISplitMain, SplitConfiguration} from "src/interfaces/external/splits/ISplitMain.sol";
import {ObolLidoSplitFactory} from "src/lido/ObolLidoSplitFactory.sol";
import {SplitterConfiguration} from "./SplitterConfiguration.sol";
/// @title ObolLidoScript
/// @author Obol
/// @notice Creates Split and ObolLidoSplit Adddresses
///
/// @dev Takes a json file following the format defined at ./data/lido-data-sample.json
/// and deploys split and ObolLido split contracts.
///
/// It outputs the result of the script to "./result.json"
///
/// NOTE: It's COMPULSORY the json file supplied follows the arrangement format defined
/// in the sample file else the json parse will fail.
///
///
/// To Run
///
/// Step 1 fill in the appropriate details for env vars
/// > cp .env.deployment .env
///
/// Step 2 add to environment
/// > source .env
///
/// Step 3 Run forge script to simulate the execution of the transaction
///
/// > forge script script/ObolLidoSetupScript.sol:ObolLidoSetupScript --fork-url $RPC_URL -vvvv --sig
/// "run(string,address,address)" "<PATH_TO_JSON_FILE e.g. ./script/data/lido-data-sample.json>" $SPLITMAIN
/// $OBOL_LIDO_SPLIT_FACTORY
///
/// add --broadcast flag to broadcast to the public blockchain
contract ObolLidoSetupScript is Script, SplitterConfiguration {
function run(string memory jsonFilePath, address splitMain, address obolLidoSplitFactory) external {
uint256 privKey = vm.envUint("PRIVATE_KEY");
string memory file = vm.readFile(jsonFilePath);
bytes memory parsedJson = vm.parseJson(file);
JsonSplitData[] memory configuration = abi.decode(parsedJson, (JsonSplitData[]));
_validateSplitInputJson(configuration);
// deploy the split and obol script
string memory jsonKey = "lidoObolDeploy";
string memory finalJSON;
for (uint256 j = 0; j < configuration.length; j++) {
string memory objKey = vm.toString(j);
// deploy split
JsonSplitData memory currentConfiguration = configuration[j];
vm.startBroadcast(privKey);
address split = ISplitMain(splitMain).createSplit(
currentConfiguration.accounts,
currentConfiguration.percentAllocations,
currentConfiguration.distributorFee,
currentConfiguration.controller
);
// create obol split
address obolLidoSplitAdress = ObolLidoSplitFactory(obolLidoSplitFactory).createCollector(address(0), split);
vm.stopBroadcast();
vm.serializeAddress(objKey, "splitAddress", split);
string memory repsonse = vm.serializeAddress(objKey, "obolLidoSplitAddress", obolLidoSplitAdress);
finalJSON = vm.serializeString(jsonKey, objKey, repsonse);
}
vm.writeJson(finalJSON, "./result.json");
}
}
Loading
Loading