diff --git a/script/Base.s.sol b/script/Base.s.sol deleted file mode 100644 index fa871c79..00000000 --- a/script/Base.s.sol +++ /dev/null @@ -1,91 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -// solhint-disable no-console -pragma solidity >=0.8.22 <0.9.0; - -import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; -import { Sphinx } from "@sphinx-labs/contracts/SphinxPlugin.sol"; - -import { console2 } from "forge-std/src/console2.sol"; -import { Script } from "forge-std/src/Script.sol"; - -contract BaseScript is Script, Sphinx { - using Strings for uint256; - - /// @dev Included to enable compilation of the script without a $MNEMONIC environment variable. - string internal constant TEST_MNEMONIC = "test test test test test test test test test test test junk"; - - /// @dev The default project name for the Sphinx plugin. - string internal constant SPHINX_PROJECT_NAME = "test-test"; - - /// @dev Needed for the deterministic deployments. - bytes32 internal constant ZERO_SALT = bytes32(0); - - /// @dev The address of the transaction broadcaster. - address internal broadcaster; - - /// @dev Used to derive the broadcaster's address if $EOA is not defined. - string internal mnemonic; - - /// @dev The project name for the Sphinx plugin. - string internal sphinxProjectName; - - /// @dev Initializes the transaction broadcaster like this: - /// - /// - If $EOA is defined, use it. - /// - Otherwise, derive the broadcaster address from $MNEMONIC. - /// - If $MNEMONIC is not defined, default to a test mnemonic. - /// - If $SPHINX_PROJECT_NAME is not defined, default to a test project name. - /// - /// The use case for $EOA is to specify the broadcaster key and its address via the command line. - constructor() { - address from = vm.envOr({ name: "EOA", defaultValue: address(0) }); - if (from != address(0)) { - broadcaster = from; - } else { - mnemonic = vm.envOr({ name: "MNEMONIC", defaultValue: TEST_MNEMONIC }); - (broadcaster,) = deriveRememberKey({ mnemonic: mnemonic, index: 0 }); - } - sphinxProjectName = vm.envOr({ name: "SPHINX_PROJECT_NAME", defaultValue: SPHINX_PROJECT_NAME }); - } - - modifier broadcast() { - vm.startBroadcast(broadcaster); - _; - vm.stopBroadcast(); - } - - /// @dev Configures the Sphinx plugin to use Sphinx managed deployment for smart contracts. - /// Refer to https://github.com/sphinx-labs/sphinx/tree/main/docs. - /// CLI example: - /// - bun sphinx propose script/DeployBatch.s.sol --networks testnets --sig "runSphinx()" - function configureSphinx() public override { - sphinxConfig.mainnets = ["arbitrum", "avalanche", "base", "bnb", "gnosis", "ethereum", "optimism", "polygon"]; - sphinxConfig.orgId = vm.envOr({ name: "SPHINX_ORG_ID", defaultValue: TEST_MNEMONIC }); - sphinxConfig.owners = [broadcaster]; - sphinxConfig.projectName = sphinxProjectName; - sphinxConfig.testnets = ["sepolia"]; - sphinxConfig.threshold = 1; - } - - /// @dev The presence of the salt instructs Forge to deploy contracts via this deterministic CREATE2 factory: - /// https://github.com/Arachnid/deterministic-deployment-proxy - /// - /// Notes: - /// - The salt format is "ChainID , Version ". - /// - The version is obtained from `package.json` using the `ffi` cheatcode: - /// https://book.getfoundry.sh/cheatcodes/ffi - /// - Requires `jq` CLI tool installed: https://jqlang.github.io/jq/ - function constructCreate2Salt() public returns (bytes32) { - string memory chainId = block.chainid.toString(); - string[] memory inputs = new string[](4); - inputs[0] = "jq"; - inputs[1] = "-r"; - inputs[2] = ".version"; - inputs[3] = "./package.json"; - bytes memory result = vm.ffi(inputs); - string memory version = string(result); - string memory create2Salt = string.concat("ChainID ", chainId, ", Version ", version); - console2.log("The CREATE2 salt is \"%s\"", create2Salt); - return bytes32(abi.encodePacked(create2Salt)); - } -} diff --git a/script/CreateMerkleLockupLL.s.sol b/script/CreateMerkleLockupLL.s.sol index 2a8a4bf8..20d6b9b5 100644 --- a/script/CreateMerkleLockupLL.s.sol +++ b/script/CreateMerkleLockupLL.s.sol @@ -1,11 +1,10 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22 <0.9.0; +import { BaseScript } from "@sablier/v2-core/script/Base.s.sol"; import { ISablierV2LockupLinear } from "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol"; import { LockupLinear } from "@sablier/v2-core/src/types/DataTypes.sol"; -import { BaseScript } from "./Base.s.sol"; - import { ISablierV2MerkleLockupFactory } from "../src/interfaces/ISablierV2MerkleLockupFactory.sol"; import { ISablierV2MerkleLockupLL } from "../src/interfaces/ISablierV2MerkleLockupLL.sol"; import { MerkleLockup } from "../src/types/DataTypes.sol"; diff --git a/script/CreateMerkleLockupLT.s.sol b/script/CreateMerkleLockupLT.s.sol index 4e028621..6bc7b0ec 100644 --- a/script/CreateMerkleLockupLT.s.sol +++ b/script/CreateMerkleLockupLT.s.sol @@ -1,10 +1,9 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22 <0.9.0; +import { BaseScript } from "@sablier/v2-core/script/Base.s.sol"; import { ISablierV2LockupTranched } from "@sablier/v2-core/src/interfaces/ISablierV2LockupTranched.sol"; -import { BaseScript } from "./Base.s.sol"; - import { ISablierV2MerkleLockupFactory } from "../src/interfaces/ISablierV2MerkleLockupFactory.sol"; import { ISablierV2MerkleLockupLT } from "../src/interfaces/ISablierV2MerkleLockupLT.sol"; import { MerkleLockup, MerkleLockupLT } from "../src/types/DataTypes.sol"; diff --git a/script/DeployBatch.t.sol b/script/DeployBatch.t.sol index 0a32ebc5..8c4aa416 100644 --- a/script/DeployBatch.t.sol +++ b/script/DeployBatch.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22 <0.9.0; -import { BaseScript } from "./Base.s.sol"; +import { BaseScript } from "@sablier/v2-core/script/Base.s.sol"; import { SablierV2Batch } from "../src/SablierV2Batch.sol"; diff --git a/script/DeployDeterministicBatch.s.sol b/script/DeployDeterministicBatch.s.sol index 632ca4de..b4311501 100644 --- a/script/DeployDeterministicBatch.s.sol +++ b/script/DeployDeterministicBatch.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22 <0.9.0; -import { BaseScript } from "./Base.s.sol"; +import { BaseScript } from "@sablier/v2-core/script/Base.s.sol"; import { SablierV2Batch } from "../src/SablierV2Batch.sol"; diff --git a/script/DeployDeterministicPeriphery.s.sol b/script/DeployDeterministicPeriphery.s.sol index 70b17bb1..44679000 100644 --- a/script/DeployDeterministicPeriphery.s.sol +++ b/script/DeployDeterministicPeriphery.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22 <0.9.0; -import { BaseScript } from "./Base.s.sol"; +import { BaseScript } from "@sablier/v2-core/script/Base.s.sol"; import { SablierV2Batch } from "../src/SablierV2Batch.sol"; import { SablierV2MerkleLockupFactory } from "../src/SablierV2MerkleLockupFactory.sol"; diff --git a/script/DeployMerkleLockupFactory.s.sol b/script/DeployMerkleLockupFactory.s.sol index d0a90429..ae9690c2 100644 --- a/script/DeployMerkleLockupFactory.s.sol +++ b/script/DeployMerkleLockupFactory.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22 <0.9.0; -import { BaseScript } from "./Base.s.sol"; +import { BaseScript } from "@sablier/v2-core/script/Base.s.sol"; import { SablierV2MerkleLockupFactory } from "../src/SablierV2MerkleLockupFactory.sol"; diff --git a/script/DeployPeriphery.s.sol b/script/DeployPeriphery.s.sol index a8576c1d..2ffe87f1 100644 --- a/script/DeployPeriphery.s.sol +++ b/script/DeployPeriphery.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22 <0.9.0; -import { BaseScript } from "./Base.s.sol"; +import { BaseScript } from "@sablier/v2-core/script/Base.s.sol"; import { SablierV2MerkleLockupFactory } from "../src/SablierV2MerkleLockupFactory.sol"; import { SablierV2Batch } from "../src/SablierV2Batch.sol"; diff --git a/script/DeployProtocol.s.sol b/script/DeployProtocol.s.sol index 27df1d40..48ac21fc 100644 --- a/script/DeployProtocol.s.sol +++ b/script/DeployProtocol.s.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22 <0.9.0; +import { BaseScript } from "@sablier/v2-core/script/Base.s.sol"; import { SablierV2LockupDynamic } from "@sablier/v2-core/src/SablierV2LockupDynamic.sol"; import { SablierV2LockupLinear } from "@sablier/v2-core/src/SablierV2LockupLinear.sol"; import { SablierV2LockupTranched } from "@sablier/v2-core/src/SablierV2LockupTranched.sol"; import { SablierV2NFTDescriptor } from "@sablier/v2-core/src/SablierV2NFTDescriptor.sol"; -import { BaseScript } from "./Base.s.sol"; import { SablierV2MerkleLockupFactory } from "../src/SablierV2MerkleLockupFactory.sol"; import { SablierV2Batch } from "../src/SablierV2Batch.sol"; diff --git a/test/utils/BaseScript.t.sol b/test/utils/BaseScript.t.sol deleted file mode 100644 index f445f21d..00000000 --- a/test/utils/BaseScript.t.sol +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -pragma solidity >=0.8.22 <0.9.0; - -import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; -import { StdAssertions } from "forge-std/src/StdAssertions.sol"; - -import { BaseScript } from "script/Base.s.sol"; - -contract BaseScript_Test is StdAssertions { - using Strings for uint256; - - BaseScript internal baseScript = new BaseScript(); - - function test_ConstructCreate2Salt() public { - string memory chainId = block.chainid.toString(); - string memory version = "1.1.1"; - string memory salt = string.concat("ChainID ", chainId, ", Version ", version); - - bytes32 actualSalt = baseScript.constructCreate2Salt(); - bytes32 expectedSalt = bytes32(abi.encodePacked(salt)); - assertEq(actualSalt, expectedSalt, "CREATE2 salt mismatch"); - } -}