2025-08-13 11:00:45 +02:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
pragma solidity >=0.8.19 <0.9.0;
|
|
|
|
|
|
|
|
|
|
import { BaseScript } from "./Base.s.sol";
|
|
|
|
|
import { TestStableToken } from "../test/TestStableToken.sol";
|
|
|
|
|
import {
|
|
|
|
|
TransparentUpgradeableProxy,
|
|
|
|
|
ITransparentUpgradeableProxy
|
|
|
|
|
} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
|
|
|
|
|
import { ProxyAdmin } from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
|
|
|
|
|
|
|
|
|
|
contract DeployTokenWithProxy is BaseScript {
|
|
|
|
|
function run() public broadcast returns (address proxy, address implementation, address admin) {
|
|
|
|
|
// Deploy the initial implementation
|
|
|
|
|
implementation = address(new TestStableToken());
|
|
|
|
|
|
|
|
|
|
// Deploy proxy admin
|
|
|
|
|
admin = address(new ProxyAdmin());
|
|
|
|
|
|
2025-08-13 11:59:43 +02:00
|
|
|
// Encode the transferOwnership call as initialization data
|
|
|
|
|
bytes memory initData = abi.encodeWithSignature("transferOwnership(address)", broadcaster);
|
2025-08-13 11:00:45 +02:00
|
|
|
|
2025-08-13 11:59:43 +02:00
|
|
|
// Deploy the proxy with initialization data to set ownership
|
|
|
|
|
proxy = address(new TransparentUpgradeableProxy(implementation, admin, initData));
|
2025-08-13 11:55:43 +02:00
|
|
|
|
2025-08-13 11:00:45 +02:00
|
|
|
return (proxy, implementation, admin);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
contract UpdateTokenImplementation is BaseScript {
|
2025-08-13 11:13:12 +02:00
|
|
|
function run(address proxyAddress, address proxyAdminAddress, address newImplementation) public broadcast {
|
|
|
|
|
// Upgrade via ProxyAdmin using the provided implementation address
|
2025-08-13 11:00:45 +02:00
|
|
|
ProxyAdmin(proxyAdminAddress).upgradeAndCall(
|
|
|
|
|
ITransparentUpgradeableProxy(proxyAddress),
|
|
|
|
|
newImplementation,
|
|
|
|
|
""
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|