Skip to content

Commit

Permalink
Merge pull request #16 from mejango/touchup/return-hook
Browse files Browse the repository at this point in the history
deploy returns the hook address and adds to allowe dposts
  • Loading branch information
mejango authored Sep 19, 2024
2 parents 8525847 + 956ea3d commit 2c55fe8
Show file tree
Hide file tree
Showing 16 changed files with 2,134 additions and 510 deletions.
947 changes: 947 additions & 0 deletions deployments/compiler-inputs/c8660e6ab664b4186505e261472223cd.json

Large diffs are not rendered by default.

96 changes: 55 additions & 41 deletions deployments/croptop-core-testnet/arbitrum_sepolia/CTDeployer.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

188 changes: 41 additions & 147 deletions deployments/croptop-core-testnet/base_sepolia/CTDeployer.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

198 changes: 46 additions & 152 deletions deployments/croptop-core-testnet/optimism_sepolia/CTDeployer.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

202 changes: 48 additions & 154 deletions deployments/croptop-core-testnet/sepolia/CTDeployer.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/sphinx
Submodule sphinx updated 94 files
+4 −1 .circleci/config.yml
+7 −24 .github/workflows/docker-image.yml
+12 −20 README.md
+57 −0 docs/breaking/registration.md
+38 −31 docs/cli-existing-project.md
+19 −15 docs/cli-quickstart.md
+8 −107 ops/ci-builder/Dockerfile
+0 −8 ops/ci-builder/check-changed.sh
+1 −1 package.json
+45 −0 packages/contracts/CHANGELOG.md
+1 −0 packages/contracts/contract-artifacts/sphinx/PermissionlessRelay.sol/PermissionlessRelay.json
+764,220 −0 packages/contracts/contract-artifacts/sphinx/permissionless-relay-build-info.json
+61 −0 packages/contracts/contracts/core/PermissionlessRelay.sol
+10 −11 packages/contracts/contracts/foundry/Sphinx.sol
+62 −8 packages/contracts/contracts/foundry/SphinxConstants.sol
+34 −3 packages/contracts/contracts/foundry/SphinxPluginTypes.sol
+93 −93 packages/contracts/contracts/foundry/SphinxUtils.sol
+2 −7 packages/contracts/package.json
+3 −3 packages/contracts/scripts/write-constants.ts
+30 −0 packages/contracts/sphinx.lock
+151 −14 packages/contracts/src/addresses.ts
+7 −15 packages/contracts/src/contract-info.ts
+4 −3 packages/contracts/src/ifaces.ts
+334 −14 packages/contracts/src/networks.ts
+0 −22 packages/contracts/src/utils.ts
+1 −1 packages/contracts/src/version.ts
+1 −1 packages/contracts/test/ManagedService.t.sol
+9 −15 packages/contracts/test/ScriptConfiguration.t.sol
+7 −13 packages/contracts/test/Sphinx.t.sol
+3 −4 packages/contracts/test/SphinxInitCode.sol
+8 −7 packages/contracts/test/SphinxTestUtils.sol
+5 −4 packages/contracts/test/SphinxUtils.t.sol
+0 −21 packages/contracts/test/issues/CHU572.s.sol
+1 −4 packages/contracts/test/issues/CHU663.s.sol
+0 −23 packages/contracts/test/issues/CHU663/CHU663.s.sol
+38 −0 packages/contracts/test/mocha/address.spec.ts
+0 −35 packages/contracts/test/mocha/utils.spec.ts
+79 −0 packages/core/CHANGELOG.md
+0 −7 packages/core/config/local.ts
+0 −14 packages/core/config/standard.ts
+67 −44 packages/core/hardhat.config.ts
+3 −3 packages/core/package.json
+19 −18 packages/core/src/actions/execute.ts
+3 −9 packages/core/src/actions/types.ts
+6 −7 packages/core/src/artifacts.ts
+8 −5 packages/core/src/config/types.ts
+0 −4 packages/core/src/constants.ts
+11 −1 packages/core/src/etherscan.ts
+2 −174 packages/core/src/languages/solidity/predeploys.ts
+2 −1 packages/core/src/languages/solidity/types.ts
+25 −0 packages/core/src/networks.ts
+18 −0 packages/core/src/types.ts
+60 −96 packages/core/src/utils.ts
+17 −7 packages/core/test/convert.spec.ts
+22 −0 packages/demo/CHANGELOG.md
+5 −5 packages/demo/package.json
+18 −0 packages/demo/sphinx.lock
+2 −2 packages/demo/test/Solc.spec.ts
+22 −16 packages/demo/test/init.spec.ts
+95 −0 packages/plugins/CHANGELOG.md
+1 −5 packages/plugins/contracts/test/script/Cases.s.sol
+0 −4 packages/plugins/contracts/test/script/Empty.s.sol
+1 −5 packages/plugins/contracts/test/script/Large.s.sol
+1 −5 packages/plugins/contracts/test/script/PartiallyEmpty.s.sol
+1 −5 packages/plugins/contracts/test/script/RevertDuringSimulation.s.sol
+3 −15 packages/plugins/contracts/test/script/Simple.s.sol
+1 −4 packages/plugins/contracts/test/script/issues/CHU676.s.sol
+4 −0 packages/plugins/foundry.toml
+7 −7 packages/plugins/package.json
+3 −7 packages/plugins/script/Sample.s.sol
+12 −0 packages/plugins/script/write-version.ts
+18 −0 packages/plugins/sphinx.lock
+0 −4 packages/plugins/src/cli/context.ts
+0 −3 packages/plugins/src/cli/deploy.ts
+11 −20 packages/plugins/src/cli/propose/index.ts
+30 −5 packages/plugins/src/cli/setup.ts
+0 −8 packages/plugins/src/cli/types.ts
+1 −0 packages/plugins/src/cli/version.ts
+1 −4 packages/plugins/src/foundry/decode.ts
+37 −149 packages/plugins/src/foundry/utils/index.ts
+0 −48 packages/plugins/src/hardhat.config.js
+0 −71 packages/plugins/src/hardhat/hardhatRunner.ts
+0 −618 packages/plugins/src/hardhat/simulate.ts
+0 −1 packages/plugins/src/index.ts
+6 −8 packages/plugins/src/sample-project/index.ts
+4 −11 packages/plugins/src/sample-project/sample-contracts.ts
+2 −1 packages/plugins/src/sample-project/sample-foundry-config.ts
+5 −2 packages/plugins/test/mocha/artifacts.spec.ts
+2 −52 packages/plugins/test/mocha/cli/deploy.spec.ts
+12 −335 packages/plugins/test/mocha/cli/propose.spec.ts
+4 −135 packages/plugins/test/mocha/common.ts
+42 −152 packages/plugins/test/mocha/foundry/utils.spec.ts
+0 −11 packages/plugins/test/mocha/mock.ts
+0 −437 packages/plugins/test/mocha/simulate.spec.ts
48 changes: 44 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@croptop/core",
"version": "0.0.17",
"version": "0.0.18",
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -17,7 +17,7 @@
},
"dependencies": {
"@bananapus/core": "^0.0.32",
"@bananapus/721-hook": "^0.0.23",
"@bananapus/721-hook": "^0.0.24",
"@bananapus/permission-ids": "^0.0.12",
"@bananapus/ownable": "^0.0.7",
"@openzeppelin/contracts": "^5.0.2",
Expand Down
1 change: 0 additions & 1 deletion script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ contract DeployScript is Script, Sphinx {
// fee_project.
uint256 FEE_PROJECT_ID = 0;


/// @notice the salts that are used to deploy the contracts.
bytes32 PUBLISHER_SALT = "_PUBLISHER_SALT_";
bytes32 DEPLOYER_SALT = "_DEPLOYER_SALT_";
Expand Down
50 changes: 45 additions & 5 deletions src/CTDeployer.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import {IJB721TiersHook} from "@bananapus/721-hook/src/interfaces/IJB721TiersHook.sol";
import {IJB721TiersHookProjectDeployer} from "@bananapus/721-hook/src/interfaces/IJB721TiersHookProjectDeployer.sol";
import {IJB721TokenUriResolver} from "@bananapus/721-hook/src/interfaces/IJB721TokenUriResolver.sol";
import {JB721InitTiersConfig} from "@bananapus/721-hook/src/structs/JB721InitTiersConfig.sol";
Expand All @@ -18,6 +19,7 @@ import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Recei
import {ICTDeployer} from "./interfaces/ICTDeployer.sol";
import {ICTPublisher} from "./interfaces/ICTPublisher.sol";
import {CTAllowedPost} from "./structs/CTAllowedPost.sol";
import {CTDeployerAllowedPost} from "./structs/CTDeployerAllowedPost.sol";

/// @notice A contract that facilitates deploying a simple Juicebox project to receive posts from Croptop templates.
contract CTDeployer is IERC721Receiver, ICTDeployer {
Expand Down Expand Up @@ -85,24 +87,25 @@ contract CTDeployer is IERC721Receiver, ICTDeployer {
/// @param name The name of the collection where posts will go.
/// @param symbol The symbol of the collection where posts will go.
/// @return projectId The ID of the newly created project.
/// @return hook The hook that was created.
function deployProjectFor(
address owner,
JBTerminalConfig[] calldata terminalConfigurations,
JBTerminalConfig[] memory terminalConfigurations,
string memory projectUri,
CTAllowedPost[] calldata allowedPosts,
CTDeployerAllowedPost[] memory allowedPosts,
string memory contractUri,
string memory name,
string memory symbol
)
external
returns (uint256 projectId)
returns (uint256 projectId, IJB721TiersHook hook)
{
JBPayDataHookRulesetConfig[] memory rulesetConfigurations = new JBPayDataHookRulesetConfig[](1);
rulesetConfigurations[0].weight = 1_000_000 * (10 ** 18);
rulesetConfigurations[0].metadata.baseCurrency = uint32(uint160(JBConstants.NATIVE_TOKEN));

// Deploy a blank project.
projectId = DEPLOYER.launchProjectFor({
(projectId, hook) = DEPLOYER.launchProjectFor({
owner: address(this),
deployTiersHookConfig: JBDeploy721TiersHookConfig({
name: name,
Expand Down Expand Up @@ -134,9 +137,46 @@ contract CTDeployer is IERC721Receiver, ICTDeployer {
});

// Configure allowed posts.
if (allowedPosts.length > 0) PUBLISHER.configurePostingCriteriaFor(allowedPosts);
if (allowedPosts.length > 0) _configurePostingCriteriaFor(address(hook), allowedPosts);

//transfer to _owner.
CONTROLLER.PROJECTS().transferFrom(address(this), owner, projectId);
}

//*********************************************************************//
// --------------------- internal transactions ----------------------- //
//*********************************************************************//

/// @notice Configure croptop posting.
/// @param hook The hook that will be posted to.
/// @param allowedPosts The type of posts that should be allowed.
function _configurePostingCriteriaFor(address hook, CTDeployerAllowedPost[] memory allowedPosts) internal {
// Keep a reference to the number of allowed posts.
uint256 numberOfAllowedPosts = allowedPosts.length;

// Keep a reference to the formatted allowed posts.
CTAllowedPost[] memory formattedAllowedPosts = new CTAllowedPost[](numberOfAllowedPosts);

// Keep a reference to the post being iterated on.
CTDeployerAllowedPost memory post;

// Iterate through each post to add it to the formatted list.
for (uint256 i; i < numberOfAllowedPosts; i++) {
// Set the post being iterated on.
post = allowedPosts[i];

// Set the formatted post.
formattedAllowedPosts[i] = CTAllowedPost({
hook: hook,
category: post.category,
minimumPrice: post.minimumPrice,
minimumTotalSupply: post.minimumTotalSupply,
maximumTotalSupply: post.maximumTotalSupply,
allowedAddresses: post.allowedAddresses
});
}

// Set up the allowed posts in the publisher.
PUBLISHER.configurePostingCriteriaFor({allowedPosts: formattedAllowedPosts});
}
}
7 changes: 4 additions & 3 deletions src/interfaces/ICTDeployer.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IJB721TiersHook} from "@bananapus/721-hook/src/interfaces/IJB721TiersHook.sol";
import {IJB721TiersHookProjectDeployer} from "@bananapus/721-hook/src/interfaces/IJB721TiersHookProjectDeployer.sol";
import {IJBController} from "@bananapus/core/src/interfaces/IJBController.sol";
import {JBTerminalConfig} from "@bananapus/core/src/structs/JBTerminalConfig.sol";

import {ICTPublisher} from "./ICTPublisher.sol";
import {CTAllowedPost} from "../structs/CTAllowedPost.sol";
import {CTDeployerAllowedPost} from "../structs/CTDeployerAllowedPost.sol";

interface ICTDeployer {
function CONTROLLER() external view returns (IJBController);
Expand All @@ -17,11 +18,11 @@ interface ICTDeployer {
address owner,
JBTerminalConfig[] calldata terminalConfigurations,
string memory projectUri,
CTAllowedPost[] calldata allowedPosts,
CTDeployerAllowedPost[] calldata allowedPosts,
string memory contractUri,
string memory name,
string memory symbol
)
external
returns (uint256 projectId);
returns (uint256 projectId, IJB721TiersHook hook);
}
17 changes: 17 additions & 0 deletions src/structs/CTDeployerAllowedPost.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @notice Criteria for allowed posts.
/// @custom:member category A category that should allow posts.
/// @custom:member minimumPrice The minimum price that a post to the specified category should cost.
/// @custom:member minimumTotalSupply The minimum total supply of NFTs that can be made available when minting.
/// @custom:member maxTotalSupply The max total supply of NFTs that can be made available when minting. Leave as 0 for
/// max.
/// @custom:member allowedAddresses A list of addresses that are allowed to post on the category through Croptop.
struct CTDeployerAllowedPost {
uint24 category;
uint104 minimumPrice;
uint32 minimumTotalSupply;
uint32 maximumTotalSupply;
address[] allowedAddresses;
}

0 comments on commit 2c55fe8

Please sign in to comment.