-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.26; | ||
|
||
import "forge-std/Script.sol"; | ||
import "contracts/evm/ERC20Custody.sol"; | ||
|
||
contract DeployERC20CustodyImplementation is Script { | ||
function run() external { | ||
address expectedImplAddress; | ||
bytes32 implSalt = keccak256("ERC20Custody"); | ||
|
||
vm.startBroadcast(); | ||
|
||
// Compute expected implementation address | ||
expectedImplAddress = vm.computeCreate2Address( | ||
implSalt, | ||
hashInitCode(type(ERC20Custody).creationCode) | ||
); | ||
|
||
// Deploy the implementation contract using CREATE2 | ||
ERC20Custody erc20CustodyImpl = new ERC20Custody{salt: implSalt}(); | ||
require(address(erc20CustodyImpl) != address(0), "erc20CustodyImpl deployment failed"); | ||
require(expectedImplAddress == address(erc20CustodyImpl), "impl address doesn't match expected address"); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.26; | ||
|
||
import "forge-std/Script.sol"; | ||
import "contracts/evm/GatewayEVM.sol"; | ||
|
||
contract DeployGatewayEVM is Script { | ||
function run() external { | ||
address expectedImplAddress; | ||
bytes32 implSalt = keccak256("GatewayEVM"); | ||
|
||
vm.startBroadcast(); | ||
|
||
// Compute expected implementation address | ||
expectedImplAddress = vm.computeCreate2Address( | ||
implSalt, | ||
hashInitCode(type(GatewayEVM).creationCode) | ||
); | ||
|
||
// Deploy the implementation contract using CREATE2 | ||
GatewayEVM gatewayImpl = new GatewayEVM{salt: implSalt}(); | ||
require(address(gatewayImpl) != address(0), "gatewayImpl deployment failed"); | ||
require(expectedImplAddress == address(gatewayImpl), "impl address doesn't match expected address"); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.26; | ||
|
||
import "forge-std/Script.sol"; | ||
import "contracts/zevm/GatewayZEVM.sol"; | ||
|
||
contract DeployGatewayZEVM is Script { | ||
function run() external { | ||
address expectedImplAddress; | ||
bytes32 implSalt = keccak256("GatewayZEVM"); | ||
|
||
vm.startBroadcast(); | ||
|
||
// Compute expected implementation address | ||
expectedImplAddress = vm.computeCreate2Address( | ||
implSalt, | ||
hashInitCode(type(GatewayZEVM).creationCode) | ||
); | ||
|
||
// Deploy the implementation contract using CREATE2 | ||
GatewayZEVM gatewayImpl = new GatewayZEVM{salt: implSalt}(); | ||
require(address(gatewayImpl) != address(0), "gatewayImpl deployment failed"); | ||
require(expectedImplAddress == address(gatewayImpl), "impl address doesn't match expected address"); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.26; | ||
|
||
import "forge-std/console.sol"; | ||
import "forge-std/Script.sol"; | ||
import "contracts/evm/ERC20Custody.sol"; | ||
|
||
contract UpgradeSimulation is Script { | ||
function run() external { | ||
// Forked environment | ||
address proxyAddress = vm.envAddress("PROXY_ADDRESS"); | ||
address adminAddress = vm.envAddress("ADMIN_ADDRESS"); | ||
|
||
// Deploy the new implementation contract | ||
bytes32 implSalt = keccak256("ERC20Custody"); | ||
address erc20CustodyImpl = address(new ERC20Custody{salt: implSalt}()); | ||
|
||
ERC20Custody proxy = ERC20Custody(proxyAddress); | ||
|
||
// Get the current state | ||
address gateway = proxy.gateway(); | ||
address tssAddress = proxy.tssAddress(); | ||
bool supportsLegacy = proxy.supportsLegacy(); | ||
|
||
// Simulate the upgrade | ||
vm.prank(adminAddress); | ||
proxy.upgradeToAndCall(erc20CustodyImpl, ""); | ||
|
||
// After upgrade, verify that the state is intact | ||
require(gateway == proxy.gateway(), "gateway address mismatch"); | ||
require(tssAddress == proxy.tssAddress(), "tss address mismatch"); | ||
require(supportsLegacy == proxy.supportsLegacy(), "supportsLegacy mismatch"); | ||
|
||
console.log("Upgraded contract state:"); | ||
console.log("gateway address:", address(proxy.gateway())); | ||
console.log("tss address:", proxy.tssAddress()); | ||
console.log("supportsLegacy address:", proxy.supportsLegacy()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.26; | ||
|
||
import "forge-std/console.sol"; | ||
import "forge-std/Script.sol"; | ||
import "contracts/evm/GatewayEVM.sol"; | ||
|
||
contract UpgradeSimulation is Script { | ||
function run() external { | ||
// Forked environment | ||
address proxyAddress = vm.envAddress("PROXY_ADDRESS"); | ||
address adminAddress = vm.envAddress("ADMIN_ADDRESS"); | ||
|
||
// Deploy the new implementation contract | ||
bytes32 implSalt = keccak256("GatewayEVM"); | ||
address gatewayImpl = address(new GatewayEVM{salt: implSalt}()); | ||
|
||
GatewayEVM proxy = GatewayEVM(proxyAddress); | ||
|
||
// Get the current state | ||
address custody = proxy.custody(); | ||
address tssAddress = proxy.tssAddress(); | ||
address zetaConnector = proxy.zetaConnector(); | ||
address zetaToken = proxy.zetaToken(); | ||
|
||
// Simulate the upgrade | ||
vm.prank(adminAddress); | ||
proxy.upgradeToAndCall(gatewayImpl, ""); | ||
|
||
// After upgrade, verify that the state is intact | ||
require(custody == proxy.custody(), "custody address mismatch"); | ||
require(tssAddress == proxy.tssAddress(), "tss address mismatch"); | ||
require(zetaConnector == proxy.zetaConnector(), "zetaConnector address mismatch"); | ||
require(zetaToken == proxy.zetaToken(), "zetaToken address mismatch"); | ||
|
||
console.log("Upgraded contract state:"); | ||
console.log("custody address:", proxy.custody()); | ||
console.log("tss address:", proxy.tssAddress()); | ||
console.log("zetaConnector address:", proxy.zetaConnector()); | ||
console.log("zetaToken address:", proxy.zetaToken()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.26; | ||
|
||
import "forge-std/console.sol"; | ||
import "forge-std/Script.sol"; | ||
import "contracts/zevm/GatewayZEVM.sol"; | ||
|
||
contract UpgradeSimulation is Script { | ||
function run() external { | ||
// Forked environment | ||
address payable proxyAddress = payable(vm.envAddress("PROXY_ADDRESS")); | ||
address adminAddress = vm.envAddress("ADMIN_ADDRESS"); | ||
|
||
// Deploy the new implementation contract | ||
bytes32 implSalt = keccak256("GatewayZEVM"); | ||
address gatewayImpl = address(new GatewayZEVM{salt: implSalt}()); | ||
|
||
GatewayZEVM proxy = GatewayZEVM(proxyAddress); | ||
|
||
// Get the current state | ||
address zetaToken = proxy.zetaToken(); | ||
|
||
// Simulate the upgrade | ||
vm.prank(adminAddress); | ||
proxy.upgradeToAndCall(gatewayImpl, ""); | ||
|
||
// After upgrade, verify that the state is intact | ||
require(zetaToken == proxy.zetaToken(), "zetaToken address mismatch"); | ||
|
||
console.log("Upgraded contract state:"); | ||
console.log("zetaToken address:", proxy.zetaToken()); | ||
} | ||
} |