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 14 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();
}
}
78 changes: 78 additions & 0 deletions script/DeployPullOWRAndSplit.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// 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 splitMain address for 0xsplits splitMain
/// @param pullOwrFactory address for factory
function run(string memory jsonFilePath, address splitMain, address pullOwrFactory, uint256 stakeSize)
// function run()
external
{
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;

uint256 stakeAmount = stakeSize * 1 ether;

for (uint256 i = 0; i < data.length; i++) {
// deploy split
ConfigurationData memory currentConfiguration = data[i];

vm.startBroadcast(privKey);

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

// create obol split
address pullOwrAddress = address(
OptimisticPullWithdrawalRecipientFactory(pullOwrFactory).createOWRecipient(
ETH_ADDRESS, currentConfiguration.recoveryRecipient, currentConfiguration.principalRecipient, split, stakeAmount
)
);

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);
}
}
}
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();
}
}
Loading
Loading