Skip to content

Commit

Permalink
Merge branch 'main' of github.com:waterfall-mkt/curta into sabnock/fl…
Browse files Browse the repository at this point in the history
…ag-renderer-updates
  • Loading branch information
Sabnock01 committed Nov 6, 2023
2 parents 6eee64f + 4117817 commit 3f29bbf
Show file tree
Hide file tree
Showing 12 changed files with 250 additions and 76 deletions.
18 changes: 12 additions & 6 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,18 @@ CurtaTest:test_transferFrom_Unauthorized_RevertsUnauthorized() (gas: 412838)
CurtaTest:test_transferFrom_WithApprovalForAllTrue_AllowsTransfer() (gas: 460343)
CurtaTest:test_transferFrom_WithTokenApproval_AllowsTransfer() (gas: 440767)
CurtaTest:test_transferFrom_WrongFrom_Fails() (gas: 407858)
DeployConstellationTest:test_AddressInitializationCorrectness() (gas: 23494)
DeployConstellationTest:test_authorshipTokenAuthorsEquality() (gas: 20777)
DeployConstellationTest:test_authorshipTokenIssueLengthEquality() (gas: 11460)
DeployConstellationTest:test_authorshipTokenMinting() (gas: 91601)
DeployConstellationTest:test_authorshipTokenOwnerEquality() (gas: 13799)
DeployConstellationTest:test_curtaOwnerEquality() (gas: 13832)
DeployBaseGoerliTest:test_AddressInitializationCorrectness() (gas: 23494)
DeployBaseGoerliTest:test_authorshipTokenAuthorsEquality() (gas: 13651)
DeployBaseGoerliTest:test_authorshipTokenIssueLengthEquality() (gas: 11460)
DeployBaseGoerliTest:test_authorshipTokenMinting() (gas: 108701)
DeployBaseGoerliTest:test_authorshipTokenOwnerEquality() (gas: 13799)
DeployBaseGoerliTest:test_curtaOwnerEquality() (gas: 13832)
DeployBaseMainnetTest:test_AddressInitializationCorrectness() (gas: 23494)
DeployBaseMainnetTest:test_authorshipTokenAuthorsEquality() (gas: 27900)
DeployBaseMainnetTest:test_authorshipTokenIssueLengthEquality() (gas: 11460)
DeployBaseMainnetTest:test_authorshipTokenMinting() (gas: 91601)
DeployBaseMainnetTest:test_authorshipTokenOwnerEquality() (gas: 13799)
DeployBaseMainnetTest:test_curtaOwnerEquality() (gas: 13832)
DeployGoerliTest:test_AddressInitializationCorrectness() (gas: 23494)
DeployGoerliTest:test_authorshipTokenAuthorsEquality() (gas: 13651)
DeployGoerliTest:test_authorshipTokenIssueLengthEquality() (gas: 11460)
Expand Down
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Since puzzles are on-chain, everyone can view everyone else's submissions. The g
<table>

