Skip to content

Commit

Permalink
Base deployment scripts v2 (#28)
Browse files Browse the repository at this point in the history
* deprecate utils in favor of Solmate

* forge snapshot

* Base deployment v2

* fix: broken imports
  • Loading branch information
Sabnock01 authored Nov 17, 2023
1 parent c07dc46 commit 1c60d7e
Show file tree
Hide file tree
Showing 12 changed files with 216 additions and 28 deletions.
22 changes: 0 additions & 22 deletions script/deploy/DeployBaseGoerli.s.sol

This file was deleted.

2 changes: 1 addition & 1 deletion script/deploy/deprecated/DeployConstellation.s.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { DeployBase } from "../DeployBase.s.sol";
import { DeployBase } from "../v0.0.1/DeployBase.s.sol";

/// @notice A script to deploy the protocol on Constellation.
contract DeployConstellation is DeployBase {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
155 changes: 155 additions & 0 deletions script/deploy/v0.0.2/DeployBase.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { Script, console } from "forge-std/Script.sol";
import { AuthorshipToken } from "@/contracts/AuthorshipToken.sol";
import { Curta } from "@/contracts/Curta.sol";
import { FlagRenderer } from "@/contracts/FlagRenderer.sol";

contract DeployBase is Script {
// -------------------------------------------------------------------------
// Environment specific variables
// -------------------------------------------------------------------------

/// @notice The address to transfer the Authorship Token's ownership to
/// immediately after deploy.
address public immutable authorshipTokenOwner;

/// @notice The address to transfer the Curta's ownership to immediately
/// after deploy.
address public immutable curtaOwner;

/// @notice The number of seconds until an additional token is made
/// available for minting by the author.
uint256 public immutable issueLength;

/// @notice The number of authors in the initial batch that will receive 1
/// Authorship Token each.
uint256 public immutable authorsLength;

/// @notice The list of authors in the initial batch that will receive 1
/// Authorship Token each.
mapping(uint256 => address) public authors;

/// @notice Sender address used for the deployment.
address curtaDeployer = 0x63F1E3CCA306a9818F6F5c76AD491a9293C57d76;

// -------------------------------------------------------------------------
// Deployment addresses
// -------------------------------------------------------------------------

/// @notice The instance of `AuthorshipToken` that will be deployed after
/// the script runs.
AuthorshipToken public authorshipToken;

/// @notice The instance of `FlagRenderer` that will be deployed and set in
/// `curta` as its base `flagRenderer` after the script runs.
FlagRenderer public flagRenderer;

/// @notice The instance of `Curta` that will be deployed after the script
/// runs.
Curta public curta;

/// @notice Address of the Create2Deployer
/// @dev This address is different on all chains except Base mainnet
/// where it is a predeploy.
address create2Deployer;

/// @notice The expected address for the deployed `FlagRenderer`.
address flagRendererAddress = 0xF1a9000080AdCB839aC55E2996c3e0c9602C2Ae4;

/// @notice The expected address for the deployed `AuthorshipToken`.
address authorshipTokenAddress = 0xC0ffe50b579c2695F42049a5351FF3a37794c872;

/// @notice The expected address for the deployed `Curta`.
address curtaAddress = 0x0000000041968e6fB76560021ee7D83175ed7eD1;

constructor(
address _create2Deployer,
address _authorshipTokenOwner,
address _curtaOwner,
uint256 _issueLength,
address[] memory _authors
) {
create2Deployer = _create2Deployer;
authorshipTokenOwner = _authorshipTokenOwner;
curtaOwner = _curtaOwner;
issueLength = _issueLength;

uint256 length = _authors.length;
authorsLength = length;
for (uint256 i; i < length;) {
authors[i] = _authors[i];
unchecked {
++i;
}
}
}

function run() public {
// Set up authors for AuthorshipToken
uint256 length = authorsLength;
address[] memory initialAuthors = new address[](length);
for (uint256 i; i < length;) {
initialAuthors[i] = authors[i];
unchecked {
++i;
}
}

// Compute and print initcode hashes for each contract
// _printInitcodeHashes(initialAuthors);

vm.startBroadcast();

// Deploy FlagRenderer
create2Deployer.call(abi.encodeWithSignature(
"deploy(uint256,bytes32,bytes)",
0,
bytes32(uint256(27228880951058027584878031418626584945025905217501640862369820082332481093632)),
type(FlagRenderer).creationCode
));

// Deploy AuthorshipToken
create2Deployer.call(abi.encodeWithSignature(
"deploy(uint256,bytes32,bytes)",
0,
bytes32(uint256(6447998015847004963245564656868529952164055284815449929101636674540665831424)),
abi.encodePacked(
type(AuthorshipToken).creationCode,
abi.encode(
curtaAddress,
issueLength,
initialAuthors
)
)
));

// Deploy Curta
curta = new Curta(
AuthorshipToken(authorshipTokenAddress),
FlagRenderer(flagRendererAddress)
);

vm.stopBroadcast();

flagRenderer = FlagRenderer(flagRendererAddress);
authorshipToken = AuthorshipToken(authorshipTokenAddress);
}

function _printInitcodeHashes(address[] memory initialAuthors) internal view {
console.logBytes32(keccak256(abi.encodePacked(type(FlagRenderer).creationCode)));
console.logBytes32(
keccak256(
abi.encodePacked(
type(AuthorshipToken).creationCode,
abi.encode(
curtaAddress,
issueLength,
initialAuthors
)
)
)
);
}
}
41 changes: 41 additions & 0 deletions script/deploy/v0.0.2/DeployBaseGoerli.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { DeployBase } from "./DeployBase.s.sol";

contract DeployBaseGoerli is DeployBase {
/// @notice The address to transfer the ownership of the Authorship Token
/// to.
address constant AUTHORSHIP_TOKEN_OWNER = 0xA85572Cd96f1643458f17340b6f0D6549Af482F5;

/// @notice The address to transfer the ownership of Curta to.
address constant CURTA_OWNER = 0xA85572Cd96f1643458f17340b6f0D6549Af482F5;

/// @notice The number of seconds until an additional token is made
/// available for minting by the author.
uint256 constant ISSUE_LENGTH = 3 days;

/// @notice Address of the create2 deployer used for deploying
/// the `FlagRenderer` and `AuthorshipToken` contracts.
/// @dev https://github.com/pcaversaccio/create2deployer
address constant CREATE2DEPLOYER = 0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2;

/// @notice The list of authors in the initial batch.
address[] internal AUTHORS = [
// fiveoutofnine.eth
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
// sabnock.eth
0xDbAacdcadD7c51a325B771ff75B261a1e7baE11c
];

constructor() DeployBase(CREATE2DEPLOYER, AUTHORSHIP_TOKEN_OWNER, CURTA_OWNER, ISSUE_LENGTH, AUTHORS) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,27 @@ contract DeployBaseMainnet is DeployBase {
/// available for minting by the author.
uint256 constant ISSUE_LENGTH = 3 days;

/// @notice Address of the create2 deployer used for deploying
/// the `FlagRenderer` and `AuthorshipToken` contracts.
/// @dev https://github.com/pcaversaccio/create2deployer
address constant CREATE2DEPLOYER = address(0);

/// @notice The list of authors in the initial batch.
address[] internal AUTHORS = [
// fiveoutofnine.eth
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
// sabnock.eth
0xDbAacdcadD7c51a325B771ff75B261a1e7baE11c
];

constructor() DeployBase(AUTHORSHIP_TOKEN_OWNER, CURTA_OWNER, ISSUE_LENGTH, AUTHORS) { }
constructor() DeployBase(CREATE2DEPLOYER, AUTHORSHIP_TOKEN_OWNER, CURTA_OWNER, ISSUE_LENGTH, AUTHORS) { }
}
2 changes: 1 addition & 1 deletion test/deploy/DeployBaseGoerli.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Test } from "forge-std/Test.sol";

import { AuthorshipToken } from "@/contracts/AuthorshipToken.sol";
import { Curta } from "@/contracts/Curta.sol";
import { DeployBaseGoerli } from "@/script/deploy/DeployBaseGoerli.s.sol";
import { DeployBaseGoerli } from "@/script/deploy/v0.0.2/DeployBaseGoerli.s.sol";

/// @notice Tests the Base Goerli deploy script.
contract DeployBaseGoerliTest is Test {
Expand Down
2 changes: 1 addition & 1 deletion test/deploy/DeployBaseMainnet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Test } from "forge-std/Test.sol";

import { AuthorshipToken } from "@/contracts/AuthorshipToken.sol";
import { Curta } from "@/contracts/Curta.sol";
import { DeployBaseMainnet } from "@/script/deploy/DeployBaseMainnet.s.sol";
import { DeployBaseMainnet } from "@/script/deploy/v0.0.2/DeployBaseMainnet.s.sol";

/// @notice Tests the Base mainnet deploy script.
contract DeployBaseMainnetTest is Test {
Expand Down
2 changes: 1 addition & 1 deletion test/deploy/DeployGoerli.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Test } from "forge-std/Test.sol";

import { AuthorshipToken } from "@/contracts/AuthorshipToken.sol";
import { Curta } from "@/contracts/Curta.sol";
import { DeployGoerli } from "@/script/deploy/DeployGoerli.s.sol";
import { DeployGoerli } from "@/script/deploy/v0.0.1/DeployGoerli.s.sol";

/// @notice Tests the Goerli deploy script.
contract DeployGoerliTest is Test {
Expand Down
2 changes: 1 addition & 1 deletion test/deploy/DeployMainnet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Test } from "forge-std/Test.sol";

import { AuthorshipToken } from "@/contracts/AuthorshipToken.sol";
import { Curta } from "@/contracts/Curta.sol";
import { DeployMainnet } from "@/script/deploy/DeployMainnet.s.sol";
import { DeployMainnet } from "@/script/deploy/v0.0.1/DeployMainnet.s.sol";

/// @notice Tests the mainnet deploy script.
contract DeployMainnetTest is Test {
Expand Down

0 comments on commit 1c60d7e

Please sign in to comment.