Skip to content

Commit 94861d4

Browse files
authoredMar 14, 2025··
Upgrade gateway on Sepolia for westend (#1407)
* Log gateway codehash * Upgrade Gateway on Westend-Sepolia
1 parent a2ad606 commit 94861d4

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed
 

‎contracts/scripts/DeployLocalGatewayLogic.sol

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {Gateway} from "../src//Gateway.sol";
77
import {ParaID} from "../src//Types.sol";
88
import {Script} from "forge-std/Script.sol";
99
import {stdJson} from "forge-std/StdJson.sol";
10+
import {console} from "forge-std/console.sol";
1011

1112
contract DeployLocalGatewayLogic is Script {
1213
using stdJson for string;
@@ -28,7 +29,7 @@ contract DeployLocalGatewayLogic is Script {
2829

2930
AgentExecutor executor = new AgentExecutor();
3031

31-
new Gateway(
32+
Gateway gatewayLogic = new Gateway(
3233
address(beefyClient),
3334
address(executor),
3435
bridgeHubParaID,
@@ -37,6 +38,10 @@ contract DeployLocalGatewayLogic is Script {
3738
maxDestinationFee
3839
);
3940

41+
console.log("Gateway contract address: %s", address(gatewayLogic));
42+
console.log("Gateway contract codehash:");
43+
console.logBytes32(address(gatewayLogic).codehash);
44+
4045
vm.stopBroadcast();
4146
}
4247
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
3+
pragma solidity 0.8.28;
4+
5+
import {AgentExecutor} from "../../../src/AgentExecutor.sol";
6+
import {Gateway20250311} from "../../../src/upgrades/westend/Gateway20250311.sol";
7+
import {ParaID} from "../../../src/Types.sol";
8+
import {Script} from "forge-std/Script.sol";
9+
import {stdJson} from "forge-std/StdJson.sol";
10+
import {console} from "forge-std/console.sol";
11+
12+
contract DeployGateway20250311 is Script {
13+
using stdJson for string;
14+
15+
function setUp() public {}
16+
17+
function run() public {
18+
uint256 privateKey = vm.envUint("PRIVATE_KEY");
19+
address deployer = vm.rememberKey(privateKey);
20+
vm.startBroadcast(deployer);
21+
22+
address beefyClient = vm.envAddress("BEEFY_CLIENT_CONTRACT_ADDRESS");
23+
24+
ParaID bridgeHubParaID = ParaID.wrap(uint32(vm.envUint("BRIDGE_HUB_PARAID")));
25+
bytes32 bridgeHubAgentID = vm.envBytes32("BRIDGE_HUB_AGENT_ID");
26+
27+
uint8 foreignTokenDecimals = uint8(vm.envUint("FOREIGN_TOKEN_DECIMALS"));
28+
uint128 maxDestinationFee = uint128(vm.envUint("RESERVE_TRANSFER_MAX_DESTINATION_FEE"));
29+
30+
AgentExecutor executor = new AgentExecutor();
31+
32+
Gateway20250311 gatewayLogic = new Gateway20250311(
33+
address(beefyClient),
34+
address(executor),
35+
bridgeHubParaID,
36+
bridgeHubAgentID,
37+
foreignTokenDecimals,
38+
maxDestinationFee
39+
);
40+
41+
console.log("Gateway contract address: %s", address(gatewayLogic));
42+
console.log("Gateway contract codehash:");
43+
console.logBytes32(address(gatewayLogic).codehash);
44+
45+
vm.stopBroadcast();
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
3+
pragma solidity 0.8.28;
4+
5+
import "../../Gateway.sol";
6+
7+
// New `Gateway` logic contract with updated Token contract
8+
contract Gateway20250311 is Gateway {
9+
constructor(
10+
address beefyClient,
11+
address agentExecutor,
12+
ParaID bridgeHubParaID,
13+
bytes32 bridgeHubAgentID,
14+
uint8 foreignTokenDecimals,
15+
uint128 destinationMaxTransferFee
16+
)
17+
Gateway(
18+
beefyClient,
19+
agentExecutor,
20+
bridgeHubParaID,
21+
bridgeHubAgentID,
22+
foreignTokenDecimals,
23+
destinationMaxTransferFee
24+
)
25+
{}
26+
27+
// Override parent initializer to prevent re-initialization of storage.
28+
function initialize(bytes memory) external override {
29+
// Ensure that arbitrary users cannot initialize storage in this logic contract.
30+
if (ERC1967.load() == address(0)) {
31+
revert Unauthorized();
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)
Please sign in to comment.