Skip to content

Commit

Permalink
patch: small fixes for ERC1155
Browse files Browse the repository at this point in the history
  • Loading branch information
cosminobol committed Jul 1, 2024
1 parent 73c5bd6 commit 9bd7932
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 42 deletions.
49 changes: 22 additions & 27 deletions script/DeployPullOWRAndSplit.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ contract DeployPullOWRAndSplit is Script, SplitterConfiguration {
}

/// @param jsonFilePath the data format can be seen in ./data/deploy-pullOWR-sample.json
/// @param splitMain address for 0xsplits splitMain
/// @param split address for 0xsplits PullSplit
/// @param pullOwrFactory address for factory
function run(string memory jsonFilePath, address splitMain, address pullOwrFactory, uint256 stakeSize)
// function run()
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));

Expand All @@ -34,36 +38,27 @@ contract DeployPullOWRAndSplit is Script, SplitterConfiguration {
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
);
{
vm.startBroadcast(privKey);

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

vm.stopBroadcast();
vm.stopBroadcast();

string memory objKey = vm.toString(i);
string memory objKey = vm.toString(i);

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

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

}

vm.writeJson(finalJSON, "./pullOwr-split.json");
Expand Down
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();
}
}
16 changes: 2 additions & 14 deletions script/data/deploy-pullOwr-sample.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
[
{
"principalRecipient": "0x0000e6203DB925DbFB9e3d650A80a1E2f4A78e94",
"recoveryRecipient": "0x0000e6203DB925DbFB9e3d650A80a1E2f4A78e94",
"split": {
"accounts": [
"0x0000e6203DB925DbFB9e3d650A80a1E2f4A78e94",
"0x08610E2A424c23169F79108D263Ed04f570A44FC"
],
"controller": "0x0000e6203DB925DbFB9e3d650A80a1E2f4A78e94",
"distributorFee": 1,
"percentAllocations": [
500000,
500000
]
}
"principalRecipient": "0x7712657E5a734fb19E3b6Bbb463dFa92BcDDb2DD",
"recoveryRecipient": "0x0000e6203DB925DbFB9e3d650A80a1E2f4A78e94"
}
]
1 change: 0 additions & 1 deletion src/owr/ObolErc1155Recipient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ contract ObolErc1155Recipient is ERC1155, Ownable, IERC1155Receiver {
// withdraw from the OWR
uint256 pullBalance = _owr.getPullBalance(address(this));
uint256 toWithdraw = pullBalance < ETH_DEPOSIT_AMOUNT ? pullBalance: ETH_DEPOSIT_AMOUNT;
if (toWithdraw < MIN_ETH_EXIT_AMOUNT) revert InvalidBurnAmount(MIN_ETH_EXIT_AMOUNT, toWithdraw);
_owr.withdraw(address(this), toWithdraw);

_burn(msg.sender, _tokenId, 1);
Expand Down

0 comments on commit 9bd7932

Please sign in to comment.