Skip to content

Commit 5f57916

Browse files
authored
ci: fix stack too deep trouble
1 parent 2c5ef5f commit 5f57916

1 file changed

Lines changed: 29 additions & 61 deletions

File tree

contracts/script/DeployWaveSendFund.s.sol

Lines changed: 29 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -8,74 +8,40 @@ import {WaveSendFund} from "../src/WaveSendFund.sol";
88
/**
99
* @title DeployWaveSendFund
1010
* @notice Foundry deployment script for WaveSendFund on Celo Mainnet.
11-
*
12-
* Usage (dry-run):
13-
* forge script script/DeployWaveSendFund.s.sol \
14-
* --rpc-url $CELO_RPC_URL \
15-
* --sig "run()" \
16-
* -vvvv
17-
*
18-
* Usage (broadcast):
19-
* forge script script/DeployWaveSendFund.s.sol \
20-
* --rpc-url $CELO_RPC_URL \
21-
* --broadcast \
22-
* --verify \
23-
* --etherscan-api-key $CELOSCAN_API_KEY \
24-
* -vvvv
25-
*
26-
* Required environment variables (set in .env):
27-
* DEPLOYER_PRIVATE_KEY -- private key of the deploying wallet
28-
* ADMIN_ADDRESS -- address that receives all roles (DEFAULT_ADMIN, OPERATOR, UPGRADER)
29-
* CELO_USDT_ADDRESS -- Celo bridged USDT token
30-
* CELO_WBTC_ADDRESS -- Celo bridged WBTC token (8 decimals)
31-
* WSND_ADDRESS -- WaveSend Token (18 decimals)
32-
* UNISWAP_V3_ROUTER -- Uniswap V3 SwapRouter on Celo
3311
*/
3412
contract DeployWaveSendFund is Script {
3513
function run() external {
36-
// Load configuration
14+
// Only load the private key as a standalone variable
3715
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY");
38-
address admin = vm.envAddress("ADMIN_ADDRESS");
39-
address usdt = vm.envAddress("CELO_USDT_ADDRESS");
40-
address wbtc = vm.envAddress("CELO_WBTC_ADDRESS");
41-
address wsnd = vm.envAddress("WSND_ADDRESS");
42-
address router = vm.envAddress("UNISWAP_V3_ROUTER");
4316

44-
uint24 poolFee = uint24(vm.envUint("POOL_FEE"));
45-
uint24 nativeFee = uint24(vm.envUint("NATIVE_FEE"));
46-
uint24 nativeUsdtFee = uint24(vm.envUint("NATIVE_USDT_FEE"));
47-
48-
// FIX: Cast explicitly to int24 (using vm.envInt to handle signed values properly)
49-
int24 poolFeeTickSpacing = int24(vm.envInt("POOL_FEE_TICK_SPACING"));
50-
int24 nativeUsdtFeeTickSpacing = int24(vm.envInt("NATIVE_USDT_FEE_TICK_SPACING"));
17+
// Load all environment variables directly into the struct
18+
// to bypass the "Stack too deep" limit in the EVM.
19+
WaveSendFund.InitParams memory params = WaveSendFund.InitParams({
20+
admin: vm.envAddress("ADMIN_ADDRESS"),
21+
usdt: vm.envAddress("CELO_USDT_ADDRESS"),
22+
wbtc: vm.envAddress("CELO_WBTC_ADDRESS"),
23+
wsnd: vm.envAddress("WSND_ADDRESS"),
24+
router: vm.envAddress("UNISWAP_V3_ROUTER"),
25+
poolFee: uint24(vm.envUint("POOL_FEE")),
26+
poolTickSpacing: int24(vm.envInt("POOL_FEE_TICK_SPACING")),
27+
nativeFee: uint24(vm.envUint("NATIVE_FEE")),
28+
nativeUsdtFee: uint24(vm.envUint("NATIVE_USDT_FEE")),
29+
nativeUsdtTickSpacing: int24(vm.envInt("NATIVE_USDT_FEE_TICK_SPACING"))
30+
});
5131

5232
vm.startBroadcast(deployerPrivateKey);
5333

5434
// 1. Deploy Implementation
5535
WaveSendFund impl = new WaveSendFund();
5636
console.log("Implementation deployed at:", address(impl));
5737

58-
// 2. Package parameters into the struct to bypass "Stack too deep"
59-
WaveSendFund.InitParams memory initParams = WaveSendFund.InitParams({
60-
admin: admin,
61-
usdt: usdt,
62-
wbtc: wbtc,
63-
wsnd: wsnd,
64-
router: router,
65-
poolFee: poolFee,
66-
poolTickSpacing: poolFeeTickSpacing,
67-
nativeFee: nativeFee,
68-
nativeUsdtFee: nativeUsdtFee,
69-
nativeUsdtTickSpacing: nativeUsdtFeeTickSpacing
70-
});
71-
72-
// 3. Encode the call to the initialize function
38+
// 2. Encode the call to the initialize function
7339
bytes memory initData = abi.encodeCall(
7440
WaveSendFund.initialize,
75-
(initParams) // FIX: Pass the struct as the single argument
41+
(params)
7642
);
7743

78-
// 4. Deploy Proxy
44+
// 3. Deploy Proxy
7945
ERC1967Proxy proxyContract = new ERC1967Proxy(address(impl), initData);
8046
WaveSendFund proxy = WaveSendFund(payable(address(proxyContract)));
8147
console.log("Proxy deployed at:", address(proxy));
@@ -85,33 +51,35 @@ contract DeployWaveSendFund is Script {
8551
// ---------------------------------------------------------
8652
// VERIFICATIONS
8753
// ---------------------------------------------------------
54+
// We now reference params.admin, params.usdt, etc., avoiding stack limits
55+
8856
require(
89-
proxy.hasRole(proxy.DEFAULT_ADMIN_ROLE(), admin),
57+
proxy.hasRole(proxy.DEFAULT_ADMIN_ROLE(), params.admin),
9058
"Verify: DEFAULT_ADMIN_ROLE not set"
9159
);
9260
require(
93-
proxy.hasRole(proxy.OPERATOR_ROLE(), admin),
61+
proxy.hasRole(proxy.OPERATOR_ROLE(), params.admin),
9462
"Verify: OPERATOR_ROLE not set"
9563
);
9664
require(
97-
proxy.hasRole(proxy.UPGRADER_ROLE(), admin),
65+
proxy.hasRole(proxy.UPGRADER_ROLE(), params.admin),
9866
"Verify: UPGRADER_ROLE not set"
9967
);
10068
console.log("[OK] Roles assigned to admin");
10169

10270
// Tokens
103-
require(address(proxy.usdt()) == usdt, "Verify: USDT mismatch");
104-
require(address(proxy.wbtc()) == wbtc, "Verify: WBTC mismatch");
105-
require(address(proxy.wsnd()) == wsnd, "Verify: WSND mismatch");
71+
require(address(proxy.usdt()) == params.usdt, "Verify: USDT mismatch");
72+
require(address(proxy.wbtc()) == params.wbtc, "Verify: WBTC mismatch");
73+
require(address(proxy.wsnd()) == params.wsnd, "Verify: WSND mismatch");
10674
console.log("[OK] Token addresses");
10775

10876
// Router & fee
10977
require(
110-
address(proxy.swapRouter()) == router,
78+
address(proxy.swapRouter()) == params.router,
11179
"Verify: router mismatch"
11280
);
113-
require(proxy.poolFee() == poolFee, "Verify: poolFee mismatch");
114-
require(proxy.nativeFee() == nativeFee, "Verify: nativeFee mismatch");
81+
require(proxy.poolFee() == params.poolFee, "Verify: poolFee mismatch");
82+
require(proxy.nativeFee() == params.nativeFee, "Verify: nativeFee mismatch");
11583
console.log("[OK] Router and pool fee");
11684

11785
// Default ratio

0 commit comments

Comments
 (0)