## Usage
This project uses [**Foundry**](https://github.com/foundry-rs/foundry) as its development/testing framework and a [**Constellation**](https://constellation.so/) roll-up for testing.
This project uses [**Foundry**](https://github.com/foundry-rs/foundry) as its development/testing framework.

### Installation

Expand Down Expand Up @@ -158,11 +158,6 @@ If you are deploying to a public chain, replace `DeployMainnet` and `mainnet` wi
forge script script/deploy/DeployMainnet.s.sol:DeployMainnet -f mainnet --broadcast --verify
```

If you are deploying to the Constellation roll-up, remove `--verify` and add `--legacy`:
```sh
forge script script/deploy/DeployConstellation.s.sol:DeployConstellation -f constellation --broadcast --legacy --sender $SENDER_ADDRESS
```

## Acknowledgements
* [**Solmate**](https://github.com/transmissions11/solmate)
* [**Art Gobblers**](https://github.com/artgobblers/art-gobblers)
Expand Down
11 changes: 11 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ libs = ['lib']
solc = "0.8.17"
optimizer_runs = 875
bytecode_hash = "none"
remappings = [
"colormap-registry/=lib/colormap-registry/src/",
"forge-std/=lib/forge-std/src/",
"solady/=lib/solady/src/",
"shields-api/=lib/shields-api-contract/contracts/",
"solmate/=lib/solmate/src/",
"@/script/=script/",
"@/contracts/=src/",
"@/test/=test/"
]
no-match-path = "test/deploy/deprecated/*"

[fmt]
line_length = 100
Expand Down
8 changes: 0 additions & 8 deletions remappings.txt

This file was deleted.

5 changes: 2 additions & 3 deletions script/deploy/DeployBase.s.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { Script } from "forge-std/Script.sol";
import { console } from "forge-std/Test.sol";
import { Script, console } from "forge-std/Script.sol";

import { AuthorshipToken } from "@/contracts/AuthorshipToken.sol";
import { Curta } from "@/contracts/Curta.sol";
Expand All @@ -16,7 +15,7 @@ import { LibRLP } from "@/contracts/utils/LibRLP.sol";
/// @dev The script requires 3 private keys: `DEPLOYER_PRIVATE_KEY`,
/// `AUTHORSHIP_TOKEN_PRIVATE_KEY` and `CURTA_PRIVATE_KEY`, which are all read
/// as environment variables via `vm.envUint`. The account specified by
/// `DEPLOYER_PRIVATE_KEY` will fund the other 2 accounts 0.25 ETH each for gas.
/// `DEPLOYER_PRIVATE_KEY` will fund the other 2 accounts 0.4 ETH each for gas.
/// Note that if accounts specified by `AUTHORSHIP_TOKEN_PRIVATE_KEY` or
/// `CURTA_PRIVATE_KEY` have a nonzero account nonce or are equal, the script
/// will most likely fail due to incorrect contract address precomputation
Expand Down
22 changes: 22 additions & 0 deletions script/deploy/DeployBaseGoerli.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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 = 0xDbAacdcadD7c51a325B771ff75B261a1e7baE11c;

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

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

/// @notice The list of authors in the initial batch.
address[] internal AUTHORS = new address[](0);

constructor() DeployBase(AUTHORSHIP_TOKEN_OWNER, CURTA_OWNER, ISSUE_LENGTH, AUTHORS) { }
}
27 changes: 27 additions & 0 deletions script/deploy/DeployBaseMainnet.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

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

contract DeployBaseMainnet 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 The list of authors in the initial batch.
address[] internal AUTHORS = [
// fiveoutofnine.eth
0xA85572Cd96f1643458f17340b6f0D6549Af482F5,
// sabnock.eth
0xDbAacdcadD7c51a325B771ff75B261a1e7baE11c
];

constructor() DeployBase(AUTHORSHIP_TOKEN_OWNER, CURTA_OWNER, ISSUE_LENGTH, AUTHORS) { }
}
51 changes: 0 additions & 51 deletions script/deploy/DeployTest.s.sol

This file was deleted.

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 "../DeployBase.s.sol";

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

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";

/// @notice Tests the Base Goerli deploy script.
contract DeployBaseGoerliTest is Test {
// -------------------------------------------------------------------------
// Contracts
// -------------------------------------------------------------------------

/// @notice The Base Goerli deploy script.
DeployBaseGoerli internal deployBaseGoerli;

// -------------------------------------------------------------------------
// Setup
// -------------------------------------------------------------------------

function setUp() public {
vm.deal(vm.addr(vm.envUint("DEPLOYER_PRIVATE_KEY")), type(uint64).max);

deployBaseGoerli = new DeployBaseGoerli();
deployBaseGoerli.run();
}

// -------------------------------------------------------------------------
// Tests
// -------------------------------------------------------------------------

/// @notice Test that the addresses were set correctly in each contract's
/// deploy.
function test_AddressInitializationCorrectness() public {
assertEq(address(deployBaseGoerli.curta().flagRenderer()), address(deployBaseGoerli.flagRenderer()));
assertEq(
address(deployBaseGoerli.curta().authorshipToken()), address(deployBaseGoerli.authorshipToken())
);
assertEq(deployBaseGoerli.authorshipToken().curta(), address(deployBaseGoerli.curta()));
}

/// @notice Test that the Authorship Token's issue length was set correctly.
function test_authorshipTokenIssueLengthEquality() public {
assertEq(deployBaseGoerli.authorshipToken().issueLength(), deployBaseGoerli.issueLength());
}

/// @notice Test that the Authorship Token's authors were set.
function test_authorshipTokenAuthorsEquality() public {
uint256 totalSupply = deployBaseGoerli.authorshipToken().totalSupply();
assertEq(totalSupply, deployBaseGoerli.authorsLength());

unchecked {
for (uint256 i; i < totalSupply; ++i) {
assertEq(deployBaseGoerli.authorshipToken().ownerOf(i + 1), deployBaseGoerli.authors(i));
}
}
}

/// @notice Test that an Authorship Token can be minted after deploy.
function test_authorshipTokenMinting() public {
AuthorshipToken authorshipToken = deployBaseGoerli.authorshipToken();

// Warp 1 `issueLength` period forward in time to ensure the owner can
// mint 1.
vm.warp(block.timestamp + authorshipToken.issueLength() + 1);

// Mint as owner.
vm.prank(authorshipToken.owner());
authorshipToken.ownerMint(address(this));
}

/// @notice Test that the Authorship Token's ownership was transferred
/// correctly.
function test_authorshipTokenOwnerEquality() public {
assertEq(deployBaseGoerli.authorshipToken().owner(), deployBaseGoerli.authorshipTokenOwner());
}

/// @notice Test that Curta's ownership was transferred correctly.
function test_curtaOwnerEquality() public {
assertEq(deployBaseGoerli.curta().owner(), deployBaseGoerli.curtaOwner());
}

}

87 changes: 87 additions & 0 deletions test/deploy/DeployBaseMainnet.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

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";

/// @notice Tests the Base mainnet deploy script.
contract DeployBaseMainnetTest is Test {
// -------------------------------------------------------------------------
// Contracts
// -------------------------------------------------------------------------

/// @notice The Base mainnet deploy script.
DeployBaseMainnet internal deployBaseMainnet;

// -------------------------------------------------------------------------
// Setup
// -------------------------------------------------------------------------

function setUp() public {
vm.deal(vm.addr(vm.envUint("DEPLOYER_PRIVATE_KEY")), type(uint64).max);

deployBaseMainnet = new DeployBaseMainnet();
deployBaseMainnet.run();
}

// -------------------------------------------------------------------------
// Tests
// -------------------------------------------------------------------------

/// @notice Test that the addresses were set correctly in each contract's
/// deploy.
function test_AddressInitializationCorrectness() public {
assertEq(
address(deployBaseMainnet.curta().flagRenderer()), address(deployBaseMainnet.flagRenderer())
);
assertEq(
address(deployBaseMainnet.curta().authorshipToken()),
address(deployBaseMainnet.authorshipToken())
);
assertEq(deployBaseMainnet.authorshipToken().curta(), address(deployBaseMainnet.curta()));
}

/// @notice Test that the Authorship Token's issue length was set correctly.
function test_authorshipTokenIssueLengthEquality() public {
assertEq(deployBaseMainnet.authorshipToken().issueLength(), deployBaseMainnet.issueLength());
}

/// @notice Test that the Authorship Token's authors were set.
function test_authorshipTokenAuthorsEquality() public {
uint256 totalSupply = deployBaseMainnet.authorshipToken().totalSupply();
assertEq(totalSupply, deployBaseMainnet.authorsLength());

unchecked {
for (uint256 i; i < totalSupply; ++i) {
assertEq(deployBaseMainnet.authorshipToken().ownerOf(i + 1), deployBaseMainnet.authors(i));
}
}
}

/// @notice Test that an Authorship Token can be minted after deploy.
function test_authorshipTokenMinting() public {
AuthorshipToken authorshipToken = deployBaseMainnet.authorshipToken();

// Warp 1 `issueLength` period forward in time to ensure the owner can
// mint 1.
vm.warp(block.timestamp + authorshipToken.issueLength() + 1);

// Mint as owner.
vm.prank(authorshipToken.owner());
authorshipToken.ownerMint(address(this));
}

/// @notice Test that the Authorship Token's ownership was transferred
/// correctly.
function test_authorshipTokenOwnerEquality() public {
assertEq(deployBaseMainnet.authorshipToken().owner(), deployBaseMainnet.authorshipTokenOwner());
}

/// @notice Test that Curta's ownership was transferred correctly.
function test_curtaOwnerEquality() public {
assertEq(deployBaseMainnet.curta().owner(), deployBaseMainnet.curtaOwner());
}
}
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 { DeployConstellation } from "@/script/deploy/DeployConstellation.s.sol";
import { DeployConstellation } from "@/script/deploy/deprecated/DeployConstellation.s.sol";

/// @notice Tests the Constellation chain deploy script.
contract DeployConstellationTest is Test {
Expand Down

0 comments on commit 3f29bbf

Please sign in to comment.