Skip to content

Commit

Permalink
compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
spengrah committed Jul 4, 2024
1 parent b6a68fd commit 14637a8
Show file tree
Hide file tree
Showing 10 changed files with 376 additions and 87 deletions.
10 changes: 9 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std

[submodule "lib/hats-protocol"]
path = lib/hats-protocol
url = https://github.com/hats-protocol/hats-protocol
[submodule "lib/farcaster-delegator"]
path = lib/farcaster-delegator
url = https://github.com/hats-protocol/farcaster-delegator
[submodule "lib/hats-module"]
path = lib/hats-module
url = https://github.com/hats-protocol/hats-module
6 changes: 5 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ optimizer_runs = 1_000_000
bytecode_hash = "none"
gas_reports = []
auto_detect_solc = false
solc = "0.8.19"
solc = "0.8.26"
remappings = [
"ds-test/=lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"hats-module/=lib/hats-module/src/",
"solady/=lib/hats-protocol/lib/solady/src",
"hats-protocol/=lib/hats-protocol/src",
"farcaster/=lib/farcaster-delegator/lib/farcaster/src",
]
# Enable tests to read ir-optimized bytecode precompiled by profile.optimized
fs_permissions = [{ access = "read", path = "./optimized-out" }]
Expand Down
1 change: 1 addition & 0 deletions lib/farcaster-delegator
Submodule farcaster-delegator added at 7fb94d
1 change: 1 addition & 0 deletions lib/hats-module
Submodule hats-module added at e83bd7
1 change: 1 addition & 0 deletions lib/hats-protocol
Submodule hats-protocol added at cccb71
41 changes: 10 additions & 31 deletions script/Counter.s.sol → script/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;
pragma solidity ^0.8.19;

import { Script, console2 } from "forge-std/Script.sol";
import { Counter } from "../src/Counter.sol";

interface ImmutableCreate2Factory {
function create2(bytes32 salt, bytes calldata initializationCode)
external
payable
returns (address deploymentAddress);
}
import { HatsFarcasterBundler, IHats } from "../src/HatsFarcasterBundler.sol";

contract Deploy is Script {
Counter public counter;
bytes32 public SALT = bytes32(abi.encode("lets add some salt to these eggs"));
HatsFarcasterBundler public bundler;
bytes32 public SALT = bytes32(abi.encode(0x4a57));

// default values
bool internal _verbose = true;
string internal _version = "0.1.0";
IHats internal _hats = IHats(0x3bc1A0Ad72417f2d411118085256fC53CBdDd137);
HatsFarcasterBundler.Hat[] internal _hatTreeTemplate;
HatsFarcasterBundler.FarcasterContracts internal _farcasterContracts;

/// @dev Override default values, if desired
function prepare(bool verbose) public {
Expand All @@ -31,7 +28,7 @@ contract Deploy is Script {

function _log(string memory prefix) internal view {
if (_verbose) {
console2.log(string.concat(prefix, "Counter:"), address(counter));
console2.log(string.concat(prefix, "HatsFarcasterBundler:"), address(bundler));
}
}

Expand All @@ -47,32 +44,14 @@ contract Deploy is Script {
* never differs regardless of where its being compiled
* 2. The provided salt, `SALT`
*/
counter = new Counter{ salt: SALT}(/* insert constructor args here */);
bundler = new HatsFarcasterBundler{ salt: SALT }(_version, _hats, _hatTreeTemplate, _farcasterContracts);

vm.stopBroadcast();

_log("");
}
}

/// @dev Deploy pre-compiled ir-optimized bytecode to a non-deterministic address
contract DeployPrecompiled is Deploy {
/// @dev Update SALT and default values in Deploy contract

function run() public override {
vm.startBroadcast(deployer());

bytes memory args = abi.encode( /* insert constructor args here */ );

/// @dev Load and deploy pre-compiled ir-optimized bytecode.
counter = Counter(deployCode("optimized-out/Counter.sol/Counter.json", args));

vm.stopBroadcast();

_log("Precompiled ");
}
}

/* FORGE CLI COMMANDS
## A. Simulate the deployment locally
Expand Down
43 changes: 0 additions & 43 deletions src/Counter.sol

This file was deleted.

Loading

0 comments on commit 14637a8

Please sign in to comment.