Skip to content

Commit 1e774df

Browse files
committed
chore: flag to overwrite CREATE2 address for EVM
1 parent 8ae04b4 commit 1e774df

File tree

3 files changed

+31
-15
lines changed

3 files changed

+31
-15
lines changed

sh/deployNttManagerWithExecutor.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,19 @@ if [ "${EVM_CHAIN_ID}X" == "X" ]; then
2424
EVM_CHAIN_ID=1337
2525
fi
2626

27+
if [ -n "${CREATE2_ADDRESS}" ]; then
28+
CREATE2_FLAG="--create2-deployer ${CREATE2_ADDRESS}"
29+
echo "Using custom CREATE2 deployer at: ${CREATE2_ADDRESS}"
30+
else
31+
CREATE2_FLAG=""
32+
echo "Using default CREATE2 deployer"
33+
fi
34+
2735
forge script ./script/DeployNttManagerWithExecutor.s.sol:DeployNttManagerWithExecutor \
2836
--sig "run(uint16,address)" $OUR_CHAIN_ID $EXECUTOR \
2937
--rpc-url "$RPC_URL" \
3038
--private-key "$MNEMONIC" \
39+
$CREATE2_FLAG \
3140
--broadcast ${FORGE_ARGS}
3241

3342
returnInfo=$(cat ./broadcast/DeployNttManagerWithExecutor.s.sol/$EVM_CHAIN_ID/run-latest.json)

src/NttManagerWithExecutor.sol

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ contract NttManagerWithExecutor is INttManagerWithExecutor {
5757

5858
// Initiate the transfer.
5959
SafeERC20.safeApprove(IERC20(token), nttManager, amount);
60-
msgId = nttm.transfer{value: msg.value - executorArgs.value}(
61-
amount, recipientChain, recipientAddress, refundAddress, false, encodedInstructions
62-
);
60+
msgId = nttm.transfer{
61+
value: msg.value - executorArgs.value
62+
}(amount, recipientChain, recipientAddress, refundAddress, false, encodedInstructions);
6363

6464
// Generate the executor event.
65-
executor.requestExecution{value: executorArgs.value}(
65+
executor.requestExecution{
66+
value: executorArgs.value
67+
}(
6668
recipientChain,
6769
nttm.getPeer(recipientChain).peerAddress,
6870
executorArgs.refundAddress,

test/NttManagerWithExecutor.t.sol

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ contract MockExecutor is Executor {
4848
}
4949

5050
// NOTE: This was copied from the tests in the executor repo.
51-
function encodeSignedQuoteHeader(Executor.SignedQuoteHeader memory signedQuote)
52-
public
53-
pure
54-
returns (bytes memory)
55-
{
51+
function encodeSignedQuoteHeader(Executor.SignedQuoteHeader memory signedQuote) public pure returns (bytes memory) {
5652
return abi.encodePacked(
5753
signedQuote.prefix,
5854
signedQuote.quoterAddress,
@@ -118,7 +114,12 @@ contract MockTransceiver is Transceiver {
118114
function _quoteDeliveryPrice(
119115
uint16, /* recipientChain */
120116
TransceiverStructs.TransceiverInstruction memory /* transceiverInstruction */
121-
) internal pure override returns (uint256) {
117+
)
118+
internal
119+
pure
120+
override
121+
returns (uint256)
122+
{
122123
return 0;
123124
}
124125

@@ -217,9 +218,9 @@ contract TestNttManagerWithExecutor is Test {
217218
vm.startPrank(user_A);
218219
token.approve(address(nttManager), 3 * 10 ** decimals);
219220

220-
uint64 s1 = nttManager.transfer{value: 10000}(
221-
1 * 10 ** decimals, chainId2, toWormholeFormat(user_B), toWormholeFormat(user_A), false, new bytes(1)
222-
);
221+
uint64 s1 = nttManager.transfer{
222+
value: 10000
223+
}(1 * 10 ** decimals, chainId2, toWormholeFormat(user_B), toWormholeFormat(user_A), false, new bytes(1));
223224

224225
assertEq(s1, 0);
225226
}
@@ -248,7 +249,9 @@ contract TestNttManagerWithExecutor is Test {
248249

249250
ExecutorArgs memory executorArgs = executor.createArgs(chainId2, 100);
250251
FeeArgs memory feeArgs = FeeArgs({dbps: dbps, payee: referrer});
251-
uint64 s1 = nttManagerWithExecutor.transfer{value: 10000}(
252+
uint64 s1 = nttManagerWithExecutor.transfer{
253+
value: 10000
254+
}(
252255
address(nttManager),
253256
amount,
254257
chainId2,
@@ -286,7 +289,9 @@ contract TestNttManagerWithExecutor is Test {
286289

287290
ExecutorArgs memory executorArgs = executor.createArgs(chainId2, 100);
288291
FeeArgs memory feeArgs = FeeArgs({dbps: 1, payee: referrer});
289-
uint64 s1 = nttManagerWithExecutor.transfer{value: 10000}(
292+
uint64 s1 = nttManagerWithExecutor.transfer{
293+
value: 10000
294+
}(
290295
address(nttManagerNoRateLimiting),
291296
amount,
292297
chainId2,

0 commit comments

Comments
 (0)