Skip to content

Commit

Permalink
feat: declare maxCount in BaseScript (#825)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreivladbrg authored Feb 17, 2024
1 parent d13598e commit 65d8513
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 38 deletions.
14 changes: 14 additions & 0 deletions script/Base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { Script } from "forge-std/src/Script.sol";
contract BaseScript is Script {
using Strings for uint256;

/// @dev The Avalanche chain ID.
uint256 internal constant AVALANCHE_CHAIN_ID = 43_114;

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

Expand All @@ -19,6 +22,10 @@ contract BaseScript is Script {
/// @dev The address of the transaction broadcaster.
address internal broadcaster;

/// @dev The upper limit on the length of data structures to ensure that transactions stay within the
/// block gas limit.
uint256 internal maxCount;

/// @dev Used to derive the broadcaster's address if $ETH_FROM is not defined.
string internal mnemonic;

Expand All @@ -37,6 +44,13 @@ contract BaseScript is Script {
mnemonic = vm.envOr({ name: "MNEMONIC", defaultValue: TEST_MNEMONIC });
(broadcaster,) = deriveRememberKey({ mnemonic: mnemonic, index: 0 });
}

// Sets `maxCount` to 300 for Avalanche, and 500 for all other chains.
if (block.chainid == AVALANCHE_CHAIN_ID) {
maxCount = 300;
} else {
maxCount = 500;
}
}

modifier broadcast() {
Expand Down
7 changes: 2 additions & 5 deletions script/DeployCore.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ import { BaseScript } from "./Base.s.sol";
/// 3. {SablierV2LockupDynamic}
/// 4. {SablierV2LockupLinear}
contract DeployCore is BaseScript {
function run(
address initialAdmin,
uint256 maxSegmentCount
)
function run(address initialAdmin)
public
virtual
broadcast
Expand All @@ -31,7 +28,7 @@ contract DeployCore is BaseScript {
{
comptroller = new SablierV2Comptroller(initialAdmin);
nftDescriptor = new SablierV2NFTDescriptor();
lockupDynamic = new SablierV2LockupDynamic(initialAdmin, comptroller, nftDescriptor, maxSegmentCount);
lockupDynamic = new SablierV2LockupDynamic(initialAdmin, comptroller, nftDescriptor, maxCount);
lockupLinear = new SablierV2LockupLinear(initialAdmin, comptroller, nftDescriptor);
}
}
5 changes: 2 additions & 3 deletions script/DeployCore2.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import { BaseScript } from "./Base.s.sol";
contract DeployCore2 is BaseScript {
function run(
address initialAdmin,
ISablierV2NFTDescriptor nftDescriptor,
uint256 maxSegmentCount
ISablierV2NFTDescriptor nftDescriptor
)
public
virtual
Expand All @@ -29,7 +28,7 @@ contract DeployCore2 is BaseScript {
)
{
comptroller = new SablierV2Comptroller(initialAdmin);
lockupDynamic = new SablierV2LockupDynamic(initialAdmin, comptroller, nftDescriptor, maxSegmentCount);
lockupDynamic = new SablierV2LockupDynamic(initialAdmin, comptroller, nftDescriptor, maxCount);
lockupLinear = new SablierV2LockupLinear(initialAdmin, comptroller, nftDescriptor);
}
}
5 changes: 2 additions & 3 deletions script/DeployCore3.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import { BaseScript } from "./Base.s.sol";
contract DeployCore3 is BaseScript {
function run(
address initialAdmin,
ISablierV2Comptroller comptroller,
uint256 maxSegmentCount
ISablierV2Comptroller comptroller
)
public
virtual
Expand All @@ -29,7 +28,7 @@ contract DeployCore3 is BaseScript {
)
{
nftDescriptor = new SablierV2NFTDescriptor();
lockupDynamic = new SablierV2LockupDynamic(initialAdmin, comptroller, nftDescriptor, maxSegmentCount);
lockupDynamic = new SablierV2LockupDynamic(initialAdmin, comptroller, nftDescriptor, maxCount);
lockupLinear = new SablierV2LockupLinear(initialAdmin, comptroller, nftDescriptor);
}
}
8 changes: 2 additions & 6 deletions script/DeployDeterministicCore.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ import { BaseScript } from "./Base.s.sol";
///
/// @dev Reverts if any contract has already been deployed.
contract DeployDeterministicCore is BaseScript {
function run(
address initialAdmin,
uint256 maxSegmentCount
)
function run(address initialAdmin)
public
virtual
broadcast
Expand All @@ -34,8 +31,7 @@ contract DeployDeterministicCore is BaseScript {
bytes32 salt = constructCreate2Salt();
comptroller = new SablierV2Comptroller{ salt: salt }(initialAdmin);
nftDescriptor = new SablierV2NFTDescriptor{ salt: salt }();
lockupDynamic =
new SablierV2LockupDynamic{ salt: salt }(initialAdmin, comptroller, nftDescriptor, maxSegmentCount);
lockupDynamic = new SablierV2LockupDynamic{ salt: salt }(initialAdmin, comptroller, nftDescriptor, maxCount);
lockupLinear = new SablierV2LockupLinear{ salt: salt }(initialAdmin, comptroller, nftDescriptor);
}
}
6 changes: 2 additions & 4 deletions script/DeployDeterministicCore2.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import { BaseScript } from "./Base.s.sol";
contract DeployDeterministicCore2 is BaseScript {
function run(
address initialAdmin,
ISablierV2NFTDescriptor nftDescriptor,
uint256 maxSegmentCount
ISablierV2NFTDescriptor nftDescriptor
)
public
virtual
Expand All @@ -32,8 +31,7 @@ contract DeployDeterministicCore2 is BaseScript {
{
bytes32 salt = constructCreate2Salt();
comptroller = new SablierV2Comptroller{ salt: salt }(initialAdmin);
lockupDynamic =
new SablierV2LockupDynamic{ salt: salt }(initialAdmin, comptroller, nftDescriptor, maxSegmentCount);
lockupDynamic = new SablierV2LockupDynamic{ salt: salt }(initialAdmin, comptroller, nftDescriptor, maxCount);
lockupLinear = new SablierV2LockupLinear{ salt: salt }(initialAdmin, comptroller, nftDescriptor);
}
}
6 changes: 2 additions & 4 deletions script/DeployDeterministicCore3.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import { BaseScript } from "./Base.s.sol";
contract DeployDeterministicCore3 is BaseScript {
function run(
address initialAdmin,
ISablierV2Comptroller comptroller,
uint256 maxSegmentCount
ISablierV2Comptroller comptroller
)
public
virtual
Expand All @@ -32,8 +31,7 @@ contract DeployDeterministicCore3 is BaseScript {
{
bytes32 salt = constructCreate2Salt();
nftDescriptor = new SablierV2NFTDescriptor{ salt: salt }();
lockupDynamic =
new SablierV2LockupDynamic{ salt: salt }(initialAdmin, comptroller, nftDescriptor, maxSegmentCount);
lockupDynamic = new SablierV2LockupDynamic{ salt: salt }(initialAdmin, comptroller, nftDescriptor, maxCount);
lockupLinear = new SablierV2LockupLinear{ salt: salt }(initialAdmin, comptroller, nftDescriptor);
}
}
8 changes: 3 additions & 5 deletions script/DeployDeterministicLockupDynamic.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ contract DeployDeterministicLockupDynamic is BaseScript {
function run(
address initialAdmin,
ISablierV2Comptroller initialComptroller,
ISablierV2NFTDescriptor initialNFTDescriptor,
uint256 maxSegmentCount
ISablierV2NFTDescriptor initialNFTDescriptor
)
public
virtual
broadcast
returns (SablierV2LockupDynamic lockupDynamic)
{
bytes32 salt = constructCreate2Salt();
lockupDynamic = new SablierV2LockupDynamic{ salt: salt }(
initialAdmin, initialComptroller, initialNFTDescriptor, maxSegmentCount
);
lockupDynamic =
new SablierV2LockupDynamic{ salt: salt }(initialAdmin, initialComptroller, initialNFTDescriptor, maxCount);
}
}
6 changes: 2 additions & 4 deletions script/DeployLockupDynamic.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ contract DeployLockupDynamic is BaseScript {
function run(
address initialAdmin,
ISablierV2Comptroller initialComptroller,
ISablierV2NFTDescriptor initialNFTDescriptor,
uint256 maxSegmentCount
ISablierV2NFTDescriptor initialNFTDescriptor
)
public
virtual
broadcast
returns (SablierV2LockupDynamic lockupDynamic)
{
lockupDynamic =
new SablierV2LockupDynamic(initialAdmin, initialComptroller, initialNFTDescriptor, maxSegmentCount);
lockupDynamic = new SablierV2LockupDynamic(initialAdmin, initialComptroller, initialNFTDescriptor, maxCount);
}
}
4 changes: 0 additions & 4 deletions shell/deploy-multi-chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ function initialize_interactive {
echo -e "2. Enter Etherscan API key: \c"
read api_key

echo -e "3. Enter max segment count: \c"
read MAX_SEGMENT_COUNT

# Comptroller only
chains["arbitrum"]="$ARBITRUM_COMPTROLLER"
chains["arbitrum_sepolia"]="$ARBITRUM_SEPOLIA_COMPTROLLER"
Expand Down Expand Up @@ -355,7 +352,6 @@ for chain in "${provided_chains[@]}"; do

deployment_command+=("${admin}")
deployment_command+=("${comptroller}")
deployment_command+=("${MAX_SEGMENT_COUNT}")
deployment_command+=("-vvv")

# Append additional options if gas price is enabled
Expand Down

0 comments on commit 65d8513

Please sign in to comment.