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

Alpha contract address deployments #584

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions contracts/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ interact-base-sepolia :;
@echo "Interacting through $(contract)..."
@SAVE_DEPLOYMENTS=1 OVERRIDE_DEPLOYMENTS=1 forge script scripts/interactions/${contract}.s.sol:${contract} --ffi --rpc-url base_sepolia --private-key ${TESTNET_PRIVATE_KEY} --broadcast --verify --verifier-url ${BASESCAN_SEPOLIA_URL} --etherscan-api-key ${BASESCAN_API_KEY}

interact-alpha-base-sepolia :;
@echo "Interacting through $(contract)..."
@SAVE_DEPLOYMENTS=1 DEPLOYMENT_CONTEXT=alpha forge script scripts/interactions/${contract}.s.sol:${contract} --ffi --rpc-url base_sepolia --private-key ${TESTNET_PRIVATE_KEY} --broadcast

test-base-sepolia :;
@echo "Testing $(contract)..."
@forge script scripts/interactions/${contract}.s.sol:${contract} --ffi --fork-url base_sepolia --private-key ${TESTNET_PRIVATE_KEY}
Expand Down
8 changes: 3 additions & 5 deletions contracts/scripts/common/Interaction.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ abstract contract Interaction is Script, DeployBase {
: vm.envUint("TESTNET_PRIVATE_KEY");

address potential = vm.addr(pk);
address deployer = isAnvil()
? potential
: msg.sender != potential
? msg.sender
: potential;
address deployer = isAnvil() ? potential : msg.sender != potential
? msg.sender
: potential;

info(
string.concat(
Expand Down
1 change: 0 additions & 1 deletion contracts/scripts/deployments/DeployBaseRegistry.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {DeployERC721ANonTransferable} from "contracts/scripts/deployments/facets
import {DeployMockMessenger} from "contracts/scripts/deployments/facets/DeployMockMessenger.s.sol";

contract DeployBaseRegistry is DiamondDeployer {
// SpaceDelegationHelper spaceDelegationHelper = new SpaceDelegationHelper();
DeployERC721ANonTransferable deployNFT = new DeployERC721ANonTransferable();

// deployments
Expand Down
9 changes: 2 additions & 7 deletions contracts/scripts/deployments/DeploySpaceFactory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ contract DeploySpaceFactory is DiamondDeployer {
500, // membershipBps 5%
0.005 ether, // membershipFee
1_000, // membershipFreeAllocation
365 days // membershipDuration
365 days, // membershipDuration
0.001 ether // membershipMinPrice
)
);
addFacet(
Expand Down Expand Up @@ -228,10 +229,4 @@ contract DeploySpaceFactory is DiamondDeployer {
)
});
}

// function postDeploy(address deployer, address spaceFactory) public override {
// vm.startBroadcast(deployer);
// ISpaceOwner(spaceOwner).setFactory(spaceFactory);
// vm.stopBroadcast();
// }
}
14 changes: 3 additions & 11 deletions contracts/scripts/deployments/DeploySpaceOwner.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,26 @@ import {IDiamond, Diamond} from "contracts/src/diamond/Diamond.sol";
// contracts
import {DiamondDeployer} from "../common/DiamondDeployer.s.sol";

// facets
import {GuardianFacet} from "contracts/src/spaces/facets/guardian/GuardianFacet.sol";

// helpers
import {DeployOwnable} from "contracts/scripts/deployments/facets/DeployOwnable.s.sol";
import {DeployDiamondCut} from "contracts/scripts/deployments/facets/DeployDiamondCut.s.sol";
import {DeployDiamondLoupe} from "contracts/scripts/deployments/facets/DeployDiamondLoupe.s.sol";
import {DeployIntrospection} from "contracts/scripts/deployments/facets/DeployIntrospection.s.sol";
import {DeployMetadata} from "contracts/scripts/deployments/facets/DeployMetadata.s.sol";
import {DeploySpaceOwnerFacet} from "contracts/scripts/deployments/facets/DeploySpaceOwnerFacet.s.sol";
import {DeployGuardianFacet} from "contracts/scripts/deployments/facets/DeployGuardianFacet.s.sol";
import {DeployMultiInit, MultiInit} from "contracts/scripts/deployments/DeployMultiInit.s.sol";

import {GuardianHelper} from "contracts/test/spaces/guardian/GuardianSetup.sol";

contract DeploySpaceOwner is DiamondDeployer {
DeployDiamondCut diamondCutHelper = new DeployDiamondCut();
DeployDiamondLoupe diamondLoupeHelper = new DeployDiamondLoupe();
DeployOwnable ownableHelper = new DeployOwnable();
DeployIntrospection introspectionHelper = new DeployIntrospection();
DeploySpaceOwnerFacet spaceOwnerHelper = new DeploySpaceOwnerFacet();
DeployMetadata metadataHelper = new DeployMetadata();
DeployGuardianFacet guardianHelper = new DeployGuardianFacet();
DeployMultiInit multiInitHelper = new DeployMultiInit();

GuardianHelper guardianHelper = new GuardianHelper();

function versionName() public pure override returns (string memory) {
return "spaceOwner";
}
Expand All @@ -47,12 +42,9 @@ contract DeploySpaceOwner is DiamondDeployer {
address ownable = ownableHelper.deploy();
address metadata = metadataHelper.deploy();
address spaceOwner = spaceOwnerHelper.deploy();
address guardian = guardianHelper.deploy();
address multiInit = multiInitHelper.deploy();

vm.startBroadcast(deployer);
address guardian = address(new GuardianFacet());
vm.stopBroadcast();

addFacet(
diamondCutHelper.makeCut(diamondCut, IDiamond.FacetCutAction.Add),
diamondCut,
Expand Down
39 changes: 39 additions & 0 deletions contracts/scripts/deployments/facets/DeployGuardianFacet.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

//interfaces

//libraries

//contracts
import {FacetHelper} from "contracts/test/diamond/Facet.t.sol";
import {Deployer} from "contracts/scripts/common/Deployer.s.sol";
import {GuardianFacet} from "contracts/src/spaces/facets/guardian/GuardianFacet.sol";

contract DeployGuardianFacet is FacetHelper, Deployer {
constructor() {
addSelector(GuardianFacet.enableGuardian.selector);
addSelector(GuardianFacet.guardianCooldown.selector);
addSelector(GuardianFacet.disableGuardian.selector);
addSelector(GuardianFacet.isGuardianEnabled.selector);
}

function versionName() public pure override returns (string memory) {
return "guardianFacet";
}

function initializer() public pure override returns (bytes4) {
return GuardianFacet.__GuardianFacet_init.selector;
}

function makeInitData(uint256 cooldown) public pure returns (bytes memory) {
return abi.encodeWithSelector(initializer(), cooldown);
}

function __deploy(address deployer) public override returns (address) {
vm.startBroadcast(deployer);
GuardianFacet facet = new GuardianFacet();
vm.stopBroadcast();
return address(facet);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ contract DeployPlatformRequirements is FacetHelper, Deployer {
uint16 membershipBps,
uint256 membershipFee,
uint256 membershipMintLimit,
uint64 membershipDuration
uint64 membershipDuration,
uint256 membershipMinPrice
) public pure returns (bytes memory) {
return
abi.encodeWithSelector(
Expand All @@ -56,7 +57,8 @@ contract DeployPlatformRequirements is FacetHelper, Deployer {
membershipBps,
membershipFee,
membershipMintLimit,
membershipDuration
membershipDuration,
membershipMinPrice
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity ^0.8.23;
// interfaces

import {ISpaceDelegation} from "contracts/src/base/registry/facets/delegation/ISpaceDelegation.sol";
import {IVotes} from "@openzeppelin/contracts/governance/utils/IVotes.sol";
import {IMainnetDelegation} from "contracts/src/tokens/river/base/delegation/IMainnetDelegation.sol";
import {IERC173} from "contracts/src/diamond/facets/ownable/IERC173.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ contract PlatformRequirementsFacet is
uint16 membershipBps,
uint256 membershipFee,
uint256 membershipMintLimit,
uint64 membershipDuration
uint64 membershipDuration,
uint256 membershipMinPrice
) external onlyInitializing {
_addInterface(type(IPlatformRequirements).interfaceId);
_setFeeRecipient(feeRecipient);
_setMembershipBps(membershipBps);
_setMembershipFee(membershipFee);
_setMembershipMintLimit(membershipMintLimit);
_setMembershipDuration(membershipDuration);
_setMembershipMinPrice(membershipMinPrice);
}

/// @inheritdoc IPlatformRequirements
Expand Down
65 changes: 19 additions & 46 deletions contracts/test/spaces/guardian/GuardianSetup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import {IDiamond, Diamond} from "contracts/src/diamond/Diamond.sol";
// libraries

// helpers
import {FacetHelper, FacetTest} from "contracts/test/diamond/Facet.t.sol";
import {FacetTest} from "contracts/test/diamond/Facet.t.sol";
import {GuardianFacet} from "contracts/src/spaces/facets/guardian/GuardianFacet.sol";
import {MultiInit} from "contracts/src/diamond/initializers/MultiInit.sol";
import {DeployGuardianFacet} from "contracts/scripts/deployments/facets/DeployGuardianFacet.s.sol";

abstract contract GuardianSetup is FacetTest {
DeployGuardianFacet internal guardianHelper = new DeployGuardianFacet();
GuardianFacet internal guardian;

function setUp() public override {
Expand All @@ -24,55 +27,25 @@ abstract contract GuardianSetup is FacetTest {
override
returns (Diamond.InitParams memory)
{
GuardianHelper guardianHelper = new GuardianHelper();
MultiInit multiInit = new MultiInit();

IDiamond.FacetCut[] memory cuts = new IDiamond.FacetCut[](1);
cuts[0] = guardianHelper.makeCut(IDiamond.FacetCutAction.Add);
address guardianFacet = guardianHelper.deploy();

addFacet(
guardianHelper.makeCut(guardianFacet, IDiamond.FacetCutAction.Add),
guardianFacet,
guardianHelper.makeInitData(7 days)
);

return
Diamond.InitParams({
baseFacets: cuts,
init: guardianHelper.facet(),
initData: guardianHelper.makeInitData(7 days)
baseFacets: baseFacets(),
init: address(multiInit),
initData: abi.encodeWithSelector(
MultiInit.multiInit.selector,
_initAddresses,
_initDatas
)
});
}
}

contract GuardianHelper is FacetHelper {
GuardianFacet internal guardian;

constructor() {
guardian = new GuardianFacet();

bytes4[] memory _selectors = new bytes4[](4);
uint256 index;

_selectors[index++] = guardian.enableGuardian.selector;
_selectors[index++] = guardian.guardianCooldown.selector;
_selectors[index++] = guardian.disableGuardian.selector;
_selectors[index++] = guardian.isGuardianEnabled.selector;

addSelectors(_selectors);
}

function facet() public view override returns (address) {
return address(guardian);
}

function initializer() public view override returns (bytes4) {
return guardian.__GuardianFacet_init.selector;
}

function selectors()
public
view
override
returns (bytes4[] memory selectors_)
{
return functionSelectors;
}

function makeInitData(uint256 cooldown) public view returns (bytes memory) {
return abi.encodeWithSelector(initializer(), cooldown);
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"address":"0x1f8cc584F711d47b9C4A5E6785DED869FbD7649b"}
{"address":"0x0230a9d28bc48a90d6f5e5112b24319ec1b14c52"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"address":"0x8B7f2CA1f83b8318b0e7ad951af143f9DE90384F"}
{"address":"0xc09ac0ffeecaae5100158247512dc177aeaca3e3"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"address":"0xc6964F8a166817AC5Fd678FF64a49255c428aAd2"}
{"address":"0x0443258849016da8Af08e2984Bce8C0ef6Cfc9A0"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"address":"0xD85bB9e2CEcdA2b8Bf39aBcb514C222046029951"}
{"address":"0x44354786eacbebf981453a05728e1653bc3c5def"}
Loading